New development branch with e.g. rendering state machine and a simple Qt example application using it. new development branch with rendering state machine and other goodies
authorsamhuttu
Mon, 01 Nov 2010 12:37:49 +0200
branchnew development branch with rendering state machine and other goodies
changeset 38 5360b7ddc251
parent 32 3785f754ee62
child 39 6369bfd1b60d
New development branch with e.g. rendering state machine and a simple Qt example application using it.
dlnasrv_plat/group/bld.inf
dlnasrv_plat/upnp_media_server_metadata_api/inc/upnpfilesharing.h
group/bld.inf
group/upnpplatformvar.hrh
layers.sysdef.xml
package_definition.xml
upnpavcontroller/group/bld.inf
upnpavcontroller/upnpavcontrollerclient/bwins/upnpavcontrollerclientu.def
upnpavcontroller/upnpavcontrollerclient/eabi/upnpavcontrollerclientu.def
upnpavcontroller/upnpavcontrollerclient/group/upnpavcontrollerclient.mmp
upnpavcontroller/upnpavcontrollerclient/inc/upnpavbrowsingsessionimpl.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavbrowsingsessionobserver.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontroller.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrolleractive.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrollerclient.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrollerfactory.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrollerglobals.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavdevice.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavdeviceobserver.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingactive.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingsession.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingsessionimpl.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingsessionobserver.h
upnpavcontroller/upnpavcontrollerclient/inc/upnpavsessionbase.h
upnpavcontroller/upnpavcontrollerclient/src/upnpavbrowsingsessionimpl.cpp
upnpavcontroller/upnpavcontrollerclient/src/upnpavconnectionactive.cpp
upnpavcontroller/upnpavcontrollerclient/src/upnpavcontrolleractive.cpp
upnpavcontroller/upnpavcontrollerclient/src/upnpavcontrollerclient.cpp
upnpavcontroller/upnpavcontrollerclient/src/upnpavcontrollerfactory.cpp
upnpavcontroller/upnpavcontrollerclient/src/upnpavdevice.cpp
upnpavcontroller/upnpavcontrollerclient/src/upnpavrenderingactive.cpp
upnpavcontroller/upnpavcontrollerclient/src/upnpavrenderingsessionimpl.cpp
upnpavcontroller/upnpavcontrollerclient/src/upnpfiledownloadsessionimpl.cpp
upnpavcontroller/upnpavcontrollerclient/src/upnpfileuploadsessionimpl.cpp
upnpavcontroller/upnpavcontrollerhelper/bwins/upnpavcontrollerhelperu.def
upnpavcontroller/upnpavcontrollerhelper/eabi/upnpavcontrollerhelperu.def
upnpavcontroller/upnpavcontrollerhelper/group/upnpavcontrollerhelper.mmp
upnpavcontroller/upnpavcontrollerhelper/inc/upnpabstractbrowsingsessionobserver.h
upnpavcontroller/upnpavcontrollerhelper/inc/upnpabstractrenderingsessionobserver.h
upnpavcontroller/upnpavcontrollerhelper/inc/upnpconstantdefs.h
upnpavcontroller/upnpavcontrollerhelper/inc/upnpdlnautility.h
upnpavcontroller/upnpavcontrollerhelper/inc/upnpdownloaditemresolver.h
upnpavcontroller/upnpavcontrollerhelper/inc/upnpitemresolver.h
upnpavcontroller/upnpavcontrollerhelper/inc/upnplocalitemresolver.h
upnpavcontroller/upnpavcontrollerhelper/inc/upnpremoteitemresolver.h
upnpavcontroller/upnpavcontrollerhelper/src/upnpabstractbrowsingsessionobserver.cpp
upnpavcontroller/upnpavcontrollerhelper/src/upnpabstractrenderingsessionobserver.cpp
upnpavcontroller/upnpavcontrollerhelper/src/upnpdlnautility.cpp
upnpavcontroller/upnpavcontrollerhelper/src/upnpdownloaditemresolver.cpp
upnpavcontroller/upnpavcontrollerhelper/src/upnpfileutility.cpp
upnpavcontroller/upnpavcontrollerhelper/src/upnpinternalfileutility.cpp
upnpavcontroller/upnpavcontrollerhelper/src/upnpitemresolverfactory.cpp
upnpavcontroller/upnpavcontrollerhelper/src/upnpitemutility.cpp
upnpavcontroller/upnpavcontrollerhelper/src/upnplocalitemresolver.cpp
upnpavcontroller/upnpavcontrollerhelper/src/upnpremoteitemresolver.cpp
upnpavcontroller/upnpavcontrollerhelper/src/upnpresourceselector.cpp
upnpavcontroller/upnpavcontrollerserver/group/upnpavcontrollerserver.mmp
upnpavcontroller/upnpavcontrollerserver/inc/upnpavcontrollerimpl.h
upnpavcontroller/upnpavcontrollerserver/inc/upnpavcontrollerserver.h
upnpavcontroller/upnpavcontrollerserver/inc/upnpavcontrollersession.h
upnpavcontroller/upnpavcontrollerserver/inc/upnpavdeviceextended.h
upnpavcontroller/upnpavcontrollerserver/inc/upnpavdispatcher.h
upnpavcontroller/upnpavcontrollerserver/inc/upnpavtimer.h
upnpavcontroller/upnpavcontrollerserver/inc/upnpbrowsingsession.h
upnpavcontroller/upnpavcontrollerserver/inc/upnpdevicerepository.h
upnpavcontroller/upnpavcontrollerserver/inc/upnpfiletransfersessionbase.h
upnpavcontroller/upnpavcontrollerserver/inc/upnpplaybacksession.h
upnpavcontroller/upnpavcontrollerserver/inc/upnpuploadsession.h
upnpavcontroller/upnpavcontrollerserver/src/upnpavcontrollerimpl.cpp
upnpavcontroller/upnpavcontrollerserver/src/upnpavcontrollerserver.cpp
upnpavcontroller/upnpavcontrollerserver/src/upnpavcontrollersession.cpp
upnpavcontroller/upnpavcontrollerserver/src/upnpavdeviceextended.cpp
upnpavcontroller/upnpavcontrollerserver/src/upnpavdispatcher.cpp
upnpavcontroller/upnpavcontrollerserver/src/upnpbrowsingsession.cpp
upnpavcontroller/upnpavcontrollerserver/src/upnpdevicerepository.cpp
upnpavcontroller/upnpavcontrollerserver/src/upnpdownloadsession.cpp
upnpavcontroller/upnpavcontrollerserver/src/upnpfiletransfersessionbase.cpp
upnpavcontroller/upnpavcontrollerserver/src/upnpplaybacksession.cpp
upnpavcontroller/upnpavcontrollerserver/src/upnpuploadsession.cpp
upnpavcontroller/upnpxmlparser/bwins/upnpxmlparseru.def
upnpavcontroller/upnpxmlparser/eabi/upnpxmlparseru.def
upnpavcontroller/upnpxmlparser/group/bld.inf
upnpavcontroller/upnpxmlparser/group/upnpxmlparser.mmp
upnpavcontroller/upnpxmlparser/inc/upnpitemtoxml.h
upnpavcontroller/upnpxmlparser/inc/upnpxmleventparser.h
upnpavcontroller/upnpxmlparser/inc/upnpxmlparser.h
upnpavcontroller/upnpxmlparser/inc/upnpxmlparserlite.h
upnpavcontroller/upnpxmlparser/src/upnpcontainertoxml.cpp
upnpavcontroller/upnpxmlparser/src/upnpitemtoxml.cpp
upnpavcontroller/upnpxmlparser/src/upnpxmleventparser.cpp
upnpavcontroller/upnpxmlparser/src/upnpxmlparser.cpp
upnpavcontroller/upnpxmlparser/src/upnpxmlparserlite.cpp
upnpframework/group/bld.inf
upnpframework/inc/upnplog.h
upnpframework/loc/upnpframework.loc
upnpframework/upnpcommand/data/upnpcommandresources.rss
upnpframework/upnpcommand/group/bld.inf
upnpframework/upnpcommand/group/upnpcommandplugin.mmp
upnpframework/upnpcommand/inc/upnpcommand.h
upnpframework/upnpcommand/inc/upnpimagerenderingengine.h
upnpframework/upnpcommand/inc/upnpimagerenderingengineobserver.h
upnpframework/upnpcommand/inc/upnpnotehandler.h
upnpframework/upnpcommand/inc/upnpshowtask.h
upnpframework/upnpcommand/inc/upnptaskresourceallocator.h
upnpframework/upnpcommand/src/upnpbrowsecommand.cpp
upnpframework/upnpcommand/src/upnpcommandcallbackadapter.cpp
upnpframework/upnpcommand/src/upnpcommandimplementation.cpp
upnpframework/upnpcommand/src/upnpcommandparameters.cpp
upnpframework/upnpcommand/src/upnpcopycommand.cpp
upnpframework/upnpcommand/src/upnpcopytask.cpp
upnpframework/upnpcommand/src/upnpfiletransferbasetask.cpp
upnpframework/upnpcommand/src/upnpimagerenderingengine.cpp
upnpframework/upnpcommand/src/upnpmovecommand.cpp
upnpframework/upnpcommand/src/upnpmovetask.cpp
upnpframework/upnpcommand/src/upnpnotehandler.cpp
upnpframework/upnpcommand/src/upnprunsetupcommand.cpp
upnpframework/upnpcommand/src/upnpshowcommand.cpp
upnpframework/upnpcommand/src/upnpshowtask.cpp
upnpframework/upnpcommand/src/upnptaskresourceallocator.cpp
upnpframework/upnpfiletransferengine/group/upnpfiletransferengine.mmp
upnpframework/upnpmusicadapter/src/upnpalbumservices.cpp
upnpframework/upnputilities/BWINS/upnputilitiesU.DEF
upnpframework/upnputilities/EABI/upnputilitiesU.DEF
upnpframework/upnputilities/group/bld.inf
upnpframework/upnputilities/group/upnputilities.mmp
upnpframework/upnputilities/inc/upnpcommonutils.h
upnpframework/upnputilities/inc/upnpconnectionmonitor.h
upnpframework/upnputilities/inc/upnpconnectionmonitorobserver.h
upnpframework/upnputilities/inc/upnpfileutilitytypes.h
upnpframework/upnputilities/inc/upnpmetadatafetcher.h
upnpframework/upnputilities/src/upnpcdsreselementutility.cpp
upnpframework/upnputilities/src/upnpcommonutils.cpp
upnpframework/upnputilities/src/upnpconnectionmonitor.cpp
upnpframework/upnputilities/src/upnpmetadatafetcher.cpp
upnpframework/upnputilities/src/upnpmetadatautility.cpp
upnpmediaserver/avobjects/src/upnpdlnaprotocolinfo.cpp
upnpmediaserver/avobjects/src/upnpitem.cpp
upnpmediaserver/contentdirectoryservice/BWINS/AVContentDirectoryU.DEF
upnpmediaserver/contentdirectoryservice/EABI/AVContentDirectoryU.DEF
upnpmediaserver/contentdirectoryservice/group/bld.inf
upnpmediaserver/contentdirectoryservice/group/contentdirectoryservice.mmp
upnpmediaserver/contentdirectoryservice/inc/dlna/upnpdlnafilter.h
upnpmediaserver/contentdirectoryservice/inc/upnpcdutils.h
upnpmediaserver/contentdirectoryservice/inc/upnpcontentdirectory.h
upnpmediaserver/contentdirectoryservice/inc/upnpcontentdirectorydb.h
upnpmediaserver/contentdirectoryservice/inc/upnpcontentdirectoryglobals.h
upnpmediaserver/contentdirectoryservice/inc/upnpelementfactory.h
upnpmediaserver/contentdirectoryservice/inc/upnpmetadatastorage.h
upnpmediaserver/contentdirectoryservice/inc/upnpmspathutility.h
upnpmediaserver/contentdirectoryservice/inc/upnpobjectbean.h
upnpmediaserver/contentdirectoryservice/inc/upnpxmlcontentfilter.h
upnpmediaserver/contentdirectoryservice/src/dlna/upnpdlnafilter.cpp
upnpmediaserver/contentdirectoryservice/src/dlna/upnphttpfilereceivetransaction.cpp
upnpmediaserver/contentdirectoryservice/src/upnpattributebean.cpp
upnpmediaserver/contentdirectoryservice/src/upnpcdutils.cpp
upnpmediaserver/contentdirectoryservice/src/upnpcontentdirectory.cpp
upnpmediaserver/contentdirectoryservice/src/upnpcontentdirectorydb.cpp
upnpmediaserver/contentdirectoryservice/src/upnpelementbean.cpp
upnpmediaserver/contentdirectoryservice/src/upnpelementfactory.cpp
upnpmediaserver/contentdirectoryservice/src/upnperror.cpp
upnpmediaserver/contentdirectoryservice/src/upnplocalstorage.cpp
upnpmediaserver/contentdirectoryservice/src/upnpmetadatastorage.cpp
upnpmediaserver/contentdirectoryservice/src/upnpmspathutility.cpp
upnpmediaserver/contentdirectoryservice/src/upnpstatehandler.cpp
upnpmediaserver/contentdirectoryservice/src/upnpxmlcontentfilter.cpp
upnpmediaserver/group/bld.inf
upnpmediaserver/mediaserverengine/src/upnpmediaserver.cpp
upnpsettings/group/bld.inf
upnpsettings/loc/upnpsettings.loc
upnpsettings/upnpsettingsengine/cenrep/20009CAE.txt
upnpsettings/upnpsettingsengine/group/bld.inf
upnpsettings/upnpsettingsengine/group/upnpsettingsengine.mmp
upnpsettings/upnpsettingsengine/inc/upnpapplicationcrkeys.h
upnpsettings/upnpsettingsengine/inc/upnpsettingsengine.h
upnpsettings/upnpsettingsengine/src/upnpsettingsengine.cpp
upnpsharing/group/bld.inf
upnpsharing/loc/upnpsharing.loc
upnpsharing/upnpcontentserver/group/bld.inf
upnpsharing/upnpcontentserver/group/upnpcontentserver.mmp
upnpsharing/upnpcontentserver/inc/upnpcontentmetadatautility.h
upnpsharing/upnpcontentserver/inc/upnpcontentserver.h
upnpsharing/upnpcontentserver/inc/upnpcontentserverhandler.h
upnpsharing/upnpcontentserver/inc/upnpselectionreader.h
upnpsharing/upnpcontentserver/inc/upnpselectionwriter.h
upnpsharing/upnpcontentserver/inc/upnpsharingcallback.h
upnpsharing/upnpcontentserver/inc/upnpsharingrequest.h
upnpsharing/upnpcontentserver/src/upnpcontentmetadatautility.cpp
upnpsharing/upnpcontentserver/src/upnpcontentserver.cpp
upnpsharing/upnpcontentserver/src/upnpcontentserverclient.cpp
upnpsharing/upnpcontentserver/src/upnpcontentserverhandler.cpp
upnpsharing/upnpcontentserver/src/upnpcontentserversession.cpp
upnpsharing/upnpcontentserver/src/upnpselectionreader.cpp
upnpsharing/upnpcontentserver/src/upnpselectionwriter.cpp
upnpsharing/upnpcontentserver/src/upnpsharingrequest.cpp
upnpsharing/upnpdlnaprofiler/group/dlnaprofiler.mmp
upnpsharing/upnpdlnaprofiler/inc/upnpavsolverbase.h
upnpsharing/upnpdlnaprofiler/inc/upnpresresolver.h
upnpsharing/upnpdlnaprofiler/src/upnpaudiosolverbase.cpp
upnpsharing/upnpdlnaprofiler/src/upnpavsolverbase.cpp
upnpsharing/upnpdlnaprofiler/src/upnpimagesolverbase.cpp
upnpsharing/upnpdlnaprofiler/src/upnpresresolver.cpp
upnpsharing/upnpsecurity/group/upnpsecuritymanagerplugin.mmp
upnpsharing/upnpsecurity/inc/server/upnpauthorizationnote.h
--- a/dlnasrv_plat/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/dlnasrv_plat/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,33 +1,24 @@
-/** @file
-* Copyright (c) 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:  
-*
-*/
-
-
-
-
-#include "../upnp_media_server_settings_api/group/bld.inf"
-
-#include "../upnp_av_objects_api/group/bld.inf"
-#include "../upnp_media_server_api/group/bld.inf"
-#include "../upnp_security_plugin_api/group/bld.inf"
-#include "../upnp_avcp_api/group/bld.inf"
-#
-#include "../upnp_media_server_metadata_api/group/bld.inf"
-
-#include "../upnp_command_api/group/bld.inf"
-#include "../upnp_plugin_api/group/bld.inf"
-
-
+/** @file
+* Copyright (c) 2006-2008 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:  
+*
+*/
+
+#include "../upnp_media_server_settings_api/group/bld.inf"
+#include "../upnp_av_objects_api/group/bld.inf"
+#include "../upnp_media_server_api/group/bld.inf"
+#include "../upnp_security_plugin_api/group/bld.inf"
+#include "../upnp_media_server_metadata_api/group/bld.inf"
+#include "../upnp_command_api/group/bld.inf"
+#include "../upnp_plugin_api/group/bld.inf"
--- a/dlnasrv_plat/upnp_media_server_metadata_api/inc/upnpfilesharing.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/dlnasrv_plat/upnp_media_server_metadata_api/inc/upnpfilesharing.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,314 +1,314 @@
-/** @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:  File sharing interface class
-*
-*/
-
-
-#ifndef C_CUPNPFILESHARING_H
-#define C_CUPNPFILESHARING_H
-
-#include <e32base.h>
-#include "upnpobject.h"
-
-// FORWARD DECLARATIONS
-class CUpnpFileSharingBody;
-class CUpnpItem;
-class CUpnpContainer;
-class CUpnpBrowseCriteria;
-class CUpnpItemList;
-class CUpnpContainerList;
-class RUpnpMediaServerClient;
-/**
- *  Interface class for UPnP File Sharing
- *
- *  @lib MediaServerClient.lib
- *  @since S60 v3.1
- */
-class CUpnpFileSharing : public CBase
-    {
-
-public:
-    
-    /**
-    * Two-phased constructor.
-    */
-    IMPORT_C static CUpnpFileSharing* NewL();
-    
-    /**
-    * Destructor.
-    */
-    virtual ~CUpnpFileSharing();
-
-public:     // Interface methods
-    /**
-    * Database Clearing function
-    * Stops mediaserver, delete database file and starts mediaserver
-    *
-    * @since S60 3.1
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void DropAllContentL(TRequestStatus& aStatus);
-    
-    /**
-    * Shares a single item asynchronously to Media Server.
-    * Symbian data base doesn't support foreign key constraints. In order to avoid  
-    * adding item with nonexistent parent container, parent id existence is checked 
-    * by Media Server. 
-    * The item is created with parent id passed as an argument to this operation 
-    * (object field iParentId value is ignored). 
-    * After creation input object is updated with:
-    * - iId - generated object identifier
-    * - "res" element value - in offline sharing there is no possible to set ip:port 
-    *    information in URL. "Res" value example: http:///00000001/filename. 
-    *    For consistency the same approach will be used in online mode.
-    *
-    * @since S60 3.1
-    * @param aContainerId information to which container the item is shared.
-    * @param aItem reference to item which is shared.
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void ShareItemL( const TDesC8& aContainerId, 
-                              CUpnpItem& aItem,
-                              TRequestStatus& aStatus ); 
-
-    /**
-    * Shares a single container asynchronously to Media Server.
-    * Nested container and items are ignored.  The container is created with parent id 
-    * passed as an argument to this operation (object field iParentId value is ignored). 
-    * Parent id existence is checked by Media Server. 
-    * After creation input object is updated with the current:
-    * - iId
-    *
-    * @since S60 3.1
-    * @param aContainerId information to which container the item is shared.
-    * @param aContainer reference to container which is shared.
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void ShareContainerL( const TDesC8& aParentId, 
-                                   CUpnpContainer& aContainer,
-                                   TRequestStatus& aStatus ); 
-    
-    /**
-    * Shares a list of items asynchronously to Media Server. 
-    * Each CUpnpItem of CUpnpItemList is created with the same parent id passed as 
-    * an argument to this operation (object field iParentId value is ignored). 
-    * Parent id existence is checked by Media Server - only once for this operation. 
-    * Database transaction is committed each 11 objects created into database. 
-    * This empirical value is hard coded in current implementation. 
-    * If an execution of task fails when creating object (e.g. 776-th item on list) 
-    * error code is retuned (aExecStatus), which points to last successfully created item index [1...total count] 
-    * (e.g. aExecutionStatus = 770 last item in database is object number 770, 
-    * if no object is cretated index = 0, if all are created index = total count).
-    *
-    * Note: There is no support for chunked operations (splitting long operation 
-    * into sequence of asynchronical calls). Each operation is atomic from 
-    * Media Server Engine perspective. Long lasting operations may block Media Server Engine. 
-    * In such case switching Media Server to offline mode is recommended.
-    *
-    * For each created item respective input object is updated with:
-    * - iId
-    * - "res" element value
-    *
-    * @since S60 3.1
-    * @param aContainerId information to which container the item is shared.
-    * @param aItemList reference to item list which are to be shared.
-    * @param aExecStatus reference pointing to the index of item list
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void ShareItemListL( const TDesC8& aContainerId, 
-                                  CUpnpItemList& aItemList,
-                                  TInt& aExecStatus,
-                                  TRequestStatus& aStatus ); 
-                                    
-    /**
-    * Unshares existing item from the Media Server.
-    * Item with specified id is removed from database regardless "restricted" property value.
-    * Note: This method removes uploaded file associated with item being destroyed. 
-    *       Shared files are never removed.
-    *       
-    *
-    * @since S60 3.1
-    * @param aItemId item which is unshared
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void UnshareItemL( TInt aItemId,
-                                TRequestStatus& aStatus);
-       
-     
-    /**
-    * Unshares existing container from the Media Server.
-    * Container with its whole branch is removed from database regardless "restricted" 
-    * property value for this container and any object in branch.
-    * Object removing is a bottom-up process. If removing of particular object fails 
-    * whole operation is broken and error is returned. 
-    *
-    * Note: This method removes uploaded file associated with item being destroyed. 
-    *       Shared files are never removed.
-    *
-    * Note: The iId value is not verified whether it points to a container or item. 
-    * Therefore, clients must not use UnshareContainer method with ids pointing to an 
-    * item or other way round. 
-    *    
-    * @since S60 3.1
-    * @param aContainerId container which is unshared
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void UnshareContainerL( TInt aItemId,
-                                     TRequestStatus& aStatus );
-     
-    /**
-    * Unshares existing items from the MediaServer.
-    * Each Item from list is removed from database regardless "restricted" property value.
-    * Database transaction is committed each 11 objects removed database. 
-    * If an execution of task fails when creating object error code is retuned, 
-    * which points to last successfully removed item index.
-    *
-    * Note: This method removes uploaded file associated with item being destroyed. 
-    *       Shared files are never removed.
-    *
-    * @since S60 3.1
-    * @param aItemList list of items which are to be unshared
-    * @param aExecStatus reference pointing to the index of item list    
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void UnshareItemListL( CUpnpItemList& aItemList,
-                                TInt& aExecStatus,
-                                TRequestStatus& aStatus);
-
-    /**
-    * Gets shared item information from MediaServer. 
-    * This operation returns all properties. Browse criteria is not used.
-    * Information is returned to item reference.
-    *
-    * @since S60 3.1
-    * @param aItemId item id
-    * @param aItem reference to item where information is updated.
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void GetSharedItemL( TInt aItemId,
-                                  CUpnpItem& aItem,
-                                  TRequestStatus& aStatus );
-    
-    
-    /**
-    * Gets shared container information from Media Server. 
-    * Nested container and items are not returned.
-    * This operation returns all properties. Browse criteria is not used.
-    * Information is returned to container reference.
-    *
-    * @since S60 3.1
-    * @param aContainerId container id
-    * @param aContainer reference to container where information is updated.
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void GetSharedContainerL( TInt aItemId,
-                                       CUpnpContainer& aContainer,
-                                       TRequestStatus& aStatus );
-
-    /**
-    * Gets shared items information from Media Server according to supported browse criteria.
-    * Note: There are only two possible values of filter:
-    * -    "" (empty filter) only required properties will be returned
-    * -    "*" (asterisk)  all properties will be returned
-    * Information is returned to container reference.    
-    *
-    * @since S60 3.1
-    * @param aContainerId id of the container of which items are to be returned
-    * @param aBrowseCriteria specifies request details, such as requestCount, startingIndes, filter
-    * @param aItemList reference to item list where information is updated.
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void GetSharedItemListL( TInt aContainerId,
-                                    CUpnpBrowseCriteria& aBrowseCriteria,
-                                    CUpnpItemList& aItemList,
-                                    TInt& aTotalMatches,
-                                    TRequestStatus& aStatus );
-    
-    /**
-    * Gets shared containers information from Media Server according to supported browse criteria.
-    * Note: There are only two possible values of filter:
-    * -    "" (empty filter) only required properties will be returned
-    * -    "*" (asterisk)  all properties will be returned
-    * Information is returned to container reference. 
-    * Nested container are not returned.   
-    *
-    * @since S60 3.1
-    * @param aContainerId id of the container of which items are to be returned
-    * @param aBrowseCriteria specifies request details, such as requestCount, startingIndes, filter
-    * @param aItemList reference to item list where information is updated.
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void GetSharedContainerListL( TInt aContainerId,
-                                    CUpnpBrowseCriteria& aBrowseCriteria,
-                                    CUpnpContainerList& aItem,
-                                    TInt& aTotalMatches,
-                                    TRequestStatus& aStatus );
-    
-    /**
-    * Creates a single reference upon passed item asynchronously in Media Server.    
-    *
-    * @since S60 5.0 HN
-    * @param aContainerId - container id upon which the reference will be located.
-    * @param aObjectId - the reference is created on the basis of passed object id
-    * @param aItem reference item to be filled
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void ShareReferenceL( TInt aContainerId, 
-                            TInt aObjectId,
-                            CUpnpItem& aItem,
-                            TRequestStatus& aStatus );
-
-    /**
-    * Creates some reference items, located at specific container, pointing specific objects
-    *
-    * @since S60 5.0 HN
-    * @param aItemList 'reference item' list which are to be shared
-    * @param aExecStatus reference pointing to the index of item list
-    * @param aStatus reference to TRequestStatus which is completed when procedure is over
-    */
-    IMPORT_C void ShareReferenceListL( CUpnpItemList& aItemList,
-                                  TInt& aExecStatus,
-                                  TRequestStatus& aStatus ); 
-    /**
-    * Returns reference to media server client
-    *
-    * @since S60 5.0 HN
-    * @return media server client refernce
-    */                              
-    IMPORT_C RUpnpMediaServerClient& CUpnpFileSharing::MediaServerClient( );
-
-private:
-
-	/**
-    * C++ default constructor.
-    */
-    CUpnpFileSharing();
-	
-	/**
-    * By default Symbian 2nd phase constructor is private.
-    */
-    void ConstructL();
-
-private: // data
-
-    /**
-     * Actual implementation class for the interface
-     * Own.
-     */
-     CUpnpFileSharingBody* iBody;
-    };
-
-
-#endif // C_CUPNPFILESHARING_H
+/** @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:  File sharing interface class
+*
+*/
+
+
+#ifndef C_CUPNPFILESHARING_H
+#define C_CUPNPFILESHARING_H
+
+#include <e32base.h>
+#include "upnpobject.h"
+
+// FORWARD DECLARATIONS
+class CUpnpFileSharingBody;
+class CUpnpItem;
+class CUpnpContainer;
+class CUpnpBrowseCriteria;
+class CUpnpItemList;
+class CUpnpContainerList;
+class RUpnpMediaServerClient;
+/**
+ *  Interface class for UPnP File Sharing
+ *
+ *  @lib MediaServerClient.lib
+ *  @since S60 v3.1
+ */
+class CUpnpFileSharing : public CBase
+    {
+
+public:
+    
+    /**
+    * Two-phased constructor.
+    */
+    IMPORT_C static CUpnpFileSharing* NewL();
+    
+    /**
+    * Destructor.
+    */
+    virtual ~CUpnpFileSharing();
+
+public:     // Interface methods
+    /**
+    * Database Clearing function
+    * Stops mediaserver, delete database file and starts mediaserver
+    *
+    * @since S60 3.1
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void DropAllContentL(TRequestStatus& aStatus);
+    
+    /**
+    * Shares a single item asynchronously to Media Server.
+    * Symbian data base doesn't support foreign key constraints. In order to avoid  
+    * adding item with nonexistent parent container, parent id existence is checked 
+    * by Media Server. 
+    * The item is created with parent id passed as an argument to this operation 
+    * (object field iParentId value is ignored). 
+    * After creation input object is updated with:
+    * - iId - generated object identifier
+    * - "res" element value - in offline sharing there is no possible to set ip:port 
+    *    information in URL. "Res" value example: http:///00000001/filename. 
+    *    For consistency the same approach will be used in online mode.
+    *
+    * @since S60 3.1
+    * @param aContainerId information to which container the item is shared.
+    * @param aItem reference to item which is shared.
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void ShareItemL( const TDesC8& aContainerId, 
+                              CUpnpItem& aItem,
+                              TRequestStatus& aStatus ); 
+
+    /**
+    * Shares a single container asynchronously to Media Server.
+    * Nested container and items are ignored.  The container is created with parent id 
+    * passed as an argument to this operation (object field iParentId value is ignored). 
+    * Parent id existence is checked by Media Server. 
+    * After creation input object is updated with the current:
+    * - iId
+    *
+    * @since S60 3.1
+    * @param aContainerId information to which container the item is shared.
+    * @param aContainer reference to container which is shared.
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void ShareContainerL( const TDesC8& aParentId, 
+                                   CUpnpContainer& aContainer,
+                                   TRequestStatus& aStatus ); 
+    
+    /**
+    * Shares a list of items asynchronously to Media Server. 
+    * Each CUpnpItem of CUpnpItemList is created with the same parent id passed as 
+    * an argument to this operation (object field iParentId value is ignored). 
+    * Parent id existence is checked by Media Server - only once for this operation. 
+    * Database transaction is committed each 11 objects created into database. 
+    * This empirical value is hard coded in current implementation. 
+    * If an execution of task fails when creating object (e.g. 776-th item on list) 
+    * error code is retuned (aExecStatus), which points to last successfully created item index [1...total count] 
+    * (e.g. aExecutionStatus = 770 last item in database is object number 770, 
+    * if no object is cretated index = 0, if all are created index = total count).
+    *
+    * Note: There is no support for chunked operations (splitting long operation 
+    * into sequence of asynchronical calls). Each operation is atomic from 
+    * Media Server Engine perspective. Long lasting operations may block Media Server Engine. 
+    * In such case switching Media Server to offline mode is recommended.
+    *
+    * For each created item respective input object is updated with:
+    * - iId
+    * - "res" element value
+    *
+    * @since S60 3.1
+    * @param aContainerId information to which container the item is shared.
+    * @param aItemList reference to item list which are to be shared.
+    * @param aExecStatus reference pointing to the index of item list
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void ShareItemListL( const TDesC8& aContainerId, 
+                                  CUpnpItemList& aItemList,
+                                  TInt& aExecStatus,
+                                  TRequestStatus& aStatus ); 
+                                    
+    /**
+    * Unshares existing item from the Media Server.
+    * Item with specified id is removed from database regardless "restricted" property value.
+    * Note: This method removes uploaded file associated with item being destroyed. 
+    *       Shared files are never removed.
+    *       
+    *
+    * @since S60 3.1
+    * @param aItemId item which is unshared
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void UnshareItemL( TInt aItemId,
+                                TRequestStatus& aStatus);
+       
+     
+    /**
+    * Unshares existing container from the Media Server.
+    * Container with its whole branch is removed from database regardless "restricted" 
+    * property value for this container and any object in branch.
+    * Object removing is a bottom-up process. If removing of particular object fails 
+    * whole operation is broken and error is returned. 
+    *
+    * Note: This method removes uploaded file associated with item being destroyed. 
+    *       Shared files are never removed.
+    *
+    * Note: The iId value is not verified whether it points to a container or item. 
+    * Therefore, clients must not use UnshareContainer method with ids pointing to an 
+    * item or other way round. 
+    *    
+    * @since S60 3.1
+    * @param aContainerId container which is unshared
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void UnshareContainerL( TInt aItemId,
+                                     TRequestStatus& aStatus );
+     
+    /**
+    * Unshares existing items from the MediaServer.
+    * Each Item from list is removed from database regardless "restricted" property value.
+    * Database transaction is committed each 11 objects removed database. 
+    * If an execution of task fails when creating object error code is retuned, 
+    * which points to last successfully removed item index.
+    *
+    * Note: This method removes uploaded file associated with item being destroyed. 
+    *       Shared files are never removed.
+    *
+    * @since S60 3.1
+    * @param aItemList list of items which are to be unshared
+    * @param aExecStatus reference pointing to the index of item list    
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void UnshareItemListL( CUpnpItemList& aItemList,
+                                TInt& aExecStatus,
+                                TRequestStatus& aStatus);
+
+    /**
+    * Gets shared item information from MediaServer. 
+    * This operation returns all properties. Browse criteria is not used.
+    * Information is returned to item reference.
+    *
+    * @since S60 3.1
+    * @param aItemId item id
+    * @param aItem reference to item where information is updated.
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void GetSharedItemL( TInt aItemId,
+                                  CUpnpItem& aItem,
+                                  TRequestStatus& aStatus );
+    
+    
+    /**
+    * Gets shared container information from Media Server. 
+    * Nested container and items are not returned.
+    * This operation returns all properties. Browse criteria is not used.
+    * Information is returned to container reference.
+    *
+    * @since S60 3.1
+    * @param aContainerId container id
+    * @param aContainer reference to container where information is updated.
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void GetSharedContainerL( TInt aItemId,
+                                       CUpnpContainer& aContainer,
+                                       TRequestStatus& aStatus );
+
+    /**
+    * Gets shared items information from Media Server according to supported browse criteria.
+    * Note: There are only two possible values of filter:
+    * -    "" (empty filter) only required properties will be returned
+    * -    "*" (asterisk)  all properties will be returned
+    * Information is returned to container reference.    
+    *
+    * @since S60 3.1
+    * @param aContainerId id of the container of which items are to be returned
+    * @param aBrowseCriteria specifies request details, such as requestCount, startingIndes, filter
+    * @param aItemList reference to item list where information is updated.
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void GetSharedItemListL( TInt aContainerId,
+                                    CUpnpBrowseCriteria& aBrowseCriteria,
+                                    CUpnpItemList& aItemList,
+                                    TInt& aTotalMatches,
+                                    TRequestStatus& aStatus );
+    
+    /**
+    * Gets shared containers information from Media Server according to supported browse criteria.
+    * Note: There are only two possible values of filter:
+    * -    "" (empty filter) only required properties will be returned
+    * -    "*" (asterisk)  all properties will be returned
+    * Information is returned to container reference. 
+    * Nested container are not returned.   
+    *
+    * @since S60 3.1
+    * @param aContainerId id of the container of which items are to be returned
+    * @param aBrowseCriteria specifies request details, such as requestCount, startingIndes, filter
+    * @param aItemList reference to item list where information is updated.
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void GetSharedContainerListL( TInt aContainerId,
+                                    CUpnpBrowseCriteria& aBrowseCriteria,
+                                    CUpnpContainerList& aItem,
+                                    TInt& aTotalMatches,
+                                    TRequestStatus& aStatus );
+    
+    /**
+    * Creates a single reference upon passed item asynchronously in Media Server.    
+    *
+    * @since S60 5.0 HN
+    * @param aContainerId - container id upon which the reference will be located.
+    * @param aObjectId - the reference is created on the basis of passed object id
+    * @param aItem reference item to be filled
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void ShareReferenceL( TInt aContainerId, 
+                            TInt aObjectId,
+                            CUpnpItem& aItem,
+                            TRequestStatus& aStatus );
+
+    /**
+    * Creates some reference items, located at specific container, pointing specific objects
+    *
+    * @since S60 5.0 HN
+    * @param aItemList 'reference item' list which are to be shared
+    * @param aExecStatus reference pointing to the index of item list
+    * @param aStatus reference to TRequestStatus which is completed when procedure is over
+    */
+    IMPORT_C void ShareReferenceListL( CUpnpItemList& aItemList,
+                                  TInt& aExecStatus,
+                                  TRequestStatus& aStatus ); 
+    /**
+    * Returns reference to media server client
+    *
+    * @since S60 5.0 HN
+    * @return media server client refernce
+    */                              
+    IMPORT_C RUpnpMediaServerClient& MediaServerClient( );
+
+private:
+
+	/**
+    * C++ default constructor.
+    */
+    CUpnpFileSharing();
+	
+	/**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    void ConstructL();
+
+private: // data
+
+    /**
+     * Actual implementation class for the interface
+     * Own.
+     */
+     CUpnpFileSharingBody* iBody;
+    };
+
+
+#endif // C_CUPNPFILESHARING_H
--- a/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,46 +1,45 @@
-/*
-* Copyright (c) 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:      upnpservices build file
-*
-*/
-
-
-
-
-
-// For compatibility with S60 3.2 and IAD branch
-#include "upnpplatformvar.hrh"
-
-// Export domain and SDK headers
-#include "../dlnasrv_plat/group/bld.inf"
-
-// upnp stack
-#include "../upnpavcontrolpoint/group/bld.inf"
-#include "../upnpmediaserver/group/bld.inf"
-
-// upnp framework
-#include "../upnpavcontroller/group/bld.inf"
-#include "../upnpframework/group/bld.inf"
-#include "../upnpsettings/group/bld.inf"
-#include "../upnpsharing/group/bld.inf"
-#include "../upnpmpxplugins/group/bld.inf"
-
-#ifdef FF_UPNP_FRAMEWORK_2_0  // UPnP feature flag
-#include "../upnpharvester/group/bld.inf"
-
-// upnp applications
-#include "../homesync/group/bld.inf"
-#include "../homemedia/group/bld.inf"
-#endif // FF_UPNP_FRAMEWORK_2_0
-// End of file
+/*
+* Copyright (c) 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:      upnpservices build file
+*
+*/
+
+// For compatibility with S60 3.2 and IAD branch
+#include "upnpplatformvar.hrh"
+
+PRJ_EXPORTS
+
+// --------------------------------------------------------------------------
+// Build the dlnasrv package's collections
+// --------------------------------------------------------------------------
+
+// Build the upnpmediaserver collection
+#include "../upnpmediaserver/group/bld.inf"
+
+// Build the upnpavcontroller collection
+#include "../upnpavcontroller/group/bld.inf"
+
+// Build the upnpframework collection
+#include "../upnpframework/group/bld.inf"
+
+// Build the upnpsettings collection
+#include "../upnpsettings/group/bld.inf"
+
+// Build the upnpsharing collection
+#include "../upnpsharing/group/bld.inf"
+
+// Export the platform headers
+#include "../dlnasrv_plat/group/bld.inf"
+
+// End of file
--- a/group/upnpplatformvar.hrh	Fri Sep 17 08:31:21 2010 +0300
+++ b/group/upnpplatformvar.hrh	Mon Nov 01 12:37:49 2010 +0200
@@ -1,44 +1,43 @@
-/*
-* Copyright (c) 2008 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:      Defines flags which are needed for compatibility with
-* S60 3.2 SDKs and IAD branch.
-*
-*/
-
-
-
-
-
-
-#ifndef UPNPPLATFORMVAR_HRH
-#define UPNPPLATFORMVAR_HRH
-
-#ifndef __SERIES60_32__
-#include <platform_paths.hrh>
-#else
-#include <platform_paths.hrh>
-#endif
-
-// LOC export for MCL SDKs.
-// Loc files have to be exported to /epoc32/include/... in MCL SDKs.
-#define UPNP_LOC_EXPORT(exported) ../loc/##exported MW_LAYER_LOC_EXPORT_PATH(exported)
-
-// No need for language ids in MCL SDKs
-
-// No need for LOC file include paths MCL SDKs.
-// But they need to be defined.
-#define UPNP_LOC_INCLUDE_PATH_COMPONENT
-#define UPNP_LOC_INCLUDE_PATH_SUBCOMPONENT
-
-#endif // UPNPPLATFORMVAR_HRH
+/*
+* Copyright (c) 2008 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:      Defines flags which are needed for compatibility with
+* S60 3.2 SDKs and IAD branch.
+*
+*/
+
+
+
+
+
+
+#ifndef UPNPPLATFORMVAR_HRH
+#define UPNPPLATFORMVAR_HRH
+
+#include <platform_paths.hrh>
+
+// LOC export for MCL SDKs.
+// Loc files have to be exported to /epoc32/include/... in MCL SDKs.
+#define UPNP_LOC_EXPORT(exported) ../loc/##exported MW_LAYER_LOC_EXPORT_PATH(exported)
+
+// No need for language ids in MCL SDKs
+
+// No need for LOC file include paths MCL SDKs.
+// But they need to be defined.
+#define UPNP_LOC_INCLUDE_PATH_COMPONENT
+#define UPNP_LOC_INCLUDE_PATH_SUBCOMPONENT
+
+// Define this flag if gstreamer is used for transcoding
+#undef UPNP_USE_GSTREAMER
+
+#endif // UPNPPLATFORMVAR_HRH
--- a/layers.sysdef.xml	Fri Sep 17 08:31:21 2010 +0300
+++ b/layers.sysdef.xml	Mon Nov 01 12:37:49 2010 +0200
@@ -1,34 +1,33 @@
-<?xml version="1.0"?>
-<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
-  <!ENTITY layer_real_source_path "sf/mw/dlnasrv" >
-]>
-
-<SystemDefinition name="dlnasrv" schema="1.4.0">
-  <systemModel>
-    <layer name="mw_layer">
-      <module name="dlnasrv">
-        <unit name="dlnasrv" unitID="hcdo.dlnasrv" bldFile="&layer_real_source_path;/group" mrp="" />
-      </module>
-    </layer>
-
-    <layer name="api_test_layer">
-      <module name="hcdo_api_tests">
-<!--
-        <unit unitID="hcdo.avcontrolframework.test" name="avcontrolframework.test" bldFile="&layer_real_source_path;/upnpavcontrolpoint/avcontrolframework/tsrc/public/basic/group" mrp="" />
-        <unit unitID="hcdo.avobjects.test" name="avobjects.test" bldFile="&layer_real_source_path;/upnpmediaserver/avobjects/tsrc/public/basic/group" mrp="" />
-        <unit unitID="hcdo.mediaserverclient.test" name="mediaserverclient.test" bldFile="&layer_real_source_path;/upnpmediaserver/mediaserverclient/tsrc/public/basic/group" mrp="" />
-        <unit unitID="hcdo.controlpointbase.test" name="controlpointbase.test" bldFile="&layer_real_source_path;/upnpstack/controlpointbase/tsrc/public/basic/group" mrp="" />
-        <unit unitID="hcdo.serviceframework.test" name="serviceframework.test" bldFile="&layer_real_source_path;/upnpstack/serviceframework/tsrc/public/basic/group" mrp="" />
-        <unit unitID="hcdo.upnputils.test" name="upnputils.test" bldFile="&layer_real_source_path;/upnpstack/upnputils/tsrc/public/basic/group" mrp="" />
-        <unit unitID="hcdo.testplugin.test" name="testplugin.test" bldFile="&layer_real_source_path;/dlnasrv_plat/upnp_plugin_api/tsrc/testplugin/group" mrp="" />
-        <unit unitID="hcdo.upnpextensionpluginiftest.test" name="upnpextensionpluginiftest.test" bldFile="&layer_real_source_path;/dlnasrv_plat/upnp_plugin_api/tsrc/upnpextensionpluginiftest/group" mrp="" />
-        <unit unitID="hcdo.upnpxmlparsertes.test" name="upnpxmlparsertest.test" bldFile="&layer_real_source_path;/upnpavcontroller/upnpxmlparser/tsrc/upnpxmlparsertest/group" mrp="" />
-        <unit unitID="hcdo.upnpsecuritytest.test" name="upnpsecuritytest.test" bldFile="&layer_real_source_path;/upnpsharing/upnpsecurity/tsrc/upnpsecuritytest/group" mrp="" />
--->
-        <unit unitID="hcdo.api.test" name="api.test" bldFile="&layer_real_source_path;/tsrc/group" mrp="" />
-    </module>
-    </layer>
-
-  </systemModel>
-</SystemDefinition>
-
+<?xml version="1.0"?>
+<!DOCTYPE SystemDefinition SYSTEM "sysdef_1_4_0.dtd" [
+  <!ENTITY layer_real_source_path "sf/mw/dlnasrv" >
+]>
+
+<SystemDefinition name="dlnasrv" schema="1.4.0">
+  <systemModel>
+    <layer name="mw_layer">
+      <module name="dlnasrv">
+        <unit name="dlnasrv" unitID="hcdo.dlnasrv" bldFile="&layer_real_source_path;/group" mrp="" />
+      </module>
+    </layer>
+
+    <layer name="api_test_layer">
+      <module name="hcdo_api_tests">
+<!--
+        <unit unitID="hcdo.avobjects.test" name="avobjects.test" bldFile="&layer_real_source_path;/upnpmediaserver/avobjects/tsrc/public/basic/group" mrp="" />
+        <unit unitID="hcdo.mediaserverclient.test" name="mediaserverclient.test" bldFile="&layer_real_source_path;/upnpmediaserver/mediaserverclient/tsrc/public/basic/group" mrp="" />
+        <unit unitID="hcdo.controlpointbase.test" name="controlpointbase.test" bldFile="&layer_real_source_path;/upnpstack/controlpointbase/tsrc/public/basic/group" mrp="" />
+        <unit unitID="hcdo.serviceframework.test" name="serviceframework.test" bldFile="&layer_real_source_path;/upnpstack/serviceframework/tsrc/public/basic/group" mrp="" />
+        <unit unitID="hcdo.upnputils.test" name="upnputils.test" bldFile="&layer_real_source_path;/upnpstack/upnputils/tsrc/public/basic/group" mrp="" />
+        <unit unitID="hcdo.testplugin.test" name="testplugin.test" bldFile="&layer_real_source_path;/dlnasrv_plat/upnp_plugin_api/tsrc/testplugin/group" mrp="" />
+        <unit unitID="hcdo.upnpextensionpluginiftest.test" name="upnpextensionpluginiftest.test" bldFile="&layer_real_source_path;/dlnasrv_plat/upnp_plugin_api/tsrc/upnpextensionpluginiftest/group" mrp="" />
+        <unit unitID="hcdo.upnpxmlparsertes.test" name="upnpxmlparsertest.test" bldFile="&layer_real_source_path;/upnpavcontroller/upnpxmlparser/tsrc/upnpxmlparsertest/group" mrp="" />
+        <unit unitID="hcdo.upnpsecuritytest.test" name="upnpsecuritytest.test" bldFile="&layer_real_source_path;/upnpsharing/upnpsecurity/tsrc/upnpsecuritytest/group" mrp="" />
+-->
+        <unit unitID="hcdo.api.test" name="api.test" bldFile="&layer_real_source_path;/tsrc/group" mrp="" />
+    </module>
+    </layer>
+
+  </systemModel>
+</SystemDefinition>
+
--- a/package_definition.xml	Fri Sep 17 08:31:21 2010 +0300
+++ b/package_definition.xml	Mon Nov 01 12:37:49 2010 +0200
@@ -19,10 +19,6 @@
     <meta rel="Api" href="dlnasrv_plat/upnp_security_plugin_api/upnp_security_plugin_api.metaxml"/>
     <unit bldFile="dlnasrv_plat/upnp_security_plugin_api/group"/>
    </component>
-   <component id="upnp_avcp_api" name="UPnP AVCP API" class="api" filter="s60">
-    <meta rel="Api" href="dlnasrv_plat/upnp_avcp_api/upnp_avcp_api.metaxml"/>
-    <unit bldFile="dlnasrv_plat/upnp_avcp_api/group"/>
-   </component>
    <component id="upnp_media_server_metadata_api" name="UPnP Media Server Metadata API" class="api" filter="s60">
     <meta rel="Api" href="dlnasrv_plat/upnp_media_server_metadata_api/upnp_media_server_metadata_api.metaxml"/>
     <unit bldFile="dlnasrv_plat/upnp_media_server_metadata_api/group"/>
@@ -39,15 +35,6 @@
     <unit bldFile="dlnasrv_plat/upnp_plugin_api/tsrc/upnpextensionpluginiftest/group" filter="test,api_test"/>
    </component>
   </collection>
-  <collection id="upnpavcontrolpoint" name="UPnP A/V Control Point" level="plugin">
-   <component id="avcontrolframework" filter="s60" name="A/V Control Famework" introduced="9.1" deprecated="^3">
-    <unit bldFile="upnpavcontrolpoint/avcontrolframework/group" filter="!test"/>
-    <unit bldFile="upnpavcontrolpoint/avcontrolframework/tsrc/public/basic/group" filter="test,api_test"/>
-   </component>
-   <component id="upnpavcontrolpoint_rom" filter="s60" name="UPnP A/V Control Point ROM" introduced="9.1" deprecated="^3">
-    <unit bldFile="upnpavcontrolpoint/rom"/>
-   </component>
-  </collection>
   <collection id="upnpmediaserver" name="UPnP Media Server" level="server">
    <component id="avobjects" filter="s60" name="A/V Objects">
     <unit bldFile="upnpmediaserver/avobjects/group" filter="!test"/>
@@ -66,9 +53,6 @@
    <component id="mediaserverengine" filter="s60" name="Media Server Engine">
     <unit bldFile="upnpmediaserver/mediaserverengine/group"/>
    </component>
-   <component id="upnpmediaserver_rom" filter="s60" name="UPnP Media Server ROM">
-    <unit bldFile="upnpmediaserver/rom"/>
-   </component>
   </collection>
   <collection id="upnpavcontroller" name="UPnP A/V Controller" level="ctrl">
    <component id="upnpxmlparser" filter="s60" name="UPnP XML Parser" introduced="^2">
@@ -84,85 +68,31 @@
    <component id="upnpavcontrollerhelper" filter="s60" name="UPnP A/V Controller Helper" introduced="^2">
     <unit bldFile="upnpavcontroller/upnpavcontrollerhelper/group"/>
    </component>
-   <component id="upnpavcontroller_rom" filter="s60" name="UPnP A/V Controller ROM" introduced="^2">
-    <unit bldFile="upnpavcontroller/rom"/>
+   <component id="upnprenderingstatemachine" filter="s60" name="UPnP Rendering State Machine" introduced="^3">
+    <unit bldFile="upnpavcontroller/upnprenderingstatemachine/group"/>
    </component>
   </collection>
   <collection id="upnpframework" name="UPnP Framework" level="framework">
    <component id="upnputilities" filter="s60" name="UPnP Utilities" introduced="^2">
     <unit bldFile="upnpframework/upnputilities/group"/>
    </component>
-   <component id="upnpextensionpluginif" filter="s60" name="UPnP Home Media Extension Plugin Interface" introduced="^2" deprecated="^3">
-    <meta rel="config">
-     <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-    </meta>
-    <unit bldFile="upnpframework/upnpextensionpluginif/group"/>
-   </component>
    <component id="upnpfiletransferengine" filter="s60" name="UPnP File Transfer Engine" introduced="^2" deprecated="^3">
     <meta rel="config">
      <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
     </meta>
     <unit bldFile="upnpframework/upnpfiletransferengine/group"/>
    </component>
-   <component id="upnpcommonui" filter="s60" name="UPnP Common UI" introduced="^2" deprecated="^3">
-    <meta rel="config">
-     <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-    </meta>
-    <unit bldFile="upnpframework/upnpcommonui/group"/>
-   </component>
-   <component id="upnpaiwengine" filter="s60" name="UPnP AIW Engine" introduced="^2" deprecated="^3">
-    <meta rel="config">
-     <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-    </meta>
-    <unit bldFile="upnpframework/upnpaiwengine/group"/>
-   </component>
-   <component id="upnpaiwprovider" filter="s60" name="UPnP AIW Provider" class="plugin" introduced="^2" deprecated="^3">
-    <meta rel="config">
-     <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-    </meta>
-    <unit bldFile="upnpframework/upnpaiwprovider/group"/>
-   </component>
    <component id="upnpmusicadapter" filter="s60" name="UPnP Music Adapter" introduced="^2">
     <unit bldFile="upnpframework/upnpmusicadapter/group"/>
    </component>
    <component id="upnpcommand" filter="s60" name="UPnP Command" introduced="^2">
     <unit bldFile="upnpframework/upnpcommand/group"/>
    </component>
-   <component id="upnpframework_rom" filter="s60" name="UPnP Framework ROM" introduced="^2">
-    <unit bldFile="upnpframework/rom"/>
-   </component>
   </collection>
   <collection id="upnpsettings" name="UPnP Settings" level="framework">
    <component id="upnpsettingsengine" filter="s60" name="UPnP Settings Engine" introduced="^2">
     <unit bldFile="upnpsettings/upnpsettingsengine/group"/>
    </component>
-   <component id="multiselectionui" filter="s60" name="Multi-Selection UI" introduced="^2" deprecated="^3">
-    <meta rel="config">
-     <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-    </meta>
-    <unit bldFile="upnpsettings/multiselectionui/group"/>
-   </component>
-   <component id="appwizard" filter="s60" name="UPnP Settings Wizard App" introduced="^2" deprecated="^3">
-    <meta rel="config">
-     <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-    </meta>
-    <unit bldFile="upnpsettings/appwizard/group"/>
-   </component>
-   <component id="upnpsharingui" filter="s60" name="UPnP Sharing UI" introduced="^2" deprecated="^3">
-    <meta rel="config">
-     <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-    </meta>
-    <unit bldFile="upnpsettings/upnpsharingui/group"/>
-   </component>
-   <component id="upnpgsplugin" filter="s60" name="UPnP GS Plugin" class="plugin" introduced="^2">
-    <meta rel="config">
-     <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-    </meta>
-    <unit bldFile="upnpsettings/upnpgsplugin/group"/>
-   </component>
-   <component id="upnpsettings_rom" filter="s60" name="UPnP Settings ROM" introduced="^2">
-    <unit bldFile="upnpsettings/rom"/>
-   </component>
   </collection>
   <!-- this collection was deleted a while back, but the tests are still #included from elsewhere. 
 	If they're coming back, uncomment out this part, otherwise just delete this whole collection 
@@ -188,57 +118,8 @@
    <component id="upnpcontentserver" filter="s60" name="UPnP Content Server" introduced="^2">
     <unit bldFile="upnpsharing/upnpcontentserver/group"/>
    </component>
-   <component id="applicationengine" filter="s60" name="UPnP Application Engine" introduced="^2">
-    <unit bldFile="upnpsharing/applicationengine/group"/>
-   </component>
-   <component id="upnpsharing_rom" filter="s60" name="UPnP Sharing ROM" introduced="^2">
-    <unit bldFile="upnpsharing/rom"/>
-   </component>
-  </collection>
-  <collection id="upnpmpxplugins" name="UPnP MPX Plugins" level="plugin">
-   <component id="upnpplaybackplugins" filter="s60" name="UPnP Playback Plugins" class="plugin" introduced="^2">
-    <unit bldFile="upnpmpxplugins/upnpplaybackplugins/group"/>
-   </component>
-   <component id="upnpmpxplugins_rom" filter="s60" name="UPnP MPX Plugins ROM" introduced="^2">
-    <unit bldFile="upnpmpxplugins/rom"/>
-   </component>
-  </collection>
-  <collection id="upnpharvester" name="UPnP Harvester" level="ctrl">
-   <meta rel="config">
-    <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-   </meta>
-   <component id="upnpharvester_common" filter="s60" name="UPnP Harvester Common" introduced="^2" deprecated="^3">
-    <!-- need to merge or #include these to a single bld.inf -->
-    <unit bldFile="upnpharvester/common/cmlibrary/group"/>
-        <unit bldFile="upnpharvester/common/cmsettings/group"/>
-        <unit bldFile="upnpharvester/common/cmsqlwrapper/group"/>
-        <unit bldFile="upnpharvester/common/dbmanager/group"/>
-   </component>
-   <component id="cdssync" filter="s60" name="CDS Sync" introduced="^2" deprecated="^3">
-    <unit bldFile="upnpharvester/cdssync/common"/>
-   </component>
-   <component id="mdhserver" filter="s60" name="Metadata Harvester Server" introduced="^2" deprecated="^3">
-    <unit bldFile="upnpharvester/mdhserver/group"/>
-   </component>
-   <component id="upnpharvester_rom" filter="s60" name="UPnP Harvester ROM" introduced="^2" deprecated="^3">
-    <unit bldFile="upnpharvester/rom"/>
-   </component>
-  </collection>
-  <collection id="homesync" name="Home Sync" level="plugin">
-   <meta rel="config">
-    <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-   </meta>
-   <component id="contentmanager" filter="s60" name="Content Manager" introduced="^2" deprecated="^3">
-        <unit bldFile="homesync/group"/> <!-- move bld.inf into contentmanager dir -->
-   </component>
-  </collection>
-  <collection id="homemedia" name="Home Media" level="framework">
-   <meta rel="config">
-    <defined condition="FF_UPNP_FRAMEWORK_2_0"/>
-   </meta>
-   <!-- collection is really just a component. Move down a directory -->
-   <component id="homemedia_build" filter="s60" name="Home Media" introduced="^2" deprecated="^3">
-     <unit bldFile="homemedia/group"/> 
+   <component id="upnpsharingalgorithm" filter="s60" name="UPnP Sharing Algorithm" introduced="^3">
+    <unit bldFile="upnpsharing/upnpsharingalgorithm/group"/>
    </component>
   </collection>
  </package>
--- a/upnpavcontroller/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,42 +1,42 @@
-/*
-* Copyright (c) 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:      Build information file for upnpavcontroller
-*
-*/
-
-#include "../../group/upnpplatformvar.hrh"
-
-PRJ_PLATFORMS
-
-PRJ_EXPORTS
-// none
-
-PRJ_MMPFILES
-// none
-
-// upnp xml parser
-#include "../upnpxmlparser/group/bld.inf"
-
-// avcontroller server
-#include "../upnpavcontrollerserver/group/bld.inf"
-
-// avcontroller client
-#include "../upnpavcontrollerclient/group/bld.inf"
-
-// avcontroller helper
-#include "../upnpavcontrollerhelper/group/bld.inf"
-
-// upnpavcontroller ROM
-#include "../rom/bld.inf"
-
+/*
+* Copyright (c) 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:      Build information file for upnpavcontroller
+*
+*/
+
+#include "../../group/upnpplatformvar.hrh"
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+// none
+
+    // upnp xml parser
+    #include "../upnpxmlparser/group/bld.inf"
+
+    // avcontroller server
+    #include "../upnpavcontrollerserver/group/bld.inf"
+
+    // avcontroller client
+    #include "../upnpavcontrollerclient/group/bld.inf"
+
+    // avcontroller helper
+    #include "../upnpavcontrollerhelper/group/bld.inf"
+    
+    // rendering statemachine
+    #include "../upnprenderingstatemachine/group/bld.inf"
+
+// End of file
--- a/upnpavcontroller/upnpavcontrollerclient/bwins/upnpavcontrollerclientu.def	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/bwins/upnpavcontrollerclientu.def	Mon Nov 01 12:37:49 2010 +0200
@@ -1,57 +1,60 @@
-EXPORTS
-	??0CUpnpAVDevice@@IAE@XZ @ 1 NONAME ; CUpnpAVDevice::CUpnpAVDevice(void)
-	??1CUpnpAVDevice@@UAE@XZ @ 2 NONAME ; CUpnpAVDevice::~CUpnpAVDevice(void)
-	??ACUpnpAVDeviceList@@QBEPAVCUpnpAVDevice@@H@Z @ 3 NONAME ; class CUpnpAVDevice * CUpnpAVDeviceList::operator[](int) const
-	?AppendDeviceL@CUpnpAVDeviceList@@QAEXAAVCUpnpAVDevice@@@Z @ 4 NONAME ; void CUpnpAVDeviceList::AppendDeviceL(class CUpnpAVDevice &)
-	?AudioCapability@CUpnpAVDevice@@QBEHXZ @ 5 NONAME ; int CUpnpAVDevice::AudioCapability(void) const
-	?CopyCapability@CUpnpAVDevice@@QBEHXZ @ 6 NONAME ; int CUpnpAVDevice::CopyCapability(void) const
-	?CopyFromL@CUpnpAVDevice@@QAEXABV1@@Z @ 7 NONAME ; void CUpnpAVDevice::CopyFromL(class CUpnpAVDevice const &)
-	?Count@CUpnpAVDeviceList@@QBEHXZ @ 8 NONAME ; int CUpnpAVDeviceList::Count(void) const
-	?DeviceType@CUpnpAVDevice@@QBE?AW4TUpnpAVDeviceType@1@XZ @ 9 NONAME ; enum CUpnpAVDevice::TUpnpAVDeviceType CUpnpAVDevice::DeviceType(void) const
-	?ExternalizeL@CUpnpAVDevice@@QBEXAAVRWriteStream@@@Z @ 10 NONAME ; void CUpnpAVDevice::ExternalizeL(class RWriteStream &) const
-	?ExternalizeL@CUpnpAVDeviceList@@QBEXAAVRWriteStream@@@Z @ 11 NONAME ; void CUpnpAVDeviceList::ExternalizeL(class RWriteStream &) const
-	?FriendlyName@CUpnpAVDevice@@QBEABVTDesC8@@XZ @ 12 NONAME ; class TDesC8 const & CUpnpAVDevice::FriendlyName(void) const
-	?ImageCapability@CUpnpAVDevice@@QBEHXZ @ 13 NONAME ; int CUpnpAVDevice::ImageCapability(void) const
-	?InternalizeL@CUpnpAVDevice@@QAEXAAVRReadStream@@@Z @ 14 NONAME ; void CUpnpAVDevice::InternalizeL(class RReadStream &)
-	?InternalizeL@CUpnpAVDeviceList@@QAEXAAVRReadStream@@@Z @ 15 NONAME ; void CUpnpAVDeviceList::InternalizeL(class RReadStream &)
-	?LinkOffset@CUpnpAVDevice@@SAHXZ @ 16 NONAME ; int CUpnpAVDevice::LinkOffset(void)
-	?MSServicesInUse@UPnPAVControllerFactory@@SAHXZ @ 17 NONAME ; int UPnPAVControllerFactory::MSServicesInUse(void)
-	?MaxVolume@CUpnpAVDevice@@QBEHXZ @ 18 NONAME ; int CUpnpAVDevice::MaxVolume(void) const
-	?MuteCapability@CUpnpAVDevice@@QBEHXZ @ 19 NONAME ; int CUpnpAVDevice::MuteCapability(void) const
-	?NewL@CUpnpAVDevice@@SAPAV1@ABV1@@Z @ 20 NONAME ; class CUpnpAVDevice * CUpnpAVDevice::NewL(class CUpnpAVDevice const &)
-	?NewL@CUpnpAVDevice@@SAPAV1@XZ @ 21 NONAME ; class CUpnpAVDevice * CUpnpAVDevice::NewL(void)
-	?NewL@CUpnpAVDeviceList@@SAPAV1@XZ @ 22 NONAME ; class CUpnpAVDeviceList * CUpnpAVDeviceList::NewL(void)
-	?NewLC@CUpnpAVDevice@@SAPAV1@XZ @ 23 NONAME ; class CUpnpAVDevice * CUpnpAVDevice::NewLC(void)
-	?NewLC@CUpnpAVDeviceList@@SAPAV1@XZ @ 24 NONAME ; class CUpnpAVDeviceList * CUpnpAVDeviceList::NewLC(void)
-	?NewUPnPAVControllerL@UPnPAVControllerFactory@@SAPAVMUPnPAVController@@XZ @ 25 NONAME ; class MUPnPAVController * UPnPAVControllerFactory::NewUPnPAVControllerL(void)
-	?NewUPnPAVControllerLC@UPnPAVControllerFactory@@SAPAVMUPnPAVController@@XZ @ 26 NONAME ; class MUPnPAVController * UPnPAVControllerFactory::NewUPnPAVControllerLC(void)
-	?NextAVTransportUri@CUpnpAVDevice@@QBEHXZ @ 27 NONAME ; int CUpnpAVDevice::NextAVTransportUri(void) const
-	?PauseCapability@CUpnpAVDevice@@QBEHXZ @ 28 NONAME ; int CUpnpAVDevice::PauseCapability(void) const
-	?Remove@CUpnpAVDeviceList@@QAEXH@Z @ 29 NONAME ; void CUpnpAVDeviceList::Remove(int)
-	?RemoveAndDestroy@CUpnpAVDeviceList@@QAEXH@Z @ 30 NONAME ; void CUpnpAVDeviceList::RemoveAndDestroy(int)
-	?Reset@CUpnpAVDeviceList@@QAEXXZ @ 31 NONAME ; void CUpnpAVDeviceList::Reset(void)
-	?ResetAndDestroy@CUpnpAVDeviceList@@QAEXXZ @ 32 NONAME ; void CUpnpAVDeviceList::ResetAndDestroy(void)
-	?SearchCapability@CUpnpAVDevice@@QBEHXZ @ 33 NONAME ; int CUpnpAVDevice::SearchCapability(void) const
-	?SetAudioCapability@CUpnpAVDevice@@QAEXH@Z @ 34 NONAME ; void CUpnpAVDevice::SetAudioCapability(int)
-	?SetCapabilitiesBySupportedMimeTypesL@CUpnpAVDevice@@QAEXABVTDesC8@@@Z @ 35 NONAME ; void CUpnpAVDevice::SetCapabilitiesBySupportedMimeTypesL(class TDesC8 const &)
-	?SetCopyCapability@CUpnpAVDevice@@QAEXH@Z @ 36 NONAME ; void CUpnpAVDevice::SetCopyCapability(int)
-	?SetDeviceType@CUpnpAVDevice@@QAEXW4TUpnpAVDeviceType@1@@Z @ 37 NONAME ; void CUpnpAVDevice::SetDeviceType(enum CUpnpAVDevice::TUpnpAVDeviceType)
-	?SetFriendlyNameL@CUpnpAVDevice@@QAEXABVTDesC8@@@Z @ 38 NONAME ; void CUpnpAVDevice::SetFriendlyNameL(class TDesC8 const &)
-	?SetImageCapability@CUpnpAVDevice@@QAEXH@Z @ 39 NONAME ; void CUpnpAVDevice::SetImageCapability(int)
-	?SetMaxVolume@CUpnpAVDevice@@QAEXH@Z @ 40 NONAME ; void CUpnpAVDevice::SetMaxVolume(int)
-	?SetMuteCapability@CUpnpAVDevice@@QAEXH@Z @ 41 NONAME ; void CUpnpAVDevice::SetMuteCapability(int)
-	?SetNextAVTransportUri@CUpnpAVDevice@@QAEXH@Z @ 42 NONAME ; void CUpnpAVDevice::SetNextAVTransportUri(int)
-	?SetPauseCapability@CUpnpAVDevice@@QAEXH@Z @ 43 NONAME ; void CUpnpAVDevice::SetPauseCapability(int)
-	?SetSearchCapability@CUpnpAVDevice@@QAEXH@Z @ 44 NONAME ; void CUpnpAVDevice::SetSearchCapability(int)
-	?SetUuidL@CUpnpAVDevice@@QAEXABVTDesC8@@@Z @ 45 NONAME ; void CUpnpAVDevice::SetUuidL(class TDesC8 const &)
-	?SetVideoCapability@CUpnpAVDevice@@QAEXH@Z @ 46 NONAME ; void CUpnpAVDevice::SetVideoCapability(int)
-	?SetVolumeCapability@CUpnpAVDevice@@QAEXH@Z @ 47 NONAME ; void CUpnpAVDevice::SetVolumeCapability(int)
-	?ToDes8L@CUpnpAVDevice@@QBEPAVHBufC8@@XZ @ 48 NONAME ; class HBufC8 * CUpnpAVDevice::ToDes8L(void) const
-	?ToDes8L@CUpnpAVDeviceList@@QBEPAVHBufC8@@XZ @ 49 NONAME ; class HBufC8 * CUpnpAVDeviceList::ToDes8L(void) const
-	?Uuid@CUpnpAVDevice@@QBEABVTDesC8@@XZ @ 50 NONAME ; class TDesC8 const & CUpnpAVDevice::Uuid(void) const
-	?VideoCapability@CUpnpAVDevice@@QBEHXZ @ 51 NONAME ; int CUpnpAVDevice::VideoCapability(void) const
-	?VolumeCapability@CUpnpAVDevice@@QBEHXZ @ 52 NONAME ; int CUpnpAVDevice::VolumeCapability(void) const
-	?DlnaCompatible@CUpnpAVDevice@@QBEHXZ @ 53 NONAME ; int CUpnpAVDevice::DlnaCompatible(void) const
-	?SetDlnaCompatible@CUpnpAVDevice@@QAEXH@Z @ 54 NONAME ; void CUpnpAVDevice::SetDlnaCompatible(int)
-	?Status@UPnPAVControllerFactory@@SAHAAW4TAVControllerServerStatus@1@@Z @ 55 NONAME ; int UPnPAVControllerFactory::Status(enum UPnPAVControllerFactory::TAVControllerServerStatus &)
-
+EXPORTS
+	??0CUpnpAVDevice@@IAE@XZ @ 1 NONAME ; CUpnpAVDevice::CUpnpAVDevice(void)
+	??1CUpnpAVDevice@@UAE@XZ @ 2 NONAME ; CUpnpAVDevice::~CUpnpAVDevice(void)
+	??ACUpnpAVDeviceList@@QBEPAVCUpnpAVDevice@@H@Z @ 3 NONAME ; class CUpnpAVDevice * CUpnpAVDeviceList::operator[](int) const
+	?AppendDeviceL@CUpnpAVDeviceList@@QAEXAAVCUpnpAVDevice@@@Z @ 4 NONAME ; void CUpnpAVDeviceList::AppendDeviceL(class CUpnpAVDevice &)
+	?AudioCapability@CUpnpAVDevice@@QBEHXZ @ 5 NONAME ; int CUpnpAVDevice::AudioCapability(void) const
+	?CopyCapability@CUpnpAVDevice@@QBEHXZ @ 6 NONAME ; int CUpnpAVDevice::CopyCapability(void) const
+	?CopyFromL@CUpnpAVDevice@@QAEXABV1@@Z @ 7 NONAME ; void CUpnpAVDevice::CopyFromL(class CUpnpAVDevice const &)
+	?Count@CUpnpAVDeviceList@@QBEHXZ @ 8 NONAME ; int CUpnpAVDeviceList::Count(void) const
+	?DeviceType@CUpnpAVDevice@@QBE?AW4TUpnpAVDeviceType@1@XZ @ 9 NONAME ; enum CUpnpAVDevice::TUpnpAVDeviceType CUpnpAVDevice::DeviceType(void) const
+	?DlnaCompatible@CUpnpAVDevice@@QBEHXZ @ 10 NONAME ; int CUpnpAVDevice::DlnaCompatible(void) const
+	?ExternalizeL@CUpnpAVDevice@@QBEXAAVRWriteStream@@@Z @ 11 NONAME ; void CUpnpAVDevice::ExternalizeL(class RWriteStream &) const
+	?ExternalizeL@CUpnpAVDeviceList@@QBEXAAVRWriteStream@@@Z @ 12 NONAME ; void CUpnpAVDeviceList::ExternalizeL(class RWriteStream &) const
+	?FriendlyName@CUpnpAVDevice@@QBEABVTDesC8@@XZ @ 13 NONAME ; class TDesC8 const & CUpnpAVDevice::FriendlyName(void) const
+	?ImageCapability@CUpnpAVDevice@@QBEHXZ @ 14 NONAME ; int CUpnpAVDevice::ImageCapability(void) const
+	?InternalizeL@CUpnpAVDevice@@QAEXAAVRReadStream@@@Z @ 15 NONAME ; void CUpnpAVDevice::InternalizeL(class RReadStream &)
+	?InternalizeL@CUpnpAVDeviceList@@QAEXAAVRReadStream@@@Z @ 16 NONAME ; void CUpnpAVDeviceList::InternalizeL(class RReadStream &)
+	?LinkOffset@CUpnpAVDevice@@SAHXZ @ 17 NONAME ; int CUpnpAVDevice::LinkOffset(void)
+	?MaxVolume@CUpnpAVDevice@@QBEHXZ @ 18 NONAME ; int CUpnpAVDevice::MaxVolume(void) const
+	?ModelName@CUpnpAVDevice@@QBEABVTDesC8@@XZ @ 19 NONAME ; class TDesC8 const & CUpnpAVDevice::ModelName(void) const
+	?MuteCapability@CUpnpAVDevice@@QBEHXZ @ 20 NONAME ; int CUpnpAVDevice::MuteCapability(void) const
+	?NewL@CUpnpAVDevice@@SAPAV1@ABV1@@Z @ 21 NONAME ; class CUpnpAVDevice * CUpnpAVDevice::NewL(class CUpnpAVDevice const &)
+	?NewL@CUpnpAVDevice@@SAPAV1@XZ @ 22 NONAME ; class CUpnpAVDevice * CUpnpAVDevice::NewL(void)
+	?NewL@CUpnpAVDeviceList@@SAPAV1@XZ @ 23 NONAME ; class CUpnpAVDeviceList * CUpnpAVDeviceList::NewL(void)
+	?NewLC@CUpnpAVDevice@@SAPAV1@XZ @ 24 NONAME ; class CUpnpAVDevice * CUpnpAVDevice::NewLC(void)
+	?NewLC@CUpnpAVDeviceList@@SAPAV1@XZ @ 25 NONAME ; class CUpnpAVDeviceList * CUpnpAVDeviceList::NewLC(void)
+	?NewUPnPAVControllerL@UPnPAVControllerFactory@@SAPAVMUPnPAVController@@XZ @ 26 NONAME ; class MUPnPAVController * UPnPAVControllerFactory::NewUPnPAVControllerL(void)
+	?NewUPnPAVControllerLC@UPnPAVControllerFactory@@SAPAVMUPnPAVController@@XZ @ 27 NONAME ; class MUPnPAVController * UPnPAVControllerFactory::NewUPnPAVControllerLC(void)
+	?NextAVTransportUri@CUpnpAVDevice@@QBEHXZ @ 28 NONAME ; int CUpnpAVDevice::NextAVTransportUri(void) const
+	?PauseCapability@CUpnpAVDevice@@QBEHXZ @ 29 NONAME ; int CUpnpAVDevice::PauseCapability(void) const
+	?Remove@CUpnpAVDeviceList@@QAEXH@Z @ 30 NONAME ; void CUpnpAVDeviceList::Remove(int)
+	?RemoveAndDestroy@CUpnpAVDeviceList@@QAEXH@Z @ 31 NONAME ; void CUpnpAVDeviceList::RemoveAndDestroy(int)
+	?Reset@CUpnpAVDeviceList@@QAEXXZ @ 32 NONAME ; void CUpnpAVDeviceList::Reset(void)
+	?ResetAndDestroy@CUpnpAVDeviceList@@QAEXXZ @ 33 NONAME ; void CUpnpAVDeviceList::ResetAndDestroy(void)
+	?SearchCapability@CUpnpAVDevice@@QBEHXZ @ 34 NONAME ; int CUpnpAVDevice::SearchCapability(void) const
+	?SeekCapability@CUpnpAVDevice@@QBE?AW4TSeekMode@1@XZ @ 35 NONAME ; enum CUpnpAVDevice::TSeekMode CUpnpAVDevice::SeekCapability(void) const
+	?SetAudioCapability@CUpnpAVDevice@@QAEXH@Z @ 36 NONAME ; void CUpnpAVDevice::SetAudioCapability(int)
+	?SetCapabilitiesBySupportedMimeTypesL@CUpnpAVDevice@@QAEXABVTDesC8@@@Z @ 37 NONAME ; void CUpnpAVDevice::SetCapabilitiesBySupportedMimeTypesL(class TDesC8 const &)
+	?SetCopyCapability@CUpnpAVDevice@@QAEXH@Z @ 38 NONAME ; void CUpnpAVDevice::SetCopyCapability(int)
+	?SetDeviceType@CUpnpAVDevice@@QAEXW4TUpnpAVDeviceType@1@@Z @ 39 NONAME ; void CUpnpAVDevice::SetDeviceType(enum CUpnpAVDevice::TUpnpAVDeviceType)
+	?SetDlnaCompatible@CUpnpAVDevice@@QAEXH@Z @ 40 NONAME ; void CUpnpAVDevice::SetDlnaCompatible(int)
+	?SetFriendlyNameL@CUpnpAVDevice@@QAEXABVTDesC8@@@Z @ 41 NONAME ; void CUpnpAVDevice::SetFriendlyNameL(class TDesC8 const &)
+	?SetImageCapability@CUpnpAVDevice@@QAEXH@Z @ 42 NONAME ; void CUpnpAVDevice::SetImageCapability(int)
+	?SetMaxVolume@CUpnpAVDevice@@QAEXH@Z @ 43 NONAME ; void CUpnpAVDevice::SetMaxVolume(int)
+	?SetModelNameL@CUpnpAVDevice@@QAEXABVTDesC8@@@Z @ 44 NONAME ; void CUpnpAVDevice::SetModelNameL(class TDesC8 const &)
+	?SetMuteCapability@CUpnpAVDevice@@QAEXH@Z @ 45 NONAME ; void CUpnpAVDevice::SetMuteCapability(int)
+	?SetNextAVTransportUri@CUpnpAVDevice@@QAEXH@Z @ 46 NONAME ; void CUpnpAVDevice::SetNextAVTransportUri(int)
+	?SetPauseCapability@CUpnpAVDevice@@QAEXH@Z @ 47 NONAME ; void CUpnpAVDevice::SetPauseCapability(int)
+	?SetSearchCapability@CUpnpAVDevice@@QAEXH@Z @ 48 NONAME ; void CUpnpAVDevice::SetSearchCapability(int)
+	?SetSeekCapability@CUpnpAVDevice@@QAEXW4TSeekMode@1@@Z @ 49 NONAME ; void CUpnpAVDevice::SetSeekCapability(enum CUpnpAVDevice::TSeekMode)
+	?SetUuidL@CUpnpAVDevice@@QAEXABVTDesC8@@@Z @ 50 NONAME ; void CUpnpAVDevice::SetUuidL(class TDesC8 const &)
+	?SetVideoCapability@CUpnpAVDevice@@QAEXH@Z @ 51 NONAME ; void CUpnpAVDevice::SetVideoCapability(int)
+	?SetVolumeCapability@CUpnpAVDevice@@QAEXH@Z @ 52 NONAME ; void CUpnpAVDevice::SetVolumeCapability(int)
+	?Status@UPnPAVControllerFactory@@SAHAAW4TAVControllerServerStatus@1@@Z @ 53 NONAME ; int UPnPAVControllerFactory::Status(enum UPnPAVControllerFactory::TAVControllerServerStatus &)
+	?ToDes8L@CUpnpAVDevice@@QBEPAVHBufC8@@XZ @ 54 NONAME ; class HBufC8 * CUpnpAVDevice::ToDes8L(void) const
+	?ToDes8L@CUpnpAVDeviceList@@QBEPAVHBufC8@@XZ @ 55 NONAME ; class HBufC8 * CUpnpAVDeviceList::ToDes8L(void) const
+	?Uuid@CUpnpAVDevice@@QBEABVTDesC8@@XZ @ 56 NONAME ; class TDesC8 const & CUpnpAVDevice::Uuid(void) const
+	?VideoCapability@CUpnpAVDevice@@QBEHXZ @ 57 NONAME ; int CUpnpAVDevice::VideoCapability(void) const
+	?VolumeCapability@CUpnpAVDevice@@QBEHXZ @ 58 NONAME ; int CUpnpAVDevice::VolumeCapability(void) const
+
--- a/upnpavcontroller/upnpavcontrollerclient/eabi/upnpavcontrollerclientu.def	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/eabi/upnpavcontrollerclientu.def	Mon Nov 01 12:37:49 2010 +0200
@@ -1,78 +1,81 @@
-EXPORTS
-	_ZN13CUpnpAVDevice10LinkOffsetEv @ 1 NONAME
-	_ZN13CUpnpAVDevice12InternalizeLER11RReadStream @ 2 NONAME
-	_ZN13CUpnpAVDevice12SetMaxVolumeEi @ 3 NONAME
-	_ZN13CUpnpAVDevice13SetDeviceTypeENS_17TUpnpAVDeviceTypeE @ 4 NONAME
-	_ZN13CUpnpAVDevice16SetFriendlyNameLERK6TDesC8 @ 5 NONAME
-	_ZN13CUpnpAVDevice17SetCopyCapabilityEi @ 6 NONAME
-	_ZN13CUpnpAVDevice17SetMuteCapabilityEi @ 7 NONAME
-	_ZN13CUpnpAVDevice18SetAudioCapabilityEi @ 8 NONAME
-	_ZN13CUpnpAVDevice18SetImageCapabilityEi @ 9 NONAME
-	_ZN13CUpnpAVDevice18SetPauseCapabilityEi @ 10 NONAME
-	_ZN13CUpnpAVDevice18SetVideoCapabilityEi @ 11 NONAME
-	_ZN13CUpnpAVDevice19SetSearchCapabilityEi @ 12 NONAME
-	_ZN13CUpnpAVDevice19SetVolumeCapabilityEi @ 13 NONAME
-	_ZN13CUpnpAVDevice21SetNextAVTransportUriEi @ 14 NONAME
-	_ZN13CUpnpAVDevice36SetCapabilitiesBySupportedMimeTypesLERK6TDesC8 @ 15 NONAME
-	_ZN13CUpnpAVDevice4NewLERKS_ @ 16 NONAME
-	_ZN13CUpnpAVDevice4NewLEv @ 17 NONAME
-	_ZN13CUpnpAVDevice5NewLCEv @ 18 NONAME
-	_ZN13CUpnpAVDevice8SetUuidLERK6TDesC8 @ 19 NONAME
-	_ZN13CUpnpAVDevice9CopyFromLERKS_ @ 20 NONAME
-	_ZN13CUpnpAVDeviceC1Ev @ 21 NONAME
-	_ZN13CUpnpAVDeviceC2Ev @ 22 NONAME
-	_ZN13CUpnpAVDeviceD0Ev @ 23 NONAME
-	_ZN13CUpnpAVDeviceD1Ev @ 24 NONAME
-	_ZN13CUpnpAVDeviceD2Ev @ 25 NONAME
-	_ZN17CUpnpAVDeviceList12InternalizeLER11RReadStream @ 26 NONAME
-	_ZN17CUpnpAVDeviceList13AppendDeviceLER13CUpnpAVDevice @ 27 NONAME
-	_ZN17CUpnpAVDeviceList15ResetAndDestroyEv @ 28 NONAME
-	_ZN17CUpnpAVDeviceList16RemoveAndDestroyEi @ 29 NONAME
-	_ZN17CUpnpAVDeviceList4NewLEv @ 30 NONAME
-	_ZN17CUpnpAVDeviceList5NewLCEv @ 31 NONAME
-	_ZN17CUpnpAVDeviceList5ResetEv @ 32 NONAME
-	_ZN17CUpnpAVDeviceList6RemoveEi @ 33 NONAME
-	_ZN23UPnPAVControllerFactory15MSServicesInUseEv @ 34 NONAME
-	_ZN23UPnPAVControllerFactory20NewUPnPAVControllerLEv @ 35 NONAME
-	_ZN23UPnPAVControllerFactory21NewUPnPAVControllerLCEv @ 36 NONAME
-	_ZNK13CUpnpAVDevice10DeviceTypeEv @ 37 NONAME
-	_ZNK13CUpnpAVDevice12ExternalizeLER12RWriteStream @ 38 NONAME
-	_ZNK13CUpnpAVDevice12FriendlyNameEv @ 39 NONAME
-	_ZNK13CUpnpAVDevice14CopyCapabilityEv @ 40 NONAME
-	_ZNK13CUpnpAVDevice14MuteCapabilityEv @ 41 NONAME
-	_ZNK13CUpnpAVDevice15AudioCapabilityEv @ 42 NONAME
-	_ZNK13CUpnpAVDevice15ImageCapabilityEv @ 43 NONAME
-	_ZNK13CUpnpAVDevice15PauseCapabilityEv @ 44 NONAME
-	_ZNK13CUpnpAVDevice15VideoCapabilityEv @ 45 NONAME
-	_ZNK13CUpnpAVDevice16SearchCapabilityEv @ 46 NONAME
-	_ZNK13CUpnpAVDevice16VolumeCapabilityEv @ 47 NONAME
-	_ZNK13CUpnpAVDevice18NextAVTransportUriEv @ 48 NONAME
-	_ZNK13CUpnpAVDevice4UuidEv @ 49 NONAME
-	_ZNK13CUpnpAVDevice7ToDes8LEv @ 50 NONAME
-	_ZNK13CUpnpAVDevice9MaxVolumeEv @ 51 NONAME
-	_ZNK17CUpnpAVDeviceList12ExternalizeLER12RWriteStream @ 52 NONAME
-	_ZNK17CUpnpAVDeviceList5CountEv @ 53 NONAME
-	_ZNK17CUpnpAVDeviceList7ToDes8LEv @ 54 NONAME
-	_ZNK17CUpnpAVDeviceListixEi @ 55 NONAME
-	_ZTI13CUpnpAVDevice @ 56 NONAME ; #<TI>#
-	_ZTI17CUpnpAVDeviceList @ 57 NONAME ; #<TI>#
-	_ZTI18CUPnPAVEventActive @ 58 NONAME ; #<TI>#
-	_ZTI19CUPnPAVDeviceActive @ 59 NONAME ; #<TI>#
-	_ZTI22CUPnPAVRenderingActive @ 60 NONAME ; #<TI>#
-	_ZTI23CUPnPAVConnectionActive @ 61 NONAME ; #<TI>#
-	_ZTI23CUPnPAVControllerActive @ 62 NONAME ; #<TI>#
-	_ZTI26CUPnPAVBrowsingSessionImpl @ 63 NONAME ; #<TI>#
-	_ZTI27CUPnPAVRenderingSessionImpl @ 64 NONAME ; #<TI>#
-	_ZTV13CUpnpAVDevice @ 65 NONAME ; #<VT>#
-	_ZTV17CUpnpAVDeviceList @ 66 NONAME ; #<VT>#
-	_ZTV18CUPnPAVEventActive @ 67 NONAME ; #<VT>#
-	_ZTV19CUPnPAVDeviceActive @ 68 NONAME ; #<VT>#
-	_ZTV22CUPnPAVRenderingActive @ 69 NONAME ; #<VT>#
-	_ZTV23CUPnPAVConnectionActive @ 70 NONAME ; #<VT>#
-	_ZTV23CUPnPAVControllerActive @ 71 NONAME ; #<VT>#
-	_ZTV26CUPnPAVBrowsingSessionImpl @ 72 NONAME ; #<VT>#
-	_ZTV27CUPnPAVRenderingSessionImpl @ 73 NONAME ; #<VT>#
-	_ZN13CUpnpAVDevice17SetDlnaCompatibleEi @ 74 NONAME
-	_ZNK13CUpnpAVDevice14DlnaCompatibleEv @ 75 NONAME
-	_ZN23UPnPAVControllerFactory6StatusERNS_25TAVControllerServerStatusE @ 76 NONAME
-
+EXPORTS
+	_ZN13CUpnpAVDevice10LinkOffsetEv @ 1 NONAME
+	_ZN13CUpnpAVDevice12InternalizeLER11RReadStream @ 2 NONAME
+	_ZN13CUpnpAVDevice12SetMaxVolumeEi @ 3 NONAME
+	_ZN13CUpnpAVDevice13SetDeviceTypeENS_17TUpnpAVDeviceTypeE @ 4 NONAME
+	_ZN13CUpnpAVDevice13SetModelNameLERK6TDesC8 @ 5 NONAME
+	_ZN13CUpnpAVDevice16SetFriendlyNameLERK6TDesC8 @ 6 NONAME
+	_ZN13CUpnpAVDevice17SetCopyCapabilityEi @ 7 NONAME
+	_ZN13CUpnpAVDevice17SetDlnaCompatibleEi @ 8 NONAME
+	_ZN13CUpnpAVDevice17SetMuteCapabilityEi @ 9 NONAME
+	_ZN13CUpnpAVDevice17SetSeekCapabilityENS_9TSeekModeE @ 10 NONAME
+	_ZN13CUpnpAVDevice18SetAudioCapabilityEi @ 11 NONAME
+	_ZN13CUpnpAVDevice18SetImageCapabilityEi @ 12 NONAME
+	_ZN13CUpnpAVDevice18SetPauseCapabilityEi @ 13 NONAME
+	_ZN13CUpnpAVDevice18SetVideoCapabilityEi @ 14 NONAME
+	_ZN13CUpnpAVDevice19SetSearchCapabilityEi @ 15 NONAME
+	_ZN13CUpnpAVDevice19SetVolumeCapabilityEi @ 16 NONAME
+	_ZN13CUpnpAVDevice21SetNextAVTransportUriEi @ 17 NONAME
+	_ZN13CUpnpAVDevice36SetCapabilitiesBySupportedMimeTypesLERK6TDesC8 @ 18 NONAME
+	_ZN13CUpnpAVDevice4NewLERKS_ @ 19 NONAME
+	_ZN13CUpnpAVDevice4NewLEv @ 20 NONAME
+	_ZN13CUpnpAVDevice5NewLCEv @ 21 NONAME
+	_ZN13CUpnpAVDevice8SetUuidLERK6TDesC8 @ 22 NONAME
+	_ZN13CUpnpAVDevice9CopyFromLERKS_ @ 23 NONAME
+	_ZN13CUpnpAVDeviceC1Ev @ 24 NONAME
+	_ZN13CUpnpAVDeviceC2Ev @ 25 NONAME
+	_ZN13CUpnpAVDeviceD0Ev @ 26 NONAME
+	_ZN13CUpnpAVDeviceD1Ev @ 27 NONAME
+	_ZN13CUpnpAVDeviceD2Ev @ 28 NONAME
+	_ZN17CUpnpAVDeviceList12InternalizeLER11RReadStream @ 29 NONAME
+	_ZN17CUpnpAVDeviceList13AppendDeviceLER13CUpnpAVDevice @ 30 NONAME
+	_ZN17CUpnpAVDeviceList15ResetAndDestroyEv @ 31 NONAME
+	_ZN17CUpnpAVDeviceList16RemoveAndDestroyEi @ 32 NONAME
+	_ZN17CUpnpAVDeviceList4NewLEv @ 33 NONAME
+	_ZN17CUpnpAVDeviceList5NewLCEv @ 34 NONAME
+	_ZN17CUpnpAVDeviceList5ResetEv @ 35 NONAME
+	_ZN17CUpnpAVDeviceList6RemoveEi @ 36 NONAME
+	_ZN23UPnPAVControllerFactory20NewUPnPAVControllerLEv @ 37 NONAME
+	_ZN23UPnPAVControllerFactory21NewUPnPAVControllerLCEv @ 38 NONAME
+	_ZN23UPnPAVControllerFactory6StatusERNS_25TAVControllerServerStatusE @ 39 NONAME
+	_ZNK13CUpnpAVDevice10DeviceTypeEv @ 40 NONAME
+	_ZNK13CUpnpAVDevice12ExternalizeLER12RWriteStream @ 41 NONAME
+	_ZNK13CUpnpAVDevice12FriendlyNameEv @ 42 NONAME
+	_ZNK13CUpnpAVDevice14CopyCapabilityEv @ 43 NONAME
+	_ZNK13CUpnpAVDevice14DlnaCompatibleEv @ 44 NONAME
+	_ZNK13CUpnpAVDevice14MuteCapabilityEv @ 45 NONAME
+	_ZNK13CUpnpAVDevice14SeekCapabilityEv @ 46 NONAME
+	_ZNK13CUpnpAVDevice15AudioCapabilityEv @ 47 NONAME
+	_ZNK13CUpnpAVDevice15ImageCapabilityEv @ 48 NONAME
+	_ZNK13CUpnpAVDevice15PauseCapabilityEv @ 49 NONAME
+	_ZNK13CUpnpAVDevice15VideoCapabilityEv @ 50 NONAME
+	_ZNK13CUpnpAVDevice16SearchCapabilityEv @ 51 NONAME
+	_ZNK13CUpnpAVDevice16VolumeCapabilityEv @ 52 NONAME
+	_ZNK13CUpnpAVDevice18NextAVTransportUriEv @ 53 NONAME
+	_ZNK13CUpnpAVDevice4UuidEv @ 54 NONAME
+	_ZNK13CUpnpAVDevice7ToDes8LEv @ 55 NONAME
+	_ZNK13CUpnpAVDevice9MaxVolumeEv @ 56 NONAME
+	_ZNK13CUpnpAVDevice9ModelNameEv @ 57 NONAME
+	_ZNK17CUpnpAVDeviceList12ExternalizeLER12RWriteStream @ 58 NONAME
+	_ZNK17CUpnpAVDeviceList5CountEv @ 59 NONAME
+	_ZNK17CUpnpAVDeviceList7ToDes8LEv @ 60 NONAME
+	_ZNK17CUpnpAVDeviceListixEi @ 61 NONAME
+	_ZTI13CUpnpAVDevice @ 62 NONAME ; #<TI>#
+	_ZTI17CUpnpAVDeviceList @ 63 NONAME ; #<TI>#
+	_ZTI18CUPnPAVEventActive @ 64 NONAME ; #<TI>#
+	_ZTI19CUPnPAVDeviceActive @ 65 NONAME ; #<TI>#
+	_ZTI22CUPnPAVRenderingActive @ 66 NONAME ; #<TI>#
+	_ZTI23CUPnPAVConnectionActive @ 67 NONAME ; #<TI>#
+	_ZTI23CUPnPAVControllerActive @ 68 NONAME ; #<TI>#
+	_ZTI26CUPnPAVBrowsingSessionImpl @ 69 NONAME ; #<TI>#
+	_ZTI27CUPnPAVRenderingSessionImpl @ 70 NONAME ; #<TI>#
+	_ZTV13CUpnpAVDevice @ 71 NONAME ; #<VT>#
+	_ZTV17CUpnpAVDeviceList @ 72 NONAME ; #<VT>#
+	_ZTV18CUPnPAVEventActive @ 73 NONAME ; #<VT>#
+	_ZTV19CUPnPAVDeviceActive @ 74 NONAME ; #<VT>#
+	_ZTV22CUPnPAVRenderingActive @ 75 NONAME ; #<VT>#
+	_ZTV23CUPnPAVConnectionActive @ 76 NONAME ; #<VT>#
+	_ZTV23CUPnPAVControllerActive @ 77 NONAME ; #<VT>#
+	_ZTV26CUPnPAVBrowsingSessionImpl @ 78 NONAME ; #<VT>#
+	_ZTV27CUPnPAVRenderingSessionImpl @ 79 NONAME ; #<VT>#
+
--- a/upnpavcontroller/upnpavcontrollerclient/group/upnpavcontrollerclient.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/group/upnpavcontrollerclient.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,71 +1,74 @@
-/*
-* Copyright (c) 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:      project file for AVController client library
-*
-*/
-
-
-
-
-
-
-#include "../../../group/upnpplatformvar.hrh"
-
-TARGET          upnpavcontrollerclient.dll
-TARGETTYPE      dll
-UID             0x1000008D 0x20007567
-
-CAPABILITY      CAP_GENERAL_DLL
-VENDORID        VID_DEFAULT
-
-VERSION         10.1
-paged
-
-SOURCEPATH      ../src 
-SOURCE          upnpavcontrollerclient.cpp
-SOURCE          upnpavcontrollerfactory.cpp
-SOURCE          upnpavcontrolleractive.cpp
-SOURCE          upnpavrenderingsessionimpl.cpp
-SOURCE          upnpavbrowsingsessionimpl.cpp
-SOURCE          upnpavdevice.cpp
-SOURCE          upnpavdevicelist.cpp
-SOURCE          upnpaveventactive.cpp
-SOURCE          upnpavdeviceactive.cpp
-SOURCE          upnpavrenderingactive.cpp
-SOURCE          upnpavconnectionactive.cpp
-SOURCE          upnpfileuploadsessionimpl.cpp
-SOURCE          upnpfiledownloadsessionimpl.cpp
-
-MW_LAYER_SYSTEMINCLUDE
-USERINCLUDE     ../../../inc
-
-USERINCLUDE     ../inc
-USERINCLUDE     ../../inc
-
-LIBRARY         euser.lib
-LIBRARY         estor.lib
-LIBRARY         upnpavobjects.lib
-LIBRARY         upnpserviceframework.lib
-LIBRARY         upnpipserversutils.lib
-LIBRARY         upnpavcontrollerhelper.lib
-LIBRARY         bafl.lib
-LIBRARY         upnputilities.lib
-LIBRARY         efsrv.lib 
-
-// XML
-LIBRARY         upnpxmlparser.lib
-
-DEBUGLIBRARY    flogger.lib
-
-// End of file
+/*
+* Copyright (c) 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:      project file for AVController client library
+*
+*/
+
+
+
+
+
+
+#include "../../../group/upnpplatformvar.hrh"
+
+TARGET          upnpavcontrollerclient.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x20007567
+
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+VERSION         10.1
+paged
+
+SOURCEPATH      ../src 
+SOURCE          upnpavcontrollerclient.cpp
+SOURCE          upnpavcontrollerfactory.cpp
+SOURCE          upnpavcontrolleractive.cpp
+SOURCE          upnpavrenderingsessionimpl.cpp
+SOURCE          upnpavbrowsingsessionimpl.cpp
+SOURCE          upnpavdevice.cpp
+SOURCE          upnpavdevicelist.cpp
+SOURCE          upnpaveventactive.cpp
+SOURCE          upnpavdeviceactive.cpp
+SOURCE          upnpavrenderingactive.cpp
+SOURCE          upnpavconnectionactive.cpp
+SOURCE          upnpfileuploadsessionimpl.cpp
+SOURCE          upnpfiledownloadsessionimpl.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+USERINCLUDE     ../../../inc
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+
+LIBRARY         euser.lib
+LIBRARY         estor.lib
+LIBRARY         upnpavobjects.lib
+LIBRARY         upnpserviceframework.lib
+LIBRARY         upnpipserversutils.lib
+LIBRARY         upnpavcontrollerhelper.lib
+LIBRARY         bafl.lib
+LIBRARY         upnputilities.lib
+LIBRARY         efsrv.lib 
+
+// XML
+LIBRARY         upnpxmlparser.lib
+
+//utf
+LIBRARY         charconv.lib
+
+DEBUGLIBRARY    flogger.lib
+
+// End of file
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavbrowsingsessionimpl.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavbrowsingsessionimpl.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,299 +1,276 @@
-/*
-* Copyright (c) 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:      implements a session towards a media server
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPAVBROWSINGSESSIONIMPL_H
-#define C_UPNPAVBROWSINGSESSIONIMPL_H
-
-// INCLUDE FILES
-#include <e32std.h>
-#include <e32base.h>
-
-#include "upnpavbrowsingsession.h"
-#include "upnpavdeviceobserver.h"
-#include "upnpavbrowserespparams.h"
-
-// FORWARD DECLARATIONS
-class CUpnpAVDevice;
-class MUPnPAVBrowsingSessionObserver;
-class RUPnPAVControllerClient;
-//class CUPnPXMLParser;
-class CUPnPAVDeviceActive;
-
-/**
- *  AV Controller browsing session implementation.
- *
- *  This class implements the browsing interface of AV Controller. Includes
- *  operations to search, browse, copy, create container, delete object and
- *  to get search capabilities.
- *
- *  @lib upnpavcontrollerclient.lib
- *  @since S60 v3.1
- */
-class CUPnPAVBrowsingSessionImpl :  public CActive,
-                                    public MUPnPAVBrowsingSession,
-                                    public MUPnPAVDeviceObserver
-    {
-
-private:
-
-    /**
-     * Defines internal state of operation
-     */
-    enum TPendingOperation
-        {
-        ENone = 0,
-        EBrowseSize,
-        ESearchSize,
-        EGetSearchCapabilities,
-        ECreateContainer,
-        EDeleteObject,
-        EStartMediaServer
-        };
-
-public:
-
-    /**
-     * Static constructor
-     *
-     * @param aServer handle to AV Controller server
-     * @param aDevice target device
-     * @return a new browsing session implementation instance
-     */
-    static CUPnPAVBrowsingSessionImpl* NewL( RUPnPAVControllerClient&
-        aServer, const CUpnpAVDevice& aDevice );
-
-    /**
-     * Destructor
-     */    
-    virtual ~CUPnPAVBrowsingSessionImpl();
-    
-private:
-
-    /**
-     * 2nd phase construct
-     */    
-    CUPnPAVBrowsingSessionImpl( RUPnPAVControllerClient& aServer );
-    
-    /**
-     * 2nd phase construct
-     */        
-    void ConstructL();
-    
-protected: // From CActive
-
-    void RunL();
-    
-    void DoCancel();
-    
-    TInt RunError( TInt aError );         
-
-protected: // From MUPnPAVBrowser
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void SetObserver( MUPnPAVBrowsingSessionObserver& aObserver);
-     
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void RemoveObserver();
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    MUPnPAVBrowsingSessionObserver* Observer() const;
-    
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    const CUpnpAVDevice& Device() const;
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void ReserveLocalMSServicesL(); 
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void CancelReserveLocalMSServicesL(); 
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void ReleaseLocalMSServicesL(); 
-    
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void BrowseL(   const TDesC8& aId,
-                    const TDesC8& aFilter,
-                    TBrowseFlag aBrowseFlag,
-                    TInt aStartIndex,
-                    TInt aRequestedCount,
-                    const TDesC8& aSortCriteria );                      
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void CancelBrowse();
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void SearchL(   const TDesC8& aId,
-                    const TDesC8& aSearchCriteria,
-                    const TDesC8& aFilter,
-                    TInt aStartIndex,
-                    TInt aRequestedCount,
-                    const TDesC8& aSortCriteria );
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void CancelSearch();
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void GetSearchCapabilitiesL();
-
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void CreateContainerL( const TDesC8& aTitle, const TDesC8& aParentId,
-        TContainerType aContainerType );
-    
-    /**
-     * See upnpavbrowsingsession.h
-     */
-    void DeleteObjectL( const TDesC8& aId );
-
-public: // From MUPnPAVDeviceObserver
-
-    /**
-     * See upnpavdeviceobserver.h
-     */
-    void UPnPDeviceDiscovered( const CUpnpAVDevice& aDevice );
-
-    /**
-     * See upnpavdeviceobserver.h
-     */
-    void UPnPDeviceDisappeared( const CUpnpAVDevice& aDevice );
-
-    /**
-     * See upnpavdeviceobserver.h
-     */
-    void WLANConnectionLost();
-    
-private: // Internal methods
-
-    /**
-     * Handles browse
-     */    
-    void BrowseSizeCompletedL();
-
-    /**
-     * Handles browse
-     */        
-    void BrowseResultCompletedL();
-    
-    /**
-     * Handles search
-     */    
-    void SearchSizeCompletedL();
-
-    /**
-     * Handles search
-     */        
-    void SearchResultCompletedL();    
-
-    /**
-     * Handles search capabilities
-     */        
-    void SearchCapabilitiesCompletedL();
-    
-    /**
-     * Handles create container
-     */                    
-    void CreateContainerCompletedL();
-    
-    /**
-     * Handles delete object
-     */                    
-    void DeleteObjectCompletedL();
-
-    /**
-     * Handles media server start
-     */                        
-    void StartMediaServerCompleteL();
-
-    /**
-     * Reset
-     */                            
-    void ResetL();
-    
-private:
-
-    MUPnPAVBrowsingSessionObserver* iObserver; // not owned
-    
-    RUPnPAVControllerClient&    iServer; // not owned
-    
-    CUpnpAVDevice*              iDevice; // owned
-    
-    // Buffer to pass data to server
-    HBufC8*                     iBuffer; // owned
-    TPtr8                       iBufferPtr;
-
-    // Buffer to pass data to server
-    HBufC8*                     iBuffer2; // owned
-    TPtr8                       iBufferPtr2;
-
-    // Buffer to pass data to server
-    HBufC8*                     iBuffer3; // owned
-    TPtr8                       iBufferPtr3;
-    
-    //CUPnPXMLParser*             iParser; // owned
-    
-    CUPnPAVDeviceActive*        iDeviceActive; // owned
-    
-    TInt                        iRespBufSize;           
-    TPckg<TInt>                 iRespBufSizePkg;
-
-//    TInt                        iRespBufSize;           
-//    TPckg<TInt>                 iRespBufSizePkg;
-
-    TUpnpAVBrowseRespParams         iRespParams;           
-    TPckg<TUpnpAVBrowseRespParams>  iRespParamsPkg;
-    
-    TPendingOperation           iPendingOperation;
-    
-    TBool iAlive;
-    
-    TBool                       iMediaServerResourceReserved;       
-            
-    };
-
-
-#endif // C_UPNPAVBROWSERIMPL_H
+/*
+* Copyright (c) 2006-2009 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:      implements a session towards a media server
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPAVBROWSINGSESSIONIMPL_H
+#define C_UPNPAVBROWSINGSESSIONIMPL_H
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32base.h>
+
+#include "upnpavbrowsingsession.h"
+#include "upnpavdeviceobserver.h"
+#include "upnpavbrowserespparams.h"
+
+// FORWARD DECLARATIONS
+class CUpnpAVDevice;
+class MUPnPAVBrowsingSessionObserver;
+class RUPnPAVControllerClient;
+//class CUPnPXMLParser;
+class CUPnPAVDeviceActive;
+
+/**
+ *  AV Controller browsing session implementation.
+ *
+ *  This class implements the browsing interface of AV Controller. Includes
+ *  operations to search, browse, copy, create container, delete object and
+ *  to get search capabilities.
+ *
+ *  @lib upnpavcontrollerclient.lib
+ *  @since S60 v3.1
+ */
+class CUPnPAVBrowsingSessionImpl :  public CActive,
+                                    public MUPnPAVBrowsingSession,
+                                    public MUPnPAVDeviceObserver
+    {
+
+private:
+
+    /**
+     * Defines internal state of operation
+     */
+    enum TPendingOperation
+        {
+        ENone = 0,
+        EBrowseSize,
+        ESearchSize,
+        EGetSearchCapabilities,
+        ECreateContainer,
+        EDeleteObject
+        };
+
+public:
+
+    /**
+     * Static constructor
+     *
+     * @param aServer handle to AV Controller server
+     * @param aDevice target device
+     * @return a new browsing session implementation instance
+     */
+    static CUPnPAVBrowsingSessionImpl* NewL( RUPnPAVControllerClient&
+        aServer, const CUpnpAVDevice& aDevice );
+
+    /**
+     * Destructor
+     */    
+    virtual ~CUPnPAVBrowsingSessionImpl();
+    
+private:
+
+    /**
+     * 2nd phase construct
+     */    
+    CUPnPAVBrowsingSessionImpl( RUPnPAVControllerClient& aServer );
+    
+    /**
+     * 2nd phase construct
+     */        
+    void ConstructL();
+    
+protected: // From CActive
+
+    void RunL();
+    
+    void DoCancel();
+    
+    TInt RunError( TInt aError );         
+
+protected: // From MUPnPAVBrowser
+
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    void SetObserver( MUPnPAVBrowsingSessionObserver& aObserver);
+     
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    void RemoveObserver();
+
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    MUPnPAVBrowsingSessionObserver* Observer() const;
+    
+
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    const CUpnpAVDevice& Device() const;
+    
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    void BrowseL(   const TDesC8& aId,
+                    const TDesC8& aFilter,
+                    TBrowseFlag aBrowseFlag,
+                    TInt aStartIndex,
+                    TInt aRequestedCount,
+                    const TDesC8& aSortCriteria );                      
+
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    void CancelBrowse();
+
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    void SearchL(   const TDesC8& aId,
+                    const TDesC8& aSearchCriteria,
+                    const TDesC8& aFilter,
+                    TInt aStartIndex,
+                    TInt aRequestedCount,
+                    const TDesC8& aSortCriteria );
+
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    void CancelSearch();
+
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    void GetSearchCapabilitiesL();
+
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    void CreateContainerL( const TDesC8& aTitle, const TDesC8& aParentId,
+        TContainerType aContainerType );
+    
+    /**
+     * See upnpavbrowsingsession.h
+     */
+    void DeleteObjectL( const TDesC8& aId );
+
+public: // From MUPnPAVDeviceObserver
+
+    /**
+     * See upnpavdeviceobserver.h
+     */
+    void UPnPDeviceDiscovered( const CUpnpAVDevice& aDevice );
+
+    /**
+     * See upnpavdeviceobserver.h
+     */
+    void UPnPDeviceDisappeared( const CUpnpAVDevice& aDevice );
+
+    /**
+     * See upnpavdeviceobserver.h
+     */
+    void WLANConnectionLost();
+    
+private: // Internal methods
+
+    /**
+     * Handles browse
+     */    
+    void BrowseSizeCompletedL();
+
+    /**
+     * Handles browse
+     */        
+    void BrowseResultCompletedL();
+    
+    /**
+     * Handles search
+     */    
+    void SearchSizeCompletedL();
+
+    /**
+     * Handles search
+     */        
+    void SearchResultCompletedL();    
+
+    /**
+     * Handles search capabilities
+     */        
+    void SearchCapabilitiesCompletedL();
+    
+    /**
+     * Handles create container
+     */                    
+    void CreateContainerCompletedL();
+    
+    /**
+     * Handles delete object
+     */                    
+    void DeleteObjectCompletedL();
+
+    /**
+     * Handles media server start
+     */                        
+    void StartMediaServerCompleteL();
+
+    /**
+     * Reset
+     */                            
+    void ResetL();
+    
+private:
+
+    MUPnPAVBrowsingSessionObserver* iObserver; // not owned
+    
+    RUPnPAVControllerClient&    iServer; // not owned
+    
+    CUpnpAVDevice*              iDevice; // owned
+    
+    // Buffer to pass data to server
+    HBufC8*                     iBuffer; // owned
+    TPtr8                       iBufferPtr;
+
+    // Buffer to pass data to server
+    HBufC8*                     iBuffer2; // owned
+    TPtr8                       iBufferPtr2;
+
+    // Buffer to pass data to server
+    HBufC8*                     iBuffer3; // owned
+    TPtr8                       iBufferPtr3;
+    
+    CUPnPAVDeviceActive*        iDeviceActive; // owned
+    
+    TInt                        iRespBufSize;           
+    TPckg<TInt>                 iRespBufSizePkg;
+
+    TUpnpAVBrowseRespParams         iRespParams;           
+    TPckg<TUpnpAVBrowseRespParams>  iRespParamsPkg;
+    
+    TPendingOperation           iPendingOperation;
+    
+    TBool iAlive;
+    
+    };
+
+
+#endif // C_UPNPAVBROWSERIMPL_H
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavbrowsingsessionobserver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavbrowsingsessionobserver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,130 +1,128 @@
-/*
-* Copyright (c) 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:      callback interface for browsing session
-*
-*/
-
-
-
-
-
-
-#ifndef M_UPNPAVBROWSINGSESSIONOBSERVER_H
-#define M_UPNPAVBROWSINGSESSIONOBSERVER_H
-
-// INCLUDES
-#include "upnpavsessionobserverbase.h"
-
-// FORWARD DECLARATIONS
-class CUpnpDevice;
-class CUpnpObject;
-
-/**
-* Defines the response interface for the browsing session operations of the
-* UPnP AV Controller.
-*
-* @since Series 60 3.1
-*/
-class MUPnPAVBrowsingSessionObserver : public MUPnPAVSessionObserverBase
-    {
-
-    public:
-
-        /**
-         * Returns a browse result received from a Media Server.
-         *         
-         * @since Series 60 3.1
-         * @param aBrowseResponse browse response xml document
-         * @param aError system wide error code
-         * @param aMatches number of returned items
-         * @param aTotalCount total number of objects on container
-         * @param aUpdateId update id number
-         * @return None
-         */
-        virtual void BrowseResponse(
-                        const TDesC8& aBrowseResponse,
-                        TInt aError,
-                        TInt aMatches,
-                        TInt aTotalCount,
-                        const TDesC8& aUpdateId
-                        ) = 0;
-
-        /**
-         * Returns a search result received from a Media Server.
-         *
-         * @param aSearchResponse search response xml document
-         * @param aError system wide error code
-         * @param aMatches number of returned items
-         * @param aTotalCount total number of resulted items
-         * @param aUpdateId update id number
-         * @return None
-         */
-        virtual void SearchResponse( 
-                        const TDesC8& aSearchResponse,
-                         TInt aError,
-                         TInt aMatches,
-                         TInt aTotalCount,
-                         const TDesC8& aUpdateId
-                         ) = 0;
-
-        /**
-         * Returns search capabilities of the requested Media Server.
-         *
-         * @since Series 60 3.1
-         * @param status aStatus  information
-         * @param aSearchCapabilities the search capabilities
-         * @return None
-         */
-        virtual void SearchCapabilitiesResponse( 
-                         TInt aError,
-                         const TDesC8& aSearchCapabilities 
-                         ) = 0;
-
-        /**
-         * Notifies that the create container operation is complete.
-         *
-         * @since Series 60 3.1
-         * @param aError status information
-         * @param aObjectId  object ID of the new container
-         */
-        virtual void CreateContainerResponse( TInt aError, 
-            const TDesC8& aObjectId ) = 0;
-
-        /**
-         * Notifies that the requested UPnP Object deletion is complete.
-         *
-         * @since Series 60 3.1
-         * @param aStatus status information
-         * @return None
-         */
-        virtual void DeleteObjectResponse( TInt aError ) = 0;
-        
-        /**
-         * Notifies that the Media Server we have a session with has
-         * disappeared. Session is now unusable and must be closed. 
-         *
-         * @since Series 60 3.1
-         * @param aReason reason code
-         * @return None
-         */        
-        virtual void MediaServerDisappeared(
-            TUPnPDeviceDisconnectedReason aReason ) = 0;
-            
-        virtual void ReserveLocalMSServicesCompleted( TInt aError ) = 0;            
-       
-    };
-
-#endif // M_UPNPAVBROWSINGSESSIONOBSERVER_H
-
-// End of File
+/*
+* Copyright (c) 2006-2009 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:      callback interface for browsing session
+*
+*/
+
+
+
+
+
+
+#ifndef M_UPNPAVBROWSINGSESSIONOBSERVER_H
+#define M_UPNPAVBROWSINGSESSIONOBSERVER_H
+
+// INCLUDES
+#include "upnpavsessionobserverbase.h"
+
+// FORWARD DECLARATIONS
+class CUpnpDevice;
+class CUpnpObject;
+
+/**
+* Defines the response interface for the browsing session operations of the
+* UPnP AV Controller.
+*
+* @since Series 60 3.1
+*/
+class MUPnPAVBrowsingSessionObserver : public MUPnPAVSessionObserverBase
+    {
+
+    public:
+
+        /**
+         * Returns a browse result received from a Media Server.
+         *         
+         * @since Series 60 3.1
+         * @param aBrowseResponse browse response xml document
+         * @param aError system wide error code
+         * @param aMatches number of returned items
+         * @param aTotalCount total number of objects on container
+         * @param aUpdateId update id number
+         * @return None
+         */
+        virtual void BrowseResponse(
+                        const TDesC8& aBrowseResponse,
+                        TInt aError,
+                        TInt aMatches,
+                        TInt aTotalCount,
+                        const TDesC8& aUpdateId
+                        ) = 0;
+
+        /**
+         * Returns a search result received from a Media Server.
+         *
+         * @param aSearchResponse search response xml document
+         * @param aError system wide error code
+         * @param aMatches number of returned items
+         * @param aTotalCount total number of resulted items
+         * @param aUpdateId update id number
+         * @return None
+         */
+        virtual void SearchResponse( 
+                        const TDesC8& aSearchResponse,
+                         TInt aError,
+                         TInt aMatches,
+                         TInt aTotalCount,
+                         const TDesC8& aUpdateId
+                         ) = 0;
+
+        /**
+         * Returns search capabilities of the requested Media Server.
+         *
+         * @since Series 60 3.1
+         * @param status aStatus  information
+         * @param aSearchCapabilities the search capabilities
+         * @return None
+         */
+        virtual void SearchCapabilitiesResponse( 
+                         TInt aError,
+                         const TDesC8& aSearchCapabilities 
+                         ) = 0;
+
+        /**
+         * Notifies that the create container operation is complete.
+         *
+         * @since Series 60 3.1
+         * @param aError status information
+         * @param aObjectId  object ID of the new container
+         */
+        virtual void CreateContainerResponse( TInt aError, 
+            const TDesC8& aObjectId ) = 0;
+
+        /**
+         * Notifies that the requested UPnP Object deletion is complete.
+         *
+         * @since Series 60 3.1
+         * @param aStatus status information
+         * @return None
+         */
+        virtual void DeleteObjectResponse( TInt aError ) = 0;
+        
+        /**
+         * Notifies that the Media Server we have a session with has
+         * disappeared. Session is now unusable and must be closed. 
+         *
+         * @since Series 60 3.1
+         * @param aReason reason code
+         * @return None
+         */        
+        virtual void MediaServerDisappeared(
+            TUPnPDeviceDisconnectedReason aReason ) = 0;            
+       
+    };
+
+#endif // M_UPNPAVBROWSINGSESSIONOBSERVER_H
+
+// End of File
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontroller.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontroller.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,209 +1,208 @@
-/*
-* Copyright (c) 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:      AVController interface
-*
-*/
-
-
-
-
-
-
-#ifndef M_UPNPAVCONTROLLER_H
-#define M_UPNPAVCONTROLLER_H
-
-// INCLUDE FILES
-#include <e32std.h>
-#include "upnpavcontrollerglobals.h"
-
-// FORWARD DECLARATIONS
-class MUPnPAVDeviceObserver;
-class CUpnpAVDeviceList;
-class CUpnpAVDevice;
-class MUPnPAVBrowsingSession;
-class MUPnPAVRenderingSession;
-class MUPnPFileUploadSession;
-class MUPnPFileDownloadSession;
-
-/**
- *  Defines the AV Controller interface
- *
- *  This class defines the AV Controller interface. Provides methods to
- *  get devices and to start and stop rendering and browsing sessions.
- *
- *  @lib upnpavcontrollerclient.lib
- *  @since S60 v3.1
- */
-class MUPnPAVController
-    {
-
-public:
-
-    /**
-     * Sets Device observer instance
-     *
-     * @since Series 60 3.1     
-     * @param aInstance MUPnPAVDeviceObserver instance of the class that 
-     *        implements the IF
-     * @return TInt status
-     */
-    virtual void SetDeviceObserver( MUPnPAVDeviceObserver& aObserver ) = 0;
-
-    /**
-     * Removes Device observer instance
-     *
-     * @since Series 60 3.1     
-     * @param None
-     * @return None
-     */
-    virtual void RemoveDeviceObserver() = 0;
-    
-    /**
-     * Returns Device observer instance
-     *
-     * @since Series 60 3.1     
-     * @param None
-     * @return observer pointer
-     */
-    virtual MUPnPAVDeviceObserver* DeviceObserver() = 0;
-
-    /**
-     * Start a browsing session with a media server
-     *
-     * @since Series 60 3.1
-     * @param aDevice media server
-     * @return session reference
-     */    
-    virtual MUPnPAVBrowsingSession& StartBrowsingSessionL(
-        const CUpnpAVDevice& aDevice ) = 0;
-
-    /**
-     * Stop a browsing session with a media server
-     *
-     * @since Series 60 3.1
-     * @param aSession session reference
-     * @return None
-     */    
-    virtual void StopBrowsingSession( MUPnPAVBrowsingSession& aSession ) = 0;
-    
-    /**
-     * Start a rendering session with a media renderer
-     *
-     * @since Series 60 3.1
-     * @param aDevice media renderer
-     * @return session reference
-     */    
-    virtual MUPnPAVRenderingSession& StartRenderingSessionL(
-        const CUpnpAVDevice& aDevice ) = 0;
-    
-    /**
-     * Stop a rendering session with a media server
-     *
-     * @since Series 60 3.1
-     * @param aSession session reference
-     * @return None
-     */    
-    virtual void StopRenderingSession(
-        MUPnPAVRenderingSession& aSession ) = 0;
-
-    /**
-     * Start an upload session with a media server
-     *
-     * @since Series 60 3.1
-     * @param aDevice media renderer
-     * @return session reference
-     */    
-    virtual MUPnPFileUploadSession& StartUploadSessionL(
-        const CUpnpAVDevice& aDevice ) = 0;
-    
-    /**
-     * Stop an upload session
-     *
-     * @since Series 60 3.1
-     * @param aSession session reference
-     * @return None
-     */    
-    virtual void StopUploadSession(
-        MUPnPFileUploadSession& aSession ) = 0;    
-
-    /**
-     * Start a download session with a media server
-     *
-     * @since Series 60 3.1
-     * @param aDevice media renderer
-     * @return session reference
-     */    
-    virtual MUPnPFileDownloadSession& StartDownloadSessionL(
-        const CUpnpAVDevice& aDevice ) = 0;
-    
-    /**
-     * Stop a download session
-     *
-     * @since Series 60 3.1
-     * @param aSession session reference
-     * @return None
-     */    
-    virtual void StopDownloadSession(
-        MUPnPFileDownloadSession& aSession ) = 0;    
-
-// =======================================================
-// DEVICE CONTROL METHODS
-// =======================================================
-public:
-
-    /**
-     * Gets the list of online Media Server devices.
-     *
-     * The client must release the memory allocated for the items 
-     * in the array.
-     *
-     * @since Series 60 3.1
-     * @param none
-     * @return device list
-     */
-    virtual CUpnpAVDeviceList* GetMediaServersL() = 0;
-
-    /**
-     * Gets the list of online Media Renderer devices.
-     *
-     * The client must release the memory allocated for the items 
-     * in the array.
-     *
-     * @since Series 60 3.1
-     * @param none
-     * @return device list
-     */
-    virtual CUpnpAVDeviceList* GetMediaRenderersL() = 0;
-    
-public: // Destructor    
-
-    /**
-     * Destructor
-     * DEPRACATED, usage of Release() recommended. Will be removed in the
-     * future. Safe deletion is not guaranteed.
-     *
-     * @since Series 60 3.1
-     */   
-    virtual ~MUPnPAVController() {};
-    
-    /**
-     * Destructor. Ensures safe deletion (also during WLAN disconnection).
-     *
-     * @since Series 60 3.2
-     */    
-    virtual void Release() = 0;
-    };
-
-
-#endif // M_UPNPAVCONTROLLER_H
+/*
+* Copyright (c) 2006-2009 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:      AVController interface
+*
+*/
+
+
+
+
+
+
+#ifndef M_UPNPAVCONTROLLER_H
+#define M_UPNPAVCONTROLLER_H
+
+// INCLUDE FILES
+#include <e32std.h>
+#include "upnpavcontrollerglobals.h"
+
+// FORWARD DECLARATIONS
+class MUPnPAVDeviceObserver;
+class CUpnpAVDeviceList;
+class CUpnpAVDevice;
+class MUPnPAVBrowsingSession;
+class MUPnPAVRenderingSession;
+class MUPnPFileUploadSession;
+class MUPnPFileDownloadSession;
+
+/**
+ *  Defines the AV Controller interface
+ *
+ *  This class defines the AV Controller interface. Provides methods to
+ *  get devices and to start and stop rendering and browsing sessions.
+ *
+ *  @lib upnpavcontrollerclient.lib
+ *  @since S60 v3.1
+ */
+class MUPnPAVController
+    {
+
+public:
+
+    /**
+     * Sets Device observer instance
+     *
+     * @since Series 60 3.1     
+     * @param aInstance MUPnPAVDeviceObserver instance of the class that 
+     *        implements the IF
+     * @return TInt status
+     */
+    virtual void SetDeviceObserver( MUPnPAVDeviceObserver& aObserver ) = 0;
+
+    /**
+     * Removes Device observer instance
+     *
+     * @since Series 60 3.1     
+     * @param None
+     * @return None
+     */
+    virtual void RemoveDeviceObserver() = 0;
+    
+    /**
+     * Returns Device observer instance
+     *
+     * @since Series 60 3.1     
+     * @param None
+     * @return observer pointer
+     */
+    virtual MUPnPAVDeviceObserver* DeviceObserver() = 0;
+
+    /**
+     * Start a browsing session with a media server
+     *
+     * @since Series 60 3.1
+     * @param aDevice media server
+     * @return session reference
+     */    
+    virtual MUPnPAVBrowsingSession& StartBrowsingSessionL(
+        const CUpnpAVDevice& aDevice ) = 0;
+
+    /**
+     * Stop a browsing session with a media server
+     *
+     * @since Series 60 3.1
+     * @param aSession session reference
+     * @return None
+     */    
+    virtual void StopBrowsingSession( MUPnPAVBrowsingSession& aSession ) = 0;
+    
+    /**
+     * Start a rendering session with a media renderer
+     *
+     * @since Series 60 3.1
+     * @param aDevice media renderer
+     * @return session reference
+     */    
+    virtual MUPnPAVRenderingSession& StartRenderingSessionL(
+        const CUpnpAVDevice& aDevice ) = 0;
+    
+    /**
+     * Stop a rendering session with a media server
+     *
+     * @since Series 60 3.1
+     * @param aSession session reference
+     * @return None
+     */    
+    virtual void StopRenderingSession(
+        MUPnPAVRenderingSession& aSession ) = 0;
+
+    /**
+     * Start an upload session with a media server
+     *
+     * @since Series 60 3.1
+     * @param aDevice media renderer
+     * @return session reference
+     */    
+    virtual MUPnPFileUploadSession& StartUploadSessionL(
+        const CUpnpAVDevice& aDevice ) = 0;
+    
+    /**
+     * Stop an upload session
+     *
+     * @since Series 60 3.1
+     * @param aSession session reference
+     * @return None
+     */    
+    virtual void StopUploadSession(
+        MUPnPFileUploadSession& aSession ) = 0;    
+
+    /**
+     * Start a download session with a media server
+     *
+     * @since Series 60 3.1
+     * @param aDevice media renderer
+     * @return session reference
+     */    
+    virtual MUPnPFileDownloadSession& StartDownloadSessionL(
+        const CUpnpAVDevice& aDevice ) = 0;
+    
+    /**
+     * Stop a download session
+     *
+     * @since Series 60 3.1
+     * @param aSession session reference
+     * @return None
+     */    
+    virtual void StopDownloadSession(
+        MUPnPFileDownloadSession& aSession ) = 0;    
+
+// =======================================================
+// DEVICE CONTROL METHODS
+// =======================================================
+public:
+
+    /**
+     * Gets the list of online Media Server devices.
+     *
+     * The client must release the memory allocated for the items 
+     * in the array.
+     *
+     * @since Series 60 3.1
+     * @param none
+     * @return device list
+     */
+    virtual CUpnpAVDeviceList* GetMediaServersL() = 0;
+
+    /**
+     * Gets the list of online Media Renderer devices.
+     *
+     * The client must release the memory allocated for the items 
+     * in the array.
+     *
+     * @since Series 60 3.1
+     * @param none
+     * @return device list
+     */
+    virtual CUpnpAVDeviceList* GetMediaRenderersL() = 0;
+
+    /**
+     * Return device specific icon as image data (e.g. jpg, png etc) read into descriptor.
+     * 
+     * @param aUuid uuid of media device
+     * @return Image data or empty buffer if there is no icon. Ownership is transferred.
+     */
+    virtual HBufC8* GetDeviceIconL( const TDesC8& aUuid ) = 0;
+
+public: // Destructor    
+    
+    /**
+     * Destructor. Ensures safe deletion (also during WLAN disconnection).
+     *
+     * @since Series 60 3.2
+     */    
+    virtual void Release() = 0;
+    };
+
+
+#endif // M_UPNPAVCONTROLLER_H
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrolleractive.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrolleractive.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,228 +1,231 @@
-/*
-* Copyright (c) 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:      AO for monitoring device events
-*
-*/
-
-
-
-
-
-
-
-#ifndef C_UPNPAVCONTROLLERACTIVE_H
-#define C_UPNPAVCONTROLLERACTIVE_H
-
-// INCLUDE FILES
-#include <e32base.h>
-#include "upnpavcontroller.h"
-
-#include "upnpconnectionmonitorobserver.h"
-#include "upnpavcontrollerclient.h"
-
-// FORWARD DECLARATIONS
-class MUPnPAVDeviceObserver;
-
-class CUPnPAVBrowsingSessionImpl;
-class CUPnPAVRenderingSessionImpl;
-class CUPnPAVDeviceActive;
-class CUPnPAVConnectionActive;
-class MUPnPFileDownloadSession;
-class MUPnPFileUploadSession;
-class CUPnPFileUploadSessionImpl;
-class CUPnPFileDownloadSessionImpl;
-
-/**
- *  Implements the AV Controller interface
- *
- *  This class implements the AV Controller interface. Provides methods to
- *  get devices and to start and stop rendering and browsing sessions.
- *
- *  @lib upnpavcontrollerclient.lib
- *  @since S60 v3.1
- */
-class CUPnPAVControllerActive : public CActive,
-                                public MUPnPAVController,
-                                public MUPnPConnectionMonitorObserver
-    {
-
-private:
-
-    /**
-     * Release (delete) state. Declares state variables to determine if
-     * deletion is safe.
-     */    
-    enum TReleaseState
-        {
-        EStateReleasable = 0,
-        EStateWLANLost,
-        EStateWaitingForRelease
-        };
-
-public:
-
-    /**
-     * Static constructor
-     *
-     * @param nonr
-     * @return a new av controller instance
-     */
-    static CUPnPAVControllerActive* NewL();
-
-    /**
-     * Static constructor
-     *
-     * @param nonr
-     * @return a new av controller instance
-     */    
-    static CUPnPAVControllerActive* NewLC();
-       
-    /**
-     * Destructor. Ensures safe deletion (also during WLAN disconnection).
-     */    
-    virtual void Release();
-    
-    /**
-     * Destructor
-     * DEPRACATED, usage of Release() recommended. Will be removed in the
-     * future. Safe deletion is not guaranteed.
-     */    
-    virtual ~CUPnPAVControllerActive();
-    
-private:
-
-    /**
-     * 2nd phase construct
-     */    
-    CUPnPAVControllerActive();    
-
-    /**
-     * 2nd phase construct
-     */        
-    void ConstructL();
-    
-protected: // From CActive
-
-    void RunL();
-    
-    void DoCancel();
-    
-    TInt RunError( TInt aError );
-
-protected: // From MUPnPAVController
-
-    /**
-     * See upnpavcontroller.h
-     */
-    void SetDeviceObserver( MUPnPAVDeviceObserver& aObserver );
-
-    /**
-     * See upnpavcontroller.h
-     */
-    void RemoveDeviceObserver();
-
-    /**
-     * See upnpavcontroller.h
-     */
-    MUPnPAVDeviceObserver* DeviceObserver();
-
-    /**
-     * See upnpavcontroller.h
-     */
-    CUpnpAVDeviceList* GetMediaServersL();
-
-    /**
-     * See upnpavcontroller.h
-     */
-    CUpnpAVDeviceList* GetMediaRenderersL();
-    
-    /**
-     * See upnpavcontroller.h
-     */
-    MUPnPAVBrowsingSession& StartBrowsingSessionL(
-        const CUpnpAVDevice& aDevice );
-
-    /**
-     * See upnpavcontroller.h
-     */
-    void StopBrowsingSession( MUPnPAVBrowsingSession& aSession );
-    
-    /**
-     * See upnpavcontroller.h
-     */
-    MUPnPAVRenderingSession& StartRenderingSessionL(
-        const CUpnpAVDevice& aDevice );
-    
-    /**
-     * See upnpavcontroller.h
-     */
-    void StopRenderingSession( MUPnPAVRenderingSession& aSession );
-
-    /**
-     * See upnpavcontroller.h
-     */
-    MUPnPFileUploadSession& StartUploadSessionL(
-        const CUpnpAVDevice& aDevice );
-    
-    /**
-     * See upnpavcontroller.h
-     */
-    void StopUploadSession( MUPnPFileUploadSession& aSession );    
-
-    /**
-     * See upnpavcontroller.h
-     */
-    MUPnPFileDownloadSession& StartDownloadSessionL(
-        const CUpnpAVDevice& aDevice );
-    
-    /**
-     * See upnpavcontroller.h
-     */
-    void StopDownloadSession( MUPnPFileDownloadSession& aSession );
-    
-protected: // From CUPnPConnectionMonitorObserver
-
-    void ConnectionLost();    
-
-private:
-    
-    MUPnPAVDeviceObserver*                      iDeviceObserver; // not owned
-    
-    CUPnPAVConnectionActive*                    iConnectionActive; // owned
-    
-    RUPnPAVControllerClient                     iServer;
-    
-    RPointerArray<CUPnPAVBrowsingSessionImpl>   iBrowsingSessions;
-    
-    RPointerArray<CUPnPAVRenderingSessionImpl>  iRenderingSessions;
-
-    RPointerArray<CUPnPFileUploadSessionImpl>   iUploadSessions;
-    
-    RPointerArray<CUPnPFileDownloadSessionImpl> iDownloadSessions;
-    
-    TInt                                        iRespBufSize;           
-    TPckg<TInt>                                 iRespBufSizePkg;
-    
-    TAVControllerDeviceDiscovery                iDiscovered;
-    TPckg<TAVControllerDeviceDiscovery>         iDiscoveredPkg;
-    
-    TBool iAlive;
-    
-    CActiveSchedulerWait                        iWait;
-    
-    TReleaseState                               iReleaseState;
-
-    };
-
-#endif // C_UPNPAVCONTROLLERACTIVE_H
+/*
+* Copyright (c) 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:      AO for monitoring device events
+*
+*/
+
+
+
+
+
+
+
+#ifndef C_UPNPAVCONTROLLERACTIVE_H
+#define C_UPNPAVCONTROLLERACTIVE_H
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "upnpavcontroller.h"
+
+#include "upnpconnectionmonitorobserver.h"
+#include "upnpavcontrollerclient.h"
+
+// FORWARD DECLARATIONS
+class MUPnPAVDeviceObserver;
+
+class CUPnPAVBrowsingSessionImpl;
+class CUPnPAVRenderingSessionImpl;
+class CUPnPAVDeviceActive;
+class CUPnPAVConnectionActive;
+class MUPnPFileDownloadSession;
+class MUPnPFileUploadSession;
+class CUPnPFileUploadSessionImpl;
+class CUPnPFileDownloadSessionImpl;
+
+/**
+ *  Implements the AV Controller interface
+ *
+ *  This class implements the AV Controller interface. Provides methods to
+ *  get devices and to start and stop rendering and browsing sessions.
+ *
+ *  @lib upnpavcontrollerclient.lib
+ *  @since S60 v3.1
+ */
+class CUPnPAVControllerActive : public CActive,
+                                public MUPnPAVController,
+                                public MUPnPConnectionMonitorObserver
+    {
+
+private:
+
+    /**
+     * Release (delete) state. Declares state variables to determine if
+     * deletion is safe.
+     */    
+    enum TReleaseState
+        {
+        EStateReleasable = 0,
+        EStateWLANLost,
+        EStateWaitingForRelease
+        };
+
+public:
+
+    /**
+     * Static constructor
+     *
+     * @param nonr
+     * @return a new av controller instance
+     */
+    static CUPnPAVControllerActive* NewL();
+
+    /**
+     * Static constructor
+     *
+     * @param nonr
+     * @return a new av controller instance
+     */    
+    static CUPnPAVControllerActive* NewLC();
+       
+    /**
+     * Destructor. Ensures safe deletion (also during WLAN disconnection).
+     */    
+    virtual void Release();
+    
+    /**
+     * Destructor
+     * DEPRACATED, usage of Release() recommended. Will be removed in the
+     * future. Safe deletion is not guaranteed.
+     */    
+    virtual ~CUPnPAVControllerActive();
+    
+private:
+
+    /**
+     * 2nd phase construct
+     */    
+    CUPnPAVControllerActive();    
+
+    /**
+     * 2nd phase construct
+     */        
+    void ConstructL();
+    
+protected: // From CActive
+
+    void RunL();
+    
+    void DoCancel();
+    
+    TInt RunError( TInt aError );
+
+protected: // From MUPnPAVController
+
+    /**
+     * See upnpavcontroller.h
+     */
+    void SetDeviceObserver( MUPnPAVDeviceObserver& aObserver );
+
+    /**
+     * See upnpavcontroller.h
+     */
+    void RemoveDeviceObserver();
+
+    /**
+     * See upnpavcontroller.h
+     */
+    MUPnPAVDeviceObserver* DeviceObserver();
+
+    /**
+     * See upnpavcontroller.h
+     */
+    CUpnpAVDeviceList* GetMediaServersL();
+
+    /**
+     * See upnpavcontroller.h
+     */
+    CUpnpAVDeviceList* GetMediaRenderersL();
+    
+    /**
+     * See upnpavcontroller.h
+     */
+    MUPnPAVBrowsingSession& StartBrowsingSessionL(
+        const CUpnpAVDevice& aDevice );
+
+    /**
+     * See upnpavcontroller.h
+     */
+    void StopBrowsingSession( MUPnPAVBrowsingSession& aSession );
+    
+    /**
+     * See upnpavcontroller.h
+     */
+    MUPnPAVRenderingSession& StartRenderingSessionL(
+        const CUpnpAVDevice& aDevice );
+    
+    /**
+     * See upnpavcontroller.h
+     */
+    void StopRenderingSession( MUPnPAVRenderingSession& aSession );
+
+    /**
+     * See upnpavcontroller.h
+     */
+    MUPnPFileUploadSession& StartUploadSessionL(
+        const CUpnpAVDevice& aDevice );
+    
+    /**
+     * See upnpavcontroller.h
+     */
+    void StopUploadSession( MUPnPFileUploadSession& aSession );    
+
+    /**
+     * See upnpavcontroller.h
+     */
+    MUPnPFileDownloadSession& StartDownloadSessionL(
+        const CUpnpAVDevice& aDevice );
+    
+    /**
+     * See upnpavcontroller.h
+     */
+    void StopDownloadSession( MUPnPFileDownloadSession& aSession );
+    
+    /**
+     * See upnpavcontroller.h
+     */
+    HBufC8* GetDeviceIconL( const TDesC8& aUuid );
+    
+protected: // From CUPnPConnectionMonitorObserver
+
+    void ConnectionLost( TBool aUserOriented );
+
+private:
+    
+    MUPnPAVDeviceObserver*                      iDeviceObserver; // not owned
+    
+    CUPnPAVConnectionActive*                    iConnectionActive; // owned
+    
+    RUPnPAVControllerClient                     iServer;
+    
+    RPointerArray<CUPnPAVBrowsingSessionImpl>   iBrowsingSessions;
+    
+    RPointerArray<CUPnPAVRenderingSessionImpl>  iRenderingSessions;
+
+    RPointerArray<CUPnPFileUploadSessionImpl>   iUploadSessions;
+    
+    RPointerArray<CUPnPFileDownloadSessionImpl> iDownloadSessions;
+    
+    TInt                                        iRespBufSize;           
+    TPckg<TInt>                                 iRespBufSizePkg;
+    
+    TAVControllerDeviceDiscovery                iDiscovered;
+    TPckg<TAVControllerDeviceDiscovery>         iDiscoveredPkg;
+    
+    TBool iAlive;
+    
+    TReleaseState                               iReleaseState;
+
+    };
+
+#endif // C_UPNPAVCONTROLLERACTIVE_H
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrollerclient.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrollerclient.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,620 +1,627 @@
-/*
-* Copyright (c) 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:      AVController client session
-*
-*/
-
-
-
-
-
-
-#ifndef C_CUPNPAVCONTROLLERCLIENT_H
-#define C_CUPNPAVCONTROLLERCLIENT_H
-
-// INCLUDES
-#include "upnpavcontrollerglobals.h"
-
-#include <e32base.h>
-
-// FORWARD DECLARATIONS
-class CUpnpItem;
-class CUpnpContainer;
-class CUpnpDevice;
-class CUpnpObject;
-class RFile;
-
-// CLASS DECLARATION
-/**
- *  Client-side interface to AV Controller Server
- *
- *  This class provides the client-side interface to the AV Controller
- *  Server session.
- *
- *  @lib upnpavcontrollerclient.lib
- *  @since S60 v3.1
- */
-class RUPnPAVControllerClient : public RSessionBase
-    {
-public:
-
-    /**
-     * Construct the object
-     */
-    RUPnPAVControllerClient();
-
-    /**
-     * Connects to the server and create a session
-     * @return error code
-     */
-    TInt Connect();
-    
-    /**
-     * Returns the version number
-     * @return the version
-     */
-    TVersion Version() const;
-
-    /**
-     * Startup request. Starts up the AV Control Point
-     *
-     * @param aStatus request status
-     */    
-    void StartUp( TRequestStatus& aStatus );
-
-    /**
-     * Cancels startup.
-     *
-     * @return error code
-     */    
-    TInt CancelStartUp();
-
-    /**
-     * Device discovery request
-     *
-     * @param aDiscovered type of device
-     * @param aRcvdBufSize size of device
-     * @param aStatus request status
-     */    
-    void DeviceRequest( TDes8& aDiscovered, TDes8& aRcvdBufSize,
-        TRequestStatus& aStatus );
-        
-    /**
-     * Cancels device discovery request
-     *
-     * @return error code
-     */    
-    TInt CancelDeviceRequest();
-    
-    /**
-     * Gets device
-     *
-     * @param aDevice device
-     * @return error code
-     */    
-    TInt GetDevice( TDes8& aDevice );
-    
-    /**
-     * Gets device list size
-     *
-     * @param aType type of devices
-     * @param aSize size of the list
-     * @return error code
-     */    
-    TInt GetDeviceListSize( TDes8& aType, TDes8& aSize );
-    
-    /**
-     * Gets device list
-     * 
-     * @param aList device list
-     * @return error code
-     */    
-    TInt GetDeviceList( TDes8& aList );
-    
-    /**
-     * Release media server
-     *
-     * @param aId session id
-     * @return error code
-     */    
-    TInt ReleaseMediaServer( TInt aId );
-    
-    /**
-     * Reserve media server
-     * 
-     * @param aId session id
-     * @param aStatus request status
-     */    
-    void ReserveMediaServer( TInt aId, TRequestStatus& aStatus );
-    
-    /**
-     * Cancel reserve media server
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelReserveMediaServer( TInt aId );
-
-public: // Rendering Session releated
-    
-    /**
-     * Create a rendering session
-     * 
-     * @param aId session id
-     * @param aUuid device Uuid
-     * @return error code
-     */    
-    TInt CreateRenderingSession( TInt aId, TDes8& aUuid );
-    
-    /**
-     * Destroy a rendering session
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt DestroyRenderingSession( TInt aId );
-    
-    /**
-     * AV event request
-     *
-     * @param aEvent AV Event
-     * @param aId session id
-     * @param aStatus request status
-     */    
-    void EventRequest( TDes8& aEvent, TInt aId, TRequestStatus& aStatus );
-    
-    /**
-     * Cancel event request
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelEventRequest( TInt aId );
-    
-    /**
-     * Set URI
-     *
-     * @param aId session id
-     * @param aRequest request information
-     * @param aItem item
-     * @param aType type of the item 
-     * @param aStatus request status
-     */    
-    void SetURI( TInt aId, TDes8& aRequest, TDes8& aItem,
-                                 TRequestStatus& aStatus );
-        
-    /**
-     * Cancel reserve media server
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelSetURI( TInt aId );
-    
-    /**
-     * Set Next URI
-     *
-     * @param aId session id
-     * @param aRequest request information
-     * @param aItem item
-     * @param aType type of the item 
-     * @param aStatus request status
-     */    
-    void SetNextURI( TInt aId, TDes8& Request, TDes8& aItem,
-                                    TRequestStatus& aStatus );
-        
-    /**
-     * Cancel reserve media server
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelSetNextURI( TInt aId );
-    
-    /**
-     * Send play action
-     *
-     * @param aId session id
-     * @param aStatus request status
-     */    
-    void Play( TInt aId, TRequestStatus& aStatus );
-    
-    /**
-     * Cancel play
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelPlay( TInt aId );
-    
-    /**
-     * Send stop action
-     *
-     * @param aId session id
-     * @param aStatus request status
-     */    
-    void Stop( TInt aId, TRequestStatus& aStatus );
-    
-    /**
-     * Cancel stop
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelStop( TInt aId );
-    
-    /**
-     * Send pause action
-     *
-     * @param aId session id
-     * @param aStatus request status
-     */    
-    void Pause( TInt aId, TRequestStatus& aStatus );
-    
-    /**
-     * Cancel pause
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelPause( TInt aId );
-    
-    /**
-     * Set volume level
-     *
-     * @param aId session id
-     * @param aVolumeLevel volume level
-     * @param aRetVolume (set) volume level
-     * @param aStatus request status
-     */    
-    void SetVolume( TInt aId, TInt aVolumeLevel, TDes8& aRetVolume,
-        TRequestStatus& aStatus );
-        
-    /**
-     * Cancel set volume
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelSetVolume( TInt aId );
-    
-    /**
-     * Get volume level
-     *
-     * @param aId session id
-     * @param aVolumeLevel volume level
-     * @param aStatus request status
-     */    
-    void GetVolume( TInt aId, TDes8& aVolumeLevel, TRequestStatus& aStatus );
-    
-    /**
-     * Cancel get volume
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelGetVolume( TInt aId );
-    
-    /**
-     * Set mute
-     *
-     * @param aId session id
-     * @param aMute mute
-     * @param aRetMute (set) mute
-     * @param aStatus request status
-     */    
-    void SetMute( TInt aId, TBool aMute, TDes8& aRetMute,
-        TRequestStatus& aStatus );
-    
-    /**
-     * Cancel set mute
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelSetMute( TInt aId );
-    
-    /**
-     * Get mute
-     *
-     * @param aId session id
-     * @param aMute mute
-     * @param aStatus request status
-     */    
-    void GetMute( TInt aId, TDes8& aMute, TRequestStatus& aStatus );
-    
-    /**
-     * Cancel get mute
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelGetMute( TInt aId );
-     
-    /**
-     * Get position info
-     *
-     * @param aId session id
-     * @param aPosition position info
-     * @param aLength lenght info
-     * @param aStatus request status
-     */    
-    void GetPositionInfo( TInt aId, TDes8& aPosition, TDes8& aLength,
-        TRequestStatus& aStatus );
-        
-    /**
-     * Cancel get position info
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelGetPositionInfo( TInt aId );
-
-public: // Browsing Session releated
-
-    /**
-     * Create browsing session
-     *
-     * @param aId session id
-     * @param aUuid device uuid
-     * @return error code
-     */    
-    TInt CreateBrowsingSession( TInt aId, TDes8& aUuid );
-    
-    /**
-     * Destroy browsing session
-     *
-     * @param aId session id
-     * @return error code
-     */    
-    TInt DestroyBrowsingSession( TInt aId );
-    
-    /**
-     * Get browse response size
-     *
-     * @param aId session id
-     * @param aRequest request information
-     * @param aSize response size
-     * @param aMatches count of items
-     * @param aStatus request status
-     */    
-    void BrowseResponseSize( TInt aId, TDes8& aRequest, TDes8& aParams,
-        TRequestStatus& aStatus );
-    
-    /**
-     * Cancel get browse response size
-     *
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelBrowseResponseSize( TInt aId );
-    
-    /**
-     * Get browse response
-     *
-     * @param aId session id
-     * @param aBrowseResponse browse response
-     * @return error code
-     */    
-    TInt BrowseResponse( TInt aId, TDes8& aBrowseResponse,
-        TDes8& aUpdateId );
-
-    /**
-     * Get search response size
-     *
-     * @param aId session id
-     * @param aRequest request information
-     * @param aSize response size
-     * @param aMatches count of items
-     * @param aStatus request status
-     */    
-    void SearchResponseSize( TInt aId, TDes8& aRequest, TDes8& aParams,
-        TRequestStatus& aStatus );
-    
-    /**
-     * Cancel get search response size
-     *
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelSearchResponseSize( TInt aId );
-    
-    /**
-     * Get search response
-     *
-     * @param aId session id
-     * @param aSearchResponse search response
-     * @return error code
-     */    
-    TInt SearchResponse( TInt aId, TDes8& aSearchResponse,
-        TDes8& aUpdateId );
-
-    /**
-     * Get search capabilities size
-     *
-     * @param aId session id
-     * @param aSize size
-     * @param aStatus request status
-     */    
-    void GetSearchCapabilitiesSize( TInt aId, TDes8& aSize,
-        TRequestStatus& aStatus );
-    
-    /**
-     * Cancel get search capabilities size
-     *
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelGetSearchCapabilitiesSize( TInt aId );
-    
-    /**
-     * Get search capabilities
-     *
-     * @param aId session id
-     * @param aCapabilitiesResponse search capabilities response
-     * @return error code
-     */    
-    TInt SearchCapabilitiesResponse( TInt aId,
-        TDes8& aCapabilitiesResponse );
-    
-    /**
-     * Create a container
-     *
-     * @param aId session id
-     * @param aTitle container title
-     * @param aParentId parent id
-     * @param aContainerType container type
-     * @param aStatus request status
-     */    
-    void CreateContainer( TInt aId,
-                          TDes8& aTitle,
-                          TDes8& aParentId,
-                          TInt aContainerType,
-                          TRequestStatus& aStatus );                          
-    
-    /**
-     * Cancel create container
-     *
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelCreateContainer( TInt aId );
-
-    /**
-     * Delete object
-     *
-     * @param aId session id
-     * @param aObjectId object id
-     * @param aStatus request status
-     */    
-    void DeleteObject( TInt aId, TDes8& aObjectId, TRequestStatus& aStatus );
-    
-    /**
-     * Cancel delete object
-     *
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelDeleteObject( TInt aId );
-    
-    /**
-     * Device disappeared request
-     *
-     * @param aId session id
-     * @param aStatus request status
-     */    
-    void DeviceDisappearedRequest( TInt aId, TRequestStatus& aStatus );
-    
-    /**
-     * Cancel device disappeared request
-     *
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelDeviceDisappearedRequest( TInt aId );    
-    
-    /**
-     * Monitor WLAN connection request
-     *
-     * @param aStatus request status
-     */    
-    void MonitorConnection( TRequestStatus& aStatus );
-    
-    /**
-     * Cancel monitor connection
-     *
-     * @param aId session id
-     * @return error code
-     */    
-    TInt CancelMonitorConnection();
-
-    /**
-     * 
-     *
-     * @param aInUse
-     * @return error code
-     */    
-    TInt MSServicesInUse( TDes8& aInUse );
-
-public: // Download Session releated
-
-    /**
-     * Create a download session
-     * 
-     * @param aId session id
-     * @param aUuid device Uuid
-     * @return error code
-     */    
-    TInt CreateDownloadSession( TInt aId, TDes8& aUuid );
-    
-    /**
-     * Destroy a download session
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt DestroyDownloadSession( TInt aId );
-
-    TInt StartDownload( TInt aId, TDes8& aFileTransferItem );
-    
-    TInt StartDownload( TInt aId, TDes8& aFileTransferItem,
-        const RFile& aFile );
-    
-    void GetDownloadEvent( TInt aId, TDes8& aEvent,
-        TRequestStatus& aStatus, TDes& aBuffer );
-    
-    TInt CancelDownloadEvent( TInt aId );
-        
-    TInt StartTrackingDownloadProgress( TInt aId, TInt aKey );    
-    
-    TInt CancelDownload( TInt aId, TInt aKey );
-    
-    TInt CancelAllDownloads( TInt aId );
-    
-public: // Upload Session releated
-
-    /**
-     * Create an upload session
-     * 
-     * @param aId session id
-     * @param aUuid device Uuid
-     * @return error code
-     */    
-    TInt CreateUploadSession( TInt aId, TDes8& aUuid );
-    
-    /**
-     * Destroy an upload session
-     * 
-     * @param aId session id
-     * @return error code
-     */    
-    TInt DestroyUploadSession( TInt aId );
-
-    TInt StartUpload( TInt aId, TDes8& aFileTransferItem );
-    
-    void GetUploadEvent( TInt aId, TDes8& aEvent,
-        TRequestStatus& aStatus );
-    
-    TInt CancelUploadEvent( TInt aId );
-        
-    TInt StartTrackingUploadProgress( TInt aId, TInt aKey );    
-    
-    TInt CancelUpload( TInt aId, TInt aKey );
-    
-    TInt CancelAllUploads( TInt aId );
-    };
-
-#endif // C_CUPNPAVCONTROLLERCLIENT_H
-
-// End of File
+/*
+* Copyright (c) 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:      AVController client session
+*
+*/
+
+
+
+
+
+
+#ifndef C_CUPNPAVCONTROLLERCLIENT_H
+#define C_CUPNPAVCONTROLLERCLIENT_H
+
+// INCLUDES
+#include "upnpavcontrollerglobals.h"
+
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CUpnpItem;
+class CUpnpContainer;
+class CUpnpDevice;
+class CUpnpObject;
+class RFile;
+
+// CLASS DECLARATION
+/**
+ *  Client-side interface to AV Controller Server
+ *
+ *  This class provides the client-side interface to the AV Controller
+ *  Server session.
+ *
+ *  @lib upnpavcontrollerclient.lib
+ *  @since S60 v3.1
+ */
+class RUPnPAVControllerClient : public RSessionBase
+    {
+public:
+
+    /**
+     * Construct the object
+     */
+    RUPnPAVControllerClient();
+
+    /**
+     * Connects to the server and create a session
+     * @return error code
+     */
+    TInt Connect();
+    
+    /**
+     * Returns the version number
+     * @return the version
+     */
+    TVersion Version() const;
+
+    /**
+     * Startup request. Starts up the AV Control Point
+     *
+     * @param aStatus request status
+     */    
+    TInt StartUp();
+
+    /**
+     * Cancels startup.
+     *
+     * @return error code
+     */    
+    TInt CancelStartUp();
+
+    /**
+     * Device discovery request
+     *
+     * @param aDiscovered type of device
+     * @param aRcvdBufSize size of device
+     * @param aStatus request status
+     */    
+    void DeviceRequest( TDes8& aDiscovered, TDes8& aRcvdBufSize,
+        TRequestStatus& aStatus );
+        
+    /**
+     * Cancels device discovery request
+     *
+     * @return error code
+     */    
+    TInt CancelDeviceRequest();
+    
+    /**
+     * Gets device
+     *
+     * @param aDevice device
+     * @return error code
+     */    
+    TInt GetDevice( TDes8& aDevice );
+    
+    /**
+     * Gets device list size
+     *
+     * @param aType type of devices
+     * @param aSize size of the list
+     * @return error code
+     */    
+    TInt GetDeviceListSize( TDes8& aType, TDes8& aSize );
+    
+    /**
+     * Gets device list
+     * 
+     * @param aList device list
+     * @return error code
+     */    
+    TInt GetDeviceList( TDes8& aList );
+
+    /**
+     * Gets device icon
+     * 
+     * @param aUuid uuid of the device
+     * @param aFile icon file
+     * @return error code
+     */    
+    TInt GetDeviceIcon( const TDesC8& aUuid, RFile& aFile );
+ 
+public: // Rendering Session releated
+    
+    /**
+     * Create a rendering session
+     * 
+     * @param aId session id
+     * @param aUuid device Uuid
+     * @return error code
+     */    
+    TInt CreateRenderingSession( TInt aId, TDes8& aUuid );
+    
+    /**
+     * Destroy a rendering session
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt DestroyRenderingSession( TInt aId );
+    
+    /**
+     * AV event request
+     *
+     * @param aEvent AV Event
+     * @param aId session id
+     * @param aStatus request status
+     */    
+    void EventRequest( TDes8& aEvent, TInt aId, TRequestStatus& aStatus );
+    
+    /**
+     * Cancel event request
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelEventRequest( TInt aId );
+    
+    /**
+     * Set URI
+     *
+     * @param aId session id
+     * @param aRequest request information
+     * @param aItem item
+     * @param aType type of the item 
+     * @param aStatus request status
+     */    
+    void SetURI( TInt aId, TDes8& aRequest, TDes8& aItem,
+                                 TRequestStatus& aStatus );
+        
+    /**
+     * Cancel reserve media server
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelSetURI( TInt aId );
+    
+    /**
+     * Set Next URI
+     *
+     * @param aId session id
+     * @param aRequest request information
+     * @param aItem item
+     * @param aType type of the item 
+     * @param aStatus request status
+     */    
+    void SetNextURI( TInt aId, TDes8& Request, TDes8& aItem,
+                                    TRequestStatus& aStatus );
+        
+    /**
+     * Cancel reserve media server
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelSetNextURI( TInt aId );
+    
+    /**
+     * Send play action
+     *
+     * @param aId session id
+     * @param aStatus request status
+     */    
+    void Play( TInt aId, TRequestStatus& aStatus );
+    
+    /**
+     * Cancel play
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelPlay( TInt aId );
+    
+    /**
+     * Send stop action
+     *
+     * @param aId session id
+     * @param aStatus request status
+     */    
+    void Stop( TInt aId, TRequestStatus& aStatus );
+    
+    /**
+     * Cancel stop
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelStop( TInt aId );
+    
+    /**
+     * Send pause action
+     *
+     * @param aId session id
+     * @param aStatus request status
+     */    
+    void Pause( TInt aId, TRequestStatus& aStatus );
+    
+    /**
+     * Cancel pause
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelPause( TInt aId );
+    
+    /**
+     * Set volume level
+     *
+     * @param aId session id
+     * @param aVolumeLevel volume level
+     * @param aRetVolume (set) volume level
+     * @param aStatus request status
+     */    
+    void SetVolume( TInt aId, TInt aVolumeLevel, TDes8& aRetVolume,
+        TRequestStatus& aStatus );
+        
+    /**
+     * Cancel set volume
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelSetVolume( TInt aId );
+    
+    /**
+     * Get volume level
+     *
+     * @param aId session id
+     * @param aVolumeLevel volume level
+     * @param aStatus request status
+     */    
+    void GetVolume( TInt aId, TDes8& aVolumeLevel, TRequestStatus& aStatus );
+    
+    /**
+     * Cancel get volume
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelGetVolume( TInt aId );
+    
+    /**
+     * Set mute
+     *
+     * @param aId session id
+     * @param aMute mute
+     * @param aRetMute (set) mute
+     * @param aStatus request status
+     */    
+    void SetMute( TInt aId, TBool aMute, TDes8& aRetMute,
+        TRequestStatus& aStatus );
+    
+    /**
+     * Cancel set mute
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelSetMute( TInt aId );
+    
+    /**
+     * Get mute
+     *
+     * @param aId session id
+     * @param aMute mute
+     * @param aStatus request status
+     */    
+    void GetMute( TInt aId, TDes8& aMute, TRequestStatus& aStatus );
+    
+    /**
+     * Cancel get mute
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelGetMute( TInt aId );
+     
+    /**
+     * Get position info
+     *
+     * @param aId session id
+     * @param aPosition position info
+     * @param aLength lenght info
+     * @param aStatus request status
+     */    
+    void GetPositionInfo( TInt aId, TDes8& aPosition, TDes8& aLength,
+        TRequestStatus& aStatus );
+        
+    /**
+     * Cancel get position info
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelGetPositionInfo( TInt aId );
+
+    /**
+     * Send seek action with REL_TIME unit. 
+     *
+     * @param aId session id.
+     * @param aTargetTime target time for seeking.
+     * @param aStatus request status.
+     */    
+    void SeekRelTime( 
+        TInt aId, 
+        TDes8& aTargetTime, 
+        TRequestStatus& aStatus );
+        
+    /**
+     * Cancel seek action with REL_TIME unit.
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelSeekRelTime( TInt aId );
+
+    /**
+     * Get renderer state
+     *
+     * @param aId session id
+     * @param aState renderer state
+     * @return error code
+     */    
+    TInt GetRendererState( TInt aId, TDes8& aState );    
+    
+public: // Browsing Session releated
+
+    /**
+     * Create browsing session
+     *
+     * @param aId session id
+     * @param aUuid device uuid
+     * @return error code
+     */    
+    TInt CreateBrowsingSession( TInt aId, TDes8& aUuid );
+    
+    /**
+     * Destroy browsing session
+     *
+     * @param aId session id
+     * @return error code
+     */    
+    TInt DestroyBrowsingSession( TInt aId );
+    
+    /**
+     * Get browse response size
+     *
+     * @param aId session id
+     * @param aRequest request information
+     * @param aSize response size
+     * @param aMatches count of items
+     * @param aStatus request status
+     */    
+    void BrowseResponseSize( TInt aId, TDes8& aRequest, TDes8& aParams,
+        TRequestStatus& aStatus );
+    
+    /**
+     * Cancel get browse response size
+     *
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelBrowseResponseSize( TInt aId );
+    
+    /**
+     * Get browse response
+     *
+     * @param aId session id
+     * @param aBrowseResponse browse response
+     * @return error code
+     */    
+    TInt BrowseResponse( TInt aId, TDes8& aBrowseResponse,
+        TDes8& aUpdateId );
+
+    /**
+     * Get search response size
+     *
+     * @param aId session id
+     * @param aRequest request information
+     * @param aSize response size
+     * @param aMatches count of items
+     * @param aStatus request status
+     */    
+    void SearchResponseSize( TInt aId, TDes8& aRequest, TDes8& aParams,
+        TRequestStatus& aStatus );
+    
+    /**
+     * Cancel get search response size
+     *
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelSearchResponseSize( TInt aId );
+    
+    /**
+     * Get search response
+     *
+     * @param aId session id
+     * @param aSearchResponse search response
+     * @return error code
+     */    
+    TInt SearchResponse( TInt aId, TDes8& aSearchResponse,
+        TDes8& aUpdateId );
+
+    /**
+     * Get search capabilities size
+     *
+     * @param aId session id
+     * @param aSize size
+     * @param aStatus request status
+     */    
+    void GetSearchCapabilitiesSize( TInt aId, TDes8& aSize,
+        TRequestStatus& aStatus );
+    
+    /**
+     * Cancel get search capabilities size
+     *
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelGetSearchCapabilitiesSize( TInt aId );
+    
+    /**
+     * Get search capabilities
+     *
+     * @param aId session id
+     * @param aCapabilitiesResponse search capabilities response
+     * @return error code
+     */    
+    TInt SearchCapabilitiesResponse( TInt aId,
+        TDes8& aCapabilitiesResponse );
+    
+    /**
+     * Create a container
+     *
+     * @param aId session id
+     * @param aTitle container title
+     * @param aParentId parent id
+     * @param aContainerType container type
+     * @param aStatus request status
+     */    
+    void CreateContainer( TInt aId,
+                          TDes8& aTitle,
+                          TDes8& aParentId,
+                          TInt aContainerType,
+                          TRequestStatus& aStatus );                          
+    
+    /**
+     * Cancel create container
+     *
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelCreateContainer( TInt aId );
+
+    /**
+     * Delete object
+     *
+     * @param aId session id
+     * @param aObjectId object id
+     * @param aStatus request status
+     */    
+    void DeleteObject( TInt aId, TDes8& aObjectId, TRequestStatus& aStatus );
+    
+    /**
+     * Cancel delete object
+     *
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelDeleteObject( TInt aId );
+    
+    /**
+     * Device disappeared request
+     *
+     * @param aId session id
+     * @param aStatus request status
+     */    
+    void DeviceDisappearedRequest( TInt aId, TRequestStatus& aStatus );
+    
+    /**
+     * Cancel device disappeared request
+     *
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelDeviceDisappearedRequest( TInt aId );    
+    
+    /**
+     * Monitor WLAN connection request
+     *
+     * @param aStatus request status
+     */    
+    void MonitorConnection( TRequestStatus& aStatus );
+    
+    /**
+     * Cancel monitor connection
+     *
+     * @param aId session id
+     * @return error code
+     */    
+    TInt CancelMonitorConnection();
+
+ 
+public: // Download Session releated
+
+    /**
+     * Create a download session
+     * 
+     * @param aId session id
+     * @param aUuid device Uuid
+     * @return error code
+     */    
+    TInt CreateDownloadSession( TInt aId, TDes8& aUuid );
+    
+    /**
+     * Destroy a download session
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt DestroyDownloadSession( TInt aId );
+
+    TInt StartDownload( TInt aId, TDes8& aFileTransferItem );
+    
+    TInt StartDownload( TInt aId, TDes8& aFileTransferItem,
+        const RFile& aFile );
+    
+    void GetDownloadEvent( TInt aId, TDes8& aEvent,
+        TRequestStatus& aStatus, TDes& aBuffer );
+    
+    TInt CancelDownloadEvent( TInt aId );
+        
+    TInt StartTrackingDownloadProgress( TInt aId, TInt aKey );    
+    
+    TInt CancelDownload( TInt aId, TInt aKey );
+    
+    TInt CancelAllDownloads( TInt aId );
+    
+public: // Upload Session releated
+
+    /**
+     * Create an upload session
+     * 
+     * @param aId session id
+     * @param aUuid device Uuid
+     * @return error code
+     */    
+    TInt CreateUploadSession( TInt aId, TDes8& aUuid );
+    
+    /**
+     * Destroy an upload session
+     * 
+     * @param aId session id
+     * @return error code
+     */    
+    TInt DestroyUploadSession( TInt aId );
+
+    TInt StartUpload( TInt aId, TDes8& aFileTransferItem );
+    
+    void GetUploadEvent( TInt aId, TDes8& aEvent,
+        TRequestStatus& aStatus );
+    
+    TInt CancelUploadEvent( TInt aId );
+        
+    TInt StartTrackingUploadProgress( TInt aId, TInt aKey );    
+    
+    TInt CancelUpload( TInt aId, TInt aKey );
+    
+    TInt CancelAllUploads( TInt aId );
+    };
+
+#endif // C_CUPNPAVCONTROLLERCLIENT_H
+
+// End of File
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrollerfactory.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrollerfactory.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,85 +1,77 @@
-/*
-* Copyright (c) 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:      Abstract factory for UPnP AV Controller
-*
-*/
-
-
-
-
-
-
-
-#ifndef C_UPNPAVCONTROLLERFACTORY_H
-#define C_UPNPAVCONTROLLERFACTORY_H
-
-#include <e32std.h>
-
-class MUPnPAVController;
-
-/**
- *  Abstract factory for UPnP AV Controller
- *
- *  Abstract factory for UPnP AV Controller. Exports methods to instantiate
- *  the AV Controller.
- *
- *  @lib upnpavcontrollerclient.lib
- *  @since S60 v3.1
- */
-class UPnPAVControllerFactory
-    {
-
-public:
-
-    enum TAVControllerServerStatus
-        {
-        EStatusOffline = 0,
-        EStatusActive
-        };
-
-public:
-
-    /**
-     * Creates a new instance of AV Controller
-     *
-     * @return instance of AV Controller
-     */
-    IMPORT_C static MUPnPAVController* NewUPnPAVControllerL();
-
-    /**
-     * Creates a new instance of AV Controller. Instance is left in
-     * cleanup stack.
-     *
-     * @return instance of AV Controller
-     */
-    IMPORT_C static MUPnPAVController* NewUPnPAVControllerLC();
-
-    /**
-     * Return ETrue is some application is using the local Media Server
-     * services via AV Controller server.
-     *
-     * @return EFalse/ETrue
-     */
-    IMPORT_C static TBool MSServicesInUse();
-
-    /**
-     * Returns the operational state of AV Controller Server
-     *
-     * @param aStatus operational state
-     * @return system wide error code
-     */
-    IMPORT_C static TInt Status( TAVControllerServerStatus& aStatus );
-    };
-
-#endif // ? C_UPNPAVCONTROLLERFACTORY_H
+/*
+* Copyright (c) 2006-2009 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:      Abstract factory for UPnP AV Controller
+*
+*/
+
+
+
+
+
+
+
+#ifndef C_UPNPAVCONTROLLERFACTORY_H
+#define C_UPNPAVCONTROLLERFACTORY_H
+
+#include <e32std.h>
+
+class MUPnPAVController;
+
+/**
+ *  Abstract factory for UPnP AV Controller
+ *
+ *  Abstract factory for UPnP AV Controller. Exports methods to instantiate
+ *  the AV Controller.
+ *
+ *  @lib upnpavcontrollerclient.lib
+ *  @since S60 v3.1
+ */
+class UPnPAVControllerFactory
+    {
+
+public:
+
+    enum TAVControllerServerStatus
+        {
+        EStatusOffline = 0,
+        EStatusActive
+        };
+
+public:
+
+    /**
+     * Creates a new instance of AV Controller
+     *
+     * @return instance of AV Controller
+     */
+    IMPORT_C static MUPnPAVController* NewUPnPAVControllerL();
+
+    /**
+     * Creates a new instance of AV Controller. Instance is left in
+     * cleanup stack.
+     *
+     * @return instance of AV Controller
+     */
+    IMPORT_C static MUPnPAVController* NewUPnPAVControllerLC();
+
+    /**
+     * Returns the operational state of AV Controller Server
+     *
+     * @param aStatus operational state
+     * @return system wide error code
+     */
+    IMPORT_C static TInt Status( TAVControllerServerStatus& aStatus );
+    };
+
+#endif // ? C_UPNPAVCONTROLLERFACTORY_H
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrollerglobals.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavcontrollerglobals.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,203 +1,227 @@
-/*
-* Copyright (c) 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:      global definitions for AVController
-*
-*/
-
-
-
-
-
-
-
-#ifndef C_UPNPAVCONTROLLERGLOBALS_H
-#define C_UPNPAVCONTROLLERGLOBALS_H
-
-#include <e32std.h>
-
-
-// CONSTANTS
-const TUint KAVControllerMajorVersionNumber = 0;
-const TUint KAVControllerMinorVersionNumber = 1;
-const TUint KAVControllerBuildVersionNumber = 1;
-
-_LIT( KAVControllerThreadName,      "AVController_MainThread" );
-_LIT( KAVControllerName,            "AVController" );
-_LIT( KAVControllerFilename,        "upnpavcontrollerserver" );
-_LIT8( KAVControllerDefaultName,    "Nokia AV Controller" );
-
-//_LIT8( KDownloadMemoryCard,     "e:\\Download\\Media\\" );
-//_LIT8( KDownloadPhoneMemory,    "c:\\Data\\Download\\Media\\" );
-//_LIT8( KDownloadRAMDrive,       "d:\\Download\\Media\\" );
-
-const TUint KMsFriendlyNameMaxSize = 256;
-const TUid KAVCServerUid3 = {0x20007566};
-
-// ENUMERATIONS
-// Opcodes used in message passing between client and server
-enum TAVControllerRqst
-    {
-    EAVControllerSetURI = 0,                    // 0
-    EAVControllerCancelSetURI,                  // 1
-    EAVControllerSetNextURI,                    // 2
-    EAVControllerCancelSetNextURI,              // 3
-    EAVControllerCancelCopyRemoteItemFinish,    // 4
-    EAVControllerCopyLocalItemStart,            // 5
-    EAVControllerCancelCopyLocalItemStart,      // 6
-    EAVControllerCopyLocalItemFinish,           // 7
-    EAVControllerCancelCopyLocalItemFinish,     // 8
-    EAVControllerCopyToPhoneStart,              // 9
-    EAVControllerCancelCopyToPhoneStart,        // 10
-    EAVControllerCopyToPhoneFinish,             // 11
-    EAVControllerCancelCopyToPhoneFinish,       // 12
-    EAVControllerGetBrowseResponseSize,         // 13
-    EAVControllerCancelGetBrowseResponseSize,   // 14
-    EAVControllerGetBrowseResponse,             // 15
-    EAVControllerGetSearchResponseSize,         // 16
-    EAVControllerCancelGetSearchResponseSize,   // 17
-    EAVControllerGetSearchResponse,             // 18
-    EAVControllerDeviceRequest,                 // 19
-    EAVControllerGetDeviceRequest,              // 20
-    EAVControllerCancelDeviceRequest,           // 21
-    EAVControllerGetDeviceListRequest,          // 22
-    EAVControllerGetDeviceListSizeRequest,      // 23
-    EAVControllerCreateRenderingSession,        // 24
-    EAVControllerDestroyRenderingSession,       // 25
-    EAVControllerEventRequest,                  // 26
-    EAVControllerCancelEventRequest,            // 27
-    EAVControllerPlay,                          // 28
-    EAVControllerCancelPlay,                    // 29
-    EAVControllerStop,                          // 30
-    EAVControllerCancelStop,                    // 31
-    EAVControllerPause,                         // 32
-    EAVControllerCancelPause,                   // 33
-    EAVControllerSetVolume,                     // 34
-    EAVControllerCancelSetVolume,               // 35
-    EAVControllerGetVolume,                     // 36
-    EAVControllerCancelGetVolume,               // 37
-    EAVControllerSetMute,                       // 38
-    EAVControllerCancelSetMute,                 // 39
-    EAVControllerGetMute,                       // 40
-    EAVControllerCancelGetMute,                 // 41
-    EAVControllerGetPositionInfo,               // 42
-    EAVControllerCancelGetPositionInfo,         // 43
-    EAVControllerCreateBrowsingSession,         // 44
-    EAVControllerDestroyBrowsingSession,        // 45
-    EAVControllerGetSearchCapabilitiesSize,     // 46
-    EAVControllerCancelGetSearchCapabilitiesSize, // 47   
-    EAVControllerGetSearchCapabilities,         // 48
-    EAVControllerCreateContainer,               // 49
-    EAVControllerCancelCreateContainer,         // 50
-    EAVControllerDeleteObject,                  // 51
-    EAVControllerCancelDeleteObject,            // 52
-    EAVControllerDeviceDisappearedRequest,      // 53
-    EAVControllerCancelDeviceDisappearedRequest,// 54   
-    EAVControllerStartMediaServer,              // 55
-    EAVControllerCancelStartMediaServer,        // 56
-    EAVControllerStopMediaServer,               // 57
-    EAVControllerMonitorConnection,             // 58
-    EAVControllerCancelMonitorConnection,       // 59
-    EAVControllerMSServicesInUse,               // 60
-    EAVControllerStartupRequest,                 // 61
-    EAVControllerCancelStartupRequest,           // 62
-    EAVControllerCreateDownloadSession,        // 63
-    EAVControllerCreateUploadSession,           // 64
-    EAVControllerDestroyDownloadSession,        // 65
-    EAVControllerDestroyUploadSession,          // 66
-    EAVControllerStartDownload,                 // 67
-    EAVControllerCancelDownload,                // 68
-    EAVControllerCancelAllDownloads,            // 69   
-    EAVControllerStartUpload,                   // 70
-    EAVControllerCancelUpload,                  // 71
-    EAVControllerCancelAllUploads,              // 72
-    EAVControllerStartTrackingUploadProgress,   // 73
-    EAVControllerStartTrackingDownloadProgress, // 74
-    EAVControllerGetDownloadEvent,              // 75
-    EAVControllerCancelDownloadEvent,           // 77
-    EAVControllerGetUploadEvent,                // 78
-    EAVControllerCancelUploadEvent,             // 79
-    EAVControllerStartDownloadFH                // 80
-    };
-    
-enum TAVControllerRsp
-    {
-    EAVControllerDeviceCompleted = 200,
-    EAVControllerSetURICompleted,
-    EAVControllerSetNextURICompleted,
-    EAVControllerPlayCompleted,
-    EAVControllerStopCompleted,
-    EAVControllerPauseCompleted,
-    EAVControllerSetVolumeCompleted,
-    EAVControllerGetVolumeCompleted,
-    EAVControllerSetMuteCompleted,
-    EAVControllerGetMuteCompleted,
-    EAVControllerPositionInfoCompleted,
-    EAVControllerGetBrowseResponseSizeCompleted,
-    EAVControllerGetBrowseResponseCompleted,    
-    EAVControllerGetSearchResponseSizeCompleted,
-    EAVControllerGetSearchResponseCompleted,
-    EAVControllerGetSearchCapabilitiesSizeCompleted,
-    EAVControllerGetSearchCapabilitiesCompleted,
-    EAVControllerCopyRemoteItemStartCompleted,
-    EAVControllerCopyRemoteItemFinishCompleted,
-    EAVControllerCopyLocalItemStartCompleted,
-    EAVControllerCopyLocalItemFinishCompleted,
-    EAVControllerCopyToPhoneStartCompleted,
-    EAVControllerCopyToPhoneFinishCompleted,
-    EAVControllerCreateContainerCompleted,
-    EAVControllerDeleteObjectCompleted,
-    EAVControllerDeviceDisappearedRequestCompleted,
-    EAVControllerStartMediaServerCompleted,
-    EAVControllerConnectionLost
-    };  
-
-enum TAVControllerDeviceDiscovery
-    {
-    EAVDeviceDisappeared,
-    EAVDeviceDiscovered
-    };
-
-enum TAVControllerDeviceListType
-    {
-    EAVMediaServer,
-    EAVMediaRenderer
-    };
-
-/**
- * Defines unsolicited event
- */
-enum TUnsolicitedEventE
-    {
-    EPlay = 0,
-    EPause,
-    EStop,
-    EVolume,
-    EMute
-    };
-
-/**
- * Helper class to queu unsolicited events
- */
-class TUnsolicitedEventC
-    {
-    
-public:    
-    
-    TUnsolicitedEventE  iEvent;
-    TInt                iValue;
-    };
-    
-#endif      // C_UPNPAVCONTROLLERGLOBALS_H
-            
-// End of File
+/*
+* Copyright (c) 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:      global definitions for AVController
+*
+*/
+
+
+
+
+
+
+
+#ifndef C_UPNPAVCONTROLLERGLOBALS_H
+#define C_UPNPAVCONTROLLERGLOBALS_H
+
+#include <e32std.h>
+
+
+// CONSTANTS
+const TUint KAVControllerMajorVersionNumber = 0;
+const TUint KAVControllerMinorVersionNumber = 1;
+const TUint KAVControllerBuildVersionNumber = 1;
+
+_LIT( KAVControllerThreadName,      "AVController_MainThread" );
+_LIT( KAVControllerName,            "AVController" );
+_LIT( KAVControllerFilename,        "upnpavcontrollerserver" );
+_LIT8( KAVControllerDefaultName,    "Nokia AV Controller" );
+
+// REL_TIME type for seek action.
+_LIT8( KRel_Time,            "REL_TIME" );
+
+//_LIT8( KDownloadMemoryCard,     "e:\\Download\\Media\\" );
+//_LIT8( KDownloadPhoneMemory,    "c:\\Data\\Download\\Media\\" );
+//_LIT8( KDownloadRAMDrive,       "d:\\Download\\Media\\" );
+
+const TUint KMsFriendlyNameMaxSize = 256;
+const TUid KAVCServerUid3 = {0x20007566};
+
+// ENUMERATIONS
+// Opcodes used in message passing between client and server
+enum TAVControllerRqst
+    {
+    EAVControllerSetURI = 0,                    // 0
+    EAVControllerCancelSetURI,                  // 1
+    EAVControllerSetNextURI,                    // 2
+    EAVControllerCancelSetNextURI,              // 3
+    EAVControllerCancelCopyRemoteItemFinish,    // 4
+    EAVControllerCopyLocalItemStart,            // 5
+    EAVControllerCancelCopyLocalItemStart,      // 6
+    EAVControllerCopyLocalItemFinish,           // 7
+    EAVControllerCancelCopyLocalItemFinish,     // 8
+    EAVControllerCopyToPhoneStart,              // 9
+    EAVControllerCancelCopyToPhoneStart,        // 10
+    EAVControllerCopyToPhoneFinish,             // 11
+    EAVControllerCancelCopyToPhoneFinish,       // 12
+    EAVControllerGetBrowseResponseSize,         // 13
+    EAVControllerCancelGetBrowseResponseSize,   // 14
+    EAVControllerGetBrowseResponse,             // 15
+    EAVControllerGetSearchResponseSize,         // 16
+    EAVControllerCancelGetSearchResponseSize,   // 17
+    EAVControllerGetSearchResponse,             // 18
+    EAVControllerDeviceRequest,                 // 19
+    EAVControllerGetDeviceRequest,              // 20
+    EAVControllerCancelDeviceRequest,           // 21
+    EAVControllerGetDeviceListRequest,          // 22
+    EAVControllerGetDeviceListSizeRequest,      // 23
+    EAVControllerCreateRenderingSession,        // 24
+    EAVControllerDestroyRenderingSession,       // 25
+    EAVControllerEventRequest,                  // 26
+    EAVControllerCancelEventRequest,            // 27
+    EAVControllerPlay,                          // 28
+    EAVControllerCancelPlay,                    // 29
+    EAVControllerStop,                          // 30
+    EAVControllerCancelStop,                    // 31
+    EAVControllerPause,                         // 32
+    EAVControllerCancelPause,                   // 33
+    EAVControllerSetVolume,                     // 34
+    EAVControllerCancelSetVolume,               // 35
+    EAVControllerGetVolume,                     // 36
+    EAVControllerCancelGetVolume,               // 37
+    EAVControllerSetMute,                       // 38
+    EAVControllerCancelSetMute,                 // 39
+    EAVControllerGetMute,                       // 40
+    EAVControllerCancelGetMute,                 // 41
+    EAVControllerGetPositionInfo,               // 42
+    EAVControllerCancelGetPositionInfo,         // 43
+    EAVControllerCreateBrowsingSession,         // 44
+    EAVControllerDestroyBrowsingSession,        // 45
+    EAVControllerGetSearchCapabilitiesSize,     // 46
+    EAVControllerCancelGetSearchCapabilitiesSize, // 47   
+    EAVControllerGetSearchCapabilities,         // 48
+    EAVControllerCreateContainer,               // 49
+    EAVControllerCancelCreateContainer,         // 50
+    EAVControllerDeleteObject,                  // 51
+    EAVControllerCancelDeleteObject,            // 52
+    EAVControllerDeviceDisappearedRequest,      // 53
+    EAVControllerCancelDeviceDisappearedRequest,// 54   
+    EAVControllerStartMediaServer,              // 55
+    EAVControllerCancelStartMediaServer,        // 56
+    EAVControllerStopMediaServer,               // 57
+    EAVControllerMonitorConnection,             // 58
+    EAVControllerCancelMonitorConnection,       // 59
+    EAVControllerMSServicesInUse,               // 60
+    EAVControllerStartupRequest,                 // 61
+    EAVControllerCancelStartupRequest,           // 62
+    EAVControllerCreateDownloadSession,        // 63
+    EAVControllerCreateUploadSession,           // 64
+    EAVControllerDestroyDownloadSession,        // 65
+    EAVControllerDestroyUploadSession,          // 66
+    EAVControllerStartDownload,                 // 67
+    EAVControllerCancelDownload,                // 68
+    EAVControllerCancelAllDownloads,            // 69   
+    EAVControllerStartUpload,                   // 70
+    EAVControllerCancelUpload,                  // 71
+    EAVControllerCancelAllUploads,              // 72
+    EAVControllerStartTrackingUploadProgress,   // 73
+    EAVControllerStartTrackingDownloadProgress, // 74
+    EAVControllerGetDownloadEvent,              // 75
+    EAVControllerCancelDownloadEvent,           // 77
+    EAVControllerGetUploadEvent,                // 78
+    EAVControllerCancelUploadEvent,             // 79
+    EAVControllerStartDownloadFH,               // 80
+    
+    // seek related opcodes
+    EAVControllerSeekRelTime,                   // 81
+    EAVControllerCancelSeekRelTime,             // 82
+    EAVControllerGetRendererState,              // 83
+
+    EAVControllerGetDeviceIconRequest,          // 84
+
+    EAVControllerRqstLast
+    };
+    
+enum TAVControllerRsp
+    {
+    EAVControllerDeviceCompleted = 200,
+    EAVControllerSetURICompleted,
+    EAVControllerSetNextURICompleted,
+    EAVControllerPlayCompleted,
+    EAVControllerStopCompleted,
+    EAVControllerPauseCompleted,
+    EAVControllerSetVolumeCompleted,
+    EAVControllerGetVolumeCompleted,
+    EAVControllerSetMuteCompleted,
+    EAVControllerGetMuteCompleted,
+    EAVControllerPositionInfoCompleted,
+    EAVControllerGetBrowseResponseSizeCompleted,
+    EAVControllerGetBrowseResponseCompleted,    
+    EAVControllerGetSearchResponseSizeCompleted,
+    EAVControllerGetSearchResponseCompleted,
+    EAVControllerGetSearchCapabilitiesSizeCompleted,
+    EAVControllerGetSearchCapabilitiesCompleted,
+    EAVControllerCopyRemoteItemStartCompleted,
+    EAVControllerCopyRemoteItemFinishCompleted,
+    EAVControllerCopyLocalItemStartCompleted,
+    EAVControllerCopyLocalItemFinishCompleted,
+    EAVControllerCopyToPhoneStartCompleted,
+    EAVControllerCopyToPhoneFinishCompleted,
+    EAVControllerCreateContainerCompleted,
+    EAVControllerDeleteObjectCompleted,
+    EAVControllerDeviceDisappearedRequestCompleted,
+    EAVControllerStartMediaServerCompleted,
+    EAVControllerConnectionLost,
+    EAVControllerSeekCompleted
+    };  
+
+enum TAVControllerDeviceDiscovery
+    {
+    EAVDeviceDisappeared,
+    EAVDeviceDiscovered,
+    EAVDeviceIconDownloaded
+    };
+
+enum TAVControllerDeviceListType
+    {
+    EAVMediaServer,
+    EAVMediaRenderer
+    };
+
+/**
+ * Defines unsolicited event
+ */
+enum TUnsolicitedEventE
+    {
+    EPlay = 0,
+    EPause,
+    EStop,
+    EVolume,
+    EMute,
+    ETransition
+    };
+
+/**
+ * Transition event data.
+ */
+enum TTransitionValue
+    {
+    ETransitionEnter,
+    ETransitionExit
+    };
+
+/**
+ * Helper class to queu unsolicited events
+ */
+class TUnsolicitedEventC
+    {
+    
+public:    
+    
+    TUnsolicitedEventE  iEvent;
+    TInt                iValue;
+    };
+    
+#endif      // C_UPNPAVCONTROLLERGLOBALS_H
+            
+// End of File
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavdevice.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavdevice.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,401 +1,448 @@
-/*
-* Copyright (c) 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:      device data class
-*
-*/
-
-
-
-
-
-
-#ifndef C_CUPNPAVDEVICE_H
-#define C_CUPNPAVDEVICE_H
-
-
-#include <e32base.h>
-//#include <s32strm.h>
-#include <s32mem.h>
-
-// FORWARD DECLARATIONS
-
-// CLASS DECLARATION
-
-/**
- *  UPnP AV Device class
- *  
- *  UPnP AV Device class, represents a UPnP Media Server or Renderer.
- *
- *  @lib - 
- *  @since Series 60 3.1
- */
-class CUpnpAVDevice : public CBase
-    {
-public:
-
-    /**
-     * Enumeration to define the type of a device
-     */
-    enum TUpnpAVDeviceType
-        {
-        EMediaServer,
-        EMediaRenderer
-        };    
-    
-public:  // Constructors and destructor
-        
-    /**
-     * Two-phased constructor. Instance is left in cleanup stack.
-     *
-     * @return a device instance
-     */
-    IMPORT_C static CUpnpAVDevice* NewLC();
-    
-    /**
-     * Two-phased constructor.
-     *
-     * @return a device instance
-     */
-    IMPORT_C static CUpnpAVDevice* NewL();
-    
-    /**
-     * Two-phased constructor.
-     *
-     * @param aDevice a device to copy information from
-     * @return a device instance
-     */
-    IMPORT_C static CUpnpAVDevice* NewL( const CUpnpAVDevice& aDevice );
-
-    /**
-     * Destructor.
-     */
-    IMPORT_C virtual ~CUpnpAVDevice();
-    
-public:
-
-    /**
-     * Externalizes device information to stream.
-     * Leaves in case of errors.
-     * @since Series 60 3.0
-     * @param reference to RWriteStream
-     * @return none
-     */
-    IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
-    
-    /**
-     * Internalizes device information from stream.
-     * Leaves in case of errors.
-     * @since Series 60 3.0
-     * @param reference to RReadStream
-     * @return none
-     */
-    IMPORT_C void InternalizeL( RReadStream& aStream );
-    
-    /**
-     * Externalizes device information to a heap descriptor
-     *
-     * @return externalized device
-     */
-    IMPORT_C HBufC8* ToDes8L() const;
-
-    /**
-     * Overwrites all existing data in this device and replaces it
-     * with data copied from given device.
-     * @since Series 60 3.1
-     * @param aDevice object to copy attributes from
-     */
-    IMPORT_C void CopyFromL( const CUpnpAVDevice& aDevice );
-
-protected: //
-
-    /**
-     * Constructor
-     */
-    IMPORT_C CUpnpAVDevice();
-
-    /**
-     * Perform the second phase construction
-     */
-    void ConstructL();
-
-public: // New methods
-
-    /**
-     * Sets the friendly name of the device
-     * 
-     * @param aName name
-     */
-    IMPORT_C void SetFriendlyNameL( const TDesC8& aName );
-    
-    /**
-     * Return friendly name
-     * 
-     * @return friendly name
-     */
-    IMPORT_C const TDesC8& FriendlyName() const;
-    
-    /**
-     * Sets the Uuid of the device
-     * 
-     * @param aUuid Uuid
-     */
-    IMPORT_C void SetUuidL( const TDesC8& aUuid );
-    
-    /**
-     * Return Uuid
-     * 
-     * @return Uuid
-     */
-    IMPORT_C const TDesC8& Uuid() const;
-    
-    /**
-     * Sets the device type (Media Server/Renderer)
-     * 
-     * @param aDeviceType device type
-     */
-    IMPORT_C void SetDeviceType( TUpnpAVDeviceType aDeviceType );
-    
-    /**
-     * Return device type
-     * 
-     * @return device type
-     */
-    IMPORT_C TUpnpAVDeviceType DeviceType() const;
-            
-    /**
-     * Return link offset (used in linked list)
-     * 
-     * @return link offset
-     */
-    IMPORT_C static TInt LinkOffset();         
-
-public: // UPnP media server device capability getters and setters 
-
-    /**
-     * Sets the copy capability of the device
-     * 
-     * @param TBool the copy capability
-     * @return None
-     */
-    IMPORT_C void SetCopyCapability( TBool aCopyCap );
-
-    /**
-     * Gets the copy capability of the device
-     * 
-     * @param None
-     * @return TBool the copy capability
-     */
-    IMPORT_C TBool CopyCapability() const;
-
-    /**
-     * Sets the search capability of the device
-     * 
-     * @param TBool the search capability
-     * @return None
-     */
-    IMPORT_C void SetSearchCapability( TBool aSearchCap );
-
-    /**
-     * Gets the search capability of the device
-     * 
-     * @param None
-     * @return TBool the search capability
-     */
-    IMPORT_C TBool SearchCapability() const;
-
-public: // UPnP rendering device capability getters and setters 
-
-    /**
-     * Sets the pause capability of the device
-     * 
-     * @param TBool the pause capability
-     * @return None
-     */
-    IMPORT_C void SetPauseCapability( TBool aPauseCap );
-
-    /**
-     * Gets the pause capability of the device
-     * 
-     * @param None
-     * @return TBool the pause capability
-     */
-    IMPORT_C TBool PauseCapability() const;
-
-    /**
-     * Sets the volume capability of the device
-     * 
-     * @param TBool the volume capability
-     * @return None
-     */
-    IMPORT_C void SetVolumeCapability( TBool aVolumeCap );
-
-    /**
-     * Gets the volume capability of the device
-     * 
-     * @param None
-     * @return TBool the volume capability
-     */
-    IMPORT_C TBool VolumeCapability() const;
-
-    /**
-     * Sets the mute capability of the device
-     * 
-     * @param TBool the mute capability
-     * @return None
-     */
-    IMPORT_C void SetMuteCapability( TBool aMuteCap );
-
-    /**
-     * Gets the mute capability of the device
-     * 
-     * @param None
-     * @return TBool the mute capability
-     */
-    IMPORT_C TBool MuteCapability() const;
-
-    /**
-     * Sets the maximum volume of the device
-     * 
-     * @param TInt the maximum volume
-     * @return None
-     */
-    IMPORT_C void SetMaxVolume( TInt aVolume );
-
-    /**
-     * Gets the maximum volume of the device
-     * 
-     * @return TInt the maximum volume
-     */
-    IMPORT_C TInt MaxVolume() const;
-    
-    /**
-     * Sets the SetNextAVTransportUri capability of the device
-     * 
-     * @param aCap (TBool)
-     * @return None
-     */
-    IMPORT_C void SetNextAVTransportUri( TBool aCap );
-
-    /**
-     * Returns the SetNextAVTransportUri capability of the device
-     * 
-     * @param None
-     * @return TBool ETrue if SetNextAVTrasportUri action is supported
-     */
-    IMPORT_C TBool NextAVTransportUri() const;           
-
-public: // UPnP media rendering capability getters and setters 
-
-    IMPORT_C void SetCapabilitiesBySupportedMimeTypesL(
-        const TDesC8& aListOfMimeTypes );
-
-    /**
-     * Sets audio capability of the device
-     * 
-     * @param aCap (TBool)
-     * @return None
-     */
-    IMPORT_C void SetAudioCapability( TBool aCap );
-
-    /**
-     * Gets the audio media capability of the device
-     * 
-     * @param None
-     * @return TBool the audio media capability
-     */
-    IMPORT_C TBool AudioCapability() const;
-
-    /**
-     * Sets image capability of the device
-     * 
-     * @param aCap (TBool)
-     * @return None
-     */
-    IMPORT_C void SetImageCapability( TBool aCap );
-
-    /**
-     * Gets the image media capability of the device
-     * 
-     * @param None
-     * @return TBool the image media capability
-     */
-    IMPORT_C TBool ImageCapability() const;
-
-    /**
-     * Sets video capability of the device
-     * 
-     * @param aCap (TBool)
-     * @return None
-     */
-    IMPORT_C void SetVideoCapability( TBool aCap );
-
-    /**
-     * Gets the video media capability of the device
-     * 
-     * @param None
-     * @return TBool the video media capability
-     */
-    IMPORT_C TBool VideoCapability() const;
-
-public: // DLNA releated
-
-    /**
-     * Sets if the device is Dlna compatible
-     * 
-     * @param aDlnaCompatible
-     */    
-    IMPORT_C void SetDlnaCompatible( TBool aDlnaCompatible );
-    
-    /**
-     * Return if the device is Dlna compatible
-     * 
-     * @return ETrue if the device is dlna compatible
-     */    
-    IMPORT_C TBool DlnaCompatible() const;
-
-protected:
-    
-    TSglQueLink iSlink;
-    
-    HBufC8*     iUuid; // Owned
-    
-    HBufC8*     iName; // Owned
-    
-    TUpnpAVDeviceType iDeviceType;
-    
-    TBool iCopyCapability;
-    
-    TBool iSearchCapability;
-    
-    TBool iPauseCapability;
-    
-    TBool iVolumeCapability;
-    
-    TBool iMuteCapability;
-    
-    TBool iAudioMediaCapability;
-    
-    TBool iImageMediaCapability;
-    
-    TBool iVideoMediaCapability;
-    
-    TBool iNextAVTransportUri;
-
-    TInt iMaxVolume;            
-    
-    TBool iDlnaCompatible;            
-    };
-
-
+/*
+* Copyright (c) 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:      device data class
+*
+*/
+
+
+
+
+
+
+#ifndef C_CUPNPAVDEVICE_H
+#define C_CUPNPAVDEVICE_H
+
+
+#include <e32base.h>
+//#include <s32strm.h>
+#include <s32mem.h>
+
+// FORWARD DECLARATIONS
+
+// CLASS DECLARATION
+
+/**
+ *  UPnP AV Device class
+ *  
+ *  UPnP AV Device class, represents a UPnP Media Server or Renderer.
+ *
+ *  @lib - 
+ *  @since Series 60 3.1
+ */
+class CUpnpAVDevice : public CBase
+    {
+public:
+
+    /**
+     * Enumeration to define the type of a device
+     */
+    enum TUpnpAVDeviceType
+        {
+        EMediaServer,
+        EMediaRenderer
+        };    
+    
+    /** 
+     * Enumeration to define the different seek modes.
+     * Use with bitwise operations.
+     */
+    enum TSeekMode 
+        {
+        ETrackNr = 0x1, 
+        ERelTime = 0x2, 
+        EAbsTime = 0x4
+        };
+    
+public:  // Constructors and destructor
+        
+    /**
+     * Two-phased constructor. Instance is left in cleanup stack.
+     *
+     * @return a device instance
+     */
+    IMPORT_C static CUpnpAVDevice* NewLC();
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @return a device instance
+     */
+    IMPORT_C static CUpnpAVDevice* NewL();
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @param aDevice a device to copy information from
+     * @return a device instance
+     */
+    IMPORT_C static CUpnpAVDevice* NewL( const CUpnpAVDevice& aDevice );
+
+    /**
+     * Destructor.
+     */
+    IMPORT_C virtual ~CUpnpAVDevice();
+    
+public:
+
+    /**
+     * Externalizes device information to stream.
+     * Leaves in case of errors.
+     * @since Series 60 3.0
+     * @param reference to RWriteStream
+     * @return none
+     */
+    IMPORT_C void ExternalizeL( RWriteStream& aStream ) const;
+    
+    /**
+     * Internalizes device information from stream.
+     * Leaves in case of errors.
+     * @since Series 60 3.0
+     * @param reference to RReadStream
+     * @return none
+     */
+    IMPORT_C void InternalizeL( RReadStream& aStream );
+    
+    /**
+     * Externalizes device information to a heap descriptor
+     *
+     * @return externalized device
+     */
+    IMPORT_C HBufC8* ToDes8L() const;
+
+    /**
+     * Overwrites all existing data in this device and replaces it
+     * with data copied from given device.
+     * @since Series 60 3.1
+     * @param aDevice object to copy attributes from
+     */
+    IMPORT_C void CopyFromL( const CUpnpAVDevice& aDevice );
+
+protected: //
+
+    /**
+     * Constructor
+     */
+    IMPORT_C CUpnpAVDevice();
+
+    /**
+     * Perform the second phase construction
+     */
+    void ConstructL();
+
+public: // New methods
+
+    /**
+     * Sets the friendly name of the device
+     * 
+     * @param aName name
+     */
+    IMPORT_C void SetFriendlyNameL( const TDesC8& aName );
+    
+    /**
+     * Return friendly name
+     * 
+     * @return friendly name
+     */
+    IMPORT_C const TDesC8& FriendlyName() const;
+    
+    /**
+     * Sets the model name of the device
+     * 
+     * @param aName name
+     */
+    IMPORT_C void SetModelNameL( const TDesC8& aName );
+
+    /**
+     * Return model name
+     * 
+     * @return model name
+     */
+    IMPORT_C const TDesC8& ModelName() const;
+    
+    /**
+     * Sets the Uuid of the device
+     * 
+     * @param aUuid Uuid
+     */
+    IMPORT_C void SetUuidL( const TDesC8& aUuid );
+    
+    /**
+     * Return Uuid
+     * 
+     * @return Uuid
+     */
+    IMPORT_C const TDesC8& Uuid() const;
+    
+    /**
+     * Sets the device type (Media Server/Renderer)
+     * 
+     * @param aDeviceType device type
+     */
+    IMPORT_C void SetDeviceType( TUpnpAVDeviceType aDeviceType );
+    
+    /**
+     * Return device type
+     * 
+     * @return device type
+     */
+    IMPORT_C TUpnpAVDeviceType DeviceType() const;
+            
+    /**
+     * Return link offset (used in linked list)
+     * 
+     * @return link offset
+     */
+    IMPORT_C static TInt LinkOffset();         
+
+public: // UPnP media server device capability getters and setters 
+
+    /**
+     * Sets the copy capability of the device
+     * 
+     * @param TBool the copy capability
+     * @return None
+     */
+    IMPORT_C void SetCopyCapability( TBool aCopyCap );
+
+    /**
+     * Gets the copy capability of the device
+     * 
+     * @param None
+     * @return TBool the copy capability
+     */
+    IMPORT_C TBool CopyCapability() const;
+
+    /**
+     * Sets the search capability of the device
+     * 
+     * @param TBool the search capability
+     * @return None
+     */
+    IMPORT_C void SetSearchCapability( TBool aSearchCap );
+
+    /**
+     * Gets the search capability of the device
+     * 
+     * @param None
+     * @return TBool the search capability
+     */
+    IMPORT_C TBool SearchCapability() const;
+
+public: // UPnP rendering device capability getters and setters 
+
+    /**
+     * Sets the pause capability of the device
+     * 
+     * @param TBool the pause capability
+     * @return None
+     */
+    IMPORT_C void SetPauseCapability( TBool aPauseCap );
+
+    /**
+     * Gets the pause capability of the device
+     * 
+     * @param None
+     * @return TBool the pause capability
+     */
+    IMPORT_C TBool PauseCapability() const;
+
+    /**
+     * Sets the volume capability of the device
+     * 
+     * @param TBool the volume capability
+     * @return None
+     */
+    IMPORT_C void SetVolumeCapability( TBool aVolumeCap );
+
+    /**
+     * Gets the volume capability of the device
+     * 
+     * @param None
+     * @return TBool the volume capability
+     */
+    IMPORT_C TBool VolumeCapability() const;
+
+    /**
+     * Sets the mute capability of the device
+     * 
+     * @param TBool the mute capability
+     * @return None
+     */
+    IMPORT_C void SetMuteCapability( TBool aMuteCap );
+
+    /**
+     * Gets the mute capability of the device
+     * 
+     * @param None
+     * @return TBool the mute capability
+     */
+    IMPORT_C TBool MuteCapability() const;
+
+    /**
+     * Sets the maximum volume of the device
+     * 
+     * @param TInt the maximum volume
+     * @return None
+     */
+    IMPORT_C void SetMaxVolume( TInt aVolume );
+
+    /**
+     * Gets the maximum volume of the device
+     * 
+     * @return TInt the maximum volume
+     */
+    IMPORT_C TInt MaxVolume() const;
+    
+    /**
+     * Sets the SetNextAVTransportUri capability of the device
+     * 
+     * @param aCap (TBool)
+     * @return None
+     */
+    IMPORT_C void SetNextAVTransportUri( TBool aCap );
+
+    /**
+     * Returns the SetNextAVTransportUri capability of the device
+     * 
+     * @param None
+     * @return TBool ETrue if SetNextAVTrasportUri action is supported
+     */
+    IMPORT_C TBool NextAVTransportUri() const;           
+
+public: // UPnP media rendering capability getters and setters 
+
+    IMPORT_C void SetCapabilitiesBySupportedMimeTypesL(
+        const TDesC8& aListOfMimeTypes );
+
+    /**
+     * Sets audio capability of the device
+     * 
+     * @param aCap (TBool)
+     * @return None
+     */
+    IMPORT_C void SetAudioCapability( TBool aCap );
+
+    /**
+     * Gets the audio media capability of the device
+     * 
+     * @param None
+     * @return TBool the audio media capability
+     */
+    IMPORT_C TBool AudioCapability() const;
+
+    /**
+     * Sets image capability of the device
+     * 
+     * @param aCap (TBool)
+     * @return None
+     */
+    IMPORT_C void SetImageCapability( TBool aCap );
+
+    /**
+     * Gets the image media capability of the device
+     * 
+     * @param None
+     * @return TBool the image media capability
+     */
+    IMPORT_C TBool ImageCapability() const;
+
+    /**
+     * Sets video capability of the device
+     * 
+     * @param aCap (TBool)
+     * @return None
+     */
+    IMPORT_C void SetVideoCapability( TBool aCap );
+
+    /**
+     * Gets the video media capability of the device
+     * 
+     * @param None
+     * @return TBool the video media capability
+     */
+    IMPORT_C TBool VideoCapability() const;
+
+public: // DLNA related
+
+    /**
+     * Sets if the device is Dlna compatible
+     * 
+     * @param aDlnaCompatible
+     */    
+    IMPORT_C void SetDlnaCompatible( TBool aDlnaCompatible );
+    
+    /**
+     * Return if the device is Dlna compatible
+     * 
+     * @return ETrue if the device is dlna compatible
+     */    
+    IMPORT_C TBool DlnaCompatible() const;
+
+public: // seek related
+    /**
+     * Sets the supported seek modes.
+     * 
+     * @param aSeekCapability
+     */    
+    IMPORT_C void SetSeekCapability( TSeekMode aSeekCapability );
+    
+    /**
+     * Return the supported seek modes.
+     * 
+     * @return TSeekMode the bitwise flag which seek modes are supported. 
+     *              See TSeekModes.
+     */    
+    IMPORT_C TSeekMode SeekCapability() const;
+
+protected:
+    
+    TSglQueLink iSlink;
+    
+    HBufC8*     iUuid; // Owned
+    
+    HBufC8*     iName; // Owned
+    
+    TUpnpAVDeviceType iDeviceType;
+    
+    TBool iCopyCapability;
+    
+    TBool iSearchCapability;
+    
+    TBool iPauseCapability;
+    
+    TBool iVolumeCapability;
+    
+    TBool iMuteCapability;
+    
+    TBool iAudioMediaCapability;
+    
+    TBool iImageMediaCapability;
+    
+    TBool iVideoMediaCapability;
+    
+    TBool iNextAVTransportUri;
+
+    TInt iMaxVolume;            
+    
+    TBool iDlnaCompatible;            
+    
+    // Seek capabilities of this device. See TSeekModes for different seek 
+    // modes.
+    TSeekMode iSeekCapability;   
+    
+    HBufC8* iModelName; // Owned
+    };
+
+
 #endif // C_CUPNPAVDEVICE_H
\ No newline at end of file
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavdeviceobserver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavdeviceobserver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,79 +1,87 @@
-/*
-* Copyright (c) 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:      main callback interface for AVController client
-*
-*/
-
-
-
-
-
-
-#ifndef M_UPNPAVDEVICEOBSERVER_H
-#define M_UPNPAVDEVICEOBSERVER_H
-
-// INCLUDES
-
-// FORWARD DECLARATIONS
-class CUpnpAVDevice;
-
-/**
-* Defines the response interface for the device control operations of the
-* UPnP AV Controller.
-*
-* @since Series 60 3.1
-*/
-class MUPnPAVDeviceObserver
-    {
-
-public:
-
-    /**
-     * Notifies that a new UPnP device was discovered.
-     *
-     * UPnPAVController releases the memory allocated for aDevice
-     * after calling the callback method.
-     *
-     * @since Series 60 3.1
-     * @param aDevice CUpnpDevice object
-     * @return None
-     */
-    virtual void UPnPDeviceDiscovered( const CUpnpAVDevice& aDevice ) = 0;
-
-    /**
-     * Notifies that a UPnP device was disappeared.
-     *
-     * UPnPAVController releases the memory allocated for aDevice
-     * after calling the callback method.
-     *
-     * @since Series 60 3.1
-     * @param aDevice CUpnpDevice object
-     * @return None
-     */
-    virtual void UPnPDeviceDisappeared( const CUpnpAVDevice& aDevice ) = 0;
-
-    /**
-     * Notifies that the WLAN connection has been lost. All sessions
-     * are now usable and must be closed.
-     *
-     * @since Series 60 3.1
-     * @return None
-     */        
-    virtual void WLANConnectionLost() = 0;       
-
-    };
-
-#endif // M_UPNPAVDEVICEOBSERVER_H
-
-// End of File
+/*
+* Copyright (c) 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:      main callback interface for AVController client
+*
+*/
+
+
+
+
+
+
+#ifndef M_UPNPAVDEVICEOBSERVER_H
+#define M_UPNPAVDEVICEOBSERVER_H
+
+// INCLUDES
+
+// FORWARD DECLARATIONS
+class CUpnpAVDevice;
+
+/**
+* Defines the response interface for the device control operations of the
+* UPnP AV Controller.
+*
+* @since Series 60 3.1
+*/
+class MUPnPAVDeviceObserver
+    {
+
+public:
+
+    /**
+     * Notifies that a new UPnP device was discovered.
+     *
+     * UPnPAVController releases the memory allocated for aDevice
+     * after calling the callback method.
+     *
+     * @since Series 60 3.1
+     * @param aDevice CUpnpDevice object
+     * @return None
+     */
+    virtual void UPnPDeviceDiscovered( const CUpnpAVDevice& aDevice ) = 0;
+
+    /**
+     * Notifies that a UPnP device was disappeared.
+     *
+     * UPnPAVController releases the memory allocated for aDevice
+     * after calling the callback method.
+     *
+     * @since Series 60 3.1
+     * @param aDevice CUpnpDevice object
+     * @return None
+     */
+    virtual void UPnPDeviceDisappeared( const CUpnpAVDevice& aDevice ) = 0;
+
+    /**
+     * Notifies that the WLAN connection has been lost. All sessions
+     * are now unusable and must be closed.
+     *
+     * @since Series 60 3.1
+     * @return None
+     */        
+    virtual void WLANConnectionLost() = 0;       
+
+    /**
+     * Notifies that the device icon download has completed and icon is readable by 
+     * MUPnPAVController::GetDeviceIconL().
+     *
+     * @param aDevice CUpnpDevice object
+     */
+    virtual void UPnPDeviceIconDownloaded( const CUpnpAVDevice& /*aDevice*/ ) {}
+
+    };
+
+#endif // M_UPNPAVDEVICEOBSERVER_H
+
+// End of File
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingactive.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingactive.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,285 +1,274 @@
-/*
-* Copyright (c) 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:      AO for performing rendering commands
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPAVRENDERINGACTIVE_H
-#define C_UPNPAVRENDERINGACTIVE_H
-
-#include <e32std.h>
-#include <e32base.h>
-#include "upnpavrenderingsessionobserver.h"
-
-class RUPnPAVControllerClient;
-class CUpnpItem;
-//class CUPnPAVRenderingSessionImpl;
-
-/**
- *  ?one_line_short_description
- *
- *  ?more_complete_description
- *
- *  @lib upnpavcontrollerclient.lib
- *  @since S60 v3.1
- */
-class CUPnPAVRenderingActive : public CActive
-    {
-
-private:
-
-    /**
-     * Enumeration to define the action
-     */
-    enum TPendingOperation
-        {
-        ENone = 0,
-        ESetURI,
-        ESetNextURI,
-        EPlay,
-        EStop,
-        EPause,
-        ESetVolume,
-        EGetVolume,
-        ESetMute,
-        EGetMute,
-        EPositionInfo,
-        EStartMediaServer
-        };
-
-public:
-
-    /**
-     * Two-phased constructor.
-     *
-     * @param aServer session handle
-     * @param aId session id
-     * @return an instance
-     */
-    static CUPnPAVRenderingActive* NewL(
-        RUPnPAVControllerClient& aServer, TInt aId );
-    
-    /**
-     * Destructor
-     */
-    virtual ~CUPnPAVRenderingActive();
-       
-private:
-
-    /**
-     * Constructor
-     */
-    CUPnPAVRenderingActive( RUPnPAVControllerClient& aServer, TInt aId );
-    
-    /**
-     * 2nd phase construct
-     */
-    void ConstructL();
-
-protected: // From CActive
-
-    /**
-     * See e32base.h
-     */
-    void RunL();
-    
-    /**
-     * See e32base.h
-     */
-    void DoCancel();
-    
-    /**
-     * See e32base.h
-     */
-    TInt RunError( TInt aError );
-
-public: // New functions    
-
-    /**
-     * Sets Media observer instance
-     *
-     * @since Series 60 3.1      
-     * @param aInstance MUPnPAVMediaObserver instance of the class that
-     *        implements the IF
-     * @return TInt status
-     */
-    void SetObserver( MUPnPAVRenderingSessionObserver& aObserver );
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void RemoveObserver();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    MUPnPAVRenderingSessionObserver* Observer() const;
-        
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void ReserveLocalMSServicesL(); 
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void CancelReserveLocalMSServicesL(); 
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void ReleaseLocalMSServicesL(); 
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void SetURIL( const TDesC8& aURI, const CUpnpItem& aItem );
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void SetNextURIL( const TDesC8& aURI, const CUpnpItem& aItem );
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void PlayL();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void StopL();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void PauseL();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void SetVolumeL( TInt aVolumeLevel );
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void GetVolumeL();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void SetMuteL( TBool aMute );
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void GetMuteL();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void GetPositionInfoL();
-        
-private:
-
-    /**
-     * Reset method
-     */
-    void ResetL();
-    
-    /**
-     * Set uri response handling
-     */
-    void SetURICompleteL();
-    
-    /**
-     * Set next uri response handling
-     */
-    void SetNextURICompleteL();
-    
-    /**
-     * Play response handling
-     */
-    void PlayCompleteL();
-    
-    /**
-     * Stop response handling
-     */
-    void StopCompleteL();
-    
-    /**
-     * Pause response handling
-     */
-    void PauseCompleteL();
-    
-    /**
-     * Set volume response handling
-     */
-    void SetVolumeCompleteL();
-    
-    /**
-     * Get volume response handling
-     */
-    void GetVolumeCompleteL();
-    
-    /**
-     * Set mute response handling
-     */
-    void SetMuteCompleteL();
-    
-    /**
-     * Get mute response handling
-     */
-    void GetMuteCompleteL();
-    
-    /**
-     * Get position info response handling
-     */
-    void PositionInfoCompleteL();
-    
-    /**
-     * Start media server response handling
-     */
-    void StartMediaServerCompleteL();    
-
-private:
-
-    RUPnPAVControllerClient&            iServer;
-
-    TInt                                iId;
-
-    // Buffer to pass data to server
-    HBufC8*                             iBuffer; // owned
-    TPtr8                               iBufferPtr;         
-
-    HBufC8*                             iBuffer2; // owned
-    TPtr8                               iBufferPtr2;         
-    
-    TInt                                iRespBufSize;           
-    TPckg<TInt>                         iRespBufSizePkg;
-    
-    TBool                               iMediaServerResourceReserved;
-    
-    TPendingOperation                   iPendingOperation;
-    
-    MUPnPAVRenderingSessionObserver*    iObserver; // Not owned      
-    
-    };
-
-#endif // C_UPNPAVRENDERINGACTIVE_H
+/*
+* Copyright (c) 2006-2009 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:      AO for performing rendering commands
+*
+*/
+
+
+#ifndef C_UPNPAVRENDERINGACTIVE_H
+#define C_UPNPAVRENDERINGACTIVE_H
+
+#include <e32std.h>
+#include <e32base.h>
+#include "upnpavrenderingsessionobserver.h"
+
+class RUPnPAVControllerClient;
+class CUpnpItem;
+
+
+/**
+ *  ?one_line_short_description
+ *
+ *  ?more_complete_description
+ *
+ *  @lib upnpavcontrollerclient.lib
+ *  @since S60 v3.1
+ */
+class CUPnPAVRenderingActive : public CActive
+    {
+
+private:
+
+    /**
+     * Enumeration to define the action
+     */
+    enum TPendingOperation
+        {
+        ENone = 0,
+        ESetURI,
+        ESetNextURI,
+        EPlay,
+        EStop,
+        EPause,
+        ESetVolume,
+        EGetVolume,
+        ESetMute,
+        EGetMute,
+        EPositionInfo,
+        ESeekRelTime
+        };
+
+public:
+
+    /**
+     * Two-phased constructor.
+     *
+     * @param aServer session handle
+     * @param aId session id
+     * @return an instance
+     */
+    static CUPnPAVRenderingActive* NewL(
+        RUPnPAVControllerClient& aServer, TInt aId );
+    
+    /**
+     * Destructor
+     */
+    virtual ~CUPnPAVRenderingActive();
+       
+private:
+
+    /**
+     * Constructor
+     */
+    CUPnPAVRenderingActive( RUPnPAVControllerClient& aServer, TInt aId );
+    
+    /**
+     * 2nd phase construct
+     */
+    void ConstructL();
+
+protected: // From CActive
+
+    /**
+     * See e32base.h
+     */
+    void RunL();
+    
+    /**
+     * See e32base.h
+     */
+    void DoCancel();
+    
+    /**
+     * See e32base.h
+     */
+    TInt RunError( TInt aError );
+
+public: // New functions    
+
+    /**
+     * Sets Media observer instance
+     *
+     * @since Series 60 3.1      
+     * @param aInstance MUPnPAVMediaObserver instance of the class that
+     *        implements the IF
+     * @return TInt status
+     */
+    void SetObserver( MUPnPAVRenderingSessionObserver& aObserver );
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void RemoveObserver();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    MUPnPAVRenderingSessionObserver* Observer() const;
+        
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SetURIL( const TDesC8& aURI, const CUpnpItem& aItem );
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SetNextURIL( const TDesC8& aURI, const CUpnpItem& aItem );
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void PlayL();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void StopL();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void PauseL();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SetVolumeL( TInt aVolumeLevel );
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void GetVolumeL();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SetMuteL( TBool aMute );
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void GetMuteL();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void GetPositionInfoL();
+        
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SeekRelTimeL( const TTime& aDesiredTime );
+    
+    /**
+     * See upnpavrenderingsession.h
+     */
+    TUPnPAVInteractOperation GetRendererStateL();
+        
+private:
+
+    /**
+     * Reset method
+     */
+    void ResetL();
+    
+    /**
+     * Set uri response handling
+     */
+    void SetURICompleteL();
+    
+    /**
+     * Set next uri response handling
+     */
+    void SetNextURICompleteL();
+    
+    /**
+     * Play response handling
+     */
+    void PlayCompleteL();
+    
+    /**
+     * Stop response handling
+     */
+    void StopCompleteL();
+    
+    /**
+     * Pause response handling
+     */
+    void PauseCompleteL();
+    
+    /**
+     * Set volume response handling
+     */
+    void SetVolumeCompleteL();
+    
+    /**
+     * Get volume response handling
+     */
+    void GetVolumeCompleteL();
+    
+    /**
+     * Set mute response handling
+     */
+    void SetMuteCompleteL();
+    
+    /**
+     * Get mute response handling
+     */
+    void GetMuteCompleteL();
+    
+    /**
+     * Get position info response handling
+     */
+    void PositionInfoCompleteL();
+    
+    /**
+     * Seek with unit REL_TIME response handling
+     */
+    void SeekRelTimeComplete();
+
+private:
+
+    RUPnPAVControllerClient&            iServer;
+
+    TInt                                iId;
+
+    // Buffer to pass data to server
+    HBufC8*                             iBuffer; // owned
+    TPtr8                               iBufferPtr;         
+
+    HBufC8*                             iBuffer2; // owned
+    TPtr8                               iBufferPtr2;         
+    
+    TInt                                iRespBufSize;           
+    TPckg<TInt>                         iRespBufSizePkg;
+    
+    TPendingOperation                   iPendingOperation;
+    
+    MUPnPAVRenderingSessionObserver*    iObserver; // Not owned      
+    
+    };
+
+#endif // C_UPNPAVRENDERINGACTIVE_H
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingsession.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingsession.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,173 +1,188 @@
-/*
-* Copyright (c) 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:      interface for session against a renderer
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPAVRENDERINGSESSION_H
-#define C_UPNPAVRENDERINGSESSION_H
-
-#include <e32std.h>
-#include "upnpavsessionbase.h"
-
-class MUPnPAVRenderingSessionObserver;
-class CUpnpItem;
-
-/**
- *  AV Controller rendering session interface.
- *
- *  This class defines the rendering interface of AV Controller.
- *  Includes operations to set and to set next uri, play, stop and
- *  pause the playback, to set the volume and mute and to get the
- *  position information
- *
- *  @lib upnpavcontrollerclient.lib
- *  @since S60 v3.1
- */
- class MUPnPAVRenderingSession : public MUPnPAVSessionBase
-    {
-
-public:
-
-    /**
-     * Sets the rendering session observer
-     *
-     * @since Series 60 3.1      
-     * @param aObserver rendering session observer
-     * @return none
-     */
-    virtual void SetObserver(
-        MUPnPAVRenderingSessionObserver& aObserver ) = 0;
-
-    /**
-     * Removes the rendering session observer
-     *
-     * @since Series 60 3.1     
-     * @param None
-     * @return None
-     */
-    virtual void RemoveObserver() = 0;
-    
-    /**
-     * Returns the rendering session observer
-     *
-     * @since Series 60 3.1     
-     * @param None
-     * @return observer
-     */
-    virtual MUPnPAVRenderingSessionObserver* Observer() const = 0;   
-    
-public:
-
-    /**
-     * Set the URI by providing an URI and the item  
-     * 
-     * @since Series 60 3.1
-     * @param aURI URI of the item
-     * @param aObject item
-     */
-    virtual void SetURIL( const TDesC8& aURI, const CUpnpItem& aItem ) = 0;
-    
-    /**
-     * Set the next URI by providing an URI and the item  
-     * 
-     * @since Series 60 3.1
-     * @param aURI URI of the item
-     * @param aObject item
-     */
-    virtual void SetNextURIL( const TDesC8& aURI,
-        const CUpnpItem& aItem ) = 0;
-
-    /**
-     * Starts the playback. 
-     *
-     * @since Series 60 3.1
-     * @param None
-     * @return none
-     */
-    virtual void PlayL() = 0;
-
-    /**
-     * Stops the playback.
-     *
-     * @since Series 60 3.1
-     * @param None
-     * @return none
-     */
-    virtual void StopL() = 0;
-
-    /**
-     * Pauses the playback.
-     *
-     * @since Series 60 3.1
-     * @param None
-     * @return none
-     */
-    virtual void PauseL() = 0;
-
-    /**
-     * Sets the volume level.
-     *
-     * @since Series 60 3.1
-     * @param aVolumeLevel TInt Volume level in percents (0 - 100)
-     * @return none
-     */
-    virtual void SetVolumeL( TInt aVolumeLevel ) = 0;
-
-    /**
-     * Gets the volume level.
-     *
-     * @since Series 60 3.1
-     * @param None
-     * @return none
-     */
-    virtual void GetVolumeL() = 0;
-
-    /**
-     * Sets the mute state.
-     *
-     * @since Series 60 3.1
-     * @param aMute TBool desired state of the mute (ETrue of EFalse)
-     * @return none
-     */
-    virtual void SetMuteL( TBool aMute ) = 0;
-
-    /**
-     * Gets the mute state.
-     *
-     * @since Series 60 3.1
-     * @param None
-     * @return none
-     */
-    virtual void GetMuteL() = 0;
-
-    /**
-     * Gets position info of the media that is currently
-     * rendered on the UPnP Media Renderer.
-     *
-     * @since Series 60 3.0
-     * @param none
-     * @return none
-     */
-    virtual void GetPositionInfoL() = 0;
-    
-    };
-
-
-#endif // C_UPNPAVRENDERINGSESSION_H
+/*
+* Copyright (c) 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:      interface for session against a renderer
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPAVRENDERINGSESSION_H
+#define C_UPNPAVRENDERINGSESSION_H
+
+#include <e32std.h>
+#include "upnpavsessionbase.h"
+#include "upnpavrenderingsessionobserver.h"
+
+class CUpnpItem;
+
+/**
+ *  AV Controller rendering session interface.
+ *
+ *  This class defines the rendering interface of AV Controller.
+ *  Includes operations to set and to set next uri, play, stop and
+ *  pause the playback, to set the volume and mute and to get the
+ *  position information
+ *
+ *  @lib upnpavcontrollerclient.lib
+ *  @since S60 v3.1
+ */
+ class MUPnPAVRenderingSession : public MUPnPAVSessionBase
+    {
+
+public:
+
+    /**
+     * Sets the rendering session observer
+     *
+     * @since Series 60 3.1      
+     * @param aObserver rendering session observer
+     * @return none
+     */
+    virtual void SetObserver(
+        MUPnPAVRenderingSessionObserver& aObserver ) = 0;
+
+    /**
+     * Removes the rendering session observer
+     *
+     * @since Series 60 3.1     
+     * @param None
+     * @return None
+     */
+    virtual void RemoveObserver() = 0;
+    
+    /**
+     * Returns the rendering session observer
+     *
+     * @since Series 60 3.1     
+     * @param None
+     * @return observer
+     */
+    virtual MUPnPAVRenderingSessionObserver* Observer() const = 0;   
+    
+public:
+
+    /**
+     * Set the URI by providing an URI and the item  
+     * 
+     * @since Series 60 3.1
+     * @param aURI URI of the item
+     * @param aObject item
+     */
+    virtual void SetURIL( const TDesC8& aURI, const CUpnpItem& aItem ) = 0;
+    
+    /**
+     * Set the next URI by providing an URI and the item  
+     * 
+     * @since Series 60 3.1
+     * @param aURI URI of the item
+     * @param aObject item
+     */
+    virtual void SetNextURIL( const TDesC8& aURI,
+        const CUpnpItem& aItem ) = 0;
+
+    /**
+     * Starts the playback. 
+     *
+     * @since Series 60 3.1
+     * @param None
+     * @return none
+     */
+    virtual void PlayL() = 0;
+
+    /**
+     * Stops the playback.
+     *
+     * @since Series 60 3.1
+     * @param None
+     * @return none
+     */
+    virtual void StopL() = 0;
+
+    /**
+     * Pauses the playback.
+     *
+     * @since Series 60 3.1
+     * @param None
+     * @return none
+     */
+    virtual void PauseL() = 0;
+
+    /**
+     * Sets the volume level.
+     *
+     * @since Series 60 3.1
+     * @param aVolumeLevel TInt Volume level in percents (0 - 100)
+     * @return none
+     */
+    virtual void SetVolumeL( TInt aVolumeLevel ) = 0;
+
+    /**
+     * Gets the volume level.
+     *
+     * @since Series 60 3.1
+     * @param None
+     * @return none
+     */
+    virtual void GetVolumeL() = 0;
+
+    /**
+     * Sets the mute state.
+     *
+     * @since Series 60 3.1
+     * @param aMute TBool desired state of the mute (ETrue of EFalse)
+     * @return none
+     */
+    virtual void SetMuteL( TBool aMute ) = 0;
+
+    /**
+     * Gets the mute state.
+     *
+     * @since Series 60 3.1
+     * @param None
+     * @return none
+     */
+    virtual void GetMuteL() = 0;
+
+    /**
+     * Gets position info of the media that is currently
+     * rendered on the UPnP Media Renderer.
+     *
+     * @since Series 60 3.0
+     * @param none
+     * @return none
+     */
+    virtual void GetPositionInfoL() = 0;
+    
+    /**
+     * Sends a AVTransport Seek operation with type REL_TIME to the renderer.
+     *
+     * @since Series 60 3.2.3
+     * @param aDesiredTime the time where to seek
+     */
+    virtual void SeekRelTimeL( const TTime& aDesiredTime ) = 0;
+        
+    /**
+     * Returns current state of the renderer
+     *
+     * @since Series 60 5.2
+     * @return TUPnPAVInteractOperation rendrer state
+     */
+    virtual TUPnPAVInteractOperation GetRendererStateL() = 0;
+    };
+
+
+#endif // C_UPNPAVRENDERINGSESSION_H
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingsessionimpl.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingsessionimpl.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,233 +1,228 @@
-/*
-* Copyright (c) 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:      implements a session against a renderer
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPAVRENDERINGSESSIONIMPL_H
-#define C_UPNPAVRENDERINGSESSIONIMPL_H
-
-// INCLUDE FILES
-#include <e32std.h>
-#include <e32base.h>
-
-#include "upnpavrenderingsession.h"
-#include "upnpavdeviceobserver.h"
-
-// FORWARD DECLARATIONS
-class CUpnpAVDevice;
-class RUPnPAVControllerClient;
-class CUPnPAVEventActive;
-class CUPnPAVDeviceActive;
-class CUPnPAVRenderingActive;
-class CUpnpItem;
-class TUnsolicitedEventC;
-
-/**
- *  AV Controller rendering session implementation.
- *
- *  This class implements the rendering session. Includes operations
- *  to set and to set next uri, play, stop and pause the playback,
- *  to set the volume and mute and to get the position information
- *
- *  @lib upnpavcontrollerclient.lib
- *  @since S60 v3.1
- */
-class CUPnPAVRenderingSessionImpl : public CBase,
-                                    public MUPnPAVRenderingSession,
-                                    public MUPnPAVDeviceObserver
-                                    
-    {
-
-public:
-
-    /**
-     * Static constructor
-     *
-     * @param aServer handle to AV Controller server
-     * @param aDevice target device
-     * @return a new browsing session implementation instance
-     */    
-    static CUPnPAVRenderingSessionImpl* NewL(
-        RUPnPAVControllerClient& aServer,
-        const CUpnpAVDevice& aDevice );
- 
-    /**
-     * Destructor
-     */        
-    virtual ~CUPnPAVRenderingSessionImpl();
-    
-private:
-
-    /**
-     * 2nd phase construct
-     */    
-    CUPnPAVRenderingSessionImpl( RUPnPAVControllerClient& aServer );
-    
-    /**
-     * 2nd phase construct
-     */        
-    void ConstructL();
-
-protected: // From MUPnPAVRenderingSession
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void SetObserver( MUPnPAVRenderingSessionObserver& aObserver );
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void RemoveObserver();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    MUPnPAVRenderingSessionObserver* Observer() const;
-    
-    /**
-     * See upnpavrenderingsession.h
-     */
-    const CUpnpAVDevice& Device() const;
-    
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void ReserveLocalMSServicesL(); 
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void CancelReserveLocalMSServicesL(); 
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void ReleaseLocalMSServicesL(); 
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void SetURIL( const TDesC8& aURI, const CUpnpItem& aItem );
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void SetNextURIL( const TDesC8& aURI, const CUpnpItem& aItem );
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void PlayL();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void StopL();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void PauseL();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void SetVolumeL( TInt aVolumeLevel );
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void GetVolumeL();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void SetMuteL( TBool aMute );
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void GetMuteL();
-
-    /**
-     * See upnpavrenderingsession.h
-     */
-    void GetPositionInfoL();
-
-public: // From MUPnPAVDeviceObserver
-
-    /**
-     * See upnpavdeviceobserver.h
-     */
-    void UPnPDeviceDiscovered( const CUpnpAVDevice& aDevice );
-
-    /**
-     * See upnpavdeviceobserver.h
-     */
-    void UPnPDeviceDisappeared( const CUpnpAVDevice& aDevice );
-
-    /**
-     * See upnpavdeviceobserver.h
-     */
-    void WLANConnectionLost();
-
-public: // Public methods
-
-    /**
-     * A method to receive an unsolicited event
-     * @param aError error code
-     * @param aEvent event
-     */     
-    void EventReceived( TInt aError,
-        TUnsolicitedEventC aEvent );
-       
-private: // Private methods
-
-    void ResetL();
-
-private:
-
-    RUPnPAVControllerClient&            iServer; // not owned
-    
-    MUPnPAVRenderingSessionObserver*    iObserver; // not owned
-    
-    CUPnPAVDeviceActive*                iDeviceActive; // owned
-    
-    CUPnPAVEventActive*                 iEventActive; // owned
-    
-    CUPnPAVRenderingActive*             iCommandActive; // owned
-    
-    CUPnPAVRenderingActive*             iSettingActive; // owned    
-    
-    CUpnpAVDevice*                      iDevice; // owned
-
-    // Buffer to pass data to server
-    HBufC8*                             iBuffer; // owned            
-    TPtr8                               iBufferPtr;         
- 
-    TBool                               iAlive;
-        
-    TBool                               iMediaServerResourceReserved;
-    
-    };
-
-
-#endif // C_UPNPAVRENDERINGSESSIONIMPL_H
+/*
+* Copyright (c) 2006-2009 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:      implements a session against a renderer
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPAVRENDERINGSESSIONIMPL_H
+#define C_UPNPAVRENDERINGSESSIONIMPL_H
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32base.h>
+
+#include "upnpavrenderingsession.h"
+#include "upnpavdeviceobserver.h"
+
+// FORWARD DECLARATIONS
+class CUpnpAVDevice;
+class RUPnPAVControllerClient;
+class CUPnPAVEventActive;
+class CUPnPAVDeviceActive;
+class CUPnPAVRenderingActive;
+class CUpnpItem;
+class TUnsolicitedEventC;
+
+/**
+ *  AV Controller rendering session implementation.
+ *
+ *  This class implements the rendering session. Includes operations
+ *  to set and to set next uri, play, stop and pause the playback,
+ *  to set the volume and mute and to get the position information
+ *
+ *  @lib upnpavcontrollerclient.lib
+ *  @since S60 v3.1
+ */
+class CUPnPAVRenderingSessionImpl : public CBase,
+                                    public MUPnPAVRenderingSession,
+                                    public MUPnPAVDeviceObserver
+                                    
+    {
+
+public:
+
+    /**
+     * Static constructor
+     *
+     * @param aServer handle to AV Controller server
+     * @param aDevice target device
+     * @return a new browsing session implementation instance
+     */    
+    static CUPnPAVRenderingSessionImpl* NewL(
+        RUPnPAVControllerClient& aServer,
+        const CUpnpAVDevice& aDevice );
+ 
+    /**
+     * Destructor
+     */        
+    virtual ~CUPnPAVRenderingSessionImpl();
+    
+private:
+
+    /**
+     * 2nd phase construct
+     */    
+    CUPnPAVRenderingSessionImpl( RUPnPAVControllerClient& aServer );
+    
+    /**
+     * 2nd phase construct
+     */        
+    void ConstructL();
+
+protected: // From MUPnPAVRenderingSession
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SetObserver( MUPnPAVRenderingSessionObserver& aObserver );
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void RemoveObserver();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    MUPnPAVRenderingSessionObserver* Observer() const;
+    
+    /**
+     * See upnpavrenderingsession.h
+     */
+    const CUpnpAVDevice& Device() const;
+    
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SetURIL( const TDesC8& aURI, const CUpnpItem& aItem );
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SetNextURIL( const TDesC8& aURI, const CUpnpItem& aItem );
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void PlayL();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void StopL();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void PauseL();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SetVolumeL( TInt aVolumeLevel );
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void GetVolumeL();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SetMuteL( TBool aMute );
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void GetMuteL();
+
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void GetPositionInfoL();
+    
+    /**
+     * See upnpavrenderingsession.h
+     */
+    void SeekRelTimeL( const TTime& aDesiredTime );
+    
+    /**
+     * See upnpavrenderingsession.h
+     */
+    TUPnPAVInteractOperation GetRendererStateL();
+
+public: // From MUPnPAVDeviceObserver
+
+    /**
+     * See upnpavdeviceobserver.h
+     */
+    void UPnPDeviceDiscovered( const CUpnpAVDevice& aDevice );
+
+    /**
+     * See upnpavdeviceobserver.h
+     */
+    void UPnPDeviceDisappeared( const CUpnpAVDevice& aDevice );
+
+    /**
+     * See upnpavdeviceobserver.h
+     */
+    void WLANConnectionLost();
+
+public: // Public methods
+
+    /**
+     * A method to receive an unsolicited event
+     * @param aError error code
+     * @param aEvent event
+     */     
+    void EventReceived( TInt aError,
+        TUnsolicitedEventC aEvent );
+       
+private: // Private methods
+
+    void ResetL();
+
+private:
+
+    RUPnPAVControllerClient&            iServer; // not owned
+    
+    MUPnPAVRenderingSessionObserver*    iObserver; // not owned
+    
+    CUPnPAVDeviceActive*                iDeviceActive; // owned
+    
+    CUPnPAVEventActive*                 iEventActive; // owned
+    
+    CUPnPAVRenderingActive*             iCommandActive; // owned
+    
+    CUPnPAVRenderingActive*             iSettingActive; // owned    
+    
+    CUpnpAVDevice*                      iDevice; // owned
+
+    // Buffer to pass data to server
+    HBufC8*                             iBuffer; // owned            
+    TPtr8                               iBufferPtr;         
+ 
+    TBool                               iAlive;
+        
+    TBool                               iMediaServerResourceReserved;
+    
+    };
+
+
+#endif // C_UPNPAVRENDERINGSESSIONIMPL_H
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingsessionobserver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavrenderingsessionobserver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,151 +1,151 @@
-/*
-* Copyright (c) 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:      callback interface for a rendering session
-*
-*/
-
-
-
-
-
-
-#ifndef M_UPNPAVRENDERINGSESSIONOBSERVER_H
-#define M_UPNPAVRENDERINGSESSIONOBSERVER_H
-
-// INCLUDE FILES
-#include "upnpavsessionobserverbase.h"
-
-// TYPEDEFS
-enum TUPnPAVInteractOperation
-    {
-    EUPnPAVPlay = 0,
-    EUPnPAVPause,
-    EUPnPAVStop,
-    EUPnPAVPlayUser,
-    EUPnPAVPauseUser,
-    EUPnPAVStopUser
-    };
-
-/**
-* Defines the response interface for the media control operations of the
-* UPnP AV Controller.
-*
-* @since Series 60 3.1
-*/
-class MUPnPAVRenderingSessionObserver : public MUPnPAVSessionObserverBase
-    {
-    
-public:
-
-    /**
-     * UPnP AV Controller calls this method to return the result for the
-     * 'get volume' request. Parameter contains the volume level of the
-     * media renderer device to which the 'get volume' request was sent.
-     *
-     * @since Series 60 3.1
-     * @param aError system wide error code
-     * @param aVolumeLevel TInt volume level (integer value between 0 - 100)
-     * @param aActionResponse ETrue, if this is a response to GetVolume()
-     * @return None
-     */
-    virtual void VolumeResult( TInt aError, TInt aVolumeLevel,
-        TBool aActionResponse ) = 0;
-
-    /**
-     * UPnP AV Controller calls this method to return the result for the
-     * 'get mute' request. Parameter contains the state of the mute of the
-     * media renderer device to which the 'get mute' request was sent.
-     *
-     * @since Series 60 3.1
-     * @param aError system wide error code
-     * @param aMute TBool the state of the mute (ETrue or EFalse)
-     * @param aActionResponse ETrue, if this is a response to GetMute()
-     * @return None
-     */
-    virtual void MuteResult( TInt aError, TBool aMute,
-        TBool aActionResponse ) = 0;
-
-    /**
-     * UPnP AV Controller calls this method to indicate that the requested
-     * interaction operation (play, stop, etc.) is complete. In other words,
-     * the target rendering device has changed it's state accordingly.
-     *
-     * @since Series 60 3.1
-     * @param aError system wide error code
-     * @param aOperation TInt operation (TAVInteractOperation)
-     * @return None
-     */
-    virtual void InteractOperationComplete( 
-                      TInt aError,
-                      TUPnPAVInteractOperation aOperation 
-                      ) = 0;
-
-    /**
-     * UPnP AV Controller calls this method as a response to Position 
-     * Info action. The current position and the total length of the 
-     * track that is currently playing is returned. The results are in
-     * (hh:mm:ss) format.
-     *
-     * UPnPAVController releases the memory allocated for aTrackPosition
-     * and aTrackLength.
-     *
-     * @since Series 60 3.0
-     * @param aStatus TInt error code
-     * @param aTrackPosition TDesC8& track position
-     * @param aTrackLength TDesC8& track length
-     * @return None
-     */
-    virtual void PositionInfoResult( 
-                      TInt aError, 
-                      const TDesC8& aTrackPosition, 
-                      const TDesC8& aTrackLength 
-                      ) = 0;
-
-    /**
-     * UPnP AV Controller calls this method to return the result for the
-     * 'set uri' request.
-     *
-     * @since Series 60 3.1
-     * @param aError error code
-     * @return None
-     */                      
-    virtual void SetURIResult( TInt aError ) = 0;
-
-    /**
-     * UPnP AV Controller calls this method to return the result for the
-     * 'set next uri' request.
-     *
-     * @since Series 60 3.1
-     * @param aError error code
-     * @return None
-     */                         
-    virtual void SetNextURIResult( TInt aError ) = 0;                   
-
-    /**
-     * Notifies that the Media Renderer we have a session with has
-     * disappeared. Session is now unusable and must be closed. 
-     *
-     * @since Series 60 3.1
-     * @return None
-     */        
-    virtual void MediaRendererDisappeared( 
-        TUPnPDeviceDisconnectedReason aReason ) = 0;
-        
-    virtual void ReserveLocalMSServicesCompleted( TInt aError ) = 0;        
-
-    };
-
-#endif // M_UPNPAVRENDERINGSESSIONOBSERVER_H
-
-// End of File
+/*
+* Copyright (c) 2006-2009 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:      callback interface for a rendering session
+*
+*/
+
+
+
+
+
+
+#ifndef M_UPNPAVRENDERINGSESSIONOBSERVER_H
+#define M_UPNPAVRENDERINGSESSIONOBSERVER_H
+
+// INCLUDE FILES
+#include "upnpavsessionobserverbase.h"
+
+// TYPEDEFS
+enum TUPnPAVInteractOperation
+    {
+    EUPnPAVPlay = 0,
+    EUPnPAVPause,
+    EUPnPAVStop,
+    EUPnPAVPlayUser,
+    EUPnPAVPauseUser,
+    EUPnPAVStopUser,
+    EUPnPAVSeek,
+    EUPnPAVTransition
+    };
+
+/**
+* Defines the response interface for the media control operations of the
+* UPnP AV Controller.
+*
+* @since Series 60 3.1
+*/
+class MUPnPAVRenderingSessionObserver : public MUPnPAVSessionObserverBase
+    {
+    
+public:
+
+    /**
+     * UPnP AV Controller calls this method to return the result for the
+     * 'get volume' request. Parameter contains the volume level of the
+     * media renderer device to which the 'get volume' request was sent.
+     *
+     * @since Series 60 3.1
+     * @param aError system wide error code
+     * @param aVolumeLevel TInt volume level (integer value between 0 - 100)
+     * @param aActionResponse ETrue, if this is a response to GetVolume()
+     * @return None
+     */
+    virtual void VolumeResult( TInt aError, TInt aVolumeLevel,
+        TBool aActionResponse ) = 0;
+
+    /**
+     * UPnP AV Controller calls this method to return the result for the
+     * 'get mute' request. Parameter contains the state of the mute of the
+     * media renderer device to which the 'get mute' request was sent.
+     *
+     * @since Series 60 3.1
+     * @param aError system wide error code
+     * @param aMute TBool the state of the mute (ETrue or EFalse)
+     * @param aActionResponse ETrue, if this is a response to GetMute()
+     * @return None
+     */
+    virtual void MuteResult( TInt aError, TBool aMute,
+        TBool aActionResponse ) = 0;
+
+    /**
+     * UPnP AV Controller calls this method to indicate that the requested
+     * interaction operation (play, stop, etc.) is complete. In other words,
+     * the target rendering device has changed it's state accordingly.
+     *
+     * @since Series 60 3.1
+     * @param aError system wide error code
+     * @param aOperation TInt operation (TAVInteractOperation)
+     * @return None
+     */
+    virtual void InteractOperationComplete( 
+                      TInt aError,
+                      TUPnPAVInteractOperation aOperation 
+                      ) = 0;
+
+    /**
+     * UPnP AV Controller calls this method as a response to Position 
+     * Info action. The current position and the total length of the 
+     * track that is currently playing is returned. The results are in
+     * (hh:mm:ss) format.
+     *
+     * UPnPAVController releases the memory allocated for aTrackPosition
+     * and aTrackLength.
+     *
+     * @since Series 60 3.0
+     * @param aStatus TInt error code
+     * @param aTrackPosition TDesC8& track position
+     * @param aTrackLength TDesC8& track length
+     * @return None
+     */
+    virtual void PositionInfoResult( 
+                      TInt aError, 
+                      const TDesC8& aTrackPosition, 
+                      const TDesC8& aTrackLength 
+                      ) = 0;
+
+    /**
+     * UPnP AV Controller calls this method to return the result for the
+     * 'set uri' request.
+     *
+     * @since Series 60 3.1
+     * @param aError error code
+     * @return None
+     */                      
+    virtual void SetURIResult( TInt aError ) = 0;
+
+    /**
+     * UPnP AV Controller calls this method to return the result for the
+     * 'set next uri' request.
+     *
+     * @since Series 60 3.1
+     * @param aError error code
+     * @return None
+     */                         
+    virtual void SetNextURIResult( TInt aError ) = 0;                   
+
+    /**
+     * Notifies that the Media Renderer we have a session with has
+     * disappeared. Session is now unusable and must be closed. 
+     *
+     * @since Series 60 3.1
+     * @return None
+     */        
+    virtual void MediaRendererDisappeared( 
+        TUPnPDeviceDisconnectedReason aReason ) = 0;      
+
+    };
+
+#endif // M_UPNPAVRENDERINGSESSIONOBSERVER_H
+
+// End of File
--- a/upnpavcontroller/upnpavcontrollerclient/inc/upnpavsessionbase.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/inc/upnpavsessionbase.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,77 +1,56 @@
-/*
-* Copyright (c) 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:      a base class for browsing and rendering sessions
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPAVSESSIONBASE_H
-#define C_UPNPAVSESSIONBASE_H
-
-#include <e32std.h>
-
-class CUpnpAVDevice;
-
-/**
- *  UPnP Session base
- *
- *  @lib upnpavcontrollerclient.lib
- *  @since S60 v3.1
- */
-class MUPnPAVSessionBase
-    {
-
-public:
-
-    /**
-     * Returns the device we have a session with
-     *
-     * @since Series 60 3.1     
-     * @return device
-     */
-    virtual const CUpnpAVDevice& Device() const = 0;
-        
-    /**
-     * Reserves local Media Server services.
-     *
-     * @since Series 60 3.1     
-     */
-    virtual void ReserveLocalMSServicesL() = 0; 
-
-    /**
-     * Cancels reserving of local Media Server services.
-     *
-     * @since Series 60 3.1     
-     */
-    virtual void CancelReserveLocalMSServicesL() = 0; 
-
-    /**
-     * Releases local Media Server services.
-     *
-     * @since Series 60 3.1     
-     */
-    virtual void ReleaseLocalMSServicesL() = 0; 
-
-protected:
-    
-    virtual ~MUPnPAVSessionBase() {};
-    
-    };
-
-
-#endif // C_UPNPAVSESSIONBASE_H
+/*
+* Copyright (c) 2006-2009 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:      a base class for browsing and rendering sessions
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPAVSESSIONBASE_H
+#define C_UPNPAVSESSIONBASE_H
+
+#include <e32std.h>
+
+class CUpnpAVDevice;
+
+/**
+ *  UPnP Session base
+ *
+ *  @lib upnpavcontrollerclient.lib
+ *  @since S60 v3.1
+ */
+class MUPnPAVSessionBase
+    {
+
+public:
+
+    /**
+     * Returns the device we have a session with
+     *
+     * @since Series 60 3.1     
+     * @return device
+     */
+    virtual const CUpnpAVDevice& Device() const = 0;
+        
+protected:
+    
+    virtual ~MUPnPAVSessionBase() {};
+    
+    };
+
+
+#endif // C_UPNPAVSESSIONBASE_H
--- a/upnpavcontroller/upnpavcontrollerclient/src/upnpavbrowsingsessionimpl.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/src/upnpavbrowsingsessionimpl.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,793 +1,698 @@
-/*
-* Copyright (c) 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:      implements a session towards a media server
-*
-*/
-
-
-
-
-
-
-// INCLUDES
-// upnp stack api
-#include <upnpcontainer.h>
-#include <upnpobjectlist.h>
-#include <upnpitem.h>
-#include <upnpstring.h>
-
-// upnpframework / avcontroller api
-#include "upnpavdevice.h"
-#include "upnpavbrowsingsessionobserver.h"
-
-// avcontroller internal
-#include "upnpavcontrollerclient.h"
-#include "upnpavrequest.h"
-#include "upnpavbrowserequest.h"
-#include "upnpavdeviceactive.h"
-#include "upnpavbrowsingsessionimpl.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
-#include "upnplog.h"
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::NewL
-// Two-phase construction
-// --------------------------------------------------------------------------
-CUPnPAVBrowsingSessionImpl* CUPnPAVBrowsingSessionImpl::NewL(
-    RUPnPAVControllerClient& aServer, const CUpnpAVDevice& aDevice )
-    {
-    CUPnPAVBrowsingSessionImpl* self = new (ELeave)
-        CUPnPAVBrowsingSessionImpl( aServer );
-    CleanupStack::PushL( self );
-    self->iDevice = CUpnpAVDevice::NewL( aDevice );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::CUPnPAVBrowsingSessionImpl
-// Constructor
-// --------------------------------------------------------------------------
-CUPnPAVBrowsingSessionImpl::CUPnPAVBrowsingSessionImpl(
-    RUPnPAVControllerClient& aServer ) :
-    CActive( EPriorityStandard ),
-    iServer( aServer ),
-    iBufferPtr( 0, 0 ),
-    iBufferPtr2( 0, 0 ),
-    iBufferPtr3( 0, 0 ),
-    iRespBufSizePkg( iRespBufSize ),
-    //iMatchesPkg( iMatches ),
-    iRespParamsPkg( iRespParams ),
-    iPendingOperation( ENone ),
-    iAlive( ETrue )
-    {
-    CActiveScheduler::Add( this );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::~CUPnPAVBrowsingSessionImpl
-// Destructor
-// --------------------------------------------------------------------------
-CUPnPAVBrowsingSessionImpl::~CUPnPAVBrowsingSessionImpl()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::~CUPnPAVBrowsingSessionImpl" );
-    
-    delete iBuffer;
-    iBuffer = NULL;
-    delete iBuffer2;
-    iBuffer2 = NULL;
-    delete iBuffer3;
-    iBuffer3 = NULL;
-    
-    delete iDeviceActive;
-    iDeviceActive = NULL;
-    
-    //delete iParser;
-    delete iDevice;    
-    iDevice = NULL;
-    
-    Cancel();
-    if( iMediaServerResourceReserved )
-        {
-        iServer.ReleaseMediaServer( (TInt)this );
-        }    
-    iServer.DestroyBrowsingSession( (TInt)this );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::ConstructL
-// Two-phase construction
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::ConstructL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::ConstructL" );
-    
-    iBuffer = iDevice->Uuid().AllocL();
-    iBufferPtr.Set( iBuffer->Des() );
-    User::LeaveIfError( iServer.CreateBrowsingSession(
-        (TInt)this , iBufferPtr ) );
-    //iParser = CUPnPXMLParser::NewL();
-    iDeviceActive = CUPnPAVDeviceActive::NewL( iServer, *this );
-    iDeviceActive->StartListening( (TInt)this );
-    }
-
-void CUPnPAVBrowsingSessionImpl::RunL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::RunL" );
-    
-    switch( iPendingOperation )
-        {
-        case EBrowseSize:
-            {
-            iPendingOperation = ENone;
-            BrowseSizeCompletedL();
-            }
-            break;
-            
-        case ESearchSize:
-            {
-            iPendingOperation = ENone;
-            SearchSizeCompletedL();
-            }
-            break;
-            
-        case EGetSearchCapabilities:
-            {
-            SearchCapabilitiesCompletedL();
-            }
-            break;
-
-        case ECreateContainer:
-            {
-            CreateContainerCompletedL();
-            }
-            break;
-
-        case EDeleteObject:
-            {
-            DeleteObjectCompletedL();
-            }
-            break;
-
-        case EStartMediaServer:
-            {
-            StartMediaServerCompleteL();
-            }
-            break;
-            
-        default:
-            __PANICD( __FILE__, __LINE__ );
-            break;            
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::DoCancel
-// From CActive
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::DoCancel()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::DoCancel" );
-    
-    switch( iPendingOperation )
-        {
-        case EBrowseSize:
-            {
-            iServer.CancelBrowseResponseSize( (TInt)this );
-            }
-            break;
-
-        case ESearchSize:
-            {
-            iServer.CancelSearchResponseSize( (TInt)this );
-            }
-            break;
-
-        case EGetSearchCapabilities:
-            {
-            iServer.CancelGetSearchCapabilitiesSize( (TInt)this );
-            }
-            break;
-
-        case ECreateContainer:
-            {
-            iServer.CancelCreateContainer( (TInt)this );
-            }
-            break;
-
-        case EDeleteObject:
-            {
-            iServer.CancelDeleteObject( (TInt)this );
-            }
-            break;
-
-        case EStartMediaServer:
-            {
-            iServer.CancelReserveMediaServer( (TInt)this );
-            }
-            break;          
-
-        default:
-            __PANICD( __FILE__, __LINE__ );
-            break;            
-        }        
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::RunError
-// From CActive
-// --------------------------------------------------------------------------
-TInt CUPnPAVBrowsingSessionImpl::RunError( TInt /*aError*/ )
-    {
-    return KErrNone;
-    }
-
-   
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::SetObserver
-// Sets observer
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::SetObserver(
-    MUPnPAVBrowsingSessionObserver& aObserver )
-    {
-    iObserver = &aObserver;
-    }
-     
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::RemoveObserver
-// Removes observer
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::RemoveObserver()
-    {
-    iObserver = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::Observer
-// Returns observer
-// --------------------------------------------------------------------------
-MUPnPAVBrowsingSessionObserver* CUPnPAVBrowsingSessionImpl::Observer() const
-    {
-    return iObserver;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::Device
-// Returns used device
-// --------------------------------------------------------------------------
-const CUpnpAVDevice& CUPnPAVBrowsingSessionImpl::Device() const
-    {
-    return *iDevice;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::ReserveLocalMSServicesL
-// Reserves local media server
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::ReserveLocalMSServicesL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::ReserveLocalMSServicesL" );
-    
-    ResetL();
-    
-    if( iMediaServerResourceReserved )
-        {
-        if( iObserver )
-            {
-            iObserver->ReserveLocalMSServicesCompleted( KErrNone );
-            }
-        }
-    else
-        {
-        iPendingOperation = EStartMediaServer;
-        iServer.ReserveMediaServer( (TInt)this, iStatus );
-        SetActive();            
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::CancelReserveLocalMSServicesL
-// Cancel reserve local media server
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::CancelReserveLocalMSServicesL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::CancelReserveLocalMSServicesL" );
-    
-    if( iPendingOperation == EStartMediaServer )
-        {
-        Cancel();
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::ReleaseLocalMSServicesL
-// Release local media server
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::ReleaseLocalMSServicesL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::ReleaseLocalMSServicesL" );
-    
-    ResetL();
-    
-    if( iMediaServerResourceReserved )
-        {
-        iMediaServerResourceReserved = EFalse;
-        
-        User::LeaveIfError( iServer.ReleaseMediaServer( (TInt)this ) );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::BrowseL
-// Browse
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::BrowseL( const TDesC8& aId,
-                          const TDesC8& aFilter,
-                          TBrowseFlag aBrowseFlag,
-                          TInt aStartIndex,
-                          TInt aRequestedCount,
-                          const TDesC8& aSortCriteria )
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::BrowseL" );
-    
-    ResetL();
-    
-    CUpnpAVBrowseRequest* request = CUpnpAVBrowseRequest::NewLC();
-    request->SetIdL( aId );
-    request->SetFilterL( aFilter );
-    request->SetBrowseFlag( aBrowseFlag );
-    request->SetStartIndex( aStartIndex );
-    request->SetRequestedCount( aRequestedCount );
-    request->SetSortCriteriaL( aSortCriteria );
-    request->SetSearchCriteriaL( KNullDesC8 ); // Not needed in browse
-    
-    iBuffer = request->ToDes8L();
-    iBufferPtr.Set( iBuffer->Des() );
-    
-    CleanupStack::PopAndDestroy( request );
-    
-    iPendingOperation = EBrowseSize;
-    
-    iServer.BrowseResponseSize( (TInt)this, iBufferPtr,
-        iRespParamsPkg, iStatus );
-    SetActive();
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::CancelBrowse
-// Cancels browse
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::CancelBrowse()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::CancelBrowse" );
-    
-    if( iPendingOperation == EBrowseSize )
-        {
-        Cancel();
-        }     
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::SearchL
-// Search
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::SearchL(   const TDesC8& aId,
-                                            const TDesC8& aSearchCriteria,
-                                            const TDesC8& aFilter,
-                                            TInt aStartIndex,
-                                            TInt aRequestedCount,
-                                            const TDesC8& aSortCriteria )
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::SearchL" );
-    
-    ResetL();
-    
-    CUpnpAVBrowseRequest* request = CUpnpAVBrowseRequest::NewLC();
-    request->SetIdL( aId );
-    request->SetSearchCriteriaL( aSearchCriteria );
-    request->SetFilterL( aFilter );
-    //request->SetBrowseFlag( aBrowseFlag );
-    request->SetStartIndex( aStartIndex );
-    request->SetRequestedCount( aRequestedCount );
-    request->SetSortCriteriaL( aSortCriteria );
-    
-    
-    iBuffer = request->ToDes8L();
-    iBufferPtr.Set( iBuffer->Des() );
-    
-    CleanupStack::PopAndDestroy( request );
-    
-    iPendingOperation = ESearchSize;
-    
-    iServer.SearchResponseSize( (TInt)this, iBufferPtr,
-        iRespParamsPkg, iStatus );
-    SetActive();    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::CancelSearch
-// Cancel search
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::CancelSearch()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::CancelSearch" );
-    
-    if( iPendingOperation == ESearchSize )
-        {
-        Cancel();
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::GetSearchCapabilitiesL
-// Get search capabilities
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::GetSearchCapabilitiesL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::GetSearchCapabilitiesL" );
-    
-    ResetL();
-    
-    iPendingOperation = EGetSearchCapabilities;
-    iServer.GetSearchCapabilitiesSize( (TInt)this,
-        iRespBufSizePkg, iStatus );
-    SetActive();
-    }                
-    
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::CreateContainerL
-// Create a container
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::CreateContainerL( 
-                                            const TDesC8& aTitle,
-                                            const TDesC8& aParentId,
-                                            TContainerType aContainerType )
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::CreateContainerL" );
-    
-    ResetL();
-
-    iBuffer = aTitle.AllocL();
-    iBufferPtr.Set( iBuffer->Des() );
-    
-    iBuffer2 = aParentId.AllocL();
-    iBufferPtr2.Set( iBuffer2->Des() );
-    
-    iServer.CreateContainer( (TInt)this, 
-                              iBufferPtr,
-                              iBufferPtr2,
-                              (TInt)aContainerType,
-                              iStatus );
-    iPendingOperation = ECreateContainer;
-    SetActive();
-    }
- 
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::UPnPDeviceDiscovered
-// Device discovered
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::UPnPDeviceDiscovered(
-    const CUpnpAVDevice& /*aDevice*/ )
-    {
-    // No implementation needed
-    }
-
-  
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::UPnPDeviceDisappeared
-// Device disappeared
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::UPnPDeviceDisappeared(
-    const CUpnpAVDevice& /*aDevice*/ )
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::UPnPDeviceDisappeared" );
-    
-    iAlive = EFalse;
-    if( iObserver )
-        {
-        iObserver->MediaServerDisappeared( 
-            MUPnPAVSessionObserverBase::EDisconnected );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::WLANConnectionLost
-// Connection lost
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::WLANConnectionLost()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::WLANConnectionLost" );
-    
-    iAlive = EFalse;
-    if( iObserver )    
-        {
-        iObserver->MediaServerDisappeared( 
-            MUPnPAVSessionObserverBase::EWLANLost );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::DeleteObjectL
-// Delete object
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::DeleteObjectL( const TDesC8& aId )
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::DeleteObjectL" );
-    
-    ResetL();
-
-    iBuffer = aId.AllocL();
-    iBufferPtr.Set( iBuffer->Des() );    
-
-    iServer.DeleteObject( (TInt)this, iBufferPtr, iStatus );
-    iPendingOperation = EDeleteObject;
-    SetActive();   
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::BrowseSizeCompletedL
-// Handle browse
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::BrowseSizeCompletedL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::BrowseSizeCompletedL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerGetBrowseResponseSizeCompleted )
-            {
-            ResetL();
-            if( iRespParams.iResponseSize > 0 )
-                {
-                iBuffer = HBufC8::NewL( iRespParams.iResponseSize );
-                iBufferPtr.Set( iBuffer->Des() );
-                iBuffer2 = HBufC8::NewL( iRespParams.iUpdateIdSize );
-                iBufferPtr2.Set( iBuffer2->Des() );
-
-                TInt err = iServer.BrowseResponse( TInt(this), iBufferPtr,
-                    iBufferPtr2 );
-                if( err == EAVControllerGetBrowseResponseCompleted )
-                    {
-                    iObserver->BrowseResponse( *iBuffer, KErrNone,
-                        iRespParams.iMatches, iRespParams.iTotalCount,
-                        *iBuffer2 );
-                    
-                    }
-                else
-                    {
-                    iObserver->BrowseResponse( KNullDesC8, err, 0,
-                        0, KNullDesC8 );
-                    }
-
-                }
-            else
-                {
-                iObserver->BrowseResponse( KNullDesC8, KErrGeneral, 0,
-                    0, KNullDesC8 );
-                }    
-            }
-        else
-            {
-            iObserver->BrowseResponse( KNullDesC8, iStatus.Int(), 0,
-                0, KNullDesC8 );
-
-            }
-        }           
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::SearchSizeCompletedL
-// Handle search
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::SearchSizeCompletedL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::SearchSizeCompletedL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerGetSearchResponseSizeCompleted )
-            {
-            ResetL();
-            if( iRespParams.iResponseSize > 0 )
-                {
-                iBuffer = HBufC8::NewL( iRespParams.iResponseSize );
-                iBufferPtr.Set( iBuffer->Des() );
-                iBuffer2 = HBufC8::NewL( iRespParams.iUpdateIdSize );
-                iBufferPtr2.Set( iBuffer2->Des() );                
-                
-                TInt err = iServer.SearchResponse( TInt(this), iBufferPtr,
-                    iBufferPtr2 );
-                if( err == EAVControllerGetSearchResponseCompleted )
-                    {
-                    iObserver->SearchResponse( *iBuffer, KErrNone,
-                        iRespParams.iMatches, iRespParams.iTotalCount,
-                        *iBuffer2 ); 
-                    }
-                else
-                    {
-                    iObserver->SearchResponse( KNullDesC8, err, 0,
-                        0, KNullDesC8 ); 
-                    }                            
-                ResetL();
-                }
-            else
-                {
-                iObserver->SearchResponse( KNullDesC8, KErrGeneral, 0,
-                    0, KNullDesC8 ); 
-                }    
-            }
-        else
-            {
-            iObserver->SearchResponse( KNullDesC8, iStatus.Int(), 0,
-                0, KNullDesC8 ); 
-            }
-        }            
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::SearchCapabilitiesCompletedL
-// Handle search capabilities
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::SearchCapabilitiesCompletedL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::SearchCapabilitiesCompletedL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() ==
-            EAVControllerGetSearchCapabilitiesSizeCompleted )
-            {
-            ResetL();
-            if( iRespBufSize > 0 )
-                {
-                iBuffer = HBufC8::NewL( iRespBufSize );
-                iBufferPtr.Set( iBuffer->Des() );
-                TInt err = iServer.SearchCapabilitiesResponse( TInt(this),
-                    iBufferPtr );
-                if( err == EAVControllerGetSearchCapabilitiesCompleted )
-                    {
-                    iObserver->SearchCapabilitiesResponse(
-                        KErrNone, *iBuffer );
-                    }
-                else
-                    {
-                    iObserver->SearchCapabilitiesResponse(
-                        iStatus.Int(), KNullDesC8 );        
-                    }                    
-                }
-            else
-                {
-                iObserver->SearchCapabilitiesResponse(
-                    KErrGeneral, KNullDesC8 );
-                }    
-            }
-        else
-            {
- 
-            iObserver->SearchCapabilitiesResponse(
-                iStatus.Int(), KNullDesC8 );   
-            }
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::CreateContainerCompletedL
-// Handle CreateContainer
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::CreateContainerCompletedL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::CreateContainerCompletedL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerCreateContainerCompleted )
-            {
-            HBufC* objectId = HBufC::NewL( iBuffer->Des().Length() );
-            objectId->Des().Copy( *iBuffer );
-            CleanupStack::PushL( objectId );
-            
-            HBufC8* objectId8 = UpnpString::FromUnicodeL( *objectId );
-            
-            CleanupStack::PopAndDestroy( objectId );
-            objectId = NULL;
-            iObserver->CreateContainerResponse( KErrNone, *objectId8 );
-            delete objectId8;
-            
-            }
-        else
-            {
-            iObserver->CreateContainerResponse( iStatus.Int(), KNullDesC8 );
-            } 
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::DeleteObjectCompletedL
-// Handle delete object
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::DeleteObjectCompletedL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::DeleteObjectCompletedL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerDeleteObjectCompleted )
-            {
-            iObserver->DeleteObjectResponse( KErrNone );
-            }
-        else
-            {
-            iObserver->DeleteObjectResponse( iStatus.Int() );
-            } 
-        }        
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::ResetL
-// Reset
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::ResetL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::ResetL" );
-    
-    if( IsActive() )
-        {
-        User::Leave( KErrServerBusy );
-        }
-    if( !iAlive )
-        {
-        User::Leave( KErrDisconnected );
-        }
-    delete iBuffer; 
-    iBuffer = NULL;
-    
-    delete iBuffer2; 
-    iBuffer2 = NULL;
-    
-    delete iBuffer3; 
-    iBuffer3 = NULL;
-
-    iPendingOperation = ENone;
-    }    
-
-// --------------------------------------------------------------------------
-// CUPnPAVBrowsingSessionImpl::StartMediaServerCompleteL
-// Handle start media server
-// --------------------------------------------------------------------------
-void CUPnPAVBrowsingSessionImpl::StartMediaServerCompleteL()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::StartMediaServerCompleteL" );
-    
-    if( iObserver )
-        {
-
-        if( iStatus.Int() == EAVControllerStartMediaServerCompleted )
-            {
-            iMediaServerResourceReserved = ETrue;
-            iObserver->ReserveLocalMSServicesCompleted( KErrNone );
-            }
-        else
-            {
-            iObserver->ReserveLocalMSServicesCompleted( iStatus.Int() );
-            }
-        
-        }
-    }
-
-// end of file
+/*
+* Copyright (c) 2006-2009 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:      implements a session towards a media server
+*
+*/
+
+
+
+
+
+
+// INCLUDES
+// upnp stack api
+#include <upnpstring.h>
+
+// dlnasrv / mediaserver api
+#include <upnpcontainer.h>
+#include <upnpobjectlist.h>
+#include <upnpitem.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavdevice.h"
+#include "upnpavbrowsingsessionobserver.h"
+
+// avcontroller internal
+#include "upnpavcontrollerclient.h"
+#include "upnpavrequest.h"
+#include "upnpavbrowserequest.h"
+#include "upnpavdeviceactive.h"
+#include "upnpavbrowsingsessionimpl.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
+#include "upnplog.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::NewL
+// Two-phase construction
+// --------------------------------------------------------------------------
+CUPnPAVBrowsingSessionImpl* CUPnPAVBrowsingSessionImpl::NewL(
+    RUPnPAVControllerClient& aServer, const CUpnpAVDevice& aDevice )
+    {
+    CUPnPAVBrowsingSessionImpl* self = new (ELeave)
+        CUPnPAVBrowsingSessionImpl( aServer );
+    CleanupStack::PushL( self );
+    self->iDevice = CUpnpAVDevice::NewL( aDevice );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::CUPnPAVBrowsingSessionImpl
+// Constructor
+// --------------------------------------------------------------------------
+CUPnPAVBrowsingSessionImpl::CUPnPAVBrowsingSessionImpl(
+    RUPnPAVControllerClient& aServer ) :
+    CActive( EPriorityStandard ),
+    iServer( aServer ),
+    iBufferPtr( 0, 0 ),
+    iBufferPtr2( 0, 0 ),
+    iBufferPtr3( 0, 0 ),
+    iRespBufSizePkg( iRespBufSize ),
+    //iMatchesPkg( iMatches ),
+    iRespParamsPkg( iRespParams ),
+    iPendingOperation( ENone ),
+    iAlive( ETrue )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::~CUPnPAVBrowsingSessionImpl
+// Destructor
+// --------------------------------------------------------------------------
+CUPnPAVBrowsingSessionImpl::~CUPnPAVBrowsingSessionImpl()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::~CUPnPAVBrowsingSessionImpl" );
+    
+    delete iBuffer;
+    iBuffer = NULL;
+    delete iBuffer2;
+    iBuffer2 = NULL;
+    delete iBuffer3;
+    iBuffer3 = NULL;
+    
+    delete iDeviceActive;
+    iDeviceActive = NULL;
+    
+    //delete iParser;
+    delete iDevice;    
+    iDevice = NULL;
+    
+    Cancel();
+    iServer.DestroyBrowsingSession( (TInt)this );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::ConstructL
+// Two-phase construction
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::ConstructL()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::ConstructL" );
+    
+    iBuffer = iDevice->Uuid().AllocL();
+    iBufferPtr.Set( iBuffer->Des() );
+    User::LeaveIfError( iServer.CreateBrowsingSession(
+        (TInt)this , iBufferPtr ) );
+    //iParser = CUPnPXMLParser::NewL();
+    iDeviceActive = CUPnPAVDeviceActive::NewL( iServer, *this );
+    iDeviceActive->StartListening( (TInt)this );
+    }
+
+void CUPnPAVBrowsingSessionImpl::RunL()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::RunL" );
+    
+    switch( iPendingOperation )
+        {
+        case EBrowseSize:
+            {
+            iPendingOperation = ENone;
+            BrowseSizeCompletedL();
+            }
+            break;
+            
+        case ESearchSize:
+            {
+            iPendingOperation = ENone;
+            SearchSizeCompletedL();
+            }
+            break;
+            
+        case EGetSearchCapabilities:
+            {
+            SearchCapabilitiesCompletedL();
+            }
+            break;
+
+        case ECreateContainer:
+            {
+            CreateContainerCompletedL();
+            }
+            break;
+
+        case EDeleteObject:
+            {
+            DeleteObjectCompletedL();
+            }
+            break;
+            
+        default:
+            __PANICD( __FILE__, __LINE__ );
+            break;            
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::DoCancel
+// From CActive
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::DoCancel()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::DoCancel" );
+    
+    switch( iPendingOperation )
+        {
+        case EBrowseSize:
+            {
+            iServer.CancelBrowseResponseSize( (TInt)this );
+            }
+            break;
+
+        case ESearchSize:
+            {
+            iServer.CancelSearchResponseSize( (TInt)this );
+            }
+            break;
+
+        case EGetSearchCapabilities:
+            {
+            iServer.CancelGetSearchCapabilitiesSize( (TInt)this );
+            }
+            break;
+
+        case ECreateContainer:
+            {
+            iServer.CancelCreateContainer( (TInt)this );
+            }
+            break;
+
+        case EDeleteObject:
+            {
+            iServer.CancelDeleteObject( (TInt)this );
+            }
+            break;
+
+        default:
+            __PANICD( __FILE__, __LINE__ );
+            break;            
+        }        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::RunError
+// From CActive
+// --------------------------------------------------------------------------
+TInt CUPnPAVBrowsingSessionImpl::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+
+   
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::SetObserver
+// Sets observer
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::SetObserver(
+    MUPnPAVBrowsingSessionObserver& aObserver )
+    {
+    iObserver = &aObserver;
+    }
+     
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::RemoveObserver
+// Removes observer
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::RemoveObserver()
+    {
+    iObserver = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::Observer
+// Returns observer
+// --------------------------------------------------------------------------
+MUPnPAVBrowsingSessionObserver* CUPnPAVBrowsingSessionImpl::Observer() const
+    {
+    return iObserver;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::Device
+// Returns used device
+// --------------------------------------------------------------------------
+const CUpnpAVDevice& CUPnPAVBrowsingSessionImpl::Device() const
+    {
+    return *iDevice;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::BrowseL
+// Browse
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::BrowseL( const TDesC8& aId,
+                          const TDesC8& aFilter,
+                          TBrowseFlag aBrowseFlag,
+                          TInt aStartIndex,
+                          TInt aRequestedCount,
+                          const TDesC8& aSortCriteria )
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::BrowseL" );
+    
+    ResetL();
+    
+    CUpnpAVBrowseRequest* request = CUpnpAVBrowseRequest::NewLC();
+    request->SetIdL( aId );
+    request->SetFilterL( aFilter );
+    request->SetBrowseFlag( aBrowseFlag );
+    request->SetStartIndex( aStartIndex );
+    request->SetRequestedCount( aRequestedCount );
+    request->SetSortCriteriaL( aSortCriteria );
+    request->SetSearchCriteriaL( KNullDesC8 ); // Not needed in browse
+    
+    iBuffer = request->ToDes8L();
+    iBufferPtr.Set( iBuffer->Des() );
+    
+    CleanupStack::PopAndDestroy( request );
+    
+    iPendingOperation = EBrowseSize;
+    
+    iServer.BrowseResponseSize( (TInt)this, iBufferPtr,
+        iRespParamsPkg, iStatus );
+    SetActive();
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::CancelBrowse
+// Cancels browse
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::CancelBrowse()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::CancelBrowse" );
+    
+    if( iPendingOperation == EBrowseSize )
+        {
+        Cancel();
+        }     
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::SearchL
+// Search
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::SearchL(   const TDesC8& aId,
+                                            const TDesC8& aSearchCriteria,
+                                            const TDesC8& aFilter,
+                                            TInt aStartIndex,
+                                            TInt aRequestedCount,
+                                            const TDesC8& aSortCriteria )
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::SearchL" );
+    
+    ResetL();
+    
+    CUpnpAVBrowseRequest* request = CUpnpAVBrowseRequest::NewLC();
+    request->SetIdL( aId );
+    request->SetSearchCriteriaL( aSearchCriteria );
+    request->SetFilterL( aFilter );
+    //request->SetBrowseFlag( aBrowseFlag );
+    request->SetStartIndex( aStartIndex );
+    request->SetRequestedCount( aRequestedCount );
+    request->SetSortCriteriaL( aSortCriteria );
+    
+    
+    iBuffer = request->ToDes8L();
+    iBufferPtr.Set( iBuffer->Des() );
+    
+    CleanupStack::PopAndDestroy( request );
+    
+    iPendingOperation = ESearchSize;
+    
+    iServer.SearchResponseSize( (TInt)this, iBufferPtr,
+        iRespParamsPkg, iStatus );
+    SetActive();    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::CancelSearch
+// Cancel search
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::CancelSearch()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::CancelSearch" );
+    
+    if( iPendingOperation == ESearchSize )
+        {
+        Cancel();
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::GetSearchCapabilitiesL
+// Get search capabilities
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::GetSearchCapabilitiesL()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::GetSearchCapabilitiesL" );
+    
+    ResetL();
+    
+    iPendingOperation = EGetSearchCapabilities;
+    iServer.GetSearchCapabilitiesSize( (TInt)this,
+        iRespBufSizePkg, iStatus );
+    SetActive();
+    }                
+    
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::CreateContainerL
+// Create a container
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::CreateContainerL( 
+                                            const TDesC8& aTitle,
+                                            const TDesC8& aParentId,
+                                            TContainerType aContainerType )
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::CreateContainerL" );
+    
+    ResetL();
+
+    iBuffer = aTitle.AllocL();
+    iBufferPtr.Set( iBuffer->Des() );
+    
+    iBuffer2 = aParentId.AllocL();
+    iBufferPtr2.Set( iBuffer2->Des() );
+    
+    iServer.CreateContainer( (TInt)this, 
+                              iBufferPtr,
+                              iBufferPtr2,
+                              (TInt)aContainerType,
+                              iStatus );
+    iPendingOperation = ECreateContainer;
+    SetActive();
+    }
+ 
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::UPnPDeviceDiscovered
+// Device discovered
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::UPnPDeviceDiscovered(
+    const CUpnpAVDevice& /*aDevice*/ )
+    {
+    // No implementation needed
+    }
+
+  
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::UPnPDeviceDisappeared
+// Device disappeared
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::UPnPDeviceDisappeared(
+    const CUpnpAVDevice& /*aDevice*/ )
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::UPnPDeviceDisappeared" );
+    
+    iAlive = EFalse;
+    if( iObserver )
+        {
+        iObserver->MediaServerDisappeared( 
+            MUPnPAVSessionObserverBase::EDisconnected );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::WLANConnectionLost
+// Connection lost
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::WLANConnectionLost()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::WLANConnectionLost" );
+    
+    iAlive = EFalse;
+    if( iObserver )    
+        {
+        iObserver->MediaServerDisappeared( 
+            MUPnPAVSessionObserverBase::EWLANLost );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::DeleteObjectL
+// Delete object
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::DeleteObjectL( const TDesC8& aId )
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::DeleteObjectL" );
+    
+    ResetL();
+
+    iBuffer = aId.AllocL();
+    iBufferPtr.Set( iBuffer->Des() );    
+
+    iServer.DeleteObject( (TInt)this, iBufferPtr, iStatus );
+    iPendingOperation = EDeleteObject;
+    SetActive();   
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::BrowseSizeCompletedL
+// Handle browse
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::BrowseSizeCompletedL()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::BrowseSizeCompletedL" );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerGetBrowseResponseSizeCompleted )
+            {
+            ResetL();
+            if( iRespParams.iResponseSize > 0 )
+                {
+                iBuffer = HBufC8::NewL( iRespParams.iResponseSize );
+                iBufferPtr.Set( iBuffer->Des() );
+                iBuffer2 = HBufC8::NewL( iRespParams.iUpdateIdSize );
+                iBufferPtr2.Set( iBuffer2->Des() );
+
+                TInt err = iServer.BrowseResponse( TInt(this), iBufferPtr,
+                    iBufferPtr2 );
+                if( err == EAVControllerGetBrowseResponseCompleted )
+                    {
+                    iObserver->BrowseResponse( *iBuffer, KErrNone,
+                        iRespParams.iMatches, iRespParams.iTotalCount,
+                        *iBuffer2 );
+                    
+                    }
+                else
+                    {
+                    iObserver->BrowseResponse( KNullDesC8, err, 0,
+                        0, KNullDesC8 );
+                    }
+
+                }
+            else
+                {
+                iObserver->BrowseResponse( KNullDesC8, KErrGeneral, 0,
+                    0, KNullDesC8 );
+                }    
+            }
+        else
+            {
+            iObserver->BrowseResponse( KNullDesC8, iStatus.Int(), 0,
+                0, KNullDesC8 );
+
+            }
+        }           
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::SearchSizeCompletedL
+// Handle search
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::SearchSizeCompletedL()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::SearchSizeCompletedL" );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerGetSearchResponseSizeCompleted )
+            {
+            ResetL();
+            if( iRespParams.iResponseSize > 0 )
+                {
+                iBuffer = HBufC8::NewL( iRespParams.iResponseSize );
+                iBufferPtr.Set( iBuffer->Des() );
+                iBuffer2 = HBufC8::NewL( iRespParams.iUpdateIdSize );
+                iBufferPtr2.Set( iBuffer2->Des() );                
+                
+                TInt err = iServer.SearchResponse( TInt(this), iBufferPtr,
+                    iBufferPtr2 );
+                if( err == EAVControllerGetSearchResponseCompleted )
+                    {
+                    iObserver->SearchResponse( *iBuffer, KErrNone,
+                        iRespParams.iMatches, iRespParams.iTotalCount,
+                        *iBuffer2 ); 
+                    }
+                else
+                    {
+                    iObserver->SearchResponse( KNullDesC8, err, 0,
+                        0, KNullDesC8 ); 
+                    }                            
+                ResetL();
+                }
+            else
+                {
+                iObserver->SearchResponse( KNullDesC8, KErrGeneral, 0,
+                    0, KNullDesC8 ); 
+                }    
+            }
+        else
+            {
+            iObserver->SearchResponse( KNullDesC8, iStatus.Int(), 0,
+                0, KNullDesC8 ); 
+            }
+        }            
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::SearchCapabilitiesCompletedL
+// Handle search capabilities
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::SearchCapabilitiesCompletedL()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::SearchCapabilitiesCompletedL" );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() ==
+            EAVControllerGetSearchCapabilitiesSizeCompleted )
+            {
+            ResetL();
+            if( iRespBufSize > 0 )
+                {
+                iBuffer = HBufC8::NewL( iRespBufSize );
+                iBufferPtr.Set( iBuffer->Des() );
+                TInt err = iServer.SearchCapabilitiesResponse( TInt(this),
+                    iBufferPtr );
+                if( err == EAVControllerGetSearchCapabilitiesCompleted )
+                    {
+                    iObserver->SearchCapabilitiesResponse(
+                        KErrNone, *iBuffer );
+                    }
+                else
+                    {
+                    iObserver->SearchCapabilitiesResponse(
+                        iStatus.Int(), KNullDesC8 );        
+                    }                    
+                }
+            else
+                {
+                iObserver->SearchCapabilitiesResponse(
+                    KErrGeneral, KNullDesC8 );
+                }    
+            }
+        else
+            {
+ 
+            iObserver->SearchCapabilitiesResponse(
+                iStatus.Int(), KNullDesC8 );   
+            }
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::CreateContainerCompletedL
+// Handle CreateContainer
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::CreateContainerCompletedL()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::CreateContainerCompletedL" );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerCreateContainerCompleted )
+            {
+            HBufC* objectId = HBufC::NewL( iBuffer->Des().Length() );
+            objectId->Des().Copy( *iBuffer );
+            CleanupStack::PushL( objectId );
+            
+            HBufC8* objectId8 = UpnpString::FromUnicodeL( *objectId );
+            
+            CleanupStack::PopAndDestroy( objectId );
+            objectId = NULL;
+            iObserver->CreateContainerResponse( KErrNone, *objectId8 );
+            delete objectId8;
+            
+            }
+        else
+            {
+            iObserver->CreateContainerResponse( iStatus.Int(), KNullDesC8 );
+            } 
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::DeleteObjectCompletedL
+// Handle delete object
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::DeleteObjectCompletedL()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::DeleteObjectCompletedL" );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerDeleteObjectCompleted )
+            {
+            iObserver->DeleteObjectResponse( KErrNone );
+            }
+        else
+            {
+            iObserver->DeleteObjectResponse( iStatus.Int() );
+            } 
+        }        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVBrowsingSessionImpl::ResetL
+// Reset
+// --------------------------------------------------------------------------
+void CUPnPAVBrowsingSessionImpl::ResetL()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::ResetL" );
+    
+    if( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+    if( !iAlive )
+        {
+        User::Leave( KErrDisconnected );
+        }
+    delete iBuffer; 
+    iBuffer = NULL;
+    
+    delete iBuffer2; 
+    iBuffer2 = NULL;
+    
+    delete iBuffer3; 
+    iBuffer3 = NULL;
+
+    iPendingOperation = ENone;
+    }    
+
+// end of file
--- a/upnpavcontroller/upnpavcontrollerclient/src/upnpavconnectionactive.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/src/upnpavconnectionactive.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,125 +1,125 @@
-/*
-* Copyright (c) 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:      AO that monitors WLAN connection in client side
-*
-*/
-
-
-
-
-
-
-#include "upnpavconnectionactive.h"
-
-#include "upnpavcontrollerclient.h"
-
-#include "upnpconnectionmonitorobserver.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
-#include "upnplog.h"
-
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPAVConnectionActive::NewL
-// Two-phase constructor
-// --------------------------------------------------------------------------
-CUPnPAVConnectionActive* CUPnPAVConnectionActive::NewL(
-    RUPnPAVControllerClient& aServer,
-    MUPnPConnectionMonitorObserver& aObserver )
-    {
-    CUPnPAVConnectionActive* self = new (ELeave) CUPnPAVConnectionActive(
-        aServer, aObserver );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVConnectionActive::CUPnPAVConnectionActive
-// Constructor
-// --------------------------------------------------------------------------
-CUPnPAVConnectionActive::CUPnPAVConnectionActive(
-    RUPnPAVControllerClient& aServer,
-    MUPnPConnectionMonitorObserver& aObserver ):
-    CActive( EPriorityStandard ),
-    iServer( aServer ),
-    iObserver( aObserver )
-    {
-    CActiveScheduler::Add( this );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVConnectionActive::~CUPnPAVConnectionActive
-// Destructor
-// --------------------------------------------------------------------------
-CUPnPAVConnectionActive::~CUPnPAVConnectionActive()
-    {
-    Cancel();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVConnectionActive::ConstructL
-// Two-phase constructor
-// --------------------------------------------------------------------------
-void CUPnPAVConnectionActive::ConstructL()
-    {
-        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVConnectionActive::RunL
-// From CActive
-// --------------------------------------------------------------------------
-void CUPnPAVConnectionActive::RunL()
-    {
-    // Connection is lost
-    if( iStatus.Int() == EAVControllerConnectionLost )
-        {
-        iObserver.ConnectionLost();
-        }
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVConnectionActive::DoCancel
-// From CActive
-// --------------------------------------------------------------------------
-void CUPnPAVConnectionActive::DoCancel()
-    {
-    iServer.CancelMonitorConnection(); // Ignore error
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVConnectionActive::RunError
-// From CActive
-// --------------------------------------------------------------------------
-TInt CUPnPAVConnectionActive::RunError( TInt /*aError*/ )
-    {
-    return KErrNone;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVConnectionActive::StartMonitoring
-// Starts monitoring
-// --------------------------------------------------------------------------
-void CUPnPAVConnectionActive::StartMonitoring()
-    {
-    __ASSERTD( !IsActive(), __FILE__, __LINE__ );
-    iServer.MonitorConnection( iStatus );
-    SetActive();
-    }
-
-// end of file
+/*
+* Copyright (c) 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:      AO that monitors WLAN connection in client side
+*
+*/
+
+
+
+
+
+
+#include "upnpavconnectionactive.h"
+
+#include "upnpavcontrollerclient.h"
+
+#include "upnpconnectionmonitorobserver.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
+#include "upnplog.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPAVConnectionActive::NewL
+// Two-phase constructor
+// --------------------------------------------------------------------------
+CUPnPAVConnectionActive* CUPnPAVConnectionActive::NewL(
+    RUPnPAVControllerClient& aServer,
+    MUPnPConnectionMonitorObserver& aObserver )
+    {
+    CUPnPAVConnectionActive* self = new (ELeave) CUPnPAVConnectionActive(
+        aServer, aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVConnectionActive::CUPnPAVConnectionActive
+// Constructor
+// --------------------------------------------------------------------------
+CUPnPAVConnectionActive::CUPnPAVConnectionActive(
+    RUPnPAVControllerClient& aServer,
+    MUPnPConnectionMonitorObserver& aObserver ):
+    CActive( EPriorityStandard ),
+    iServer( aServer ),
+    iObserver( aObserver )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVConnectionActive::~CUPnPAVConnectionActive
+// Destructor
+// --------------------------------------------------------------------------
+CUPnPAVConnectionActive::~CUPnPAVConnectionActive()
+    {
+    Cancel();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVConnectionActive::ConstructL
+// Two-phase constructor
+// --------------------------------------------------------------------------
+void CUPnPAVConnectionActive::ConstructL()
+    {
+        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVConnectionActive::RunL
+// From CActive
+// --------------------------------------------------------------------------
+void CUPnPAVConnectionActive::RunL()
+    {
+    // Connection is lost
+    if( iStatus.Int() == EAVControllerConnectionLost )
+        {
+        iObserver.ConnectionLost( EFalse );
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVConnectionActive::DoCancel
+// From CActive
+// --------------------------------------------------------------------------
+void CUPnPAVConnectionActive::DoCancel()
+    {
+    iServer.CancelMonitorConnection(); // Ignore error
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVConnectionActive::RunError
+// From CActive
+// --------------------------------------------------------------------------
+TInt CUPnPAVConnectionActive::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVConnectionActive::StartMonitoring
+// Starts monitoring
+// --------------------------------------------------------------------------
+void CUPnPAVConnectionActive::StartMonitoring()
+    {
+    __ASSERTD( !IsActive(), __FILE__, __LINE__ );
+    iServer.MonitorConnection( iStatus );
+    SetActive();
+    }
+
+// end of file
--- a/upnpavcontroller/upnpavcontrollerclient/src/upnpavcontrolleractive.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/src/upnpavcontrolleractive.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,651 +1,671 @@
-/*
-* Copyright (c) 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:      AO that monitors for device events
-*
-*/
-
-
-
-
-
-
-// INCLUDES
-// upnp stack api
-#include <upnpsettings.h>
-
-// upnpframework / avcontroller api
-#include "upnpavdevice.h"
-#include "upnpavdeviceobserver.h"
-#include "upnpavdevicelist.h"
-
-// avcontroller internal
-#include "upnpavcontrolleractive.h"
-#include "upnpavrenderingsessionimpl.h"
-#include "upnpavbrowsingsessionimpl.h"
-#include "upnpavconnectionactive.h"
-#include "upnpfileuploadsessionimpl.h"
-#include "upnpfiledownloadsessionimpl.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
-#include "upnplog.h"
-
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::NewL
-// Two-phase construct
-// --------------------------------------------------------------------------
-CUPnPAVControllerActive* CUPnPAVControllerActive::NewL()
-    {
-    CUPnPAVControllerActive* self = CUPnPAVControllerActive::NewLC();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::NewLC
-// Two-phase construct
-// --------------------------------------------------------------------------
-CUPnPAVControllerActive* CUPnPAVControllerActive::NewLC()
-    {
-    CUPnPAVControllerActive* self = new (ELeave) CUPnPAVControllerActive;
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::CUPnPAVControllerActive
-// Two-phase construct
-// --------------------------------------------------------------------------
-CUPnPAVControllerActive::CUPnPAVControllerActive() :
-    CActive( EPriorityStandard ),
-    iRespBufSizePkg( iRespBufSize ),
-    iDiscoveredPkg( iDiscovered ),
-    iAlive( ETrue ),
-    iReleaseState( EStateReleasable )
-    {
-    CActiveScheduler::Add( this );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::Release
-// Destructor
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::Release()
-    {
-    __LOG( "CUPnPAVControllerActive::Release" );
-    
-    if( iReleaseState == EStateReleasable )
-        {
-        __LOG( "Release - ok to delete" );
-        delete this;
-        }
-    else if( iReleaseState == EStateWLANLost )
-        {
-        __LOG( "Release - waiting for release" );
-        // Still sending WLAN lost messages, cannot delete
-        // To be released
-        iReleaseState = EStateWaitingForRelease;
-        }
-    else
-        {
-        __LOG( "Release - do nothing, double release" );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::~CUPnPAVControllerActive
-// Destructor
-// --------------------------------------------------------------------------
-CUPnPAVControllerActive::~CUPnPAVControllerActive()
-    {
-    __LOG( "CUPnPAVControllerActive::~CUPnPAVControllerActive" );
-    Cancel();
-    delete iConnectionActive;
-    iBrowsingSessions.ResetAndDestroy();
-    iRenderingSessions.ResetAndDestroy();
-    iDownloadSessions.ResetAndDestroy();
-    iUploadSessions.ResetAndDestroy();
-
-    iServer.Close();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::ConstructL
-// Two-phase construct
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::ConstructL()
-    {
-    __LOG( "CUPnPAVControllerActive::ConstructL" );
-    
-    // Check the aip
-    TInt iap = 0;
-    CUpnpSettings* settings = CUpnpSettings::NewL( KCRUidUPnPStack );
-    settings->Get( CUpnpSettings::KUPnPStackIapId, iap );
-    delete settings;
-    User::LeaveIfError( iap );
-    User::LeaveIfError( iServer.Connect() );
-    
-    iConnectionActive = CUPnPAVConnectionActive::NewL( iServer, *this );
-    iConnectionActive->StartMonitoring();
-    
-    iServer.StartUp( iStatus ); // Start up the AV Control Point and wait
-    // until it has been started. 
-    SetActive();
-    iWait.Start();
-    __LOG1( "ConstructL - iStatus = %d", iStatus.Int() );
-    User::LeaveIfError( iStatus.Int() );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::RunL
-// From CActive
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::RunL()
-    {
-    __LOG( "CUPnPAVControllerActive::RunL" );
-    
-    if( iWait.IsStarted() )
-        {
-        iWait.AsyncStop(); // AV Control Point has been started, continue
-        // Construction
-        return;
-        }    
-    
-    switch( iStatus.Int() )
-        {
-        case EAVControllerDeviceCompleted:
-            {
-            HBufC8* tempBuf = HBufC8::NewLC( iRespBufSize );
-            TPtr8 ptr = tempBuf->Des();
-            if( iServer.GetDevice( ptr ) == KErrNone )
-                {
-                // Create a device and make a callback
-                CUpnpAVDevice* tempDev = CUpnpAVDevice::NewLC(); 
-                RDesReadStream stream( ptr );
-                CleanupClosePushL( stream );
-                stream >> *tempDev;
-                CleanupStack::PopAndDestroy( &stream );
-                
-                if( iDiscovered == EAVDeviceDiscovered )
-                    {
-                    // Discovered a device
-                    iDeviceObserver->UPnPDeviceDiscovered( *tempDev );
-                    }
-                else
-                    {
-                    // Device disappeared
-                    iDeviceObserver->UPnPDeviceDisappeared( *tempDev );
-                    }       
-                CleanupStack::PopAndDestroy( tempDev );
-                
-                // Activate again if needed (it's possible to remove and set
-                // the device obs from the UPnPDeviceDiscovered or
-                // UPnPDeviceDisappeared callbacks  
-                if( !IsActive() )
-                    {
-                    iServer.DeviceRequest( iDiscoveredPkg, iRespBufSizePkg,
-                        iStatus ); 
-                    SetActive();                      
-                    }
-                }
-            else
-                {
-                // Can't handle the error anyhow, just log it
-                __LOG1( "RunL - error: %d", iStatus.Int() );
-                }
-            CleanupStack::PopAndDestroy( tempBuf );
-            }
-            break;
-            
-        default:
-            {
-            __PANICD( __FILE__, __LINE__ );
-            }    
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::DoCancel
-// From CActive
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::DoCancel()
-    {
-    __LOG( "CUPnPAVControllerActive::DoCancel" );
-    if( !iDeviceObserver )
-        {
-        __LOG( "iServer.CancelStartUp()" );
-        // Not a real cancel, but if this is the last session, we'll shut
-        // down the server immidiately
-        iServer.CancelStartUp();
-        }
-    else
-        {
-        iServer.CancelDeviceRequest();
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::RunError
-// From CActive
-// --------------------------------------------------------------------------
-TInt CUPnPAVControllerActive::RunError(
-    TInt aError
-    )
-    {
-    // Can't handle the error anyhow, just log it
-    __LOG1( "CUPnPAVControllerActive::RunError: %d", aError );
-    
-    return KErrNone;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::SetDeviceObserver
-// Sets device observer
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::SetDeviceObserver( 
-    MUPnPAVDeviceObserver& aObserver )
-    {
-    __LOG( "CUPnPAVControllerActive::SetDeviceObserver" );
-    
-    // Set the observer and make an async request to the server to receive
-    // device callbacks
-    __ASSERTD( !iDeviceObserver, __FILE__, __LINE__ );
-    
-    if( iAlive )
-        {
-        iDeviceObserver = &aObserver;
-        
-        iServer.DeviceRequest( iDiscoveredPkg, iRespBufSizePkg, iStatus ); 
-        SetActive();  
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::DeviceObserver
-// Returns device observer
-// --------------------------------------------------------------------------
-MUPnPAVDeviceObserver* CUPnPAVControllerActive::DeviceObserver()
-    {
-    __LOG( "CUPnPAVControllerActive::DeviceObserver" );
-    
-    return iDeviceObserver;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::RemoveDeviceObserver
-// Removes device observer
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::RemoveDeviceObserver()
-    {
-    __LOG( "CUPnPAVControllerActive::RemoveDeviceObserver" );
-    
-    Cancel();
-    
-    iDeviceObserver = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::GetMediaServersL
-// Returns a list of media servers
-// --------------------------------------------------------------------------
-CUpnpAVDeviceList* CUPnPAVControllerActive::GetMediaServersL()
-    {
-    __LOG( "CUPnPAVControllerActive::GetMediaServersL" );
-    
-    if( !iAlive )
-        {
-        User::Leave( KErrDisconnected );
-        }
-    
-    CUpnpAVDeviceList* tempList = NULL;
-    
-    TPckg<TAVControllerDeviceListType> type( EAVMediaServer );
-    
-    TInt respBufSize = 0;           
-    TPckg<TInt> respBufSizePkg( respBufSize );        
-    TInt err = iServer.GetDeviceListSize( type, respBufSizePkg );
-    
-    if( err == KErrNone )
-        {
-        
-        HBufC8* tempBuf = HBufC8::NewLC( respBufSize );
-        TPtr8 ptr = tempBuf->Des();
-
-        err = iServer.GetDeviceList( ptr );
-        if( err == KErrNone )
-            {
-            // Create a device and make a callback
-            tempList = CUpnpAVDeviceList::NewL(); 
-            RDesReadStream stream( ptr );
-            stream >> *tempList;
-            stream.Close();
-            }
-        else
-            {
-            User::Leave( err );
-            }
-        CleanupStack::PopAndDestroy( tempBuf );        
-        }
-    else
-        {
-        User::Leave( err );
-        }
-    return tempList;    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::GetMediaRenderersL
-// Returns a list of media renderes
-// --------------------------------------------------------------------------
-CUpnpAVDeviceList* CUPnPAVControllerActive::GetMediaRenderersL()
-    {
-    __LOG( "CUPnPAVControllerActive::GetMediaRenderersL" );
-    
-    if( !iAlive )
-        {
-        User::Leave( KErrDisconnected );
-        }    
-    
-    CUpnpAVDeviceList* tempList = NULL;
-    
-    TPckg<TAVControllerDeviceListType> type( EAVMediaRenderer );
-    
-    TInt respBufSize = 0;           
-    TPckg<TInt> respBufSizePkg( respBufSize );
-    TInt err = iServer.GetDeviceListSize( type, respBufSizePkg );
-    
-    if( err == KErrNone )
-        {
-        
-        HBufC8* tempBuf = HBufC8::NewLC( respBufSize );
-        TPtr8 ptr = tempBuf->Des();
-
-        err = iServer.GetDeviceList( ptr );
-        if( err == KErrNone )
-            {
-            // Create a device and make a callback
-            tempList = CUpnpAVDeviceList::NewL(); 
-            RDesReadStream stream( ptr );
-            stream >> *tempList;
-            stream.Close();
-            }
-        else
-            {
-            User::Leave( err );
-            }
-        CleanupStack::PopAndDestroy( tempBuf );        
-        }
-    else
-        {
-        User::Leave( err );
-        }
-    return tempList;    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::StartBrowsingSessionL
-// Starts a browsing session
-// --------------------------------------------------------------------------
-MUPnPAVBrowsingSession& CUPnPAVControllerActive::StartBrowsingSessionL(
-    const CUpnpAVDevice& aDevice )
-    {
-    __LOG( "CUPnPAVControllerActive::StartBrowsingSessionL" );
-   
-    if( !iAlive )
-        {
-        User::Leave( KErrDisconnected );
-        }
-    
-    if( aDevice.DeviceType() != CUpnpAVDevice::EMediaServer )
-        {
-        User::Leave( KErrNotSupported );
-        }
-    CUPnPAVBrowsingSessionImpl* sessionImpl =
-        CUPnPAVBrowsingSessionImpl::NewL( iServer, aDevice );
-    iBrowsingSessions.AppendL( sessionImpl );
-    return *sessionImpl;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::StopBrowsingSession
-// Stops a browsing session
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::StopBrowsingSession(
-    MUPnPAVBrowsingSession& aSession )
-    {
-    __LOG( "CUPnPAVControllerActive::StopBrowsingSession" );
-    
-    CUPnPAVBrowsingSessionImpl* sessionImpl = 
-        static_cast<CUPnPAVBrowsingSessionImpl*>(&aSession);
-    TInt count = iBrowsingSessions.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ] == sessionImpl )
-            {
-            delete iBrowsingSessions[ i ];
-            iBrowsingSessions[ i ] = NULL;
-            i = count;
-            }
-        }
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::StartRenderingSessionL
-// Starts a rendering session
-// --------------------------------------------------------------------------
-MUPnPAVRenderingSession& CUPnPAVControllerActive::StartRenderingSessionL(
-    const CUpnpAVDevice& aDevice )
-    {
-    __LOG( "CUPnPAVControllerActive::StartRenderingSessionL" );
-    
-    if( !iAlive )
-        {
-        User::Leave( KErrDisconnected );
-        }
-    
-    if( aDevice.DeviceType() != CUpnpAVDevice::EMediaRenderer )
-        {
-        User::Leave( KErrNotSupported );
-        }
-    CUPnPAVRenderingSessionImpl* sessionImpl =
-        CUPnPAVRenderingSessionImpl::NewL( iServer, aDevice );
-    iRenderingSessions.AppendL( sessionImpl );
-    return *sessionImpl;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::StopRenderingSession
-// Stops a rendering session
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::StopRenderingSession(
-    MUPnPAVRenderingSession& aSession )
-    {
-    __LOG( "CUPnPAVControllerActive::StopRenderingSession" );
-    
-    CUPnPAVRenderingSessionImpl* sessionImpl =
-        static_cast<CUPnPAVRenderingSessionImpl*>(&aSession);
-    TInt count = iRenderingSessions.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iRenderingSessions[ i ] == sessionImpl )
-            {
-            delete iRenderingSessions[ i ];
-            iRenderingSessions[ i ] = NULL; 
-            i = count;
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::StartUploadSessionL
-// Starts an upload session
-// --------------------------------------------------------------------------
-MUPnPFileUploadSession& CUPnPAVControllerActive::StartUploadSessionL(
-    const CUpnpAVDevice& aDevice )
-    {
-    __LOG( "CUPnPAVControllerActive::StartUploadSessionL" );
-   
-    if( !iAlive )
-        {
-        User::Leave( KErrDisconnected );
-        }
-    
-    if( aDevice.DeviceType() != CUpnpAVDevice::EMediaServer )
-        {
-        User::Leave( KErrNotSupported );
-        }
-    CUPnPFileUploadSessionImpl* sessionImpl =
-        CUPnPFileUploadSessionImpl::NewL( iServer, aDevice );
-    iUploadSessions.AppendL( sessionImpl );
-    return *sessionImpl;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::StopUploadSession
-// Stops an upload session
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::StopUploadSession(
-    MUPnPFileUploadSession& aSession )
-    {
-    __LOG( "CUPnPAVControllerActive::StopUploadSession" );
-  
-    CUPnPFileUploadSessionImpl* sessionImpl =
-        static_cast<CUPnPFileUploadSessionImpl*>(&aSession);
-    TInt count = iUploadSessions.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iUploadSessions[ i ] == sessionImpl )
-            {
-            delete iUploadSessions[ i ];
-            iUploadSessions[ i ] = NULL; 
-            i = count;
-            }
-        }
-
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::StartDownloadSessionL
-// Starts a download session
-// --------------------------------------------------------------------------
-MUPnPFileDownloadSession& CUPnPAVControllerActive::StartDownloadSessionL(
-    const CUpnpAVDevice& aDevice )
-    {
-    __LOG( "CUPnPAVControllerActive::StartDownloadSessionL" );
-
-    if( !iAlive )
-        {
-        User::Leave( KErrDisconnected );
-        }
-    
-    if( aDevice.DeviceType() != CUpnpAVDevice::EMediaServer )
-        {
-        User::Leave( KErrNotSupported );
-        }
-    CUPnPFileDownloadSessionImpl* sessionImpl =
-        CUPnPFileDownloadSessionImpl::NewL( iServer, aDevice );
-    iDownloadSessions.AppendL( sessionImpl );
-    return *sessionImpl;
-    }   
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::StopDownloadSession
-// Stops a download session
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::StopDownloadSession(
-    MUPnPFileDownloadSession& aSession )
-    {
-    __LOG( "CUPnPAVControllerActive::StopDownloadSession" );
-
-    CUPnPFileDownloadSessionImpl* sessionImpl =
-        static_cast<CUPnPFileDownloadSessionImpl*>(&aSession);
-    TInt count = iDownloadSessions.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ] == sessionImpl )
-            {
-            delete iDownloadSessions[ i ];
-            //iRenderingSessions.Remove( i );
-            iDownloadSessions[ i ] = NULL; 
-            i = count;
-            }
-        }
-
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerActive::ConnectionLost
-// Wlan disconnected
-// --------------------------------------------------------------------------
-void CUPnPAVControllerActive::ConnectionLost()
-    {
-    __LOG( "CUPnPAVControllerActive::ConnectionLost" );
-    
-    iAlive = EFalse;
-    
-    iReleaseState = EStateWLANLost;
-    
-    TInt count = iRenderingSessions.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iRenderingSessions.Count() && iRenderingSessions[ i ] )
-            {
-            iRenderingSessions[ i ]->WLANConnectionLost();    
-            }   
-        }       
-
-    count = iBrowsingSessions.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions.Count() && iBrowsingSessions[ i ] )
-            {
-            iBrowsingSessions[ i ]->WLANConnectionLost();    
-            }
-        }
-
-    count = iUploadSessions.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iUploadSessions.Count() && iUploadSessions[ i ] )
-            {
-            iUploadSessions[ i ]->WLANConnectionLost();    
-            }   
-        }       
-
-    count = iDownloadSessions.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions.Count() && iDownloadSessions[ i ] )
-            {
-            iDownloadSessions[ i ]->WLANConnectionLost();    
-            }   
-        }       
-
-    if( iDeviceObserver )
-        {
-        iDeviceObserver->WLANConnectionLost();
-        }
-        
-    if( iReleaseState == EStateWaitingForRelease )
-        {
-        __LOG( "ConnectionLost - release" );
-        delete this;
-        }
-        
-    iReleaseState = EStateReleasable;       
-    }
-// end of file
+/*
+* Copyright (c) 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:      AO that monitors for device events
+*
+*/
+
+
+
+
+
+
+// INCLUDES
+// upnp stack api
+#include <upnpsettings.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavdevice.h"
+#include "upnpavdeviceobserver.h"
+#include "upnpavdevicelist.h"
+
+// dlnasrv / avcontroller internal
+#include "upnpavcontrolleractive.h"
+#include "upnpavrenderingsessionimpl.h"
+#include "upnpavbrowsingsessionimpl.h"
+#include "upnpavconnectionactive.h"
+#include "upnpfileuploadsessionimpl.h"
+#include "upnpfiledownloadsessionimpl.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
+#include "upnplog.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::NewL
+// Two-phase construct
+// --------------------------------------------------------------------------
+CUPnPAVControllerActive* CUPnPAVControllerActive::NewL()
+    {
+    CUPnPAVControllerActive* self = CUPnPAVControllerActive::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::NewLC
+// Two-phase construct
+// --------------------------------------------------------------------------
+CUPnPAVControllerActive* CUPnPAVControllerActive::NewLC()
+    {
+    CUPnPAVControllerActive* self = new (ELeave) CUPnPAVControllerActive;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::CUPnPAVControllerActive
+// Two-phase construct
+// --------------------------------------------------------------------------
+CUPnPAVControllerActive::CUPnPAVControllerActive() :
+    CActive( EPriorityStandard ),
+    iRespBufSizePkg( iRespBufSize ),
+    iDiscoveredPkg( iDiscovered ),
+    iAlive( ETrue ),
+    iReleaseState( EStateReleasable )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::Release
+// Destructor
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::Release()
+    {
+    __LOG( "CUPnPAVControllerActive::Release" );
+    
+    if( iReleaseState == EStateReleasable )
+        {
+        __LOG( "Release - ok to delete" );
+        delete this;
+        }
+    else if( iReleaseState == EStateWLANLost )
+        {
+        __LOG( "Release - waiting for release" );
+        // Still sending WLAN lost messages, cannot delete
+        // To be released
+        iReleaseState = EStateWaitingForRelease;
+        }
+    else
+        {
+        __LOG( "Release - do nothing, double release" );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::~CUPnPAVControllerActive
+// Destructor
+// --------------------------------------------------------------------------
+CUPnPAVControllerActive::~CUPnPAVControllerActive()
+    {
+    __LOG( "CUPnPAVControllerActive::~CUPnPAVControllerActive" );
+    Cancel();
+    delete iConnectionActive;
+    iBrowsingSessions.ResetAndDestroy();
+    iRenderingSessions.ResetAndDestroy();
+    iDownloadSessions.ResetAndDestroy();
+    iUploadSessions.ResetAndDestroy();
+
+    iServer.Close();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::ConstructL
+// Two-phase construct
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::ConstructL()
+    {
+    __LOG( "CUPnPAVControllerActive::ConstructL" );
+    
+    // Check the aip
+    TInt iap = 0;
+    CUpnpSettings* settings = CUpnpSettings::NewL( KCRUidUPnPStack );
+    settings->Get( CUpnpSettings::KUPnPStackIapId, iap );
+    delete settings;
+    User::LeaveIfError( iap );
+    User::LeaveIfError( iServer.Connect() );
+    
+    iConnectionActive = CUPnPAVConnectionActive::NewL( iServer, *this );
+    iConnectionActive->StartMonitoring();
+
+    // Startup AV control point
+    User::LeaveIfError( iServer.StartUp() );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::RunL
+// From CActive
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::RunL()
+    {
+    __LOG( "CUPnPAVControllerActive::RunL" );
+    
+    switch( iStatus.Int() )
+        {
+        case EAVControllerDeviceCompleted:
+            {
+            HBufC8* tempBuf = HBufC8::NewLC( iRespBufSize );
+            TPtr8 ptr = tempBuf->Des();
+            if( iServer.GetDevice( ptr ) == KErrNone )
+                {
+                // Create a device and make a callback
+                CUpnpAVDevice* tempDev = CUpnpAVDevice::NewLC(); 
+                RDesReadStream stream( ptr );
+                CleanupClosePushL( stream );
+                stream >> *tempDev;
+                CleanupStack::PopAndDestroy( &stream );
+                
+                if( iDiscovered == EAVDeviceDiscovered )
+                    {
+                    // Discovered a device
+                    iDeviceObserver->UPnPDeviceDiscovered( *tempDev );
+                    }
+                else if ( iDiscovered == EAVDeviceIconDownloaded )
+                    {
+                    // Device icon download completed
+                    iDeviceObserver->UPnPDeviceIconDownloaded( *tempDev );
+                    }
+                else
+                    {
+                    // Device disappeared
+                    iDeviceObserver->UPnPDeviceDisappeared( *tempDev );
+                    }       
+                CleanupStack::PopAndDestroy( tempDev );
+                
+                // Activate again if needed (it's possible to remove and set
+                // the device obs from the UPnPDeviceDiscovered or
+                // UPnPDeviceDisappeared callbacks  
+                if( iDeviceObserver )
+                    {
+                    iServer.DeviceRequest( iDiscoveredPkg, iRespBufSizePkg,
+                        iStatus ); 
+                    SetActive();                      
+                    }
+                }
+            else
+                {
+                // Can't handle the error anyhow, just log it
+                __LOG1( "RunL - error: %d", iStatus.Int() );
+                }
+            CleanupStack::PopAndDestroy( tempBuf );
+            }
+            break;
+            
+        case KErrServerTerminated:
+            {
+            __LOG( "RunL - ServerTerminated" );
+            }
+            break;
+            
+        default:
+            {
+            __PANICD( __FILE__, __LINE__ );
+            }    
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::DoCancel
+// From CActive
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::DoCancel()
+    {
+    __LOG( "CUPnPAVControllerActive::DoCancel" );
+    if( !iDeviceObserver )
+        {
+        __LOG( "iServer.CancelStartUp()" );
+        // Not a real cancel, but if this is the last session, we'll shut
+        // down the server immidiately
+        iServer.CancelStartUp();
+        }
+    else
+        {
+        iServer.CancelDeviceRequest();
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::RunError
+// From CActive
+// --------------------------------------------------------------------------
+TInt CUPnPAVControllerActive::RunError(
+    TInt aError
+    )
+    {
+    // Can't handle the error anyhow, just log it
+    __LOG1( "CUPnPAVControllerActive::RunError: %d", aError );
+    
+    return KErrNone;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::SetDeviceObserver
+// Sets device observer
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::SetDeviceObserver( 
+    MUPnPAVDeviceObserver& aObserver )
+    {
+    __LOG( "CUPnPAVControllerActive::SetDeviceObserver" );
+    
+    // Set the observer and make an async request to the server to receive
+    // device callbacks
+    __ASSERTD( !iDeviceObserver, __FILE__, __LINE__ );
+    
+    if( iAlive )
+        {
+        iDeviceObserver = &aObserver;
+        
+        iServer.DeviceRequest( iDiscoveredPkg, iRespBufSizePkg, iStatus ); 
+        SetActive();  
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::DeviceObserver
+// Returns device observer
+// --------------------------------------------------------------------------
+MUPnPAVDeviceObserver* CUPnPAVControllerActive::DeviceObserver()
+    {
+    __LOG( "CUPnPAVControllerActive::DeviceObserver" );
+    
+    return iDeviceObserver;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::RemoveDeviceObserver
+// Removes device observer
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::RemoveDeviceObserver()
+    {
+    __LOG( "CUPnPAVControllerActive::RemoveDeviceObserver" );
+    
+    Cancel();
+    
+    iDeviceObserver = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::GetMediaServersL
+// Returns a list of media servers
+// --------------------------------------------------------------------------
+CUpnpAVDeviceList* CUPnPAVControllerActive::GetMediaServersL()
+    {
+    __LOG( "CUPnPAVControllerActive::GetMediaServersL" );
+    
+    if( !iAlive )
+        {
+        User::Leave( KErrDisconnected );
+        }
+    
+    CUpnpAVDeviceList* tempList = NULL;
+    
+    TPckgBuf<TAVControllerDeviceListType> type( EAVMediaServer );
+    
+    TInt respBufSize = 0;           
+    TPckg<TInt> respBufSizePkg( respBufSize );        
+    TInt err = iServer.GetDeviceListSize( type, respBufSizePkg );
+    
+    if( err == KErrNone )
+        {
+        
+        HBufC8* tempBuf = HBufC8::NewLC( respBufSize );
+        TPtr8 ptr = tempBuf->Des();
+
+        err = iServer.GetDeviceList( ptr );
+        if( err == KErrNone )
+            {
+            // Create a device and make a callback
+            tempList = CUpnpAVDeviceList::NewL(); 
+            RDesReadStream stream( ptr );
+            stream >> *tempList;
+            stream.Close();
+            }
+        else
+            {
+            User::Leave( err );
+            }
+        CleanupStack::PopAndDestroy( tempBuf );        
+        }
+    else
+        {
+        User::Leave( err );
+        }
+    return tempList;    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::GetMediaRenderersL
+// Returns a list of media renderes
+// --------------------------------------------------------------------------
+CUpnpAVDeviceList* CUPnPAVControllerActive::GetMediaRenderersL()
+    {
+    __LOG( "CUPnPAVControllerActive::GetMediaRenderersL" );
+    
+    if( !iAlive )
+        {
+        User::Leave( KErrDisconnected );
+        }    
+    
+    CUpnpAVDeviceList* tempList = NULL;
+    
+    TPckg<TAVControllerDeviceListType> type( EAVMediaRenderer );
+    
+    TInt respBufSize = 0;           
+    TPckg<TInt> respBufSizePkg( respBufSize );
+    TInt err = iServer.GetDeviceListSize( type, respBufSizePkg );
+    
+    if( err == KErrNone )
+        {
+        
+        HBufC8* tempBuf = HBufC8::NewLC( respBufSize );
+        TPtr8 ptr = tempBuf->Des();
+
+        err = iServer.GetDeviceList( ptr );
+        if( err == KErrNone )
+            {
+            // Create a device and make a callback
+            tempList = CUpnpAVDeviceList::NewL(); 
+            RDesReadStream stream( ptr );
+            stream >> *tempList;
+            stream.Close();
+            }
+        else
+            {
+            User::Leave( err );
+            }
+        CleanupStack::PopAndDestroy( tempBuf );        
+        }
+    else
+        {
+        User::Leave( err );
+        }
+    return tempList;    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::StartBrowsingSessionL
+// Starts a browsing session
+// --------------------------------------------------------------------------
+MUPnPAVBrowsingSession& CUPnPAVControllerActive::StartBrowsingSessionL(
+    const CUpnpAVDevice& aDevice )
+    {
+    __LOG( "CUPnPAVControllerActive::StartBrowsingSessionL" );
+   
+    if( !iAlive )
+        {
+        User::Leave( KErrDisconnected );
+        }
+    
+    if( aDevice.DeviceType() != CUpnpAVDevice::EMediaServer )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    CUPnPAVBrowsingSessionImpl* sessionImpl =
+        CUPnPAVBrowsingSessionImpl::NewL( iServer, aDevice );
+    iBrowsingSessions.Append( sessionImpl );
+    return *sessionImpl;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::StopBrowsingSession
+// Stops a browsing session
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::StopBrowsingSession(
+    MUPnPAVBrowsingSession& aSession )
+    {
+    __LOG( "CUPnPAVControllerActive::StopBrowsingSession" );
+    
+    CUPnPAVBrowsingSessionImpl* sessionImpl = 
+        static_cast<CUPnPAVBrowsingSessionImpl*>(&aSession);
+    TInt count = iBrowsingSessions.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ] == sessionImpl )
+            {
+            delete iBrowsingSessions[ i ];
+            iBrowsingSessions[ i ] = NULL;
+            i = count;
+            }
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::StartRenderingSessionL
+// Starts a rendering session
+// --------------------------------------------------------------------------
+MUPnPAVRenderingSession& CUPnPAVControllerActive::StartRenderingSessionL(
+    const CUpnpAVDevice& aDevice )
+    {
+    __LOG( "CUPnPAVControllerActive::StartRenderingSessionL" );
+    
+    if( !iAlive )
+        {
+        User::Leave( KErrDisconnected );
+        }
+    
+    if( aDevice.DeviceType() != CUpnpAVDevice::EMediaRenderer )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    CUPnPAVRenderingSessionImpl* sessionImpl =
+        CUPnPAVRenderingSessionImpl::NewL( iServer, aDevice );
+    iRenderingSessions.Append( sessionImpl );
+    return *sessionImpl;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::StopRenderingSession
+// Stops a rendering session
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::StopRenderingSession(
+    MUPnPAVRenderingSession& aSession )
+    {
+    __LOG( "CUPnPAVControllerActive::StopRenderingSession" );
+    
+    CUPnPAVRenderingSessionImpl* sessionImpl =
+        static_cast<CUPnPAVRenderingSessionImpl*>(&aSession);
+    TInt count = iRenderingSessions.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iRenderingSessions[ i ] == sessionImpl )
+            {
+            delete iRenderingSessions[ i ];
+            iRenderingSessions[ i ] = NULL; 
+            i = count;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::StartUploadSessionL
+// Starts an upload session
+// --------------------------------------------------------------------------
+MUPnPFileUploadSession& CUPnPAVControllerActive::StartUploadSessionL(
+    const CUpnpAVDevice& aDevice )
+    {
+    __LOG( "CUPnPAVControllerActive::StartUploadSessionL" );
+   
+    if( !iAlive )
+        {
+        User::Leave( KErrDisconnected );
+        }
+    
+    if( aDevice.DeviceType() != CUpnpAVDevice::EMediaServer )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    CUPnPFileUploadSessionImpl* sessionImpl =
+        CUPnPFileUploadSessionImpl::NewL( iServer, aDevice );
+    iUploadSessions.Append( sessionImpl );
+    return *sessionImpl;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::StopUploadSession
+// Stops an upload session
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::StopUploadSession(
+    MUPnPFileUploadSession& aSession )
+    {
+    __LOG( "CUPnPAVControllerActive::StopUploadSession" );
+  
+    CUPnPFileUploadSessionImpl* sessionImpl =
+        static_cast<CUPnPFileUploadSessionImpl*>(&aSession);
+    TInt count = iUploadSessions.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iUploadSessions[ i ] == sessionImpl )
+            {
+            delete iUploadSessions[ i ];
+            iUploadSessions[ i ] = NULL; 
+            i = count;
+            }
+        }
+
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::StartDownloadSessionL
+// Starts a download session
+// --------------------------------------------------------------------------
+MUPnPFileDownloadSession& CUPnPAVControllerActive::StartDownloadSessionL(
+    const CUpnpAVDevice& aDevice )
+    {
+    __LOG( "CUPnPAVControllerActive::StartDownloadSessionL" );
+
+    if( !iAlive )
+        {
+        User::Leave( KErrDisconnected );
+        }
+    
+    if( aDevice.DeviceType() != CUpnpAVDevice::EMediaServer )
+        {
+        User::Leave( KErrNotSupported );
+        }
+    CUPnPFileDownloadSessionImpl* sessionImpl =
+        CUPnPFileDownloadSessionImpl::NewL( iServer, aDevice );
+    iDownloadSessions.Append( sessionImpl );
+    return *sessionImpl;
+    }   
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::StopDownloadSession
+// Stops a download session
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::StopDownloadSession(
+    MUPnPFileDownloadSession& aSession )
+    {
+    __LOG( "CUPnPAVControllerActive::StopDownloadSession" );
+
+    CUPnPFileDownloadSessionImpl* sessionImpl =
+        static_cast<CUPnPFileDownloadSessionImpl*>(&aSession);
+    TInt count = iDownloadSessions.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ] == sessionImpl )
+            {
+            delete iDownloadSessions[ i ];
+            //iRenderingSessions.Remove( i );
+            iDownloadSessions[ i ] = NULL; 
+            i = count;
+            }
+        }
+
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::GetDeviceIconL
+// --------------------------------------------------------------------------
+HBufC8* CUPnPAVControllerActive::GetDeviceIconL( const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPAVControllerActive::GetDeviceIconL" );
+
+    RFile file;
+    CleanupClosePushL( file );
+    User::LeaveIfError( iServer.GetDeviceIcon( aUuid, file ) );
+    TInt fileSize( 0 );
+    User::LeaveIfError( file.Size( fileSize ) );
+    HBufC8* ret = HBufC8::NewLC( fileSize );
+    TPtr8 ptr( ret->Des() );
+    User::LeaveIfError( file.Read( ptr ) );
+    CleanupStack::Pop( ret );
+    CleanupStack::PopAndDestroy( &file );
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerActive::ConnectionLost
+// Wlan disconnected
+// --------------------------------------------------------------------------
+void CUPnPAVControllerActive::ConnectionLost( TBool /*aUserOriented*/ )
+    {
+    __LOG( "CUPnPAVControllerActive::ConnectionLost" );
+    
+    iAlive = EFalse;
+    
+    iReleaseState = EStateWLANLost;
+    
+    TInt count = iRenderingSessions.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iRenderingSessions.Count() && iRenderingSessions[ i ] )
+            {
+            iRenderingSessions[ i ]->WLANConnectionLost();    
+            }   
+        }       
+
+    count = iBrowsingSessions.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions.Count() && iBrowsingSessions[ i ] )
+            {
+            iBrowsingSessions[ i ]->WLANConnectionLost();    
+            }
+        }
+
+    count = iUploadSessions.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iUploadSessions.Count() && iUploadSessions[ i ] )
+            {
+            iUploadSessions[ i ]->WLANConnectionLost();    
+            }   
+        }       
+
+    count = iDownloadSessions.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions.Count() && iDownloadSessions[ i ] )
+            {
+            iDownloadSessions[ i ]->WLANConnectionLost();    
+            }   
+        }       
+
+    if( iDeviceObserver )
+        {
+        iDeviceObserver->WLANConnectionLost();
+        }
+        
+    if( iReleaseState == EStateWaitingForRelease )
+        {
+        __LOG( "ConnectionLost - release" );
+        delete this;
+        }
+        
+    iReleaseState = EStateReleasable;       
+    }
+// end of file
--- a/upnpavcontroller/upnpavcontrollerclient/src/upnpavcontrollerclient.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/src/upnpavcontrollerclient.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,897 +1,909 @@
-/*
-* Copyright (c) 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:      AV Controller client
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// Sysatem
-#include <e32math.h>
-#include <s32mem.h>
-#include <f32file.h>
-
-// upnpframework / avcontroller api
-#include "upnpavcontrollerglobals.h"
-
-// avcontroller internal
-#include "upnpavcontrollerclient.h"
-
-// Number of message slots to reserve for this client server session.
-const TInt KDefaultMessageSlots = -1;
-
-
-// Function prototypes
-static TInt StartServer( void );
-static TInt CreateServerProcess( void ); 
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::RUPnPAVControllerClient
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// --------------------------------------------------------------------------
-RUPnPAVControllerClient::RUPnPAVControllerClient()
-    :RSessionBase() 
-    {
-    // No implementation required
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::Connect
-// Connect to Media Server session. 
-// exist
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::Connect()
-    {
-    TInt error = ::StartServer();
-
-    if ( KErrNone == error )
-        {
-        error = CreateSession( KAVControllerName,
-                               Version(),
-                               KDefaultMessageSlots );
-        }
-    return error;
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::Version
-// Version information.
-// --------------------------------------------------------------------------
-TVersion RUPnPAVControllerClient::Version() const
-    {
-    return TVersion( KAVControllerMajorVersionNumber,
-                     KAVControllerMinorVersionNumber,
-                     KAVControllerBuildVersionNumber );
-    }
-
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::StartUp
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::StartUp( TRequestStatus& aStatus )
-    {
-    TIpcArgs args( TIpcArgs::ENothing );
-    SendReceive( EAVControllerStartupRequest, args, aStatus );    
-    }
-
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelStartUp
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelStartUp()
-    {
-    TIpcArgs args( TIpcArgs::ENothing );
-    return SendReceive( EAVControllerCancelStartupRequest, args );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::DeviceRequest
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::DeviceRequest( TDes8& aDiscovered,
-    TDes8& aRcvdBufSize, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( &aDiscovered, &aRcvdBufSize );
-    SendReceive( EAVControllerDeviceRequest, args, aStatus );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelDeviceRequest
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelDeviceRequest()
-    {
-    TIpcArgs args( TIpcArgs::ENothing );
-    return SendReceive( EAVControllerCancelDeviceRequest, args );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::GetDevice
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::GetDevice( TDes8& aDevice )
-    {
-    TIpcArgs args( &aDevice );
-    return SendReceive( EAVControllerGetDeviceRequest, args );
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::GetDeviceListSize
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::GetDeviceListSize( TDes8& aType, TDes8& aSize )
-    {
-    TIpcArgs args( &aType, &aSize );
-    return SendReceive( EAVControllerGetDeviceListSizeRequest, args );
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::GetDeviceList
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::GetDeviceList( TDes8& aList )
-    {
-    TIpcArgs args( &aList );
-    return SendReceive( EAVControllerGetDeviceListRequest, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::ReleaseMediaServer
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::ReleaseMediaServer( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerStopMediaServer, args );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::ReserveMediaServer
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::ReserveMediaServer( TInt aId,
-    TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId );
-    SendReceive( EAVControllerStartMediaServer, args, aStatus );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelReserveMediaServer
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelReserveMediaServer( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelStartMediaServer, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CreateRenderingSession
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CreateRenderingSession( TInt aId,
-    TDes8& aUuid )
-    {
-    TIpcArgs args( aId, &aUuid );
-    return SendReceive( EAVControllerCreateRenderingSession, args );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::DestroyRenderingSession
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::DestroyRenderingSession( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerDestroyRenderingSession, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::EventRequest
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::EventRequest( TDes8& aEvent, TInt aId,
-    TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aEvent );
-    SendReceive( EAVControllerEventRequest, args, aStatus );   
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelEventRequest
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelEventRequest( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelEventRequest, args );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::SetURI
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::SetURI( TInt aId, TDes8& aRequest,
-    TDes8& aItem, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aRequest, &aItem );
-    
-    SendReceive( EAVControllerSetURI, args, aStatus );   
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelSetURI
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelSetURI( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelSetURI, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::SetNextURI
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::SetNextURI( TInt aId, TDes8& aRequest,
-    TDes8& aItem, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aRequest, &aItem );
-    
-    SendReceive( EAVControllerSetNextURI, args, aStatus );       
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelSetNextURI
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelSetNextURI( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelSetNextURI, args );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::Play
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::Play( TInt aId, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId );
-    
-    SendReceive( EAVControllerPlay, args, aStatus );       
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelPlay
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelPlay( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelPlay, args );
-    }
-      
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::Stop
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::Stop( TInt aId, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId );
-    SendReceive( EAVControllerStop, args, aStatus ); 
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelStop
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelStop( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelStop, args ); 
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::Pause
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::Pause( TInt aId, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId );
-    SendReceive( EAVControllerPause, args, aStatus ); 
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelPause
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelPause( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelPause, args );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::SetVolume
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::SetVolume( TInt aId, TInt aVolumeLevel,
-    TDes8& aRetVolume, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, aVolumeLevel, &aRetVolume );
-    SendReceive( EAVControllerSetVolume, args, aStatus );      
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelSetVolume
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelSetVolume( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelSetVolume, args );        
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::GetVolume
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::GetVolume( TInt aId, TDes8& aVolumeLevel,
-    TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aVolumeLevel );
-    SendReceive( EAVControllerGetVolume, args, aStatus );     
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelGetVolume
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelGetVolume( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelGetVolume, args );        
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::SetMute
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::SetMute( TInt aId, TBool aMute,
-    TDes8& aRetMute, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, (TInt)aMute, &aRetMute );
-    SendReceive( EAVControllerSetMute, args, aStatus );        
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::GetMute
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::GetMute( TInt aId, TDes8& aMute,
-    TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aMute );
-    SendReceive( EAVControllerGetMute, args, aStatus );     
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelSetMute
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelSetMute( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelSetMute, args );        
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelGetMute
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelGetMute( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelGetMute, args );        
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::GetPositionInfo
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::GetPositionInfo( TInt aId, TDes8& aPosition,
-    TDes8& aLength, TRequestStatus& aStatus )    
-    {
-    TIpcArgs args( aId, &aPosition, &aLength );
-    SendReceive( EAVControllerGetPositionInfo, args, aStatus );     
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelGetPositionInfo
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelGetPositionInfo( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelGetPositionInfo, args ); 
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CreateBrowsingSession
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CreateBrowsingSession( TInt aId, TDes8& aUuid )
-    {
-    TIpcArgs args( aId, &aUuid );
-    return SendReceive( EAVControllerCreateBrowsingSession, args ); 
-    }
-
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::DestroyBrowsingSession
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::DestroyBrowsingSession( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerDestroyBrowsingSession, args );     
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::BrowseResponseSize
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::BrowseResponseSize( TInt aId, TDes8& aRequest,
-    TDes8& aParams, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aRequest, &aParams );
-    SendReceive( EAVControllerGetBrowseResponseSize, args, aStatus );         
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelBrowseResponseSize
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelBrowseResponseSize( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelGetBrowseResponseSize, args );     
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::BrowseResponse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::BrowseResponse( TInt aId,
-    TDes8& aBrowseResponse, TDes8& aUpdateId)
-    {
-    TIpcArgs args( aId, &aBrowseResponse, &aUpdateId );
-    return SendReceive( EAVControllerGetBrowseResponse, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::SearchResponseSize
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::SearchResponseSize( TInt aId, TDes8& aRequest,
-    TDes8& aParams, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aRequest, &aParams );
-    SendReceive( EAVControllerGetSearchResponseSize, args, aStatus );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelSearchResponseSize
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelSearchResponseSize( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelGetSearchResponseSize, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::SearchResponse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::SearchResponse( TInt aId,
-    TDes8& aSearchResponse, TDes8& aUpdateId )
-    {
-    TIpcArgs args( aId, &aSearchResponse,& aUpdateId );
-    return SendReceive( EAVControllerGetSearchResponse, args );             
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::GetSearchCapabilitiesSize
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::GetSearchCapabilitiesSize( TInt aId,
-    TDes8& aSize, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aSize );
-    SendReceive( EAVControllerGetSearchCapabilitiesSize, args, aStatus );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelGetSearchCapabilitiesSize
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelGetSearchCapabilitiesSize( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelGetSearchCapabilitiesSize,
-        args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::SearchCapabilitiesResponse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::SearchCapabilitiesResponse( TInt aId,
-    TDes8& aCapabilitiesResponse )
-    {
-    TIpcArgs args( aId, &aCapabilitiesResponse );
-    return SendReceive( EAVControllerGetSearchCapabilities, args );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CreateContainer
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::CreateContainer( TInt aId, TDes8& aTitle,
-    TDes8& aParentId, TInt aContainerType, TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aTitle, &aParentId, aContainerType );
-    SendReceive( EAVControllerCreateContainer, args, aStatus );        
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelCreateContainer
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelCreateContainer( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelCreateContainer, args );        
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::DeleteObject
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::DeleteObject( TInt aId, TDes8& aObjectId,
-    TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aObjectId );
-    SendReceive( EAVControllerDeleteObject, args, aStatus );        
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelDeleteObject
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelDeleteObject( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelDeleteObject, args );        
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::DeviceDisappearedRequest
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::DeviceDisappearedRequest( TInt aId,
-    TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId );
-    SendReceive( EAVControllerDeviceDisappearedRequest, args, aStatus );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelDeviceDisappearedRequest
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelDeviceDisappearedRequest( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelDeviceDisappearedRequest, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MonitorConnection
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::MonitorConnection( TRequestStatus& aStatus )
-    {
-    TIpcArgs args( TIpcArgs::ENothing );
-    SendReceive( EAVControllerMonitorConnection, args, aStatus );        
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CancelMonitorConnection
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelMonitorConnection()
-    {
-    TIpcArgs args( TIpcArgs::ENothing );
-    return SendReceive( EAVControllerCancelMonitorConnection, args );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::MSServicesInUse( TDes8& aInUse )
-    {
-    TIpcArgs args( &aInUse );
-    return SendReceive( EAVControllerMSServicesInUse, args ); 
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CreateDownloadSession
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CreateDownloadSession( TInt aId, TDes8& aUuid )
-    {
-    TIpcArgs args( aId, &aUuid );
-    return SendReceive( EAVControllerCreateDownloadSession, args );        
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::DestroyDownloadSession
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::DestroyDownloadSession( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerDestroyDownloadSession, args );    
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::CreateUploadSession
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CreateUploadSession( TInt aId, TDes8& aUuid )
-    {
-    TIpcArgs args( aId, &aUuid );
-    return SendReceive( EAVControllerCreateUploadSession, args );            
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::DestroyUploadSession( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerDestroyUploadSession, args );        
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::StartDownload( TInt aId,
-    TDes8& aFileTransferItem )
-    {
-    TIpcArgs args( aId, &aFileTransferItem );
-    return SendReceive( EAVControllerStartDownload, args );    
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::StartDownload( TInt aId,
-    TDes8& aFileTransferItem, const RFile& aFile )
-    {
-    TIpcArgs args( aId, &aFileTransferItem );
-    aFile.TransferToServer( args, 2, 3 );
-    return SendReceive( EAVControllerStartDownloadFH, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::GetDownloadEvent( TInt aId, TDes8& aEvent,
-    TRequestStatus& aStatus, TDes& aBuffer )
-    {
-    TIpcArgs args( aId, &aEvent, &aBuffer );
-    SendReceive( EAVControllerGetDownloadEvent, args, aStatus );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelDownloadEvent( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelDownloadEvent, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::StartTrackingDownloadProgress( TInt aId,
-    TInt aKey )
-    {
-    TIpcArgs args( aId, aKey );
-    return SendReceive( EAVControllerStartTrackingDownloadProgress, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelDownload( TInt aId, TInt aKey )
-    {
-    TIpcArgs args( aId, aKey );
-    return SendReceive( EAVControllerCancelDownload, args );    
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelAllDownloads( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelAllDownloads, args );
-    }
-
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::StartUpload( TInt aId, TDes8& aFileTransferItem )
-    {
-    TIpcArgs args( aId, &aFileTransferItem );
-    return SendReceive( EAVControllerStartUpload, args );    
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-void RUPnPAVControllerClient::GetUploadEvent( TInt aId, TDes8& aEvent,
-        TRequestStatus& aStatus )
-    {
-    TIpcArgs args( aId, &aEvent );
-    SendReceive( EAVControllerGetUploadEvent, args, aStatus );    
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelUploadEvent( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelUploadEvent, args );    
-    }
-        
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::StartTrackingUploadProgress( TInt aId, TInt aKey )
-    {
-    TIpcArgs args( aId, aKey );
-    return SendReceive( EAVControllerStartTrackingUploadProgress, args );    
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelUpload( TInt aId, TInt aKey )
-    {
-    TIpcArgs args( aId, aKey );
-    return SendReceive( EAVControllerCancelUpload, args );        
-    }
-    
-// --------------------------------------------------------------------------
-// RUPnPAVControllerClient::MSServicesInUse
-// See upnpavcontrollerclient.h
-// --------------------------------------------------------------------------
-TInt RUPnPAVControllerClient::CancelAllUploads( TInt aId )
-    {
-    TIpcArgs args( aId );
-    return SendReceive( EAVControllerCancelAllUploads, args );    
-    }
-
-// --------------------------------------------------------------------------
-// StartServer
-// Static method to start the server.
-// --------------------------------------------------------------------------
-static TInt StartServer()
-    {
-    TInt result;
-
-    TFindServer findAVControllerServer( KAVControllerName );
-    TFullName name;
-
-    result = findAVControllerServer.Next( name );
-    if ( result != KErrNone )
-        {
-        // server not found - try to create it.
-        result = CreateServerProcess();
-        }
-
-    return  result;
-    }
-
-// --------------------------------------------------------------------------
-// CreateServerProcess
-// Static method to create the server process.
-// --------------------------------------------------------------------------
-static TInt CreateServerProcess()
-    {
-    TInt result;
-
-    const TUidType serverUid( KNullUid, KNullUid, KAVCServerUid3 );
-    RProcess server;
-
-    result = server.Create( KAVControllerFilename, KNullDesC, serverUid );
-    if ( result != KErrNone )
-        {
-        return  result;
-        }
-
-    TRequestStatus stat = KRequestPending;
-    server.Rendezvous(stat);
-    if ( stat != KRequestPending )
-        {
-        server.Kill( 0 );       // abort startup
-        }
-    else
-        {
-        server.Resume();    // logon OK - start the server
-        }
-        
-    User::WaitForRequest(stat);     // wait for start or death
-
-    // we can't use the 'exit reason' if the server panicked as this
-    // is the panic 'reason' and may be '0' which cannot be distinguished
-    // from KErrNone
-    if ( server.ExitType() == EExitPanic )
-        {
-        result = KErrGeneral;
-        }
-    else
-        {
-        result = stat.Int();
-        }
-    
-    server.Close();   
-    return result;
-    }
-
-
-
-
-
-
+/*
+* Copyright (c) 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:      AV Controller client
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// System
+#include <e32math.h>
+#include <s32mem.h>
+#include <f32file.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavcontrollerglobals.h"
+
+// dlnasrv / avcontroller internal
+#include "upnpavcontrollerclient.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
+#include "upnplog.h"
+
+// Number of message slots to reserve for this client server session.
+const TInt KDefaultMessageSlots = -1;
+
+
+// Function prototypes
+static TInt StartServer( void );
+static TInt CreateServerProcess( void ); 
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::RUPnPAVControllerClient
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// --------------------------------------------------------------------------
+RUPnPAVControllerClient::RUPnPAVControllerClient()
+    :RSessionBase() 
+    {
+    // No implementation required
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::Connect
+// Connect to Media Server session. 
+// exist
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::Connect()
+    {
+    __LOG( "RUPnPAVControllerClient::Connect" );
+    
+    TInt error = ::StartServer();
+
+    if ( KErrNone == error )
+        {
+        error = CreateSession( KAVControllerName,
+                               Version(),
+                               KDefaultMessageSlots );
+        }
+    return error;
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::Version
+// Version information.
+// --------------------------------------------------------------------------
+TVersion RUPnPAVControllerClient::Version() const
+    {
+    return TVersion( KAVControllerMajorVersionNumber,
+                     KAVControllerMinorVersionNumber,
+                     KAVControllerBuildVersionNumber );
+    }
+
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::StartUp
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::StartUp()
+    {
+    TIpcArgs args( TIpcArgs::ENothing );
+    return SendReceive( EAVControllerStartupRequest, args );    
+    }
+
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelStartUp
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelStartUp()
+    {
+    TIpcArgs args( TIpcArgs::ENothing );
+    return SendReceive( EAVControllerCancelStartupRequest, args );    
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::DeviceRequest
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::DeviceRequest( TDes8& aDiscovered,
+    TDes8& aRcvdBufSize, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( &aDiscovered, &aRcvdBufSize );
+    SendReceive( EAVControllerDeviceRequest, args, aStatus );    
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelDeviceRequest
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelDeviceRequest()
+    {
+    TIpcArgs args( TIpcArgs::ENothing );
+    return SendReceive( EAVControllerCancelDeviceRequest, args );    
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::GetDevice
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::GetDevice( TDes8& aDevice )
+    {
+    TIpcArgs args( &aDevice );
+    return SendReceive( EAVControllerGetDeviceRequest, args );
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::GetDeviceListSize
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::GetDeviceListSize( TDes8& aType, TDes8& aSize )
+    {
+    TIpcArgs args( &aType, &aSize );
+    return SendReceive( EAVControllerGetDeviceListSizeRequest, args );
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::GetDeviceList
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::GetDeviceList( TDes8& aList )
+    {
+    TIpcArgs args( &aList );
+    return SendReceive( EAVControllerGetDeviceListRequest, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::GetDeviceIcon
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::GetDeviceIcon( const TDesC8& aUuid, RFile& aFile )
+    {
+    TPckgBuf< TInt > fileHandlePckg( 0 );
+    TIpcArgs args( &aUuid, &fileHandlePckg );
+    TInt fsHandle( SendReceive( EAVControllerGetDeviceIconRequest, args ) );
+    return ( fsHandle < 0 ? fsHandle : aFile.AdoptFromServer( fsHandle,
+            fileHandlePckg() ) );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CreateRenderingSession
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CreateRenderingSession( TInt aId,
+    TDes8& aUuid )
+    {
+    TIpcArgs args( aId, &aUuid );
+    return SendReceive( EAVControllerCreateRenderingSession, args );    
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::DestroyRenderingSession
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::DestroyRenderingSession( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerDestroyRenderingSession, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::EventRequest
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::EventRequest( TDes8& aEvent, TInt aId,
+    TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aEvent );
+    SendReceive( EAVControllerEventRequest, args, aStatus );   
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelEventRequest
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelEventRequest( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelEventRequest, args );    
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::SetURI
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::SetURI( TInt aId, TDes8& aRequest,
+    TDes8& aItem, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aRequest, &aItem );
+    
+    SendReceive( EAVControllerSetURI, args, aStatus );   
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelSetURI
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelSetURI( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelSetURI, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::SetNextURI
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::SetNextURI( TInt aId, TDes8& aRequest,
+    TDes8& aItem, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aRequest, &aItem );
+    
+    SendReceive( EAVControllerSetNextURI, args, aStatus );       
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelSetNextURI
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelSetNextURI( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelSetNextURI, args );    
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::Play
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::Play( TInt aId, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId );
+    
+    SendReceive( EAVControllerPlay, args, aStatus );       
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelPlay
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelPlay( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelPlay, args );
+    }
+      
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::Stop
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::Stop( TInt aId, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId );
+    SendReceive( EAVControllerStop, args, aStatus ); 
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelStop
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelStop( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelStop, args ); 
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::Pause
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::Pause( TInt aId, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId );
+    SendReceive( EAVControllerPause, args, aStatus ); 
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelPause
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelPause( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelPause, args );    
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::SetVolume
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::SetVolume( TInt aId, TInt aVolumeLevel,
+    TDes8& aRetVolume, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, aVolumeLevel, &aRetVolume );
+    SendReceive( EAVControllerSetVolume, args, aStatus );      
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelSetVolume
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelSetVolume( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelSetVolume, args );        
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::GetVolume
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::GetVolume( TInt aId, TDes8& aVolumeLevel,
+    TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aVolumeLevel );
+    SendReceive( EAVControllerGetVolume, args, aStatus );     
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelGetVolume
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelGetVolume( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelGetVolume, args );        
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::SetMute
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::SetMute( TInt aId, TBool aMute,
+    TDes8& aRetMute, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, (TInt)aMute, &aRetMute );
+    SendReceive( EAVControllerSetMute, args, aStatus );        
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::GetMute
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::GetMute( TInt aId, TDes8& aMute,
+    TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aMute );
+    SendReceive( EAVControllerGetMute, args, aStatus );     
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelSetMute
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelSetMute( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelSetMute, args );        
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelGetMute
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelGetMute( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelGetMute, args );        
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::GetPositionInfo
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::GetPositionInfo( TInt aId, TDes8& aPosition,
+    TDes8& aLength, TRequestStatus& aStatus )    
+    {
+    TIpcArgs args( aId, &aPosition, &aLength );
+    SendReceive( EAVControllerGetPositionInfo, args, aStatus );     
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelGetPositionInfo
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelGetPositionInfo( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelGetPositionInfo, args ); 
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::SeekRelTime
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::SeekRelTime( 
+    TInt aId, 
+    TDes8& aTargetTime, 
+    TRequestStatus& aStatus  )
+    {
+    TIpcArgs args( aId, &aTargetTime );
+    SendReceive( EAVControllerSeekRelTime, args, aStatus );     
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelSeekRelTime
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelSeekRelTime( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelSeekRelTime, args ); 
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::GetRendererState
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::GetRendererState( TInt aId, TDes8& aState )
+    {
+    TIpcArgs args( aId, &aState );
+    return SendReceive( EAVControllerGetRendererState, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CreateBrowsingSession
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CreateBrowsingSession( TInt aId, TDes8& aUuid )
+    {
+    TIpcArgs args( aId, &aUuid );
+    return SendReceive( EAVControllerCreateBrowsingSession, args ); 
+    }
+
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::DestroyBrowsingSession
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::DestroyBrowsingSession( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerDestroyBrowsingSession, args );     
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::BrowseResponseSize
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::BrowseResponseSize( TInt aId, TDes8& aRequest,
+    TDes8& aParams, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aRequest, &aParams );
+    SendReceive( EAVControllerGetBrowseResponseSize, args, aStatus );         
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelBrowseResponseSize
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelBrowseResponseSize( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelGetBrowseResponseSize, args );     
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::BrowseResponse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::BrowseResponse( TInt aId,
+    TDes8& aBrowseResponse, TDes8& aUpdateId)
+    {
+    TIpcArgs args( aId, &aBrowseResponse, &aUpdateId );
+    return SendReceive( EAVControllerGetBrowseResponse, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::SearchResponseSize
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::SearchResponseSize( TInt aId, TDes8& aRequest,
+    TDes8& aParams, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aRequest, &aParams );
+    SendReceive( EAVControllerGetSearchResponseSize, args, aStatus );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelSearchResponseSize
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelSearchResponseSize( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelGetSearchResponseSize, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::SearchResponse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::SearchResponse( TInt aId,
+    TDes8& aSearchResponse, TDes8& aUpdateId )
+    {
+    TIpcArgs args( aId, &aSearchResponse,& aUpdateId );
+    return SendReceive( EAVControllerGetSearchResponse, args );             
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::GetSearchCapabilitiesSize
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::GetSearchCapabilitiesSize( TInt aId,
+    TDes8& aSize, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aSize );
+    SendReceive( EAVControllerGetSearchCapabilitiesSize, args, aStatus );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelGetSearchCapabilitiesSize
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelGetSearchCapabilitiesSize( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelGetSearchCapabilitiesSize,
+        args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::SearchCapabilitiesResponse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::SearchCapabilitiesResponse( TInt aId,
+    TDes8& aCapabilitiesResponse )
+    {
+    TIpcArgs args( aId, &aCapabilitiesResponse );
+    return SendReceive( EAVControllerGetSearchCapabilities, args );    
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CreateContainer
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::CreateContainer( TInt aId, TDes8& aTitle,
+    TDes8& aParentId, TInt aContainerType, TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aTitle, &aParentId, aContainerType );
+    SendReceive( EAVControllerCreateContainer, args, aStatus );        
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelCreateContainer
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelCreateContainer( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelCreateContainer, args );        
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::DeleteObject
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::DeleteObject( TInt aId, TDes8& aObjectId,
+    TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aObjectId );
+    SendReceive( EAVControllerDeleteObject, args, aStatus );        
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelDeleteObject
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelDeleteObject( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelDeleteObject, args );        
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::DeviceDisappearedRequest
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::DeviceDisappearedRequest( TInt aId,
+    TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId );
+    SendReceive( EAVControllerDeviceDisappearedRequest, args, aStatus );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelDeviceDisappearedRequest
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelDeviceDisappearedRequest( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelDeviceDisappearedRequest, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MonitorConnection
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::MonitorConnection( TRequestStatus& aStatus )
+    {
+    TIpcArgs args( TIpcArgs::ENothing );
+    SendReceive( EAVControllerMonitorConnection, args, aStatus );        
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CancelMonitorConnection
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelMonitorConnection()
+    {
+    TIpcArgs args( TIpcArgs::ENothing );
+    return SendReceive( EAVControllerCancelMonitorConnection, args );    
+    }
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CreateDownloadSession
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CreateDownloadSession( TInt aId, TDes8& aUuid )
+    {
+    TIpcArgs args( aId, &aUuid );
+    return SendReceive( EAVControllerCreateDownloadSession, args );        
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::DestroyDownloadSession
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::DestroyDownloadSession( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerDestroyDownloadSession, args );    
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::CreateUploadSession
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CreateUploadSession( TInt aId, TDes8& aUuid )
+    {
+    TIpcArgs args( aId, &aUuid );
+    return SendReceive( EAVControllerCreateUploadSession, args );            
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::DestroyUploadSession( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerDestroyUploadSession, args );        
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::StartDownload( TInt aId,
+    TDes8& aFileTransferItem )
+    {
+    TIpcArgs args( aId, &aFileTransferItem );
+    return SendReceive( EAVControllerStartDownload, args );    
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::StartDownload( TInt aId,
+    TDes8& aFileTransferItem, const RFile& aFile )
+    {
+    TIpcArgs args( aId, &aFileTransferItem );
+    aFile.TransferToServer( args, 2, 3 );
+    return SendReceive( EAVControllerStartDownloadFH, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::GetDownloadEvent( TInt aId, TDes8& aEvent,
+    TRequestStatus& aStatus, TDes& aBuffer )
+    {
+    TIpcArgs args( aId, &aEvent, &aBuffer );
+    SendReceive( EAVControllerGetDownloadEvent, args, aStatus );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelDownloadEvent( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelDownloadEvent, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::StartTrackingDownloadProgress( TInt aId,
+    TInt aKey )
+    {
+    TIpcArgs args( aId, aKey );
+    return SendReceive( EAVControllerStartTrackingDownloadProgress, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelDownload( TInt aId, TInt aKey )
+    {
+    TIpcArgs args( aId, aKey );
+    return SendReceive( EAVControllerCancelDownload, args );    
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelAllDownloads( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelAllDownloads, args );
+    }
+
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::StartUpload( TInt aId, TDes8& aFileTransferItem )
+    {
+    TIpcArgs args( aId, &aFileTransferItem );
+    return SendReceive( EAVControllerStartUpload, args );    
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+void RUPnPAVControllerClient::GetUploadEvent( TInt aId, TDes8& aEvent,
+        TRequestStatus& aStatus )
+    {
+    TIpcArgs args( aId, &aEvent );
+    SendReceive( EAVControllerGetUploadEvent, args, aStatus );    
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelUploadEvent( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelUploadEvent, args );    
+    }
+        
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::StartTrackingUploadProgress( TInt aId, TInt aKey )
+    {
+    TIpcArgs args( aId, aKey );
+    return SendReceive( EAVControllerStartTrackingUploadProgress, args );    
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelUpload( TInt aId, TInt aKey )
+    {
+    TIpcArgs args( aId, aKey );
+    return SendReceive( EAVControllerCancelUpload, args );        
+    }
+    
+// --------------------------------------------------------------------------
+// RUPnPAVControllerClient::MSServicesInUse
+// See upnpavcontrollerclient.h
+// --------------------------------------------------------------------------
+TInt RUPnPAVControllerClient::CancelAllUploads( TInt aId )
+    {
+    TIpcArgs args( aId );
+    return SendReceive( EAVControllerCancelAllUploads, args );    
+    }
+
+// --------------------------------------------------------------------------
+// StartServer
+// Static method to start the server.
+// --------------------------------------------------------------------------
+static TInt StartServer()
+    {
+    __LOG( "StartServer" );
+    
+    TInt result;
+
+    TFindServer findAVControllerServer( KAVControllerName );
+    TFullName name;
+
+    result = findAVControllerServer.Next( name );
+    if ( result != KErrNone )
+        {
+        // server not found - try to create it.
+        result = CreateServerProcess();
+        }
+
+    return  result;
+    }
+
+// --------------------------------------------------------------------------
+// CreateServerProcess
+// Static method to create the server process.
+// --------------------------------------------------------------------------
+static TInt CreateServerProcess()
+    {
+    TInt result;
+
+    const TUidType serverUid( KNullUid, KNullUid, KAVCServerUid3 );
+    RProcess server;
+
+    result = server.Create( KAVControllerFilename, KNullDesC, serverUid );
+    __LOG2( "Process create for '%S' completed with code %d", &KAVControllerFilename, result );
+    if ( result != KErrNone )
+        {
+        return  result;
+        }
+
+    TRequestStatus stat = KRequestPending;
+    server.Rendezvous(stat);
+    if ( stat != KRequestPending )
+        {
+        server.Kill( 0 );       // abort startup
+        }
+    else
+        {
+        server.Resume();    // logon OK - start the server
+        }
+        
+    User::WaitForRequest(stat);     // wait for start or death
+
+    // we can't use the 'exit reason' if the server panicked as this
+    // is the panic 'reason' and may be '0' which cannot be distinguished
+    // from KErrNone
+    if ( server.ExitType() == EExitPanic )
+        {
+        result = KErrGeneral;
+        }
+    else
+        {
+        result = stat.Int();
+        }
+    
+    server.Close();   
+    return result;
+    }
+
+
+
+
+
+
--- a/upnpavcontroller/upnpavcontrollerclient/src/upnpavcontrollerfactory.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/src/upnpavcontrollerfactory.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,125 +1,76 @@
-/*
-* Copyright (c) 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:      The factory for AVController client
-*
-*/
-
-
-
-
-
-
-// INCLUDES
-// upnpframework / avcontroller api
-#include "upnpavcontrollerfactory.h"
-#include "upnpavcontrollerglobals.h"
-
-// avcontroller internal
-#include "upnpavcontrolleractive.h"
-#include "upnpavcontrollerclient.h"
-
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// UPnPAVControllerFactory::NewUPnPAVControllerL
-// Two-phase construct
-// --------------------------------------------------------------------------
-EXPORT_C MUPnPAVController* UPnPAVControllerFactory::NewUPnPAVControllerL()
-    {
-    return CUPnPAVControllerActive::NewL();
-    }
-    
-// --------------------------------------------------------------------------
-// UPnPAVControllerFactory::NewUPnPAVControllerLC
-// Two-phase construct
-// --------------------------------------------------------------------------
-EXPORT_C MUPnPAVController* UPnPAVControllerFactory::NewUPnPAVControllerLC()
-    {
-    return CUPnPAVControllerActive::NewLC();
-    }
-
-// --------------------------------------------------------------------------
-// UPnPAVControllerFactory::MSServicesInUse
-// See upnpavcontrollerfactory.h
-// --------------------------------------------------------------------------
-EXPORT_C TBool UPnPAVControllerFactory::MSServicesInUse()
-    {
-    TBool retVal = EFalse;
-    TFindServer findAVControllerServer( KAVControllerName );
-    TFullName name;
-
-    if ( findAVControllerServer.Next( name ) == KErrNone )
-        {
-        // Server already running, connect and check if it's using the local
-        // media server
-        RUPnPAVControllerClient avClient;
-        TInt err = avClient.Connect();
-        TBool inUse = EFalse;
-        TPckg<TBool> inUsePckg( inUse );
-        
-        if( err )
-            {
-            // Error in client/servers comms, let the client think that the
-            // local media server is in use
-            retVal = ETrue;            
-            }
-        else
-            {
-            err = avClient.MSServicesInUse( inUsePckg );
-            if( err )
-                {
-                // Error in client/servers comms, let the client think that the
-                // local media server is in use
-                retVal = ETrue;
-                }
-            else if( inUse )
-                {
-                // Local media server is in use
-                retVal = ETrue;
-                }                
-            }    
-        avClient.Close();
-        }
-    else
-        {
-        // Server not running, local media server is not used
-        }
-    return retVal;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPAVControllerFactory::Status
-// See upnpavcontrollerfactory.h
-// --------------------------------------------------------------------------
-EXPORT_C TInt UPnPAVControllerFactory::Status(
-    TAVControllerServerStatus& aStatus )
-    {
-    TFindServer findAVControllerServer( KAVControllerName );
-    TFullName name;
-
-    if ( findAVControllerServer.Next( name ) == KErrNone )
-        {
-        // Server running
-        aStatus = EStatusActive;
-        }
-    else
-        {
-        // Server not running
-        aStatus = EStatusOffline;
-        }
-    return KErrNone;    
-    }
-
-// end of file
+/*
+* Copyright (c) 2006-2009 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:      The factory for AVController client
+*
+*/
+
+
+
+
+
+
+// INCLUDES
+// dlnasrv / avcontroller api
+#include "upnpavcontrollerfactory.h"
+#include "upnpavcontrollerglobals.h"
+
+// dlnasrv / avcontroller internal
+#include "upnpavcontrolleractive.h"
+#include "upnpavcontrollerclient.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// UPnPAVControllerFactory::NewUPnPAVControllerL
+// Two-phase construct
+// --------------------------------------------------------------------------
+EXPORT_C MUPnPAVController* UPnPAVControllerFactory::NewUPnPAVControllerL()
+    {
+    return CUPnPAVControllerActive::NewL();
+    }
+    
+// --------------------------------------------------------------------------
+// UPnPAVControllerFactory::NewUPnPAVControllerLC
+// Two-phase construct
+// --------------------------------------------------------------------------
+EXPORT_C MUPnPAVController* UPnPAVControllerFactory::NewUPnPAVControllerLC()
+    {
+    return CUPnPAVControllerActive::NewLC();
+    }
+
+// --------------------------------------------------------------------------
+// UPnPAVControllerFactory::Status
+// See upnpavcontrollerfactory.h
+// --------------------------------------------------------------------------
+EXPORT_C TInt UPnPAVControllerFactory::Status(
+    TAVControllerServerStatus& aStatus )
+    {
+    TFindServer findAVControllerServer( KAVControllerName );
+    TFullName name;
+
+    if ( findAVControllerServer.Next( name ) == KErrNone )
+        {
+        // Server running
+        aStatus = EStatusActive;
+        }
+    else
+        {
+        // Server not running
+        aStatus = EStatusOffline;
+        }
+    return KErrNone;    
+    }
+
+// end of file
--- a/upnpavcontroller/upnpavcontrollerclient/src/upnpavdevice.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/src/upnpavdevice.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,543 +1,592 @@
-/*
-* Copyright (c) 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:      The device object
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-
-#include "upnpavdevice.h"
-
-// CONSTANTS
-const TInt KMaxStringLen = 255;
-const TInt KBufferGranularity = 100;
-
-_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-_LIT8( KAudioSupport,        "audio/" );
-_LIT8( KImageSupport,        "image/" );
-_LIT8( KVideoSupport,        "video/" );
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::CUpnpAVDevice
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// --------------------------------------------------------------------------
-EXPORT_C CUpnpAVDevice::CUpnpAVDevice()
-    {    
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::ConstructL
-// Symbian 2nd phase constructor can leave.
-// --------------------------------------------------------------------------
-void CUpnpAVDevice::ConstructL()
-    {                           
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::NewL
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-EXPORT_C CUpnpAVDevice* CUpnpAVDevice::NewL()
-    {
-    CUpnpAVDevice* self = NewLC();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::NewL
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-EXPORT_C CUpnpAVDevice* CUpnpAVDevice::NewL( const CUpnpAVDevice& aDevice )
-    {
-    CUpnpAVDevice* self = NewLC();
-    
-    self->CopyFromL( aDevice );
-
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-EXPORT_C CUpnpAVDevice* CUpnpAVDevice::NewLC()
-    {
-    CUpnpAVDevice* self = new( ELeave )
-        CUpnpAVDevice;    
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::~CUpnpAVDevice
-// Destructor
-// --------------------------------------------------------------------------
-EXPORT_C CUpnpAVDevice::~CUpnpAVDevice()
-    {
-    delete iName;
-    delete iUuid;            
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::ExternalizeL
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::ExternalizeL( RWriteStream& aStream ) const
-    {
-    __ASSERTD( iUuid, __FILE__, __LINE__ );
-    __ASSERTD( iName, __FILE__, __LINE__ );
-    
-    aStream << *iUuid;
-    aStream << *iName;
-    aStream.WriteInt32L( (TInt)iDeviceType );
-    aStream.WriteInt32L( (TInt)iCopyCapability );
-    aStream.WriteInt32L( (TInt)iSearchCapability );
-    aStream.WriteInt32L( (TInt)iPauseCapability );
-    aStream.WriteInt32L( (TInt)iVolumeCapability );
-    aStream.WriteInt32L( (TInt)iMuteCapability );
-    aStream.WriteInt32L( (TInt)iAudioMediaCapability );
-    aStream.WriteInt32L( (TInt)iImageMediaCapability );
-    aStream.WriteInt32L( (TInt)iVideoMediaCapability );
-    aStream.WriteInt32L( (TInt)iNextAVTransportUri );
-    aStream.WriteInt32L( (TInt)iMaxVolume );
-    aStream.WriteInt32L( (TInt)iDlnaCompatible );
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::InternalizeL
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::InternalizeL( RReadStream& aStream )
-    {
-    delete iUuid;
-    iUuid = NULL;
-    iUuid = HBufC8::NewL( aStream, KMaxStringLen );
-
-    delete iName;
-    iName = NULL;
-    iName = HBufC8::NewL( aStream, KMaxStringLen );
-    
-    iDeviceType = (TUpnpAVDeviceType)aStream.ReadInt32L();
-    iCopyCapability = (TBool)aStream.ReadInt32L();
-    iSearchCapability = (TBool)aStream.ReadInt32L();
-    iPauseCapability = (TBool)aStream.ReadInt32L();
-    iVolumeCapability = (TBool)aStream.ReadInt32L();
-    iMuteCapability = (TBool)aStream.ReadInt32L();
-    iAudioMediaCapability = (TBool)aStream.ReadInt32L();
-    iImageMediaCapability = (TBool)aStream.ReadInt32L();
-    iVideoMediaCapability = (TBool)aStream.ReadInt32L();
-    iNextAVTransportUri = (TBool)aStream.ReadInt32L();
-    iMaxVolume = (TInt)aStream.ReadInt32L();
-    iDlnaCompatible = (TBool)aStream.ReadInt32L();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::ToDes8L
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C HBufC8* CUpnpAVDevice::ToDes8L() const
-    {
-    // serialize object
-    CBufFlat* tempFlatBuf = CBufFlat::NewL( KBufferGranularity );
-    CleanupStack::PushL( tempFlatBuf );
-
-    RBufWriteStream stream( *tempFlatBuf );
-    CleanupClosePushL( stream );
-    
-    stream << *this;
-    
-    // create heap descriptor
-    HBufC8* tempBuf = HBufC8::NewLC( tempFlatBuf->Size() );
-    TPtr8 ptr( tempBuf->Des() );
-    tempFlatBuf->Read( 0, ptr, tempFlatBuf->Size() );
-    
-    // clean up
-    CleanupStack::Pop( tempBuf );
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( tempFlatBuf );
-    
-    return tempBuf;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::CopyFromL
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::CopyFromL( const CUpnpAVDevice& aDevice )
-    {
-    iDeviceType = aDevice.DeviceType();
-    SetFriendlyNameL( aDevice.FriendlyName() );
-    SetUuidL( aDevice.Uuid() );
-    iCopyCapability = aDevice.CopyCapability();
-    iSearchCapability = aDevice.SearchCapability();
-    iPauseCapability = aDevice.PauseCapability();
-    iVolumeCapability = aDevice.VolumeCapability();
-    iMuteCapability = aDevice.MuteCapability();
-    iAudioMediaCapability = aDevice.AudioCapability();
-    iImageMediaCapability = aDevice.ImageCapability();
-    iVideoMediaCapability = aDevice.VideoCapability();
-    iNextAVTransportUri = aDevice.NextAVTransportUri();
-    iMaxVolume = aDevice.MaxVolume();
-    iDlnaCompatible = aDevice.DlnaCompatible();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetFriendlyNameL
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetFriendlyNameL( const TDesC8& aName )
-    {
-    HBufC8* tempBuf = aName.AllocL();
-    delete iName;
-    iName = tempBuf;    
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::FriendlyName
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C const TDesC8& CUpnpAVDevice::FriendlyName() const
-    {
-    if( iName )
-        {
-        return *iName;
-        }
-    else
-        {
-        return KNullDesC8;
-        }        
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetUuidL
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetUuidL( const TDesC8& aUuid )
-    {
-    HBufC8* tempBuf = aUuid.AllocL();
-    delete iUuid;
-    iUuid = tempBuf;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::Uuid
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C const TDesC8& CUpnpAVDevice::Uuid() const
-    {
-    if( iUuid )
-        {
-        return *iUuid;
-        }
-    else
-        {
-        return KNullDesC8;
-        }    
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetDeviceType
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetDeviceType( TUpnpAVDeviceType aDeviceType )
-    {
-    iDeviceType = aDeviceType;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::DeviceType
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C CUpnpAVDevice::TUpnpAVDeviceType CUpnpAVDevice::DeviceType() const
-    {
-    return iDeviceType;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetCapabilitiesBySupportedMimeTypesL
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetCapabilitiesBySupportedMimeTypesL(
-                                const TDesC8& aListOfMimeTypes )
-    {
-    if( aListOfMimeTypes == KNullDesC8 )
-        {
-        User::Leave( KErrArgument );
-        }
-    else
-        {
-        // Update the audio media capability
-        if( aListOfMimeTypes.Find( KAudioSupport ) >= 0 )
-            {
-            iAudioMediaCapability = ETrue;
-            }
-        else
-            {
-            iAudioMediaCapability = EFalse;
-            }
-
-        // Update the image media capability
-        if( aListOfMimeTypes.Find( KImageSupport ) >= 0 )
-            {
-            iImageMediaCapability = ETrue;
-            }
-        else
-            {
-            iImageMediaCapability = EFalse;
-            }
-
-        // Update the video media capability
-        if( aListOfMimeTypes.Find( KVideoSupport ) >= 0 )
-            {
-            iVideoMediaCapability = ETrue;
-            }
-        else
-            {
-            iVideoMediaCapability = EFalse;
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::LinkOffset
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C TInt CUpnpAVDevice::LinkOffset()
-    {
-    return _FOFF( CUpnpAVDevice, iSlink );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetCopyCapability
-// Sets the copy capability of the device
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetCopyCapability( TBool aCopyCap )
-    {
-    iCopyCapability = aCopyCap;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::CopyCapability
-// Gets the copy capability of the device
-// --------------------------------------------------------------------------
-EXPORT_C TBool CUpnpAVDevice::CopyCapability() const
-    {
-    return iCopyCapability;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetSearchCapability
-// Sets the search capability of the device
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetSearchCapability( TBool aSearchCap )
-    {
-    iSearchCapability = aSearchCap;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SearchCapability
-// Gets the search capability of the device
-// --------------------------------------------------------------------------
-EXPORT_C TBool CUpnpAVDevice::SearchCapability() const
-    {
-    return iSearchCapability;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetPauseCapability
-// Sets the pause capability of the device
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetPauseCapability( TBool aPauseCap )
-    {
-    iPauseCapability = aPauseCap;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::PauseCapability
-// Gets the pause capability of the device
-// --------------------------------------------------------------------------
-EXPORT_C TBool CUpnpAVDevice::PauseCapability() const
-    {
-    return iPauseCapability;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetVolumeCapability
-// Sets the volume capability of the device
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetVolumeCapability( TBool aVolumeCap )
-    {
-    iVolumeCapability = aVolumeCap;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::VolumeCapability
-// Gets the volume capability of the device
-// --------------------------------------------------------------------------
-EXPORT_C TBool CUpnpAVDevice::VolumeCapability() const
-    {
-    return iVolumeCapability;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetMuteCapability
-// Sets the mute capability of the device
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetMuteCapability( TBool aMuteCap )
-    {
-    iMuteCapability = aMuteCap;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::MuteCapability
-// Gets the mute capability of the device
-// --------------------------------------------------------------------------
-EXPORT_C TBool CUpnpAVDevice::MuteCapability() const
-    {
-    return iMuteCapability;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetMaxVolume
-// Sets the maximum volume of the device
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetMaxVolume( TInt aVolume )
-    {
-    iMaxVolume = aVolume;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::MaxVolume
-// Gets the maximum volume of the device
-// --------------------------------------------------------------------------
-EXPORT_C TInt CUpnpAVDevice::MaxVolume() const
-    {
-    return iMaxVolume;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetNextAVTransportUri
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetNextAVTransportUri( TBool aCap )
-    {
-    iNextAVTransportUri = aCap;
-    __LOG1( "CUpnpAVDevice::SetNextAVTransportUri: iNextAVTransportUri %d",
-            iNextAVTransportUri );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::NextAVTransportUri
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C TBool CUpnpAVDevice::NextAVTransportUri() const
-    {
-    __LOG1( "CUpnpAVDevice::NextAVTransportUri: iNextAVTransportUri %d",
-            iNextAVTransportUri );
-    // Do not support NextAVTransportUri for now
-    __LOG( "return EFalse" );
-    return EFalse;
-    }           
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetAudioCapability
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetAudioCapability( TBool aCap )
-    {
-    iAudioMediaCapability = aCap;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::AudioCapability
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C TBool CUpnpAVDevice::AudioCapability() const
-    {
-    return iAudioMediaCapability;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetImageCapability
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetImageCapability( TBool aCap )
-    {
-    iImageMediaCapability = aCap;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::ImageCapability
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C TBool CUpnpAVDevice::ImageCapability() const
-    {
-    return iImageMediaCapability;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetVideoCapability
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetVideoCapability( TBool aCap )
-    {
-    iVideoMediaCapability = aCap;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::VideoCapability
-// See upnpavdevice.h
-// --------------------------------------------------------------------------
-EXPORT_C TBool CUpnpAVDevice::VideoCapability() const
-    {
-    return iVideoMediaCapability;     
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::SetDlnaCompatible
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUpnpAVDevice::SetDlnaCompatible( TBool aDlnaCompatible )
-    {
-    iDlnaCompatible = aDlnaCompatible;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDevice::DlnaCompatible
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-EXPORT_C TBool CUpnpAVDevice::DlnaCompatible() const
-    {
-    return iDlnaCompatible;
-    }
-
-// End of File
-
+/*
+* Copyright (c) 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:      The device object
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+
+#include "upnpavdevice.h"
+
+// CONSTANTS
+const TInt KMaxStringLen = 255;
+const TInt KBufferGranularity = 100;
+
+_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+_LIT8( KAudioSupport,        "audio/" );
+_LIT8( KImageSupport,        "image/" );
+_LIT8( KVideoSupport,        "video/" );
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::CUpnpAVDevice
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// --------------------------------------------------------------------------
+EXPORT_C CUpnpAVDevice::CUpnpAVDevice()
+    {    
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::ConstructL
+// Symbian 2nd phase constructor can leave.
+// --------------------------------------------------------------------------
+void CUpnpAVDevice::ConstructL()
+    {                           
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::NewL
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+EXPORT_C CUpnpAVDevice* CUpnpAVDevice::NewL()
+    {
+    CUpnpAVDevice* self = NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::NewL
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+EXPORT_C CUpnpAVDevice* CUpnpAVDevice::NewL( const CUpnpAVDevice& aDevice )
+    {
+    CUpnpAVDevice* self = NewLC();
+    
+    self->CopyFromL( aDevice );
+
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::NewLC
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+EXPORT_C CUpnpAVDevice* CUpnpAVDevice::NewLC()
+    {
+    CUpnpAVDevice* self = new( ELeave )
+        CUpnpAVDevice;    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::~CUpnpAVDevice
+// Destructor
+// --------------------------------------------------------------------------
+EXPORT_C CUpnpAVDevice::~CUpnpAVDevice()
+    {
+    delete iName;
+    delete iUuid; 
+    delete iModelName;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::ExternalizeL
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::ExternalizeL( RWriteStream& aStream ) const
+    {
+    __ASSERTD( iUuid, __FILE__, __LINE__ );
+    __ASSERTD( iName, __FILE__, __LINE__ );
+    __ASSERTD( iModelName, __FILE__, __LINE__ );
+    
+    aStream << *iUuid;
+    aStream << *iName;
+    aStream << *iModelName;
+    aStream.WriteInt32L( (TInt)iDeviceType );
+    aStream.WriteInt32L( (TInt)iCopyCapability );
+    aStream.WriteInt32L( (TInt)iSearchCapability );
+    aStream.WriteInt32L( (TInt)iPauseCapability );
+    aStream.WriteInt32L( (TInt)iVolumeCapability );
+    aStream.WriteInt32L( (TInt)iMuteCapability );
+    aStream.WriteInt32L( (TInt)iAudioMediaCapability );
+    aStream.WriteInt32L( (TInt)iImageMediaCapability );
+    aStream.WriteInt32L( (TInt)iVideoMediaCapability );
+    aStream.WriteInt32L( (TInt)iNextAVTransportUri );
+    aStream.WriteInt32L( (TInt)iMaxVolume );
+    aStream.WriteInt32L( (TInt)iDlnaCompatible );
+    aStream.WriteInt32L( (TInt)iSeekCapability );
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::InternalizeL
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::InternalizeL( RReadStream& aStream )
+    {
+    delete iUuid;
+    iUuid = NULL;
+    iUuid = HBufC8::NewL( aStream, KMaxStringLen );
+
+    delete iName;
+    iName = NULL;
+    iName = HBufC8::NewL( aStream, KMaxStringLen );
+    
+    delete iModelName;
+    iModelName = NULL;
+    iModelName = HBufC8::NewL( aStream, KMaxStringLen );
+    
+    iDeviceType = (TUpnpAVDeviceType)aStream.ReadInt32L();
+    iCopyCapability = (TBool)aStream.ReadInt32L();
+    iSearchCapability = (TBool)aStream.ReadInt32L();
+    iPauseCapability = (TBool)aStream.ReadInt32L();
+    iVolumeCapability = (TBool)aStream.ReadInt32L();
+    iMuteCapability = (TBool)aStream.ReadInt32L();
+    iAudioMediaCapability = (TBool)aStream.ReadInt32L();
+    iImageMediaCapability = (TBool)aStream.ReadInt32L();
+    iVideoMediaCapability = (TBool)aStream.ReadInt32L();
+    iNextAVTransportUri = (TBool)aStream.ReadInt32L();
+    iMaxVolume = (TInt)aStream.ReadInt32L();
+    iDlnaCompatible = (TBool)aStream.ReadInt32L();
+    iSeekCapability = (TSeekMode)aStream.ReadInt32L();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::ToDes8L
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C HBufC8* CUpnpAVDevice::ToDes8L() const
+    {
+    // serialize object
+    CBufFlat* tempFlatBuf = CBufFlat::NewL( KBufferGranularity );
+    CleanupStack::PushL( tempFlatBuf );
+
+    RBufWriteStream stream( *tempFlatBuf );
+    CleanupClosePushL( stream );
+    
+    stream << *this;
+    
+    // create heap descriptor
+    HBufC8* tempBuf = HBufC8::NewLC( tempFlatBuf->Size() );
+    TPtr8 ptr( tempBuf->Des() );
+    tempFlatBuf->Read( 0, ptr, tempFlatBuf->Size() );
+    
+    // clean up
+    CleanupStack::Pop( tempBuf );
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( tempFlatBuf );
+    
+    return tempBuf;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::CopyFromL
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::CopyFromL( const CUpnpAVDevice& aDevice )
+    {
+    iDeviceType = aDevice.DeviceType();
+    SetFriendlyNameL( aDevice.FriendlyName() );
+    SetUuidL( aDevice.Uuid() );
+    SetModelNameL( aDevice.ModelName() );
+    iCopyCapability = aDevice.CopyCapability();
+    iSearchCapability = aDevice.SearchCapability();
+    iPauseCapability = aDevice.PauseCapability();
+    iVolumeCapability = aDevice.VolumeCapability();
+    iMuteCapability = aDevice.MuteCapability();
+    iAudioMediaCapability = aDevice.AudioCapability();
+    iImageMediaCapability = aDevice.ImageCapability();
+    iVideoMediaCapability = aDevice.VideoCapability();
+    iNextAVTransportUri = aDevice.NextAVTransportUri();
+    iMaxVolume = aDevice.MaxVolume();
+    iDlnaCompatible = aDevice.DlnaCompatible();
+    iSeekCapability = aDevice.SeekCapability();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetFriendlyNameL
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetFriendlyNameL( const TDesC8& aName )
+    {
+    HBufC8* tempBuf = aName.AllocL();
+    delete iName;
+    iName = tempBuf;    
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::FriendlyName
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C const TDesC8& CUpnpAVDevice::FriendlyName() const
+    {
+    if( iName )
+        {
+        return *iName;
+        }
+    else
+        {
+        return KNullDesC8;
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetModelNameL
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetModelNameL( const TDesC8& aName )
+    {
+    HBufC8* tempBuf = aName.AllocL();
+    delete iModelName;
+    iModelName = tempBuf;    
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::ModelName
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C const TDesC8& CUpnpAVDevice::ModelName() const
+    {
+    return (iModelName) ? *iModelName : KNullDesC8();     
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetUuidL
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetUuidL( const TDesC8& aUuid )
+    {
+    HBufC8* tempBuf = aUuid.AllocL();
+    delete iUuid;
+    iUuid = tempBuf;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::Uuid
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C const TDesC8& CUpnpAVDevice::Uuid() const
+    {
+    if( iUuid )
+        {
+        return *iUuid;
+        }
+    else
+        {
+        return KNullDesC8;
+        }    
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetDeviceType
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetDeviceType( TUpnpAVDeviceType aDeviceType )
+    {
+    iDeviceType = aDeviceType;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::DeviceType
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C CUpnpAVDevice::TUpnpAVDeviceType CUpnpAVDevice::DeviceType() const
+    {
+    return iDeviceType;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetCapabilitiesBySupportedMimeTypesL
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetCapabilitiesBySupportedMimeTypesL(
+                                const TDesC8& aListOfMimeTypes )
+    {
+    if( aListOfMimeTypes == KNullDesC8 )
+        {
+        User::Leave( KErrArgument );
+        }
+    else
+        {
+        // Update the audio media capability
+        if( aListOfMimeTypes.Find( KAudioSupport ) >= 0 )
+            {
+            iAudioMediaCapability = ETrue;
+            }
+        else
+            {
+            iAudioMediaCapability = EFalse;
+            }
+
+        // Update the image media capability
+        if( aListOfMimeTypes.Find( KImageSupport ) >= 0 )
+            {
+            iImageMediaCapability = ETrue;
+            }
+        else
+            {
+            iImageMediaCapability = EFalse;
+            }
+
+        // Update the video media capability
+        if( aListOfMimeTypes.Find( KVideoSupport ) >= 0 )
+            {
+            iVideoMediaCapability = ETrue;
+            }
+        else
+            {
+            iVideoMediaCapability = EFalse;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::LinkOffset
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C TInt CUpnpAVDevice::LinkOffset()
+    {
+    return _FOFF( CUpnpAVDevice, iSlink );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetCopyCapability
+// Sets the copy capability of the device
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetCopyCapability( TBool aCopyCap )
+    {
+    iCopyCapability = aCopyCap;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::CopyCapability
+// Gets the copy capability of the device
+// --------------------------------------------------------------------------
+EXPORT_C TBool CUpnpAVDevice::CopyCapability() const
+    {
+    return iCopyCapability;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetSearchCapability
+// Sets the search capability of the device
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetSearchCapability( TBool aSearchCap )
+    {
+    iSearchCapability = aSearchCap;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SearchCapability
+// Gets the search capability of the device
+// --------------------------------------------------------------------------
+EXPORT_C TBool CUpnpAVDevice::SearchCapability() const
+    {
+    return iSearchCapability;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetPauseCapability
+// Sets the pause capability of the device
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetPauseCapability( TBool aPauseCap )
+    {
+    iPauseCapability = aPauseCap;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::PauseCapability
+// Gets the pause capability of the device
+// --------------------------------------------------------------------------
+EXPORT_C TBool CUpnpAVDevice::PauseCapability() const
+    {
+    return iPauseCapability;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetVolumeCapability
+// Sets the volume capability of the device
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetVolumeCapability( TBool aVolumeCap )
+    {
+    iVolumeCapability = aVolumeCap;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::VolumeCapability
+// Gets the volume capability of the device
+// --------------------------------------------------------------------------
+EXPORT_C TBool CUpnpAVDevice::VolumeCapability() const
+    {
+    return iVolumeCapability;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetMuteCapability
+// Sets the mute capability of the device
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetMuteCapability( TBool aMuteCap )
+    {
+    iMuteCapability = aMuteCap;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::MuteCapability
+// Gets the mute capability of the device
+// --------------------------------------------------------------------------
+EXPORT_C TBool CUpnpAVDevice::MuteCapability() const
+    {
+    return iMuteCapability;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetMaxVolume
+// Sets the maximum volume of the device
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetMaxVolume( TInt aVolume )
+    {
+    iMaxVolume = aVolume;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::MaxVolume
+// Gets the maximum volume of the device
+// --------------------------------------------------------------------------
+EXPORT_C TInt CUpnpAVDevice::MaxVolume() const
+    {
+    return iMaxVolume;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetNextAVTransportUri
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetNextAVTransportUri( TBool aCap )
+    {
+    iNextAVTransportUri = aCap;
+    __LOG1( "CUpnpAVDevice::SetNextAVTransportUri: iNextAVTransportUri %d",
+            iNextAVTransportUri );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::NextAVTransportUri
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C TBool CUpnpAVDevice::NextAVTransportUri() const
+    {
+    __LOG1( "CUpnpAVDevice::NextAVTransportUri: iNextAVTransportUri %d",
+            iNextAVTransportUri );
+    // Do not support NextAVTransportUri for now
+    __LOG( "return EFalse" );
+    return EFalse;
+    }           
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetAudioCapability
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetAudioCapability( TBool aCap )
+    {
+    iAudioMediaCapability = aCap;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::AudioCapability
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C TBool CUpnpAVDevice::AudioCapability() const
+    {
+    return iAudioMediaCapability;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetImageCapability
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetImageCapability( TBool aCap )
+    {
+    iImageMediaCapability = aCap;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::ImageCapability
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C TBool CUpnpAVDevice::ImageCapability() const
+    {
+    return iImageMediaCapability;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetVideoCapability
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetVideoCapability( TBool aCap )
+    {
+    iVideoMediaCapability = aCap;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::VideoCapability
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C TBool CUpnpAVDevice::VideoCapability() const
+    {
+    return iVideoMediaCapability;     
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetDlnaCompatible
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetDlnaCompatible( TBool aDlnaCompatible )
+    {
+    iDlnaCompatible = aDlnaCompatible;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::DlnaCompatible
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C TBool CUpnpAVDevice::DlnaCompatible() const
+    {
+    return iDlnaCompatible;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SetSeekCapability
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUpnpAVDevice::SetSeekCapability( 
+                                CUpnpAVDevice::TSeekMode aSeekCapability )
+    {
+    iSeekCapability = aSeekCapability;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDevice::SeekCapability
+// See upnpavdevice.h
+// --------------------------------------------------------------------------
+EXPORT_C CUpnpAVDevice::TSeekMode CUpnpAVDevice::SeekCapability() const
+    {
+    return iSeekCapability;
+    }
+
+// End of File
+
--- a/upnpavcontroller/upnpavcontrollerclient/src/upnpavrenderingactive.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/src/upnpavrenderingactive.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,791 +1,753 @@
-/*
-* Copyright (c) 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:      AO for rendering commands
-*
-*/
-
-
-
-
-
-
-#include "upnpavrenderingactive.h"
-
-#include "upnpavcontrollerclient.h"
-#include "upnpavrenderingsessionimpl.h"
-#include "upnpavrequest.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
-#include "upnplog.h"
-
-const TInt KPositionInfoSize = 15;
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::NewL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-CUPnPAVRenderingActive* CUPnPAVRenderingActive::NewL(
-    RUPnPAVControllerClient& aServer, TInt aId )
-    {
-    CUPnPAVRenderingActive* self = new (ELeave) CUPnPAVRenderingActive(
-        aServer, aId );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::CUPnPAVRenderingActive
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-CUPnPAVRenderingActive::CUPnPAVRenderingActive(
-    RUPnPAVControllerClient& aServer, TInt aId ):
-    CActive( EPriorityStandard ),
-    iServer( aServer ),
-    iId( aId ),
-    iBufferPtr( 0, 0 ),
-    iBufferPtr2( 0, 0 ),
-    iRespBufSizePkg( iRespBufSize )
-    {
-    CActiveScheduler::Add( this );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::~CUPnPAVRenderingActive
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-CUPnPAVRenderingActive::~CUPnPAVRenderingActive()
-    {
-    __LOG( "CUPnPAVRenderingActive::~CUPnPAVRenderingActive" );
-    
-    Cancel();
-    
-    delete iBuffer;
-    delete iBuffer2;
-
-    if( iMediaServerResourceReserved )
-        {
-        iServer.ReleaseMediaServer( iId );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::ConstructL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::ConstructL()
-    {  
-    __LOG( "CUPnPAVRenderingActive::ConstructL" );  
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::RunL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::RunL()
-    {
-    __LOG( "CUPnPAVRenderingActive::RunL" );
-    
-    switch( iPendingOperation )
-        {
-        case ESetURI:
-            {
-            SetURICompleteL();
-            }
-            break;
-
-        case ESetNextURI:
-            {
-            SetNextURICompleteL();
-            }
-            break;
-
-        case EPlay:
-            {
-            PlayCompleteL();
-            }
-            break;
-
-        case EStop:
-            {
-            StopCompleteL();
-            }
-            break;
-
-        case EPause:
-            {
-            PauseCompleteL();
-            }
-            break;
-
-        case ESetVolume:
-            {
-            SetVolumeCompleteL();
-            }
-            break;
-
-        case EGetVolume:
-            {
-            GetVolumeCompleteL();
-            }
-            break;
-
-        case ESetMute:
-            {
-            SetMuteCompleteL();
-            }
-            break;
-
-        case EGetMute:
-            {
-            GetMuteCompleteL();
-            }
-            break;
-
-        case EPositionInfo:
-            {
-            PositionInfoCompleteL();
-            }
-            break;
-            
-        case EStartMediaServer:
-            {
-            StartMediaServerCompleteL();
-            }
-            break;
-            
-        default:
-            __PANICD( __FILE__, __LINE__ );
-            break;            
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::DoCancel
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::DoCancel()
-    {
-    __LOG( "CUPnPAVRenderingActive::DoCancel" );
-    
-    switch( iPendingOperation )
-        {
-        case ESetURI:
-            {
-            iServer.CancelSetURI( iId );
-            }
-            break;
-
-        case ESetNextURI:
-            {
-            iServer.CancelSetNextURI( iId );
-            }
-            break;
-
-        case EPlay:
-            {
-            iServer.CancelPlay( iId );
-            }
-            break;
-
-        case EStop:
-            {
-            iServer.CancelStop( iId );
-            }
-            break;
-
-        case EPause:
-            {
-            iServer.CancelPause( iId );
-            }
-            break;
-
-        case ESetVolume:
-            {
-            iServer.CancelSetVolume( iId );
-            }
-            break;
-
-        case EGetVolume:
-            {
-            iServer.CancelGetVolume( iId );
-            }
-            break;
-
-        case ESetMute:
-            {
-            iServer.CancelSetMute( iId );
-            }
-            break;
-
-        case EGetMute:
-            {
-            iServer.CancelGetMute( iId );
-            }
-            break;
-
-        case EPositionInfo:
-            {
-            iServer.CancelGetPositionInfo( iId );
-            }
-            break;
-
-        case EStartMediaServer:
-            {
-            iServer.CancelReserveMediaServer( iId );
-            }
-            break;          
-                       
-        default:
-            __PANICD( __FILE__, __LINE__ );
-            break;            
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::RunError
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-TInt CUPnPAVRenderingActive::RunError( TInt /*aError*/ )
-    {
-    return KErrNone;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::SetObserver
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::SetObserver( 
-                                 MUPnPAVRenderingSessionObserver& aObserver )
-    {
-    // Set the observer and make an async request to the server to receive
-    // device callbacks
-    __ASSERTD( !iObserver, __FILE__, __LINE__ );
-
-        
-    iObserver = &aObserver;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::Observer
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-MUPnPAVRenderingSessionObserver* CUPnPAVRenderingActive::Observer() const
-    {
-    return iObserver;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::RemoveObserver
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::RemoveObserver()
-    {
-    iObserver = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::ReserveLocalMSServicesL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::ReserveLocalMSServicesL()
-    {
-    __LOG( "CUPnPAVRenderingActive::ReserveLocalMSServicesL" );
-    
-    ResetL();
-    
-    if( iMediaServerResourceReserved )
-        {
-        if( iObserver )
-            {
-            iObserver->ReserveLocalMSServicesCompleted( KErrNone );
-            }
-        }
-    else
-        {
-        iPendingOperation = EStartMediaServer;
-        iServer.ReserveMediaServer( iId, iStatus );
-        SetActive();    
-        
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::CancelReserveLocalMSServicesL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::CancelReserveLocalMSServicesL()
-    {
-    __LOG( "CUPnPAVRenderingActive::CancelReserveLocalMSServicesL" );
-    
-    if( iPendingOperation == EStartMediaServer )
-        {
-        Cancel();
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::ReleaseLocalMSServicesL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::ReleaseLocalMSServicesL()
-    {
-    __LOG( "CUPnPAVRenderingActive::ReleaseLocalMSServicesL" );
-    
-    ResetL();
-    
-    if( iMediaServerResourceReserved )
-        {
-        iMediaServerResourceReserved = EFalse;
-        
-        User::LeaveIfError( iServer.ReleaseMediaServer( iId ) );        
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::SetURIL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::SetURIL( const TDesC8& aURI,
-    const CUpnpItem& aItem )
-    {
-    __LOG( "CUPnPAVRenderingActive::SetURIL" );
-    
-    ResetL();
-        
-    CUpnpAVRequest* tempRequest = CUpnpAVRequest::NewLC();
-    tempRequest->SetURIL( aURI );
-    
-    iBuffer = tempRequest->ToDes8L();
-    iBufferPtr.Set( iBuffer->Des() );
-    
-    iBuffer2 = aItem.ToDes8L();
-    iBufferPtr2.Set( iBuffer2->Des() );
-    
-    CleanupStack::PopAndDestroy( tempRequest );
-
-    iPendingOperation = ESetURI;
-        
-    iServer.SetURI( iId, iBufferPtr, iBufferPtr2, iStatus );
-    SetActive();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::SetNextURIL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::SetNextURIL( const TDesC8& aURI,
-    const CUpnpItem& aItem )    
-    {
-    __LOG( "CUPnPAVRenderingActive::SetNextURIL" );
-    
-    ResetL();
-    
-    CUpnpAVRequest* tempRequest = CUpnpAVRequest::NewLC();
-    tempRequest->SetURIL( aURI );
-    
-    iBuffer = tempRequest->ToDes8L();
-    iBufferPtr.Set( iBuffer->Des() );
-
-    iBuffer2 = aItem.ToDes8L();
-    iBufferPtr2.Set( iBuffer2->Des() );
-    
-    CleanupStack::PopAndDestroy( tempRequest );
-            
-    iPendingOperation = ESetNextURI;
-    
-    iServer.SetNextURI( iId, iBufferPtr, iBufferPtr2, iStatus );
-    SetActive();        
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::PlayL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::PlayL()
-    {
-    __LOG( "CUPnPAVRenderingActive::PlayL" );
-    
-    ResetL();
-    iPendingOperation = EPlay;
-    iServer.Play( iId, iStatus );
-    SetActive();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::StopL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::StopL()
-    {
-    __LOG( "CUPnPAVRenderingActive::StopL" );
-    
-    ResetL();
-    iPendingOperation = EStop;
-    iServer.Stop( iId, iStatus );
-    SetActive();    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::PauseL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::PauseL()
-    {
-    __LOG( "CUPnPAVRenderingActive::PauseL" );
-    
-    ResetL();
-    iPendingOperation = EPause;
-    iServer.Pause( iId, iStatus );
-    SetActive();    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::SetVolumeL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::SetVolumeL( TInt aVolumeLevel )
-    {
-    __LOG( "CUPnPAVRenderingActive::SetVolumeL" );
-    
-    ResetL();
-    iPendingOperation = ESetVolume;
-    iServer.SetVolume( iId, aVolumeLevel, iRespBufSizePkg, iStatus );
-    SetActive();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::GetVolumeL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::GetVolumeL()
-    {
-    __LOG( "CUPnPAVRenderingActive::GetVolumeL" );
-    
-    ResetL();
-    iPendingOperation = EGetVolume;
-    iServer.GetVolume( iId, iRespBufSizePkg, iStatus );
-    SetActive();    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::SetMuteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::SetMuteL( TBool aMute )
-    {
-    __LOG( "CUPnPAVRenderingActive::SetMuteL" );
-    
-    ResetL();
-    iPendingOperation = ESetMute;
-    iServer.SetMute( iId, aMute, iRespBufSizePkg, iStatus );
-    SetActive();        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::NewL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::GetMuteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::GetMuteL" );
-    
-    ResetL();
-    iPendingOperation = EGetMute;
-    iServer.GetMute( iId, iRespBufSizePkg, iStatus );
-    SetActive();            
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::GetPositionInfoL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::GetPositionInfoL()
-    {
-    __LOG( "CUPnPAVRenderingActive::GetPositionInfoL" );
-    
-    ResetL();
-  
-    iBuffer = HBufC8::NewL( KPositionInfoSize );
-    iBufferPtr.Set( iBuffer->Des() );
-    iBuffer2 = HBufC8::NewL( KPositionInfoSize );
-    iBufferPtr2.Set( iBuffer2->Des() );
-    iPendingOperation = EPositionInfo;
-    iServer.GetPositionInfo( iId, iBufferPtr, iBufferPtr2, iStatus );
-    SetActive();                
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::ResetL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::ResetL()
-    {
-    __LOG( "CUPnPAVRenderingActive::ResetL" );
-    
-    if( IsActive() )
-        {
-        User::Leave( KErrServerBusy );
-        }
-
-    delete iBuffer; iBuffer = NULL;
-    delete iBuffer2; iBuffer2 = NULL;
-    iPendingOperation = ENone;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::SetURICompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::SetURICompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::SetURICompleteL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerSetURICompleted )
-            {
-            iObserver->SetURIResult( KErrNone );    
-            }
-        else
-            {
-            iObserver->SetURIResult( iStatus.Int() );    
-            }
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::SetNextURICompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::SetNextURICompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::SetNextURICompleteL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerSetNextURICompleted )
-            {
-            iObserver->SetNextURIResult( KErrNone );    
-            }
-        else
-            {
-            iObserver->SetNextURIResult( iStatus.Int() );    
-            }
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::PlayCompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::PlayCompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::PlayCompleteL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerPlayCompleted )
-            {
-            iObserver->InteractOperationComplete( KErrNone, EUPnPAVPlay );    
-            }
-        else
-            {
-            iObserver->InteractOperationComplete( iStatus.Int(), 
-                                                  EUPnPAVPlay ); 
-            }
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::StopCompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::StopCompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::StopCompleteL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerStopCompleted )
-            {
-            iObserver->InteractOperationComplete( KErrNone, EUPnPAVStop );    
-            }
-        else
-            {
-            iObserver->InteractOperationComplete( iStatus.Int(), 
-                                                  EUPnPAVStop ); 
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::PauseCompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::PauseCompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::PauseCompleteL" );
-
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerPauseCompleted )
-            {
-            iObserver->InteractOperationComplete( KErrNone,
-                                                  EUPnPAVPause );
-            }
-        else
-            {
-            iObserver->InteractOperationComplete( iStatus.Int(), 
-                                                  EUPnPAVPause );    
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::SetVolumeCompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::SetVolumeCompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::SetVolumeCompleteL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerSetVolumeCompleted )
-            {
-            iObserver->VolumeResult( KErrNone, iRespBufSize, ETrue );    
-            }
-        else
-            {
-            iObserver->VolumeResult( iStatus.Int(), 0, ETrue );
-            }
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::GetVolumeCompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::GetVolumeCompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::GetVolumeCompleteL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerGetVolumeCompleted )
-            {
-            iObserver->VolumeResult( KErrNone, iRespBufSize, ETrue );    
-            }
-        else
-            {
-            iObserver->VolumeResult( iStatus.Int(), 0, ETrue );
-            }
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::SetMuteCompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::SetMuteCompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::SetMuteCompleteL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerSetMuteCompleted )
-            {
-            iObserver->MuteResult( KErrNone, (TBool)iRespBufSize, ETrue );    
-            }
-        else
-            {
-            iObserver->MuteResult( iStatus.Int(), 0, ETrue );
-            }
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::GetMuteCompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::GetMuteCompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::GetMuteCompleteL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerGetMuteCompleted )
-            {
-            iObserver->MuteResult( KErrNone, iRespBufSize, ETrue );    
-            }
-        else
-            {
-            iObserver->MuteResult( iStatus.Int(), 0, ETrue );
-            }
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::PositionInfoCompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::PositionInfoCompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::PositionInfoCompleteL" );
-    
-    if( iObserver )
-        {
-        if( iStatus.Int() == EAVControllerPositionInfoCompleted )
-            {
-            iObserver->PositionInfoResult( KErrNone, *iBuffer2, *iBuffer );  
-            }
-        else
-            {
-            iObserver->PositionInfoResult( iStatus.Int(), 
-                                           KNullDesC8, 
-                                           KNullDesC8 );
-            }
-        }            
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingActive::StartMediaServerCompleteL
-// See upnpavrenderingactive.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingActive::StartMediaServerCompleteL()
-    {
-    __LOG( "CUPnPAVRenderingActive::StartMediaServerCompleteL" );
-    
-    if( iObserver )
-        {
-
-        if( iStatus.Int() == EAVControllerStartMediaServerCompleted )
-            {
-            iMediaServerResourceReserved = ETrue;
-            iObserver->ReserveLocalMSServicesCompleted( KErrNone );
-            }
-        else
-            {
-            iObserver->ReserveLocalMSServicesCompleted( iStatus.Int() );
-            }
-        
-        }
-    }    
-// end of file
+/*
+* Copyright (c) 2006-2009 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:      AO for rendering commands
+*
+*/
+
+
+
+
+
+#include <utf.h>
+
+#include "upnpavrenderingactive.h"
+
+#include "upnpavcontrollerclient.h"
+#include "upnpavrenderingsessionimpl.h"
+#include "upnpavrequest.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
+#include "upnplog.h"
+
+const TInt KPositionInfoSize = 15;
+static const TInt KSeekTargetMaxLength = 8; // "00:00:20" -> 8
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::NewL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+CUPnPAVRenderingActive* CUPnPAVRenderingActive::NewL(
+    RUPnPAVControllerClient& aServer, TInt aId )
+    {
+    CUPnPAVRenderingActive* self = new (ELeave) CUPnPAVRenderingActive(
+        aServer, aId );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::CUPnPAVRenderingActive
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+CUPnPAVRenderingActive::CUPnPAVRenderingActive(
+    RUPnPAVControllerClient& aServer, TInt aId ):
+    CActive( EPriorityStandard ),
+    iServer( aServer ),
+    iId( aId ),
+    iBufferPtr( 0, 0 ),
+    iBufferPtr2( 0, 0 ),
+    iRespBufSizePkg( iRespBufSize )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::~CUPnPAVRenderingActive
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+CUPnPAVRenderingActive::~CUPnPAVRenderingActive()
+    {
+    __LOG1( "CUPnPAVRenderingActive::~CUPnPAVRenderingActive %d", this );
+    
+    Cancel();
+    
+    delete iBuffer;
+    delete iBuffer2;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::ConstructL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::ConstructL()
+    {  
+    __LOG1( "CUPnPAVRenderingActive::ConstructL %d", this );  
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::RunL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::RunL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::RunL %d", this );
+    
+    switch( iPendingOperation )
+        {
+        case ESetURI:
+            {
+            SetURICompleteL();
+            }
+            break;
+
+        case ESetNextURI:
+            {
+            SetNextURICompleteL();
+            }
+            break;
+
+        case EPlay:
+            {
+            PlayCompleteL();
+            }
+            break;
+
+        case EStop:
+            {
+            StopCompleteL();
+            }
+            break;
+
+        case EPause:
+            {
+            PauseCompleteL();
+            }
+            break;
+
+        case ESetVolume:
+            {
+            SetVolumeCompleteL();
+            }
+            break;
+
+        case EGetVolume:
+            {
+            GetVolumeCompleteL();
+            }
+            break;
+
+        case ESetMute:
+            {
+            SetMuteCompleteL();
+            }
+            break;
+
+        case EGetMute:
+            {
+            GetMuteCompleteL();
+            }
+            break;
+
+        case EPositionInfo:
+            {
+            PositionInfoCompleteL();
+            }
+            break;
+            
+        case ESeekRelTime:
+            {
+            SeekRelTimeComplete();
+            }
+            break;
+            
+        default:
+            {
+            __PANICD( __FILE__, __LINE__ );
+            }
+            break;            
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::DoCancel
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::DoCancel()
+    {
+    __LOG1( "CUPnPAVRenderingActive::DoCancel %d", this );
+    
+    switch( iPendingOperation )
+        {
+        case ESetURI:
+            {
+            iServer.CancelSetURI( iId );
+            }
+            break;
+
+        case ESetNextURI:
+            {
+            iServer.CancelSetNextURI( iId );
+            }
+            break;
+
+        case EPlay:
+            {
+            iServer.CancelPlay( iId );
+            }
+            break;
+
+        case EStop:
+            {
+            iServer.CancelStop( iId );
+            }
+            break;
+
+        case EPause:
+            {
+            iServer.CancelPause( iId );
+            }
+            break;
+
+        case ESetVolume:
+            {
+            iServer.CancelSetVolume( iId );
+            }
+            break;
+
+        case EGetVolume:
+            {
+            iServer.CancelGetVolume( iId );
+            }
+            break;
+
+        case ESetMute:
+            {
+            iServer.CancelSetMute( iId );
+            }
+            break;
+
+        case EGetMute:
+            {
+            iServer.CancelGetMute( iId );
+            }
+            break;
+
+        case EPositionInfo:
+            {
+            iServer.CancelGetPositionInfo( iId );
+            }
+            break;
+                       
+        case ESeekRelTime:
+            {
+            iServer.CancelSeekRelTime( iId );
+            }
+            break;
+                       
+        default:
+            {
+            __PANICD( __FILE__, __LINE__ );
+            }
+            break;            
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::RunError
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+TInt CUPnPAVRenderingActive::RunError( TInt /*aError*/ )
+    {
+    return KErrNone;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SetObserver
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SetObserver( 
+                                 MUPnPAVRenderingSessionObserver& aObserver )
+    {
+    // Set the observer and make an async request to the server to receive
+    // device callbacks
+    __ASSERTD( !iObserver, __FILE__, __LINE__ );
+
+        
+    iObserver = &aObserver;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::Observer
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+MUPnPAVRenderingSessionObserver* CUPnPAVRenderingActive::Observer() const
+    {
+    return iObserver;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::RemoveObserver
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::RemoveObserver()
+    {
+    iObserver = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SetURIL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SetURIL( const TDesC8& aURI,
+    const CUpnpItem& aItem )
+    {
+    __LOG1( "CUPnPAVRenderingActive::SetURIL %d", this );
+    
+    ResetL();
+        
+    CUpnpAVRequest* tempRequest = CUpnpAVRequest::NewLC();
+    tempRequest->SetURIL( aURI );
+    
+    iBuffer = tempRequest->ToDes8L();
+    iBufferPtr.Set( iBuffer->Des() );
+    
+    iBuffer2 = aItem.ToDes8L();
+    iBufferPtr2.Set( iBuffer2->Des() );
+    
+    CleanupStack::PopAndDestroy( tempRequest );
+
+    iPendingOperation = ESetURI;
+        
+    iServer.SetURI( iId, iBufferPtr, iBufferPtr2, iStatus );
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SetNextURIL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SetNextURIL( const TDesC8& aURI,
+    const CUpnpItem& aItem )    
+    {
+    __LOG1( "CUPnPAVRenderingActive::SetNextURIL %d", this );
+    
+    ResetL();
+    
+    CUpnpAVRequest* tempRequest = CUpnpAVRequest::NewLC();
+    tempRequest->SetURIL( aURI );
+    
+    iBuffer = tempRequest->ToDes8L();
+    iBufferPtr.Set( iBuffer->Des() );
+
+    iBuffer2 = aItem.ToDes8L();
+    iBufferPtr2.Set( iBuffer2->Des() );
+    
+    CleanupStack::PopAndDestroy( tempRequest );
+            
+    iPendingOperation = ESetNextURI;
+    
+    iServer.SetNextURI( iId, iBufferPtr, iBufferPtr2, iStatus );
+    SetActive();        
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::PlayL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::PlayL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::PlayL %d", this );
+    
+    ResetL();
+    iPendingOperation = EPlay;
+    iServer.Play( iId, iStatus );
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::StopL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::StopL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::StopL %d", this );
+    
+    ResetL();
+    iPendingOperation = EStop;
+    iServer.Stop( iId, iStatus );
+    SetActive();    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::PauseL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::PauseL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::PauseL %d", this );
+    
+    ResetL();
+    iPendingOperation = EPause;
+    iServer.Pause( iId, iStatus );
+    SetActive();    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SetVolumeL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SetVolumeL( TInt aVolumeLevel )
+    {
+    __LOG1( "CUPnPAVRenderingActive::SetVolumeL %d", this );
+    
+    ResetL();
+    iPendingOperation = ESetVolume;
+    iServer.SetVolume( iId, aVolumeLevel, iRespBufSizePkg, iStatus );
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::GetVolumeL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::GetVolumeL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::GetVolumeL %d", this );
+    
+    ResetL();
+    iPendingOperation = EGetVolume;
+    iServer.GetVolume( iId, iRespBufSizePkg, iStatus );
+    SetActive();    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SetMuteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SetMuteL( TBool aMute )
+    {
+    __LOG1( "CUPnPAVRenderingActive::SetMuteL %d", this );
+    
+    ResetL();
+    iPendingOperation = ESetMute;
+    iServer.SetMute( iId, aMute, iRespBufSizePkg, iStatus );
+    SetActive();        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::NewL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::GetMuteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::GetMuteL %d", this );
+    
+    ResetL();
+    iPendingOperation = EGetMute;
+    iServer.GetMute( iId, iRespBufSizePkg, iStatus );
+    SetActive();            
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::GetPositionInfoL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::GetPositionInfoL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::GetPositionInfoL %d", this );
+    
+    ResetL();
+  
+    iBuffer = HBufC8::NewL( KPositionInfoSize );
+    iBufferPtr.Set( iBuffer->Des() );
+    iBuffer2 = HBufC8::NewL( KPositionInfoSize );
+    iBufferPtr2.Set( iBuffer2->Des() );
+    iPendingOperation = EPositionInfo;
+    iServer.GetPositionInfo( iId, iBufferPtr, iBufferPtr2, iStatus );
+    SetActive();                
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SeekRelTimeL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SeekRelTimeL( const TTime& aDesiredTime ) 
+    {
+    __LOG1( "CUPnPAVRenderingActive::SeekRelTimeL %d", this );
+    
+    ResetL();
+  
+    _LIT16( KHourMinSecFormatString, "%:0%*H%:1%T%:2%S%:3" ); //Current value equals to R_QTN_TIME_DURAT_LONG.
+    TBuf<KSeekTargetMaxLength> desiredTimeString;
+    aDesiredTime.FormatL( desiredTimeString, KHourMinSecFormatString );
+
+    iBuffer = CnvUtfConverter::ConvertFromUnicodeToUtf8L( desiredTimeString );
+    iBufferPtr.Set( iBuffer->Des() );
+    iPendingOperation = ESeekRelTime;
+    iServer.SeekRelTime( iId, iBufferPtr, iStatus );
+    SetActive();   
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::ResetL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::ResetL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::ResetL %d", this );
+    
+    if( IsActive() )
+        {
+        User::Leave( KErrServerBusy );
+        }
+
+    delete iBuffer; iBuffer = NULL;
+    delete iBuffer2; iBuffer2 = NULL;
+    iPendingOperation = ENone;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SetURICompleteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SetURICompleteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::SetURICompleteL %d", this );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerSetURICompleted )
+            {
+            iObserver->SetURIResult( KErrNone );    
+            }
+        else
+            {
+            iObserver->SetURIResult( iStatus.Int() );    
+            }
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SetNextURICompleteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SetNextURICompleteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::SetNextURICompleteL %d", this );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerSetNextURICompleted )
+            {
+            iObserver->SetNextURIResult( KErrNone );    
+            }
+        else
+            {
+            iObserver->SetNextURIResult( iStatus.Int() );    
+            }
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::PlayCompleteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::PlayCompleteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::PlayCompleteL %d", this );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerPlayCompleted )
+            {
+            iObserver->InteractOperationComplete( KErrNone, EUPnPAVPlay );    
+            }
+        else
+            {
+            iObserver->InteractOperationComplete( iStatus.Int(), 
+                                                  EUPnPAVPlay ); 
+            }
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::StopCompleteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::StopCompleteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::StopCompleteL %d", this );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerStopCompleted )
+            {
+            iObserver->InteractOperationComplete( KErrNone, EUPnPAVStop );    
+            }
+        else
+            {
+            iObserver->InteractOperationComplete( iStatus.Int(), 
+                                                  EUPnPAVStop ); 
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::PauseCompleteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::PauseCompleteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::PauseCompleteL %d", this );
+
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerPauseCompleted )
+            {
+            iObserver->InteractOperationComplete( KErrNone,
+                                                  EUPnPAVPause );
+            }
+        else
+            {
+            iObserver->InteractOperationComplete( iStatus.Int(), 
+                                                  EUPnPAVPause );    
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SetVolumeCompleteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SetVolumeCompleteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::SetVolumeCompleteL %d", this );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerSetVolumeCompleted )
+            {
+            iObserver->VolumeResult( KErrNone, iRespBufSize, ETrue );    
+            }
+        else
+            {
+            iObserver->VolumeResult( iStatus.Int(), 0, ETrue );
+            }
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::GetVolumeCompleteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::GetVolumeCompleteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::GetVolumeCompleteL %d", this );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerGetVolumeCompleted )
+            {
+            iObserver->VolumeResult( KErrNone, iRespBufSize, ETrue );    
+            }
+        else
+            {
+            iObserver->VolumeResult( iStatus.Int(), 0, ETrue );
+            }
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SetMuteCompleteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SetMuteCompleteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::SetMuteCompleteL %d", this );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerSetMuteCompleted )
+            {
+            iObserver->MuteResult( KErrNone, (TBool)iRespBufSize, ETrue );    
+            }
+        else
+            {
+            iObserver->MuteResult( iStatus.Int(), 0, ETrue );
+            }
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::GetMuteCompleteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::GetMuteCompleteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::GetMuteCompleteL %d", this );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerGetMuteCompleted )
+            {
+            iObserver->MuteResult( KErrNone, iRespBufSize, ETrue );    
+            }
+        else
+            {
+            iObserver->MuteResult( iStatus.Int(), 0, ETrue );
+            }
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::PositionInfoCompleteL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::PositionInfoCompleteL()
+    {
+    __LOG1( "CUPnPAVRenderingActive::PositionInfoCompleteL %d", this );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerPositionInfoCompleted )
+            {
+            iObserver->PositionInfoResult( KErrNone, *iBuffer2, *iBuffer );  
+            }
+        else
+            {
+            iObserver->PositionInfoResult( iStatus.Int(), 
+                                           KNullDesC8, 
+                                           KNullDesC8 );
+            }
+        }            
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::SeekRelTimeComplete
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingActive::SeekRelTimeComplete()
+    {
+    __LOG1( "CUPnPAVRenderingActive::SeekRelTimeCompleteL %d", this );
+    
+    if( iObserver )
+        {
+        if( iStatus.Int() == EAVControllerSeekCompleted )
+            {
+            iObserver->InteractOperationComplete( KErrNone, EUPnPAVSeek );    
+            }
+        else
+            {
+            iObserver->InteractOperationComplete( iStatus.Int(),EUPnPAVSeek); 
+            }
+        }
+    }
+
+// end of file
--- a/upnpavcontroller/upnpavcontrollerclient/src/upnpavrenderingsessionimpl.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/src/upnpavrenderingsessionimpl.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,415 +1,440 @@
-/*
-* Copyright (c) 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:      implements a session towards a renderer
-*
-*/
-
-
-
-
-
-
-// INCLUDES
-// upnp stack api
-#include <upnpitem.h>
-#include <upnpobjectlist.h>
-
-// upnpframework / avcontroller api
-#include "upnpavdevice.h"
-#include "upnpavcontrollerglobals.h"
-#include "upnpavrenderingsessionobserver.h"
-
-// avcontroller internal
-#include "upnpaveventactive.h"
-#include "upnpavcontrollerclient.h"
-#include "upnpavdeviceactive.h"
-#include "upnpavrenderingactive.h"
-#include "upnpavrenderingsessionimpl.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
-#include "upnplog.h"
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::CUPnPAVRenderingSessionImpl
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-CUPnPAVRenderingSessionImpl* CUPnPAVRenderingSessionImpl::NewL( 
-                                            RUPnPAVControllerClient& aServer, 
-                                            const CUpnpAVDevice& aDevice )
-    {
-    CUPnPAVRenderingSessionImpl* self = 
-                        new (ELeave) CUPnPAVRenderingSessionImpl( aServer );
-    CleanupStack::PushL( self );
-    self->iDevice = CUpnpAVDevice::NewL( aDevice );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::CUPnPAVRenderingSessionImpl
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-CUPnPAVRenderingSessionImpl::CUPnPAVRenderingSessionImpl( 
-                                        RUPnPAVControllerClient& aServer ):
-    iServer( aServer ),
-    iBufferPtr( 0, 0 ),
-    iAlive( ETrue )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::~CUPnPAVRenderingSessionImpl
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-CUPnPAVRenderingSessionImpl::~CUPnPAVRenderingSessionImpl()
-    {
-    __LOG( "CUPnPAVRenderingSessionImpl::~CUPnPAVRenderingSessionImpl" );
-    
-    delete iDevice;
-    delete iEventActive;
-    delete iCommandActive;
-    delete iSettingActive;
-    delete iDeviceActive;
-    delete iBuffer; 
-
-    iServer.DestroyRenderingSession( (TInt)this );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::ConstructL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::ConstructL()
-    {
-    __LOG( "CUPnPAVRenderingSessionImpl::ConstructL" );
-    
-    iBuffer = iDevice->Uuid().AllocL();
-    iBufferPtr.Set( iBuffer->Des() );
-    User::LeaveIfError( iServer.CreateRenderingSession( (TInt)this , 
-                                                        iBufferPtr ) );
-    iEventActive = CUPnPAVEventActive::NewL( iServer, *this );
-    iCommandActive = CUPnPAVRenderingActive::NewL( iServer, (TInt)this );
-    iSettingActive = CUPnPAVRenderingActive::NewL( iServer, (TInt)this );
-    iDeviceActive = CUPnPAVDeviceActive::NewL( iServer, *this );
-    iDeviceActive->StartListening( (TInt)this );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::SetObserver
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::SetObserver( 
-                                 MUPnPAVRenderingSessionObserver& aObserver )
-    {
-    // Set the observer and make an async request to the server to receive
-    // device callbacks
-    __ASSERTD( !iObserver, __FILE__, __LINE__ );
-
-    iEventActive->StartListeningEvents( (TInt)this );        
-        
-    iObserver = &aObserver;
-    iCommandActive->SetObserver( aObserver );
-    iSettingActive->SetObserver( aObserver );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::Observer
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-MUPnPAVRenderingSessionObserver* CUPnPAVRenderingSessionImpl::Observer() const
-    {
-    return iObserver;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::RemoveObserver
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::RemoveObserver()
-    {
-    iObserver = NULL;
-    iCommandActive->RemoveObserver();
-    iSettingActive->RemoveObserver();    
-    iEventActive->Cancel();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::Device
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-const CUpnpAVDevice& CUPnPAVRenderingSessionImpl::Device() const
-    {
-    return *iDevice;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::ReserveLocalMSServicesL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::ReserveLocalMSServicesL()
-    {  
-    ResetL();
-    
-    iCommandActive->ReserveLocalMSServicesL();       
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::CancelReserveLocalMSServicesL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::CancelReserveLocalMSServicesL()
-    {
-    ResetL();
-    
-    iCommandActive->CancelReserveLocalMSServicesL();  
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::ReleaseLocalMSServicesL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::ReleaseLocalMSServicesL()
-    {  
-    ResetL();
-    
-    iCommandActive->ReleaseLocalMSServicesL();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::SetURIL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::SetURIL( const TDesC8& aURI,
-    const CUpnpItem& aItem )
-    {
-    ResetL();
-    
-    iCommandActive->SetURIL( aURI, aItem );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::SetNextURIL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::SetNextURIL( const TDesC8& aURI,
-    const CUpnpItem& aItem )    
-    {
-    ResetL();
-    
-    iCommandActive->SetNextURIL( aURI, aItem );     
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::PlayL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::PlayL()
-    {
-    ResetL();
-    
-    iCommandActive->PlayL();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::StopL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::StopL()
-    {
-    ResetL();
-    
-    iCommandActive->StopL(); 
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::PauseL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::PauseL()
-    {
-    ResetL();
-    
-    iCommandActive->PauseL();   
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::SetVolumeL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::SetVolumeL( TInt aVolumeLevel )
-    {
-    ResetL();
-    
-    iSettingActive->SetVolumeL( aVolumeLevel );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::GetVolumeL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::GetVolumeL()
-    {
-    ResetL();
-    
-    iSettingActive->GetVolumeL();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::SetMuteL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::SetMuteL( TBool aMute )
-    {
-    ResetL();
-    
-    iSettingActive->SetMuteL( aMute );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::GetMuteL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::GetMuteL()
-    {
-    ResetL();
-    
-    iSettingActive->GetMuteL();           
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::GetPositionInfoL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::GetPositionInfoL()
-    {
-    ResetL();
-    
-    iSettingActive->GetPositionInfoL();               
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::UPnPDeviceDiscovered
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::UPnPDeviceDiscovered( 
-                                        const CUpnpAVDevice& /*aDevice*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::UPnPDeviceDisappeared
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::UPnPDeviceDisappeared( 
-                                        const CUpnpAVDevice& /*aDevice*/ )
-    {
-    __LOG( "CUPnPAVRenderingSessionImpl::UPnPDeviceDisappeared" );
-    
-    iAlive = EFalse;
-    if( iObserver )
-        {
-        iObserver->MediaRendererDisappeared(
-            MUPnPAVSessionObserverBase::EDisconnected );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::WLANConnectionLost
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::WLANConnectionLost()
-    {
-    __LOG( "CUPnPAVRenderingSessionImpl::WLANConnectionLost" );
-    
-    iAlive = EFalse;
-    if( iObserver )    
-        {
-        iObserver->MediaRendererDisappeared(
-            MUPnPAVSessionObserverBase::EWLANLost );
-        }
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::EventReceived
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::EventReceived( TInt aError,
-    TUnsolicitedEventC aEvent )
-    {
-    if( iObserver )
-        {
-        switch( aEvent.iEvent )
-            {
-            case EPlay:
-                {
-                iObserver->InteractOperationComplete( aError,
-                    EUPnPAVPlayUser );
-                break;
-                }
-            case EPause:
-                {
-                iObserver->InteractOperationComplete( aError,
-                    EUPnPAVPauseUser );                
-                break;
-                }
-            case EStop:
-                {
-                iObserver->InteractOperationComplete( aError,
-                    EUPnPAVStopUser );                
-                break;
-                }
-            case EVolume:
-                {
-                iObserver->VolumeResult( aError, aEvent.iValue, EFalse );
-                break;
-                }
-            case EMute:
-                {
-                iObserver->MuteResult( aError, (TBool)aEvent.iValue,
-                    EFalse );
-                break;
-                }
-            default:
-                {
-                __PANICD( __FILE__, __LINE__ );
-                break;
-                }    
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVRenderingSessionImpl::ResetL
-// See upnpavrenderingsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVRenderingSessionImpl::ResetL()
-    {
-    __LOG( "CUPnPAVRenderingSessionImpl::ResetL" );
-    
-    if( !iAlive )
-        {
-        __LOG( "ResetL - disconnected, leave " );
-        User::Leave( KErrDisconnected );        
-        }
-
-    delete iBuffer; iBuffer = NULL;
-    }
-
-// end of file
+/*
+* Copyright (c) 2006-2009 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:      implements a session towards a renderer
+*
+*/
+
+
+
+
+
+
+// INCLUDES
+// dlnasrv / mediaserver api
+#include <upnpitem.h>
+#include <upnpobjectlist.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavdevice.h"
+#include "upnpavcontrollerglobals.h"
+#include "upnpavrenderingsessionobserver.h"
+
+// avcontroller internal
+#include "upnpaveventactive.h"
+#include "upnpavcontrollerclient.h"
+#include "upnpavdeviceactive.h"
+#include "upnpavrenderingactive.h"
+#include "upnpavrenderingsessionimpl.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
+#include "upnplog.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::CUPnPAVRenderingSessionImpl
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+CUPnPAVRenderingSessionImpl* CUPnPAVRenderingSessionImpl::NewL( 
+                                            RUPnPAVControllerClient& aServer, 
+                                            const CUpnpAVDevice& aDevice )
+    {
+    CUPnPAVRenderingSessionImpl* self = 
+                        new (ELeave) CUPnPAVRenderingSessionImpl( aServer );
+    CleanupStack::PushL( self );
+    self->iDevice = CUpnpAVDevice::NewL( aDevice );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::CUPnPAVRenderingSessionImpl
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+CUPnPAVRenderingSessionImpl::CUPnPAVRenderingSessionImpl( 
+                                        RUPnPAVControllerClient& aServer ):
+    iServer( aServer ),
+    iBufferPtr( 0, 0 ),
+    iAlive( ETrue )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::~CUPnPAVRenderingSessionImpl
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+CUPnPAVRenderingSessionImpl::~CUPnPAVRenderingSessionImpl()
+    {
+    __LOG( "CUPnPAVRenderingSessionImpl::~CUPnPAVRenderingSessionImpl" );
+    
+    delete iDevice;
+    delete iEventActive;
+    delete iCommandActive;
+    delete iSettingActive;
+    delete iDeviceActive;
+    delete iBuffer; 
+
+    iServer.DestroyRenderingSession( (TInt)this );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::ConstructL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::ConstructL()
+    {
+    __LOG( "CUPnPAVRenderingSessionImpl::ConstructL" );
+    
+    iBuffer = iDevice->Uuid().AllocL();
+    iBufferPtr.Set( iBuffer->Des() );
+    User::LeaveIfError( iServer.CreateRenderingSession( (TInt)this , 
+                                                        iBufferPtr ) );
+    iEventActive = CUPnPAVEventActive::NewL( iServer, *this );
+    iCommandActive = CUPnPAVRenderingActive::NewL( iServer, (TInt)this );
+    iSettingActive = CUPnPAVRenderingActive::NewL( iServer, (TInt)this );
+    iDeviceActive = CUPnPAVDeviceActive::NewL( iServer, *this );
+    iDeviceActive->StartListening( (TInt)this );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::SetObserver
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::SetObserver( 
+                                 MUPnPAVRenderingSessionObserver& aObserver )
+    {
+    // Set the observer and make an async request to the server to receive
+    // device callbacks
+    __ASSERTD( !iObserver, __FILE__, __LINE__ );
+
+    iEventActive->StartListeningEvents( (TInt)this );        
+        
+    iObserver = &aObserver;
+    iCommandActive->SetObserver( aObserver );
+    iSettingActive->SetObserver( aObserver );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::Observer
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+MUPnPAVRenderingSessionObserver* CUPnPAVRenderingSessionImpl::Observer() const
+    {
+    return iObserver;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::RemoveObserver
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::RemoveObserver()
+    {
+    iObserver = NULL;
+    iCommandActive->RemoveObserver();
+    iSettingActive->RemoveObserver();    
+    iEventActive->Cancel();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::Device
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+const CUpnpAVDevice& CUPnPAVRenderingSessionImpl::Device() const
+    {
+    return *iDevice;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::SetURIL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::SetURIL( const TDesC8& aURI,
+    const CUpnpItem& aItem )
+    {
+    ResetL();
+    
+    iCommandActive->SetURIL( aURI, aItem );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::SetNextURIL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::SetNextURIL( const TDesC8& aURI,
+    const CUpnpItem& aItem )    
+    {
+    ResetL();
+    
+    iCommandActive->SetNextURIL( aURI, aItem );     
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::PlayL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::PlayL()
+    {
+    ResetL();
+    
+    iCommandActive->PlayL();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::StopL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::StopL()
+    {
+    ResetL();
+    
+    iCommandActive->StopL(); 
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::PauseL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::PauseL()
+    {
+    ResetL();
+    
+    iCommandActive->PauseL();   
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::SetVolumeL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::SetVolumeL( TInt aVolumeLevel )
+    {
+    ResetL();
+    
+    iSettingActive->SetVolumeL( aVolumeLevel );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::GetVolumeL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::GetVolumeL()
+    {
+    ResetL();
+    
+    iSettingActive->GetVolumeL();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::SetMuteL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::SetMuteL( TBool aMute )
+    {
+    ResetL();
+    
+    iSettingActive->SetMuteL( aMute );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::GetMuteL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::GetMuteL()
+    {
+    ResetL();
+    
+    iSettingActive->GetMuteL();           
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::GetPositionInfoL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::GetPositionInfoL()
+    {
+    ResetL();
+    
+    iCommandActive->GetPositionInfoL();               
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::SeekRelTimeL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::SeekRelTimeL( const TTime& aDesiredTime ) 
+    {
+    ResetL();
+    
+    iCommandActive->SeekRelTimeL( aDesiredTime );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingActive::GetRendererStateL
+// See upnpavrenderingactive.h
+// --------------------------------------------------------------------------
+TUPnPAVInteractOperation CUPnPAVRenderingSessionImpl::GetRendererStateL()
+    {
+    __LOG( "CUPnPAVRenderingSessionImpl::GetRendererStateL" );
+    
+    ResetL();
+    
+    TUnsolicitedEventE event;
+    TPckg<TUnsolicitedEventE> pckg( event );
+    User::LeaveIfError( iServer.GetRendererState( (TInt)this, pckg ) );
+    
+    TUPnPAVInteractOperation op( EUPnPAVStopUser );
+    switch( event )
+        {
+        case EPlay:
+            {
+            op = EUPnPAVPlayUser;
+            }
+            break;       
+        case EStop:
+            {
+            op = EUPnPAVStopUser;
+            }
+            break;       
+        case EPause:
+            {
+            op = EUPnPAVPauseUser;
+            }
+            break;    
+        default:
+            {
+            __PANIC( __FILE__, __LINE__ );
+            }
+        }
+    
+    return op;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::UPnPDeviceDiscovered
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::UPnPDeviceDiscovered( 
+                                        const CUpnpAVDevice& /*aDevice*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::UPnPDeviceDisappeared
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::UPnPDeviceDisappeared( 
+                                        const CUpnpAVDevice& /*aDevice*/ )
+    {
+    __LOG( "CUPnPAVRenderingSessionImpl::UPnPDeviceDisappeared" );
+    
+    iAlive = EFalse;
+    if( iObserver )
+        {
+        iObserver->MediaRendererDisappeared(
+            MUPnPAVSessionObserverBase::EDisconnected );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::WLANConnectionLost
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::WLANConnectionLost()
+    {
+    __LOG( "CUPnPAVRenderingSessionImpl::WLANConnectionLost" );
+    
+    iAlive = EFalse;
+    if( iObserver )    
+        {
+        iObserver->MediaRendererDisappeared(
+            MUPnPAVSessionObserverBase::EWLANLost );
+        }
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::EventReceived
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::EventReceived( TInt aError,
+    TUnsolicitedEventC aEvent )
+    {
+    if( iObserver )
+        {
+        switch( aEvent.iEvent )
+            {
+            case EPlay:
+                {
+                iObserver->InteractOperationComplete( aError,
+                    EUPnPAVPlayUser );
+                break;
+                }
+            case EPause:
+                {
+                iObserver->InteractOperationComplete( aError,
+                    EUPnPAVPauseUser );                
+                break;
+                }
+            case EStop:
+                {
+                iObserver->InteractOperationComplete( aError,
+                    EUPnPAVStopUser );                
+                break;
+                }
+            case EVolume:
+                {
+                iObserver->VolumeResult( aError, aEvent.iValue, EFalse );
+                break;
+                }
+            case EMute:
+                {
+                iObserver->MuteResult( aError, (TBool)aEvent.iValue,
+                    EFalse );
+                break;
+                }
+            case ETransition:
+                {
+                iObserver->InteractOperationComplete( aEvent.iValue,
+                    EUPnPAVTransition );                
+                break;
+                }
+            default:
+                {
+                __PANICD( __FILE__, __LINE__ );
+                break;
+                }    
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVRenderingSessionImpl::ResetL
+// See upnpavrenderingsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVRenderingSessionImpl::ResetL()
+    {
+    __LOG( "CUPnPAVRenderingSessionImpl::ResetL" );
+    
+    if( !iAlive )
+        {
+        __LOG( "ResetL - disconnected, leave " );
+        User::Leave( KErrDisconnected );        
+        }
+
+    delete iBuffer; iBuffer = NULL;
+    }
+
+// end of file
--- a/upnpavcontroller/upnpavcontrollerclient/src/upnpfiledownloadsessionimpl.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/src/upnpfiledownloadsessionimpl.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,442 +1,452 @@
-/*
-* Copyright (c) 2007 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:      Implements download session
-*
-*/
-
-
-
-
-
-
-// INTERNAL INCLUDES
-// upnp stack api
-#include <upnpitem.h>
-#include <upnpelement.h>
-#include <upnpstring.h>
-
-// upnpframework / avcontroller api
-#include "upnpavdevice.h"
-#include "upnpfiletransfersessionobserver.h"
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h" // for upnp-specific stuff
-#include "upnpitemutility.h" // FindAttributeByName
-#include "upnpfileutility.h" // FitsInMemory
-
-// avcontroller internal
-#include "upnpfiledownloadsessionimpl.h"
-#include "upnpavcontrollerclient.h"
-#include "upnpfiletransferitem.h"
-
-// EXTERNAL INCLUDES
-
-_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
-#include "upnplog.h"
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::NewL
-// Two-phase construction
-// --------------------------------------------------------------------------
-CUPnPFileDownloadSessionImpl* CUPnPFileDownloadSessionImpl::NewL(
-    RUPnPAVControllerClient& aServer, const CUpnpAVDevice& aDevice )
-    {
-    CUPnPFileDownloadSessionImpl* self = new (ELeave)
-        CUPnPFileDownloadSessionImpl( aServer );
-    CleanupStack::PushL( self );
-    self->iDevice = CUpnpAVDevice::NewL( aDevice );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::CUPnPFileDownloadSessionImpl
-// Constructor
-// --------------------------------------------------------------------------
-CUPnPFileDownloadSessionImpl::CUPnPFileDownloadSessionImpl(
-    RUPnPAVControllerClient& aServer ) :
-    CActive( EPriorityStandard ),
-    iServer( aServer ),
-    iBufferPtr( 0, 0 ),
-    iBufferPtr2( 0, 0 ),
-    iAlive( ETrue ),
-    iEventPkg( iEvent )
-    {
-    CActiveScheduler::Add( this );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::~CUPnPFileDownloadSessionImpl
-// Destructor
-// --------------------------------------------------------------------------
-CUPnPFileDownloadSessionImpl::~CUPnPFileDownloadSessionImpl()
-    {
-    __LOG( "CUPnPFileDownloadSessionImpl::~CUPnPFileDownloadSessionImpl" );
-    
-    CancelAllTransfers();
-    
-    Cancel();
-    iServer.DestroyDownloadSession( (TInt)this );
-    
-    delete iDevice;
-    delete iBuffer;
-    delete iBuffer2;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::ConstructL
-// Two-phase construction
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::ConstructL()
-    {
-    __LOG( "CUPnPFileDownloadSessionImpl::ConstructL" );
-    
-    iBuffer = iDevice->Uuid().AllocL();
-    iBufferPtr.Set( iBuffer->Des() );
-    User::LeaveIfError( iServer.CreateDownloadSession(
-        (TInt)this , iBufferPtr ) );
-    
-    iBuffer2 = HBufC::NewL( KMaxPath );
-    iBufferPtr2.Set( iBuffer2->Des() );    
-    iServer.GetDownloadEvent( (TInt)this, iEventPkg, iStatus, iBufferPtr2 );
-    SetActive();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::ConstructL
-// From CActive
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::RunL()
-    {
-    __LOG( "CUPnPFileDownloadSessionImpl::RunL" );
-
-    TUpnpFileTransferEvent event = iEvent;
-
-    if( iStatus.Int() == KErrNone )
-        {
-        __LOG( "RunL - Activate again" );
-
-        iServer.GetDownloadEvent( (TInt)this, iEventPkg, iStatus,
-            iBufferPtr2 );
-        SetActive();        
-        }
-    else
-        {
-        __LOG1( "RunL - %d", iStatus.Int() );      
-        }              
-    
-    // Handle event and activate again
-    switch( event.iEvent )
-        {
-        case TUpnpFileTransferEvent::ETransferStarted:
-            {
-            if( iObserver )
-                {
-                __LOG( "RunL - ETransferStarted" );
-                
-                // iKey - 1 since it's incremented when we request the
-                // download. The reason behind of this is the fact that
-                // httptransfer does not accept value 0 which is legal from
-                // the API point of view
-                iObserver->TransferStarted( event.iKey - 1,
-                    event.iStatus );
-                }
-            break;
-            }
-
-        case TUpnpFileTransferEvent::ETransferCompleted:
-            {
-            if( iObserver )
-                {
-                __LOG( "RunL - ETransferCompleted" );
-                
-                iObserver->TransferCompleted( event.iKey - 1,
-                    event.iStatus, *iBuffer2 );   
-                }                  
-            break;
-            }
-            
-        case TUpnpFileTransferEvent::ETransferProgress:
-            {
-            if( iObserver )
-                {
-                __LOG( "RunL - ETransferProgress" );
-                
-                iObserver->TransferProgress( event.iKey - 1,
-                    event.iParam1, event.iParam2 );
-                }                  
-            break;
-            }
-            
-        case TUpnpFileTransferEvent::EDeviceDisconnected:
-            {
-            CUpnpAVDevice* tmpDev = NULL;
-            UPnPDeviceDisappeared( *tmpDev );
-            break;
-            }
-            
-        default:
-            {
-            __LOG( "RunL - default!" );      
-            break;
-            }
-        
-        }        
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::DoCancel
-// From CActive
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::DoCancel()
-    {
-    __LOG( "CUPnPFileDownloadSessionImpl::DoCancel" );
-    
-    iServer.CancelDownloadEvent( (TInt)this );
-    
-    __LOG( "CUPnPFileDownloadSessionImpl::DoCancel - end" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::RunError
-// From CActive
-// --------------------------------------------------------------------------
-TInt CUPnPFileDownloadSessionImpl::RunError( TInt /*aError*/ )
-    {
-    __LOG( "CUPnPFileDownloadSessionImpl::RunError" );
-    
-    return KErrNone;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::StartDownloadL
-// From CActive
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::StartDownloadL(
-    const CUpnpItem& aItem, TInt aKey )
-    {
-    __LOG( "CUPnPFileDownloadSessionImpl::StartDownloadL" );
-    
-    ResetL();
-
-    CUpnpFileTransferItem* item = CUpnpFileTransferItem::NewLC();
-    item->SetTitleL( aItem.Title() );
-    // aKey + 1 
-    // the reason behind of this is the fact that httptransfer
-    // does not accept value 0 which is legal from the API point
-    // of view.    
-    item->SetKey( aKey + 1 );
-
-    // Get the most suitable (original) res-element from the item
-    const CUpnpElement& tmpEl = UPnPItemUtility::ResourceFromItemL( 
-        aItem );
-    
-    if( !UPnPFileUtility::FitsInMemory( tmpEl ) )
-        {
-        User::Leave( KErrDiskFull );
-        }
-
-    item->SetUriL( tmpEl.Value() );    
-
-    // Get the protocolinfo-attribute
-    const CUpnpAttribute* tmpPInfo = UPnPItemUtility::FindAttributeByName(
-        tmpEl, KAttributeProtocolInfo );
-    if( tmpPInfo )
-        {
-        item->SetProtocolInfoL( tmpPInfo->Value() );
-        }
-    else
-        {
-        User::Leave( KErrArgument );
-        }    
-
-    iBuffer = item->ToDes8L();
-    iBufferPtr.Set( iBuffer->Des() );
-    
-    CleanupStack::PopAndDestroy( item );
-    
-    User::LeaveIfError( iServer.StartDownload( (TInt)this, iBufferPtr ) );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::StartDownloadL
-// See upnpfiledownloadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::StartDownloadL( 
-    const CUpnpElement& aResElement, const CUpnpItem& aItem,
-    RFile& aFile, TInt aKey )
-    {
-    __LOG( "CUPnPFileDownloadSessionImpl::StartDownloadL" );
-    
-    ResetL();
-
-    CUpnpFileTransferItem* item = CUpnpFileTransferItem::NewLC();
-    item->SetTitleL( aItem.Title() );
-    item->SetUriL( aResElement.Value() );
-    item->SetKey( aKey + 1 );
-
-    const CUpnpAttribute* pInfo = UPnPItemUtility::FindAttributeByName(
-        aResElement, KAttributeProtocolInfo );
-    if( pInfo )
-        {
-        item->SetProtocolInfoL( pInfo->Value() );
-        }
-    else
-        {
-        User::Leave( KErrArgument );
-        }   
-
-    iBuffer = item->ToDes8L();
-    iBufferPtr.Set( iBuffer->Des() );
-    
-    CleanupStack::PopAndDestroy( item );
-    
-    User::LeaveIfError( iServer.StartDownload( (TInt)this, iBufferPtr,
-        aFile ) );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::SetObserver
-// See upnpfiledownloadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::SetObserver(
-    MUPnPFileTransferSessionObserver& aObserver )
-    {
-    __LOG( "CUPnPFileDownloadSessionImpl::SetObserver" );
-    
-    iObserver = &aObserver;
-    }
-     
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::RemoveObserver
-// See upnpfiledownloadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::RemoveObserver()
-    {
-    iObserver = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::Observer
-// See upnpfiledownloadsessionimpl.h
-// --------------------------------------------------------------------------
-MUPnPFileTransferSessionObserver* CUPnPFileDownloadSessionImpl::Observer()
-    const
-    {
-    return iObserver;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::StartTrackingProgressL
-// See upnpfiledownloadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::StartTrackingProgressL( TInt aKey )
-    {
-    ResetL();
-    User::LeaveIfError( iServer.StartTrackingDownloadProgress(
-        (TInt)this, aKey + 1 ) );
-                   
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::CancelTransfer
-// See upnpfiledownloadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::CancelTransfer( TInt aKey )
-    {
-    iServer.CancelDownload( (TInt)this, aKey + 1 ); // Ignore error
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::CancelAllTransfers
-// See upnpfiledownloadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::CancelAllTransfers()
-    {
-    iServer.CancelAllDownloads( (TInt)this ); // Ignore error
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::UPnPDeviceDiscovered
-// Device discovered
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::UPnPDeviceDiscovered(
-    const CUpnpAVDevice& /*aDevice*/ )
-    {
-    // No implementation needed
-    }
-
-  
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::UPnPDeviceDisappeared
-// Device disappeared
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::UPnPDeviceDisappeared(
-    const CUpnpAVDevice& /*aDevice*/ )
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::UPnPDeviceDisappeared" );
-    
-    iAlive = EFalse;
-    if( iObserver )
-        {
-        iObserver->MediaServerDisappeared( 
-            MUPnPAVSessionObserverBase::EDisconnected );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::WLANConnectionLost
-// Connection lost
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::WLANConnectionLost()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::WLANConnectionLost" );
-    
-    iAlive = EFalse;
-    if( iObserver )    
-        {
-        iObserver->MediaServerDisappeared( 
-            MUPnPAVSessionObserverBase::EWLANLost );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::Device
-// Returns used device
-// --------------------------------------------------------------------------
-const CUpnpAVDevice& CUPnPFileDownloadSessionImpl::Device() const
-    {
-    return *iDevice;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileDownloadSessionImpl::ResetL
-// Reset
-// --------------------------------------------------------------------------
-void CUPnPFileDownloadSessionImpl::ResetL()
-    {
-    __LOG( "CUPnPFileDownloadSessionImpl::ResetL" );
-    
-    if( !iAlive )
-        {
-        User::Leave( KErrDisconnected );
-        }
-
-    delete iBuffer; iBuffer = NULL;
-    }    
-
-// end of file
+/*
+* Copyright (c) 2007 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:      Implements download session
+*
+*/
+
+
+
+
+
+
+// INTERNAL INCLUDES
+// upnp stack api
+#include <upnpstring.h>
+
+// dlnasrv / mediaserver api
+#include <upnpitem.h>
+#include <upnpelement.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavdevice.h"
+#include "upnpfiletransfersessionobserver.h"
+
+// dlnasrv / avcontroller helper api
+#include "upnpconstantdefs.h" // for upnp-specific stuff
+#include "upnpitemutility.h" // FindAttributeByName
+#include "upnpfileutility.h" // FitsInMemory
+#include "upnppathutility.h" // CreateCopyPath
+
+// dlnasrv / avcontroller internal
+#include "upnpfiledownloadsessionimpl.h"
+#include "upnpavcontrollerclient.h"
+#include "upnpfiletransferitem.h"
+
+// EXTERNAL INCLUDES
+
+_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
+#include "upnplog.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::NewL
+// Two-phase construction
+// --------------------------------------------------------------------------
+CUPnPFileDownloadSessionImpl* CUPnPFileDownloadSessionImpl::NewL(
+    RUPnPAVControllerClient& aServer, const CUpnpAVDevice& aDevice )
+    {
+    CUPnPFileDownloadSessionImpl* self = new (ELeave)
+        CUPnPFileDownloadSessionImpl( aServer );
+    CleanupStack::PushL( self );
+    self->iDevice = CUpnpAVDevice::NewL( aDevice );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::CUPnPFileDownloadSessionImpl
+// Constructor
+// --------------------------------------------------------------------------
+CUPnPFileDownloadSessionImpl::CUPnPFileDownloadSessionImpl(
+    RUPnPAVControllerClient& aServer ) :
+    CActive( EPriorityStandard ),
+    iServer( aServer ),
+    iBufferPtr( 0, 0 ),
+    iBufferPtr2( 0, 0 ),
+    iAlive( ETrue ),
+    iEventPkg( iEvent )
+    {
+    CActiveScheduler::Add( this );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::~CUPnPFileDownloadSessionImpl
+// Destructor
+// --------------------------------------------------------------------------
+CUPnPFileDownloadSessionImpl::~CUPnPFileDownloadSessionImpl()
+    {
+    __LOG( "CUPnPFileDownloadSessionImpl::~CUPnPFileDownloadSessionImpl" );
+    
+    CancelAllTransfers();
+    
+    Cancel();
+    iServer.DestroyDownloadSession( (TInt)this );
+    
+    delete iDevice;
+    delete iBuffer;
+    delete iBuffer2;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::ConstructL
+// Two-phase construction
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::ConstructL()
+    {
+    __LOG( "CUPnPFileDownloadSessionImpl::ConstructL" );
+    
+    iBuffer = iDevice->Uuid().AllocL();
+    iBufferPtr.Set( iBuffer->Des() );
+    User::LeaveIfError( iServer.CreateDownloadSession(
+        (TInt)this , iBufferPtr ) );
+    
+    iBuffer2 = HBufC::NewL( KMaxPath );
+    iBufferPtr2.Set( iBuffer2->Des() );    
+    iServer.GetDownloadEvent( (TInt)this, iEventPkg, iStatus, iBufferPtr2 );
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::ConstructL
+// From CActive
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::RunL()
+    {
+    __LOG( "CUPnPFileDownloadSessionImpl::RunL" );
+
+    TUpnpFileTransferEvent event = iEvent;
+
+    if( iStatus.Int() == KErrNone )
+        {
+        __LOG( "RunL - Activate again" );
+
+        iServer.GetDownloadEvent( (TInt)this, iEventPkg, iStatus,
+            iBufferPtr2 );
+        SetActive();        
+        }
+    else
+        {
+        __LOG1( "RunL - %d", iStatus.Int() );      
+        }              
+    
+    // Handle event and activate again
+    switch( event.iEvent )
+        {
+        case TUpnpFileTransferEvent::ETransferStarted:
+            {
+            if( iObserver )
+                {
+                __LOG( "RunL - ETransferStarted" );
+                
+                // iKey - 1 since it's incremented when we request the
+                // download. The reason behind of this is the fact that
+                // httptransfer does not accept value 0 which is legal from
+                // the API point of view
+                iObserver->TransferStarted( event.iKey - 1,
+                    event.iStatus );
+                }
+            break;
+            }
+
+        case TUpnpFileTransferEvent::ETransferCompleted:
+            {
+            if( iObserver )
+                {
+                __LOG( "RunL - ETransferCompleted" );
+                
+                iObserver->TransferCompleted( event.iKey - 1,
+                    event.iStatus, *iBuffer2 );   
+                }                  
+            break;
+            }
+            
+        case TUpnpFileTransferEvent::ETransferProgress:
+            {
+            if( iObserver )
+                {
+                __LOG( "RunL - ETransferProgress" );
+                
+                iObserver->TransferProgress( event.iKey - 1,
+                    event.iParam1, event.iParam2 );
+                }                  
+            break;
+            }
+            
+        case TUpnpFileTransferEvent::EDeviceDisconnected:
+            {
+            CUpnpAVDevice* tmpDev = NULL;
+            UPnPDeviceDisappeared( *tmpDev );
+            break;
+            }
+            
+        default:
+            {
+            __LOG( "RunL - default!" );      
+            break;
+            }
+        
+        }        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::DoCancel
+// From CActive
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::DoCancel()
+    {
+    __LOG( "CUPnPFileDownloadSessionImpl::DoCancel" );
+    
+    iServer.CancelDownloadEvent( (TInt)this );
+    
+    __LOG( "CUPnPFileDownloadSessionImpl::DoCancel - end" );
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::RunError
+// From CActive
+// --------------------------------------------------------------------------
+TInt CUPnPFileDownloadSessionImpl::RunError( TInt /*aError*/ )
+    {
+    __LOG( "CUPnPFileDownloadSessionImpl::RunError" );
+    
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::StartDownloadL
+// From CActive
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::StartDownloadL(
+    const CUpnpItem& aItem, TInt aKey )
+    {
+    __LOG( "CUPnPFileDownloadSessionImpl::StartDownloadL" );
+    
+    ResetL();
+
+    CUpnpFileTransferItem* item = CUpnpFileTransferItem::NewLC();
+    item->SetTitleL( aItem.Title() );
+    // aKey + 1 
+    // the reason behind of this is the fact that httptransfer
+    // does not accept value 0 which is legal from the API point
+    // of view.    
+    item->SetKey( aKey + 1 );
+
+    // Get the most suitable (original) res-element from the item
+    const CUpnpElement& tmpEl = UPnPItemUtility::ResourceFromItemL( 
+        aItem );
+    
+    if( !UPnPFileUtility::FitsInMemory( tmpEl ) )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
+    item->SetUriL( tmpEl.Value() );    
+
+    CUPnPPathUtility* pathUtil = CUPnPPathUtility::NewLC();
+    HBufC* path = pathUtil->CreateCopyPathL( aItem, tmpEl, EFalse );
+    CleanupStack::PopAndDestroy( pathUtil );
+    CleanupStack::PushL( path );
+    item->SetPathL( *path );
+    CleanupStack::PopAndDestroy( path );
+    
+    // Get the protocolinfo-attribute
+    const CUpnpAttribute* tmpPInfo = UPnPItemUtility::FindAttributeByName(
+        tmpEl, KAttributeProtocolInfo );
+    if( tmpPInfo )
+        {
+        item->SetProtocolInfoL( tmpPInfo->Value() );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }    
+
+    iBuffer = item->ToDes8L();
+    iBufferPtr.Set( iBuffer->Des() );
+    
+    CleanupStack::PopAndDestroy( item );
+    
+    User::LeaveIfError( iServer.StartDownload( (TInt)this, iBufferPtr ) );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::StartDownloadL
+// See upnpfiledownloadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::StartDownloadL( 
+    const CUpnpElement& aResElement, const CUpnpItem& aItem,
+    RFile& aFile, TInt aKey )
+    {
+    __LOG( "CUPnPFileDownloadSessionImpl::StartDownloadL" );
+    
+    ResetL();
+
+    CUpnpFileTransferItem* item = CUpnpFileTransferItem::NewLC();
+    item->SetTitleL( aItem.Title() );
+    item->SetUriL( aResElement.Value() );
+    item->SetKey( aKey + 1 );
+
+    const CUpnpAttribute* pInfo = UPnPItemUtility::FindAttributeByName(
+        aResElement, KAttributeProtocolInfo );
+    if( pInfo )
+        {
+        item->SetProtocolInfoL( pInfo->Value() );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }   
+
+    iBuffer = item->ToDes8L();
+    iBufferPtr.Set( iBuffer->Des() );
+    
+    CleanupStack::PopAndDestroy( item );
+    
+    User::LeaveIfError( iServer.StartDownload( (TInt)this, iBufferPtr,
+        aFile ) );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::SetObserver
+// See upnpfiledownloadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::SetObserver(
+    MUPnPFileTransferSessionObserver& aObserver )
+    {
+    __LOG( "CUPnPFileDownloadSessionImpl::SetObserver" );
+    
+    iObserver = &aObserver;
+    }
+     
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::RemoveObserver
+// See upnpfiledownloadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::RemoveObserver()
+    {
+    iObserver = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::Observer
+// See upnpfiledownloadsessionimpl.h
+// --------------------------------------------------------------------------
+MUPnPFileTransferSessionObserver* CUPnPFileDownloadSessionImpl::Observer()
+    const
+    {
+    return iObserver;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::StartTrackingProgressL
+// See upnpfiledownloadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::StartTrackingProgressL( TInt aKey )
+    {
+    ResetL();
+    User::LeaveIfError( iServer.StartTrackingDownloadProgress(
+        (TInt)this, aKey + 1 ) );
+                   
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::CancelTransfer
+// See upnpfiledownloadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::CancelTransfer( TInt aKey )
+    {
+    iServer.CancelDownload( (TInt)this, aKey + 1 ); // Ignore error
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::CancelAllTransfers
+// See upnpfiledownloadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::CancelAllTransfers()
+    {
+    iServer.CancelAllDownloads( (TInt)this ); // Ignore error
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::UPnPDeviceDiscovered
+// Device discovered
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::UPnPDeviceDiscovered(
+    const CUpnpAVDevice& /*aDevice*/ )
+    {
+    // No implementation needed
+    }
+
+  
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::UPnPDeviceDisappeared
+// Device disappeared
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::UPnPDeviceDisappeared(
+    const CUpnpAVDevice& /*aDevice*/ )
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::UPnPDeviceDisappeared" );
+    
+    iAlive = EFalse;
+    if( iObserver )
+        {
+        iObserver->MediaServerDisappeared( 
+            MUPnPAVSessionObserverBase::EDisconnected );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::WLANConnectionLost
+// Connection lost
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::WLANConnectionLost()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::WLANConnectionLost" );
+    
+    iAlive = EFalse;
+    if( iObserver )    
+        {
+        iObserver->MediaServerDisappeared( 
+            MUPnPAVSessionObserverBase::EWLANLost );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::Device
+// Returns used device
+// --------------------------------------------------------------------------
+const CUpnpAVDevice& CUPnPFileDownloadSessionImpl::Device() const
+    {
+    return *iDevice;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileDownloadSessionImpl::ResetL
+// Reset
+// --------------------------------------------------------------------------
+void CUPnPFileDownloadSessionImpl::ResetL()
+    {
+    __LOG( "CUPnPFileDownloadSessionImpl::ResetL" );
+    
+    if( !iAlive )
+        {
+        User::Leave( KErrDisconnected );
+        }
+
+    delete iBuffer; iBuffer = NULL;
+    }    
+
+// end of file
--- a/upnpavcontroller/upnpavcontrollerclient/src/upnpfileuploadsessionimpl.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerclient/src/upnpfileuploadsessionimpl.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,380 +1,380 @@
-/*
-* Copyright (c) 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:      implements upload session
-*
-*/
-
-
-
-
-
-
-// INTERNAL INCLUDES
-// upnpframework / avcontroller api
-#include "upnpavdevice.h"
-#include "upnpfiletransfersessionobserver.h"
-
-// avcontroller internal
-#include "upnpfileuploadsessionimpl.h"
-#include "upnpavcontrollerclient.h"
-#include "upnpfiletransferitem.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
-#include "upnplog.h"
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::NewL
-// Two-phase construction
-// --------------------------------------------------------------------------
-CUPnPFileUploadSessionImpl* CUPnPFileUploadSessionImpl::NewL(
-    RUPnPAVControllerClient& aServer, const CUpnpAVDevice& aDevice )
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::NewL" );
-    
-    CUPnPFileUploadSessionImpl* self = new (ELeave)
-        CUPnPFileUploadSessionImpl( aServer );
-    CleanupStack::PushL( self );
-    self->iDevice = CUpnpAVDevice::NewL( aDevice );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::CUPnPFileUploadSessionImpl
-// Constructor
-// --------------------------------------------------------------------------
-CUPnPFileUploadSessionImpl::CUPnPFileUploadSessionImpl(
-    RUPnPAVControllerClient& aServer ) :
-    CActive( EPriorityStandard ),
-    iServer( aServer ),
-    iBufferPtr( 0, 0 ),
-    iAlive( ETrue ),
-    iEventPkg( iEvent )
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::NewL" );
-    
-    CActiveScheduler::Add( this );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::~CUPnPFileUploadSessionImpl
-// Destructor
-// --------------------------------------------------------------------------
-CUPnPFileUploadSessionImpl::~CUPnPFileUploadSessionImpl()
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::~CUPnPFileUploadSessionImpl" );
-    
-    CancelAllTransfers();
-    
-    Cancel();
-    iServer.DestroyUploadSession( (TInt)this );
-    
-    delete iDevice;
-    delete iBuffer;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::ConstructL
-// Two-phase construction
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::ConstructL()
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::ConstructL" );
-    
-    iBuffer = iDevice->Uuid().AllocL();
-    iBufferPtr.Set( iBuffer->Des() );
-    User::LeaveIfError( iServer.CreateUploadSession(
-        (TInt)this , iBufferPtr ) );
-
-    iServer.GetUploadEvent( (TInt)this, iEventPkg, iStatus );
-    SetActive();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::ConstructL
-// Two-phase construction
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::RunL()
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::RunL" );
-
-    TUpnpFileTransferEvent event = iEvent;    
-
-    if( iStatus.Int() == KErrNone )
-        {
-        iServer.GetUploadEvent( (TInt)this, iEventPkg, iStatus );
-        SetActive();        
-        }
-    else
-        {
-        __LOG1( "RunL - %d", iStatus.Int() );      
-        }      
-
-    // Handle event and activate again
-    switch( event.iEvent )
-        {
-        case TUpnpFileTransferEvent::ETransferStarted:
-            {
-            if( iObserver )
-                {
-                __LOG2( "RunL - ETransferStarted, key = %d, status = %d",
-                    event.iKey, event.iStatus );
-                
-                // iKey - 1 since it's incremented when we request the upload
-                // the reason behind of this is the fact that httptransfer
-                // does not accept value 0 which is legal from the API point
-                // of view
-                iObserver->TransferStarted( event.iKey - 1,
-                    event.iStatus );
-                }
-            break;
-            }
-            
-        case TUpnpFileTransferEvent::ETransferCompleted:
-            {
-            if( iObserver )
-                {
-                __LOG2( "RunL - ETransferCompleted,key = %d, status = %d",
-                    event.iKey, event.iStatus );
-                    
-                iObserver->TransferCompleted( event.iKey - 1,
-                    event.iStatus, KNullDesC );
-                }                  
-            break;
-            }
-            
-        case TUpnpFileTransferEvent::ETransferProgress:
-            {
-            if( iObserver )
-                {
-                __LOG1( "RunL - ETransferProgress, status = %d",
-                    event.iStatus );
-                    
-                iObserver->TransferProgress( event.iKey - 1,
-                    event.iParam1, event.iParam2 );
-                }                  
-            break;
-            }
-
-        case TUpnpFileTransferEvent::EDeviceDisconnected:
-            {
-            __LOG( "RunL - EDeviceDisconnected" );
-
-            CUpnpAVDevice* tmpDev = NULL;
-            UPnPDeviceDisappeared( *tmpDev );
-            }
-            break;
-            
-        default:
-            {
-            __LOG( "RunL - default!" ); 
-            break;     
-            }
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::ConstructL
-// See upnpfileuploadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::StartUploadL( const TDesC& aFilePath,
-    TInt aKey )
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::StartUploadL" );
-    
-    ResetL();
-
-    CUpnpFileTransferItem* item = CUpnpFileTransferItem::NewLC();
-    // aKey + 1 
-    // the reason behind of this is the fact that httptransfer
-    // does not accept value 0 which is legal from the API point
-    // of view.
-    item->SetKey( aKey + 1 );
-    item->SetPathL( aFilePath );   
-
-    iBuffer = item->ToDes8L();
-    iBufferPtr.Set( iBuffer->Des() );
-    
-    CleanupStack::PopAndDestroy( item );
-    
-    User::LeaveIfError( iServer.StartUpload( (TInt)this, iBufferPtr ) );    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::DoCancel
-// From CActive
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::DoCancel()
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::DoCancel" );
-    
-    iServer.CancelUploadEvent( (TInt)this );
-    
-    __LOG( "CUPnPFileUploadSessionImpl::DoCancel - end" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::RunError
-// From CActive
-// --------------------------------------------------------------------------
-TInt CUPnPFileUploadSessionImpl::RunError( TInt /*aError*/ )
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::RunError" );
-    
-    return KErrNone;
-    }
-
-   
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::SetObserver
-// See upnpfileuploadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::SetObserver(
-    MUPnPFileTransferSessionObserver& aObserver )
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::SetObserver" );
-    
-    iObserver = &aObserver;
-    }
-     
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::RemoveObserver
-// See upnpfileuploadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::RemoveObserver()
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::RemoveObserver" );
-    
-    iObserver = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::Observer
-// See upnpfileuploadsessionimpl.h
-// --------------------------------------------------------------------------
-MUPnPFileTransferSessionObserver*
-    CUPnPFileUploadSessionImpl::Observer() const
-    {
-    return iObserver;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::StartTrackingProgressL
-// See upnpfileuploadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::StartTrackingProgressL( TInt aKey )
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::StartTrackingProgressL" );
-    
-    ResetL();
-    User::LeaveIfError( iServer.StartTrackingUploadProgress(
-        (TInt)this, aKey + 1 ) );    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::CancelTransfer
-// See upnpfileuploadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::CancelTransfer( TInt aKey )
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::CancelTransfer" );
-    
-    iServer.CancelUpload( (TInt)this, aKey + 1 ); // Ignore error
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::CancelAllTransfers
-// See upnpfileuploadsessionimpl.h
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::CancelAllTransfers()
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::CancelAllTransfers" );
-    
-    iServer.CancelAllUploads( (TInt)this ); // Ignore error
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::UPnPDeviceDiscovered
-// Device discovered
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::UPnPDeviceDiscovered(
-    const CUpnpAVDevice& /*aDevice*/ )
-    {
-    // No implementation needed
-    }
-
-  
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::UPnPDeviceDisappeared
-// Device disappeared
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::UPnPDeviceDisappeared(
-    const CUpnpAVDevice& /*aDevice*/ )
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::UPnPDeviceDisappeared" );
-    
-    iAlive = EFalse;
-    if( iObserver )
-        {
-        iObserver->MediaServerDisappeared( 
-            MUPnPAVSessionObserverBase::EDisconnected );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::WLANConnectionLost
-// Connection lost
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::WLANConnectionLost()
-    {
-    __LOG( "CUPnPAVBrowsingSessionImpl::WLANConnectionLost" );
-    
-    iAlive = EFalse;
-    if( iObserver )    
-        {
-        iObserver->MediaServerDisappeared( 
-            MUPnPAVSessionObserverBase::EWLANLost );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::Device
-// Returns used device
-// --------------------------------------------------------------------------
-const CUpnpAVDevice& CUPnPFileUploadSessionImpl::Device() const
-    {
-    return *iDevice;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileUploadSessionImpl::ResetL
-// Reset
-// --------------------------------------------------------------------------
-void CUPnPFileUploadSessionImpl::ResetL()
-    {
-    __LOG( "CUPnPFileUploadSessionImpl::ResetL" );
-    
-    if( !iAlive )
-        {
-        User::Leave( KErrDisconnected );
-        }
-
-    delete iBuffer; iBuffer = NULL;
-    }    
-
-// end of file
-
+/*
+* Copyright (c) 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:      implements upload session
+*
+*/
+
+
+
+
+
+
+// INTERNAL INCLUDES
+// dlnasrv / avcontroller api
+#include "upnpavdevice.h"
+#include "upnpfiletransfersessionobserver.h"
+
+// dlnasrv / avcontroller internal
+#include "upnpfileuploadsessionimpl.h"
+#include "upnpavcontrollerclient.h"
+#include "upnpfiletransferitem.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerclient.txt");
+#include "upnplog.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::NewL
+// Two-phase construction
+// --------------------------------------------------------------------------
+CUPnPFileUploadSessionImpl* CUPnPFileUploadSessionImpl::NewL(
+    RUPnPAVControllerClient& aServer, const CUpnpAVDevice& aDevice )
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::NewL" );
+    
+    CUPnPFileUploadSessionImpl* self = new (ELeave)
+        CUPnPFileUploadSessionImpl( aServer );
+    CleanupStack::PushL( self );
+    self->iDevice = CUpnpAVDevice::NewL( aDevice );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::CUPnPFileUploadSessionImpl
+// Constructor
+// --------------------------------------------------------------------------
+CUPnPFileUploadSessionImpl::CUPnPFileUploadSessionImpl(
+    RUPnPAVControllerClient& aServer ) :
+    CActive( EPriorityStandard ),
+    iServer( aServer ),
+    iBufferPtr( 0, 0 ),
+    iAlive( ETrue ),
+    iEventPkg( iEvent )
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::NewL" );
+    
+    CActiveScheduler::Add( this );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::~CUPnPFileUploadSessionImpl
+// Destructor
+// --------------------------------------------------------------------------
+CUPnPFileUploadSessionImpl::~CUPnPFileUploadSessionImpl()
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::~CUPnPFileUploadSessionImpl" );
+    
+    CancelAllTransfers();
+    
+    Cancel();
+    iServer.DestroyUploadSession( (TInt)this );
+    
+    delete iDevice;
+    delete iBuffer;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::ConstructL
+// Two-phase construction
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::ConstructL()
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::ConstructL" );
+    
+    iBuffer = iDevice->Uuid().AllocL();
+    iBufferPtr.Set( iBuffer->Des() );
+    User::LeaveIfError( iServer.CreateUploadSession(
+        (TInt)this , iBufferPtr ) );
+
+    iServer.GetUploadEvent( (TInt)this, iEventPkg, iStatus );
+    SetActive();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::ConstructL
+// Two-phase construction
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::RunL()
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::RunL" );
+
+    TUpnpFileTransferEvent event = iEvent;    
+
+    if( iStatus.Int() == KErrNone )
+        {
+        iServer.GetUploadEvent( (TInt)this, iEventPkg, iStatus );
+        SetActive();        
+        }
+    else
+        {
+        __LOG1( "RunL - %d", iStatus.Int() );      
+        }      
+
+    // Handle event and activate again
+    switch( event.iEvent )
+        {
+        case TUpnpFileTransferEvent::ETransferStarted:
+            {
+            if( iObserver )
+                {
+                __LOG2( "RunL - ETransferStarted, key = %d, status = %d",
+                    event.iKey, event.iStatus );
+                
+                // iKey - 1 since it's incremented when we request the upload
+                // the reason behind of this is the fact that httptransfer
+                // does not accept value 0 which is legal from the API point
+                // of view
+                iObserver->TransferStarted( event.iKey - 1,
+                    event.iStatus );
+                }
+            break;
+            }
+            
+        case TUpnpFileTransferEvent::ETransferCompleted:
+            {
+            if( iObserver )
+                {
+                __LOG2( "RunL - ETransferCompleted,key = %d, status = %d",
+                    event.iKey, event.iStatus );
+                    
+                iObserver->TransferCompleted( event.iKey - 1,
+                    event.iStatus, KNullDesC );
+                }                  
+            break;
+            }
+            
+        case TUpnpFileTransferEvent::ETransferProgress:
+            {
+            if( iObserver )
+                {
+                __LOG1( "RunL - ETransferProgress, status = %d",
+                    event.iStatus );
+                    
+                iObserver->TransferProgress( event.iKey - 1,
+                    event.iParam1, event.iParam2 );
+                }                  
+            break;
+            }
+
+        case TUpnpFileTransferEvent::EDeviceDisconnected:
+            {
+            __LOG( "RunL - EDeviceDisconnected" );
+
+            CUpnpAVDevice* tmpDev = NULL;
+            UPnPDeviceDisappeared( *tmpDev );
+            }
+            break;
+            
+        default:
+            {
+            __LOG( "RunL - default!" ); 
+            break;     
+            }
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::ConstructL
+// See upnpfileuploadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::StartUploadL( const TDesC& aFilePath,
+    TInt aKey )
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::StartUploadL" );
+    
+    ResetL();
+
+    CUpnpFileTransferItem* item = CUpnpFileTransferItem::NewLC();
+    // aKey + 1 
+    // the reason behind of this is the fact that httptransfer
+    // does not accept value 0 which is legal from the API point
+    // of view.
+    item->SetKey( aKey + 1 );
+    item->SetPathL( aFilePath );   
+
+    iBuffer = item->ToDes8L();
+    iBufferPtr.Set( iBuffer->Des() );
+    
+    CleanupStack::PopAndDestroy( item );
+    
+    User::LeaveIfError( iServer.StartUpload( (TInt)this, iBufferPtr ) );    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::DoCancel
+// From CActive
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::DoCancel()
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::DoCancel" );
+    
+    iServer.CancelUploadEvent( (TInt)this );
+    
+    __LOG( "CUPnPFileUploadSessionImpl::DoCancel - end" );
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::RunError
+// From CActive
+// --------------------------------------------------------------------------
+TInt CUPnPFileUploadSessionImpl::RunError( TInt /*aError*/ )
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::RunError" );
+    
+    return KErrNone;
+    }
+
+   
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::SetObserver
+// See upnpfileuploadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::SetObserver(
+    MUPnPFileTransferSessionObserver& aObserver )
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::SetObserver" );
+    
+    iObserver = &aObserver;
+    }
+     
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::RemoveObserver
+// See upnpfileuploadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::RemoveObserver()
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::RemoveObserver" );
+    
+    iObserver = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::Observer
+// See upnpfileuploadsessionimpl.h
+// --------------------------------------------------------------------------
+MUPnPFileTransferSessionObserver*
+    CUPnPFileUploadSessionImpl::Observer() const
+    {
+    return iObserver;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::StartTrackingProgressL
+// See upnpfileuploadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::StartTrackingProgressL( TInt aKey )
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::StartTrackingProgressL" );
+    
+    ResetL();
+    User::LeaveIfError( iServer.StartTrackingUploadProgress(
+        (TInt)this, aKey + 1 ) );    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::CancelTransfer
+// See upnpfileuploadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::CancelTransfer( TInt aKey )
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::CancelTransfer" );
+    
+    iServer.CancelUpload( (TInt)this, aKey + 1 ); // Ignore error
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::CancelAllTransfers
+// See upnpfileuploadsessionimpl.h
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::CancelAllTransfers()
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::CancelAllTransfers" );
+    
+    iServer.CancelAllUploads( (TInt)this ); // Ignore error
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::UPnPDeviceDiscovered
+// Device discovered
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::UPnPDeviceDiscovered(
+    const CUpnpAVDevice& /*aDevice*/ )
+    {
+    // No implementation needed
+    }
+
+  
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::UPnPDeviceDisappeared
+// Device disappeared
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::UPnPDeviceDisappeared(
+    const CUpnpAVDevice& /*aDevice*/ )
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::UPnPDeviceDisappeared" );
+    
+    iAlive = EFalse;
+    if( iObserver )
+        {
+        iObserver->MediaServerDisappeared( 
+            MUPnPAVSessionObserverBase::EDisconnected );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::WLANConnectionLost
+// Connection lost
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::WLANConnectionLost()
+    {
+    __LOG( "CUPnPAVBrowsingSessionImpl::WLANConnectionLost" );
+    
+    iAlive = EFalse;
+    if( iObserver )    
+        {
+        iObserver->MediaServerDisappeared( 
+            MUPnPAVSessionObserverBase::EWLANLost );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::Device
+// Returns used device
+// --------------------------------------------------------------------------
+const CUpnpAVDevice& CUPnPFileUploadSessionImpl::Device() const
+    {
+    return *iDevice;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileUploadSessionImpl::ResetL
+// Reset
+// --------------------------------------------------------------------------
+void CUPnPFileUploadSessionImpl::ResetL()
+    {
+    __LOG( "CUPnPFileUploadSessionImpl::ResetL" );
+    
+    if( !iAlive )
+        {
+        User::Leave( KErrDisconnected );
+        }
+
+    delete iBuffer; iBuffer = NULL;
+    }    
+
+// end of file
+
--- a/upnpavcontroller/upnpavcontrollerhelper/bwins/upnpavcontrollerhelperu.def	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/bwins/upnpavcontrollerhelperu.def	Mon Nov 01 12:37:49 2010 +0200
@@ -1,36 +1,40 @@
-EXPORTS
-	??0CUPnPAbstractBrowsingSessionObserver@@QAE@XZ @ 1 NONAME ; CUPnPAbstractBrowsingSessionObserver::CUPnPAbstractBrowsingSessionObserver(void)
-	??0CUPnPAbstractRenderingSessionObserver@@QAE@XZ @ 2 NONAME ; CUPnPAbstractRenderingSessionObserver::CUPnPAbstractRenderingSessionObserver(void)
-	??1CUPnPAbstractBrowsingSessionObserver@@UAE@XZ @ 3 NONAME ; CUPnPAbstractBrowsingSessionObserver::~CUPnPAbstractBrowsingSessionObserver(void)
-	??1CUPnPAbstractRenderingSessionObserver@@UAE@XZ @ 4 NONAME ; CUPnPAbstractRenderingSessionObserver::~CUPnPAbstractRenderingSessionObserver(void)
-	?BelongsToClass@UPnPItemUtility@@SAHABVCUpnpObject@@ABVTDesC8@@@Z @ 5 NONAME ; int UPnPItemUtility::BelongsToClass(class CUpnpObject const &, class TDesC8 const &)
-	?DisableSessionObserver@CUPnPAbstractBrowsingSessionObserver@@QAEXXZ @ 6 NONAME ; void CUPnPAbstractBrowsingSessionObserver::DisableSessionObserver(void)
-	?DisableSessionObserver@CUPnPAbstractRenderingSessionObserver@@QAEXXZ @ 7 NONAME ; void CUPnPAbstractRenderingSessionObserver::DisableSessionObserver(void)
-	?EnableSessionObserver@CUPnPAbstractBrowsingSessionObserver@@QAEXXZ @ 8 NONAME ; void CUPnPAbstractBrowsingSessionObserver::EnableSessionObserver(void)
-	?EnableSessionObserver@CUPnPAbstractRenderingSessionObserver@@QAEXXZ @ 9 NONAME ; void CUPnPAbstractRenderingSessionObserver::EnableSessionObserver(void)
-	?FindAttributeByName@UPnPItemUtility@@SAPBVCUpnpAttribute@@ABVCUpnpElement@@ABVTDesC8@@@Z @ 10 NONAME ; class CUpnpAttribute const * UPnPItemUtility::FindAttributeByName(class CUpnpElement const &, class TDesC8 const &)
-	?FindAttributeByNameL@UPnPItemUtility@@SAABVCUpnpAttribute@@ABVCUpnpElement@@ABVTDesC8@@@Z @ 11 NONAME ; class CUpnpAttribute const & UPnPItemUtility::FindAttributeByNameL(class CUpnpElement const &, class TDesC8 const &)
-	?FindElementByName@UPnPItemUtility@@SAPBVCUpnpElement@@ABVCUpnpObject@@ABVTDesC8@@@Z @ 12 NONAME ; class CUpnpElement const * UPnPItemUtility::FindElementByName(class CUpnpObject const &, class TDesC8 const &)
-	?FindElementByNameL@UPnPItemUtility@@SAABVCUpnpElement@@ABVCUpnpObject@@ABVTDesC8@@@Z @ 13 NONAME ; class CUpnpElement const & UPnPItemUtility::FindElementByNameL(class CUpnpObject const &, class TDesC8 const &)
-	?FitsInMemory@UPnPFileUtility@@SAHABVCUpnpElement@@@Z @ 14 NONAME ; int UPnPFileUtility::FitsInMemory(class CUpnpElement const &)
-	?GetResElements@UPnPItemUtility@@SAXABVCUpnpObject@@AAV?$RPointerArray@VCUpnpElement@@@@@Z @ 15 NONAME ; void UPnPItemUtility::GetResElements(class CUpnpObject const &, class RPointerArray<class CUpnpElement> &)
-	?GetSupportedProfilesL@UPnPDlnaUtility@@SAAAVCDesC8Array@@W4TDlnaMode@1@@Z @ 16 NONAME ; class CDesC8Array & UPnPDlnaUtility::GetSupportedProfilesL(enum UPnPDlnaUtility::TDlnaMode)
-	?IsFileProtectedL@UPnPFileUtility@@SAHABVTDesC16@@@Z @ 17 NONAME ; int UPnPFileUtility::IsFileProtectedL(class TDesC16 const &)
-	?IsSessionObserverEnabled@CUPnPAbstractBrowsingSessionObserver@@QAEHXZ @ 18 NONAME ; int CUPnPAbstractBrowsingSessionObserver::IsSessionObserverEnabled(void)
-	?IsSessionObserverEnabled@CUPnPAbstractRenderingSessionObserver@@QAEHXZ @ 19 NONAME ; int CUPnPAbstractRenderingSessionObserver::IsSessionObserverEnabled(void)
-	?IsSupportedDlnaProfile@UPnPDlnaUtility@@SAHABVTDesC8@@@Z @ 20 NONAME ; int UPnPDlnaUtility::IsSupportedDlnaProfile(class TDesC8 const &)
-	?IsSupportedMimeType@UPnPDlnaUtility@@SAHABVTDesC8@@@Z @ 21 NONAME ; int UPnPDlnaUtility::IsSupportedMimeType(class TDesC8 const &)
-	?NewDownloadItemResolverL@UPnPItemResolverFactory@@SAPAVMUPnPItemResolver@@ABVTDesC8@@AAVMUPnPAVController@@AAVMUPnPAVBrowsingSession@@AAVMUPnPResourceSelector@@0H@Z @ 22 NONAME ; class MUPnPItemResolver * UPnPItemResolverFactory::NewDownloadItemResolverL(class TDesC8 const &, class MUPnPAVController &, class MUPnPAVBrowsingSession &, class MUPnPResourceSelector &, class TDesC8 const &, int)
-	?NewLocalItemResolverL@UPnPItemResolverFactory@@SAPAVMUPnPItemResolver@@ABVTDesC16@@AAVMUPnPAVController@@AAVMUPnPResourceSelector@@H@Z @ 23 NONAME ; class MUPnPItemResolver * UPnPItemResolverFactory::NewLocalItemResolverL(class TDesC16 const &, class MUPnPAVController &, class MUPnPResourceSelector &, int)
-	?NewRemoteItemResolverL@UPnPItemResolverFactory@@SAPAVMUPnPItemResolver@@ABVTDesC8@@AAVMUPnPAVBrowsingSession@@AAVMUPnPResourceSelector@@0H@Z @ 24 NONAME ; class MUPnPItemResolver * UPnPItemResolverFactory::NewRemoteItemResolverL(class TDesC8 const &, class MUPnPAVBrowsingSession &, class MUPnPResourceSelector &, class TDesC8 const &, int)
-	?ResourceFromItemL@UPnPItemUtility@@SAABVCUpnpElement@@ABVCUpnpItem@@@Z @ 25 NONAME ; class CUpnpElement const & UPnPItemUtility::ResourceFromItemL(class CUpnpItem const &)
-	?SelectResourceL@TUPnPSelectDefaultResource@@UAEABVCUpnpElement@@ABVCUpnpItem@@@Z @ 26 NONAME ; class CUpnpElement const & TUPnPSelectDefaultResource::SelectResourceL(class CUpnpItem const &)
-	?SelectResourceL@TUPnPSelectFirstResource@@UAEABVCUpnpElement@@ABVCUpnpItem@@@Z @ 27 NONAME ; class CUpnpElement const & TUPnPSelectFirstResource::SelectResourceL(class CUpnpItem const &)
-	?SetSession@CUPnPAbstractBrowsingSessionObserver@@QAEXAAVMUPnPAVBrowsingSession@@@Z @ 28 NONAME ; void CUPnPAbstractBrowsingSessionObserver::SetSession(class MUPnPAVBrowsingSession &)
-	?SetSession@CUPnPAbstractRenderingSessionObserver@@QAEXAAVMUPnPAVRenderingSession@@@Z @ 29 NONAME ; void CUPnPAbstractRenderingSessionObserver::SetSession(class MUPnPAVRenderingSession &)
-	?UPnPDateAsTTime@UPnPItemUtility@@SAHABVTDesC8@@AAVTTime@@@Z @ 30 NONAME ; int UPnPItemUtility::UPnPDateAsTTime(class TDesC8 const &, class TTime &)
-	?UPnPDurationAsMilliseconds@UPnPItemUtility@@SAHABVTDesC8@@AAH@Z @ 31 NONAME ; int UPnPItemUtility::UPnPDurationAsMilliseconds(class TDesC8 const &, int &)
-	?DeleteTempDownloadFilesL@CUPnPDownloadItemResolver@@SAXXZ @ 32 NONAME ; void CUPnPDownloadItemResolver::DeleteTempDownloadFilesL(void)
-	?CreateTmpFileNameL@UPnPInternalFileUtility@@SAPAVHBufC16@@ABVCUpnpItem@@@Z @ 33 NONAME ; class HBufC16 * UPnPInternalFileUtility::CreateTmpFileNameL(class CUpnpItem const &)
-	?GetSelectedDownloadLocationL@UPnPInternalFileUtility@@SAPAVHBufC16@@XZ @ 34 NONAME ; class HBufC16 * UPnPInternalFileUtility::GetSelectedDownloadLocationL(void)
-
+EXPORTS
+	??0CUPnPAbstractBrowsingSessionObserver@@QAE@XZ @ 1 NONAME ; CUPnPAbstractBrowsingSessionObserver::CUPnPAbstractBrowsingSessionObserver(void)
+	??0CUPnPAbstractRenderingSessionObserver@@QAE@XZ @ 2 NONAME ; CUPnPAbstractRenderingSessionObserver::CUPnPAbstractRenderingSessionObserver(void)
+	??1CUPnPAbstractBrowsingSessionObserver@@UAE@XZ @ 3 NONAME ; CUPnPAbstractBrowsingSessionObserver::~CUPnPAbstractBrowsingSessionObserver(void)
+	??1CUPnPAbstractRenderingSessionObserver@@UAE@XZ @ 4 NONAME ; CUPnPAbstractRenderingSessionObserver::~CUPnPAbstractRenderingSessionObserver(void)
+	?BelongsToClass@UPnPItemUtility@@SAHABVCUpnpObject@@ABVTDesC8@@@Z @ 5 NONAME ; int UPnPItemUtility::BelongsToClass(class CUpnpObject const &, class TDesC8 const &)
+	?CreateTmpFileNameL@UPnPInternalFileUtility@@SAPAVHBufC16@@ABVCUpnpItem@@@Z @ 6 NONAME ; class HBufC16 * UPnPInternalFileUtility::CreateTmpFileNameL(class CUpnpItem const &)
+	?DeleteTempDownloadFilesL@CUPnPDownloadItemResolver@@SAXXZ @ 7 NONAME ; void CUPnPDownloadItemResolver::DeleteTempDownloadFilesL(void)
+	?DisableSessionObserver@CUPnPAbstractBrowsingSessionObserver@@QAEXXZ @ 8 NONAME ; void CUPnPAbstractBrowsingSessionObserver::DisableSessionObserver(void)
+	?DisableSessionObserver@CUPnPAbstractRenderingSessionObserver@@QAEXXZ @ 9 NONAME ; void CUPnPAbstractRenderingSessionObserver::DisableSessionObserver(void)
+	?EnableSessionObserver@CUPnPAbstractBrowsingSessionObserver@@QAEXXZ @ 10 NONAME ; void CUPnPAbstractBrowsingSessionObserver::EnableSessionObserver(void)
+	?EnableSessionObserver@CUPnPAbstractRenderingSessionObserver@@QAEXXZ @ 11 NONAME ; void CUPnPAbstractRenderingSessionObserver::EnableSessionObserver(void)
+	?FindAttributeByName@UPnPItemUtility@@SAPBVCUpnpAttribute@@ABVCUpnpElement@@ABVTDesC8@@@Z @ 12 NONAME ; class CUpnpAttribute const * UPnPItemUtility::FindAttributeByName(class CUpnpElement const &, class TDesC8 const &)
+	?FindAttributeByNameL@UPnPItemUtility@@SAABVCUpnpAttribute@@ABVCUpnpElement@@ABVTDesC8@@@Z @ 13 NONAME ; class CUpnpAttribute const & UPnPItemUtility::FindAttributeByNameL(class CUpnpElement const &, class TDesC8 const &)
+	?FindElementByName@UPnPItemUtility@@SAPBVCUpnpElement@@ABVCUpnpObject@@ABVTDesC8@@@Z @ 14 NONAME ; class CUpnpElement const * UPnPItemUtility::FindElementByName(class CUpnpObject const &, class TDesC8 const &)
+	?FindElementByNameL@UPnPItemUtility@@SAABVCUpnpElement@@ABVCUpnpObject@@ABVTDesC8@@@Z @ 15 NONAME ; class CUpnpElement const & UPnPItemUtility::FindElementByNameL(class CUpnpObject const &, class TDesC8 const &)
+	?FitsInMemory@UPnPFileUtility@@SAHABVCUpnpElement@@@Z @ 16 NONAME ; int UPnPFileUtility::FitsInMemory(class CUpnpElement const &)
+	?GetResElements@UPnPItemUtility@@SAXABVCUpnpObject@@AAV?$RPointerArray@VCUpnpElement@@@@@Z @ 17 NONAME ; void UPnPItemUtility::GetResElements(class CUpnpObject const &, class RPointerArray<class CUpnpElement> &)
+	?GetSelectedDownloadLocationL@UPnPInternalFileUtility@@SAPAVHBufC16@@XZ @ 18 NONAME ; class HBufC16 * UPnPInternalFileUtility::GetSelectedDownloadLocationL(void)
+	?GetSupportedProfilesL@UPnPDlnaUtility@@SAAAVCDesC8Array@@W4TDlnaMode@1@@Z @ 19 NONAME ; class CDesC8Array & UPnPDlnaUtility::GetSupportedProfilesL(enum UPnPDlnaUtility::TDlnaMode)
+	?IsFileProtectedL@UPnPFileUtility@@SAHABVTDesC16@@@Z @ 20 NONAME ; int UPnPFileUtility::IsFileProtectedL(class TDesC16 const &)
+	?IsRunning@CUpnpPushServer@@SAHXZ @ 21 NONAME ; int CUpnpPushServer::IsRunning(void)
+	?IsSessionObserverEnabled@CUPnPAbstractBrowsingSessionObserver@@QAEHXZ @ 22 NONAME ; int CUPnPAbstractBrowsingSessionObserver::IsSessionObserverEnabled(void)
+	?IsSessionObserverEnabled@CUPnPAbstractRenderingSessionObserver@@QAEHXZ @ 23 NONAME ; int CUPnPAbstractRenderingSessionObserver::IsSessionObserverEnabled(void)
+	?IsSupportedDlnaProfile@UPnPDlnaUtility@@SAHABVTDesC8@@@Z @ 24 NONAME ; int UPnPDlnaUtility::IsSupportedDlnaProfile(class TDesC8 const &)
+	?IsSupportedMimeType@UPnPDlnaUtility@@SAHABVTDesC8@@@Z @ 25 NONAME ; int UPnPDlnaUtility::IsSupportedMimeType(class TDesC8 const &)
+	?NewDownloadItemResolverL@UPnPItemResolverFactory@@SAPAVMUPnPItemResolver@@ABVTDesC8@@AAVMUPnPAVController@@AAVMUPnPAVBrowsingSession@@AAVMUPnPResourceSelector@@0H@Z @ 26 NONAME ; class MUPnPItemResolver * UPnPItemResolverFactory::NewDownloadItemResolverL(class TDesC8 const &, class MUPnPAVController &, class MUPnPAVBrowsingSession &, class MUPnPResourceSelector &, class TDesC8 const &, int)
+	?NewLocalItemResolverL@UPnPItemResolverFactory@@SAPAVMUPnPItemResolver@@ABVTDesC16@@AAVMUPnPAVController@@AAVMUPnPResourceSelector@@H@Z @ 27 NONAME ; class MUPnPItemResolver * UPnPItemResolverFactory::NewLocalItemResolverL(class TDesC16 const &, class MUPnPAVController &, class MUPnPResourceSelector &, int)
+	?NewRemoteItemResolverL@UPnPItemResolverFactory@@SAPAVMUPnPItemResolver@@ABVTDesC8@@AAVMUPnPAVBrowsingSession@@AAVMUPnPResourceSelector@@0H@Z @ 28 NONAME ; class MUPnPItemResolver * UPnPItemResolverFactory::NewRemoteItemResolverL(class TDesC8 const &, class MUPnPAVBrowsingSession &, class MUPnPResourceSelector &, class TDesC8 const &, int)
+	?ResourceFromItemL@UPnPItemUtility@@SAABVCUpnpElement@@ABVCUpnpItem@@@Z @ 29 NONAME ; class CUpnpElement const & UPnPItemUtility::ResourceFromItemL(class CUpnpItem const &)
+	?SelectResourceL@TUPnPSelectDefaultResource@@UAEABVCUpnpElement@@ABVCUpnpItem@@@Z @ 30 NONAME ; class CUpnpElement const & TUPnPSelectDefaultResource::SelectResourceL(class CUpnpItem const &)
+	?SelectResourceL@TUPnPSelectFirstResource@@UAEABVCUpnpElement@@ABVCUpnpItem@@@Z @ 31 NONAME ; class CUpnpElement const & TUPnPSelectFirstResource::SelectResourceL(class CUpnpItem const &)
+	?SetSession@CUPnPAbstractBrowsingSessionObserver@@QAEXAAVMUPnPAVBrowsingSession@@@Z @ 32 NONAME ; void CUPnPAbstractBrowsingSessionObserver::SetSession(class MUPnPAVBrowsingSession &)
+	?SetSession@CUPnPAbstractRenderingSessionObserver@@QAEXAAVMUPnPAVRenderingSession@@@Z @ 33 NONAME ; void CUPnPAbstractRenderingSessionObserver::SetSession(class MUPnPAVRenderingSession &)
+	?ShareL@CUpnpPushServer@@SAXIAAVCUpnpItem@@@Z @ 34 NONAME ; void CUpnpPushServer::ShareL(unsigned int, class CUpnpItem &)
+	?UPnPDateAsTTime@UPnPItemUtility@@SAHABVTDesC8@@AAVTTime@@@Z @ 35 NONAME ; int UPnPItemUtility::UPnPDateAsTTime(class TDesC8 const &, class TTime &)
+	?UPnPDurationAsMilliseconds@UPnPItemUtility@@SAHABVTDesC8@@AAH@Z @ 36 NONAME ; int UPnPItemUtility::UPnPDurationAsMilliseconds(class TDesC8 const &, int &)
+	?UnshareAllL@CUpnpPushServer@@SAXXZ @ 37 NONAME ; void CUpnpPushServer::UnshareAllL(void)
+	?UnshareL@CUpnpPushServer@@SAXI@Z @ 38 NONAME ; void CUpnpPushServer::UnshareL(unsigned int)
+
--- a/upnpavcontroller/upnpavcontrollerhelper/eabi/upnpavcontrollerhelperu.def	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/eabi/upnpavcontrollerhelperu.def	Mon Nov 01 12:37:49 2010 +0200
@@ -1,56 +1,59 @@
-EXPORTS
-	_ZN15UPnPDlnaUtility19IsSupportedMimeTypeERK6TDesC8 @ 1 NONAME
-	_ZN15UPnPDlnaUtility21GetSupportedProfilesLENS_9TDlnaModeE @ 2 NONAME
-	_ZN15UPnPDlnaUtility22IsSupportedDlnaProfileERK6TDesC8 @ 3 NONAME
-	_ZN15UPnPFileUtility12FitsInMemoryERK12CUpnpElement @ 4 NONAME
-	_ZN15UPnPFileUtility16IsFileProtectedLERK7TDesC16 @ 5 NONAME
-	_ZN15UPnPItemUtility14BelongsToClassERK11CUpnpObjectRK6TDesC8 @ 6 NONAME
-	_ZN15UPnPItemUtility14GetResElementsERK11CUpnpObjectR13RPointerArrayI12CUpnpElementE @ 7 NONAME
-	_ZN15UPnPItemUtility15UPnPDateAsTTimeERK6TDesC8R5TTime @ 8 NONAME
-	_ZN15UPnPItemUtility17FindElementByNameERK11CUpnpObjectRK6TDesC8 @ 9 NONAME
-	_ZN15UPnPItemUtility17ResourceFromItemLERK9CUpnpItem @ 10 NONAME
-	_ZN15UPnPItemUtility18FindElementByNameLERK11CUpnpObjectRK6TDesC8 @ 11 NONAME
-	_ZN15UPnPItemUtility19FindAttributeByNameERK12CUpnpElementRK6TDesC8 @ 12 NONAME
-	_ZN15UPnPItemUtility20FindAttributeByNameLERK12CUpnpElementRK6TDesC8 @ 13 NONAME
-	_ZN15UPnPItemUtility26UPnPDurationAsMillisecondsERK6TDesC8Ri @ 14 NONAME
-	_ZN23UPnPItemResolverFactory21NewLocalItemResolverLERK7TDesC16R17MUPnPAVControllerR21MUPnPResourceSelectori @ 15 NONAME
-	_ZN23UPnPItemResolverFactory22NewRemoteItemResolverLERK6TDesC8R22MUPnPAVBrowsingSessionR21MUPnPResourceSelectorS2_i @ 16 NONAME
-	_ZN23UPnPItemResolverFactory24NewDownloadItemResolverLERK6TDesC8R17MUPnPAVControllerR22MUPnPAVBrowsingSessionR21MUPnPResourceSelectorS2_i @ 17 NONAME
-	_ZN24TUPnPSelectFirstResource15SelectResourceLERK9CUpnpItem @ 18 NONAME
-	_ZN26TUPnPSelectDefaultResource15SelectResourceLERK9CUpnpItem @ 19 NONAME
-	_ZN36CUPnPAbstractBrowsingSessionObserver10SetSessionER22MUPnPAVBrowsingSession @ 20 NONAME
-	_ZN36CUPnPAbstractBrowsingSessionObserver21EnableSessionObserverEv @ 21 NONAME
-	_ZN36CUPnPAbstractBrowsingSessionObserver22DisableSessionObserverEv @ 22 NONAME
-	_ZN36CUPnPAbstractBrowsingSessionObserver24IsSessionObserverEnabledEv @ 23 NONAME
-	_ZN36CUPnPAbstractBrowsingSessionObserverC1Ev @ 24 NONAME
-	_ZN36CUPnPAbstractBrowsingSessionObserverC2Ev @ 25 NONAME
-	_ZN36CUPnPAbstractBrowsingSessionObserverD0Ev @ 26 NONAME
-	_ZN36CUPnPAbstractBrowsingSessionObserverD1Ev @ 27 NONAME
-	_ZN36CUPnPAbstractBrowsingSessionObserverD2Ev @ 28 NONAME
-	_ZN37CUPnPAbstractRenderingSessionObserver10SetSessionER23MUPnPAVRenderingSession @ 29 NONAME
-	_ZN37CUPnPAbstractRenderingSessionObserver21EnableSessionObserverEv @ 30 NONAME
-	_ZN37CUPnPAbstractRenderingSessionObserver22DisableSessionObserverEv @ 31 NONAME
-	_ZN37CUPnPAbstractRenderingSessionObserver24IsSessionObserverEnabledEv @ 32 NONAME
-	_ZN37CUPnPAbstractRenderingSessionObserverC1Ev @ 33 NONAME
-	_ZN37CUPnPAbstractRenderingSessionObserverC2Ev @ 34 NONAME
-	_ZN37CUPnPAbstractRenderingSessionObserverD0Ev @ 35 NONAME
-	_ZN37CUPnPAbstractRenderingSessionObserverD1Ev @ 36 NONAME
-	_ZN37CUPnPAbstractRenderingSessionObserverD2Ev @ 37 NONAME
-	_ZTI22CUPnPLocalItemResolver @ 38 NONAME ; #<TI>#
-	_ZTI23CUPnPRemoteItemResolver @ 39 NONAME ; #<TI>#
-	_ZTI24TUPnPSelectFirstResource @ 40 NONAME ; #<TI>#
-	_ZTI25CUPnPDownloadItemResolver @ 41 NONAME ; #<TI>#
-	_ZTI26TUPnPSelectDefaultResource @ 42 NONAME ; #<TI>#
-	_ZTI36CUPnPAbstractBrowsingSessionObserver @ 43 NONAME ; #<TI>#
-	_ZTI37CUPnPAbstractRenderingSessionObserver @ 44 NONAME ; #<TI>#
-	_ZTV22CUPnPLocalItemResolver @ 45 NONAME ; #<VT>#
-	_ZTV23CUPnPRemoteItemResolver @ 46 NONAME ; #<VT>#
-	_ZTV24TUPnPSelectFirstResource @ 47 NONAME ; #<VT>#
-	_ZTV25CUPnPDownloadItemResolver @ 48 NONAME ; #<VT>#
-	_ZTV26TUPnPSelectDefaultResource @ 49 NONAME ; #<VT>#
-	_ZTV36CUPnPAbstractBrowsingSessionObserver @ 50 NONAME ; #<VT>#
-	_ZTV37CUPnPAbstractRenderingSessionObserver @ 51 NONAME ; #<VT>#
-	_ZN25CUPnPDownloadItemResolver24DeleteTempDownloadFilesLEv @ 52 NONAME
-	_ZN23UPnPInternalFileUtility18CreateTmpFileNameLERK9CUpnpItem @ 53 NONAME
-	_ZN23UPnPInternalFileUtility28GetSelectedDownloadLocationLEv @ 54 NONAME
-
+EXPORTS
+	_ZN15CUpnpPushServer11UnshareAllLEv @ 1 NONAME
+	_ZN15CUpnpPushServer6ShareLEjR9CUpnpItem @ 2 NONAME
+	_ZN15CUpnpPushServer8UnshareLEj @ 3 NONAME
+	_ZN15CUpnpPushServer9IsRunningEv @ 4 NONAME
+	_ZN15UPnPDlnaUtility19IsSupportedMimeTypeERK6TDesC8 @ 5 NONAME
+	_ZN15UPnPDlnaUtility21GetSupportedProfilesLENS_9TDlnaModeE @ 6 NONAME
+	_ZN15UPnPDlnaUtility22IsSupportedDlnaProfileERK6TDesC8 @ 7 NONAME
+	_ZN15UPnPFileUtility12FitsInMemoryERK12CUpnpElement @ 8 NONAME
+	_ZN15UPnPFileUtility16IsFileProtectedLERK7TDesC16 @ 9 NONAME
+	_ZN15UPnPItemUtility14BelongsToClassERK11CUpnpObjectRK6TDesC8 @ 10 NONAME
+	_ZN15UPnPItemUtility14GetResElementsERK11CUpnpObjectR13RPointerArrayI12CUpnpElementE @ 11 NONAME
+	_ZN15UPnPItemUtility15UPnPDateAsTTimeERK6TDesC8R5TTime @ 12 NONAME
+	_ZN15UPnPItemUtility17FindElementByNameERK11CUpnpObjectRK6TDesC8 @ 13 NONAME
+	_ZN15UPnPItemUtility17ResourceFromItemLERK9CUpnpItem @ 14 NONAME
+	_ZN15UPnPItemUtility18FindElementByNameLERK11CUpnpObjectRK6TDesC8 @ 15 NONAME
+	_ZN15UPnPItemUtility19FindAttributeByNameERK12CUpnpElementRK6TDesC8 @ 16 NONAME
+	_ZN15UPnPItemUtility20FindAttributeByNameLERK12CUpnpElementRK6TDesC8 @ 17 NONAME
+	_ZN15UPnPItemUtility26UPnPDurationAsMillisecondsERK6TDesC8Ri @ 18 NONAME
+	_ZN23UPnPInternalFileUtility18CreateTmpFileNameLERK9CUpnpItem @ 19 NONAME
+	_ZN23UPnPInternalFileUtility28GetSelectedDownloadLocationLEv @ 20 NONAME
+	_ZN23UPnPItemResolverFactory21NewLocalItemResolverLERK7TDesC16R17MUPnPAVControllerR21MUPnPResourceSelectori @ 21 NONAME
+	_ZN23UPnPItemResolverFactory22NewRemoteItemResolverLERK6TDesC8R22MUPnPAVBrowsingSessionR21MUPnPResourceSelectorS2_i @ 22 NONAME
+	_ZN23UPnPItemResolverFactory24NewDownloadItemResolverLERK6TDesC8R17MUPnPAVControllerR22MUPnPAVBrowsingSessionR21MUPnPResourceSelectorS2_i @ 23 NONAME
+	_ZN24TUPnPSelectFirstResource15SelectResourceLERK9CUpnpItem @ 24 NONAME
+	_ZN25CUPnPDownloadItemResolver24DeleteTempDownloadFilesLEv @ 25 NONAME
+	_ZN26TUPnPSelectDefaultResource15SelectResourceLERK9CUpnpItem @ 26 NONAME
+	_ZN36CUPnPAbstractBrowsingSessionObserver10SetSessionER22MUPnPAVBrowsingSession @ 27 NONAME
+	_ZN36CUPnPAbstractBrowsingSessionObserver21EnableSessionObserverEv @ 28 NONAME
+	_ZN36CUPnPAbstractBrowsingSessionObserver22DisableSessionObserverEv @ 29 NONAME
+	_ZN36CUPnPAbstractBrowsingSessionObserver24IsSessionObserverEnabledEv @ 30 NONAME
+	_ZN36CUPnPAbstractBrowsingSessionObserverC1Ev @ 31 NONAME
+	_ZN36CUPnPAbstractBrowsingSessionObserverC2Ev @ 32 NONAME
+	_ZN36CUPnPAbstractBrowsingSessionObserverD0Ev @ 33 NONAME
+	_ZN36CUPnPAbstractBrowsingSessionObserverD1Ev @ 34 NONAME
+	_ZN36CUPnPAbstractBrowsingSessionObserverD2Ev @ 35 NONAME
+	_ZN37CUPnPAbstractRenderingSessionObserver10SetSessionER23MUPnPAVRenderingSession @ 36 NONAME
+	_ZN37CUPnPAbstractRenderingSessionObserver21EnableSessionObserverEv @ 37 NONAME
+	_ZN37CUPnPAbstractRenderingSessionObserver22DisableSessionObserverEv @ 38 NONAME
+	_ZN37CUPnPAbstractRenderingSessionObserver24IsSessionObserverEnabledEv @ 39 NONAME
+	_ZN37CUPnPAbstractRenderingSessionObserverC1Ev @ 40 NONAME
+	_ZN37CUPnPAbstractRenderingSessionObserverC2Ev @ 41 NONAME
+	_ZN37CUPnPAbstractRenderingSessionObserverD0Ev @ 42 NONAME
+	_ZN37CUPnPAbstractRenderingSessionObserverD1Ev @ 43 NONAME
+	_ZN37CUPnPAbstractRenderingSessionObserverD2Ev @ 44 NONAME
+	_ZTI22CUPnPLocalItemResolver @ 45 NONAME ; #<TI>#
+	_ZTI23CUPnPRemoteItemResolver @ 46 NONAME ; #<TI>#
+	_ZTI24TUPnPSelectFirstResource @ 47 NONAME ; #<TI>#
+	_ZTI25CUPnPDownloadItemResolver @ 48 NONAME ; #<TI>#
+	_ZTI26TUPnPSelectDefaultResource @ 49 NONAME ; #<TI>#
+	_ZTI36CUPnPAbstractBrowsingSessionObserver @ 50 NONAME ; #<TI>#
+	_ZTI37CUPnPAbstractRenderingSessionObserver @ 51 NONAME ; #<TI>#
+	_ZTV22CUPnPLocalItemResolver @ 52 NONAME ; #<VT>#
+	_ZTV23CUPnPRemoteItemResolver @ 53 NONAME ; #<VT>#
+	_ZTV24TUPnPSelectFirstResource @ 54 NONAME ; #<VT>#
+	_ZTV25CUPnPDownloadItemResolver @ 55 NONAME ; #<VT>#
+	_ZTV26TUPnPSelectDefaultResource @ 56 NONAME ; #<VT>#
+	_ZTV36CUPnPAbstractBrowsingSessionObserver @ 57 NONAME ; #<VT>#
+	_ZTV37CUPnPAbstractRenderingSessionObserver @ 58 NONAME ; #<VT>#
--- a/upnpavcontroller/upnpavcontrollerhelper/group/upnpavcontrollerhelper.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/group/upnpavcontrollerhelper.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,80 +1,96 @@
-/*
-* Copyright (c) 2007 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:      project file for AVController helper library
-*
-*/
-
-
-
-
-
-
-#include "../../../group/upnpplatformvar.hrh"
-
-TARGET          upnpavcontrollerhelper.dll
-TARGETTYPE      dll
-UID             0x1000008D 0x20009CA8
-
-CAPABILITY      CAP_GENERAL_DLL
-VENDORID        VID_DEFAULT
-
-VERSION         10.1
-paged
-
-SOURCEPATH      ../src 
-SOURCE          upnpitemutility.cpp
-SOURCE          upnpfileutility.cpp
-SOURCE          upnpdlnautility.cpp
-SOURCE          upnpitemresolverfactory.cpp
-SOURCE          upnpremoteitemresolver.cpp
-SOURCE          upnplocalitemresolver.cpp
-SOURCE          upnpdownloaditemresolver.cpp
-SOURCE          upnpresourceselector.cpp
-SOURCE          upnpabstractbrowsingsessionobserver.cpp
-SOURCE          upnpabstractrenderingsessionobserver.cpp
-SOURCE          upnpinternalfileutility.cpp
-
-USERINCLUDE     ../inc
-USERINCLUDE     ../../inc
-
-MW_LAYER_SYSTEMINCLUDE 
-USERINCLUDE   ../../../inc
-
-// system
-LIBRARY         euser.lib
-LIBRARY         estor.lib
-LIBRARY         bafl.lib
-LIBRARY         drmcommon.lib  // OEM-DRM
-LIBRARY         caf.lib // WM-DRM
-LIBRARY         cafutils.lib // WM-DRM
-LIBRARY         efsrv.lib // RFs
-LIBRARY         PlatformEnv.lib // PathInfo
-LIBRARY         insock.lib // TInetAddr
-
-// S60 upnp stack
-LIBRARY         upnpavobjects.lib // CUpnpObject, ...
-LIBRARY         upnpipserversutils.lib // CUpnpDlnaProtocolInfo
-LIBRARY         avmediaserverclient.lib // file sharing
-
-// other upnp components
-LIBRARY         upnpavcontrollerclient.lib
-LIBRARY         upnpxmlparser.lib // browse response
-LIBRARY         upnputilities.lib // CreateItemFromFileLC
-LIBRARY         upnpsettingsengine.lib // SettingsEngine
-LIBRARY         upnpsecurity.lib // SecAccessController
-
-// debug
-DEBUGLIBRARY    flogger.lib
-
-// End of file
+/*
+* Copyright (c) 2007 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:      project file for AVController helper library
+*
+*/
+
+
+
+
+
+
+#include "../../../group/upnpplatformvar.hrh"
+#include "../../../inc/upnpframeworkfeatures_mmp.hrh" // __UPNP_CONSOLE_MT__
+
+TARGET          upnpavcontrollerhelper.dll
+TARGETTYPE      dll
+UID             0x1000008D 0x20009CA8
+
+EPOCALLOWDLLDATA
+
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+VERSION         10.1
+paged
+
+SOURCEPATH      ../src 
+SOURCE          upnpitemutility.cpp
+SOURCE          upnpfileutility.cpp
+SOURCE          upnpdlnautility.cpp
+SOURCE          upnpitemresolverfactory.cpp
+SOURCE          upnpremoteitemresolver.cpp
+SOURCE          upnplocalitemresolver.cpp
+SOURCE          upnpdownloaditemresolver.cpp
+SOURCE          upnpresourceselector.cpp
+SOURCE          upnpabstractbrowsingsessionobserver.cpp
+SOURCE          upnpabstractrenderingsessionobserver.cpp
+SOURCE          upnpinternalfileutility.cpp
+SOURCE          upnppushserver.cpp
+#ifdef UPNP_USE_GSTREAMER
+SOURCE          upnptranscodehelper.cpp
+#endif
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+
+// System include paths
+MW_LAYER_SYSTEMINCLUDE 
+USERINCLUDE   ../../../inc
+
+// system
+LIBRARY         euser.lib
+LIBRARY         estor.lib
+LIBRARY         bafl.lib
+LIBRARY         drmcommon.lib  // OEM-DRM
+LIBRARY         caf.lib // WM-DRM
+LIBRARY         cafutils.lib // WM-DRM
+LIBRARY         efsrv.lib // RFs
+LIBRARY         PlatformEnv.lib // PathInfo
+LIBRARY         insock.lib // TInetAddr
+LIBRARY         esock.lib // TSockAddr 
+
+// dlnasrv
+LIBRARY         upnpavobjects.lib // CUpnpObject, ...
+LIBRARY         upnpipserversutils.lib // CUpnpDlnaProtocolInfo
+LIBRARY         avmediaserverclient.lib // file sharing
+LIBRARY         upnpavcontrollerclient.lib
+LIBRARY         upnpxmlparser.lib // browse response
+LIBRARY         upnputilities.lib // CreateItemFromFileLC
+LIBRARY         upnpsettingsengine.lib // SettingsEngine
+LIBRARY         upnpsecurity.lib // SecAccessController
+LIBRARY         dlnawebserver.lib // MUpnpHttpServerObserver
+LIBRARY         avcontentdirectory.lib //upnpdlnafilter
+LIBRARY         mpxcollectionhelper.lib
+LIBRARY         mpxcommon.lib
+LIBRARY         upnpthumbnailcreator.lib
+LIBRARY         dlnaprofiler.lib
+#ifdef UPNP_USE_GSTREAMER
+LIBRARY         upnpgstwrapper.lib
+#endif
+
+// debug
+DEBUGLIBRARY    flogger.lib
+
+// End of file
--- a/upnpavcontroller/upnpavcontrollerhelper/inc/upnpabstractbrowsingsessionobserver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/inc/upnpabstractbrowsingsessionobserver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,178 +1,173 @@
-/*
-* Copyright (c) 2007 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:      An abstract browsing session observer implementation
-*
-*/
-
-
-
-
-
-
-#ifndef UPNPABSTRACTBROWSINGSESSIONOBSERVER_H
-#define UPNPABSTRACTBROWSINGSESSIONOBSERVER_H
-
-//  INCLUDES
-#include <e32base.h>
-#include "upnpavbrowsingsessionobserver.h" // base class
-
-// FORWARD DECLARATIONS
-class MUPnPAVBrowsingSession;
-
-// CLASS DECLARATION
-
-/**
-* An abstract class for implementing a browsing session observer.
-* This class is purposed as a base class for imnplementing a
-* browsing observer. There are 2 main use cases:
-* 1. reducing implementation code so that the actual observer will
-*    only need to write the observer methods that are really used.
-* 2. implementing an observer proxy that will attach itself to a session
-*    and just handle some of the callbacks and forward a majority of the
-*    callbacks the original session observer.
-*
-* @lib upnpavcontrollerhelper.lib
-* @since S60 3.2
-*/
-class CUPnPAbstractBrowsingSessionObserver
-    : public CBase
-    , public MUPnPAVBrowsingSessionObserver
-    {
-
-public: // construction/destruction
-
-    /**
-     * default constructor.
-     */
-    IMPORT_C CUPnPAbstractBrowsingSessionObserver();
-
-    /**
-     * destructor
-     */
-    IMPORT_C virtual ~CUPnPAbstractBrowsingSessionObserver();
-
-
-public: // the abstract observer interface
-
-    /**
-     * Sets the host session for the observer. This is the session where
-     * the observer will register for callbacks. If the session already
-     * has an observer, it will become the proxy observer. The default
-     * implementatin for all observer methods is to forward the method to
-     * the observer, if it exists.
-     *
-     * @since S60 3.2
-     * @param aHostSession, browsing session
-     */
-    IMPORT_C void SetSession( MUPnPAVBrowsingSession& aHostSession );
-
-    /**
-     * Enables receiving callbacks. When enabled, the abstract observer
-     * registers to the given session and thus starts receiving callbacks.
-     * Note that only those callbacks that are overwritten in the derived
-     * class will actually provide some value. Other will be either processed
-     * in an empty method, or forwarded to the observer that previously was
-     * registered as an observer (proxy mode)
-     *
-     * @since S60 3.2
-     */
-    IMPORT_C void EnableSessionObserver();
-
-    /**
-     * Disables receiving session callbacks. The observer interface is
-     * deregistered, and if before observer registration there was an 
-     * original observer interface (proxy mode) the original observer
-     * is restored.
-     *
-     * @since S60 3.2
-     */
-    IMPORT_C void DisableSessionObserver();
-
-    /**
-     * Returns true if the observer is active (registered for events)
-     *
-     * @since S60 3.2
-     */
-    IMPORT_C TBool IsSessionObserverEnabled();
-
-public: // MUPnPAVBrowsingSessionObserver
-
-    /**
-     * see MUPnPAVBrowsingSessionObserver
-     */
-    void BrowseResponse(
-        const TDesC8& aBrowseResponse,
-        TInt aError,
-        TInt aMatches,
-        TInt aTotalCount,
-        const TDesC8& aUpdateId );
-
-    /**
-     * see MUPnPAVBrowsingSessionObserver
-     */
-    void SearchResponse( 
-        const TDesC8& aSearchResponse,
-        TInt aError,
-        TInt aMatches,
-        TInt aTotalCount,
-        const TDesC8& aUpdateId );
-
-    /**
-     * see MUPnPAVBrowsingSessionObserver
-     */
-    void SearchCapabilitiesResponse( 
-        TInt aError,
-        const TDesC8& aSearchCapabilities );
-
-    /**
-     * see MUPnPAVBrowsingSessionObserver
-     */
-    void CreateContainerResponse( TInt aError, 
-        const TDesC8& aObjectId );
-
-    /**
-     * see MUPnPAVBrowsingSessionObserver
-     */
-    void DeleteObjectResponse( TInt aError );
-
-    /**
-     * see MUPnPAVBrowsingSessionObserver
-     */
-    void ReserveLocalMSServicesCompleted( TInt aError );
-
-    /**
-     * see MUPnPAVBrowsingSessionObserver
-     */
-    void MediaServerDisappeared(
-        TUPnPDeviceDisconnectedReason aReason );
-
-
-private: // members
-
-    // the host browsing session. Note: NOT OWNED!
-    MUPnPAVBrowsingSession* iObservedSession;
-
-    // The proxy observer. Note: NOT OWNED!
-    MUPnPAVBrowsingSessionObserver* iProxyObserver;
-
-    // if observer is enabled
-    TBool iObserverEnabled;
-
-    };
-
-
-#endif  // UPNPABSTRACTBROWSINGSESSIONOBSERVER_H
-
-// End of File
-
+/*
+* Copyright (c) 2007-2009 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:      An abstract browsing session observer implementation
+*
+*/
+
+
+
+
+
+
+#ifndef UPNPABSTRACTBROWSINGSESSIONOBSERVER_H
+#define UPNPABSTRACTBROWSINGSESSIONOBSERVER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include "upnpavbrowsingsessionobserver.h" // base class
+
+// FORWARD DECLARATIONS
+class MUPnPAVBrowsingSession;
+
+// CLASS DECLARATION
+
+/**
+* An abstract class for implementing a browsing session observer.
+* This class is purposed as a base class for imnplementing a
+* browsing observer. There are 2 main use cases:
+* 1. reducing implementation code so that the actual observer will
+*    only need to write the observer methods that are really used.
+* 2. implementing an observer proxy that will attach itself to a session
+*    and just handle some of the callbacks and forward a majority of the
+*    callbacks the original session observer.
+*
+* @lib upnpavcontrollerhelper.lib
+* @since S60 3.2
+*/
+class CUPnPAbstractBrowsingSessionObserver
+    : public CBase
+    , public MUPnPAVBrowsingSessionObserver
+    {
+
+public: // construction/destruction
+
+    /**
+     * default constructor.
+     */
+    IMPORT_C CUPnPAbstractBrowsingSessionObserver();
+
+    /**
+     * destructor
+     */
+    IMPORT_C virtual ~CUPnPAbstractBrowsingSessionObserver();
+
+
+public: // the abstract observer interface
+
+    /**
+     * Sets the host session for the observer. This is the session where
+     * the observer will register for callbacks. If the session already
+     * has an observer, it will become the proxy observer. The default
+     * implementatin for all observer methods is to forward the method to
+     * the observer, if it exists.
+     *
+     * @since S60 3.2
+     * @param aHostSession, browsing session
+     */
+    IMPORT_C void SetSession( MUPnPAVBrowsingSession& aHostSession );
+
+    /**
+     * Enables receiving callbacks. When enabled, the abstract observer
+     * registers to the given session and thus starts receiving callbacks.
+     * Note that only those callbacks that are overwritten in the derived
+     * class will actually provide some value. Other will be either processed
+     * in an empty method, or forwarded to the observer that previously was
+     * registered as an observer (proxy mode)
+     *
+     * @since S60 3.2
+     */
+    IMPORT_C void EnableSessionObserver();
+
+    /**
+     * Disables receiving session callbacks. The observer interface is
+     * deregistered, and if before observer registration there was an 
+     * original observer interface (proxy mode) the original observer
+     * is restored.
+     *
+     * @since S60 3.2
+     */
+    IMPORT_C void DisableSessionObserver();
+
+    /**
+     * Returns true if the observer is active (registered for events)
+     *
+     * @since S60 3.2
+     */
+    IMPORT_C TBool IsSessionObserverEnabled();
+
+public: // MUPnPAVBrowsingSessionObserver
+
+    /**
+     * see MUPnPAVBrowsingSessionObserver
+     */
+    void BrowseResponse(
+        const TDesC8& aBrowseResponse,
+        TInt aError,
+        TInt aMatches,
+        TInt aTotalCount,
+        const TDesC8& aUpdateId );
+
+    /**
+     * see MUPnPAVBrowsingSessionObserver
+     */
+    void SearchResponse( 
+        const TDesC8& aSearchResponse,
+        TInt aError,
+        TInt aMatches,
+        TInt aTotalCount,
+        const TDesC8& aUpdateId );
+
+    /**
+     * see MUPnPAVBrowsingSessionObserver
+     */
+    void SearchCapabilitiesResponse( 
+        TInt aError,
+        const TDesC8& aSearchCapabilities );
+
+    /**
+     * see MUPnPAVBrowsingSessionObserver
+     */
+    void CreateContainerResponse( TInt aError, 
+        const TDesC8& aObjectId );
+
+    /**
+     * see MUPnPAVBrowsingSessionObserver
+     */
+    void DeleteObjectResponse( TInt aError );
+
+    /**
+     * see MUPnPAVBrowsingSessionObserver
+     */
+    void MediaServerDisappeared(
+        TUPnPDeviceDisconnectedReason aReason );
+
+
+private: // members
+
+    // the host browsing session. Note: NOT OWNED!
+    MUPnPAVBrowsingSession* iObservedSession;
+
+    // The proxy observer. Note: NOT OWNED!
+    MUPnPAVBrowsingSessionObserver* iProxyObserver;
+
+    // if observer is enabled
+    TBool iObserverEnabled;
+
+    };
+
+
+#endif  // UPNPABSTRACTBROWSINGSESSIONOBSERVER_H
+
+// End of File
+
--- a/upnpavcontroller/upnpavcontrollerhelper/inc/upnpabstractrenderingsessionobserver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/inc/upnpabstractrenderingsessionobserver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,174 +1,168 @@
-/*
-* Copyright (c) 2007 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:      An abstract proxy for a rendering session observer
-*
-*/
-
-
-
-
-
-
-#ifndef UPNPABSTRACTRENDERINGSESSIONOBSERVER_H
-#define UPNPABSTRACTRENDERINGSESSIONOBSERVER_H
-
-//  INCLUDES
-#include <e32base.h>
-#include "upnpavrenderingsessionobserver.h" // base class
-
-// FORWARD DECLARATIONS
-class MUPnPAVRenderingSession;
-
-// CLASS DECLARATION
-
-/**
-* An abstract class for implementing a rendering session observer.
-* This class is purposed as a base class for imnplementing a
-* rendering session observer. There are 2 main use cases:
-* 1. reducing implementation code so that the actual observer will
-*    only need to write the observer methods that are really used.
-* 2. implementing an observer proxy that will attach itself to a session
-*    and just handle some of the callbacks and forward a majority of the
-*    callbacks the original session observer.
-*
-* @lib upnpavcontrollerhelper.lib
-* @since S60 3.2
-*/
-class CUPnPAbstractRenderingSessionObserver
-    : public CBase
-    , public MUPnPAVRenderingSessionObserver
-    {
-
-public: // construction/destruction
-
-    /**
-     * default constructor.
-     */
-    IMPORT_C CUPnPAbstractRenderingSessionObserver();
-
-    /**
-     * destructor
-     */
-    IMPORT_C virtual ~CUPnPAbstractRenderingSessionObserver();
-
-
-public: // the abstract observer interface
-
-    /**
-     * Sets the host session for the observer. This is the session where
-     * the observer will register for callbacks. If the session already
-     * has an observer, it will become the proxy observer. The default
-     * implementatin for all observer methods is to forward the method to
-     * the observer, if it exists.
-     *
-     * @since S60 3.2
-     * @param aHostSession, rendering session
-     */
-    IMPORT_C void SetSession( MUPnPAVRenderingSession& aHostSession );
-
-    /**
-     * Enables receiving callbacks. When enabled, the abstract observer
-     * registers to the given session and thus starts receiving callbacks.
-     * Note that only those callbacks that are overwritten in the derived
-     * class will actually provide some value. Other will be either processed
-     * in an empty method, or forwarded to the observer that previously was
-     * registered as an observer (proxy mode)
-     *
-     * @since S60 3.2
-     */
-    IMPORT_C void EnableSessionObserver();
-
-    /**
-     * Disables receiving session callbacks. The observer interface is
-     * deregistered, and if before observer registration there was an 
-     * original observer interface (proxy mode) the original observer
-     * is restored.
-     *
-     * @since S60 3.2
-     */
-    IMPORT_C void DisableSessionObserver();
-
-    /**
-     * Returns true if the observer is active (registered for events)
-     *
-     * @since S60 3.2
-     */
-    IMPORT_C TBool IsSessionObserverEnabled();
-
-public: // MUPnPAVRenderingSessionObserver
-
-    /**
-     * see MUPnPAVRenderingSessionObserver
-     */
-    void VolumeResult( TInt aError, TInt aVolumeLevel,
-        TBool aActionResponse );
-
-    /**
-     * see MUPnPAVRenderingSessionObserver
-     */
-    void MuteResult( TInt aError, TBool aMute,
-        TBool aActionResponse );
-
-    /**
-     * see MUPnPAVRenderingSessionObserver
-     */
-    void InteractOperationComplete( TInt aError,
-        TUPnPAVInteractOperation aOperation );
-
-    /**
-     * see MUPnPAVRenderingSessionObserver
-     */
-    void PositionInfoResult( TInt aError,
-        const TDesC8& aTrackPosition, const TDesC8& aTrackLength );
-
-    /**
-     * see MUPnPAVRenderingSessionObserver
-     */
-    void SetURIResult( TInt aError );
-
-    /**
-     * see MUPnPAVRenderingSessionObserver
-     */
-    void SetNextURIResult( TInt aError );
-
-    /**
-     * see MUPnPAVRenderingSessionObserver
-     */
-    void MediaRendererDisappeared(
-        TUPnPDeviceDisconnectedReason aReason );
-
-    /**
-     * see MUPnPAVRenderingSessionObserver
-     */
-    void ReserveLocalMSServicesCompleted( TInt aError );
-
-
-private: // members
-
-    // the host rendering session. Note: NOT OWNED!
-    MUPnPAVRenderingSession* iObservedSession;
-
-    // The proxy observer. Note: NOT OWNED!
-    MUPnPAVRenderingSessionObserver* iProxyObserver;
-
-    // if observer is enabled
-    TBool iObserverEnabled;
-
-    };
-
-
-#endif  // UPNPABSTRACTRENDERINGSESSIONOBSERVER_H
-
-// End of File
-
+/*
+* Copyright (c) 2007-2009 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:      An abstract proxy for a rendering session observer
+*
+*/
+
+
+
+
+
+
+#ifndef UPNPABSTRACTRENDERINGSESSIONOBSERVER_H
+#define UPNPABSTRACTRENDERINGSESSIONOBSERVER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include "upnpavrenderingsessionobserver.h" // base class
+
+// FORWARD DECLARATIONS
+class MUPnPAVRenderingSession;
+
+// CLASS DECLARATION
+
+/**
+* An abstract class for implementing a rendering session observer.
+* This class is purposed as a base class for imnplementing a
+* rendering session observer. There are 2 main use cases:
+* 1. reducing implementation code so that the actual observer will
+*    only need to write the observer methods that are really used.
+* 2. implementing an observer proxy that will attach itself to a session
+*    and just handle some of the callbacks and forward a majority of the
+*    callbacks the original session observer.
+*
+* @lib upnpavcontrollerhelper.lib
+* @since S60 3.2
+*/
+class CUPnPAbstractRenderingSessionObserver
+    : public CBase
+    , public MUPnPAVRenderingSessionObserver
+    {
+
+public: // construction/destruction
+
+    /**
+     * default constructor.
+     */
+    IMPORT_C CUPnPAbstractRenderingSessionObserver();
+
+    /**
+     * destructor
+     */
+    IMPORT_C virtual ~CUPnPAbstractRenderingSessionObserver();
+
+
+public: // the abstract observer interface
+
+    /**
+     * Sets the host session for the observer. This is the session where
+     * the observer will register for callbacks. If the session already
+     * has an observer, it will become the proxy observer. The default
+     * implementatin for all observer methods is to forward the method to
+     * the observer, if it exists.
+     *
+     * @since S60 3.2
+     * @param aHostSession, rendering session
+     */
+    IMPORT_C void SetSession( MUPnPAVRenderingSession& aHostSession );
+
+    /**
+     * Enables receiving callbacks. When enabled, the abstract observer
+     * registers to the given session and thus starts receiving callbacks.
+     * Note that only those callbacks that are overwritten in the derived
+     * class will actually provide some value. Other will be either processed
+     * in an empty method, or forwarded to the observer that previously was
+     * registered as an observer (proxy mode)
+     *
+     * @since S60 3.2
+     */
+    IMPORT_C void EnableSessionObserver();
+
+    /**
+     * Disables receiving session callbacks. The observer interface is
+     * deregistered, and if before observer registration there was an 
+     * original observer interface (proxy mode) the original observer
+     * is restored.
+     *
+     * @since S60 3.2
+     */
+    IMPORT_C void DisableSessionObserver();
+
+    /**
+     * Returns true if the observer is active (registered for events)
+     *
+     * @since S60 3.2
+     */
+    IMPORT_C TBool IsSessionObserverEnabled();
+
+public: // MUPnPAVRenderingSessionObserver
+
+    /**
+     * see MUPnPAVRenderingSessionObserver
+     */
+    void VolumeResult( TInt aError, TInt aVolumeLevel,
+        TBool aActionResponse );
+
+    /**
+     * see MUPnPAVRenderingSessionObserver
+     */
+    void MuteResult( TInt aError, TBool aMute,
+        TBool aActionResponse );
+
+    /**
+     * see MUPnPAVRenderingSessionObserver
+     */
+    void InteractOperationComplete( TInt aError,
+        TUPnPAVInteractOperation aOperation );
+
+    /**
+     * see MUPnPAVRenderingSessionObserver
+     */
+    void PositionInfoResult( TInt aError,
+        const TDesC8& aTrackPosition, const TDesC8& aTrackLength );
+
+    /**
+     * see MUPnPAVRenderingSessionObserver
+     */
+    void SetURIResult( TInt aError );
+
+    /**
+     * see MUPnPAVRenderingSessionObserver
+     */
+    void SetNextURIResult( TInt aError );
+
+    /**
+     * see MUPnPAVRenderingSessionObserver
+     */
+    void MediaRendererDisappeared(
+        TUPnPDeviceDisconnectedReason aReason );
+
+private: // members
+
+    // the host rendering session. Note: NOT OWNED!
+    MUPnPAVRenderingSession* iObservedSession;
+
+    // The proxy observer. Note: NOT OWNED!
+    MUPnPAVRenderingSessionObserver* iProxyObserver;
+
+    // if observer is enabled
+    TBool iObserverEnabled;
+
+    };
+
+
+#endif  // UPNPABSTRACTRENDERINGSESSIONOBSERVER_H
+
+// End of File
+
--- a/upnpavcontroller/upnpavcontrollerhelper/inc/upnpconstantdefs.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/inc/upnpconstantdefs.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,321 +1,322 @@
-/*
-* Copyright (c) 2006-2007 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:      UPnP Object-related constant definitions
-*
-*/
-
-
-
-
-
-
-// System includes
-#include <e32base.h>
-
-// ***************************************************
-// * Upnp interface is full of constants that come
-// * directly from upnp specifications. This file
-// * contains some most commonly used definitions
-// * for your comfort.
-// ***************************************************
-
-
-
-// ***************************************************
-// * Classes
-// * 
-// * Note: when comparing object class, the class
-// * constant MUST be found in beginning:
-// * 
-// * if ( object.ObjectClass().Find( KClassContainer ) == 0 )
-// *     { ...
-// * 
-// * 
-// ***************************************************
-
-// item. This means the object represents something
-// rather than containing child objects
-_LIT8( KClassItem,        "object.item" );
-
-// the item represents an image media
-_LIT8( KClassImage,       "object.item.imageItem" );
-
-// the item represents a video media
-_LIT8( KClassVideo,       "object.item.videoItem" );
-
-// the item represents an audio media
-_LIT8( KClassAudio,       "object.item.audioItem" );
-
-// the item represents a music track
-_LIT8( KClassAudioMusicTrack, "object.item.audioItem.musicTrack" );
-
-// the object is a container that can contain child objects
-_LIT8( KClassContainer,   "object.container" );
-
-// container that represents a playlist
-_LIT8( KClassPlaylist,    "object.container.playlistContainer" );
-
-// container that represents an album of music tracks
-_LIT8( KClassAlbum,       "object.container.album.musicAlbum" );
-
-// container that represents a generic media storage
-_LIT8( KClassStorage,    "object.container.storageFolder" );
-
-
-
-// ***************************************************
-// * Elements
-// * 
-// * Use these when finding an apropriate element
-// * within an object. Useful with 2 helper utility
-// * functions:
-// * 
-// * const CUpnpElement* e = UPnPCommonUtils::
-// *     FindElementByName( object, KElementDate );
-// * if ( e ) {
-// *     const TDesC& d = e->Value();
-// *     ...
-// * 
-// * const TDesC8& d = UPnPCommonUtils::
-// *     FindElementByNameL( object, KElementDate ).Value();
-// * 
-// * The former is useful if we are not sure if the
-// * element exists, the latter if the element MUST
-// * exist to proceed.
-// * 
-// ***************************************************
-
-// The title. Mandatory for all objects.
-_LIT8( KElementTitle,           "dc:title" );
-
-// The class. Mandatory for all objects.
-_LIT8( KElementClass,           "upnp:class" );
-
-// media timestamp. In DLNA mandatory for images and videos
-_LIT8( KElementDate,            "dc:date" );
-
-// Creator of the media. In DLNA mandatory for music tracks and albums
-_LIT8( KElementCreator,         "dc:creator" );
-
-// The artist. De facto standard in upnp, but not mandatory.
-// could be understood as an alias to dc:creator
-_LIT8( KElementArtist,          "upnp:artist");
-
-// Album this media belongs to. in DLNA mandatory for audio tracks
-_LIT8( KElementAlbum,           "upnp:album");
-
-// Genre. in DLNA mandatory for audio and video
-_LIT8( KElementGenre,           "upnp:genre");
-
-// The res element. Defines the resource of the item.
-_LIT8( KElementRes,             "res");
-
-// The SortCriteria, Search by default 
-_LIT8( KSortCriteria,           "+dc:title");
-
-// The albumArtURI
-_LIT8( KElementAlbumArtUri,     "upnp:albumArtURI");
-
-// Song track number
-_LIT8( KElementTrackNumber,     "upnp:originalTrackNumber");
-
-
-// ***************************************************
-// * Element attributes
-// * 
-// * Use these when finding an attribute within an
-// * element.
-// * 
-// * const CUpnpElement& resource = UPnPCommonUtils
-// *     ::ResourceFromItemL( object );
-// * const TDesC8& size = UPnPCommonUtils
-// *     ::FindAttributeByNameL( resource, KAttributeSize )
-// *     .Value();
-// * const TDesC8& duration = UPnPCommonUtils
-// *     ::FindAttributeByNameL( resource, KAttributeDuration )
-// *     .Value();
-// * 
-// ***************************************************
-
-// attribute of RES element
-// media size in bytes. Used for all media.
-_LIT8( KAttributeSize,         "size" );
-
-// attribute of RES element
-// image resolution: "<XDIM>x<YDIM>", example "1024x768"
-// used for images and video.
-_LIT8( KAttributeResolution,   "resolution" );
-
-// attribute of RES element
-// song duration, "hh:mm:ss.yyy", example "00:03:15.000"
-// used for audio and video
-_LIT8( KAttributeDuration,     "duration" );
-
-// attribute of RES element
-// UPNP and DLNA specific technical data
-_LIT8( KAttributeProtocolInfo, "protocolInfo" );
-
-// attribute of RES element
-// bitrate. used in
-_LIT8( KAttributeBitrate,      "bitrate" );
-
-
-
-// ***************************************************
-// * Filters and sorting
-// * 
-// * Pre-defined constants for browse or search.
-// * The filters determine which elements the remote
-// * server is adding into the response. Querying
-// * only the required elements will speed up the
-// * application.
-// *
-// * Sort criteria defines the order of returned
-// * elements.
-// * 
-// * iBs->BrowseL( _L("0"), KFilterFull,
-// *     MUPnPAVBrowsingSession::EDirectChildren,
-// *     0, 100, KSortNone );
-// * 
-// ***************************************************
-
-// full filter, returns everything
-_LIT8( KFilterFull, "*" );
-
-// filter only minimum data (object id)
-_LIT8( KFilterMin, "" );
-
-// filter only object key data and title
-_LIT8( KFilterTitle, "dc:title" );
-
-// Filter most commonly used and mandatory DLNA field
-_LIT8( KFilterCommon, "dc:title,dc:date,dc:creator,"
-    "upnp:originalTrackNumber,"
-    "upnp:album,upnp:artist,upnp:genre,upnp:albumArtURI,"
-    "res,res@size,res@duration" );
-
-// sort criteria: let server decide
-_LIT8( KSortNone, "" );
-
-// sort criteria: sort by object title
-_LIT8( KSortTitle, "dc:title" );
-
-
-
-
-// ***************************************************
-// * Constant container ID's
-// * 
-// * Some container ID's are defined as constants
-// * and have special meaning.
-// *
-// * Root container: the container that recursively
-// * contains all other containers. This container
-// * is not contained in any other container.
-// * 
-// * Any container: used when addressing a remote
-// * container. Lets the remote mediaserver decide
-// * an apropriate container.
-// * 
-// ***************************************************
-
-// the root container
-_LIT8( KContainerIdRoot, "0" );
-
-// Anycontainer
-_LIT8( KContainerIdAny,  "DLNA.ORG_AnyContainer" );
-
-
-
-// ***************************************************
-// * Constructing search criteria
-// * 
-// * Some useful constants that are used in generating
-// * search criteria fields
-// * 
-// * Please see UPnP specifications for more details
-// * 
-// ***************************************************
-
-// searches for elements that contain given partial string
-_LIT8( KCriteriaContains, "contains" );
-
-// searches for classes or any child classes of given class
-_LIT8( KCriteriaDerivedFrom, "derivedfrom" );
-
-// searches for classes where an element exists
-_LIT8( KCriteriaExists, "exists" );
-
-// negates the boolean operator
-_LIT8( KCriteriaFalse, "false" );
-
-// logical AND
-_LIT8( KCriteriaAnd, "and" );
-
-// logical OR
-_LIT8( KCriteriaOr, "or" );
-
-// logical comparision
-_LIT8( KCriteriaEQ, "=" );
-_LIT8( KCriteriaNEQ, "!=" );
-_LIT8( KCriteriaGT, ">" );
-_LIT8( KCriteriaLT, "<" );
-_LIT8( KCriteriaGTE, ">=" );
-_LIT8( KCriteriaLTE, "<=" );
-_LIT8( KCriteriaOB, "(" );
-_LIT8( KCriteriaCB, ")" );
-
-// other useful for filling up the strings
-_LIT8( KCriteriaQuot, "\"" );
-_LIT8( KCriteriaSpace, " " );
-
-
-
-// ***************************************************
-// * DLNA Transfer modes
-// * 
-// * Please see DLNA specifications for more details
-// ***************************************************
-_LIT8( KTransferMode, "transferMode.dlna.org" );
-_LIT8( KBackgroundMode, "Background" );
-_LIT8( KStreamingMode, "Streaming" );
-_LIT8( KInteractiveMode, "Interactive" );
-
-
-// ***************************************************
-// * DLNA Content headers
-// * 
-// * Please see DLNA specifications for more details
-// ***************************************************
-_LIT8( KContentType, "Content-Type" );
-_LIT8( KContentFeatures, "contentFeatures.dlna.org" );
-
-
-// ***************************************************
-// * DLNA headers misc.
-// * 
-// * Please see DLNA specifications for more details
-// ***************************************************
-_LIT8( KExpectHeader, "Expect" );
-_LIT8( K100Continue, "100-continue" );
-
-
-// ***************************************************
-// * Misc
-// * 
-// ***************************************************
-
-// attribute value - not implemented or not supported
-_LIT8( KValueNotImplemented, "NOT_IMPLEMENTED" );
-
+/*
+* Copyright (c) 2006-2007 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:      UPnP Object-related constant definitions
+*
+*/
+
+
+
+
+
+
+// System includes
+#include <e32base.h>
+
+// ***************************************************
+// * Upnp interface is full of constants that come
+// * directly from upnp specifications. This file
+// * contains some most commonly used definitions
+// * for your comfort.
+// ***************************************************
+
+
+
+// ***************************************************
+// * Classes
+// * 
+// * Note: when comparing object class, the class
+// * constant MUST be found in beginning:
+// * 
+// * if ( object.ObjectClass().Find( KClassContainer ) == 0 )
+// *     { ...
+// * 
+// * 
+// ***************************************************
+
+// item. This means the object represents something
+// rather than containing child objects
+_LIT8( KClassItem,        "object.item" );
+
+// the item represents an image media
+_LIT8( KClassImage,       "object.item.imageItem" );
+
+// the item represents a video media
+_LIT8( KClassVideo,       "object.item.videoItem" );
+
+// the item represents an audio media
+_LIT8( KClassAudio,       "object.item.audioItem" );
+
+// the item represents a music track
+_LIT8( KClassAudioMusicTrack, "object.item.audioItem.musicTrack" );
+
+// the object is a container that can contain child objects
+_LIT8( KClassContainer,   "object.container" );
+
+// container that represents a playlist
+_LIT8( KClassPlaylist,    "object.container.playlistContainer" );
+
+// container that represents an album of music tracks
+_LIT8( KClassAlbum,       "object.container.album.musicAlbum" );
+
+// container that represents a generic media storage
+_LIT8( KClassStorage,    "object.container.storageFolder" );
+
+
+
+// ***************************************************
+// * Elements
+// * 
+// * Use these when finding an apropriate element
+// * within an object. Useful with 2 helper utility
+// * functions:
+// * 
+// * const CUpnpElement* e = UPnPCommonUtils::
+// *     FindElementByName( object, KElementDate );
+// * if ( e ) {
+// *     const TDesC& d = e->Value();
+// *     ...
+// * 
+// * const TDesC8& d = UPnPCommonUtils::
+// *     FindElementByNameL( object, KElementDate ).Value();
+// * 
+// * The former is useful if we are not sure if the
+// * element exists, the latter if the element MUST
+// * exist to proceed.
+// * 
+// ***************************************************
+
+// The title. Mandatory for all objects.
+_LIT8( KElementTitle,           "dc:title" );
+
+// The class. Mandatory for all objects.
+_LIT8( KElementClass,           "upnp:class" );
+
+// media timestamp. In DLNA mandatory for images and videos
+_LIT8( KElementDate,            "dc:date" );
+
+// Creator of the media. In DLNA mandatory for music tracks and albums
+_LIT8( KElementCreator,         "dc:creator" );
+
+// The artist. De facto standard in upnp, but not mandatory.
+// could be understood as an alias to dc:creator
+_LIT8( KElementArtist,          "upnp:artist");
+
+// Album this media belongs to. in DLNA mandatory for audio tracks
+_LIT8( KElementAlbum,           "upnp:album");
+
+// Genre. in DLNA mandatory for audio and video
+_LIT8( KElementGenre,           "upnp:genre");
+
+// The res element. Defines the resource of the item.
+_LIT8( KElementRes,             "res");
+
+// The SortCriteria, Search by default 
+_LIT8( KSortCriteria,           "+dc:title");
+
+// The albumArtURI
+_LIT8( KElementAlbumArtUri,     "upnp:albumArtURI");
+
+// Song track number
+_LIT8( KElementTrackNumber,     "upnp:originalTrackNumber");
+
+
+// ***************************************************
+// * Element attributes
+// * 
+// * Use these when finding an attribute within an
+// * element.
+// * 
+// * const CUpnpElement& resource = UPnPCommonUtils
+// *     ::ResourceFromItemL( object );
+// * const TDesC8& size = UPnPCommonUtils
+// *     ::FindAttributeByNameL( resource, KAttributeSize )
+// *     .Value();
+// * const TDesC8& duration = UPnPCommonUtils
+// *     ::FindAttributeByNameL( resource, KAttributeDuration )
+// *     .Value();
+// * 
+// ***************************************************
+
+// attribute of RES element
+// media size in bytes. Used for all media.
+_LIT8( KAttributeSize,         "size" );
+
+// attribute of RES element
+// image resolution: "<XDIM>x<YDIM>", example "1024x768"
+// used for images and video.
+_LIT8( KAttributeResolution,   "resolution" );
+
+// attribute of RES element
+// song duration, "hh:mm:ss.yyy", example "00:03:15.000"
+// used for audio and video
+_LIT8( KAttributeDuration,     "duration" );
+
+// attribute of RES element
+// UPNP and DLNA specific technical data
+_LIT8( KAttributeProtocolInfo, "protocolInfo" );
+
+// attribute of RES element
+// bitrate. used in
+_LIT8( KAttributeBitrate,      "bitrate" );
+
+// attribute for album art element
+_LIT8( KAttributeProfileId,    "dlna:profileID" );
+
+// ***************************************************
+// * Filters and sorting
+// * 
+// * Pre-defined constants for browse or search.
+// * The filters determine which elements the remote
+// * server is adding into the response. Querying
+// * only the required elements will speed up the
+// * application.
+// *
+// * Sort criteria defines the order of returned
+// * elements.
+// * 
+// * iBs->BrowseL( _L("0"), KFilterFull,
+// *     MUPnPAVBrowsingSession::EDirectChildren,
+// *     0, 100, KSortNone );
+// * 
+// ***************************************************
+
+// full filter, returns everything
+_LIT8( KFilterFull, "*" );
+
+// filter only minimum data (object id)
+_LIT8( KFilterMin, "" );
+
+// filter only object key data and title
+_LIT8( KFilterTitle, "dc:title" );
+
+// Filter most commonly used and mandatory DLNA field
+_LIT8( KFilterCommon, "dc:title,dc:date,dc:creator,"
+    "upnp:originalTrackNumber,"
+    "upnp:album,upnp:artist,upnp:genre,upnp:albumArtURI,"
+    "res,res@size,res@duration" );
+
+// sort criteria: let server decide
+_LIT8( KSortNone, "" );
+
+// sort criteria: sort by object title
+_LIT8( KSortTitle, "dc:title" );
+
+
+
+
+// ***************************************************
+// * Constant container ID's
+// * 
+// * Some container ID's are defined as constants
+// * and have special meaning.
+// *
+// * Root container: the container that recursively
+// * contains all other containers. This container
+// * is not contained in any other container.
+// * 
+// * Any container: used when addressing a remote
+// * container. Lets the remote mediaserver decide
+// * an apropriate container.
+// * 
+// ***************************************************
+
+// the root container
+_LIT8( KContainerIdRoot, "0" );
+
+// Anycontainer
+_LIT8( KContainerIdAny,  "DLNA.ORG_AnyContainer" );
+
+
+
+// ***************************************************
+// * Constructing search criteria
+// * 
+// * Some useful constants that are used in generating
+// * search criteria fields
+// * 
+// * Please see UPnP specifications for more details
+// * 
+// ***************************************************
+
+// searches for elements that contain given partial string
+_LIT8( KCriteriaContains, "contains" );
+
+// searches for classes or any child classes of given class
+_LIT8( KCriteriaDerivedFrom, "derivedfrom" );
+
+// searches for classes where an element exists
+_LIT8( KCriteriaExists, "exists" );
+
+// negates the boolean operator
+_LIT8( KCriteriaFalse, "false" );
+
+// logical AND
+_LIT8( KCriteriaAnd, "and" );
+
+// logical OR
+_LIT8( KCriteriaOr, "or" );
+
+// logical comparision
+_LIT8( KCriteriaEQ, "=" );
+_LIT8( KCriteriaNEQ, "!=" );
+_LIT8( KCriteriaGT, ">" );
+_LIT8( KCriteriaLT, "<" );
+_LIT8( KCriteriaGTE, ">=" );
+_LIT8( KCriteriaLTE, "<=" );
+_LIT8( KCriteriaOB, "(" );
+_LIT8( KCriteriaCB, ")" );
+
+// other useful for filling up the strings
+_LIT8( KCriteriaQuot, "\"" );
+_LIT8( KCriteriaSpace, " " );
+
+
+
+// ***************************************************
+// * DLNA Transfer modes
+// * 
+// * Please see DLNA specifications for more details
+// ***************************************************
+_LIT8( KTransferMode, "transferMode.dlna.org" );
+_LIT8( KBackgroundMode, "Background" );
+_LIT8( KStreamingMode, "Streaming" );
+_LIT8( KInteractiveMode, "Interactive" );
+
+
+// ***************************************************
+// * DLNA Content headers
+// * 
+// * Please see DLNA specifications for more details
+// ***************************************************
+_LIT8( KContentType, "Content-Type" );
+_LIT8( KContentFeatures, "contentFeatures.dlna.org" );
+
+
+// ***************************************************
+// * DLNA headers misc.
+// * 
+// * Please see DLNA specifications for more details
+// ***************************************************
+_LIT8( KExpectHeader, "Expect" );
+_LIT8( K100Continue, "100-continue" );
+
+
+// ***************************************************
+// * Misc
+// * 
+// ***************************************************
+
+// attribute value - not implemented or not supported
+_LIT8( KValueNotImplemented, "NOT_IMPLEMENTED" );
+
--- a/upnpavcontroller/upnpavcontrollerhelper/inc/upnpdlnautility.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/inc/upnpdlnautility.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,85 +1,107 @@
-/*
-* Copyright (c) 2007 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:      Utility for working with dlna profiles
-*
-*/
-
-
-
-
-
-
-#ifndef UPNPDLNAUTILITY_H
-#define UPNPDLNAUTILITY_H
-
-// INCLUDES
-#include <e32base.h>
-#include <badesca.h>
-    
-/**
-* Utility for working with dlna profiles and mime types
-*
-* @lib upnpavcontrollerhelper.lib
-* @since S60 3.2
-*/
-class UPnPDlnaUtility
-    {
-
-public: // datatypes 
-
-    enum TDlnaMode
-        {
-        EDMSMode = 0,
-        EDMPMode,
-        EDMUMode,
-        EDMDMode
-        };
-
-public: // Business logic methods
-
-         /**
-         * Returns Dlna profiles for which playback on
-         * device might be supported.         
-         * The client must release the memory allocated for the items 
-         * in the array.          
-         * @since Series 60 3.2
-         * @param aMode, dlna mode
-         * @return Dlna profile string array
-         */
-        IMPORT_C static CDesC8Array& GetSupportedProfilesL( 
-            const TDlnaMode aMode );
-    
-         /**
-         * Returns ETrue if aMime is such a mime type for which playback on 
-         * device might be supported.
-         * @since Series 60 3.2
-         * @param aMime mime type
-         * @return TBool Can the mime type possibly be playable on device.
-         */
-        IMPORT_C static TBool IsSupportedMimeType( const TDesC8& aMime );
-        
-         /**
-         * Returns ETrue if aProfile is such a DLNA profile for which 
-         * playback on device might be supported.
-         * @since Series 60 3.2
-         * @param aProfile mime type
-         * @return TBool Can the DLNA profile possibly be playable on device.
-         */
-        IMPORT_C static TBool IsSupportedDlnaProfile( const TDesC8& aProfile );
-
-    };
-
-#endif  // UPNPDLNAUTILITY_H
-
-// End of File
+/*
+* Copyright (c) 2007 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:      Utility for working with dlna profiles
+*
+*/
+
+
+
+
+
+
+#ifndef UPNPDLNAUTILITY_H
+#define UPNPDLNAUTILITY_H
+
+// INCLUDES
+#include <e32base.h>
+#include <badesca.h>
+#include <stringpool.h>
+
+/**
+* Utility for working with dlna profiles and mime types
+*
+* @lib upnpavcontrollerhelper.lib
+* @since S60 3.2
+*/
+class UPnPDlnaUtility
+    {
+
+public: // datatypes 
+
+    enum TDlnaMode
+        {
+        EDMSMode = 0,
+        EDMPMode,
+        EDMUMode,
+        EDMDMode
+        };
+
+public: // Business logic methods
+
+         /**
+         * Returns Dlna profiles for which playback on
+         * device might be supported.         
+         * The client must release the memory allocated for the items 
+         * in the array.          
+         * @since Series 60 3.2
+         * @param aMode, dlna mode
+         * @return Dlna profile string array
+         */
+        IMPORT_C static CDesC8Array& GetSupportedProfilesL( 
+            const TDlnaMode aMode );
+    
+         /**
+         * Returns ETrue if aMime is such a mime type for which playback on 
+         * device might be supported.
+         * @since Series 60 3.2
+         * @param aMime mime type
+         * @return TBool Can the mime type possibly be playable on device.
+         */
+        IMPORT_C static TBool IsSupportedMimeType( const TDesC8& aMime );
+        
+         /**
+         * Returns ETrue if aProfile is such a DLNA profile for which 
+         * playback on device might be supported.
+         * @since Series 60 3.2
+         * @param aProfile mime type
+         * @return TBool Can the DLNA profile possibly be playable on device.
+         */
+        IMPORT_C static TBool IsSupportedDlnaProfile( const TDesC8& aProfile );
+        
+private:
+    
+        /**
+         * IsSupported
+         * 
+         * @param  aTable
+         * @param  aType
+         * @return boolean is type supported
+         */
+        static TBool IsSupported( const TStringTable& aTable , const TDesC8& aType );
+        
+        /**
+         * static string table
+         */
+        static const TStringTable iMimeTypes; 
+
+        /**
+         * static string table
+         */
+        static const TStringTable iDlnaTypes;
+        
+    };
+
+#endif  // UPNPDLNAUTILITY_H
+
+// End of File
--- a/upnpavcontroller/upnpavcontrollerhelper/inc/upnpdownloaditemresolver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/inc/upnpdownloaditemresolver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,279 +1,280 @@
-/*
-* Copyright (c) 2007 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:      Resolver for downloading remote items
-*
-*/
-
-
-
-
-
-
-#ifndef UPNPDOWNLOADITEMRESOLVER_H
-#define UPNPDOWNLOADITEMRESOLVER_H
-
-//  INCLUDES
-#include <e32base.h>
-#include <f32file.h>
-#include "upnpfiletransfersessionobserver.h" // base class
-#include "upnpitemresolver.h" // base class
-#include "upnpitemresolverobserver.h" // base class
-
-// FORWARD DECLARATIONS
-class CUPnPSettingsEngine;
-class CUPnPRemoteItemResolver;
-class MUPnPAVController;
-class CUpnpAVDevice;
-class MUPnPFileDownloadSession;
-
-// CLASS DECLARATION
-
-/**
-* Resolves remote upnp items from a plain item id.
-* This resolving is done by executing a upnp metadata browse, or
-* possibly several ones of those.
-*
-* @lib upnpavcontrollerhelper.lib
-* @since S60 3.2
-*/
-class CUPnPDownloadItemResolver
-    : public CBase
-    , public MUPnPItemResolver
-    , public MUPnPItemResolverObserver
-    , public MUPnPFileTransferSessionObserver
-    {
-public: // construction/destruction
-
-    /**
-     * static constructor
-     *
-     * @since Series 60 3.2
-     * @param aItemId, item to be resolved
-     * @param aAvController, AVController
-     * @param aHostSession, browsing session
-     * @param aSelector, resource selector
-     * @param aBrowseFilter, filter
-     * @return DownloadItemResolver instance 
-     */
-    static CUPnPDownloadItemResolver* NewL(
-        const TDesC8& aItemId,
-        MUPnPAVController& aAvController,
-        MUPnPAVBrowsingSession& aHostSession,
-        MUPnPResourceSelector& aSelector,
-        const TDesC8& aBrowseFilter );
-
-    /**
-     * destructor
-     */
-    virtual ~CUPnPDownloadItemResolver();
-
-private:
-
-    /**
-     * default constructor
-     *
-     * @since Series 60 3.2
-     * @param aItemId, item to be resolved
-     * @param aAvController, AVController
-     * @param aHostSession, browsing session
-     * @param aSelector, resource selector
-     * @param aBrowseFilter, filter
-     */
-    CUPnPDownloadItemResolver(
-        const TDesC8& aItemId,
-        MUPnPAVController& aAvController,
-        MUPnPAVBrowsingSession& aHostSession,
-        MUPnPResourceSelector& aSelector,
-        const TDesC8& aBrowseFilter );
-
-    /**
-     * 2nd phase constructor
-     *
-     * @since Series 60 3.2
-     * @param aItemId, item to be resolved
-     * @param aAvController, AVController
-     * @param aHostSession, browsing session
-     * @param aSelector, resource selector
-     * @param aBrowseFilter, filter
-     */
-    void ConstructL(
-        const TDesC8& aItemId,
-        MUPnPAVController& aAvController,
-        MUPnPAVBrowsingSession& aHostSession,
-        MUPnPResourceSelector& aSelector,
-        const TDesC8& aBrowseFilter );
-
-public: // the interface
-
-    /**
-     * see UPnPItemResolver
-     */
-    void ResolveL(
-        MUPnPItemResolverObserver& aObserver
-        );
-
-    /**
-     * see UPnPItemResolver
-     */
-    const CUpnpItem& Item() const;
-
-
-    /**
-     * see UPnPItemResolver
-     */
-    const CUpnpElement& Resource() const;
-    
-    /**
-     * Delete upnp genereated temporary files from download locations
-     * Leave in case of fatal errors
-     *
-     * @since S60 3.2
-     */
-    IMPORT_C static void DeleteTempDownloadFilesL();
-
-
-protected: // MUPnPItemResolverObserver
-
-    /**
-     * see MUPnPItemResolverObserver
-     */
-    void ResolveComplete(
-        const MUPnPItemResolver& aResolver, TInt aError );
-
-protected: // MUPnPFileTransferSessionObserver
-
-
-    /**
-     * see MUPnPFileTransferSessionObserver
-     */
-    void TransferStarted( TInt aKey, TInt aStatus );
-
-    /**
-     * see MUPnPFileTransferSessionObserver
-     */
-    void TransferCompleted( TInt aKey, TInt aStatus,
-        const TDesC& aFilePath );
-
-    /**
-     * see MUPnPFileTransferSessionObserver
-     */
-    void TransferProgress( TInt aKey,
-        TInt aBytes, TInt aTotalBytes );
-
-    /**
-     * see MUPnPFileTransferSessionObserver
-     */
-    void MediaServerDisappeared(
-        TUPnPDeviceDisconnectedReason aReason );
-
-private: // private methods
-
-    /**
-     * Starts download when the remote item itself has been
-     * resolved using the remote resolver
-     */
-    void InitiateDownloadL();
-
-    /**
-     * Completes ongoing async operation
-     */
-    void Complete( TInt aError );
-
-    /**
-     * Clean up all resources
-     */
-    void Cleanup();
-    
-    /**
-     * Create temporary file name for file to be download.
-     * Format is upnpfwtemp<item_id><file extension>
-     * The following characters are replaced with an underscore: 
-     * >, <, ", \, /, *, |, * : and ?
-     *
-     * @return file name. Ownership transferred.
-     */
-    HBufC* CreateTmpFileNameL();
-    
-    /**
-     * Get selected download location from settings engine.
-     *
-     * @return download location. Ownership transferred.
-     */
-    HBufC* GetSelectedDownloadLocationL();
-    
-    /**
-     * Creates RFile
-     * @param aFilePath, file name and path
-     * @return error code
-     */
-    TInt CreateRFile( const TDesC& aFilePath );
-
-    /**
-     * internal state machinery
-     */
-    enum TInternalState {
-        EStateIdle,         // no data, ready for starting
-        EStateResolving,    // using remote resolver to resolve the item
-        EStateDownloading,  // Downloading data to local file system
-        EStateReady         // Ready, can read data
-    };
-
-    /**
-    * Check if the audio is DLNA supported in remote to local playback 
-    * @since Series 60 3.1
-    * @param CUpnpObject item to be checked
-    * @return void
-    */
-    void IsLocallySupportedL( const CUpnpElement& aRes ); 
-
-private: // members
-
-    // the remote resolver is a part of this resolver
-    CUPnPRemoteItemResolver* iRemoteResolver;
-    
-    // Settings engine for get selected copy location (Owned).
-    CUPnPSettingsEngine*    iSettingsEngine;
-
-    // avcontroller
-    MUPnPAVController& iAvController;
-
-    // the remote device
-    CUpnpAVDevice* iRemoteDevice;
-
-    // the local filename
-    HBufC* iLocalFile;
-
-    // session for downloading items
-    MUPnPFileDownloadSession* iDownloadSession;
-
-    // observer for this utility. Note: NOT OWNED
-    MUPnPItemResolverObserver* iObserver;
-
-    // state of the class
-    TInternalState iState;
-    
-    // File server session
-    RFs iFsSession;
-    
-    // Download target
-    RFile iFile;
-    
-    // selector interface to use
-    MUPnPResourceSelector& iSelector;
-    };
-
-
-#endif  // UPNPDOWNLOADITEMRESOLVER_H
-
-// End of File
+/*
+* Copyright (c) 2007 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:      Resolver for downloading remote items
+*
+*/
+
+
+
+
+
+
+#ifndef UPNPDOWNLOADITEMRESOLVER_H
+#define UPNPDOWNLOADITEMRESOLVER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include "upnpfiletransfersessionobserver.h" // base class
+#include "upnpitemresolver.h" // base class
+#include "upnpitemresolverobserver.h" // base class
+
+// FORWARD DECLARATIONS
+class CUPnPSettingsEngine;
+class CUPnPRemoteItemResolver;
+class MUPnPAVController;
+class CUpnpAVDevice;
+class MUPnPFileDownloadSession;
+
+// CLASS DECLARATION
+
+/**
+* Resolves remote upnp items from a plain item id.
+* This resolving is done by executing a upnp metadata browse, or
+* possibly several ones of those.
+*
+* @lib upnpavcontrollerhelper.lib
+* @since S60 3.2
+*/
+class CUPnPDownloadItemResolver
+    : public CBase
+    , public MUPnPItemResolver
+    , public MUPnPItemResolverObserver
+    , public MUPnPFileTransferSessionObserver
+    {
+public: // construction/destruction
+
+    /**
+     * static constructor
+     *
+     * @since Series 60 3.2
+     * @param aItemId, item to be resolved
+     * @param aAvController, AVController
+     * @param aHostSession, browsing session
+     * @param aSelector, resource selector
+     * @param aBrowseFilter, filter
+     * @return DownloadItemResolver instance 
+     */
+    static CUPnPDownloadItemResolver* NewL(
+        const TDesC8& aItemId,
+        MUPnPAVController& aAvController,
+        MUPnPAVBrowsingSession& aHostSession,
+        MUPnPResourceSelector& aSelector,
+        const TDesC8& aBrowseFilter );
+
+    /**
+     * destructor
+     */
+    virtual ~CUPnPDownloadItemResolver();
+
+private:
+
+    /**
+     * default constructor
+     *
+     * @since Series 60 3.2
+     * @param aItemId, item to be resolved
+     * @param aAvController, AVController
+     * @param aHostSession, browsing session
+     * @param aSelector, resource selector
+     * @param aBrowseFilter, filter
+     */
+    CUPnPDownloadItemResolver(
+        const TDesC8& aItemId,
+        MUPnPAVController& aAvController,
+        MUPnPAVBrowsingSession& aHostSession,
+        MUPnPResourceSelector& aSelector,
+        const TDesC8& aBrowseFilter );
+
+    /**
+     * 2nd phase constructor
+     *
+     * @since Series 60 3.2
+     * @param aItemId, item to be resolved
+     * @param aAvController, AVController
+     * @param aHostSession, browsing session
+     * @param aSelector, resource selector
+     * @param aBrowseFilter, filter
+     */
+    void ConstructL(
+        const TDesC8& aItemId,
+        MUPnPAVController& aAvController,
+        MUPnPAVBrowsingSession& aHostSession,
+        MUPnPResourceSelector& aSelector,
+        const TDesC8& aBrowseFilter );
+
+public: // the interface
+
+    /**
+     * see UPnPItemResolver
+     */
+    void ResolveL(
+        MUPnPItemResolverObserver& aObserver
+        , CUpnpAVDevice* aDevice = NULL);
+
+    /**
+     * see UPnPItemResolver
+     */
+    const CUpnpItem& Item() const;
+
+
+    /**
+     * see UPnPItemResolver
+     */
+    const CUpnpElement& Resource() const;
+    
+    /**
+     * Delete upnp genereated temporary files from download locations
+     * Leave in case of fatal errors
+     *
+     * @since S60 3.2
+     */
+    IMPORT_C static void DeleteTempDownloadFilesL();
+
+
+protected: // MUPnPItemResolverObserver
+
+    /**
+     * see MUPnPItemResolverObserver
+     */
+    void ResolveComplete(
+        const MUPnPItemResolver& aResolver, TInt aError );
+
+protected: // MUPnPFileTransferSessionObserver
+
+
+    /**
+     * see MUPnPFileTransferSessionObserver
+     */
+    void TransferStarted( TInt aKey, TInt aStatus );
+
+    /**
+     * see MUPnPFileTransferSessionObserver
+     */
+    void TransferCompleted( TInt aKey, TInt aStatus,
+        const TDesC& aFilePath );
+
+    /**
+     * see MUPnPFileTransferSessionObserver
+     */
+    void TransferProgress( TInt aKey,
+        TInt aBytes, TInt aTotalBytes );
+
+    /**
+     * see MUPnPFileTransferSessionObserver
+     */
+    void MediaServerDisappeared(
+        TUPnPDeviceDisconnectedReason aReason );
+
+private: // private methods
+
+    /**
+     * Starts download when the remote item itself has been
+     * resolved using the remote resolver
+     */
+    void InitiateDownloadL();
+
+    /**
+     * Completes ongoing async operation
+     */
+    void Complete( TInt aError );
+
+    /**
+     * Clean up all resources
+     */
+    void Cleanup();
+    
+    /**
+     * Create temporary file name for file to be download.
+     * Format is upnpfwtemp<item_id><file extension>
+     * The following characters are replaced with an underscore: 
+     * >, <, ", \, /, *, |, * : and ?
+     *
+     * @return file name. Ownership transferred.
+     */
+    HBufC* CreateTmpFileNameL();
+    
+    /**
+     * Get selected download location from settings engine.
+     *
+     * @return download location. Ownership transferred.
+     */
+    HBufC* GetSelectedDownloadLocationL();
+    
+    /**
+     * Creates RFile
+     * @param aFilePath, file name and path
+     * @return error code
+     */
+    TInt CreateRFile( const TDesC& aFilePath );
+
+    /**
+     * internal state machinery
+     */
+    enum TInternalState {
+        EStateIdle,         // no data, ready for starting
+        EStateResolving,    // using remote resolver to resolve the item
+        EStateDownloading,  // Downloading data to local file system
+        EStateReady         // Ready, can read data
+    };
+
+    /**
+    * Check if the audio is DLNA supported in remote to local playback 
+    * @since Series 60 3.1
+    * @param CUpnpObject item to be checked
+    * @return void
+    */
+    void IsLocallySupportedL( const CUpnpElement& aRes ); 
+
+private: // members
+
+    // the remote resolver is a part of this resolver
+    CUPnPRemoteItemResolver* iRemoteResolver;
+    
+    // Settings engine for get selected copy location (Owned).
+    CUPnPSettingsEngine*    iSettingsEngine;
+
+    // avcontroller
+    MUPnPAVController& iAvController;
+
+    // the remote device
+    CUpnpAVDevice* iRemoteDevice;
+
+    // the local filename
+    HBufC* iLocalFile;
+
+    // session for downloading items
+    MUPnPFileDownloadSession* iDownloadSession;
+
+    // observer for this utility. Note: NOT OWNED
+    MUPnPItemResolverObserver* iObserver;
+
+    // state of the class
+    TInternalState iState;
+    
+    // File server session
+    RFs iFsSession;
+    
+    // Download target
+    RFile iFile;
+    
+    // selector interface to use
+    MUPnPResourceSelector& iSelector;   
+
+    };
+
+
+#endif  // UPNPDOWNLOADITEMRESOLVER_H
+
+// End of File
--- a/upnpavcontroller/upnpavcontrollerhelper/inc/upnpitemresolver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/inc/upnpitemresolver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,103 +1,103 @@
-/*
-* Copyright (c) 2005-2007 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:      Tool for resolving local or remote items
-*
-*/
-
-
-
-
-
-
-#ifndef UPNPITEMRESOLVER_H
-#define UPNPITEMRESOLVER_H
-
-//  INCLUDES
-#include <e32base.h>
-
-// FORWARD DECLARATIONS
-class MUPnPAVController;
-class MUPnPAVBrowsingSession;
-class MUPnPResourceSelector;
-class MUPnPItemResolverObserver;
-class CUpnpItem;
-class CUpnpElement;
-
-// CLASS DECLARATION
-
-/**
-* An interface for resolving either remote or local content.
-* The interface takes in some identification of the content,
-* resolves the content and asynchronously notifies when the
-* content is available. The content itself is provided by
-* CUpnpItem, which contains item metadata, resource and URI,
-* and it can be used directly in AVController interface to
-* play content on remote renderer or download content.
-*
-* @lib upnpavcontrollerhelper.lib
-* @since S60 3.2
-*/
-class MUPnPItemResolver
-    {
-
-public: // construction/destruction
-
-
-    /**
-     * virtual destructor
-     * for deleting the resolver implementation using the API pointer
-     */
-    virtual ~MUPnPItemResolver()  {}
-
-
-public: // the interface
-
-    /**
-     * Starts resolving an object id using given session.
-     * given Callback is notified when result objects are available,
-     * or in case of an error.
-     * @since S60 3.2
-     * @param aObserver interface that will receive result callback
-     * @param aSelector selects the desider resource
-     */
-    virtual void ResolveL(
-        MUPnPItemResolverObserver& aObserver ) = 0;
-
-    /**
-     * access to the resolved item.
-     * Note that if the object represents an item, it is not necessarily
-     * safe to query the resource in this item, instead you should use
-     * this item to query all metadata.
-     * Use this method after receiving MetadataBrowseComplete( KErrNone )
-     * @return reference to the item with the given ID
-     */
-    virtual const CUpnpItem& Item() const = 0;
-
-    /**
-     * access to the pointed item's resource.
-     * The resource may be in the original or in the pointed item.
-     * This is the easiest and recommended way for accessing the
-     * resource.
-     * example:
-     * const TDesC& uri = browseUtil->Res().Value();
-     * Use this method after receiving MetadataBrowseComplete( KErrNone )
-     * @return reference to the upnp element of <res> type.
-     */
-    virtual const CUpnpElement& Resource() const = 0;
-
-    };
-
-#endif  // UPNPITEMRESOLVER_H
-
-// End of File
+/*
+* Copyright (c) 2005-2007 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:      Tool for resolving local or remote items
+*
+*/
+
+
+
+
+
+
+#ifndef UPNPITEMRESOLVER_H
+#define UPNPITEMRESOLVER_H
+
+//  INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class MUPnPAVController;
+class MUPnPAVBrowsingSession;
+class MUPnPResourceSelector;
+class MUPnPItemResolverObserver;
+class CUpnpItem;
+class CUpnpElement;
+class CUpnpAVDevice;
+// CLASS DECLARATION
+
+/**
+* An interface for resolving either remote or local content.
+* The interface takes in some identification of the content,
+* resolves the content and asynchronously notifies when the
+* content is available. The content itself is provided by
+* CUpnpItem, which contains item metadata, resource and URI,
+* and it can be used directly in AVController interface to
+* play content on remote renderer or download content.
+*
+* @lib upnpavcontrollerhelper.lib
+* @since S60 3.2
+*/
+class MUPnPItemResolver
+    {
+
+public: // construction/destruction
+
+
+    /**
+     * virtual destructor
+     * for deleting the resolver implementation using the API pointer
+     */
+    virtual ~MUPnPItemResolver()  {}
+
+
+public: // the interface
+
+    /**
+     * Starts resolving an object id using given session.
+     * given Callback is notified when result objects are available,
+     * or in case of an error.
+     * @since S60 3.2
+     * @param aObserver interface that will receive result callback
+     * @param aSelector selects the desider resource
+     */
+    virtual void ResolveL(
+        MUPnPItemResolverObserver& aObserver, CUpnpAVDevice* aDevice=NULL ) = 0;
+
+    /**
+     * access to the resolved item.
+     * Note that if the object represents an item, it is not necessarily
+     * safe to query the resource in this item, instead you should use
+     * this item to query all metadata.
+     * Use this method after receiving MetadataBrowseComplete( KErrNone )
+     * @return reference to the item with the given ID
+     */
+    virtual const CUpnpItem& Item() const = 0;
+
+    /**
+     * access to the pointed item's resource.
+     * The resource may be in the original or in the pointed item.
+     * This is the easiest and recommended way for accessing the
+     * resource.
+     * example:
+     * const TDesC& uri = browseUtil->Res().Value();
+     * Use this method after receiving MetadataBrowseComplete( KErrNone )
+     * @return reference to the upnp element of <res> type.
+     */
+    virtual const CUpnpElement& Resource() const = 0;
+
+    };
+
+#endif  // UPNPITEMRESOLVER_H
+
+// End of File
--- a/upnpavcontroller/upnpavcontrollerhelper/inc/upnplocalitemresolver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/inc/upnplocalitemresolver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,278 +1,177 @@
-/*
-* Copyright (c) 2007 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:      Resolver for local items
-*
-*/
-
-
-
-
-
-
-#ifndef UPNPLOCALITEMRESOLVER_H
-#define UPNPLOCALITEMRESOLVER_H
-
-//  INCLUDES
-#include <e32base.h>
-#include "upnpavbrowsingsessionobserver.h" // base class
-#include "upnpitemresolver.h" // base class
-#include <upnpmediaserverclient.h> // a member
-
-// FORWARD DECLARATIONS
-class MUPnPAVController;
-class MUPnPAVBrowsingSession;
-class CUpnpFileSharing;
-class CUpnpItem;
-class CUpnpSecAccessController;
-class CUPnPPeriodic;
-
-// CLASS DECLARATION
-
-/**
-* Resolves remote upnp items from a plain item id.
-* This resolving is done by executing a upnp metadata browse, or
-* possibly several ones of those.
-*
-* @lib upnpavcontrollerhelper.lib
-* @since S60 3.2
-*/
-class CUPnPLocalItemResolver
-    : public CActive
-    , public MUPnPAVBrowsingSessionObserver
-    , public MUPnPItemResolver
-    {
-public: // construction/destruction
-
-    /**
-     * static constructor
-     *
-     * @since Series 60 3.2
-     * @param aFilePath, local item to be resolved
-     * @param aAvController, AVController
-     * @param aSelector, resource selector
-     * @param aOptimisationFlags flags to optimise the algorithm
-     * @return LocaltemResolver instance 
-     */
-    static CUPnPLocalItemResolver* NewL(
-        const TDesC& aFilePath,
-        MUPnPAVController& aAvController,
-        MUPnPResourceSelector& aSelector,
-        TInt aOptimisationFlags );
-
-    /**
-     * destructor
-     * @since Series 60 3.2
-     */
-    virtual ~CUPnPLocalItemResolver();
-
-private:
-
-    /**
-     * default constructor
-     *
-     * @since Series 60 3.2
-     * @param aAvController, AVController
-     * @param aSelector, resource selector
-     */
-    CUPnPLocalItemResolver(
-        MUPnPAVController& aAvController,
-        MUPnPResourceSelector& aSelector,
-        TInt aOptimisationFlags );
-
-    /**
-     * 2nd phase constructor
-     *
-     * @param aFilePath, local item to be resolved
-     */
-    void ConstructL( const TDesC& aFilePath );
-
-private: // Business logic methods
-
-    /**
-     * Allows/denied access to the files to which the given item's res-
-     * elements are pointing.
-     *
-     * @since Series 60 3.2
-     * @param aItem the item
-     * @param aAccessAllowed ETrue to allow and EFalse to deny the access
-     */
-    void SetAccesstoItemResources( CUpnpItem& aItem, TBool aAccessAllowed );
-
-public: // the interface
-
-    /**
-     * see UPnPItemResolver
-     */
-    void ResolveL(
-        MUPnPItemResolverObserver& aObserver
-        );
-
-    /**
-     * see UPnPItemResolver
-     */
-    const CUpnpItem& Item() const;
-
-
-    /**
-     * see UPnPItemResolver
-     */
-    const CUpnpElement& Resource() const;
-    
-protected: // From CActive
-
-    /**
-     * See CActive
-     */
-    void RunL();
-    
-    /**
-     * See CActive
-     */
-    void DoCancel();
-    
-    /**
-     * See CActive
-     */
-    TInt RunError( TInt aError );
-
-protected: // overrides to CUPnPBrowsingSessionObserverProxy
-
-
-    /**
-     * see MUPnPAVSessionObserverBase
-     */
-    void ReserveLocalMSServicesCompleted( TInt aError );
-
-
-private: // private methods
-
-    /**
-     * initiate the sharing process
-     */
-    void DoShareL();
-    
-    /**
-     * initiate the unsharing process
-     */
-    void DoUnshareL();
-
-    /**
-     * Completes ongoing async operation
-     */
-    void Complete( TInt aError );
-
-    /**
-     * Clean up all resources
-     */
-    void Cleanup();
-
-    /**
-     * internal state machinery
-     */
-    enum TInternalState {
-        EStateIdle,         // no data, ready for starting
-        EStateCreatingItem, // CreateItemFromFileLC called
-        EStateStartingMS,   // starting the local mediaserver
-		EStateSharing,      // sharing the local file
-		EStateUnsharing,    // unsharing the local file
-        EStateReady,        // Ready. Can free.
-		EStateCancel		// command to cancel ongoing process
-    };        
-        
-private: // Call back methods of MUPnPAVBrowsingSessionObserver
-
-    /* Not used */
-    void BrowseResponse(
-        const TDesC8& /*aBrowseResponse*/,
-        TInt /*aError*/,
-        TInt /*aMatches*/,
-        TInt /*aTotalCount*/,
-        const TDesC8& /*aUpdateId*/
-        ) {}
-    void SearchResponse( 
-        const TDesC8& /*aSearchResponse*/,
-        TInt /*aError*/,
-        TInt /*aMatches*/,
-        TInt /*aTotalCount*/,
-        const TDesC8& /*aUpdateId*/
-        ) {}
-    void SearchCapabilitiesResponse( 
-        TInt /*aError*/,
-        const TDesC8& /*aSearchCapabilities*/ 
-        ) {}
-    void CreateContainerResponse( TInt /*aError*/, 
-        const TDesC8& /*aObjectId*/ ) {}
-    void DeleteObjectResponse( TInt /*aError*/ ) {}  
-
-    void MediaServerDisappeared(
-        TUPnPDeviceDisconnectedReason /*aReason*/ ) {}
-    
-    
-private: // Timer callback
-    /**
-     * timer callback
-     * unsharing is sometimes jammed and timer is used for cancelling
-     * unshare call
-     */
-   static TInt TimerExpired( TAny* aArg );
-
-private: // members
-
-    // local file path (Owned).
-    HBufC* iFilePath;
-
-    // avcontroller
-    MUPnPAVController& iAvController;
-
-    // temporary session for starting local mediaserver
-    MUPnPAVBrowsingSession* iTempSession;
-
-    // resource selector
-    MUPnPResourceSelector& iSelector;
-
-    // observer for this utility. Note: NOT OWNED
-    MUPnPItemResolverObserver* iObserver;
-
-    // state of the class
-    TInternalState iState;
-
-    // the first level browse result item (Owned).
-    CUpnpItem* iSharedItem;
-
-    // The selected resource within the last level item.
-    const CUpnpElement* iResource;
-
-    // The mediaserver (required to get the server IP address)
-    RUpnpMediaServerClient iMediaServer;
-
-    // optimisation flags
-    TInt iOptimisationFlags;
-
-    // S60 file sharing metadata interface
-    CUpnpFileSharing* iFileSharing;
-
-    // security access controller
-    CUpnpSecAccessController* iAccessController;
-    
-    // wait until unshare finishes
-    CActiveSchedulerWait*   iWait;
-    
-    // timer to cancel unshare
-    CUPnPPeriodic*          iTimer;
-    };
-
-
-#endif  // UPNPLOCALITEMRESOLVER_H
-
-// End of File
+/*
+* Copyright (c) 2009 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:      Resolver for local items
+*
+*/
+
+
+
+
+#ifndef UPNPLOCALITEMRESOLVER_H
+#define UPNPLOCALITEMRESOLVER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include "upnpitemresolver.h" // base class
+#include "upnpthumbnailcreator.h"
+
+// FORWARD DECLARATIONS
+class MUPnPAVController;
+class CUpnpItem;
+class MUPnPItemResolverObserver;
+class MMPXCollectionHelper;
+class CUpnpAVDevice;
+class CUpnpTranscodeHelper;
+
+// CLASS DECLARATION
+
+/**
+* Resolves remote upnp items from a plain item id.
+* This resolving is done by executing a upnp metadata browse, or
+* possibly several ones of those.
+*
+* @lib upnpavcontrollerhelper.lib
+* @since S60 3.2
+*/
+class CUPnPLocalItemResolver
+    : public CBase
+    , public MUPnPItemResolver
+    , public MUpnpThumbnailCreatorObserver
+    {
+public: // construction/destruction
+
+    /**
+     * static constructor
+     *
+     * @since Series 60 3.2
+     * @param aFilePath, local item to be resolved
+     * @param aAvController, AVController
+     * @param aSelector, resource selector
+     * @param aOptimisationFlags flags to optimise the algorithm
+     * @return LocaltemResolver instance 
+     */
+    static CUPnPLocalItemResolver* NewL(
+        const TDesC& aFilePath,
+        MUPnPAVController& aAvController,
+        MUPnPResourceSelector& aSelector,
+        TInt aOptimisationFlags );
+
+    /**
+     * destructor
+     * @since Series 60 3.2
+     */
+    virtual ~CUPnPLocalItemResolver();
+
+private:
+
+    /**
+     * default constructor
+     *
+     * @since Series 60 3.2
+     * @param aAvController, AVController
+     * @param aSelector, resource selector
+     */
+    CUPnPLocalItemResolver(
+        MUPnPAVController& aAvController,
+        MUPnPResourceSelector& aSelector,
+        TInt aOptimisationFlags );
+
+    /**
+     * 2nd phase constructor
+     *
+     * @param aFilePath, local item to be resolved
+     */
+    void ConstructL( const TDesC& aFilePath );
+
+
+private: 
+
+    /**
+     * see UPnPItemResolver
+     */
+    void ResolveL(
+        MUPnPItemResolverObserver& aObserver
+        , CUpnpAVDevice* aDevice = NULL);
+
+    /**
+     * see UPnPItemResolver
+     */
+    const CUpnpItem& Item() const;
+
+
+    /**
+     * see UPnPItemResolver
+     */
+    const CUpnpElement& Resource() const;
+
+
+private: // private methods
+
+	/**
+	 * shares upnpitem
+	 */
+    void ShareL();
+    
+    /**
+     * Clean up all resources
+     */
+    void Cleanup();
+
+    /**
+     * checks if media "song" file has a album art 
+	 *
+     * @param aFileName filepath to media
+     */
+    void SetAlbumArtResourceToItemL( const TDesC& aFileName );
+    
+private:
+    void ThumbnailCreatorReady( TInt aError);
+    
+    void AddAlbumArtAndShareL();
+    
+    void AddThumbnailandShareL();
+
+private: // members
+
+    // resource selector
+    MUPnPResourceSelector& iSelector;
+
+    // local file path (Owned).
+    HBufC* iFilePath;
+
+    // the first level browse result item (Owned).
+    CUpnpItem* iSharedItem;
+
+    // The selected resource within the last level item.
+    const CUpnpElement* iResource;
+
+    // optimisation flags
+    TInt iOptimisationFlags;
+
+    CUpnpThumbnailCreator* iThumbnailCreator;
+
+    MUPnPItemResolverObserver* iObserver;
+    
+    CUpnpItem* iLocalItem;
+    
+	// owned
+    MMPXCollectionHelper* iCollectionHelper;
+	
+    CUpnpTranscodeHelper* iTranscodeHelper;
+    };
+
+
+#endif  // UPNPLOCALITEMRESOLVER_H
+
+// End of File
--- a/upnpavcontroller/upnpavcontrollerhelper/inc/upnpremoteitemresolver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/inc/upnpremoteitemresolver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,216 +1,216 @@
-/*
-* Copyright (c) 2007 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:      Resolver for remote items
-*
-*/
-
-
-
-
-
-
-#ifndef UPNPREMOTEITEMRESOLVER_H
-#define UPNPREMOTEITEMRESOLVER_H
-
-//  INCLUDES
-#include <e32base.h>
-#include "upnpitemresolver.h" // base class
-#include "upnpabstractbrowsingsessionobserver.h" // base class
-
-// FORWARD DECLARATIONS
-class MUPnPAVBrowsingSession;
-class CUpnpItem;
-class CUpnpElement;
-class MUPnPResourceSelector;
-
-// CLASS DECLARATION
-
-/**
-* Resolves remote upnp items from a plain item id.
-* This resolving is done by executing a upnp metadata browse, or
-* possibly several ones of those.
-*
-* @lib upnpavcontrollerhelper.lib
-* @since S60 3.2
-*/
-class CUPnPRemoteItemResolver
-    : public CUPnPAbstractBrowsingSessionObserver
-    , public MUPnPItemResolver
-    {
-public: // construction/destruction
-
-    /**
-     * static constructor.
-     *
-     * @since Series 60 3.2
-     * @param aItemId, item to be resolved
-     * @param aHostSession, browsing session
-     * @param aSelector, resource selector
-     * @param aBrowseFilter, filter
-     * @return RemoteItemResolver instance 
-     */
-    static CUPnPRemoteItemResolver* NewL(
-        const TDesC8& aItemId,
-        MUPnPAVBrowsingSession& aHostSession,
-        MUPnPResourceSelector& aSelector,
-        const TDesC8& aBrowseFilter );
-
-    /**
-     * destructor
-     * @since Series 60 3.2
-     */
-    virtual ~CUPnPRemoteItemResolver();
-
-private: // private construction part
-
-    /**
-     * default constructor.
-     *
-     * @since Series 60 3.2
-     * @param aItemId, item to be resolved
-     * @param aHostSession, browsing session
-     * @param aSelector, resource selector
-     * @param aBrowseFilter, filter
-     */
-    CUPnPRemoteItemResolver(
-        const TDesC8& aItemId,
-        MUPnPAVBrowsingSession& aHostSession,
-        MUPnPResourceSelector& aSelector,
-        const TDesC8& aBrowseFilter );
-
-    /**
-     * 2nd phase constructor.
-     *
-     * @since Series 60 3.2
-     * @param aItemId, item to be resolved
-     * @param aHostSession, browsing session
-     * @param aSelector, resource selector
-     * @param aBrowseFilter, filter
-     */
-    void ConstructL(
-        const TDesC8& aItemId,
-        MUPnPAVBrowsingSession& aHostSession,
-        MUPnPResourceSelector& aSelector,
-        const TDesC8& aBrowseFilter );
-
-
-public: // the interface
-
-    /**
-     * see UPnPItemResolver
-     */
-    void ResolveL(
-        MUPnPItemResolverObserver& aObserver );
-
-    /**
-     * see UPnPItemResolver
-     */
-    const CUpnpItem& Item() const;
-
-
-    /**
-     * see UPnPItemResolver
-     */
-    const CUpnpElement& Resource() const;
-
-
-protected: // MUPnPAVBrowsingSessionObserver
-
-    /**
-     * see MUPnPAVBrowsingSessionObserver
-     */
-    void BrowseResponse(
-        const TDesC8& aBrowseResponse,
-        TInt aError,
-        TInt aMatches,
-        TInt aTotalCount,
-        const TDesC8& aUpdateId
-        );
-
-
-private: // private methods
-
-    /**
-     * after receiving the result object, processes it:
-     * either continues browsing recursively or calls back
-     * notifying the object is ready to be fetched.
-     */
-    void ProcessResultObjectL( const CUpnpObject* aResult );
-
-    /**
-     * Completes ongoing async operation
-     */
-    void Complete( TInt aError );
-
-    /**
-     * Clean up all resources
-     */
-    void Cleanup();
-
-    /**
-     * internal state machinery
-     */
-    enum TInternalState {
-        EStateIdle,    // no data, ready for starting
-        EStateActive,  // browsing for data
-        EStateReady    // Data exists
-    };
-
-    /**
-     * Handles the parsing of the browse response.
-     *
-     * @since S60 3.2
-     * @param aBrowseResponse (const TDesC8&) the browse response
-     */
-    void BrowseResponseL( const TDesC8& aBrowseResponse );
-
-private: // members
-
-    // item to resolve (Owned)
-    HBufC8* iItemId;
-
-    // the host browsing session
-    MUPnPAVBrowsingSession& iBrowsingSession;
-
-    // selector interface to use
-    MUPnPResourceSelector& iSelector;
-
-    // filter used in browse
-    const TDesC8& iBrowseFilter;
-
-    // observer for the resolver. NOT OWNED
-    MUPnPItemResolverObserver* iObserver;
-
-    // state of the class
-    TInternalState iState;
-
-    // counter for browse resursion
-    TInt iRecursionDepth;
-
-    // the first level browse result item (Owned).
-    CUpnpItem* iFirstLevelItem;
-
-    // optional: last level browse result item, if first level
-    // is a pointer object (Owned). 
-    CUpnpItem* iLastLevelItem;
-
-    // The selected resource within the last level item. NOT OWNED
-    const CUpnpElement* iResource;
-
-    };
-
-
-#endif  // UPNPREMOTEITEMRESOLVER_H
-
-// End of File
+/*
+* Copyright (c) 2007 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:      Resolver for remote items
+*
+*/
+
+
+
+
+
+
+#ifndef UPNPREMOTEITEMRESOLVER_H
+#define UPNPREMOTEITEMRESOLVER_H
+
+//  INCLUDES
+#include <e32base.h>
+#include "upnpitemresolver.h" // base class
+#include "upnpabstractbrowsingsessionobserver.h" // base class
+
+// FORWARD DECLARATIONS
+class MUPnPAVBrowsingSession;
+class CUpnpItem;
+class CUpnpElement;
+class MUPnPResourceSelector;
+
+// CLASS DECLARATION
+
+/**
+* Resolves remote upnp items from a plain item id.
+* This resolving is done by executing a upnp metadata browse, or
+* possibly several ones of those.
+*
+* @lib upnpavcontrollerhelper.lib
+* @since S60 3.2
+*/
+class CUPnPRemoteItemResolver
+    : public CUPnPAbstractBrowsingSessionObserver
+    , public MUPnPItemResolver
+    {
+public: // construction/destruction
+
+    /**
+     * static constructor.
+     *
+     * @since Series 60 3.2
+     * @param aItemId, item to be resolved
+     * @param aHostSession, browsing session
+     * @param aSelector, resource selector
+     * @param aBrowseFilter, filter
+     * @return RemoteItemResolver instance 
+     */
+    static CUPnPRemoteItemResolver* NewL(
+        const TDesC8& aItemId,
+        MUPnPAVBrowsingSession& aHostSession,
+        MUPnPResourceSelector& aSelector,
+        const TDesC8& aBrowseFilter );
+
+    /**
+     * destructor
+     * @since Series 60 3.2
+     */
+    virtual ~CUPnPRemoteItemResolver();
+
+private: // private construction part
+
+    /**
+     * default constructor.
+     *
+     * @since Series 60 3.2
+     * @param aItemId, item to be resolved
+     * @param aHostSession, browsing session
+     * @param aSelector, resource selector
+     * @param aBrowseFilter, filter
+     */
+    CUPnPRemoteItemResolver(
+        const TDesC8& aItemId,
+        MUPnPAVBrowsingSession& aHostSession,
+        MUPnPResourceSelector& aSelector,
+        const TDesC8& aBrowseFilter );
+
+    /**
+     * 2nd phase constructor.
+     *
+     * @since Series 60 3.2
+     * @param aItemId, item to be resolved
+     * @param aHostSession, browsing session
+     * @param aSelector, resource selector
+     * @param aBrowseFilter, filter
+     */
+    void ConstructL(
+        const TDesC8& aItemId,
+        MUPnPAVBrowsingSession& aHostSession,
+        MUPnPResourceSelector& aSelector,
+        const TDesC8& aBrowseFilter );
+
+
+public: // the interface
+
+    /**
+     * see UPnPItemResolver
+     */
+    void ResolveL(
+        MUPnPItemResolverObserver& aObserver, CUpnpAVDevice* aDevice = NULL );
+
+    /**
+     * see UPnPItemResolver
+     */
+    const CUpnpItem& Item() const;
+
+
+    /**
+     * see UPnPItemResolver
+     */
+    const CUpnpElement& Resource() const;
+
+
+protected: // MUPnPAVBrowsingSessionObserver
+
+    /**
+     * see MUPnPAVBrowsingSessionObserver
+     */
+    void BrowseResponse(
+        const TDesC8& aBrowseResponse,
+        TInt aError,
+        TInt aMatches,
+        TInt aTotalCount,
+        const TDesC8& aUpdateId
+        );
+
+
+private: // private methods
+
+    /**
+     * after receiving the result object, processes it:
+     * either continues browsing recursively or calls back
+     * notifying the object is ready to be fetched.
+     */
+    void ProcessResultObjectL( const CUpnpObject* aResult );
+
+    /**
+     * Completes ongoing async operation
+     */
+    void Complete( TInt aError );
+
+    /**
+     * Clean up all resources
+     */
+    void Cleanup();
+
+    /**
+     * internal state machinery
+     */
+    enum TInternalState {
+        EStateIdle,    // no data, ready for starting
+        EStateActive,  // browsing for data
+        EStateReady    // Data exists
+    };
+
+    /**
+     * Handles the parsing of the browse response.
+     *
+     * @since S60 3.2
+     * @param aBrowseResponse (const TDesC8&) the browse response
+     */
+    void BrowseResponseL( const TDesC8& aBrowseResponse );
+
+private: // members
+
+    // item to resolve (Owned)
+    HBufC8* iItemId;
+
+    // the host browsing session
+    MUPnPAVBrowsingSession& iBrowsingSession;
+
+    // selector interface to use
+    MUPnPResourceSelector& iSelector;
+
+    // filter used in browse
+    const TDesC8& iBrowseFilter;
+
+    // observer for the resolver. NOT OWNED
+    MUPnPItemResolverObserver* iObserver;
+
+    // state of the class
+    TInternalState iState;
+
+    // counter for browse resursion
+    TInt iRecursionDepth;
+
+    // the first level browse result item (Owned).
+    CUpnpItem* iFirstLevelItem;
+
+    // optional: last level browse result item, if first level
+    // is a pointer object (Owned). 
+    CUpnpItem* iLastLevelItem;
+
+    // The selected resource within the last level item. NOT OWNED
+    const CUpnpElement* iResource;
+
+    };
+
+
+#endif  // UPNPREMOTEITEMRESOLVER_H
+
+// End of File
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnpabstractbrowsingsessionobserver.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnpabstractbrowsingsessionobserver.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,228 +1,215 @@
-/*
-* Copyright (c) 2007 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:      An abstract browsing session observer implementation
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-#include "upnpavbrowsingsession.h"
-#include "upnpavbrowsingsessionobserver.h"
-
-#include "upnpabstractbrowsingsessionobserver.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
-#include "upnplog.h"
-
-
-// CONSTANTS
-
-
-// METHODS
-
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::CUPnPAbstractBrowsingSessionObserver
-//---------------------------------------------------------------------------
-EXPORT_C CUPnPAbstractBrowsingSessionObserver::
-    CUPnPAbstractBrowsingSessionObserver()
-    {
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::~CUPnPAbstractBrowsingSessionObserver
-//---------------------------------------------------------------------------
-EXPORT_C CUPnPAbstractBrowsingSessionObserver::
-    ~CUPnPAbstractBrowsingSessionObserver()
-    {
-    DisableSessionObserver();
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::SetSession
-//---------------------------------------------------------------------------
-EXPORT_C void CUPnPAbstractBrowsingSessionObserver::SetSession(
-    MUPnPAVBrowsingSession& aHostSession )
-    {
-    // observer bust be disabled when calling this!
-    __ASSERTD( !iObserverEnabled, __FILE__, __LINE__ );
-    iObservedSession = &aHostSession;
-    }
-
-
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::EnableSessionObserver
-//---------------------------------------------------------------------------
-EXPORT_C void CUPnPAbstractBrowsingSessionObserver::EnableSessionObserver()
-    {
-    __LOG( "AbstractObserver:EnableSessionObserver()" );
-    if ( !iObserverEnabled )
-        {
-        // take original observer as proxy
-        iProxyObserver = iObservedSession->Observer();
-        iObservedSession->RemoveObserver();
-        iObservedSession->SetObserver( *this );
-        iObserverEnabled = ETrue;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::DisableSessionObserver
-//---------------------------------------------------------------------------
-EXPORT_C void CUPnPAbstractBrowsingSessionObserver::DisableSessionObserver()
-    {
-    if ( iObserverEnabled )
-        {
-        __LOG( "AbstractObserver:DisableSessionObserver()" );
-        __ASSERTD( iObservedSession != 0, __FILE__, __LINE__ );
-        // check we still are still the observer !!!
-        if ( iObservedSession->Observer() == this )
-            {
-            iObservedSession->RemoveObserver();
-            if ( iProxyObserver )
-                {
-                // set proxy observer back
-                iObservedSession->SetObserver( *iProxyObserver );
-                iProxyObserver = 0;
-                }
-            }
-        else
-            {
-            __LOG( "Disable: Not disabling - wrong observer!" );
-            }
-        iObserverEnabled = EFalse;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::IsSessionObserverEnabled
-//---------------------------------------------------------------------------
-EXPORT_C TBool CUPnPAbstractBrowsingSessionObserver::IsSessionObserverEnabled()
-    {
-    return iObserverEnabled;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::BrowseResponse
-//---------------------------------------------------------------------------
-void CUPnPAbstractBrowsingSessionObserver::BrowseResponse(
-    const TDesC8& aBrowseResponse,
-    TInt aError,
-    TInt aMatches,
-    TInt aTotalCount,
-    const TDesC8& aUpdateId )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->BrowseResponse( aBrowseResponse, aError,
-            aMatches, aTotalCount, aUpdateId );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::SearchResponse
-//---------------------------------------------------------------------------
-void CUPnPAbstractBrowsingSessionObserver::SearchResponse( 
-    const TDesC8& aSearchResponse,
-    TInt aError,
-    TInt aMatches,
-    TInt aTotalCount,
-    const TDesC8& aUpdateId )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->SearchResponse( aSearchResponse, aError,
-            aMatches, aTotalCount, aUpdateId );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::SearchCapabilitiesResponse
-//---------------------------------------------------------------------------
-void CUPnPAbstractBrowsingSessionObserver::SearchCapabilitiesResponse( 
-    TInt aError,
-    const TDesC8& aSearchCapabilities )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->SearchCapabilitiesResponse(
-            aError, aSearchCapabilities );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::CreateContainerResponse
-//---------------------------------------------------------------------------
-void CUPnPAbstractBrowsingSessionObserver::CreateContainerResponse(
-    TInt aError, 
-    const TDesC8& aObjectId )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->CreateContainerResponse( aError, aObjectId );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::DeleteObjectResponse
-//---------------------------------------------------------------------------
-void CUPnPAbstractBrowsingSessionObserver::DeleteObjectResponse(
-    TInt aError )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->DeleteObjectResponse( aError );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::ReserveLocalMSServicesCompleted
-//---------------------------------------------------------------------------
-void CUPnPAbstractBrowsingSessionObserver::
-    ReserveLocalMSServicesCompleted( TInt aError )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->ReserveLocalMSServicesCompleted( aError );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractBrowsingSessionObserver::MediaServerDisappeared
-//---------------------------------------------------------------------------
-void CUPnPAbstractBrowsingSessionObserver::MediaServerDisappeared(
-    TUPnPDeviceDisconnectedReason aReason )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->MediaServerDisappeared( aReason );
-        }
-    }
-
-
+/*
+* Copyright (c) 2007-2009 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:      An abstract browsing session observer implementation
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+#include "upnpavbrowsingsession.h"
+#include "upnpavbrowsingsessionobserver.h"
+
+#include "upnpabstractbrowsingsessionobserver.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
+#include "upnplog.h"
+
+
+// CONSTANTS
+
+
+// METHODS
+
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::CUPnPAbstractBrowsingSessionObserver
+//---------------------------------------------------------------------------
+EXPORT_C CUPnPAbstractBrowsingSessionObserver::
+    CUPnPAbstractBrowsingSessionObserver()
+    {
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::~CUPnPAbstractBrowsingSessionObserver
+//---------------------------------------------------------------------------
+EXPORT_C CUPnPAbstractBrowsingSessionObserver::
+    ~CUPnPAbstractBrowsingSessionObserver()
+    {
+    DisableSessionObserver();
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::SetSession
+//---------------------------------------------------------------------------
+EXPORT_C void CUPnPAbstractBrowsingSessionObserver::SetSession(
+    MUPnPAVBrowsingSession& aHostSession )
+    {
+    // observer bust be disabled when calling this!
+    __ASSERTD( !iObserverEnabled, __FILE__, __LINE__ );
+    iObservedSession = &aHostSession;
+    }
+
+
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::EnableSessionObserver
+//---------------------------------------------------------------------------
+EXPORT_C void CUPnPAbstractBrowsingSessionObserver::EnableSessionObserver()
+    {
+    __LOG( "AbstractObserver:EnableSessionObserver()" );
+    if ( !iObserverEnabled )
+        {
+        // take original observer as proxy
+        iProxyObserver = iObservedSession->Observer();
+        iObservedSession->RemoveObserver();
+        iObservedSession->SetObserver( *this );
+        iObserverEnabled = ETrue;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::DisableSessionObserver
+//---------------------------------------------------------------------------
+EXPORT_C void CUPnPAbstractBrowsingSessionObserver::DisableSessionObserver()
+    {
+    if ( iObserverEnabled )
+        {
+        __LOG( "AbstractObserver:DisableSessionObserver()" );
+        __ASSERTD( iObservedSession != 0, __FILE__, __LINE__ );
+        // check we still are still the observer !!!
+        if ( iObservedSession->Observer() == this )
+            {
+            iObservedSession->RemoveObserver();
+            if ( iProxyObserver )
+                {
+                // set proxy observer back
+                iObservedSession->SetObserver( *iProxyObserver );
+                iProxyObserver = 0;
+                }
+            }
+        else
+            {
+            __LOG( "Disable: Not disabling - wrong observer!" );
+            }
+        iObserverEnabled = EFalse;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::IsSessionObserverEnabled
+//---------------------------------------------------------------------------
+EXPORT_C TBool CUPnPAbstractBrowsingSessionObserver::IsSessionObserverEnabled()
+    {
+    return iObserverEnabled;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::BrowseResponse
+//---------------------------------------------------------------------------
+void CUPnPAbstractBrowsingSessionObserver::BrowseResponse(
+    const TDesC8& aBrowseResponse,
+    TInt aError,
+    TInt aMatches,
+    TInt aTotalCount,
+    const TDesC8& aUpdateId )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->BrowseResponse( aBrowseResponse, aError,
+            aMatches, aTotalCount, aUpdateId );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::SearchResponse
+//---------------------------------------------------------------------------
+void CUPnPAbstractBrowsingSessionObserver::SearchResponse( 
+    const TDesC8& aSearchResponse,
+    TInt aError,
+    TInt aMatches,
+    TInt aTotalCount,
+    const TDesC8& aUpdateId )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->SearchResponse( aSearchResponse, aError,
+            aMatches, aTotalCount, aUpdateId );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::SearchCapabilitiesResponse
+//---------------------------------------------------------------------------
+void CUPnPAbstractBrowsingSessionObserver::SearchCapabilitiesResponse( 
+    TInt aError,
+    const TDesC8& aSearchCapabilities )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->SearchCapabilitiesResponse(
+            aError, aSearchCapabilities );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::CreateContainerResponse
+//---------------------------------------------------------------------------
+void CUPnPAbstractBrowsingSessionObserver::CreateContainerResponse(
+    TInt aError, 
+    const TDesC8& aObjectId )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->CreateContainerResponse( aError, aObjectId );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::DeleteObjectResponse
+//---------------------------------------------------------------------------
+void CUPnPAbstractBrowsingSessionObserver::DeleteObjectResponse(
+    TInt aError )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->DeleteObjectResponse( aError );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractBrowsingSessionObserver::MediaServerDisappeared
+//---------------------------------------------------------------------------
+void CUPnPAbstractBrowsingSessionObserver::MediaServerDisappeared(
+    TUPnPDeviceDisconnectedReason aReason )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->MediaServerDisappeared( aReason );
+        }
+    }
+
+
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnpabstractrenderingsessionobserver.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnpabstractrenderingsessionobserver.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,227 +1,214 @@
-/*
-* Copyright (c) 2007 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:      An abstract rendering session observer implementation
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-#include "upnpavrenderingsession.h"
-#include "upnpavrenderingsessionobserver.h"
-
-#include "upnpabstractrenderingsessionobserver.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-
-
-// METHODS
-
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::CUPnPAbstractRenderingSessionObs
-//---------------------------------------------------------------------------
-EXPORT_C CUPnPAbstractRenderingSessionObserver::
-    CUPnPAbstractRenderingSessionObserver()
-    {
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::~CUPnPAbstractRenderingSessionObs
-//---------------------------------------------------------------------------
-EXPORT_C CUPnPAbstractRenderingSessionObserver::
-    ~CUPnPAbstractRenderingSessionObserver()
-    {
-    DisableSessionObserver();
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::SetSession
-//---------------------------------------------------------------------------
-EXPORT_C void CUPnPAbstractRenderingSessionObserver::SetSession(
-    MUPnPAVRenderingSession& aHostSession )
-    {
-    // observer bust be disabled when calling this!
-    __ASSERTD( !iObserverEnabled, __FILE__, __LINE__ );
-    iObservedSession = &aHostSession;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::EnableSessionObserver
-//---------------------------------------------------------------------------
-EXPORT_C void CUPnPAbstractRenderingSessionObserver::EnableSessionObserver()
-    {
-    __LOG( "AbstractObserver:EnableSessionObserver()" );
-    if ( !iObserverEnabled )
-        {
-        // take original observer as proxy
-        iProxyObserver = iObservedSession->Observer();
-        iObservedSession->RemoveObserver();
-        iObservedSession->SetObserver( *this );
-        iObserverEnabled = ETrue;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::DisableSessionObserver
-//---------------------------------------------------------------------------
-EXPORT_C void CUPnPAbstractRenderingSessionObserver::DisableSessionObserver()
-    {
-    if ( iObserverEnabled )
-        {
-        __LOG( "AbstractObserver:DisableSessionObserver()" );
-        __ASSERTD( iObservedSession != 0, __FILE__, __LINE__ );
-        // check we still are still the observer !!!
-        if ( iObservedSession->Observer() == this )
-            {
-            iObservedSession->RemoveObserver();
-            if ( iProxyObserver )
-                {
-                // set proxy observer back
-                iObservedSession->SetObserver( *iProxyObserver );
-                iProxyObserver = 0;
-                }
-            }
-        else
-            {
-            __LOG( "Disable: Not disabling - wrong observer!" );
-            }
-        iObserverEnabled = EFalse;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::IsSessionObserverEnabled
-//---------------------------------------------------------------------------
-EXPORT_C TBool CUPnPAbstractRenderingSessionObserver::
-    IsSessionObserverEnabled()
-    {
-    return iObserverEnabled;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::VolumeResult
-//---------------------------------------------------------------------------
-void CUPnPAbstractRenderingSessionObserver::VolumeResult(
-    TInt aError, TInt aVolumeLevel,
-    TBool aActionResponse )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->VolumeResult( aError, aVolumeLevel, aActionResponse );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::MuteResult
-//---------------------------------------------------------------------------
-void CUPnPAbstractRenderingSessionObserver::MuteResult(
-    TInt aError, TBool aMute,
-    TBool aActionResponse )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->MuteResult( aError, aMute, aActionResponse );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::InteractOperationComplete
-//---------------------------------------------------------------------------
-void CUPnPAbstractRenderingSessionObserver::InteractOperationComplete(
-    TInt aError, TUPnPAVInteractOperation aOperation )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->InteractOperationComplete( aError, aOperation );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::PositionInfoResult
-//---------------------------------------------------------------------------
-void CUPnPAbstractRenderingSessionObserver::PositionInfoResult( TInt aError,
-    const TDesC8& aTrackPosition, const TDesC8& aTrackLength )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->PositionInfoResult( aError,
-            aTrackPosition, aTrackLength );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::SetURIResult
-//---------------------------------------------------------------------------
-void CUPnPAbstractRenderingSessionObserver::SetURIResult( TInt aError )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->SetURIResult( aError );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::SetNextURIResult
-//---------------------------------------------------------------------------
-void CUPnPAbstractRenderingSessionObserver::SetNextURIResult( TInt aError )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->SetNextURIResult( aError );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::MediaRendererDisappeared
-//---------------------------------------------------------------------------
-void CUPnPAbstractRenderingSessionObserver::MediaRendererDisappeared(
-    TUPnPDeviceDisconnectedReason aReason )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->MediaRendererDisappeared( aReason );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAbstractRenderingSessionObserver::ReserveLocalMSServicesCompleted
-//---------------------------------------------------------------------------
-void CUPnPAbstractRenderingSessionObserver::ReserveLocalMSServicesCompleted(
-    TInt aError )
-    {
-    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
-    if ( iProxyObserver )
-        {
-        iProxyObserver->ReserveLocalMSServicesCompleted( aError );
-        }
-    }
-
+/*
+* Copyright (c) 2007-2009 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:      An abstract rendering session observer implementation
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+#include "upnpavrenderingsession.h"
+#include "upnpavrenderingsessionobserver.h"
+
+#include "upnpabstractrenderingsessionobserver.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+
+
+// METHODS
+
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::CUPnPAbstractRenderingSessionObs
+//---------------------------------------------------------------------------
+EXPORT_C CUPnPAbstractRenderingSessionObserver::
+    CUPnPAbstractRenderingSessionObserver()
+    {
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::~CUPnPAbstractRenderingSessionObs
+//---------------------------------------------------------------------------
+EXPORT_C CUPnPAbstractRenderingSessionObserver::
+    ~CUPnPAbstractRenderingSessionObserver()
+    {
+    DisableSessionObserver();
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::SetSession
+//---------------------------------------------------------------------------
+EXPORT_C void CUPnPAbstractRenderingSessionObserver::SetSession(
+    MUPnPAVRenderingSession& aHostSession )
+    {
+    // observer bust be disabled when calling this!
+    __ASSERTD( !iObserverEnabled, __FILE__, __LINE__ );
+    iObservedSession = &aHostSession;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::EnableSessionObserver
+//---------------------------------------------------------------------------
+EXPORT_C void CUPnPAbstractRenderingSessionObserver::EnableSessionObserver()
+    {
+    __LOG( "AbstractObserver:EnableSessionObserver()" );
+    if ( !iObserverEnabled )
+        {
+        // take original observer as proxy
+        iProxyObserver = iObservedSession->Observer();
+        iObservedSession->RemoveObserver();
+        iObservedSession->SetObserver( *this );
+        iObserverEnabled = ETrue;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::DisableSessionObserver
+//---------------------------------------------------------------------------
+EXPORT_C void CUPnPAbstractRenderingSessionObserver::DisableSessionObserver()
+    {
+    if ( iObserverEnabled )
+        {
+        __LOG( "AbstractObserver:DisableSessionObserver()" );
+        __ASSERTD( iObservedSession != 0, __FILE__, __LINE__ );
+        // check we still are still the observer !!!
+        if ( iObservedSession->Observer() == this )
+            {
+            iObservedSession->RemoveObserver();
+            if ( iProxyObserver )
+                {
+                // set proxy observer back
+                iObservedSession->SetObserver( *iProxyObserver );
+                iProxyObserver = 0;
+                }
+            }
+        else
+            {
+            __LOG( "Disable: Not disabling - wrong observer!" );
+            }
+        iObserverEnabled = EFalse;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::IsSessionObserverEnabled
+//---------------------------------------------------------------------------
+EXPORT_C TBool CUPnPAbstractRenderingSessionObserver::
+    IsSessionObserverEnabled()
+    {
+    return iObserverEnabled;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::VolumeResult
+//---------------------------------------------------------------------------
+void CUPnPAbstractRenderingSessionObserver::VolumeResult(
+    TInt aError, TInt aVolumeLevel,
+    TBool aActionResponse )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->VolumeResult( aError, aVolumeLevel, aActionResponse );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::MuteResult
+//---------------------------------------------------------------------------
+void CUPnPAbstractRenderingSessionObserver::MuteResult(
+    TInt aError, TBool aMute,
+    TBool aActionResponse )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->MuteResult( aError, aMute, aActionResponse );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::InteractOperationComplete
+//---------------------------------------------------------------------------
+void CUPnPAbstractRenderingSessionObserver::InteractOperationComplete(
+    TInt aError, TUPnPAVInteractOperation aOperation )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->InteractOperationComplete( aError, aOperation );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::PositionInfoResult
+//---------------------------------------------------------------------------
+void CUPnPAbstractRenderingSessionObserver::PositionInfoResult( TInt aError,
+    const TDesC8& aTrackPosition, const TDesC8& aTrackLength )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->PositionInfoResult( aError,
+            aTrackPosition, aTrackLength );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::SetURIResult
+//---------------------------------------------------------------------------
+void CUPnPAbstractRenderingSessionObserver::SetURIResult( TInt aError )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->SetURIResult( aError );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::SetNextURIResult
+//---------------------------------------------------------------------------
+void CUPnPAbstractRenderingSessionObserver::SetNextURIResult( TInt aError )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->SetNextURIResult( aError );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAbstractRenderingSessionObserver::MediaRendererDisappeared
+//---------------------------------------------------------------------------
+void CUPnPAbstractRenderingSessionObserver::MediaRendererDisappeared(
+    TUPnPDeviceDisconnectedReason aReason )
+    {
+    __ASSERTD( iObserverEnabled, __FILE__, __LINE__ );
+    if ( iProxyObserver )
+        {
+        iProxyObserver->MediaRendererDisappeared( aReason );
+        }
+    }
+
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnpdlnautility.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnpdlnautility.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,458 +1,202 @@
-/*
-* Copyright (c) 2007 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:      Utility for working with files in upnp context
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-#include <e32std.h>
-
-#include "upnpdlnautility.h"
-
-// CONSTANTS
-
-// LITERALS
-// Video mimetypes that can be played on device
-_LIT8( KVideoMp4, "video/mp4" );
-_LIT8( KVideo3Gpp, "video/3gpp" );
-
-// Audio mimetypes that can be played on device
-_LIT8( KAudioMpeg, "audio/mpeg" );
-_LIT8( KAudioWma, "audio/x-ms-wma" );
-_LIT8( KAudio3Gpp, "audio/3gpp" );
-_LIT8( KAudioMp4, "audio/mp4" );
-_LIT8( KAudioAdts, "audio/vnd.dlna.adts" );
-_LIT8( KAudioWav, "audio/x-wav" );
-_LIT8( KAudioXAac, "audio/x-aac" );
-_LIT8( KAudioAac, "audio/aac" );
-_LIT8( KAudioM4a, "audio/x-m4a" );
-
-// Image mimetypes that can be played on device
-_LIT8( KImageJpeg, "image/jpeg" );
-_LIT8( KImagePng, "image/png" );
-_LIT8( KImageGif, "image/gif" );
-_LIT8( KImageBmp, "image/bmp" );
-
-// Video profiles that can be played on device
-_LIT8( KAvcMp4BlCif15Aac520, "AVC_MP4_BL_CIF15_AAC_520" );
-_LIT8( KMpeg4H2633gppP3L10Amr, "MPEG4_H263_3GPP_P3_L10_AMR" ); 
-_LIT8( KMpeg4P23gppSpL0bAmr, "MPEG4_P2_3GPP_SP_L0B_AMR" ); 
-_LIT8( KMpeg4P2Mp4AspAac, "MPEG4_P2_MP4_ASP_AAC" ); 
-_LIT8( KMpeg4P2Mp4AspHeaac, "MPEG4_P2_MP4_ASP_HEAAC" ); 
-_LIT8( KMpeg4P2Mp4AspL4SoAac, "MPEG4_P2_MP4_ASP_L4_SO_AAC" ); 
-_LIT8( KMpeg4P2Mp4AspL4SoHeaac, "MPEG4_P2_MP4_ASP_L4_SO_HEAAC" ); 
-_LIT8( KMpeg4P2Mp4SpVgaAac, "MPEG4_P2_MP4_SP_VGA_AAC" ); 
-_LIT8( KMpeg4P2Mp4SpVgaHeaac, "MPEG4_P2_MP4_SP_VGA_HEAAC" ); 
-_LIT8( KMpeg4P2Mp4SpL2Aac, "MPEG4_P2_MP4_SP_L2_AAC" ); 
-_LIT8( KMpeg4P2Mp4spAac, "MPEG4_P2_MP4_SP_AAC" );
-
-_LIT8( KMpeg4P23gppSpL0bAac, "MPEG4_P2_3GPP_SP_L0B_AAC");
-_LIT8( KAvcMp4BlCif15Aac, "AVC_MP4_BL_CIF15_AAC" ); 
-_LIT8( KAvcMp4BlCif15AacLtp, "AVC_MP4_BL_CIF15_AAC_LTP" ); 
-_LIT8( KAvcMp4BlCif15AacLtp520, "AVC_MP4_BL_CIF15_AAC_LTP_520" ); 
-_LIT8( KAvcMp4BlCif30Aac940, "AVC_MP4_BL_CIF30_AAC_940" ); 
-_LIT8( KAvcMp4BlL12Cif15Heaac, "AVC_MP4_BL_L12_CIF15_HEAAC" );
-_LIT8( KAvcTSBlCif15Aac, "AVC_TS_BL_CIF15_AAC" );
-
-// Audio profiles that can be played on device
-_LIT8( KAacIso, "AAC_ISO" ); 
-_LIT8( KAacIso320, "AAC_ISO_320" );
-_LIT8( KAacAdts, "AAC_ADTS" ); 
-_LIT8( KAacAdts320, "AAC_ADTS_320" ); 
-_LIT8( KAacMult5Iso, "AAC_MULT5_ISO" );
-_LIT8( KHeaacL2Iso, "HEAAC_L2_ISO" ); 
-_LIT8( KHeaacL2Iso320, "HEAAC_L2_ISO_320" ); 
-_LIT8( KHeaacL2Adts, "HEAAC_L2_ADTS" ); 
-_LIT8( KHeaacL2Adts320, "HEAAC_L2_ADTS_320" ); 
-_LIT8( KHeaacMuLt5Iso, "HEAAC_MULT5_ISO" ); 
-_LIT8( KHeaacL3ADTS, "HEAAC_L3_ADTS" ); 
-_LIT8( KAmr3gpp, "AMR_3GPP" ); 
-_LIT8( KAmrWbplus, "AMR_WBplus" ); 
-_LIT8( KMp3, "MP3" );
-_LIT8( KMp3x, "MP3X" ); 
-_LIT8( KWmaBase, "WMABASE" );
-_LIT8( KWmaFull, "WMAFULL" );
-
-// Image profiles that can be played on device
-_LIT8( KJpegLrg, "JPEG_LRG" ); 
-_LIT8( KJpegMed, "JPEG_MED" ); 
-_LIT8( KJpegSm, "JPEG_SM" );
-_LIT8( KPngLrg, "PNG_LRG" );
-_LIT8( KJpegLrgIco, "JPEG_LRG_ICO" );
-_LIT8( KJpegSmIco, "JPEG_SM_ICO" );
-_LIT8( KJpegTn, "JPEG_TN" );
-_LIT8( KPngTn, "PNG_TN" );
-_LIT8( KPngSmIco, "PNG_SM_ICO" );
-_LIT8( KPngLrgIco, "PNG_LRG_ICO" );
-
-
-// ============================ LOCAL FUNCTIONS =============================
-
-// --------------------------------------------------------------------------
-// UPnPDlnaUtility::GetSupportedProfilesL
-// Returns Supported dlna profiles, Only player mode supported.
-// --------------------------------------------------------------------------
-EXPORT_C CDesC8Array& UPnPDlnaUtility::GetSupportedProfilesL( 
-    const TDlnaMode aMode )
-    {
-    CDesC8Array* array = new (ELeave) CDesC8ArrayFlat( 10 );
-    CleanupStack::PushL( array );
-    // At the m
-    switch( aMode )
-        {         
-        case EDMPMode:
-            {
-            // Video profiles that can be played on device
-            array->AppendL( KAvcMp4BlCif15Aac520() );
-            array->AppendL( KMpeg4H2633gppP3L10Amr() );
-            array->AppendL( KMpeg4P23gppSpL0bAmr() );
-            array->AppendL( KMpeg4P2Mp4AspAac() );
-            array->AppendL( KMpeg4P2Mp4AspHeaac() );
-            array->AppendL( KMpeg4P2Mp4AspL4SoAac() );
-            array->AppendL( KMpeg4P2Mp4AspL4SoHeaac() );
-            array->AppendL( KMpeg4P2Mp4SpVgaAac() );
-            array->AppendL( KMpeg4P2Mp4AspL4SoHeaac() );
-            array->AppendL( KMpeg4P2Mp4SpVgaAac() );
-            array->AppendL( KMpeg4P2Mp4SpVgaHeaac() );
-            array->AppendL( KMpeg4P2Mp4SpL2Aac() );
-            array->AppendL( KMpeg4P2Mp4spAac() );
-            
-            array->AppendL( KMpeg4P23gppSpL0bAac() );
-            array->AppendL( KAvcMp4BlCif15Aac() );
-            array->AppendL( KAvcMp4BlCif15AacLtp() );
-            array->AppendL( KAvcMp4BlCif15AacLtp520() );
-            array->AppendL( KAvcMp4BlCif30Aac940() );
-            array->AppendL( KAvcMp4BlL12Cif15Heaac() );
-            array->AppendL( KAvcTSBlCif15Aac() );            
-            
-            // Audio profiles that can be played on device
-            array->AppendL( KAacIso() );
-            array->AppendL( KAacIso320() );
-            array->AppendL( KAacAdts() );
-            array->AppendL( KAacAdts320() );
-            array->AppendL( KAacMult5Iso() );
-            array->AppendL( KHeaacL2Iso() );
-            array->AppendL( KHeaacL2Iso320() );
-            array->AppendL( KHeaacL2Adts() );
-            array->AppendL( KHeaacL2Adts320() );
-            array->AppendL( KAmr3gpp() );
-            array->AppendL( KAmrWbplus() );
-            array->AppendL( KMp3() );
-            array->AppendL( KMp3x() );
-            array->AppendL( KWmaBase() );
-            array->AppendL( KWmaFull() );
-            
-            // Image profiles that can be played on device
-            array->AppendL( KJpegLrg() );
-            array->AppendL( KJpegMed() );
-            array->AppendL( KJpegSm() );            
-            array->AppendL( KPngLrg() ); //fix for EFCG-7E2DKU            
-            array->AppendL( KJpegLrgIco() );
-            array->AppendL( KJpegSmIco() );
-            array->AppendL( KJpegTn() );
-            array->AppendL( KPngTn() );
-            array->AppendL( KPngSmIco() );
-            array->AppendL( KPngLrgIco() );
-
-            break;
-            }
-        case EDMSMode:
-        case EDMUMode:      
-        case EDMDMode:    
-        default:            
-            {
-            User::Leave( KErrNotSupported );
-            break;
-            }             
-        }
-    CleanupStack::Pop( array );        
-    return *array;        
-    }
-    
-// --------------------------------------------------------------------------
-// UPnPDlnaUtility::IsSupportedMimeType
-// Returns ETrue if aMime is such a mime type for which playback on device 
-// might be supported.
-// -------------------------------------------------------------------------- 
-EXPORT_C TBool UPnPDlnaUtility::IsSupportedMimeType( const TDesC8& aMime ) 
-    {
-    TBool retval = EFalse;
-    
-    if ( aMime.Compare( KVideoMp4() ) == 0 ) 
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare( KVideo3Gpp() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare( KAudioMpeg() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare( KAudioWma() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare( KAudio3Gpp() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare( KAudioMp4() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare( KAudioAdts() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare( KImageJpeg() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare( KImagePng() ) == 0 )
-        {
-        retval = ETrue;
-        } 
-    else if ( aMime.Compare ( KAudioWav() ) == 0 ) 
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare ( KAudioXAac() ) == 0 ) 
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare ( KAudioAac() ) == 0 ) 
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare ( KAudioM4a() ) == 0 ) 
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare ( KImageGif() ) == 0 ) 
-        {
-        retval = ETrue;
-        }
-    else if ( aMime.Compare ( KImageBmp() ) == 0 ) 
-        {
-        retval = ETrue;
-        }
-
-    return retval;
-    }
-    
-// --------------------------------------------------------------------------
-// UPnPDlnaUtility::IsSupportedDlnaProfile
-// Returns ETrue if aProfile is such a DLNA profile for which playback on 
-// device might be supported.
-// -------------------------------------------------------------------------- 
-EXPORT_C TBool UPnPDlnaUtility::IsSupportedDlnaProfile( 
-    const TDesC8& aProfile ) 
-    {
-    TBool retval = EFalse;
-    
-    if ( aProfile.Compare( KAvcMp4BlCif15Aac520() ) == 0 ) 
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMpeg4H2633gppP3L10Amr() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMpeg4P23gppSpL0bAmr() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMpeg4P2Mp4AspAac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMpeg4P2Mp4AspHeaac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMpeg4P2Mp4AspL4SoAac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMpeg4P2Mp4AspL4SoHeaac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMpeg4P2Mp4SpVgaAac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMpeg4P2Mp4SpVgaHeaac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMpeg4P2Mp4SpL2Aac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMpeg4P2Mp4spAac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if( aProfile.Compare( KMpeg4P23gppSpL0bAac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAvcMp4BlCif15Aac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAvcMp4BlCif15AacLtp() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAvcMp4BlCif15AacLtp520() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAvcMp4BlCif30Aac940() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAvcMp4BlL12Cif15Heaac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAvcTSBlCif15Aac() ) == 0 )
-        {
-        retval = ETrue;
-        }
-     
-    else if ( aProfile.Compare( KAacIso() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAacIso320() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAacAdts() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAacAdts320() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAacMult5Iso() ) == 0 ) 
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KHeaacL2Iso() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KHeaacL2Iso320() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KHeaacL2Adts() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KHeaacL2Adts320() ) == 0 )
-        {
-        retval = ETrue;
-        }
-	else if ( aProfile.Compare( KHeaacMuLt5Iso() ) == 0 )
-        {
-        retval = ETrue;
-        }
-	else if ( aProfile.Compare( KHeaacL3ADTS() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAmr3gpp() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KAmrWbplus() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMp3() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KMp3x() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KWmaBase() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KWmaFull() ) == 0 )
-        {
-        retval = ETrue;
-        }
-
-    else if ( aProfile.Compare( KJpegLrg() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KJpegMed() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KJpegSm() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KPngLrg() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KJpegLrgIco() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KJpegSmIco() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KJpegTn() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KPngTn() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KPngSmIco() ) == 0 )
-        {
-        retval = ETrue;
-        }
-    else if ( aProfile.Compare( KPngLrgIco() ) == 0 )
-        {
-        retval = ETrue;
-        }
-
-    return retval;    
-    }
-
-// End of file
-
+/*
+* Copyright (c) 2007 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:      Utility for working with files in upnp context
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+#include <e32std.h>
+#include <e32des8.h> 
+#include "upnpdlnautility.h"
+
+// CONSTANTS
+
+#define CHARTOVOID(chr) (const void*)chr
+
+/**
+ * pointer array for mime types 
+ */
+const void* const KMimeTypes[]=
+    {
+    CHARTOVOID("video/mp4"),
+    CHARTOVOID("video/3gpp"),
+    CHARTOVOID("audio/mpeg"),
+    CHARTOVOID("audio/x-ms-wma"),
+    CHARTOVOID("audio/3gpp"),
+    CHARTOVOID("audio/mp4"),
+    CHARTOVOID("audio/vnd.dlna.adts"),
+    CHARTOVOID("audio/x-wav"),
+    CHARTOVOID("audio/x-aac"),
+    CHARTOVOID("audio/aac"),
+    CHARTOVOID("audio/x-m4a"),
+    CHARTOVOID("image/jpeg"),
+    CHARTOVOID("image/png"),
+    CHARTOVOID("image/gif"),
+    CHARTOVOID("image/bmp")
+    };
+
+/**
+ * pointer array for dlna types 
+ */
+const void* const KDlnaTypes[]=
+    {
+    CHARTOVOID( "AVC_MP4_BL_CIF15_AAC_520" ),
+    CHARTOVOID( "MPEG4_H263_3GPP_P3_L10_AMR" ), 
+    CHARTOVOID( "MPEG4_P2_3GPP_SP_L0B_AMR" ), 
+    CHARTOVOID( "MPEG4_P2_MP4_ASP_AAC" ), 
+    CHARTOVOID( "MPEG4_P2_MP4_ASP_HEAAC" ), 
+    CHARTOVOID( "MPEG4_P2_MP4_ASP_L4_SO_AAC" ), 
+    CHARTOVOID( "MPEG4_P2_MP4_ASP_L4_SO_HEAAC" ), 
+    CHARTOVOID( "MPEG4_P2_MP4_SP_VGA_AAC" ), 
+    CHARTOVOID( "MPEG4_P2_MP4_SP_VGA_HEAAC" ), 
+    CHARTOVOID( "MPEG4_P2_MP4_SP_L2_AAC" ), 
+    CHARTOVOID( "MPEG4_P2_MP4_SP_AAC" ),    
+    CHARTOVOID( "MPEG4_P2_3GPP_SP_L0B_AAC"),
+    CHARTOVOID( "AVC_MP4_BL_CIF15_AAC" ), 
+    CHARTOVOID( "AVC_MP4_BL_CIF15_AAC_LTP" ), 
+    CHARTOVOID( "AVC_MP4_BL_CIF15_AAC_LTP_520" ), 
+    CHARTOVOID( "AVC_MP4_BL_CIF30_AAC_940" ), 
+    CHARTOVOID( "AVC_MP4_BL_L12_CIF15_HEAAC" ),
+    CHARTOVOID( "AVC_TS_BL_CIF15_AAC" ),   
+    CHARTOVOID( "AVC_MP4_MP_HD_720p_AAC" ),
+    CHARTOVOID( "AVC_MP4_HP_HD_AAC" ),    
+    // Audio profiles that can be played on device 
+    CHARTOVOID( "AAC_ISO" ), 
+    CHARTOVOID( "AAC_ISO_320" ),
+    CHARTOVOID( "AAC_ADTS" ), 
+    CHARTOVOID( "AAC_ADTS_320" ), 
+    CHARTOVOID( "AAC_MULT5_ISO" ),
+    CHARTOVOID( "HEAAC_L2_ISO" ), 
+    CHARTOVOID( "HEAAC_L2_ISO_320" ), 
+    CHARTOVOID( "HEAAC_L2_ADTS" ), 
+    CHARTOVOID( "HEAAC_L2_ADTS_320" ), 
+    CHARTOVOID( "HEAAC_MULT5_ISO" ), 
+    CHARTOVOID( "HEAAC_L3_ADTS" ), 
+    CHARTOVOID( "AMR_3GPP" ), 
+    CHARTOVOID( "AMR_WBplus" ), 
+    CHARTOVOID( "MP3" ),
+    CHARTOVOID( "MP3X" ), 
+    CHARTOVOID( "WMABASE" ),
+    CHARTOVOID( "WMAFULL" ),    
+    // Image profiles that can be played on device 
+    CHARTOVOID( "JPEG_LRG" ), 
+    CHARTOVOID( "JPEG_MED" ), 
+    CHARTOVOID( "JPEG_SM" ),
+    CHARTOVOID( "PNG_LRG" ),
+    CHARTOVOID( "JPEG_LRG_ICO" ),
+    CHARTOVOID( "JPEG_SM_ICO" ),
+    CHARTOVOID( "JPEG_TN" ),
+    CHARTOVOID( "PNG_TN" ),
+    CHARTOVOID( "PNG_SM_ICO" ),
+    CHARTOVOID( "PNG_LRG_ICO" )
+    };
+
+const TStringTable UPnPDlnaUtility::iMimeTypes = 
+    {
+    15, 
+    KMimeTypes, 
+    EFalse
+    };
+
+const TStringTable UPnPDlnaUtility::iDlnaTypes = 
+    {
+    47, 
+    KDlnaTypes, 
+    EFalse
+    };
+
+// ============================ LOCAL FUNCTIONS =============================
+
+// --------------------------------------------------------------------------
+// UPnPDlnaUtility::GetSupportedProfilesL
+// Returns Supported dlna profiles, Only player mode supported.
+// --------------------------------------------------------------------------
+EXPORT_C CDesC8Array& UPnPDlnaUtility::GetSupportedProfilesL( 
+    const TDlnaMode aMode )
+    {
+    CDesC8Array* array = new (ELeave) CDesC8ArrayFlat( 10 );
+    CleanupStack::PushL( array );
+    // At the m
+    switch( aMode )
+        {         
+        case EDMPMode:
+            {
+            // Video profiles that can be played on device
+            
+            for ( TInt i(0) ; i < UPnPDlnaUtility::iDlnaTypes.iCount ; ++i )
+                {
+                array->AppendL( TPtrC8( 
+                (const TUint8*)(UPnPDlnaUtility::iDlnaTypes.iTable[i]) ) );
+                }
+            break;
+            }
+        case EDMSMode:
+        case EDMUMode:      
+        case EDMDMode:    
+        default:            
+            {
+            User::Leave( KErrNotSupported );
+            break;
+            }             
+        }
+    CleanupStack::Pop( array );        
+    return *array;        
+    }
+    
+// --------------------------------------------------------------------------
+// UPnPDlnaUtility::IsSupportedMimeType
+// Returns ETrue if aMime is such a mime type for which playback on device 
+// might be supported.
+// -------------------------------------------------------------------------- 
+EXPORT_C TBool UPnPDlnaUtility::IsSupportedMimeType( const TDesC8& aMime ) 
+    {
+    return UPnPDlnaUtility::IsSupported(iMimeTypes,aMime);
+    }
+    
+// --------------------------------------------------------------------------
+// UPnPDlnaUtility::IsSupportedDlnaProfile
+// Returns ETrue if aProfile is such a DLNA profile for which playback on 
+// device might be supported.
+// -------------------------------------------------------------------------- 
+EXPORT_C TBool UPnPDlnaUtility::IsSupportedDlnaProfile( 
+    const TDesC8& aProfile ) 
+    {
+    return UPnPDlnaUtility::IsSupported(iDlnaTypes,aProfile);  
+    }
+
+//---------------------------------------------------------------------------
+// IsSupported
+//---------------------------------------------------------------------------
+TBool UPnPDlnaUtility::IsSupported( const TStringTable& aTable 
+                                  , const TDesC8& aType )
+    {
+    TBool ret( EFalse );
+    for ( TInt i(0) ; i < aTable.iCount ; ++i )
+        {
+        if ( aType == TPtrC8( (const TUint8*)(aTable.iTable[i]) ) )
+            {
+            ret = ETrue;
+            i = aTable.iCount;
+            }
+        }
+    return ret;
+    }
+
+// End of file
+
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnpdownloaditemresolver.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnpdownloaditemresolver.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,596 +1,599 @@
-/*
-* Copyright (c) 2007 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:      Resolver for downloading remote items
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <pathinfo.h>
-#include <bautils.h>
-
-// upnp stack api's
-#include <upnpobject.h>
-#include <upnpitem.h>
-#include <upnpelement.h>
-#include <upnpattribute.h> // for getting resource protocol info
-#include <upnpdlnaprotocolinfo.h> // for resolving object mimetype
-
-// upnpframework / avcontroller api
-#include "upnpavcontroller.h" // avcontrol services
-#include "upnpavdevice.h" // avcontroller device class
-#include "upnpavbrowsingsession.h" // avcontrol browsing session
-#include "upnpfiledownloadsession.h" // avcontrol download session
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h" // for element names
-#include "upnpitemutility.h" // for FindAttributeByName
-#include "upnpresourceselector.h" // MUPnPResourceSelector
-#include "upnpitemresolverobserver.h" // observer for this class
-#include "upnpdlnautility.h"  // IsSupportedDlnaProfile
-
-// upnpframework / internal api's
-#include "upnpcommonutils.h" // for FileExtensionByMimeTypeL
-#include "upnpsettingsengine.h" // get selected download location
-
-// avcontroller helper internal
-#include "upnpremoteitemresolver.h" // remote item resolver impl.
-#include "upnpdownloaditemresolver.h" // download item resolver impl.
-
-_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-_LIT( KTempPrefix, "upnpfwtemp");
-
-// METHODS
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::NewL
-//---------------------------------------------------------------------------
-CUPnPDownloadItemResolver* CUPnPDownloadItemResolver::NewL(
-    const TDesC8& aItemId,
-    MUPnPAVController& aAvController,
-    MUPnPAVBrowsingSession& aHostSession,
-    MUPnPResourceSelector& aSelector,
-    const TDesC8& aBrowseFilter )
-    {
-    CUPnPDownloadItemResolver* self = new (ELeave) CUPnPDownloadItemResolver(
-        aItemId, aAvController, aHostSession, aSelector, aBrowseFilter );
-    CleanupStack::PushL( self );
-    self->ConstructL(
-        aItemId, aAvController, aHostSession, aSelector, aBrowseFilter );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::CUPnPDownloadItemResolver
-//---------------------------------------------------------------------------
-CUPnPDownloadItemResolver::CUPnPDownloadItemResolver(
-    const TDesC8& /*aItemId*/,
-    MUPnPAVController& aAvController,
-    MUPnPAVBrowsingSession& /*aHostSession*/,
-    MUPnPResourceSelector& aSelector,
-    const TDesC8& /*aBrowseFilter*/ )
-    : iAvController( aAvController ),
-      iState( EStateIdle ),iSelector(aSelector)
-    {
-
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::ConstructL
-//---------------------------------------------------------------------------
-void CUPnPDownloadItemResolver::ConstructL(
-    const TDesC8& aItemId,
-    MUPnPAVController& /*aAvController*/,
-    MUPnPAVBrowsingSession& aHostSession,
-    MUPnPResourceSelector& aSelector,
-    const TDesC8& aBrowseFilter )
-    {
-    iRemoteResolver = CUPnPRemoteItemResolver::NewL(
-        aItemId, aHostSession, aSelector, aBrowseFilter );
-    iRemoteDevice = CUpnpAVDevice::NewL( aHostSession.Device() );
-    iSettingsEngine = CUPnPSettingsEngine::NewL();
-    
-    // Open File Server session
-    User::LeaveIfError( iFsSession.Connect() );
-    User::LeaveIfError( iFsSession.ShareProtected() );   
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::~CUPnPDownloadItemResolver
-//---------------------------------------------------------------------------
-CUPnPDownloadItemResolver::~CUPnPDownloadItemResolver()
-    {        
-    Cleanup();
-    delete iRemoteResolver;
-    iRemoteResolver = 0;
-    delete iRemoteDevice;
-    iRemoteDevice= 0;
-    delete iSettingsEngine;
-    iSettingsEngine = 0;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::ResolveL
-//---------------------------------------------------------------------------
-void CUPnPDownloadItemResolver::ResolveL(
-    MUPnPItemResolverObserver& aObserver )
-    {
-    __LOG( "DownloadItemResolver:Resolve()" );
-    __ASSERTD( iState == EStateIdle, __FILE__, __LINE__ );
-
-    // change state
-    iObserver = &aObserver;
-
-    // first resolve the item
-    iRemoteResolver->ResolveL( *this );
-    iState = EStateResolving;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::ResolveComplete
-//---------------------------------------------------------------------------
-void CUPnPDownloadItemResolver::ResolveComplete(
-    const MUPnPItemResolver& /*aResolver*/, TInt aError )
-    {
-    __LOG1( "DownloadItemResolver:ResolveComplete(%d)", aError );
-    __ASSERTD( iState == EStateResolving, __FILE__, __LINE__ );
-
-    if ( aError == KErrNone )
-        {
-        TRAP( aError, 
-                const CUpnpElement& res =
-                        iSelector.SelectResourceL( iRemoteResolver->Item() );
-                IsLocallySupportedL( res );
-                );
-        if( aError )
-            {
-            Complete( aError );
-            }
-        else
-            {
-            TRAPD( err, InitiateDownloadL() );
-            if ( err != KErrNone )
-                {
-                Complete( err );
-                }
-            }
-        }
-    else
-        {
-        Complete( aError );
-        }
-
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::InitiateDownloadL
-//---------------------------------------------------------------------------
-void CUPnPDownloadItemResolver::InitiateDownloadL()
-    {
-    __LOG( "CUPnPDownloadItemResolver::InitiateDownloadL");
-    // start a download session if not already started
-    if( !iDownloadSession )
-        {
-        iDownloadSession =
-            &iAvController.StartDownloadSessionL( *iRemoteDevice );
-        }
-    iDownloadSession->SetObserver( *this );
-
-    // Get selected download location.
-    HBufC* copyLocation = GetSelectedDownloadLocationL();
-    CleanupStack::PushL( copyLocation );
-    _LIT(KTempFolder, "temp\\");
-    // Create temp file name
-    HBufC* tempFileName = CreateTmpFileNameL();
-    CleanupStack::PushL( tempFileName );
-
-    // Create and save full file path.
-    if( iLocalFile )
-        {
-        // delete if already allocated.
-        delete iLocalFile;
-        iLocalFile = 0;
-        }
-    
-    iLocalFile = HBufC::NewL( copyLocation->Length() +
-                              KTempFolder().Length() );
-    iLocalFile->Des().Append( *copyLocation );
-    iLocalFile->Des().Append( KTempFolder );
-    //check the existence of the target folder
-    if( !BaflUtils::FolderExists( iFsSession, *iLocalFile ) )
-        {
-        User::LeaveIfError( iFsSession.MkDirAll( *iLocalFile ) );
-        }
-        
-    User::LeaveIfError( iFsSession.SetAtt( *iLocalFile, 
-                                    KEntryAttHidden, 
-                                    KEntryAttNormal ) );
-                                        
-    iLocalFile = iLocalFile->ReAllocL( 
-        iLocalFile->Length() + tempFileName->Length() );
-    
-    iLocalFile->Des().Append( *tempFileName );
-
-    // write the file path into the item
-    CUpnpElement& writableRes =
-        const_cast<CUpnpElement&>( iRemoteResolver->Resource() );
-    writableRes.SetFilePathL( *iLocalFile );
-    CleanupStack::PopAndDestroy( tempFileName );
-    CleanupStack::PopAndDestroy( copyLocation );
-    
-    // Create local target file for dowload item
-    TInt err = CreateRFile( *iLocalFile );
-
-    if( err == KErrNone )
-        {
-        __LOG( "StartDownloading...");
-        // initiate download
-        
-        iDownloadSession->StartDownloadL( writableRes, 
-                                      iRemoteResolver->Item(), 
-                                      iFile,
-                                      (TInt)this );
-                                      
-        iState = EStateDownloading;
-        }
-    else // Create download target failed!
-        {
-        __LOG( "Create download target failed!");
-        User::Leave( err );
-        }
-    __LOG( "CUPnPDownloadItemResolver::InitiateDownloadL -End");
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::TransferStarted
-//---------------------------------------------------------------------------
-void CUPnPDownloadItemResolver::TransferStarted( TInt /*aKey*/,
-    TInt /*aStatus*/ )
-    {
-    __LOG( "DownloadItemResolver:TransferStarted");
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::TransferCompleted
-//---------------------------------------------------------------------------
-void CUPnPDownloadItemResolver::TransferCompleted( TInt /*aKey*/,
-    TInt aStatus, const TDesC& /*aFilePath*/ )
-    {
-    __LOG1( "DownloadItemResolver:TransferCompleted(%d)", aStatus );
-    iFile.Close();
-    Complete( aStatus );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::TransferProgress
-//---------------------------------------------------------------------------
-void CUPnPDownloadItemResolver::TransferProgress( TInt /*aKey*/,
-    TInt /*aBytes*/, TInt /*aTotalBytes*/ )
-    {
-    __LOG( "DownloadItemResolver:TransferProgress");
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::MediaServerDisappeared
-//---------------------------------------------------------------------------
-void CUPnPDownloadItemResolver::MediaServerDisappeared(
-    TUPnPDeviceDisconnectedReason /*aReason*/ )
-    {
-    __LOG( "DownloadItemResolver:MediaServerDisappeared" );
-    Complete( KErrDisconnected );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::Item
-//---------------------------------------------------------------------------
-const CUpnpItem& CUPnPDownloadItemResolver::Item() const
-    {
-    __ASSERTD( iState == EStateReady, __FILE__, __LINE__ );
-
-    return iRemoteResolver->Item();
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::Resource
-//---------------------------------------------------------------------------
-const CUpnpElement& CUPnPDownloadItemResolver::Resource() const
-    {
-    __ASSERTD( iState == EStateReady, __FILE__, __LINE__ );
-
-    return iRemoteResolver->Resource();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::DeleteTempFilesL
-// --------------------------------------------------------------------------
-EXPORT_C void CUPnPDownloadItemResolver::DeleteTempDownloadFilesL()
-    {
-    __LOG("CUPnPDownloadItemResolver::DeleteTempDownloadFilesL begin");
-
-    RFs fs;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL( fs );
-
-    CFileMan* fileMan = CFileMan::NewL( fs );
-    CleanupStack::PushL( fileMan );
-    _LIT( KAnyChar, "*");
-    _LIT( KAnyExtension, "*.*");
-    _LIT( KUpnpUploadTempDirectory, "temp\\" );
-
-    // clean selected download directory
-    HBufC* path = HBufC::NewLC( KMaxFileName );
-    CUPnPSettingsEngine* settingsEngine = CUPnPSettingsEngine::NewL();
-    CleanupStack::PushL( settingsEngine );
-    HBufC* copyLocation = HBufC::NewL( KMaxFileName );
-    CleanupStack::PushL( copyLocation );
-    TBool copyLocationIsPhoneMemory = 0; // not used in this case
-    TPtr copyLocationPtr( copyLocation->Des() );
-    settingsEngine->GetCopyLocationL( copyLocationPtr,
-        copyLocationIsPhoneMemory );
-    path->Des().Append( *copyLocation );
-    path->Des().Append( KAnyChar );
-    path->Des().Append( KTempPrefix );
-    path->Des().Append( KAnyExtension );
-    fileMan->Delete( *path );
-    
-    path->Des().Zero();
-    path->Des().Append( *copyLocation );
-    path->Des().Append( KUpnpUploadTempDirectory );
-    path->Des().Append( KAnyExtension );
-    fileMan->Delete( *path );
-
-    CleanupStack::PopAndDestroy( copyLocation );
-    CleanupStack::PopAndDestroy( settingsEngine );
-    CleanupStack::PopAndDestroy( path );
-
-    CleanupStack::PopAndDestroy( fileMan );
-    CleanupStack::PopAndDestroy( &fs );
-
-    __LOG("CUPnPDownloadItemResolver::DeleteTempDownloadFilesL End");
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::Complete
-//---------------------------------------------------------------------------
-void CUPnPDownloadItemResolver::Complete( TInt aError )
-    {
-    __ASSERTD( iState == EStateResolving || iState == EStateDownloading,
-        __FILE__, __LINE__ );
-
-    if ( iDownloadSession != 0 )
-        {
-        iAvController.StopDownloadSession( *iDownloadSession );
-        iDownloadSession = 0;
-        }
-
-    MUPnPItemResolverObserver& observer = *iObserver;
-    iObserver = 0;
-    if ( aError == KErrNone )
-        {
-        iState = EStateReady;
-        }
-    else
-        {
-        iState = EStateIdle;
-        Cleanup();
-        }
-
-    observer.ResolveComplete( *this, aError );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::Cleanup
-//---------------------------------------------------------------------------
-void CUPnPDownloadItemResolver::Cleanup()
-    {
-    iObserver = 0;
-    iFile.Close();
-    
-    if ( iDownloadSession != 0 )
-        {
-        iAvController.StopDownloadSession( *iDownloadSession );
-        iDownloadSession = 0;
-        }
-        
-    if ( iLocalFile )
-        {
-        // delete the local file
-        iFsSession.Delete( iLocalFile->Des() );       
-        __LOG1( "DownloadItemResolver: deleted local file(%d)", iLocalFile );
-        delete iLocalFile;
-        iLocalFile = 0;
-        }
-        
-    iFsSession.Close();
-
-    iState = EStateIdle;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::CreateTmpFileNameL
-//---------------------------------------------------------------------------
-HBufC* CUPnPDownloadItemResolver::CreateTmpFileNameL()
-    {
-    __LOG( "DownloadItemResolver::CreateTmpFileName" );
-    __ASSERTD( iState == EStateResolving, __FILE__, __LINE__ );
-
-    HBufC* tempfilename = NULL;
-    HBufC* fileExt = NULL;
-    
-    // Get file extension
-    const CUpnpAttribute* attr = UPnPItemUtility
-        ::FindAttributeByName( iRemoteResolver->Resource(), 
-        KAttributeProtocolInfo );
-    if ( attr != 0 )
-        {
-        CUpnpDlnaProtocolInfo* pInfo =
-            CUpnpDlnaProtocolInfo::NewL( attr->Value() );
-        CleanupStack::PushL( pInfo );
-        fileExt = UPnPCommonUtils::FileExtensionByMimeTypeL(
-            pInfo->ThirdField() );
-        CleanupStack::PopAndDestroy( pInfo );
-        pInfo = NULL;
-        }
-
-    // If file extension exist create whole file name.
-    if( fileExt )
-        {
-        CleanupStack::PushL( fileExt );
-        tempfilename = HBufC::NewL( 
-            KTempPrefix().Length() + 
-            iRemoteResolver->Item().Id().Length() + 
-            fileExt->Length() );
-        CleanupStack::PushL( tempfilename );
-        // Add prefix
-        tempfilename->Des().Append( KTempPrefix ); 
-        // Add item name. Convert 8 to 16 and replace illeagal characters.
-        HBufC8* tmpItemName8 = 
-            UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
-            iRemoteResolver->Item().Id() );
-        CleanupStack::PushL( tmpItemName8 );
-        HBufC* itemname = HBufC::NewL( tmpItemName8->Length() );
-        CleanupStack::PushL( itemname );
-        itemname->Des().Copy( *tmpItemName8 );
-        tempfilename->Des().Append( *itemname );
-        CleanupStack::PopAndDestroy( itemname );
-        CleanupStack::PopAndDestroy( tmpItemName8 );
-        // Add file extension
-        tempfilename->Des().Append( *fileExt );
-
-        CleanupStack::Pop( tempfilename );
-        CleanupStack::PopAndDestroy( fileExt );
-        }
-    else // Create without file extension
-        {
-        tempfilename = HBufC::NewL( 
-            KTempPrefix().Length() + iRemoteResolver->Item().Id().Length() );
-        CleanupStack::PushL( tempfilename );
-        // Add prefix
-        tempfilename->Des().Append( KTempPrefix ); 
-        // Add item name. Convert 8 to 16 and replace illeagal characters.
-        HBufC8* tmpItemName8 = 
-            UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
-            iRemoteResolver->Item().Id() );
-        CleanupStack::PushL( tmpItemName8 );
-        HBufC* itemname = HBufC::NewL( tmpItemName8->Length() );
-        CleanupStack::PushL( itemname );
-        itemname->Des().Copy( *tmpItemName8 );
-        tempfilename->Des().Append( *itemname );
-        CleanupStack::PopAndDestroy( itemname );
-        CleanupStack::PopAndDestroy( tmpItemName8 );
-
-        CleanupStack::Pop( tempfilename );
-        }
-
-    return tempfilename; //transfer ownership
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::GetSelectedDownloadLocationL
-//---------------------------------------------------------------------------
-HBufC* CUPnPDownloadItemResolver::GetSelectedDownloadLocationL()
-    {
-    __LOG( "DownloadItemResolver::GetSelectedDownloadLocationL" );
-
-    HBufC* copyLocation = HBufC::NewL( KMaxFileName );
-    CleanupStack::PushL( copyLocation );
-    TBool copyLocationIsPhoneMemory = 0;
-    TPtr copyLocationPtr( copyLocation->Des() );
-    TRAPD( error, iSettingsEngine->GetCopyLocationL( 
-        copyLocationPtr, copyLocationIsPhoneMemory ) )
-    
-    // Something wrong in getting copy location. Default to 
-    // phone memory.
-    if( error != KErrNone )
-        {
-        TPtrC phoneDrive( PathInfo::PhoneMemoryRootPath() );
-        copyLocation->Des().Append( phoneDrive );
-        }
-    
-    CleanupStack::Pop( copyLocation );
-    return copyLocation;
-    }
-
-// -----------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::CreateRFile
-// -----------------------------------------------------------------------------
-// 
-TInt CUPnPDownloadItemResolver::CreateRFile( const TDesC& aFilePath )
-    {
-    __LOG( "DownloadItemResolver::CreateRFile" );
-    iFile.Close();
-
-    // In some special case, the function Replace() will fail
-    // with error -14(KErrInUse) by using 'EFileWrite' mode.
-    // Maybe some other handler does not close the file. 
-    TInt err = iFile.Replace(
-                iFsSession,
-                aFilePath,
-                EFileShareReadersOrWriters );
-                
-    if( KErrPathNotFound == err )
-        {
-        __LOG( "Directory not available -> create new" );
-        iFsSession.MkDirAll( aFilePath );
-        err = iFile.Create( iFsSession, aFilePath, EFileWrite );
-        }
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadItemResolver::IsLocallySupportedL()
-// Check if the audio is DLNA supported in remote to local playback 
-// --------------------------------------------------------------------------
-//
-void CUPnPDownloadItemResolver::IsLocallySupportedL( const CUpnpElement& aRes )
-    {
-    const CUpnpAttribute* attr = 
-                       &UPnPItemUtility::FindAttributeByNameL( 
-                                              aRes, KAttributeProtocolInfo );
-    // parse protocol info
-    CUpnpDlnaProtocolInfo* pInfo = NULL;
-    pInfo = CUpnpDlnaProtocolInfo::NewL( attr->Value() );
-    
-    //if DLNA compliant item
-    if ( pInfo->PnParameter() != KNullDesC8() )
-        {
-        if( !UPnPDlnaUtility::IsSupportedDlnaProfile( 
-                                              pInfo->PnParameter() ) )
-            {
-            User::Leave(KErrNotSupported);
-            }
-        }
-    else //if not, check MIME type
-        {
-        if( !UPnPDlnaUtility::IsSupportedMimeType( pInfo->ThirdField() ) )
-            {
-            User::Leave(KErrNotSupported);
-            }
-        
-        }
-    }
-
-
-
+/*
+* Copyright (c) 2007 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:      Resolver for downloading remote items
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// System
+#include <pathinfo.h>
+#include <bautils.h>
+
+// dlnasrv / mediaserver api
+#include <upnpobject.h>
+#include <upnpitem.h>
+#include <upnpelement.h>
+#include <upnpattribute.h> // for getting resource protocol info
+#include <upnpdlnaprotocolinfo.h> // for resolving object mimetype
+
+// dlnasrv / avcontroller api
+#include "upnpavcontroller.h" // avcontrol services
+#include "upnpavdevice.h" // avcontroller device class
+#include "upnpavbrowsingsession.h" // avcontrol browsing session
+#include "upnpfiledownloadsession.h" // avcontrol download session
+
+// dlnasrv / avcontroller helper api
+#include "upnpconstantdefs.h" // for element names
+#include "upnpitemutility.h" // for FindAttributeByName
+#include "upnpresourceselector.h" // MUPnPResourceSelector
+#include "upnpitemresolverobserver.h" // observer for this class
+#include "upnpdlnautility.h"  // IsSupportedDlnaProfile
+
+// dlnasrv / internal api's
+#include "upnpcommonutils.h" // for FileExtensionByMimeTypeL
+#include "upnpsettingsengine.h" // get selected download location
+
+// dlnasrv / avcontroller helper internal
+#include "upnpremoteitemresolver.h" // remote item resolver impl.
+#include "upnpdownloaditemresolver.h" // download item resolver impl.
+
+_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+_LIT( KTempPrefix, "upnpfwtemp");
+
+// METHODS
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::NewL
+//---------------------------------------------------------------------------
+CUPnPDownloadItemResolver* CUPnPDownloadItemResolver::NewL(
+    const TDesC8& aItemId,
+    MUPnPAVController& aAvController,
+    MUPnPAVBrowsingSession& aHostSession,
+    MUPnPResourceSelector& aSelector,
+    const TDesC8& aBrowseFilter )
+    {
+    CUPnPDownloadItemResolver* self = new (ELeave) CUPnPDownloadItemResolver(
+        aItemId, aAvController, aHostSession, aSelector, aBrowseFilter );
+    CleanupStack::PushL( self );
+    self->ConstructL(
+        aItemId, aAvController, aHostSession, aSelector, aBrowseFilter );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::CUPnPDownloadItemResolver
+//---------------------------------------------------------------------------
+CUPnPDownloadItemResolver::CUPnPDownloadItemResolver(
+    const TDesC8& /*aItemId*/,
+    MUPnPAVController& aAvController,
+    MUPnPAVBrowsingSession& /*aHostSession*/,
+    MUPnPResourceSelector& aSelector,
+    const TDesC8& /*aBrowseFilter*/ )
+    : iAvController( aAvController ),
+      iState( EStateIdle ),iSelector(aSelector)
+    {
+
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::ConstructL
+//---------------------------------------------------------------------------
+void CUPnPDownloadItemResolver::ConstructL(
+    const TDesC8& aItemId,
+    MUPnPAVController& /*aAvController*/,
+    MUPnPAVBrowsingSession& aHostSession,
+    MUPnPResourceSelector& aSelector,
+    const TDesC8& aBrowseFilter )
+    {
+    iRemoteResolver = CUPnPRemoteItemResolver::NewL(
+        aItemId, aHostSession, aSelector, aBrowseFilter );
+    iRemoteDevice = CUpnpAVDevice::NewL( aHostSession.Device() );
+    iSettingsEngine = CUPnPSettingsEngine::NewL();
+    
+    // Open File Server session
+    User::LeaveIfError( iFsSession.Connect() );
+    User::LeaveIfError( iFsSession.ShareProtected() );   
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::~CUPnPDownloadItemResolver
+//---------------------------------------------------------------------------
+CUPnPDownloadItemResolver::~CUPnPDownloadItemResolver()
+    {        
+    Cleanup();
+    delete iRemoteResolver;
+    iRemoteResolver = 0;
+    delete iRemoteDevice;
+    iRemoteDevice= 0;
+    delete iSettingsEngine;
+    iSettingsEngine = 0;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::ResolveL
+//---------------------------------------------------------------------------
+void CUPnPDownloadItemResolver::ResolveL(
+    MUPnPItemResolverObserver& aObserver, CUpnpAVDevice* /*aDevice*/ )
+    {
+    __LOG( "DownloadItemResolver:Resolve()" );
+    __ASSERTD( iState == EStateIdle, __FILE__, __LINE__ );
+
+    // change state
+    iObserver = &aObserver;
+
+    // first resolve the item
+    iRemoteResolver->ResolveL( *this );
+    iState = EStateResolving;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::ResolveComplete
+//---------------------------------------------------------------------------
+void CUPnPDownloadItemResolver::ResolveComplete(
+    const MUPnPItemResolver& /*aResolver*/, TInt aError )
+    {
+    __LOG1( "DownloadItemResolver:ResolveComplete(%d)", aError );
+    __ASSERTD( iState == EStateResolving, __FILE__, __LINE__ );
+
+    if ( aError == KErrNone )
+        {
+        TRAP( aError, 
+                const CUpnpElement& res =
+                        iSelector.SelectResourceL( iRemoteResolver->Item() );
+                IsLocallySupportedL( res );
+                );
+        if( aError )
+            {
+            Complete( aError );
+            }
+        else
+            {
+            TRAPD( err, InitiateDownloadL() );
+            if ( err != KErrNone )
+                {
+                Complete( err );
+                }
+            }
+        }
+    else
+        {
+        Complete( aError );
+        }
+
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::InitiateDownloadL
+//---------------------------------------------------------------------------
+void CUPnPDownloadItemResolver::InitiateDownloadL()
+    {
+    __LOG( "CUPnPDownloadItemResolver::InitiateDownloadL");
+    // start a download session if not already started
+    if( !iDownloadSession )
+        {
+        iDownloadSession =
+            &iAvController.StartDownloadSessionL( *iRemoteDevice );
+        }
+    iDownloadSession->SetObserver( *this );
+
+    // Get selected download location.
+    HBufC* copyLocation = GetSelectedDownloadLocationL();
+    CleanupStack::PushL( copyLocation );
+    _LIT(KTempFolder, "temp\\");
+    // Create temp file name
+    HBufC* tempFileName = CreateTmpFileNameL();
+    CleanupStack::PushL( tempFileName );
+
+    // Create and save full file path.
+    if( iLocalFile )
+        {
+        // delete if already allocated.
+        delete iLocalFile;
+        iLocalFile = 0;
+        }
+    
+    iLocalFile = HBufC::NewL( copyLocation->Length() +
+                              KTempFolder().Length() );
+    iLocalFile->Des().Append( *copyLocation );
+    iLocalFile->Des().Append( KTempFolder );
+    //check the existence of the target folder
+    if( !BaflUtils::FolderExists( iFsSession, *iLocalFile ) )
+        {
+        User::LeaveIfError( iFsSession.MkDirAll( *iLocalFile ) );
+        }
+        
+    User::LeaveIfError( iFsSession.SetAtt( *iLocalFile, 
+                                    KEntryAttHidden, 
+                                    KEntryAttNormal ) );
+                                        
+    iLocalFile = iLocalFile->ReAllocL( 
+        iLocalFile->Length() + tempFileName->Length() );
+    
+    iLocalFile->Des().Append( *tempFileName );
+
+    // write the file path into the item
+    CUpnpElement& writableRes =
+        const_cast<CUpnpElement&>( iRemoteResolver->Resource() );
+    writableRes.SetFilePathL( *iLocalFile );
+    CleanupStack::PopAndDestroy( tempFileName );
+    CleanupStack::PopAndDestroy( copyLocation );
+    
+    // Create local target file for dowload item
+    TInt err = CreateRFile( *iLocalFile );
+
+    if( err == KErrNone )
+        {
+        __LOG( "StartDownloading...");
+        // initiate download
+        
+        iDownloadSession->StartDownloadL( writableRes, 
+                                      iRemoteResolver->Item(), 
+                                      iFile,
+                                      (TInt)this );
+                                      
+        iState = EStateDownloading;
+        }
+    else // Create download target failed!
+        {
+        __LOG( "Create download target failed!");
+        User::Leave( err );
+        }
+    __LOG( "CUPnPDownloadItemResolver::InitiateDownloadL -End");
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::TransferStarted
+//---------------------------------------------------------------------------
+void CUPnPDownloadItemResolver::TransferStarted( TInt /*aKey*/,
+    TInt /*aStatus*/ )
+    {
+    __LOG( "DownloadItemResolver:TransferStarted");
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::TransferCompleted
+//---------------------------------------------------------------------------
+void CUPnPDownloadItemResolver::TransferCompleted( TInt /*aKey*/,
+    TInt aStatus, const TDesC& /*aFilePath*/ )
+    {
+    __LOG1( "DownloadItemResolver:TransferCompleted(%d)", aStatus );
+    iFile.Close();
+    Complete( aStatus );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::TransferProgress
+//---------------------------------------------------------------------------
+void CUPnPDownloadItemResolver::TransferProgress( TInt /*aKey*/,
+    TInt /*aBytes*/, TInt /*aTotalBytes*/ )
+    {
+    __LOG( "DownloadItemResolver:TransferProgress");
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::MediaServerDisappeared
+//---------------------------------------------------------------------------
+void CUPnPDownloadItemResolver::MediaServerDisappeared(
+    TUPnPDeviceDisconnectedReason /*aReason*/ )
+    {
+    __LOG( "DownloadItemResolver:MediaServerDisappeared" );
+    Complete( KErrDisconnected );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::Item
+//---------------------------------------------------------------------------
+const CUpnpItem& CUPnPDownloadItemResolver::Item() const
+    {
+    __ASSERTD( iState == EStateReady, __FILE__, __LINE__ );
+
+    return iRemoteResolver->Item();
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::Resource
+//---------------------------------------------------------------------------
+const CUpnpElement& CUPnPDownloadItemResolver::Resource() const
+    {
+    __ASSERTD( iState == EStateReady, __FILE__, __LINE__ );
+
+    return iRemoteResolver->Resource();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::DeleteTempFilesL
+// --------------------------------------------------------------------------
+EXPORT_C void CUPnPDownloadItemResolver::DeleteTempDownloadFilesL()
+    {
+    __LOG("CUPnPDownloadItemResolver::DeleteTempDownloadFilesL begin");
+
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+
+    CFileMan* fileMan = CFileMan::NewL( fs );
+    CleanupStack::PushL( fileMan );
+    _LIT( KAnyChar, "*");
+    _LIT( KAnyExtension, "*.*");
+    _LIT( KUpnpUploadTempDirectory, "temp\\" );
+
+    // clean selected download directory
+    HBufC* path = HBufC::NewLC( KMaxFileName );
+    CUPnPSettingsEngine* settingsEngine = CUPnPSettingsEngine::NewL();
+    CleanupStack::PushL( settingsEngine );
+    HBufC* copyLocation = HBufC::NewL( KMaxFileName );
+    CleanupStack::PushL( copyLocation );
+    TBool copyLocationIsPhoneMemory = 0; // not used in this case
+    TPtr copyLocationPtr( copyLocation->Des() );
+    settingsEngine->GetCopyLocationL( copyLocationPtr,
+        copyLocationIsPhoneMemory );
+    path->Des().Append( *copyLocation );
+    path->Des().Append( KAnyChar );
+    path->Des().Append( KTempPrefix );
+    path->Des().Append( KAnyExtension );
+    fileMan->Delete( *path );
+    
+    path->Des().Zero();
+    path->Des().Append( *copyLocation );
+    path->Des().Append( KUpnpUploadTempDirectory );
+    path->Des().Append( KAnyExtension );
+    fileMan->Delete( *path );
+
+    CleanupStack::PopAndDestroy( copyLocation );
+    CleanupStack::PopAndDestroy( settingsEngine );
+    CleanupStack::PopAndDestroy( path );
+
+    CleanupStack::PopAndDestroy( fileMan );
+    CleanupStack::PopAndDestroy( &fs );
+
+    __LOG("CUPnPDownloadItemResolver::DeleteTempDownloadFilesL End");
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::Complete
+//---------------------------------------------------------------------------
+void CUPnPDownloadItemResolver::Complete( TInt aError )
+    {
+    __ASSERTD( iState == EStateResolving || iState == EStateDownloading,
+        __FILE__, __LINE__ );
+
+    if ( iDownloadSession != 0 )
+        {
+        iAvController.StopDownloadSession( *iDownloadSession );
+        iDownloadSession = 0;
+        }
+
+    MUPnPItemResolverObserver& observer = *iObserver;
+    iObserver = 0;
+    if ( aError == KErrNone )
+        {
+        iState = EStateReady;
+        }
+    else
+        {
+        iState = EStateIdle;
+        Cleanup();
+        }
+
+    observer.ResolveComplete( *this, aError );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::Cleanup
+//---------------------------------------------------------------------------
+void CUPnPDownloadItemResolver::Cleanup()
+    {
+    iObserver = 0;
+    iFile.Close();
+    
+    if ( iDownloadSession != 0 )
+        {
+        iAvController.StopDownloadSession( *iDownloadSession );
+        iDownloadSession = 0;
+        }
+        
+    if ( iLocalFile )
+        {
+        // delete the local file
+        iFsSession.Delete( iLocalFile->Des() );       
+        __LOG1( "DownloadItemResolver: deleted local file(%d)", iLocalFile );
+        delete iLocalFile;
+        iLocalFile = 0;
+        }
+        
+    iFsSession.Close();
+
+    iState = EStateIdle;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::CreateTmpFileNameL
+//---------------------------------------------------------------------------
+HBufC* CUPnPDownloadItemResolver::CreateTmpFileNameL()
+    {
+    __LOG( "DownloadItemResolver::CreateTmpFileName" );
+    __ASSERTD( iState == EStateResolving, __FILE__, __LINE__ );
+
+    HBufC* tempfilename = NULL;
+    HBufC* fileExt = NULL;
+    
+    // Get file extension
+    const CUpnpAttribute* attr = UPnPItemUtility
+        ::FindAttributeByName( iRemoteResolver->Resource(), 
+        KAttributeProtocolInfo );
+    if ( attr != 0 )
+        {
+        CUpnpDlnaProtocolInfo* pInfo =
+            CUpnpDlnaProtocolInfo::NewL( attr->Value() );
+        CleanupStack::PushL( pInfo );
+        fileExt = UPnPCommonUtils::FileExtensionByMimeTypeL(
+            pInfo->ThirdField() );
+        CleanupStack::PopAndDestroy( pInfo );
+        pInfo = NULL;
+        }
+
+    // If file extension exist create whole file name.
+    if( fileExt )
+        {
+        CleanupStack::PushL( fileExt );
+        tempfilename = HBufC::NewL( 
+            KTempPrefix().Length() + 
+            iRemoteResolver->Item().Id().Length() + 
+            fileExt->Length() );
+        CleanupStack::PushL( tempfilename );
+        // Add prefix
+        tempfilename->Des().Append( KTempPrefix ); 
+        // Add item name. Convert 8 to 16 and replace illeagal characters.
+        HBufC8* tmpItemName8 = 
+            UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
+            iRemoteResolver->Item().Id() );
+        CleanupStack::PushL( tmpItemName8 );
+        HBufC* itemname = HBufC::NewL( tmpItemName8->Length() );
+        CleanupStack::PushL( itemname );
+        itemname->Des().Copy( *tmpItemName8 );
+        tempfilename->Des().Append( *itemname );
+        CleanupStack::PopAndDestroy( itemname );
+        CleanupStack::PopAndDestroy( tmpItemName8 );
+        // Add file extension
+        tempfilename->Des().Append( *fileExt );
+
+        CleanupStack::Pop( tempfilename );
+        CleanupStack::PopAndDestroy( fileExt );
+        }
+    else // Create without file extension
+        {
+        tempfilename = HBufC::NewL( 
+            KTempPrefix().Length() + iRemoteResolver->Item().Id().Length() );
+        CleanupStack::PushL( tempfilename );
+        // Add prefix
+        tempfilename->Des().Append( KTempPrefix ); 
+        // Add item name. Convert 8 to 16 and replace illeagal characters.
+        HBufC8* tmpItemName8 = 
+            UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
+            iRemoteResolver->Item().Id() );
+        CleanupStack::PushL( tmpItemName8 );
+        HBufC* itemname = HBufC::NewL( tmpItemName8->Length() );
+        CleanupStack::PushL( itemname );
+        itemname->Des().Copy( *tmpItemName8 );
+        tempfilename->Des().Append( *itemname );
+        CleanupStack::PopAndDestroy( itemname );
+        CleanupStack::PopAndDestroy( tmpItemName8 );
+
+        CleanupStack::Pop( tempfilename );
+        }
+
+    return tempfilename; //transfer ownership
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::GetSelectedDownloadLocationL
+//---------------------------------------------------------------------------
+HBufC* CUPnPDownloadItemResolver::GetSelectedDownloadLocationL()
+    {
+    __LOG( "DownloadItemResolver::GetSelectedDownloadLocationL" );
+
+    HBufC* copyLocation = HBufC::NewL( KMaxFileName );
+    CleanupStack::PushL( copyLocation );
+    TBool copyLocationIsPhoneMemory = 0;
+    TPtr copyLocationPtr( copyLocation->Des() );
+    TRAPD( error, iSettingsEngine->GetCopyLocationL( 
+        copyLocationPtr, copyLocationIsPhoneMemory ) )
+    
+    // Something wrong in getting copy location. Default to 
+    // phone memory.
+    if( error != KErrNone )
+        {
+        TPtrC phoneDrive( PathInfo::PhoneMemoryRootPath() );
+        copyLocation->Des().Append( phoneDrive );
+        }
+    
+    CleanupStack::Pop( copyLocation );
+    return copyLocation;
+    }
+
+// -----------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::CreateRFile
+// -----------------------------------------------------------------------------
+// 
+TInt CUPnPDownloadItemResolver::CreateRFile( const TDesC& aFilePath )
+    {
+    __LOG( "DownloadItemResolver::CreateRFile" );
+    iFile.Close();
+
+    // In some special case, the function Replace() will fail
+    // with error -14(KErrInUse) by using 'EFileWrite' mode.
+    // Maybe some other handler does not close the file. 
+    TInt err = iFile.Replace(
+                iFsSession,
+                aFilePath,
+                EFileShareReadersOrWriters );
+                
+    if( KErrPathNotFound == err )
+        {
+        __LOG( "Directory not available -> create new" );
+        iFsSession.MkDirAll( aFilePath );
+        err = iFile.Create( iFsSession, aFilePath, EFileWrite );
+        }
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadItemResolver::IsLocallySupportedL()
+// Check if the audio is DLNA supported in remote to local playback 
+// --------------------------------------------------------------------------
+//
+void CUPnPDownloadItemResolver::IsLocallySupportedL( const CUpnpElement& aRes )
+    {
+    const CUpnpAttribute* attr = 
+                       &UPnPItemUtility::FindAttributeByNameL( 
+                                              aRes, KAttributeProtocolInfo );
+    // parse protocol info
+    CUpnpDlnaProtocolInfo* pInfo = NULL;
+    pInfo = CUpnpDlnaProtocolInfo::NewL( attr->Value() );
+    CleanupStack::PushL(pInfo);
+    
+    //if DLNA compliant item
+    if ( pInfo->PnParameter() != KNullDesC8() )
+        {
+        if( !UPnPDlnaUtility::IsSupportedDlnaProfile( 
+                                              pInfo->PnParameter() ) )
+            {
+            User::Leave(KErrNotSupported);
+            }
+        }
+    else //if not, check MIME type
+        {
+        if( !UPnPDlnaUtility::IsSupportedMimeType( pInfo->ThirdField() ) )
+            {
+            User::Leave(KErrNotSupported);
+            }
+        
+        }
+		
+    CleanupStack::PopAndDestroy(pInfo);
+    }
+
+
+
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnpfileutility.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnpfileutility.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,186 +1,187 @@
-/*
-* Copyright (c) 2007 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:      Utility for working with files in upnp context
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <e32std.h>
-#include <upnpelement.h>
-#include <DRMCommon.h>              // OEM-DRM
-#include <caf/content.h>                // CAF (WM-DRM check)
-#include <caf/agent.h>                  // CAF (WM-DRM check)
-#include <pathinfo.h>               // PathInfo
-
-// upnpframework / avcontroller helper api
-#include "upnpitemutility.h"        // FindAttributeByName
-#include "upnpconstantdefs.h"       // KAttributeSize
-#include "upnpfileutility.h"
-
-// upnpframework / internal api's
-#include "upnpsettingsengine.h"     // get target drive
-
-_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-_LIT( KWmDrmAgentName,     "PV WMA CAF Agent" );
-_LIT( K60WmDrmAgentName,   "WM DRM Agent" );
-const TInt64 KPhoneMemoryThreshold    = 1048576; //1MB
-
-
-// ============================ LOCAL FUNCTIONS =============================
-
-// --------------------------------------------------------------------------
-// UPnPFileUtility::IsFileDrmProtectedL
-//---------------------------------------------------------------------------
-EXPORT_C TBool UPnPFileUtility::IsFileProtectedL(
-    const TDesC& aFilePath )
-    {
-    __LOG( "FileUtility:IsFileDrmProtectedL( aFileName )" );
-    TBool isProtected = ETrue;
-
-    // Check if the file is OEM-DRM protected
-    DRMCommon* drmCommon = DRMCommon::NewL();
-    CleanupStack::PushL( drmCommon );
-    User::LeaveIfError( drmCommon->Connect() );
-    User::LeaveIfError( drmCommon->IsProtectedFile(
-        aFilePath, isProtected ) );
-    CleanupStack::PopAndDestroy( drmCommon );
-    drmCommon = NULL;
-
-    // If not OEM-DRM protected, check if the file is WM-DRM protected
-    if( !isProtected )
-        {
-        CContent* content = CContent::NewLC( aFilePath );
-        TAgent agent = content->Agent();
-
-        // Check if .wma file
-        if( agent.Name().CompareF( KWmDrmAgentName ) == 0 ||
-            agent.Name().CompareF( K60WmDrmAgentName ) == 0 )
-            {
-            __LOG( "FileUtility:IsFileDrmProtectedL: .wma file " );
-            CData* data = CData::NewL( (TVirtualPathPtr) aFilePath,
-                EPeek, EContentShareReadOnly );
-            data->GetAttribute( EIsProtected, isProtected );
-            delete data;
-            }
-        CleanupStack::PopAndDestroy( content );
-        content = NULL;
-        }
-    return isProtected;
-    }
-
-
-// --------------------------------------------------------------------------
-// UPnPFileUtility::FitsInMemory
-// see UPnPFileUtility.h
-// --------------------------------------------------------------------------
-EXPORT_C TBool UPnPFileUtility::FitsInMemory(
-    const CUpnpElement& aResource )
-    {
-    TBool result( ETrue );
-    
-    //it will always return ETrue if Leave
-    TRAP_IGNORE( result = FitsInMemoryL( aResource ) );
-    return result;
-    }
-
-
-// --------------------------------------------------------------------------
-// UPnPFileUtility::FitsInMemory
-// see UPnPFileUtility.h
-// --------------------------------------------------------------------------
-TBool UPnPFileUtility::FitsInMemoryL( const CUpnpElement& aResource )
-    {
-    __LOG( "UPnPFileUtility::FitsInMemoryL" );
-    // 1. get object size
-    TInt fileSize = -1;
-    const CUpnpAttribute* attr =
-        UPnPItemUtility::FindAttributeByName( aResource, KAttributeSize );
-
-    //if "file size" not found, straightly go for downloading
-    if( !attr )   
-        {
-        __LOG( "UPnPFileUtility::size not found" );
-        return ETrue;
-        }
-
-    // 2. convert size to integer
-    TLex8 sizeconvert( attr->Value() );
-    sizeconvert.Val( fileSize );
-
-    if( fileSize < 0)
-        {
-        __LOG1( "UPnPFileUtility::file size %d", fileSize );
-        return ETrue;
-        }
-           
-    // 3. check the copy target configuration
-    CUPnPSettingsEngine* engine = NULL;
-    engine = CUPnPSettingsEngine::NewL();
-    CleanupStack::PushL( engine );
-    
-    HBufC* location = HBufC::NewLC( KMaxFileName );
-    TPtr locationPtr( location->Des() );
-    TBool isPhoneMemory;
-    
-    engine->GetCopyLocationL( locationPtr, isPhoneMemory );
-        
-    // 4. check bytes available in the drive
-    RFs fileServer;
-    CleanupClosePushL( fileServer );
-    User::LeaveIfError( fileServer.Connect() );
-
-    TVolumeInfo freeVol;
-
-    User::LeaveIfError( fileServer.SetSessionPath( locationPtr ) );
-    User::LeaveIfError( fileServer.Volume( freeVol ) );
-
-    CleanupStack::PopAndDestroy(); // close fileServer;
-    CleanupStack::PopAndDestroy(); // delete location
-    CleanupStack::PopAndDestroy( engine ); // not needed anymore
-
-    __LOG1( "UPnPFileUtility::free space: %d", freeVol.iFree );
-
-    TInt64 freeSize = 0;
-
-    // 5. result
-    // With phone memory a threshold is used. 
-    if( isPhoneMemory )
-        {
-        freeSize = freeVol.iFree - KPhoneMemoryThreshold;
-        }
-    else
-        {
-        freeSize = freeVol.iFree;
-        }
-
-    if( freeSize >= fileSize )
-        {
-        __LOG( "UPnPFileUtility::FitsInMemoryL -TRUE" );
-        return ETrue;
-        }
-    else
-        {
-        __LOG( "UPnPFileUtility::FitsInMemoryL -FALSE" );
-        return EFalse;
-        }
-    }
+/*
+* Copyright (c) 2007 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:      Utility for working with files in upnp context
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// System
+#include <e32std.h>
+#include <upnpelement.h>
+#include <caf/content.h>                // CAF (WM-DRM check)
+#include <caf/agent.h>                  // CAF (WM-DRM check)
+#include <caf/rightsinfo.h>
+#include <DRMCommon.h>         // OEM-DRM
+#include <pathinfo.h>               // PathInfo
+
+// dlnasrv / avcontroller helper api
+#include "upnpitemutility.h"        // FindAttributeByName
+#include "upnpconstantdefs.h"       // KAttributeSize
+#include "upnpfileutility.h"
+
+// dlnasrv / internal api's
+#include "upnpsettingsengine.h"     // get target drive
+
+_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+_LIT( KWmDrmAgentName,     "PV WMA CAF Agent" );
+_LIT( K60WmDrmAgentName,   "WM DRM Agent" );
+const TInt64 KPhoneMemoryThreshold    = 1048576; //1MB
+
+
+// ============================ LOCAL FUNCTIONS =============================
+
+// --------------------------------------------------------------------------
+// UPnPFileUtility::IsFileDrmProtectedL
+//---------------------------------------------------------------------------
+EXPORT_C TBool UPnPFileUtility::IsFileProtectedL(
+    const TDesC& aFilePath )
+    {
+    __LOG( "FileUtility:IsFileDrmProtectedL( aFileName )" );
+    TBool isProtected = ETrue;
+
+    // Check if the file is OEM-DRM protected
+    DRMCommon* drmCommon = DRMCommon::NewL();
+    CleanupStack::PushL( drmCommon );
+    User::LeaveIfError( drmCommon->Connect() );
+    User::LeaveIfError( drmCommon->IsProtectedFile(
+        aFilePath, isProtected ) );
+    CleanupStack::PopAndDestroy( drmCommon );
+    drmCommon = NULL;
+
+    // If not OEM-DRM protected, check if the file is WM-DRM protected
+    if( !isProtected )
+        {
+        CContent* content = CContent::NewLC( aFilePath );
+        TAgent agent = content->Agent();
+
+        // Check if .wma file
+        if( agent.Name().CompareF( KWmDrmAgentName ) == 0 ||
+            agent.Name().CompareF( K60WmDrmAgentName ) == 0 )
+            {
+            __LOG( "FileUtility:IsFileDrmProtectedL: .wma file " );
+            CData* data = CData::NewL( (TVirtualPathPtr) aFilePath,
+                EPeek, EContentShareReadOnly );
+            data->GetAttribute( EIsProtected, isProtected );
+            delete data;
+            }
+        CleanupStack::PopAndDestroy( content );
+        content = NULL;
+        }
+    return isProtected;
+    }
+
+
+// --------------------------------------------------------------------------
+// UPnPFileUtility::FitsInMemory
+// see UPnPFileUtility.h
+// --------------------------------------------------------------------------
+EXPORT_C TBool UPnPFileUtility::FitsInMemory(
+    const CUpnpElement& aResource )
+    {
+    TBool result( ETrue );
+    
+    //it will always return ETrue if Leave
+    TRAP_IGNORE( result = FitsInMemoryL( aResource ) );
+    return result;
+    }
+
+
+// --------------------------------------------------------------------------
+// UPnPFileUtility::FitsInMemory
+// see UPnPFileUtility.h
+// --------------------------------------------------------------------------
+TBool UPnPFileUtility::FitsInMemoryL( const CUpnpElement& aResource )
+    {
+    __LOG( "UPnPFileUtility::FitsInMemoryL" );
+    // 1. get object size
+    TInt fileSize = -1;
+    const CUpnpAttribute* attr =
+        UPnPItemUtility::FindAttributeByName( aResource, KAttributeSize );
+
+    //if "file size" not found, straightly go for downloading
+    if( !attr )   
+        {
+        __LOG( "UPnPFileUtility::size not found" );
+        return ETrue;
+        }
+
+    // 2. convert size to integer
+    TLex8 sizeconvert( attr->Value() );
+    sizeconvert.Val( fileSize );
+
+    if( fileSize < 0)
+        {
+        __LOG1( "UPnPFileUtility::file size %d", fileSize );
+        return ETrue;
+        }
+           
+    // 3. check the copy target configuration
+    CUPnPSettingsEngine* engine = NULL;
+    engine = CUPnPSettingsEngine::NewL();
+    CleanupStack::PushL( engine );
+    
+    HBufC* location = HBufC::NewLC( KMaxFileName );
+    TPtr locationPtr( location->Des() );
+    TBool isPhoneMemory;
+    
+    engine->GetCopyLocationL( locationPtr, isPhoneMemory );
+        
+    // 4. check bytes available in the drive
+    RFs fileServer;
+    CleanupClosePushL( fileServer );
+    User::LeaveIfError( fileServer.Connect() );
+
+    TVolumeInfo freeVol;
+
+    User::LeaveIfError( fileServer.SetSessionPath( locationPtr ) );
+    User::LeaveIfError( fileServer.Volume( freeVol ) );
+
+    CleanupStack::PopAndDestroy(); // close fileServer;
+    CleanupStack::PopAndDestroy(); // delete location
+    CleanupStack::PopAndDestroy( engine ); // not needed anymore
+
+    __LOG1( "UPnPFileUtility::free space: %d", freeVol.iFree );
+
+    TInt64 freeSize = 0;
+
+    // 5. result
+    // With phone memory a threshold is used. 
+    if( isPhoneMemory )
+        {
+        freeSize = freeVol.iFree - KPhoneMemoryThreshold;
+        }
+    else
+        {
+        freeSize = freeVol.iFree;
+        }
+
+    if( freeSize >= fileSize )
+        {
+        __LOG( "UPnPFileUtility::FitsInMemoryL -TRUE" );
+        return ETrue;
+        }
+    else
+        {
+        __LOG( "UPnPFileUtility::FitsInMemoryL -FALSE" );
+        return EFalse;
+        }
+    }
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnpinternalfileutility.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnpinternalfileutility.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,161 +1,162 @@
-/*
-* Copyright (c) 2007 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:      Utility for working with files in upnp context 
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <e32std.h>
-#include <upnpelement.h>
-#include <DRMCommon.h>              // OEM-DRM
-#include <caf/content.h>                // CAF (WM-DRM check)
-#include <caf/agent.h>                  // CAF (WM-DRM check)
-#include <pathinfo.h>               // PathInfo
-#include <upnpitem.h>
-#include <upnpattribute.h>          // for getting resource protocol info
-#include <upnpdlnaprotocolinfo.h>   // for resolving object mimetypE
-
-// upnpframework / avcontroller helper api
-#include "upnpitemutility.h"        // FindAttributeByName
-#include "upnpconstantdefs.h"       // KAttributeSize
-#include "upnpinternalfileutility.h"
-
-// upnpframework / internal api's
-#include "upnpsettingsengine.h"     // get target drive
-#include "upnpcommonutils.h"        // for FileExtensionByMimeTypeL
-
-_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-//_LIT( KWmDrmAgentName,     "PV WMA CAF Agent" );
-//_LIT( K60WmDrmAgentName,   "WM DRM Agent" );
-//const TInt64 KPhoneMemoryThreshold    = 1048576; //1MB
-_LIT( KTempPrefix, "upnpfwtemp");
-
-
-// --------------------------------------------------------------------------
-// UPnPFileUtility::GetSelectedDownloadLocationL
-//---------------------------------------------------------------------------
-EXPORT_C HBufC* UPnPInternalFileUtility::GetSelectedDownloadLocationL()
-    {
-    __LOG( "UPnPFileUtility::GetSelectedDownloadLocationL" );
-
-    HBufC* copyLocation = HBufC::NewL( KMaxFileName );
-    CleanupStack::PushL( copyLocation );
-    TBool copyLocationIsPhoneMemory = 0;
-    TPtr copyLocationPtr( copyLocation->Des() );
-    
-    CUPnPSettingsEngine* settingsEngine = CUPnPSettingsEngine::NewL();
-    CleanupStack::PushL( settingsEngine );
-    TRAPD( error, settingsEngine->GetCopyLocationL( 
-        copyLocationPtr, copyLocationIsPhoneMemory ) )
-    
-    // Something wrong in getting copy location. Default to 
-    // phone memory.
-    if( error != KErrNone )
-        {
-        TPtrC phoneDrive( PathInfo::PhoneMemoryRootPath() );
-        copyLocation->Des().Append( phoneDrive );
-        }
-    CleanupStack::PopAndDestroy( settingsEngine );
-    CleanupStack::Pop( copyLocation );
-    return copyLocation; // transfer ownership
-    }
-
-
-// --------------------------------------------------------------------------
-// UPnPFileUtility::CreateTmpFileNameL
-//---------------------------------------------------------------------------
-EXPORT_C HBufC* UPnPInternalFileUtility::CreateTmpFileNameL( const CUpnpItem& aItem )
-    {
-    __LOG( "UPnPFileUtility::CreateTmpFileName" );
-
-    HBufC* tempfilename = NULL;
-    HBufC* fileExt = NULL;
-    
-    // Get file extension        
-    const CUpnpElement& res =
-        UPnPItemUtility::ResourceFromItemL( aItem );        
-    const CUpnpAttribute* attr = UPnPItemUtility
-        ::FindAttributeByName( res, KAttributeProtocolInfo );
-        if ( attr != 0 )
-        {
-        CUpnpDlnaProtocolInfo* pInfo =
-            CUpnpDlnaProtocolInfo::NewL( attr->Value() );
-        CleanupStack::PushL( pInfo );
-        fileExt = UPnPCommonUtils::FileExtensionByMimeTypeL(
-            pInfo->ThirdField() );
-        CleanupStack::PopAndDestroy( pInfo );
-        pInfo = NULL;
-        }
-
-    // If file extension exist create whole file name.
-    if( fileExt )
-        {
-        CleanupStack::PushL( fileExt );
-        tempfilename = HBufC::NewL( 
-            KTempPrefix().Length() + 
-            aItem.Id().Length() + 
-            fileExt->Length() );
-        CleanupStack::PushL( tempfilename );
-        // Add prefix
-        tempfilename->Des().Append( KTempPrefix ); 
-        // Add item name. Convert 8 to 16 and replace illeagal characters.
-        HBufC8* tmpItemName8 = 
-            UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
-            aItem.Id() );
-        CleanupStack::PushL( tmpItemName8 );
-        HBufC* itemname = HBufC::NewL( tmpItemName8->Length() );
-        CleanupStack::PushL( itemname );
-        itemname->Des().Copy( *tmpItemName8 );
-        tempfilename->Des().Append( *itemname );
-        CleanupStack::PopAndDestroy( itemname );
-        CleanupStack::PopAndDestroy( tmpItemName8 );
-        // Add file extension
-        tempfilename->Des().Append( *fileExt );
-
-        CleanupStack::Pop( tempfilename );
-        CleanupStack::PopAndDestroy( fileExt );
-        }
-    else // Create without file extension
-        {
-        tempfilename = HBufC::NewL( 
-            KTempPrefix().Length() + aItem.Id().Length() );
-        CleanupStack::PushL( tempfilename );
-        // Add prefix
-        tempfilename->Des().Append( KTempPrefix ); 
-        // Add item name. Convert 8 to 16 and replace illeagal characters.
-        HBufC8* tmpItemName8 = 
-            UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
-            aItem.Id() );
-        CleanupStack::PushL( tmpItemName8 );
-        HBufC* itemname = HBufC::NewL( tmpItemName8->Length() );
-        CleanupStack::PushL( itemname );
-        itemname->Des().Copy( *tmpItemName8 );
-        tempfilename->Des().Append( *itemname );
-        CleanupStack::PopAndDestroy( itemname );
-        CleanupStack::PopAndDestroy( tmpItemName8 );
-
-        CleanupStack::Pop( tempfilename );
-        }
-
-    return tempfilename; //transfer ownership
-    }
+/*
+* Copyright (c) 2007 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:      Utility for working with files in upnp context 
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// System
+#include <e32std.h>
+#include <upnpelement.h>
+#include <caf/content.h>                // CAF (WM-DRM check)
+#include <caf/agent.h>                  // CAF (WM-DRM check)
+#include <caf/rightsinfo.h>
+#include <DRMCommon.h>              // OEM-DRM
+#include <pathinfo.h>               // PathInfo
+#include <upnpitem.h>
+#include <upnpattribute.h>          // for getting resource protocol info
+#include <upnpdlnaprotocolinfo.h>   // for resolving object mimetypE
+
+// dlnasrv / avcontroller helper api
+#include "upnpitemutility.h"        // FindAttributeByName
+#include "upnpconstantdefs.h"       // KAttributeSize
+
+// dlnasrv / internal api's
+#include "upnpinternalfileutility.h"
+#include "upnpsettingsengine.h"     // get target drive
+#include "upnpcommonutils.h"        // for FileExtensionByMimeTypeL
+
+_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+//_LIT( KWmDrmAgentName,     "PV WMA CAF Agent" );
+//_LIT( K60WmDrmAgentName,   "WM DRM Agent" );
+//const TInt64 KPhoneMemoryThreshold    = 1048576; //1MB
+_LIT( KTempPrefix, "upnpfwtemp");
+
+
+// --------------------------------------------------------------------------
+// UPnPFileUtility::GetSelectedDownloadLocationL
+//---------------------------------------------------------------------------
+EXPORT_C HBufC* UPnPInternalFileUtility::GetSelectedDownloadLocationL()
+    {
+    __LOG( "UPnPFileUtility::GetSelectedDownloadLocationL" );
+
+    HBufC* copyLocation = HBufC::NewL( KMaxFileName );
+    CleanupStack::PushL( copyLocation );
+    TBool copyLocationIsPhoneMemory = 0;
+    TPtr copyLocationPtr( copyLocation->Des() );
+    
+    CUPnPSettingsEngine* settingsEngine = CUPnPSettingsEngine::NewL();
+    CleanupStack::PushL( settingsEngine );
+    TRAPD( error, settingsEngine->GetCopyLocationL( 
+        copyLocationPtr, copyLocationIsPhoneMemory ) )
+    
+    // Something wrong in getting copy location. Default to 
+    // phone memory.
+    if( error != KErrNone )
+        {
+        TPtrC phoneDrive( PathInfo::PhoneMemoryRootPath() );
+        copyLocation->Des().Append( phoneDrive );
+        }
+    CleanupStack::PopAndDestroy( settingsEngine );
+    CleanupStack::Pop( copyLocation );
+    return copyLocation; // transfer ownership
+    }
+
+
+// --------------------------------------------------------------------------
+// UPnPFileUtility::CreateTmpFileNameL
+//---------------------------------------------------------------------------
+EXPORT_C HBufC* UPnPInternalFileUtility::CreateTmpFileNameL( const CUpnpItem& aItem )
+    {
+    __LOG( "UPnPFileUtility::CreateTmpFileName" );
+
+    HBufC* tempfilename = NULL;
+    HBufC* fileExt = NULL;
+    
+    // Get file extension        
+    const CUpnpElement& res =
+        UPnPItemUtility::ResourceFromItemL( aItem );        
+    const CUpnpAttribute* attr = UPnPItemUtility
+        ::FindAttributeByName( res, KAttributeProtocolInfo );
+        if ( attr != 0 )
+        {
+        CUpnpDlnaProtocolInfo* pInfo =
+            CUpnpDlnaProtocolInfo::NewL( attr->Value() );
+        CleanupStack::PushL( pInfo );
+        fileExt = UPnPCommonUtils::FileExtensionByMimeTypeL(
+            pInfo->ThirdField() );
+        CleanupStack::PopAndDestroy( pInfo );
+        pInfo = NULL;
+        }
+
+    // If file extension exist create whole file name.
+    if( fileExt )
+        {
+        CleanupStack::PushL( fileExt );
+        tempfilename = HBufC::NewL( 
+            KTempPrefix().Length() + 
+            aItem.Id().Length() + 
+            fileExt->Length() );
+        CleanupStack::PushL( tempfilename );
+        // Add prefix
+        tempfilename->Des().Append( KTempPrefix ); 
+        // Add item name. Convert 8 to 16 and replace illeagal characters.
+        HBufC8* tmpItemName8 = 
+            UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
+            aItem.Id() );
+        CleanupStack::PushL( tmpItemName8 );
+        HBufC* itemname = HBufC::NewL( tmpItemName8->Length() );
+        CleanupStack::PushL( itemname );
+        itemname->Des().Copy( *tmpItemName8 );
+        tempfilename->Des().Append( *itemname );
+        CleanupStack::PopAndDestroy( itemname );
+        CleanupStack::PopAndDestroy( tmpItemName8 );
+        // Add file extension
+        tempfilename->Des().Append( *fileExt );
+
+        CleanupStack::Pop( tempfilename );
+        CleanupStack::PopAndDestroy( fileExt );
+        }
+    else // Create without file extension
+        {
+        tempfilename = HBufC::NewL( 
+            KTempPrefix().Length() + aItem.Id().Length() );
+        CleanupStack::PushL( tempfilename );
+        // Add prefix
+        tempfilename->Des().Append( KTempPrefix ); 
+        // Add item name. Convert 8 to 16 and replace illeagal characters.
+        HBufC8* tmpItemName8 = 
+            UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
+            aItem.Id() );
+        CleanupStack::PushL( tmpItemName8 );
+        HBufC* itemname = HBufC::NewL( tmpItemName8->Length() );
+        CleanupStack::PushL( itemname );
+        itemname->Des().Copy( *tmpItemName8 );
+        tempfilename->Des().Append( *itemname );
+        CleanupStack::PopAndDestroy( itemname );
+        CleanupStack::PopAndDestroy( tmpItemName8 );
+
+        CleanupStack::Pop( tempfilename );
+        }
+
+    return tempfilename; //transfer ownership
+    }
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnpitemresolverfactory.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnpitemresolverfactory.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,80 +1,80 @@
-/*
-* Copyright (c) 2007 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:      Tool for resolving local or remote items - factory
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// upnpframework / avcontroller helper api
-#include "upnpitemresolverfactory.h"
-
-// avcontrollerhelper internal
-#include "upnpremoteitemresolver.h"
-#include "upnplocalitemresolver.h"
-#include "upnpdownloaditemresolver.h"
-
-// CONSTANTS
-
-// METHODS
-
-// --------------------------------------------------------------------------
-// MUPnPItemResolver::NewRemoteItemResolverL
-// factory for implementation
-//---------------------------------------------------------------------------
-EXPORT_C MUPnPItemResolver* UPnPItemResolverFactory::NewRemoteItemResolverL(
-    const TDesC8& aItemId,
-    MUPnPAVBrowsingSession& aHostSession,
-    MUPnPResourceSelector& aSelector,
-    const TDesC8& aBrowseFilter,
-    TInt /*aOptimisationFlags*/ )
-    {
-    return CUPnPRemoteItemResolver::NewL(
-        aItemId, aHostSession, aSelector, aBrowseFilter );
-    }
-
-// --------------------------------------------------------------------------
-// MUPnPItemResolver::NewRemoteItemResolverL
-// factory for implementation
-//---------------------------------------------------------------------------
-EXPORT_C MUPnPItemResolver* UPnPItemResolverFactory::NewLocalItemResolverL(
-    const TDesC& aFilePath,
-    MUPnPAVController& aAvController,
-    MUPnPResourceSelector& aSelector,
-    TInt aOptimisationFlags )
-    {
-    return CUPnPLocalItemResolver::NewL(
-        aFilePath, aAvController, aSelector, aOptimisationFlags );
-    }
-
-// --------------------------------------------------------------------------
-// MUPnPItemResolver::NewDownloadItemResolverL
-// factory for implementation
-//---------------------------------------------------------------------------
-EXPORT_C MUPnPItemResolver* UPnPItemResolverFactory::NewDownloadItemResolverL(
-    const TDesC8& aItemId,
-    MUPnPAVController& aAvController,
-    MUPnPAVBrowsingSession& aHostSession,
-    MUPnPResourceSelector& aSelector,
-    const TDesC8& aBrowseFilter,
-    TInt /*aOptimisationFlags*/ )
-    {
-    return CUPnPDownloadItemResolver::NewL(
-        aItemId, aAvController, aHostSession, aSelector, aBrowseFilter );
-    }
-
+/*
+* Copyright (c) 2007 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:      Tool for resolving local or remote items - factory
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// dlnasrv / avcontroller helper api
+#include "upnpitemresolverfactory.h"
+
+// dlnasrv / avcontroller helper internal
+#include "upnpremoteitemresolver.h"
+#include "upnplocalitemresolver.h"
+#include "upnpdownloaditemresolver.h"
+
+// CONSTANTS
+
+// METHODS
+
+// --------------------------------------------------------------------------
+// MUPnPItemResolver::NewRemoteItemResolverL
+// factory for implementation
+//---------------------------------------------------------------------------
+EXPORT_C MUPnPItemResolver* UPnPItemResolverFactory::NewRemoteItemResolverL(
+    const TDesC8& aItemId,
+    MUPnPAVBrowsingSession& aHostSession,
+    MUPnPResourceSelector& aSelector,
+    const TDesC8& aBrowseFilter,
+    TInt /*aOptimisationFlags*/ )
+    {
+    return CUPnPRemoteItemResolver::NewL(
+        aItemId, aHostSession, aSelector, aBrowseFilter );
+    }
+
+// --------------------------------------------------------------------------
+// MUPnPItemResolver::NewRemoteItemResolverL
+// factory for implementation
+//---------------------------------------------------------------------------
+EXPORT_C MUPnPItemResolver* UPnPItemResolverFactory::NewLocalItemResolverL(
+    const TDesC& aFilePath,
+    MUPnPAVController& aAvController,
+    MUPnPResourceSelector& aSelector,
+    TInt aOptimisationFlags )
+    {
+    return CUPnPLocalItemResolver::NewL(
+        aFilePath, aAvController, aSelector, aOptimisationFlags );
+    }
+
+// --------------------------------------------------------------------------
+// MUPnPItemResolver::NewDownloadItemResolverL
+// factory for implementation
+//---------------------------------------------------------------------------
+EXPORT_C MUPnPItemResolver* UPnPItemResolverFactory::NewDownloadItemResolverL(
+    const TDesC8& aItemId,
+    MUPnPAVController& aAvController,
+    MUPnPAVBrowsingSession& aHostSession,
+    MUPnPResourceSelector& aSelector,
+    const TDesC8& aBrowseFilter,
+    TInt /*aOptimisationFlags*/ )
+    {
+    return CUPnPDownloadItemResolver::NewL(
+        aItemId, aAvController, aHostSession, aSelector, aBrowseFilter );
+    }
+
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnpitemutility.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnpitemutility.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,427 +1,427 @@
-/*
-* Copyright (c) 2007 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:      Utility for parsing upnp items
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <e32std.h>
-
-// upnp stack api
-#include <upnpitem.h>
-#include <upnpdlnaprotocolinfo.h>
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h" // for KValueNotImplemented
-#include "upnpitemutility.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-const TInt KDateStringLength        = 10;
-const TInt KDateTimeStringLength    = 19;
-const TInt KMaxDateStringLength     = 30;
-const TInt KCodeSemicolon           = 58;
-_LIT( KSeparator,                   ":" );
-_LIT( KNullTime,                    "000000" );
-_LIT8( KHttp,                       "http://" );
-_LIT8( KCiParam,                    "DLNA.ORG_CI" );
-
-/* removed due to M-DMC CTT test case 7.3.26.2
-_LIT8( KAudioSupport,               "audio/" );
-_LIT8( KImageSupport,               "image/" );
-_LIT8( KVideoSupport,               "video/" );
-*/
-
-// ============================ LOCAL FUNCTIONS =============================
-
-// --------------------------------------------------------------------------
-// UPnPItemUtility::BelongsToClass
-//---------------------------------------------------------------------------
-EXPORT_C TBool UPnPItemUtility::BelongsToClass(
-    const CUpnpObject& aObject,
-    const TDesC8& aClass )
-    {
-    TBool beginsWith = 
-        ( aObject.ObjectClass().Find( aClass ) == 0 );
-    return beginsWith;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPItemUtility::GetResElements
-//---------------------------------------------------------------------------
-EXPORT_C void UPnPItemUtility::GetResElements(
-    const CUpnpObject& aObject,
-    RUPnPElementsArray& aResElementsArray )
-    {
-    const RUPnPElementsArray& array =
-        const_cast<CUpnpObject&>(aObject).GetElements();
-    
-    for( TInt i = 0; i < array.Count(); i++ )
-        {
-        if( array[ i ]->Name() == KElementRes() )
-            {
-            aResElementsArray.Append( array[ i ] );
-            }
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// UPnPItemUtility::ResourceFromItemL
-//---------------------------------------------------------------------------
-EXPORT_C const CUpnpElement& UPnPItemUtility::ResourceFromItemL(
-    const CUpnpItem& aItem )
-    {
-    __LOG( "UpnpItemUtility:ResourceFromItemL" );
-
-    // Obtain list of item's res elements   
-    RUPnPElementsArray elms;
-    GetResElements( aItem, elms );
-    TInt count = elms.Count();
-
-    CUpnpDlnaProtocolInfo* pInfo = NULL;
-    TBool found = EFalse;
-    TInt i(0);
-    // bestCandidate is an index of some res element in the list. This res
-    // will be considered as the best candidate for desired res and that
-    // candidate will be returned if no res element contains false CI-flag.
-
-    const CUpnpElement* bestCandidate = 0;
-
-    // determine which resource is the original one
-    // 1. In DLNA 1.5 case, parse protocolInfo attribute and see if some res 
-    //    element has CI-flag false (=not converted so that is what we want)
-    // 2. In non-DLNA 1.5 case and in DLNA 1.5 case where CI-flag does not 
-    //    exist, do the following:
-    //      o filter out other than HTTP GET resources (internal uri's, RTP)
-    //      o filter out resources that do not match itemtype (mime type of 
-    //        audio file resources should start with "audio/" etc.)
-    for( i = 0 ; i < count; i++ )
-        {
-        // Make sure that it is a HTTP GET resource. Otherwise continue.
-        if( elms[ i ]->Value().Left( KHttp.iTypeLength ).Compare( KHttp() ) 
-            != 0 )
-            {
-            continue;
-            }
-
-        // Obtain protocolInfo of the res element.
-        const CUpnpAttribute* attr = FindAttributeByName(
-            *elms[i], KAttributeProtocolInfo() );
-        if ( attr ) 
-            {           
-            TRAP_IGNORE( pInfo = CUpnpDlnaProtocolInfo::NewL( attr->Value() ) );
-            if( !pInfo )
-                {
-                //if pInfo, start next one!
-                continue;
-                }
-            // check if CI parameter is false or it doesn't have CI parameters at all.
-            //for upnp item, always the first res element is the best, resolution
-            // should be checked in the future
-            if ( ( attr->Value().Find( KCiParam() ) != KErrNotFound && 
-                 pInfo->CiParameter() == EFalse ) || 
-                 attr->Value().Find( KCiParam() ) == KErrNotFound )
-                {
-                // end loop, we found what we were looking for. 
-                found = ETrue;
-                delete pInfo; pInfo = NULL;
-                break;                
-                }
-
-/* removed due to M-DMC CTT test case 7.3.26.2            
-            // check that mimetype corresponds to objectType
-            TPtrC8 mime = pInfo->ThirdField();
-            
-            TPtrC8 objectClass = aItem.ObjectClass();
-            if ( objectClass.Compare( KClassAudio ) == 0 ) 
-                {
-                if ( mime.Left( KAudioSupport().Length() ).CompareF( 
-                                                    KAudioSupport() ) != 0 ) 
-                    {
-                    // if mime type does not match to object type, this is 
-                    // not the correct resource.
-                    delete pInfo; pInfo = NULL;
-                    continue;
-                    }
-                }
-            else if ( objectClass.Compare( KClassVideo ) == 0 ) 
-                {
-                if ( mime.Left( KVideoSupport().Length() ).CompareF( 
-                                                    KVideoSupport() ) != 0 ) 
-                    {
-                    // if mime type does not match to object type, this is 
-                    // not the correct resource.
-                    delete pInfo; pInfo = NULL;
-                    continue;
-                    }
-                }
-            else if ( objectClass.Compare( KClassImage ) == 0 ) 
-                {
-                if ( mime.Left( KImageSupport().Length() ).CompareF( 
-                                                    KImageSupport() ) != 0 ) 
-                    {
-                    // if mime type does not match to object type, this is 
-                    // not the correct resource.
-                    delete pInfo; pInfo = NULL;
-                    continue;
-                    }
-                }
- */
-            // use the first suitable res field as candidate which will be
-            // returned if better is not found.
-            // More sophisticated solution would be to compare resolution
-            // etc. attributes to determine the best candidate,
-            if ( 0 == bestCandidate ) 
-                {
-                bestCandidate = elms[i];
-                }
-            delete pInfo; pInfo = NULL;
-            }
-        else 
-            {
-            // No mandatory protocolinfo attribute. This is not what we want.
-            }
-        }
-    if ( found ) 
-        {
-        bestCandidate = elms[i];
-        }
-
-    // close the elements array
-    elms.Close();
-
-    if( bestCandidate == 0 )
-        {
-        User::Leave( KErrNotFound );
-        }
-    return *bestCandidate;
-    }
-
-
-// --------------------------------------------------------------------------
-// UPnPItemUtility::FindElementByName
-//---------------------------------------------------------------------------
-EXPORT_C const CUpnpElement* UPnPItemUtility::FindElementByName(
-    const CUpnpObject& aObject, const TDesC8& aName )
-    {
-    __LOG( "UpnpItemUtility:FindElementByName" );
-
-    CUpnpElement* element = NULL;
-    const RUPnPElementsArray& array =
-        const_cast<CUpnpObject&>(aObject).GetElements();
-    for( TInt i = 0; i < array.Count(); i++ )
-        {
-        if( array[ i ]->Name() == aName )
-            {
-            element = array[ i ];
-            i = array.Count();
-            }
-        }
-    return element;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPItemUtility::FindElementByNameL
-//---------------------------------------------------------------------------
-EXPORT_C const CUpnpElement& UPnPItemUtility::FindElementByNameL(
-    const CUpnpObject& aObject, const TDesC8& aName )
-    {
-    __LOG( "UpnpItemUtility:FindElementByNameL" );
-
-    const CUpnpElement* element = FindElementByName(
-        aObject, aName );
-    if( !element )
-        {
-        User::Leave( KErrNotFound );
-        }
-    return *element;    
-    }
-
-// --------------------------------------------------------------------------
-// UPnPItemUtility::FindAttributeByName
-//---------------------------------------------------------------------------
-EXPORT_C const CUpnpAttribute* UPnPItemUtility::FindAttributeByName(
-    const CUpnpElement& aElement, const TDesC8& aName )
-    {
-    __LOG( "UpnpItemUtility:FindAttributeByName" );
-
-    CUpnpAttribute* attribute = NULL;
-    const RUPnPAttributesArray& array =
-        const_cast<CUpnpElement&>(aElement).GetAttributes();
-    
-    for( TInt i = 0; i < array.Count(); i++ )
-        {
-        
-        TBufC8<255> buf(array[ i ]->Name());
-        if( array[ i ]->Name() == aName )
-            {
-            attribute = array[ i ];
-            i = array.Count();
-            }
-        }
-    return attribute;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPItemUtility::FindAttributeByNameL
-//---------------------------------------------------------------------------
-EXPORT_C const CUpnpAttribute& UPnPItemUtility::FindAttributeByNameL(
-    const CUpnpElement& aElement, const TDesC8& aName )
-    {
-    __LOG( "UpnpItemUtility:FindAttributeByNameL" );
-
-    const CUpnpAttribute* attribute = FindAttributeByName(
-        aElement, aName );
-    if( !attribute )
-        {
-        User::Leave( KErrNotFound );
-        }
-    return *attribute;        
-    }
-
-// --------------------------------------------------------------------------
-// UPnPItemUtility::UpnpDateAsTTime
-//---------------------------------------------------------------------------
-EXPORT_C TInt UPnPItemUtility::UPnPDateAsTTime(
-    const TDesC8& aUpnpDate, TTime& aTime )
-    {
-    __LOG( "UpnpItemUtility:UpnpDateAsTTime" );
-
-    TRAPD( err, UPnPItemUtility::UPnPDateAsTTimeL( aUpnpDate, aTime ) );
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPItemUtility::UpnpDurationAsMilliseconds
-//---------------------------------------------------------------------------
-EXPORT_C TInt UPnPItemUtility::UPnPDurationAsMilliseconds(
-    const TDesC8& aDuration, TInt& aMilliseconds )
-    {
-    __LOG( "UpnpItemUtility:UpnpDurationAsMilliseconds" );
-
-    TInt retVal = KErrNone;    
-    if( aDuration.Length() > 0 )
-        {
-        // Check if information is actually returned by the device
-        if( aDuration.Compare( KValueNotImplemented ) != 0 )
-            {        
-            TInt time = 0;
-            TChar separator( KCodeSemicolon );
-            TInt lposit = aDuration.Locate( separator );
-            
-            if ( lposit != KErrNotFound )
-                {
-                TInt rposit = aDuration.LocateReverse( separator );
-                if( rposit != lposit )
-                    {
-                    // Hours
-                    TLex8 lex( aDuration.Left( lposit ) );
-                    retVal = lex.Val( time ); 
-                    if( retVal == KErrNone  )
-                        {
-                        // Convert to ms and add
-                        aMilliseconds += time * 3600 * 1000;
-                        // Minutes
-                        lex.Assign( aDuration.Mid(
-                            lposit + 1, rposit - lposit - 1 ) );
-                        retVal = lex.Val( time ); 
-                        if( retVal == KErrNone )
-                            {
-                            // Convert to ms and add
-                            aMilliseconds += time * 60* 1000;
-                            // Seconds
-                            lex.Assign( aDuration.Mid(
-                                rposit + 1, 2 ) );
-                            retVal = lex.Val( time ); 
-                            if( retVal  == KErrNone )
-                                {
-                                // Convert to ms and add
-                                aMilliseconds += time * 1000;
-                                }
-                            }
-                        }
-                    }
-                else
-                    {
-                    retVal = KErrNotSupported;
-                    }        
-                }
-            else
-                {
-                retVal = KErrNotSupported;
-                }   
-            }  
-        else
-            {
-            retVal = KErrNotSupported;
-            }
-        }
-    else
-        {
-        retVal = KErrNotSupported;
-        }
-        
-    return retVal;
-    }
-
-void UPnPItemUtility::UPnPDateAsTTimeL( const TDesC8& aUpnpDate,
-    TTime& aTime )
-    {
-    // This method is capable of handling the most common dc:date formats:
-    // CCYY-MM-DD and CCYY-MM-DDThh:mm:ss
-    // Rest of the dc:date formats are handled as well, but they might not
-    // be converted precisely
-    
-    TBuf<KMaxDateStringLength> formatDateString;
-    HBufC* dateString = HBufC::NewL( aUpnpDate.Length() );
-    dateString->Des().Copy( aUpnpDate );
-
-    if( aUpnpDate.Length() >= KDateStringLength )
-        {
-        // CCYY-MM-DD --> CCYYMMDD
-        formatDateString.Copy( dateString->Des().Left( 4 ) ); // Year
-        formatDateString.Append( dateString->Des().Mid( 5,2 ) ); // Month
-        formatDateString.Append( dateString->Des().Mid( 8,2 ) ); // Day        
-
-        if( aUpnpDate.Length() >= KDateTimeStringLength )
-            {
-            // hh:mm:ss --> hhmmss
-            formatDateString.Append( KSeparator );
-            // Hours
-            formatDateString.Append( dateString->Des().Mid( 11, 2 ) ); 
-            // Minutes
-            formatDateString.Append( dateString->Des().Mid( 14, 2 ) );
-            // Seconds 
-            formatDateString.Append( dateString->Des().Mid( 17, 2 ) ); 
-            }
-        else
-            {
-            // hh:mm:ss --> 000000
-            formatDateString.Append( KSeparator );
-            formatDateString.Append( KNullTime );
-            }
-        }
-    delete dateString;
-    
-    User::LeaveIfError( aTime.Set( formatDateString ) );
-    }
-
+/*
+* Copyright (c) 2007 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:      Utility for parsing upnp items
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// System
+#include <e32std.h>
+
+// dlnasrv / mediaserver api
+#include <upnpitem.h>
+#include <upnpdlnaprotocolinfo.h>
+
+// dlnasrv / avcontroller helper api
+#include "upnpconstantdefs.h" // for KValueNotImplemented
+#include "upnpitemutility.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+const TInt KDateStringLength        = 10;
+const TInt KDateTimeStringLength    = 19;
+const TInt KMaxDateStringLength     = 30;
+const TInt KCodeSemicolon           = 58;
+_LIT( KSeparator,                   ":" );
+_LIT( KNullTime,                    "000000" );
+_LIT8( KHttp,                       "http://" );
+_LIT8( KCiParam,                    "DLNA.ORG_CI" );
+
+/* removed due to M-DMC CTT test case 7.3.26.2
+_LIT8( KAudioSupport,               "audio/" );
+_LIT8( KImageSupport,               "image/" );
+_LIT8( KVideoSupport,               "video/" );
+*/
+
+// ============================ LOCAL FUNCTIONS =============================
+
+// --------------------------------------------------------------------------
+// UPnPItemUtility::BelongsToClass
+//---------------------------------------------------------------------------
+EXPORT_C TBool UPnPItemUtility::BelongsToClass(
+    const CUpnpObject& aObject,
+    const TDesC8& aClass )
+    {
+    TBool beginsWith = 
+        ( aObject.ObjectClass().Find( aClass ) == 0 );
+    return beginsWith;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPItemUtility::GetResElements
+//---------------------------------------------------------------------------
+EXPORT_C void UPnPItemUtility::GetResElements(
+    const CUpnpObject& aObject,
+    RUPnPElementsArray& aResElementsArray )
+    {
+    const RUPnPElementsArray& array =
+        const_cast<CUpnpObject&>(aObject).GetElements();
+    
+    for( TInt i = 0; i < array.Count(); i++ )
+        {
+        if( array[ i ]->Name() == KElementRes() )
+            {
+            aResElementsArray.Append( array[ i ] );
+            }
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// UPnPItemUtility::ResourceFromItemL
+//---------------------------------------------------------------------------
+EXPORT_C const CUpnpElement& UPnPItemUtility::ResourceFromItemL(
+    const CUpnpItem& aItem )
+    {
+    __LOG( "UpnpItemUtility:ResourceFromItemL" );
+
+    // Obtain list of item's res elements   
+    RUPnPElementsArray elms;
+    GetResElements( aItem, elms );
+    TInt count = elms.Count();
+
+    CUpnpDlnaProtocolInfo* pInfo = NULL;
+    TBool found = EFalse;
+    TInt i(0);
+    // bestCandidate is an index of some res element in the list. This res
+    // will be considered as the best candidate for desired res and that
+    // candidate will be returned if no res element contains false CI-flag.
+
+    const CUpnpElement* bestCandidate = 0;
+
+    // determine which resource is the original one
+    // 1. In DLNA 1.5 case, parse protocolInfo attribute and see if some res 
+    //    element has CI-flag false (=not converted so that is what we want)
+    // 2. In non-DLNA 1.5 case and in DLNA 1.5 case where CI-flag does not 
+    //    exist, do the following:
+    //      o filter out other than HTTP GET resources (internal uri's, RTP)
+    //      o filter out resources that do not match itemtype (mime type of 
+    //        audio file resources should start with "audio/" etc.)
+    for( i = 0 ; i < count; i++ )
+        {
+        // Make sure that it is a HTTP GET resource. Otherwise continue.
+        if( elms[ i ]->Value().Left( KHttp.iTypeLength ).Compare( KHttp() ) 
+            != 0 )
+            {
+            continue;
+            }
+
+        // Obtain protocolInfo of the res element.
+        const CUpnpAttribute* attr = FindAttributeByName(
+            *elms[i], KAttributeProtocolInfo() );
+        if ( attr ) 
+            {           
+            TRAP_IGNORE( pInfo = CUpnpDlnaProtocolInfo::NewL( attr->Value() ) );
+            if( !pInfo )
+                {
+                //if pInfo, start next one!
+                continue;
+                }
+            // check if CI parameter is false or it doesn't have CI parameters at all.
+            //for upnp item, always the first res element is the best, resolution
+            // should be checked in the future
+            if ( ( attr->Value().Find( KCiParam() ) != KErrNotFound && 
+                 pInfo->CiParameter() == EFalse ) || 
+                 attr->Value().Find( KCiParam() ) == KErrNotFound )
+                {
+                // end loop, we found what we were looking for. 
+                found = ETrue;
+                delete pInfo; pInfo = NULL;
+                break;                
+                }
+
+/* removed due to M-DMC CTT test case 7.3.26.2            
+            // check that mimetype corresponds to objectType
+            TPtrC8 mime = pInfo->ThirdField();
+            
+            TPtrC8 objectClass = aItem.ObjectClass();
+            if ( objectClass.Compare( KClassAudio ) == 0 ) 
+                {
+                if ( mime.Left( KAudioSupport().Length() ).CompareF( 
+                                                    KAudioSupport() ) != 0 ) 
+                    {
+                    // if mime type does not match to object type, this is 
+                    // not the correct resource.
+                    delete pInfo; pInfo = NULL;
+                    continue;
+                    }
+                }
+            else if ( objectClass.Compare( KClassVideo ) == 0 ) 
+                {
+                if ( mime.Left( KVideoSupport().Length() ).CompareF( 
+                                                    KVideoSupport() ) != 0 ) 
+                    {
+                    // if mime type does not match to object type, this is 
+                    // not the correct resource.
+                    delete pInfo; pInfo = NULL;
+                    continue;
+                    }
+                }
+            else if ( objectClass.Compare( KClassImage ) == 0 ) 
+                {
+                if ( mime.Left( KImageSupport().Length() ).CompareF( 
+                                                    KImageSupport() ) != 0 ) 
+                    {
+                    // if mime type does not match to object type, this is 
+                    // not the correct resource.
+                    delete pInfo; pInfo = NULL;
+                    continue;
+                    }
+                }
+ */
+            // use the first suitable res field as candidate which will be
+            // returned if better is not found.
+            // More sophisticated solution would be to compare resolution
+            // etc. attributes to determine the best candidate,
+            if ( 0 == bestCandidate ) 
+                {
+                bestCandidate = elms[i];
+                }
+            delete pInfo; pInfo = NULL;
+            }
+        else 
+            {
+            // No mandatory protocolinfo attribute. This is not what we want.
+            }
+        }
+    if ( found ) 
+        {
+        bestCandidate = elms[i];
+        }
+
+    // close the elements array
+    elms.Close();
+
+    if( bestCandidate == 0 )
+        {
+        User::Leave( KErrNotFound );
+        }
+    return *bestCandidate;
+    }
+
+
+// --------------------------------------------------------------------------
+// UPnPItemUtility::FindElementByName
+//---------------------------------------------------------------------------
+EXPORT_C const CUpnpElement* UPnPItemUtility::FindElementByName(
+    const CUpnpObject& aObject, const TDesC8& aName )
+    {
+    __LOG( "UpnpItemUtility:FindElementByName" );
+
+    CUpnpElement* element = NULL;
+    const RUPnPElementsArray& array =
+        const_cast<CUpnpObject&>(aObject).GetElements();
+    for( TInt i = 0; i < array.Count(); i++ )
+        {
+        if( array[ i ]->Name() == aName )
+            {
+            element = array[ i ];
+            i = array.Count();
+            }
+        }
+    return element;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPItemUtility::FindElementByNameL
+//---------------------------------------------------------------------------
+EXPORT_C const CUpnpElement& UPnPItemUtility::FindElementByNameL(
+    const CUpnpObject& aObject, const TDesC8& aName )
+    {
+    __LOG( "UpnpItemUtility:FindElementByNameL" );
+
+    const CUpnpElement* element = FindElementByName(
+        aObject, aName );
+    if( !element )
+        {
+        User::Leave( KErrNotFound );
+        }
+    return *element;    
+    }
+
+// --------------------------------------------------------------------------
+// UPnPItemUtility::FindAttributeByName
+//---------------------------------------------------------------------------
+EXPORT_C const CUpnpAttribute* UPnPItemUtility::FindAttributeByName(
+    const CUpnpElement& aElement, const TDesC8& aName )
+    {
+    __LOG( "UpnpItemUtility:FindAttributeByName" );
+
+    CUpnpAttribute* attribute = NULL;
+    const RUPnPAttributesArray& array =
+        const_cast<CUpnpElement&>(aElement).GetAttributes();
+    
+    for( TInt i = 0; i < array.Count(); i++ )
+        {
+        
+        TBufC8<255> buf(array[ i ]->Name());
+        if( array[ i ]->Name() == aName )
+            {
+            attribute = array[ i ];
+            i = array.Count();
+            }
+        }
+    return attribute;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPItemUtility::FindAttributeByNameL
+//---------------------------------------------------------------------------
+EXPORT_C const CUpnpAttribute& UPnPItemUtility::FindAttributeByNameL(
+    const CUpnpElement& aElement, const TDesC8& aName )
+    {
+    __LOG( "UpnpItemUtility:FindAttributeByNameL" );
+
+    const CUpnpAttribute* attribute = FindAttributeByName(
+        aElement, aName );
+    if( !attribute )
+        {
+        User::Leave( KErrNotFound );
+        }
+    return *attribute;        
+    }
+
+// --------------------------------------------------------------------------
+// UPnPItemUtility::UpnpDateAsTTime
+//---------------------------------------------------------------------------
+EXPORT_C TInt UPnPItemUtility::UPnPDateAsTTime(
+    const TDesC8& aUpnpDate, TTime& aTime )
+    {
+    __LOG( "UpnpItemUtility:UpnpDateAsTTime" );
+
+    TRAPD( err, UPnPItemUtility::UPnPDateAsTTimeL( aUpnpDate, aTime ) );
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPItemUtility::UpnpDurationAsMilliseconds
+//---------------------------------------------------------------------------
+EXPORT_C TInt UPnPItemUtility::UPnPDurationAsMilliseconds(
+    const TDesC8& aDuration, TInt& aMilliseconds )
+    {
+    __LOG( "UpnpItemUtility:UpnpDurationAsMilliseconds" );
+
+    TInt retVal = KErrNone;    
+    if( aDuration.Length() > 0 )
+        {
+        // Check if information is actually returned by the device
+        if( aDuration.Compare( KValueNotImplemented ) != 0 )
+            {        
+            TInt time = 0;
+            TChar separator( KCodeSemicolon );
+            TInt lposit = aDuration.Locate( separator );
+            
+            if ( lposit != KErrNotFound )
+                {
+                TInt rposit = aDuration.LocateReverse( separator );
+                if( rposit != lposit )
+                    {
+                    // Hours
+                    TLex8 lex( aDuration.Left( lposit ) );
+                    retVal = lex.Val( time ); 
+                    if( retVal == KErrNone  )
+                        {
+                        // Convert to ms and add
+                        aMilliseconds += time * 3600 * 1000;
+                        // Minutes
+                        lex.Assign( aDuration.Mid(
+                            lposit + 1, rposit - lposit - 1 ) );
+                        retVal = lex.Val( time ); 
+                        if( retVal == KErrNone )
+                            {
+                            // Convert to ms and add
+                            aMilliseconds += time * 60* 1000;
+                            // Seconds
+                            lex.Assign( aDuration.Mid(
+                                rposit + 1, 2 ) );
+                            retVal = lex.Val( time ); 
+                            if( retVal  == KErrNone )
+                                {
+                                // Convert to ms and add
+                                aMilliseconds += time * 1000;
+                                }
+                            }
+                        }
+                    }
+                else
+                    {
+                    retVal = KErrNotSupported;
+                    }        
+                }
+            else
+                {
+                retVal = KErrNotSupported;
+                }   
+            }  
+        else
+            {
+            retVal = KErrNotSupported;
+            }
+        }
+    else
+        {
+        retVal = KErrNotSupported;
+        }
+        
+    return retVal;
+    }
+
+void UPnPItemUtility::UPnPDateAsTTimeL( const TDesC8& aUpnpDate,
+    TTime& aTime )
+    {
+    // This method is capable of handling the most common dc:date formats:
+    // CCYY-MM-DD and CCYY-MM-DDThh:mm:ss
+    // Rest of the dc:date formats are handled as well, but they might not
+    // be converted precisely
+    
+    TBuf<KMaxDateStringLength> formatDateString;
+    HBufC* dateString = HBufC::NewL( aUpnpDate.Length() );
+    dateString->Des().Copy( aUpnpDate );
+
+    if( aUpnpDate.Length() >= KDateStringLength )
+        {
+        // CCYY-MM-DD --> CCYYMMDD
+        formatDateString.Copy( dateString->Des().Left( 4 ) ); // Year
+        formatDateString.Append( dateString->Des().Mid( 5,2 ) ); // Month
+        formatDateString.Append( dateString->Des().Mid( 8,2 ) ); // Day        
+
+        if( aUpnpDate.Length() >= KDateTimeStringLength )
+            {
+            // hh:mm:ss --> hhmmss
+            formatDateString.Append( KSeparator );
+            // Hours
+            formatDateString.Append( dateString->Des().Mid( 11, 2 ) ); 
+            // Minutes
+            formatDateString.Append( dateString->Des().Mid( 14, 2 ) );
+            // Seconds 
+            formatDateString.Append( dateString->Des().Mid( 17, 2 ) ); 
+            }
+        else
+            {
+            // hh:mm:ss --> 000000
+            formatDateString.Append( KSeparator );
+            formatDateString.Append( KNullTime );
+            }
+        }
+    delete dateString;
+    
+    User::LeaveIfError( aTime.Set( formatDateString ) );
+    }
+
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnplocalitemresolver.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnplocalitemresolver.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,553 +1,397 @@
-/*
-* Copyright (c) 2007 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:      Resolver for local items
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// upnp stack api's
-#include <upnpitem.h>
-
-// upnpframework / avcontroller api
-#include "upnpavcontroller.h" // avcontroller service
-#include "upnpavbrowsingsession.h" // browsing session
-#include "upnpavdevice.h" // device (for creating a session)
-#include <upnpfilesharing.h>
-
-// upnpframework / avcontroller helper api
-#include "upnpitemresolverfactory.h" // optimisation flags
-#include "upnpitemresolverobserver.h" // MUPnPItemResolverObserver
-#include "upnpfileutility.h" // IsFileProtected
-#include "upnpresourceselector.h" // MUPnPResourceSelector
-
-// upnpframework / internal api's
-#include "upnpmetadatafetcher.h" // CreateItemFromFileLC
-#include "upnpcommonutils.h" // ReplacePlaceHolderInURIL
-
-// avcontrollerhelper internal
-#include "upnplocalitemresolver.h"
-
-#include "upnpconstantdefs.h" // for upnp-specific stuff
-#include "upnpitemutility.h" // for GetResElements
-#include "upnpsecaccesscontroller.h" // CUpnpSecAccessController
-#include "upnpperiodic.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-const TInt KCancelWaitMaximum =   4000000;
-const TInt KCancelWaitResolution = 500000;
-const TInt KUnshareWait =  1000000;
-
-// METHODS
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver:: NewL
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-CUPnPLocalItemResolver* CUPnPLocalItemResolver::NewL(
-    const TDesC& aFilePath,
-    MUPnPAVController& aAvController,
-    MUPnPResourceSelector& aSelector,
-    TInt aOptimisationFlags    )
-    {
-    CUPnPLocalItemResolver* self =
-        new (ELeave )CUPnPLocalItemResolver(
-        aAvController, aSelector, aOptimisationFlags );
-    CleanupStack::PushL( self );
-    self->ConstructL( aFilePath );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::CUPnPLocalItemResolver
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-CUPnPLocalItemResolver::CUPnPLocalItemResolver(
-    MUPnPAVController& aAvController,
-    MUPnPResourceSelector& aSelector,
-    TInt aOptimisationFlags )
-    : CActive( EPriorityStandard )
-    , iAvController( aAvController )
-    , iSelector( aSelector )
-    {
-    CActiveScheduler::Add( this );
-    iOptimisationFlags = aOptimisationFlags;
-    iState = EStateIdle;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::ConstructL
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-void CUPnPLocalItemResolver::ConstructL(
-    const TDesC& aFilePath )
-    {
-    __LOG1( "LocalItemResolver:ConstructL() 0x%d", TInt(this) );
-    iFilePath = aFilePath.AllocL();
-    iFileSharing = CUpnpFileSharing::NewL();    
-    iAccessController = CUpnpSecAccessController::NewL();
-    iWait = new (ELeave) CActiveSchedulerWait();
-    iTimer = CUPnPPeriodic::NewL( CActive::EPriorityHigh );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::~CUPnPLocalItemResolver
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-CUPnPLocalItemResolver::~CUPnPLocalItemResolver()
-    {
-    __LOG1( "LocalItemResolver destructor 0x%d", TInt(this) );
-    
-    Cleanup();
-    
-    if ( iTempSession )
-        {
-        iTempSession->RemoveObserver();
-        iAvController.StopBrowsingSession( *iTempSession );
-        }
-
-    delete iFileSharing;
-    iFileSharing = NULL;
-    
-    // cancel any async calls
-    if ( IsActive() )
-        {
-         __LOG( "LocalItemResolver destructor RequestComplete" );
-        TRequestStatus* stat = &iStatus;
-        User::RequestComplete( stat, KErrNone );
-        }
-    
-    Cancel();
-      
-    delete iFilePath;
-    iFilePath = NULL;
-    
-    delete iAccessController;
-    iAccessController = NULL;
-    
-    delete iSharedItem;
-    iSharedItem = NULL;
-        
-    if( iTimer )
-        {
-        iTimer->Cancel();
-        delete iTimer;
-        iTimer = NULL;
-        }
-    
-    if( iWait->IsStarted() )
-        {
-        iWait->AsyncStop();
-        }
-    delete iWait;
-    iWait = NULL;
-        
-    __LOG( "LocalItemResolver destructor end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::ResolveL
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-void CUPnPLocalItemResolver::ResolveL(
-    MUPnPItemResolverObserver& aObserver )
-    {
-    __LOG1( "LocalItemResolver:Resolve() 0x%d", TInt(this) );
-    __ASSERTD( iState == EStateIdle, __FILE__, __LINE__ );
-    iObserver = &aObserver;
-
-    if ( iOptimisationFlags & UPnPItemResolverFactory::EOmitDrmCheck )
-        {
-        // no need to check DRM ! this branch is empty.
-        }
-    else
-        {
-        // check DRM
-        if ( UPnPFileUtility::IsFileProtectedL( iFilePath->Des() ) )
-            {
-            User::Leave( KErrNotSupported );
-            }
-        }
-
-    // create item metadata
-    iState = EStateCreatingItem;
-    CUpnpItem* item = UPnPMetadataFetcher::CreateItemFromFileLC(
-        iFilePath->Des() );
-    CleanupStack::Pop( item );
-    __LOG1( "LocalItemResolver:Resolve CreateItemFromFileLC done 0x%d", TInt(this) );
-    if( iSharedItem )
-        {
-        delete iSharedItem;
-        iSharedItem = 0;
-        }
-    iSharedItem = item;
-
-    // state check
-    if ( iState == EStateCreatingItem )
-        {
-        // start local mediaserver
-        if ( iOptimisationFlags & UPnPItemResolverFactory::EOmitLocalMSStart )
-            {
-            // omit mediaserver start - go directly to sharing.
-            DoShareL();
-            }
-        else
-            {
-            // start a session for local MS keepalive
-            CUpnpAVDevice* dummyDevice = CUpnpAVDevice::NewLC();
-            dummyDevice->SetUuidL( KNullDesC8 );
-            dummyDevice->SetDeviceType(CUpnpAVDevice::EMediaServer);    
-            iTempSession = &iAvController.StartBrowsingSessionL( *dummyDevice );
-            CleanupStack::PopAndDestroy( dummyDevice );
-
-            iTempSession->SetObserver( *this );
-            // request for start local MS
-            iState = EStateStartingMS;
-            iTempSession->ReserveLocalMSServicesL();
-            }
-        
-        }
-    else
-        {
-        __LOG( "LocalItemResolver: create item interrupted" );
-		iState = EStateIdle;
-        }
-        
-    __LOG( "LocalItemResolver:Resolve() END" );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::DoCancel
-// See upnplocalitemresolver.h
-// --------------------------------------------------------------------------
-void CUPnPLocalItemResolver::DoCancel()
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::RunError
-// See upnplocalitemresolver.h
-// --------------------------------------------------------------------------
-TInt CUPnPLocalItemResolver::RunError( TInt aError )
-    {
-    __LOG1( "CUPnPLocalItemResolver::RunError %d", aError );
-    // should never be here.
-    __PANICD( __FILE__, __LINE__ );
-    return KErrNone;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::RunL
-// See upnplocalitemresolver.h
-// --------------------------------------------------------------------------
-void CUPnPLocalItemResolver::RunL()
-    {
-    __LOG2( "CUPnPLocalItemResolver::RunL iStatus=%d, iState=%d", 
-        iStatus.Int(), iState );
-
-
-	if ( iState == EStateSharing )
-		{
-		// If the sharing failed
-        if( iStatus.Int() != KErrNone )
-            {
-            // Deny access to the files listed in res-elements
-            SetAccesstoItemResources( *iSharedItem, EFalse );
-            }
-        
-        if( iStatus.Int() == KErrNone )
-    		{
-    	    // replace the IP address in the URI
-    	    __LOG( "LocalItemResolver:replacing IP in URI" );
-    	    TInetAddr address;
-    	    User::LeaveIfError( iMediaServer.Connect() );
-    	    iMediaServer.GetAddress( address );
-    	    UPnPCommonUtils::ReplacePlaceHolderInURIL(
-    	        *iSharedItem, address );
-    	    iMediaServer.Close();
-
-    	    // select the resource
-    	    iResource = &iSelector.SelectResourceL( *iSharedItem );
-            }
-               
-        Complete( iStatus.Int() );
-		}
-		
-    else if ( iState == EStateUnsharing )
-		{	
-		iTimer->Cancel();
-		
-        // Deny access to the files listed in res-elements
-        SetAccesstoItemResources( *iSharedItem, EFalse );
-        
-        iResource = 0; // NOTE: no deletion !
-        iState = EStateIdle;
-        
-        iWait->AsyncStop();
-        }
-        
-    __LOG( "CUPnPLocalItemResolver::RunL end" );
-    }
-    
-    
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::ReserveLocalMSServicesCompleted
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-void CUPnPLocalItemResolver::ReserveLocalMSServicesCompleted(
-    TInt aError )
-    {
-    __LOG( "LocalItemResolver:MSServicesComplete" );
-    __ASSERTD( iState == EStateStartingMS, __FILE__, __LINE__ );
-
-    if ( aError == KErrNone )
-        {
-        TRAPD( err, DoShareL() );
-        if( err != KErrNone )
-            {
-            __LOG1( "LocalItemResolver:MSServicesComplete\
- DoShareL failed %d", err );
-            }
-        }
-    else
-        {
-        Complete( aError );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::DoShareL
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-void CUPnPLocalItemResolver::DoShareL()
-    {
-    __LOG( "CUPnPLocalItemResolver::DoShareL start" );
-    // share the item
-    iState = EStateSharing;
-    
-    // Allow access to the files listed in res-elements
-    SetAccesstoItemResources( *iSharedItem, ETrue );
-    
-    // Share the item
-    iFileSharing->ShareItemL( KContainerIdRoot, *iSharedItem, iStatus );
-        
-    SetActive();
-    __LOG( "CUPnPLocalItemResolver::DoShareL end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::DoUnshareL
-// See upnplocalitemresolver.h
-// --------------------------------------------------------------------------
-void CUPnPLocalItemResolver::DoUnshareL()
-    {
-    __LOG( "CUPnPLocalItemResolver::DoUnshareL" );
-
-    iState = EStateUnsharing;
-    
-    TInt id;
-    TLex8 idParser( iSharedItem->Id() );
-    TInt status = idParser.Val( id );
-    if ( status == KErrNone )
-        {
-        iFileSharing->UnshareItemL( id, iStatus );
-
-        SetActive();
-        }
-    else
-        {
-        __LOG1( "CUPnPLocalItemResolver::DoUnshareL leave %d", status );
-        User::Leave( status );
-        }
-        
-    __LOG( "CUPnPLocalItemResolver::DoUnshareL - end" );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::Item
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-const CUpnpItem& CUPnPLocalItemResolver::Item() const
-    {
-    __ASSERTD( iState == EStateReady, __FILE__, __LINE__ );
-    __ASSERTD( iSharedItem, __FILE__, __LINE__ );
-
-    return *iSharedItem;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::Resource
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-const CUpnpElement& CUPnPLocalItemResolver::Resource() const
-    {
-    __ASSERTD( iState == EStateReady, __FILE__, __LINE__ );
-    __ASSERTD( iResource, __FILE__, __LINE__ );
-
-    return *iResource;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::Complete
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-void CUPnPLocalItemResolver::Complete( TInt aError )
-    {
-    __LOG1( "LocalItemResolver:Complete() %d", aError );
-    __ASSERTD( iState == EStateStartingMS || 
-        iState == EStateSharing, __FILE__, __LINE__ );
-        
-    MUPnPItemResolverObserver& observer = *iObserver;
-    iObserver = 0;
-    if ( aError == KErrNone )
-        {
-        iState = EStateReady;
-        }
-    else
-        {
-        iState = EStateIdle;
-        Cleanup();
-        }
-
-    observer.ResolveComplete( *this, aError );
-    __LOG( "LocalItemResolver:Complete() END" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::Cleanup
-// See upnplocalitemresolver.h
-//---------------------------------------------------------------------------
-void CUPnPLocalItemResolver::Cleanup()
-    {
-    __LOG1( "CUPnPLocalItemResolver:Cleanup() iState %d", iState );
-    
-    iObserver = 0;
-
-    if ( iState == EStateCreatingItem )
-        {
-        // signal cancel, wait until create item exits
-        iState = EStateCancel;
-        for ( TInt t = KCancelWaitMaximum;
-            t > 0 && iState != EStateIdle;
-            t -= KCancelWaitResolution )
-            {
-            User::After( TTimeIntervalMicroSeconds32(
-                KCancelWaitResolution ) );
-            }
-        }
-    else if ( iState == EStateStartingMS )
-        {
-        if( iTempSession )
-            {
-            TRAP_IGNORE( iTempSession->CancelReserveLocalMSServicesL() );
-            }
-        }
-    else if ( iState == EStateSharing )
-		{
-        // do nothing, cannot unshare item if sharing hasn't finished yet.
-        __LOG( "CUPnPLocalItemResolver:Cleanup() sharing in progress, do nothing" );
-		} 
-    else if ( iState == EStateUnsharing )
-		{
-        // do nothing, unsharing is still in progress. This happens,
-        // if we start shutting down while previous cleanup hasn't finished yet.
-        __LOG( "CUPnPLocalItemResolver:Cleanup() unsharing in progress, do nothing" );
-		}
-    else if ( iState == EStateCancel )
-		{
-        // do nothing, we shouldn't be here
-        __LOG( "CUPnPLocalItemResolver:Cleanup() cancelling, shouldn't be here.." );
-		}
-    else if ( iSharedItem )
-        {
-        TRAPD( error, DoUnshareL() );
-        
-        if( error == KErrNone )
-            {
-            // wait some time.. 
-            // if unshare doesn't finish in time, just cancel andcontinue
-            __LOG( "CUPnPLocalItemResolver:Cleanup() start timer" );
-            iTimer->Start( KUnshareWait, KUnshareWait, TCallBack( TimerExpired, this ) );
-            iWait->Start();
-            
-            iTimer->Cancel();
-            }
-        else
-            {
-            __LOG1( "CUPnPLocalItemResolver:Cleanup() unshare failed %d", error );
-            }
-        }
-
-    __LOG( "CUPnPLocalItemResolver:Cleanup() end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::SetAccesstoItemResources
-// See upnplocalitemresolver.h
-// --------------------------------------------------------------------------
-void CUPnPLocalItemResolver::SetAccesstoItemResources(
-                                                CUpnpItem& aItem,
-                                                TBool aAccessAllowed )
-    {
-    __LOG( "CUPnPLocalItemResolver::SetAccesstoItemResources" );
-
-    // Get all filenames and set the access for those.
-    RUPnPElementsArray resElements;
-    UPnPItemUtility::GetResElements( aItem, resElements );
-    for( TInt i=0; i<resElements.Count(); i++ )
-        {
-        if( aAccessAllowed )
-            {
-            iAccessController->AddAllowedFile( resElements[i]->FilePath() );
-            }
-        else
-            {
-            iAccessController->RemoveAllowedFile(
-                                        resElements[i]->FilePath() );
-            }
-        }
-    resElements.Close();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPLocalItemResolver::TimerExpired
-// See upnplocalitemresolver.h
-// -------------------------------------------------------------------------- 
-TInt CUPnPLocalItemResolver::TimerExpired( TAny* aArg )
-    {
-    __LOG( "CUPnPLocalItemResolver::TimerExpired" );
-    
-    CUPnPLocalItemResolver* resolver =
-        (static_cast<CUPnPLocalItemResolver*>( aArg ));
-    
-    resolver->iTimer->Cancel();
-    resolver->iWait->AsyncStop();
-    
-    __LOG( "CUPnPLocalItemResolver::TimerExpired end" );
-    return KErrNone;
-    }
-
+/*
+* Copyright (c) 2009 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:      Resolver for local items
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// dlnasrv / mediaserver api
+#include <upnpitem.h>
+// mpx
+#include <mpxmedia.h>
+#include <mpxmediamusicdefs.h>
+#include <mpxcollectionhelper.h>
+#include <mpxcollectionhelperfactory.h>
+// dlnasrv / avcontroller api
+#include "upnpavcontroller.h" // avcontroller service
+#include "upnpavbrowsingsession.h" // browsing session
+#include "upnpavdevice.h" // device (for creating a session)
+
+// dlnasrv / avcontroller helper api
+#include "upnpitemresolverfactory.h" // optimisation flags
+#include "upnpitemresolverobserver.h" // MUPnPItemResolverObserver
+#include "upnpfileutility.h" // IsFileProtected
+#include "upnpresourceselector.h" // MUPnPResourceSelector
+#include "upnpitemutility.h" // GetResElements
+#include "upnpconstantdefs.h" // for upnp-specific stuff
+
+// dlnasrv / internal api
+#include "upnppushserver.h" // CUpnpPushServer
+#include "upnpmetadatafetcher.h" // CreateItemFromFileLC
+#include "upnpstring.h"
+
+// dlnasrv / avcontrollerhelper internal
+#include "upnplocalitemresolver.h"
+
+#include "upnptranscodehelper.h"
+
+#include "upnpcdsreselementutility.h"
+#include "upnpdlnaprofiler.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+static TUint KFirstSharedHash = 8647544;
+
+// METHODS
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver:: NewL
+// See upnplocalitemresolver.h
+//---------------------------------------------------------------------------
+CUPnPLocalItemResolver* CUPnPLocalItemResolver::NewL(
+    const TDesC& aFilePath,
+    MUPnPAVController& aAvController,
+    MUPnPResourceSelector& aSelector,
+    TInt aOptimisationFlags    )
+    {
+    CUPnPLocalItemResolver* self = new (ELeave )CUPnPLocalItemResolver(
+								aAvController, aSelector, aOptimisationFlags );
+    CleanupStack::PushL( self );
+    self->ConstructL( aFilePath );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::CUPnPLocalItemResolver
+// See upnplocalitemresolver.h
+//---------------------------------------------------------------------------
+CUPnPLocalItemResolver::CUPnPLocalItemResolver(
+    MUPnPAVController& /*aAvController*/,
+    MUPnPResourceSelector& aSelector,
+    TInt aOptimisationFlags )
+    : iSelector( aSelector )
+    {
+    iOptimisationFlags = aOptimisationFlags;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::ConstructL
+// See upnplocalitemresolver.h
+//---------------------------------------------------------------------------
+void CUPnPLocalItemResolver::ConstructL(
+    const TDesC& aFilePath )
+    {
+    __LOG1( "LocalItemResolver:ConstructL() 0x%d", TInt(this) );
+    iFilePath = aFilePath.AllocL();
+    
+#ifdef UPNP_USE_GSTREAMER
+    iTranscodeHelper = CUpnpTranscodeHelper::NewL();
+#endif
+    
+    // create mpx collection helper
+    iCollectionHelper = CMPXCollectionHelperFactory::NewCollectionHelperL();
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::~CUPnPLocalItemResolver
+// See upnplocalitemresolver.h
+//---------------------------------------------------------------------------
+CUPnPLocalItemResolver::~CUPnPLocalItemResolver()
+    {
+    __LOG1( "LocalItemResolver destructor 0x%d", TInt(this) );
+    delete iFilePath;
+    iFilePath = NULL;
+    delete iSharedItem;
+    iSharedItem = NULL;
+    delete iThumbnailCreator;
+    iThumbnailCreator = NULL;
+    Cleanup();
+#ifdef UPNP_USE_GSTREAMER
+    delete iTranscodeHelper;
+#endif
+    iCollectionHelper->Close();
+    __LOG( "LocalItemResolver destructor end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::ResolveL
+// See upnplocalitemresolver.h
+//---------------------------------------------------------------------------
+void CUPnPLocalItemResolver::ResolveL(
+    MUPnPItemResolverObserver& aObserver, CUpnpAVDevice* aDevice )
+    {
+    __LOG1( "LocalItemResolver:Resolve() 0x%d", TInt(this) );
+    
+    _LIT(KExtJpeg, ".jpeg");
+    _LIT(KExtJpg,  ".jpg");
+    
+    iObserver = &aObserver;
+    if ( !(iOptimisationFlags & UPnPItemResolverFactory::EOmitDrmCheck ))
+        {
+        // check DRM
+        if ( UPnPFileUtility::IsFileProtectedL( iFilePath->Des() ) )
+            {
+            User::Leave( KErrNotSupported );
+            }
+        }
+    // create item metadata
+	delete iLocalItem;
+	iLocalItem = NULL;
+    iLocalItem =
+		UPnPMetadataFetcher::CreateItemFromFileLC(
+			iFilePath->Des());
+    CleanupStack::Pop( iLocalItem );
+
+#ifdef UPNP_USE_GSTREAMER
+    if( aDevice )
+        {
+        HBufC8* pipeline = NULL;
+        HBufC8* protocolInfo = NULL;
+        
+        TRAPD( err, iTranscodeHelper->PreDefinedCfgL( *aDevice, 
+                *iLocalItem, pipeline, protocolInfo ) );
+        
+        __ASSERT_ALWAYS( err == KErrNone || err == KErrNotFound, 
+                User::Invariant() );
+        
+        if( err == KErrNone )
+            {
+            CleanupStack::PushL(pipeline);
+            CleanupStack::PushL(protocolInfo);
+            
+            //config found -> start transc and replace resource
+            iTranscodeHelper->TranscodeL( *pipeline );
+            iTranscodeHelper->ReplaceResourceL( *iLocalItem, *protocolInfo );
+            
+            CleanupStack::PopAndDestroy(protocolInfo);
+            CleanupStack::PopAndDestroy(pipeline);
+            }               
+        }
+#endif
+    
+    TParse p;
+    p.Set(iFilePath->Des(),NULL,NULL);
+    if( p.Ext().CompareF(KExtJpeg) == KErrNone 
+        || p.Ext().CompareF(KExtJpg) == KErrNone )
+        {
+        //TThumbnailDlnaSize size (EThumbnail);
+        //iThumbnailCreator = CUpnpThumbnailCreator::NewL(*this,
+        //                                                *iFilePath, size);
+        // TODO: the above code starts thumbnail creation,
+        // but for some reason thumbnail manager returns with KErrBadName.
+        // For now, just share the original, without creating a thumbnail res element
+        ShareL();
+        }
+    else if( UPnPItemUtility::BelongsToClass(*iLocalItem,KClassAudio()) )
+        {
+        // 
+        TRAPD( err, SetAlbumArtResourceToItemL( *iFilePath ) );
+        __LOG1( "LocalItemResolver:Resolve() music album art err=%d",err );
+        if( err )
+            {
+            // if song did not have album art share normally
+            ShareL();
+            }
+        }
+    else
+        {
+        ShareL();
+        }
+    __LOG( "LocalItemResolver:Resolve() END" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::ShareL
+//---------------------------------------------------------------------------
+void CUPnPLocalItemResolver::ShareL()
+    {
+    // share
+    CUpnpPushServer::ShareL( KFirstSharedHash++, *iLocalItem );
+
+    // Store item & resource
+    delete iSharedItem;
+    iSharedItem = NULL;    
+    iSharedItem = iLocalItem;
+	iLocalItem = NULL;
+        
+    iResource = &iSelector.SelectResourceL( *iSharedItem );
+	
+    //inform the observer
+    iObserver->ResolveComplete( *this, KErrNone );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::Item
+// See upnplocalitemresolver.h
+//---------------------------------------------------------------------------
+const CUpnpItem& CUPnPLocalItemResolver::Item() const
+    {
+    __ASSERT( iSharedItem, __FILE__, __LINE__ );
+    return *iSharedItem;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::Resource
+// See upnplocalitemresolver.h
+//---------------------------------------------------------------------------
+const CUpnpElement& CUPnPLocalItemResolver::Resource() const
+    {
+    __ASSERT( iResource, __FILE__, __LINE__ );
+    return *iResource;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::Cleanup
+// See upnplocalitemresolver.h
+//---------------------------------------------------------------------------
+void CUPnPLocalItemResolver::Cleanup()
+    {
+    __LOG( "CUPnPLocalItemResolver:Cleanup() ");
+    // unshare
+    TRAP_IGNORE(CUpnpPushServer::UnshareL( (TUint)this ));
+    __LOG( "CUPnPLocalItemResolver:Cleanup() end" );
+    }
+
+// -----------------------------------------------------------------------------
+// CUPnPLocalItemResolver::SetAlbumArtResourceToItemL
+// -----------------------------------------------------------------------------
+//
+void CUPnPLocalItemResolver::SetAlbumArtResourceToItemL( const TDesC& aFileName )
+    {
+    __LOG1( "CUPnPLocalItemResolver:SetAlbumArtResourceToItemL() fileName = %S",&aFileName);
+    RArray<TMPXAttribute> attrs;
+    CleanupClosePushL( attrs );
+    attrs.AppendL( TMPXAttribute( KMPXMediaMusicAlbumArtFileName ) );
+    
+    CMPXMedia* media( NULL );
+    media = iCollectionHelper->GetL( aFileName,
+        attrs.Array(), EMPXSong );
+    CleanupStack::PopAndDestroy( &attrs );
+    CleanupStack::PushL( media );
+    
+    const TDesC& filePath = media->ValueText( KMPXMediaMusicAlbumArtFileName );
+    
+    TInt leaveErr(KErrNone);
+    if( filePath != KNullDesC && filePath.CompareF(aFileName) != KErrNone )
+        {
+        __LOG( "CUPnPLocalItemResolver:SetAlbumArtResourceToItemL() \
+                start waiting album art");
+        TThumbnailDlnaSize size (EThumbnail);
+        iThumbnailCreator = CUpnpThumbnailCreator::NewL(*this,
+                filePath, size);
+        }
+    else
+        {
+        leaveErr = KErrNotFound;
+        }
+    CleanupStack::PopAndDestroy( media );
+    if( leaveErr ) 
+        {
+        User::Leave(leaveErr);
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::ThumbnailCreatorReady
+// See upnplocalitemresolver.h
+//---------------------------------------------------------------------------
+void CUPnPLocalItemResolver::ThumbnailCreatorReady( TInt aError)
+    {
+    __LOG1( "CUPnPLocalItemResolver:ThumbnailCreatorReady() %d",aError);
+    if(aError == KErrNone)
+    	{
+        if( UPnPItemUtility::BelongsToClass(*iLocalItem,KClassAudio()) )
+            {
+            TRAPD(err, AddAlbumArtAndShareL())
+            aError = err;
+            }
+        else
+            {
+            TRAPD(err,AddThumbnailandShareL());    
+            aError = err;
+            }
+    	}
+    //inform the observer
+    iObserver->ResolveComplete( *this, aError );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::AddAlbumArtAndShareL
+//---------------------------------------------------------------------------
+void CUPnPLocalItemResolver::AddAlbumArtAndShareL()
+    {
+    __ASSERT( iLocalItem, __FILE__, __LINE__ );    
+    __LOG( "CUPnPLocalItemResolver:AddAlbumArtAndShareL()");
+    CUpnpElement* albumArtUri = CUpnpElement::NewLC( KElementAlbumArtUri );
+    CUpnpAttribute* attr = CUpnpAttribute::NewLC( KAttributeProfileId() );
+    CUpnpDlnaProfiler* profiler = CUpnpDlnaProfiler::NewLC();
+    
+    HBufC8* profile = NULL;
+    profile = UpnpString::FromUnicodeL(*(profiler->ProfileForFileL( 
+            iThumbnailCreator->ThumbnailFilePath())) ); 
+    
+    CleanupStack::PopAndDestroy( profiler );                  
+    __LOG1( "CUPnPLocalItemResolver:AddAlbumArtAndShareL() \
+            profile=%S",profile);
+    
+    attr->SetValueL(*profile);
+    albumArtUri->AddAttributeL(attr);    
+    CleanupStack::Pop( attr );                  
+
+    albumArtUri->SetFilePathL( iThumbnailCreator->ThumbnailFilePath() );
+
+    iLocalItem->AddElementL( albumArtUri );
+    CleanupStack::Pop( albumArtUri );    
+    
+    // share
+    CUpnpPushServer::ShareL( KFirstSharedHash++, *iLocalItem );	
+    
+    // Store item & resource
+    delete iSharedItem;
+    iSharedItem = NULL;
+    
+    iSharedItem = iLocalItem;
+    iResource = &iSelector.SelectResourceL( *iSharedItem );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPLocalItemResolver::AddThumbnailandShareL
+// See upnplocalitemresolver.h
+//---------------------------------------------------------------------------
+void CUPnPLocalItemResolver::AddThumbnailandShareL()
+    {
+    __ASSERT( iLocalItem, __FILE__, __LINE__ );
+    UpnpCdsResElementUtility::AddResElementL(*iLocalItem,
+                                iThumbnailCreator->ThumbnailFilePath());
+    // share
+    CUpnpPushServer::ShareL( KFirstSharedHash++, *iLocalItem );
+
+    // Store item & resource
+    delete iSharedItem;
+    iSharedItem = NULL;
+    
+    iSharedItem = iLocalItem;
+    iResource = &iSelector.SelectResourceL( *iSharedItem );
+    }
+
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnpremoteitemresolver.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnpremoteitemresolver.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,360 +1,360 @@
-/*
-* Copyright (c) 2007 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:      Resolver for remote items
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// upnp stack api's
-#include <upnpobject.h>
-#include <upnpitem.h>
-#include <upnpcontainer.h>
-#include <upnpelement.h>
-#include <upnpattribute.h>
-#include <upnpdlnaprotocolinfo.h>
-
-// upnpframework / avcontroller api
-#include "upnpavbrowsingsession.h" // browsing session
-
-// upnpframework / avcontroller helper api
-#include "upnpresourceselector.h" // MUPnPResourceSelector
-#include "upnpitemresolverobserver.h" // observer for this class
-#include "upnpitemutility.h" // for ResourceFromItem
-#include "upnpconstantdefs.h" // for browsing param: KSortNone
-
-// upnpframework / xml parser api
-#include "upnpxmlparser.h" // for xml parsing
-
-// avcontrollerhelper internal
-#include "upnpremoteitemresolver.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-
-
-// METHODS
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::NewL
-//---------------------------------------------------------------------------
-CUPnPRemoteItemResolver* CUPnPRemoteItemResolver::NewL(
-    const TDesC8& aItemId,
-    MUPnPAVBrowsingSession& aHostSession,
-    MUPnPResourceSelector& aSelector,
-    const TDesC8& aBrowseFilter )
-    {
-    CUPnPRemoteItemResolver* self = new (ELeave) CUPnPRemoteItemResolver(
-        aItemId, aHostSession, aSelector, aBrowseFilter );
-    CleanupStack::PushL( self );
-    self->ConstructL( aItemId, aHostSession, aSelector, aBrowseFilter );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::CUPnPRemoteItemResolver
-//---------------------------------------------------------------------------
-CUPnPRemoteItemResolver::CUPnPRemoteItemResolver(
-    const TDesC8& /*aItemId*/,
-    MUPnPAVBrowsingSession& aHostSession,
-    MUPnPResourceSelector& aSelector,
-    const TDesC8& aBrowseFilter )
-    : CUPnPAbstractBrowsingSessionObserver()
-    , iBrowsingSession( aHostSession )
-    , iSelector( aSelector )
-    , iBrowseFilter( aBrowseFilter )
-    {
-    iState = EStateIdle;
-    SetSession( aHostSession );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::ConstructL
-//---------------------------------------------------------------------------
-void CUPnPRemoteItemResolver::ConstructL(
-    const TDesC8& aItemId,
-    MUPnPAVBrowsingSession& /*aHostSession*/,
-    MUPnPResourceSelector& /*aSelector*/,
-    const TDesC8& /*aBrowseFilter*/ )
-    {
-    iItemId = aItemId.AllocL();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::~CUPnPRemoteItemResolver
-//---------------------------------------------------------------------------
-CUPnPRemoteItemResolver::~CUPnPRemoteItemResolver()
-    {
-    Cleanup();
-    delete iItemId;
-    iItemId = 0;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::ResolveL
-//---------------------------------------------------------------------------
-void CUPnPRemoteItemResolver::ResolveL(
-    MUPnPItemResolverObserver& aObserver )
-    {
-    __LOG( "RemoteItemResolver:Resolve()" );
-    __ASSERTD( iState == EStateIdle, __FILE__, __LINE__ );
-
-    // enable receiving callbacks here
-    EnableSessionObserver();
-
-    // change state
-    iObserver = &aObserver;
-    iState = EStateActive;
-
-    iRecursionDepth = 0;
-
-    iBrowsingSession.BrowseL(
-        iItemId->Des(), iBrowseFilter,
-        MUPnPAVBrowsingSession::EMetadata,
-        0, 1, KSortNone );
-
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::Item
-//---------------------------------------------------------------------------
-const CUpnpItem& CUPnPRemoteItemResolver::Item() const
-    {
-    __LOG( "RemoteItemResolver:item" );
-    __ASSERTD( iState == EStateReady, __FILE__, __LINE__ );
-    __ASSERTD( iFirstLevelItem, __FILE__, __LINE__ );
-
-    return *iFirstLevelItem;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::Resource
-//---------------------------------------------------------------------------
-const CUpnpElement& CUPnPRemoteItemResolver::Resource() const
-    {
-    __LOG( "RemoteItemResolver:Resource" );
-    __ASSERTD( iState == EStateReady, __FILE__, __LINE__ );
-    __ASSERTD( iResource, __FILE__, __LINE__ );
-
-    return *iResource;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::BrowseResponse
-//---------------------------------------------------------------------------
-void CUPnPRemoteItemResolver::BrowseResponse(
-    const TDesC8& aBrowseResponse,
-    TInt aError,
-    TInt /*aMatches*/,
-    TInt /*aTotalCount*/,
-    const TDesC8& /*aUpdateId*/ )
-    {
-    __ASSERTD( iState == EStateActive, __FILE__, __LINE__ );
-    __LOG1( "RemoteItemResolver:BrowseResponse(%d)", aError );
-
-    // If the browse succeeded, parse the response and process the result
-    if ( aError == KErrNone )
-        {
-        TRAP( aError, BrowseResponseL( aBrowseResponse ) );
-        }
-
-    // It the browse failed, or the parsing/processging of the response
-    // failed, do complete.
-    if( aError != KErrNone )
-        {
-        Complete( aError );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::BrowseResponseL
-//---------------------------------------------------------------------------
-//
-void CUPnPRemoteItemResolver::BrowseResponseL( const TDesC8& aBrowseResponse )
-    {
-    __LOG( "RemoteItemResolver:BrowseResponseL" );
-
-    // Status code
-    TInt status = KErrNone;
-
-    // Result array
-    RPointerArray<CUpnpObject> array;
-
-    // Create parser
-    CUPnPXMLParser* parser = NULL;
-    TRAP( status, parser = CUPnPXMLParser::NewL() );
-
-    // If the parser was created succesfully...
-    if( status == KErrNone )
-        {
-        CleanupStack::PushL( parser );
-
-        // Parse the result data, and process the result object
-        TRAP( status,
-              parser->ParseResultDataL( array, aBrowseResponse );
-              if(array.Count()!= 0 )
-            	  ProcessResultObjectL( array[0] );
-              else
-            	  {
-            	  //handle error no object
-            	  Complete( KErrNotFound );
-            	  }
-            );
-
-        // Clean up
-        CleanupStack::PopAndDestroy( parser );
-        parser = NULL;
-        }
-
-    // Empty, reset and close the array
-    for( TInt i=0; i<array.Count(); i++ )
-        {
-        delete array[i];
-        }
-    array.Reset();
-    array.Close();
-
-    // If there was an error, forward the leave
-    if( status != KErrNone )
-        {
-        User::Leave( status );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::ProcessResultObjectL
-//---------------------------------------------------------------------------
-void CUPnPRemoteItemResolver::ProcessResultObjectL(
-    const CUpnpObject* aResult )
-    {
-  /*  if ( aResult->ObjectType() != EUPnPItem )
-        {
-        User::Leave( KErrArgument );
-        }
-
-    // copy the item
-    CUpnpItem* item = CUpnpItem::NewL();
-    CleanupStack::PushL( item );
-    item->CopyL( *aResult );
-
-    // select the resource
-    __LOG( "RemoteItemResolver:calling SelectResource" );
-    const CUpnpElement& res =
-        iSelector.SelectResourceL( *item );
-
-    if ( iRecursionDepth == 0 )
-        {
-        __ASSERTD( !iFirstLevelItem, __FILE__, __LINE__ );
-        CleanupStack::Pop( item );
-        iFirstLevelItem = item;
-        item = 0; // take ownership
-        }
-
-    HBufC8* recurringId = 0;
-
-
-    if ( recurringId )
-        {
-        // continue recursion !
-        ++iRecursionDepth;
-        __LOG1( "RemoteItemResolver:ProcessResult - recur %d",
-            iRecursionDepth );
-        iBrowsingSession.BrowseL(
-            recurringId->Des(), iBrowseFilter, 
-            MUPnPAVBrowsingSession::EMetadata,
-            0, 1, KSortNone );
-        CleanupStack::PopAndDestroy( recurringId );
-        }
-    else
-        {
-        // finished browsing the item
-        __ASSERTD( !iLastLevelItem, __FILE__, __LINE__ );
-        __LOG( "RemoteItemResolver:ProcessResult - finished" );
-        if ( iRecursionDepth > 0 )
-            {
-            // pointed object is DIFFERENT from first level object
-            iLastLevelItem = CUpnpItem::NewL();
-            iLastLevelItem->CopyL( *item );
-            }
-        iResource = &res;
-        Complete( KErrNone );
-        }
-
-    if( item )
-        {
-        CleanupStack::PopAndDestroy( item );
-        }*/
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::Complete
-//---------------------------------------------------------------------------
-void CUPnPRemoteItemResolver::Complete( TInt aError )
-    {
-    __ASSERTD( iState == EStateActive, __FILE__, __LINE__ );
-
-    DisableSessionObserver();
-    MUPnPItemResolverObserver& observer = *iObserver;
-    iObserver = 0;
-    if ( aError == KErrNone )
-        {
-        iState = EStateReady;
-        }
-    else
-        {
-        iState = EStateIdle;
-        Cleanup();
-        }
-
-    observer.ResolveComplete( *this, aError );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPRemoteItemResolver::Cleanup
-//---------------------------------------------------------------------------
-void CUPnPRemoteItemResolver::Cleanup()
-    {
-    DisableSessionObserver();
-
-    if ( iState == EStateActive )
-        {
-        iBrowsingSession.CancelBrowse();
-        }
-
-    iObserver = 0;
-
-    delete iFirstLevelItem;
-    iFirstLevelItem = 0;
-
-    delete iLastLevelItem;
-    iLastLevelItem = 0;
-
-    iResource = 0;
-
-    iState = EStateIdle;
-    }
-
-
+/*
+* Copyright (c) 2007 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:      Resolver for remote items
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// dlnasrv / mediaserver api
+#include <upnpobject.h>
+#include <upnpitem.h>
+#include <upnpcontainer.h>
+#include <upnpelement.h>
+#include <upnpattribute.h>
+#include <upnpdlnaprotocolinfo.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavbrowsingsession.h" // browsing session
+
+// dlnasrv / avcontroller helper api
+#include "upnpresourceselector.h" // MUPnPResourceSelector
+#include "upnpitemresolverobserver.h" // observer for this class
+#include "upnpitemutility.h" // for ResourceFromItem
+#include "upnpconstantdefs.h" // for browsing param: KSortNone
+
+// dlnasrv / xmlparser api
+#include "upnpxmlparser.h" // for xml parsing
+
+// dlnasrv / avcontroller helper internal
+#include "upnpremoteitemresolver.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerhelper.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+
+
+// METHODS
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::NewL
+//---------------------------------------------------------------------------
+CUPnPRemoteItemResolver* CUPnPRemoteItemResolver::NewL(
+    const TDesC8& aItemId,
+    MUPnPAVBrowsingSession& aHostSession,
+    MUPnPResourceSelector& aSelector,
+    const TDesC8& aBrowseFilter )
+    {
+    CUPnPRemoteItemResolver* self = new (ELeave) CUPnPRemoteItemResolver(
+        aItemId, aHostSession, aSelector, aBrowseFilter );
+    CleanupStack::PushL( self );
+    self->ConstructL( aItemId, aHostSession, aSelector, aBrowseFilter );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::CUPnPRemoteItemResolver
+//---------------------------------------------------------------------------
+CUPnPRemoteItemResolver::CUPnPRemoteItemResolver(
+    const TDesC8& /*aItemId*/,
+    MUPnPAVBrowsingSession& aHostSession,
+    MUPnPResourceSelector& aSelector,
+    const TDesC8& aBrowseFilter )
+    : CUPnPAbstractBrowsingSessionObserver()
+    , iBrowsingSession( aHostSession )
+    , iSelector( aSelector )
+    , iBrowseFilter( aBrowseFilter )
+    {
+    iState = EStateIdle;
+    SetSession( aHostSession );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::ConstructL
+//---------------------------------------------------------------------------
+void CUPnPRemoteItemResolver::ConstructL(
+    const TDesC8& aItemId,
+    MUPnPAVBrowsingSession& /*aHostSession*/,
+    MUPnPResourceSelector& /*aSelector*/,
+    const TDesC8& /*aBrowseFilter*/ )
+    {
+    iItemId = aItemId.AllocL();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::~CUPnPRemoteItemResolver
+//---------------------------------------------------------------------------
+CUPnPRemoteItemResolver::~CUPnPRemoteItemResolver()
+    {
+    Cleanup();
+    delete iItemId;
+    iItemId = 0;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::ResolveL
+//---------------------------------------------------------------------------
+void CUPnPRemoteItemResolver::ResolveL(
+    MUPnPItemResolverObserver& aObserver, CUpnpAVDevice* /*aDevice*/ )
+    {
+    __LOG( "RemoteItemResolver:Resolve()" );
+    __ASSERTD( iState == EStateIdle, __FILE__, __LINE__ );
+
+    // enable receiving callbacks here
+    EnableSessionObserver();
+
+    // change state
+    iObserver = &aObserver;
+    iState = EStateActive;
+
+    iRecursionDepth = 0;
+
+    iBrowsingSession.BrowseL(
+        iItemId->Des(), iBrowseFilter,
+        MUPnPAVBrowsingSession::EMetadata,
+        0, 1, KSortNone );
+
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::Item
+//---------------------------------------------------------------------------
+const CUpnpItem& CUPnPRemoteItemResolver::Item() const
+    {
+    __LOG( "RemoteItemResolver:item" );
+    __ASSERTD( iState == EStateReady, __FILE__, __LINE__ );
+    __ASSERTD( iFirstLevelItem, __FILE__, __LINE__ );
+
+    return *iFirstLevelItem;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::Resource
+//---------------------------------------------------------------------------
+const CUpnpElement& CUPnPRemoteItemResolver::Resource() const
+    {
+    __LOG( "RemoteItemResolver:Resource" );
+    __ASSERTD( iState == EStateReady, __FILE__, __LINE__ );
+    __ASSERTD( iResource, __FILE__, __LINE__ );
+
+    return *iResource;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::BrowseResponse
+//---------------------------------------------------------------------------
+void CUPnPRemoteItemResolver::BrowseResponse(
+    const TDesC8& aBrowseResponse,
+    TInt aError,
+    TInt /*aMatches*/,
+    TInt /*aTotalCount*/,
+    const TDesC8& /*aUpdateId*/ )
+    {
+    __ASSERTD( iState == EStateActive, __FILE__, __LINE__ );
+    __LOG1( "RemoteItemResolver:BrowseResponse(%d)", aError );
+
+    // If the browse succeeded, parse the response and process the result
+    if ( aError == KErrNone )
+        {
+        TRAP( aError, BrowseResponseL( aBrowseResponse ) );
+        }
+
+    // It the browse failed, or the parsing/processging of the response
+    // failed, do complete.
+    if( aError != KErrNone )
+        {
+        Complete( aError );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::BrowseResponseL
+//---------------------------------------------------------------------------
+//
+void CUPnPRemoteItemResolver::BrowseResponseL( const TDesC8& aBrowseResponse )
+    {
+    __LOG( "RemoteItemResolver:BrowseResponseL" );
+
+    // Status code
+    TInt status = KErrNone;
+
+    // Result array
+    RPointerArray<CUpnpObject> array;
+
+    // Create parser
+    CUPnPXMLParser* parser = NULL;
+    TRAP( status, parser = CUPnPXMLParser::NewL() );
+
+    // If the parser was created succesfully...
+    if( status == KErrNone )
+        {
+        CleanupStack::PushL( parser );
+
+        // Parse the result data, and process the result object
+        TRAP( status,
+              parser->ParseResultDataL( array, aBrowseResponse );
+              if(array.Count()!= 0 )
+            	  ProcessResultObjectL( array[0] );
+              else
+            	  {
+            	  //handle error no object
+            	  Complete( KErrNotFound );
+            	  }
+            );
+
+        // Clean up
+        CleanupStack::PopAndDestroy( parser );
+        parser = NULL;
+        }
+
+    // Empty, reset and close the array
+    for( TInt i=0; i<array.Count(); i++ )
+        {
+        delete array[i];
+        }
+    array.Reset();
+    array.Close();
+
+    // If there was an error, forward the leave
+    if( status != KErrNone )
+        {
+        User::Leave( status );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::ProcessResultObjectL
+//---------------------------------------------------------------------------
+void CUPnPRemoteItemResolver::ProcessResultObjectL(
+    const CUpnpObject* aResult )
+    {
+    if ( aResult->ObjectType() != EUPnPItem )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // copy the item
+    CUpnpItem* item = CUpnpItem::NewL();
+    CleanupStack::PushL( item );
+    item->CopyL( *aResult );
+
+    // select the resource
+    __LOG( "RemoteItemResolver:calling SelectResource" );
+    const CUpnpElement& res =
+        iSelector.SelectResourceL( *item );
+
+    if ( iRecursionDepth == 0 )
+        {
+        __ASSERTD( !iFirstLevelItem, __FILE__, __LINE__ );
+        CleanupStack::Pop( item );
+        iFirstLevelItem = item;
+        item = 0; // take ownership
+        }
+
+    HBufC8* recurringId = 0;
+
+
+    if ( recurringId )
+        {
+        // continue recursion !
+        ++iRecursionDepth;
+        __LOG1( "RemoteItemResolver:ProcessResult - recur %d",
+            iRecursionDepth );
+        iBrowsingSession.BrowseL(
+            recurringId->Des(), iBrowseFilter, 
+            MUPnPAVBrowsingSession::EMetadata,
+            0, 1, KSortNone );
+        CleanupStack::PopAndDestroy( recurringId );
+        }
+    else
+        {
+        // finished browsing the item
+        __ASSERTD( !iLastLevelItem, __FILE__, __LINE__ );
+        __LOG( "RemoteItemResolver:ProcessResult - finished" );
+        if ( iRecursionDepth > 0 )
+            {
+            // pointed object is DIFFERENT from first level object
+            iLastLevelItem = CUpnpItem::NewL();
+            iLastLevelItem->CopyL( *item );
+            }
+        iResource = &res;
+        Complete( KErrNone );
+        }
+
+    if( item )
+        {
+        CleanupStack::PopAndDestroy( item );
+        }
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::Complete
+//---------------------------------------------------------------------------
+void CUPnPRemoteItemResolver::Complete( TInt aError )
+    {
+    __ASSERTD( iState == EStateActive, __FILE__, __LINE__ );
+
+    DisableSessionObserver();
+    MUPnPItemResolverObserver& observer = *iObserver;
+    iObserver = 0;
+    if ( aError == KErrNone )
+        {
+        iState = EStateReady;
+        }
+    else
+        {
+        iState = EStateIdle;
+        Cleanup();
+        }
+
+    observer.ResolveComplete( *this, aError );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPRemoteItemResolver::Cleanup
+//---------------------------------------------------------------------------
+void CUPnPRemoteItemResolver::Cleanup()
+    {
+    DisableSessionObserver();
+
+    if ( iState == EStateActive )
+        {
+        iBrowsingSession.CancelBrowse();
+        }
+
+    iObserver = 0;
+
+    delete iFirstLevelItem;
+    iFirstLevelItem = 0;
+
+    delete iLastLevelItem;
+    iLastLevelItem = 0;
+
+    iResource = 0;
+
+    iState = EStateIdle;
+    }
+
+
--- a/upnpavcontroller/upnpavcontrollerhelper/src/upnpresourceselector.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerhelper/src/upnpresourceselector.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,67 +1,68 @@
-/*
-* Copyright (c) 2007 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:      Interface for selecting a resource within an item
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-#include <upnpitem.h>
-#include "upnpelement.h"
-
-// upnpframework / avcontroller helper api
-#include "upnpitemutility.h" // ResourceFromItemL, GetResElements
-#include "upnpconstantdefs.h" // KElementRes
-#include "upnpresourceselector.h"
-
-
-
-
-
-
-// ==========================================================================
-// METHODS for TUPnPSelectDefaultResource
-// ==========================================================================
-
-// --------------------------------------------------------------------------
-// TUPnPSelectDefaultResource::SelectResourceL
-// this algorithm works BEST
-//---------------------------------------------------------------------------
-EXPORT_C const CUpnpElement& TUPnPSelectDefaultResource::
-    SelectResourceL(
-    const CUpnpItem& aItem )
-    {
-    return UPnPItemUtility::ResourceFromItemL( aItem );
-    }
-
-
-// ==========================================================================
-// METHODS for TUPnPSelectFirstResource
-// ==========================================================================
-
-// --------------------------------------------------------------------------
-// TUPnPSelectFirstResource::SelectResourceL
-// this algorithm works FAST
-//---------------------------------------------------------------------------
-EXPORT_C const CUpnpElement& TUPnPSelectFirstResource::
-    SelectResourceL(
-    const CUpnpItem& aItem )
-    {
-    return UPnPItemUtility::FindElementByNameL( aItem, KElementRes );
-    }
-
+/*
+* Copyright (c) 2007 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:      Interface for selecting a resource within an item
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// dlnasrv / mediaserver api
+#include <upnpitem.h>
+#include <upnpelement.h>
+
+// dlnasrv / avcontroller helper api
+#include "upnpitemutility.h" // ResourceFromItemL, GetResElements
+#include "upnpconstantdefs.h" // KElementRes
+#include "upnpresourceselector.h"
+
+
+
+
+
+
+// ==========================================================================
+// METHODS for TUPnPSelectDefaultResource
+// ==========================================================================
+
+// --------------------------------------------------------------------------
+// TUPnPSelectDefaultResource::SelectResourceL
+// this algorithm works BEST
+//---------------------------------------------------------------------------
+EXPORT_C const CUpnpElement& TUPnPSelectDefaultResource::
+    SelectResourceL(
+    const CUpnpItem& aItem )
+    {
+    return UPnPItemUtility::ResourceFromItemL( aItem );
+    }
+
+
+// ==========================================================================
+// METHODS for TUPnPSelectFirstResource
+// ==========================================================================
+
+// --------------------------------------------------------------------------
+// TUPnPSelectFirstResource::SelectResourceL
+// this algorithm works FAST
+//---------------------------------------------------------------------------
+EXPORT_C const CUpnpElement& TUPnPSelectFirstResource::
+    SelectResourceL(
+    const CUpnpItem& aItem )
+    {
+    return UPnPItemUtility::FindElementByNameL( aItem, KElementRes );
+    }
+
--- a/upnpavcontroller/upnpavcontrollerserver/group/upnpavcontrollerserver.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/group/upnpavcontrollerserver.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,87 +1,88 @@
-/*
-* Copyright (c) 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:      project file for AVController server library
-*
-*/
-
-
-
-
-
-#include "../../../group/upnpplatformvar.hrh"
-
-TARGET          upnpavcontrollerserver.exe
-TARGETTYPE      exe
-CAPABILITY      CAP_SERVER
-VENDORID        VID_DEFAULT
-UID             0x1000008d 0x20007566
-
-VERSION         10.1
-paged
-
-EPOCHEAPSIZE    4096 2097152 // 4K / 2M
-
-SOURCEPATH      ../src
-SOURCE          upnpavcontrollerserver.cpp
-SOURCE          upnpavcontrollersession.cpp
-SOURCE          upnpavdispatcher.cpp
-SOURCE          upnpavactioninfo.cpp
-SOURCE          upnpavcontrollerimpl.cpp
-SOURCE          upnpplaybacksession.cpp
-SOURCE          upnpfilesharingactive.cpp
-SOURCE          upnpbrowsingsession.cpp
-SOURCE          upnpaverrorhandler.cpp
-SOURCE          upnpavtimer.cpp
-SOURCE          upnpdevicerepository.cpp
-SOURCE          upnpavdeviceextended.cpp
-SOURCE          upnpdevicediscoverymessage.cpp
-SOURCE          upnpdownloadsession.cpp
-SOURCE          upnpuploadsession.cpp
-SOURCE          upnpfiletransfersessionbase.cpp
-SOURCE          upnpresourcehelper.cpp
-
-MW_LAYER_SYSTEMINCLUDE
-USERINCLUDE   ../../../inc
-
-USERINCLUDE     ../inc
-USERINCLUDE     ../../inc
-USERINCLUDE     ../../upnpavcontrollerclient/inc
-
-// system
-LIBRARY         euser.lib 
-LIBRARY         efsrv.lib
-LIBRARY         estor.lib
-LIBRARY         insock.lib
-LIBRARY         centralrepository.lib
-LIBRARY         charconv.lib
-
-// upnp stack
-LIBRARY         avmediaserverclient.lib
-LIBRARY         upnpserviceframework.lib
-LIBRARY         upnpcontrolpointbase.lib
-LIBRARY         upnpavobjects.lib
-LIBRARY         upnpipserversutils.lib
-LIBRARY         avcontrolframework.lib
-
-// UPnP framework
-LIBRARY         upnpavcontrollerclient.lib
-LIBRARY         upnpavcontrollerhelper.lib
-LIBRARY         upnpxmlparser.lib
-LIBRARY         upnputilities.lib
-LIBRARY         upnpsecurity.lib
-LIBRARY         httptransfer.lib
-
-DEBUGLIBRARY    flogger.lib
-
-// End of file
+/*
+* Copyright (c) 2006-2009 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:      project file for AVController server library
+*
+*/
+
+
+
+
+
+#include "../../../group/upnpplatformvar.hrh"
+
+TARGET          upnpavcontrollerserver.exe
+TARGETTYPE      exe
+CAPABILITY      CAP_SERVER
+VENDORID        VID_DEFAULT
+UID             0x1000008d 0x20007566
+
+VERSION         10.1
+paged
+
+EPOCHEAPSIZE    4096 2097152 // 4K / 2M
+
+SOURCEPATH      ../src
+SOURCE          upnpavcontrollerserver.cpp
+SOURCE          upnpavcontrollersession.cpp
+SOURCE          upnpavdispatcher.cpp
+SOURCE          upnpavactioninfo.cpp
+SOURCE          upnpavcontrollerimpl.cpp
+SOURCE          upnpplaybacksession.cpp
+SOURCE          upnpbrowsingsession.cpp
+SOURCE          upnpaverrorhandler.cpp
+SOURCE          upnpavtimer.cpp
+SOURCE          upnpdevicerepository.cpp
+SOURCE          upnpavdeviceextended.cpp
+SOURCE          upnpdevicediscoverymessage.cpp
+SOURCE          upnpdownloadsession.cpp
+SOURCE          upnpuploadsession.cpp
+SOURCE          upnpfiletransfersessionbase.cpp
+SOURCE          upnpresourcehelper.cpp
+SOURCE          upnpavcontrolpoint.cpp
+SOURCE          upnpdeviceicondownloader.cpp
+
+MW_LAYER_SYSTEMINCLUDE
+USERINCLUDE   ../../../inc
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+USERINCLUDE     ../../upnpavcontrollerclient/inc
+
+// system
+LIBRARY         euser.lib 
+LIBRARY         efsrv.lib
+LIBRARY         estor.lib
+LIBRARY         bafl.lib
+LIBRARY         insock.lib
+LIBRARY         esock.lib
+LIBRARY         sysutil.lib
+
+// upnp stack
+LIBRARY         upnpserviceframework.lib
+LIBRARY         upnpcontrolpointbase.lib
+LIBRARY         upnpipserversutils.lib
+
+// dlnasrv
+LIBRARY         avmediaserverclient.lib
+LIBRARY         upnpavobjects.lib
+LIBRARY         upnpavcontrollerclient.lib
+LIBRARY         upnpavcontrollerhelper.lib
+LIBRARY         upnpxmlparser.lib
+LIBRARY         upnputilities.lib
+LIBRARY         upnpconnmon.lib
+LIBRARY         httptransfer.lib
+
+DEBUGLIBRARY    flogger.lib
+
+// End of file
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpavcontrollerimpl.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpavcontrollerimpl.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,547 +1,653 @@
-/*
-* Copyright (c) 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:      AV Controller Implementation
-*
-*/
-
-
-
-
-
-
-
-#ifndef C_UPNPAVCONTROLLERIMPL_H
-#define C_UPNPAVCONTROLLERIMPL_H
-
-// INDLUDE FILES
-#include <e32base.h>
-#include <upnpavcontrolpointobserver.h>
-#include <upnpmediaserverclient.h>
-#include "upnpavcontrollerglobals.h"
-#include "upnpconnectionmonitorobserver.h"
-
-// FORWARD DECLARATIONS
-class MUPnPAVDeviceObserver;
-class MUPnPAVMediaObserver;
-class MUPnPAVFileObserver;
-class CUPnPPlaybackSession;
-class CUpnpAVControllerServer;
-class CUpnpAVDevice;
-class CUpnpHttpMessage;
-class CUpnpDevice;
-class CUpnpAVDeviceExtended;
-class CUPnPBrowsingSession;
-class CUpnpDeviceDiscoveryMessage;
-
-class CUPnPUploadSession;
-class CUPnPDownloadSession;
-
-/**
- *  AV Controller server side implementation. Impmements the base session. 
- *  Rendering and browsing sessions are created from this session.
- *  Handles device discovery and fetching of device listst.
- *
- *  @lib upnpavcontrollerclient.lib
- *  @since S60 v3.1
- */
-class CUPnPAVControllerImpl :   public CBase,
-                                public MUPnPConnectionMonitorObserver
-                                
-    {
-
-public:
-
-    /**
-     * Two-phased constructor.
-     *
-     * @param aControlPoint control point reference
-     * @param aClient media server client reference
-     * @param aDispatcher callback dispatcher reference
-     * @param aServer server class reference
-     */
-    static CUPnPAVControllerImpl* NewL
-        (
-        RUpnpMediaServerClient& aClient,
-        CUpnpAVControllerServer& aServer
-        );
-    
-    /**
-     * Destructor
-     */
-    virtual ~CUPnPAVControllerImpl();
-    
-private:
-
-    /**
-     * Private constructor
-     *
-     * @param aControlPoint control point reference
-     * @param aClient media server client reference
-     * @param aDispatcher callback dispatcher reference
-     * @param aServer server class reference          
-     */
-    CUPnPAVControllerImpl
-    (
-    RUpnpMediaServerClient& aClient,
-    CUpnpAVControllerServer& aServer
-    );    
-    
-    /**
-     * Destructor
-     */
-    void ConstructL();    
-
-public: // From MUPnPConnectionMonitorObserver
-    
-    /**
-     * See upnpconnectionmonitorobserver.h
-     */
-    void ConnectionLost();
-    
-public: // New functions
-
-    /**
-     * Handles UPnP device discoveries.
-     * @since Series 60 2.6
-     * @param aDevice Device that is discovered.
-     */
-    void DeviceDiscoveredL( CUpnpAVDeviceExtended& aDevice );
-
-    /**
-     * Handles UPnP device disappears.
-     * @since Series 60 2.6
-     * @param aDevice Device that disappeared.
-     */
-    void DeviceDisappearedL( CUpnpAVDeviceExtended& aDevice );
-    
-
-    /**
-     * Enables device discovery by storing a message to server side, which
-     * is completed when a device has been discovered.
-     *
-     * @param aMessage message
-     */
-    void EnableDeviceDiscoveryL( const RMessage2& aMessage );
-        
-    /**
-     * Disables (cancels) device discovery (and message).
-     */
-    void DisableDeviceDiscoveryL();
-    
-    /**
-     * Returns a discovered/disappeared device to client side.
-     *
-     * @param aMessage message
-     */
-    void GetDeviceL( const RMessage2& aMessage );
-    
-    /**
-     * Returns the size of device list to client side.
-     *
-     * @param aMessage message
-     */
-    void GetDeviceListSizeL( const RMessage2& aMessage );
-    
-    /**
-     * Returns the device list to client side.
-     *
-     * @param aMessage message
-     */
-    void GetDeviceListL( const RMessage2& aMessage );
-    
-    /**
-     * Creates a rendering session.
-     *
-     * @param aMessage message
-     */
-    void CreateRenderingSessionL( const RMessage2& aMessage );
-    
-    /**
-     * Destroys a rendering session
-     *
-     * @param aMessage message
-     */
-    void DestroyRenderingSessionL( const RMessage2& aMessage );
-    
-    /**
-     * Enables (unsolicited) eventing from a remote device. Stores
-     * the message in to redering session to return an event.
-     *
-     * @param aMessage message
-     */
-    void EventRequestL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels eventing message.
-     *
-     * @param aMessage message
-     */
-    void CancelEventRequestL( const RMessage2& aMessage );
-    
-    /**
-     * Sets URI
-     *
-     * @param aMessage message
-     */
-    void SetURIL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels SetURI (basically just ignores the result)
-     *
-     * @param aMessage message
-     */
-    void CancelSetURIL( const RMessage2& aMessage );
-    
-    /**
-     * Sets Next URI
-     *
-     * @param aMessage message
-     */
-    void SetNextURIL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels SetNextURI (basically just ignores the result)
-     *
-     * @param aMessage message
-     */
-    void CancelSetNextURIL( const RMessage2& aMessage );
-    
-    /**
-     * Send the play-action
-     *
-     * @param aMessage message
-     */
-    void PlayL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels the play-action (basically just ignores the result)
-     *
-     * @param aMessage message
-     */
-    void CancelPlayL( const RMessage2& aMessage );
-
-    /**
-     * Send the stop-action
-     *
-     * @param aMessage message
-     */
-    void StopL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels stop (basically just ignores the result)
-     *
-     * @param aMessage message
-     */
-    void CancelStopL( const RMessage2& aMessage );
-
-    /**
-     * Send the pause-action
-     *
-     * @param aMessage message
-     */
-    void PauseL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels pause (basically just ignores the result)
-     *
-     * @param aMessage message
-     */
-    void CancelPauseL( const RMessage2& aMessage );
-
-    /**
-     * Send the setvolume-action
-     *
-     * @param aMessage message
-     */
-    void SetVolumeL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels setvolume (basically just ignores the result)
-     *
-     * @param aMessage message
-     */
-    void CancelSetVolumeL( const RMessage2& aMessage );
-    
-    /**
-     * Send the getvolume-action
-     *
-     * @param aMessage message
-     */
-    void GetVolumeL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels getvolume (basically just ignores the result)
-     *
-     * @param aMessage message
-     */
-    void CancelGetVolumeL( const RMessage2& aMessage );
-    
-    /**
-     * Send the setmute-action
-     *
-     * @param aMessage message
-     */
-    void SetMuteL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels setmute (basically just ignores the result)
-     *
-     * @param aMessage message
-     */
-    void CancelSetMuteL( const RMessage2& aMessage );
-    
-    /**
-     * Send the getmute-action
-     *
-     * @param aMessage message
-     */
-    void GetMuteL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels getmute (basically just ignores the result)
-     *
-     * @param aMessage message
-     */
-    void CancelGetMuteL( const RMessage2& aMessage );
-    
-    /**
-     * Send the getpositioninfo-action
-     *
-     * @param aMessage message
-     */
-    void GetPositionInfoL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels getpositioninfo (basically just ignores the result)
-     *
-     * @param aMessage message
-     */
-    void CancelGetPositionInfoL( const RMessage2& aMessage );
-    
-    /**
-     * Create a browsing session
-     *
-     * @param aMessage message
-     */
-    void CreateBrowsingSessionL( const RMessage2& aMessage );
-    
-    /**
-     * Destroy a browsing session
-     *
-     * @param aMessage message
-     */
-    void DestroyBrowsingSessionL( const RMessage2& aMessage );
-    
-    /**
-     * Get browse response (return the size of it to client side)
-     *
-     * @param aMessage message
-     */
-    void GetBrowseResponseSizeL( const RMessage2& aMessage );  
-
-    /**
-     * Cancel get browse response (ignore result)
-     *
-     * @param aMessage message
-     */
-    void CancelGetBrowseResponseSizeL( const RMessage2& aMessage );
-
-    /**
-     * Return browse response to client side
-     *
-     * @param aMessage message
-     */
-    void GetBrowseResponseL( const RMessage2& aMessage );
-
-    /**
-     * Get search response (return the size of it to client side)
-     *
-     * @param aMessage message
-     */
-    void GetSearchResponseSizeL( const RMessage2& aMessage );
-
-    /**
-     * Cancel search response (ignore result)
-     *
-     * @param aMessage message
-     */
-    void CancelGetSearchResponseSizeL( const RMessage2& aMessage );
-
-    /**
-     * Return search response to client side
-     *
-     * @param aMessage message
-     */
-    void GetSearchResponseL( const RMessage2& aMessage );
-    
-    /**
-     * Get search capabilities (return the size of it to client side)
-     *
-     * @param aMessage message
-     */
-    void GetSearchCapabitiesSizeL( const RMessage2& aMessage );
-    
-    /**
-     * Cancel get search capabilities (ignore result)
-     *
-     * @param aMessage message
-     */
-    void CancelGetSearchCapabitiesSizeL( const RMessage2& aMessage );
-    
-    /**
-     * Return search capabilities to client side
-     *
-     * @param aMessage message
-     */
-    void GetSearchCapabitiesL( const RMessage2& aMessage );
-
-    /**
-     * Create container action.
-     *
-     * @param aMessage message
-     */
-    void CreateContainerL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels create container.
-     *
-     * @param aMessage message
-     */
-    void CancelCreateContainerL( const RMessage2& aMessage );
-    
-    /**
-     * Delete object action
-     *
-     * @param aMessage message
-     */
-    void DeleteObjectL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels delete object
-     *
-     * @param aMessage message
-     */
-    void CancelDeleteObjectL( const RMessage2& aMessage );
-
-    /**
-     * Stores a message in to rendering or browsing session, which is
-     * completed when the session specific device has disappeared. As a
-     * result the client knows that the device is no longer available and
-     * the session has became absolete.
-     *
-     * @param aMessage message
-     */
-    void DeviceDisappearedRequestL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels the msg.
-     *
-     * @param aMessage message
-     */
-    void CancelDeviceDisappearedRequestL( const RMessage2& aMessage );
-    
-    /**
-     * Stores a message in to base session, which is completed when the
-     * WLAN is disconnected.
-     *
-     * @param aMessage message
-     */
-    void MonitorConnectionL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels the msg.
-     *
-     * @param aMessage message
-     */
-    void CancelMonitorConnectionL( const RMessage2& aMessage );
-
-    void CreateDownloadSessionL( const RMessage2& aMessage );
-    
-    void DestroyDownloadSessionL( const RMessage2& aMessage );
-
-    void StartDownloadL( const RMessage2& aMessage );
-    
-    void StartDownloadFHL( const RMessage2& aMessage );
-    
-    void CancelDownloadL( const RMessage2& aMessage );
-
-    void CancelAllDownloadsL( const RMessage2& aMessage );
-    
-    void StartTrackingDownloadProgressL( const RMessage2& aMessage );
-
-    void StopTrackingDownloadProgressL( const RMessage2& aMessage );
-
-    void GetDownloadEventL( const RMessage2& aMessage );
-    
-    void CancelGetDownloadEventL( const RMessage2& aMessage );
-
-    void CreateUploadSessionL( const RMessage2& aMessage );
-    
-    void DestroyUploadSessionL( const RMessage2& aMessage );    
-
-    void StartUploadL( const RMessage2& aMessage );
-    
-    void CancelUploadL( const RMessage2& aMessage );
-
-    void CancelAllUploadsL( const RMessage2& aMessage );
-    
-    void StartTrackingUploadProgressL( const RMessage2& aMessage );
-
-    void StopTrackingUploadProgressL( const RMessage2& aMessage );
-
-    void GetUploadEventL( const RMessage2& aMessage );
-    
-    void CancelGetUploadEventL( const RMessage2& aMessage );
-
-private:
-
-    /**
-     * Device queu handling. Checks the queu and dequeus it if needed.
-     *
-     * @param aDevice av device
-     * @param aType discovered/disappeared
-     */
-    void DequeDeviceL( const CUpnpAVDevice& aDevice,
-        TAVControllerDeviceDiscovery aType );
-
-private:
-    
-    RUpnpMediaServerClient&     iMediaServer; // Not own       
-    
-    CUpnpAVControllerServer&    iServer; // Not own       
-    
-    RMessage2*                  iDeviceDiscoveryMsg; // Own
-    
-    TBool                       iDeviceDiscoveryEnabled;
-    
-    RMessage2*                  iConnectionMsg; // Own
-    
-    HBufC8*                     iDeviceRespBuf; // Own
-    
-    HBufC8*                     iDeviceListRespBuf; // Own
-    
-    RPointerArray<CUPnPPlaybackSession> iPlaybackSessions; // Own
-    
-    RPointerArray<CUPnPBrowsingSession> iBrowsingSessions; // Own
-    
-    RPointerArray<CUPnPUploadSession>   iUploadSessions; // Own
-    
-    RPointerArray<CUPnPDownloadSession> iDownloadSessions; // Own
-    
-    
-    TSglQue<CUpnpDeviceDiscoveryMessage>        iDeviceMsgQue; // Own
-    TSglQueIter<CUpnpDeviceDiscoveryMessage>    iDeviceMsgQueIter;
-    };
-
-#endif // C_UPNPAVCONTROLLERIMPL_H
+/*
+* Copyright (c) 2006-2009 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:      AV Controller Implementation
+*
+*/
+
+
+
+
+
+
+
+#ifndef C_UPNPAVCONTROLLERIMPL_H
+#define C_UPNPAVCONTROLLERIMPL_H
+
+// INDLUDE FILES
+#include <e32base.h>
+#include "upnpavcontrollerglobals.h"
+
+// FORWARD DECLARATIONS
+
+class CUPnPPlaybackSession;
+class CUpnpAVControllerServer;
+class CUpnpAVDevice;
+class CUpnpAVDeviceExtended;
+class CUPnPBrowsingSession;
+class CUpnpDeviceDiscoveryMessage;
+class CUPnPUploadSession;
+class CUPnPDownloadSession;
+
+/**
+ *  AV Controller server side implementation. Impmements the base session. 
+ *  Rendering and browsing sessions are created from this session.
+ *  Handles device discovery and fetching of device listst.
+ *
+ *  @exe upnpavcontrollerserver.exe
+ *  @since S60 v3.1
+ */
+class CUPnPAVControllerImpl : public CBase
+                                
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     *
+     * @param aClient media server client reference
+     * @param aServer server class reference
+     */
+    static CUPnPAVControllerImpl* NewL
+        (
+        CUpnpAVControllerServer& aServer
+        );
+    
+    /**
+     * Destructor
+     */
+    virtual ~CUPnPAVControllerImpl();
+    
+private:
+
+    /**
+     * Private constructor
+     *
+     * @param aClient media server client reference
+     * @param aServer server class reference          
+     */
+    CUPnPAVControllerImpl( CUpnpAVControllerServer& aServer );    
+    
+    /**
+     * Destructor
+     */
+    void ConstructL();    
+
+public: // New functions
+
+    /**
+     * Handles connection lost.
+     */
+    void ConnectionLost();
+    
+    /**
+     * Handles UPnP device discoveries.
+     * @since Series 60 2.6
+     * @param aDevice Device that is discovered.
+     */
+    void DeviceDiscoveredL( CUpnpAVDeviceExtended& aDevice );
+
+    /**
+     * Handles UPnP device disappears.
+     * @since Series 60 2.6
+     * @param aDevice Device that disappeared.
+     */
+    void DeviceDisappearedL( CUpnpAVDeviceExtended& aDevice );
+
+    /**
+     * Handles UPnP device icon download completions.
+     * @param aDevice Device that's icon was downloaded.
+     */
+    void DeviceIconDownloadedL( CUpnpAVDeviceExtended& aDevice );
+
+    /**
+     * Enables device discovery by storing a message to server side, which
+     * is completed when a device has been discovered.
+     *
+     * @param aMessage message
+     */
+    void EnableDeviceDiscoveryL( const RMessage2& aMessage );
+        
+    /**
+     * Disables (cancels) device discovery (and message).
+     */
+    void DisableDeviceDiscoveryL();
+    
+    /**
+     * Returns a discovered/disappeared device to client side.
+     *
+     * @param aMessage message
+     */
+    void GetDeviceL( const RMessage2& aMessage );
+    
+    /**
+     * Returns the size of device list to client side.
+     *
+     * @param aMessage message
+     */
+    void GetDeviceListSizeL( const RMessage2& aMessage );
+    
+    /**
+     * Returns the device list to client side.
+     *
+     * @param aMessage message
+     */
+    void GetDeviceListL( const RMessage2& aMessage );
+
+    /**
+     * Returns the icon to client side.
+     *
+     * @param aMessage message
+     */
+    void GetDeviceIconRequestL( const RMessage2& aMessage );
+
+    /**
+     * Creates a rendering session.
+     *
+     * @param aMessage message
+     */
+    void CreateRenderingSessionL( const RMessage2& aMessage );
+    
+    /**
+     * Destroys a rendering session
+     *
+     * @param aMessage message
+     */
+    void DestroyRenderingSessionL( const RMessage2& aMessage );
+    
+    /**
+     * Enables (unsolicited) eventing from a remote device. Stores
+     * the message in to redering session to return an event.
+     *
+     * @param aMessage message
+     */
+    void EventRequestL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels eventing message.
+     *
+     * @param aMessage message
+     */
+    void CancelEventRequestL( const RMessage2& aMessage );
+    
+    /**
+     * Sets URI
+     *
+     * @param aMessage message
+     */
+    void SetURIL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels SetURI (basically just ignores the result)
+     *
+     * @param aMessage message
+     */
+    void CancelSetURIL( const RMessage2& aMessage );
+    
+    /**
+     * Sets Next URI
+     *
+     * @param aMessage message
+     */
+    void SetNextURIL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels SetNextURI (basically just ignores the result)
+     *
+     * @param aMessage message
+     */
+    void CancelSetNextURIL( const RMessage2& aMessage );
+    
+    /**
+     * Send the play-action
+     *
+     * @param aMessage message
+     */
+    void PlayL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels the play-action (basically just ignores the result)
+     *
+     * @param aMessage message
+     */
+    void CancelPlayL( const RMessage2& aMessage );
+
+    /**
+     * Send the stop-action
+     *
+     * @param aMessage message
+     */
+    void StopL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels stop (basically just ignores the result)
+     *
+     * @param aMessage message
+     */
+    void CancelStopL( const RMessage2& aMessage );
+
+    /**
+     * Send the pause-action
+     *
+     * @param aMessage message
+     */
+    void PauseL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels pause (basically just ignores the result)
+     *
+     * @param aMessage message
+     */
+    void CancelPauseL( const RMessage2& aMessage );
+
+    /**
+     * Send the setvolume-action
+     *
+     * @param aMessage message
+     */
+    void SetVolumeL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels setvolume (basically just ignores the result)
+     *
+     * @param aMessage message
+     */
+    void CancelSetVolumeL( const RMessage2& aMessage );
+    
+    /**
+     * Send the getvolume-action
+     *
+     * @param aMessage message
+     */
+    void GetVolumeL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels getvolume (basically just ignores the result)
+     *
+     * @param aMessage message
+     */
+    void CancelGetVolumeL( const RMessage2& aMessage );
+    
+    /**
+     * Send the setmute-action
+     *
+     * @param aMessage message
+     */
+    void SetMuteL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels setmute (basically just ignores the result)
+     *
+     * @param aMessage message
+     */
+    void CancelSetMuteL( const RMessage2& aMessage );
+    
+    /**
+     * Send the getmute-action
+     *
+     * @param aMessage message
+     */
+    void GetMuteL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels getmute (basically just ignores the result)
+     *
+     * @param aMessage message
+     */
+    void CancelGetMuteL( const RMessage2& aMessage );
+    
+    /**
+     * Send the getpositioninfo-action
+     *
+     * @param aMessage message
+     */
+    void GetPositionInfoL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels getpositioninfo (basically just ignores the result)
+     *
+     * @param aMessage message
+     */
+    void CancelGetPositionInfoL( const RMessage2& aMessage );
+    
+    /**
+     * Send the seek action with unit REL_TIME.
+     *
+     * @param aMessage message
+     */
+    void SeekRelTimeL( const RMessage2& aMessage );
+        
+    /**
+     * Get initial state of the renderer
+     *
+     * @param aMessage message
+     */
+    void GetRendererStateL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels seeking with unit REL_TIME (basically just ignores the result).
+     *
+     * @param aMessage message
+     */
+    void CancelSeekRelTimeL( const RMessage2& aMessage );
+    
+    /**
+     * Create a browsing session
+     *
+     * @param aMessage message
+     */
+    void CreateBrowsingSessionL( const RMessage2& aMessage );
+    
+    /**
+     * Destroy a browsing session
+     *
+     * @param aMessage message
+     */
+    void DestroyBrowsingSessionL( const RMessage2& aMessage );
+    
+    /**
+     * Get browse response (return the size of it to client side)
+     *
+     * @param aMessage message
+     */
+    void GetBrowseResponseSizeL( const RMessage2& aMessage );  
+
+    /**
+     * Cancel get browse response (ignore result)
+     *
+     * @param aMessage message
+     */
+    void CancelGetBrowseResponseSizeL( const RMessage2& aMessage );
+
+    /**
+     * Return browse response to client side
+     *
+     * @param aMessage message
+     */
+    void GetBrowseResponseL( const RMessage2& aMessage );
+
+    /**
+     * Get search response (return the size of it to client side)
+     *
+     * @param aMessage message
+     */
+    void GetSearchResponseSizeL( const RMessage2& aMessage );
+
+    /**
+     * Cancel search response (ignore result)
+     *
+     * @param aMessage message
+     */
+    void CancelGetSearchResponseSizeL( const RMessage2& aMessage );
+
+    /**
+     * Return search response to client side
+     *
+     * @param aMessage message
+     */
+    void GetSearchResponseL( const RMessage2& aMessage );
+    
+    /**
+     * Get search capabilities (return the size of it to client side)
+     *
+     * @param aMessage message
+     */
+    void GetSearchCapabitiesSizeL( const RMessage2& aMessage );
+    
+    /**
+     * Cancel get search capabilities (ignore result)
+     *
+     * @param aMessage message
+     */
+    void CancelGetSearchCapabitiesSizeL( const RMessage2& aMessage );
+    
+    /**
+     * Return search capabilities to client side
+     *
+     * @param aMessage message
+     */
+    void GetSearchCapabitiesL( const RMessage2& aMessage );
+
+    /**
+     * Create container action.
+     *
+     * @param aMessage message
+     */
+    void CreateContainerL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels create container.
+     *
+     * @param aMessage message
+     */
+    void CancelCreateContainerL( const RMessage2& aMessage );
+    
+    /**
+     * Delete object action
+     *
+     * @param aMessage message
+     */
+    void DeleteObjectL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels delete object
+     *
+     * @param aMessage message
+     */
+    void CancelDeleteObjectL( const RMessage2& aMessage );
+
+    /**
+     * Stores a message in to rendering or browsing session, which is
+     * completed when the session specific device has disappeared. As a
+     * result the client knows that the device is no longer available and
+     * the session has became absolete.
+     *
+     * @param aMessage message
+     */
+    void DeviceDisappearedRequestL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels the msg.
+     *
+     * @param aMessage message
+     */
+    void CancelDeviceDisappearedRequestL( const RMessage2& aMessage );
+    
+    /**
+     * Stores a message in to base session, which is completed when the
+     * WLAN is disconnected.
+     *
+     * @param aMessage message
+     */
+    void MonitorConnectionL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels the connection monitoring message.
+     *
+     * @param aMessage message
+     */
+    void CancelMonitorConnectionL( const RMessage2& aMessage );
+    
+    /**
+     * Create a download session
+     *
+     * @param aMessage message
+     */
+    void CreateDownloadSessionL( const RMessage2& aMessage );
+    
+    /**
+     * Destroy the download session
+     *
+     * @param aMessage message
+     */
+    void DestroyDownloadSessionL( const RMessage2& aMessage );
+    
+    /**
+     * Start download
+     *
+     * @param aMessage message
+     */
+    void StartDownloadL( const RMessage2& aMessage );
+    
+    /**
+     * Start FHL download.
+     *
+     * @param aMessage message
+     */
+    void StartDownloadFHL( const RMessage2& aMessage );
+    
+    /**
+     * Cancel download
+     *
+     * @param aMessage message
+     */
+    void CancelDownloadL( const RMessage2& aMessage );
+    
+    /**
+     * Cancel all download
+     *
+     * @param aMessage message
+     */
+    void CancelAllDownloadsL( const RMessage2& aMessage );
+    
+    /**
+     * Start tracking the download progress
+     *
+     * @param aMessage message
+     */
+    void StartTrackingDownloadProgressL( const RMessage2& aMessage );
+    
+    /**
+     * Stop tracking the download progress
+     *
+     * @param aMessage message
+     */
+    void StopTrackingDownloadProgressL( const RMessage2& aMessage );
+    
+    /**
+     * Get download event
+     *
+     * @param aMessage message
+     */
+    void GetDownloadEventL( const RMessage2& aMessage );
+    
+    /**
+     * Cancel download event
+     *
+     * @param aMessage message
+     */
+    void CancelGetDownloadEventL( const RMessage2& aMessage );
+
+    /**
+     * Create upload session
+     *
+     * @param aMessage message
+     */
+    void CreateUploadSessionL( const RMessage2& aMessage );
+    
+    /**
+     * Destroy upload session
+     *
+     * @param aMessage message
+     */
+    void DestroyUploadSessionL( const RMessage2& aMessage );    
+    
+    /**
+     * Start upload
+     *
+     * @param aMessage message
+     */
+    void StartUploadL( const RMessage2& aMessage );
+    
+    /**
+     * Cancel upload
+     *
+     * @param aMessage message
+     */
+    void CancelUploadL( const RMessage2& aMessage );
+    
+    /**
+     * Cancel all upload
+     *
+     * @param aMessage message
+     */
+    void CancelAllUploadsL( const RMessage2& aMessage );
+    
+    /**
+     * Start tracking the upload progress
+     *
+     * @param aMessage message
+     */
+    void StartTrackingUploadProgressL( const RMessage2& aMessage );
+    
+    /**
+     * Stop tracking upload progress
+     *
+     * @param aMessage message
+     */
+    void StopTrackingUploadProgressL( const RMessage2& aMessage );
+    
+    /**
+     * Get upload event
+     *
+     * @param aMessage message
+     */
+    void GetUploadEventL( const RMessage2& aMessage );
+    
+    /**
+     * Cancel get upload event
+     *
+     * @param aMessage message
+     */
+    void CancelGetUploadEventL( const RMessage2& aMessage );
+
+private:
+
+    /**
+     * Device queu handling. Checks the queu and dequeus it if needed.
+     *
+     * @param aDevice av device
+     * @param aType discovered/disappeared
+     */
+    void DequeDeviceL( const CUpnpAVDevice& aDevice,
+        TAVControllerDeviceDiscovery aType );
+
+private:
+       
+    CUpnpAVControllerServer&    iServer; // Not own       
+    
+    RMessage2*                  iDeviceDiscoveryMsg; // Own
+    
+    TBool                       iDeviceDiscoveryEnabled;
+    
+    RMessage2*                  iConnectionMsg; // Own
+    
+    HBufC8*                     iDeviceRespBuf; // Own
+    
+    HBufC8*                     iDeviceListRespBuf; // Own
+    
+    RPointerArray<CUPnPPlaybackSession> iPlaybackSessions; // Own
+    
+    RPointerArray<CUPnPBrowsingSession> iBrowsingSessions; // Own
+    
+    RPointerArray<CUPnPUploadSession>   iUploadSessions; // Own
+    
+    RPointerArray<CUPnPDownloadSession> iDownloadSessions; // Own
+    
+    
+    TSglQue<CUpnpDeviceDiscoveryMessage>        iDeviceMsgQue; // Own
+    TSglQueIter<CUpnpDeviceDiscoveryMessage>    iDeviceMsgQueIter;
+    };
+
+#endif // C_UPNPAVCONTROLLERIMPL_H
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpavcontrollerserver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpavcontrollerserver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,355 +1,343 @@
-/*
-* Copyright (c) 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:      AV Controller server
-*
-*/
-
-
-
-
-
-
-#ifndef C_CUPNPAVCONTROLLERSERVER_H
-#define C_CUPNPAVCONTROLLERSERVER_H
-
-
-// INCLUDES
-#include "upnpavcontrollerserver.pan"
-
-#include <upnpaction.h>
-#include <upnpservice.h>
-#include <upnpdevice.h>
-#include <e32base.h>
-#include <upnpmediaserverclient.h>
-#include "upnpconnectionmonitorobserver.h"
-
-#include "upnpavtimer.h"
-
-// FORWARD DECLARATIONS
-class CUpnpAVControlPoint;
-class CUPnPAVDispatcher;
-class CUPnPConnectionMonitor;
-class CUPnPDeviceRepository;
-
-// CLASS DECLARATION
-
-/**
-*  UPnP Media Server container.
-*  Provides interface for Media Server maintanace purposes.
-*
-*  @lib - 
-*  @since Series 60 3.1
-*/
-class CUpnpAVControllerServer :  public CPolicyServer,
-                                 public MUPnPAVTimerCallback,
-                                 public MUPnPConnectionMonitorObserver
-    {
-
-private: // Internal server state
-
-    enum TAVControllerServerState
-        {
-        EStateUndefined = 0,
-        EStateStartingUp,
-        EStateRunning,
-        EStateShuttingDown
-        };    
-    
-public:  // Constructors and destructor
-        
-    /**
-     * Two-phased constructor.
-     */
-    static CUpnpAVControllerServer* NewLC();
-
-    /**
-     * Destructor.
-     */
-    virtual ~CUpnpAVControllerServer();
-    
-public: // New functions        
-     
-    /**
-     * Increment the count of the active sessions for this server
-     */
-    void IncrementSessions();
-
-    /**
-     * Decrement the count of the active sessions for this server. 
-     */
-    void DecrementSessions();
-    
-    /**
-     * Handles UPnP device discoveries.
-     * 
-     * @param aDevice Device that is discovered.
-     */
-    void DeviceDiscoveredL( CUpnpDevice& aDevice);
-
-    /**
-     * Handles UPnP device disappears.
-     * 
-     * @param aDevice Device that disappeared.
-     */
-    void DeviceDisappearedL( CUpnpDevice& aDevice);
-    
-    /**
-     * Handles UPnP device disappears.
-     * 
-     * @param aUuid Device that disappeared.
-     */
-    void DeviceDisappearedL( const TDesC8& aUuid );
-    
-    /**
-     * Return a reference to the control point
-     *
-     * @return reference to the control point
-     */
-    CUpnpAVControlPoint& ControlPoint();
-
-    /**
-     * Return a reference to the s60 MS session
-     *
-     * @return reference to the s60 MS session
-     */
-    RUpnpMediaServerClient& MediaServer();
-    
-    /**
-     * Return a reference to the callback dispatcher
-     *
-     * @return reference to the callback dispatcher
-     */
-    CUPnPAVDispatcher& Dispatcher();
-    
-    /**
-     * Return a reference to the device repository
-     *
-     * @return reference to the device repository
-     */
-    CUPnPDeviceRepository& DeviceRepository();
-    
-    TInt IAP();
-    
-         
-    /**
-     * First stage startup for the server thread
-     * 
-     * @return return KErrNone or panics thread
-     */
-    static TInt ThreadFunction();
-    
-    /**
-     * Starts the s60 MS if not started. Increments the reference ocunt
-     * 
-     * @param aMessage message
-     */
-    void StartMediaServerL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels the start
-     * 
-     * @param aMessage message
-     */
-    void CancelStartMediaServerL( const RMessage2& aMessage );
-
-    /**
-     * Stops the s60 MS if reference count hits 0
-     * 
-     * @param aMessage message
-     */
-    void StopMediaServerL( const RMessage2& aMessage );
-
-    /**
-     * Returns ETrue if someone is using the local Media Server
-     * 
-     * @param aMessage message
-     */
-    void MSServicesInUse( const RMessage2& aMessage );
-    
-    /**
-     * Observer callback for Connection Manager GetProtocolInfo function.
-     * 
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSource
-     * @param aSink
-     */ 
-    void CmProtocolInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSource, 
-        const TDesC8& aSink );
-    
-protected:  // From CActive
-
-    /**
-     * Process any errors
-     * @param aError the leave code reported.
-     * @result return KErrNone if leave is handled
-     */
-    TInt RunError( TInt aError );
-    
-protected: // From MUPnPAVTimerCallback
-
-    /**
-     * See upnpavtimercallback.h
-     */
-    void UPnPAVTimerCallback( CUPnPAVTimer::TAVTimerType aType ); 
-
-protected: // From CUPnPConnectionMonitorObserver
-
-    /**
-     * See upnpconnectionmonitorobserver.h
-     */
-    void ConnectionLost();
-
-private: // 2nd phase construct
-
-    /**
-     * Constructs the server 
-     *
-     * @param aPriority CServer2 input parameter
-     */
-    CUpnpAVControllerServer(TInt aPriority);
-
-    /**
-     * Perform the second phase construction of a CUpnpMessageHandler object
-     */
-    void ConstructL() ;
-
-public:
-        
-    /**
-     * Perform the second phase startup. Starts up AV Control Point and
-     * Dispatcher
-     */
-    void StartUpL();
-
-    /**
-     * Perform the second phase startup. Starts up AV Control Point and
-     * Dispatcher
-     */
-    void CancelStartUp();
-    
-private: // New methods 
-
-    /**
-     * Panic client. 
-     *
-     * @param aMessage RMessage2
-     * @param aPanic panic code
-     */
-    static void PanicClient( const RMessage2& aMessage,
-        TAVControllerServerPanic aPanic );
-  
-    /**
-     * Panic the server. 
-     *
-     * @param param aPanic the panic code
-     * @return a updateId of container
-     */
-    static void PanicServer(TAVControllerServerPanic aPanic);
-  
-    /**
-     * Second stage startup for the server thread 
-     */
-    static void ThreadFunctionL();
-    
-    /**
-     * Handles embedded discovered device. Recoursive.
-     *
-     * @param aDevice device
-     * @param aDepth device depth
-     */
-    void HandleEmbeddedDiscoveredDevicesL( CUpnpDevice& aDevice,
-        TInt aDepth );
-    
-    /**
-     * Handles embedded disappeared device. Recoursive.
-     *
-     * @param aDevice device
-     * @param aDepth device depth
-     */
-    void HandleEmbeddedDisappearedDevicesL( CUpnpDevice& aDevice,
-        TInt aDepth );
-        
-    /**
-     * Stops the local media server
-     */
-    void StopMediaServer();
-    
-    /**
-     * Error handler for failed protocolinfo-action
-     *
-     * @param aUuid device uuid
-     * @param aDev pointer to the device in repository
-     */
-    void HandleFailedProtocolInfoResponse( const TDesC8& aUuid );                  
-
-private: // From CServer
-
-    /**
-     * Create a time server session, and return a pointer to the created
-     * object
-     * @param aVersion the client version 
-     * @result pointer to new session
-     */
-    CSession2* NewSessionL( const TVersion& aVersion,
-        const RMessage2& aMessage )  const;
-    
-private:
-    
-    /** @var iSessionCount the number of session owned by this server */
-    TInt iSessionCount;
-    
-    CUpnpAVControlPoint*        iAVControlPoint; // Own
-    RUpnpMediaServerClient      iMediaServer; // Own
-    
-    CUPnPAVDispatcher*          iDispatcher; // Own
-
-    CUPnPAVTimer*               iServerTimer; // Own
-    
-    CUPnPAVTimer*               iMSTimer; // Own
-
-    CUPnPConnectionMonitor*     iMonitor; // Own
-    
-    TInt                        iServerUserCount;
-    
-    TBool                       iMediaServerOnline;
-    
-    TBool                       iStartingMS;
-    
-    TBool                       iMSActivatedBeforeStart;
-    
-    RPointerArray<RMessage2>    iStartMessages; // Own
-    
-    CUPnPDeviceRepository*      iDeviceRepository; // Own
-    
-    TInt                        iDiscoveredDeviceCount;    
-    
-    TInt                        iDisappearedDeviceCount;
-    
-    TInt                        iShutdownTimeoutValue;
-    
-    TInt                        iIAP;    
-
-    TAVControllerServerState    iServerState;
-
-    
-    };
-
-
-#endif // C_CUPNPAVCONTROLLERSERVER_H
+/*
+* Copyright (c) 2006-2009 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:      AV Controller server
+*
+*/
+
+
+
+
+
+
+#ifndef C_CUPNPAVCONTROLLERSERVER_H
+#define C_CUPNPAVCONTROLLERSERVER_H
+
+
+// INCLUDES
+#include "upnpavcontrollerserver.pan"
+
+#include <upnpaction.h>
+#include <upnpservice.h>
+#include <upnpdevice.h>
+#include <e32base.h>
+#include "upnpconnectionmonitorobserver.h"
+#include "upnpavcontrolpointobserver.h"
+#include "upnpavtimer.h"
+#include "upnpdeviceicondownloader.h"
+
+// FORWARD DECLARATIONS
+class CUpnpAVControlPoint;
+class CUPnPAVDispatcher;
+class CUPnPConnectionMonitor;
+class CUPnPDeviceRepository;
+class CUpnpSettings;
+
+// CLASS DECLARATION
+
+/**
+*  UPnP Media Server container.
+*  Provides interface for Media Server maintanace purposes.
+*
+*  @lib - 
+*  @since Series 60 3.1
+*/
+NONSHARABLE_CLASS ( CUpnpAVControllerServer ) :  public CPolicyServer,
+                                 private MUPnPAVTimerCallback,
+                                 private MUPnPConnectionMonitorObserver,
+                                 private MUpnpAVControlPointObserver,
+                                 private MUpnpDeviceIconDownloadObserver
+    {
+
+private: // Internal server state
+
+    enum TAVControllerServerState
+        {
+        EStateUndefined = 0,
+        EStateStartingServer,
+        EStateStartingControlPoint,
+        EStateRunning,
+        EStateShuttingDown,
+        EStateShutDown
+        };    
+    
+public:  // Constructors and destructor
+        
+    /**
+     * Two-phased constructor.
+     */
+    static CUpnpAVControllerServer* NewLC();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUpnpAVControllerServer();
+
+public: // New functions        
+     
+    /**
+     * Increment the count of the active sessions for this server
+     */
+    void IncrementSessions();
+
+    /**
+     * Decrement the count of the active sessions for this server. 
+     */
+    void DecrementSessions();
+    
+    /**
+     * Handles UPnP device discoveries.
+     * 
+     * @param aDevice Device that is discovered.
+     */
+    void DeviceDiscoveredL( CUpnpDevice& aDevice);
+
+    /**
+     * Handles UPnP device disappears.
+     * 
+     * @param aDevice Device that disappeared.
+     */
+    void DeviceDisappearedL( CUpnpDevice& aDevice);
+    
+    /**
+     * Handles UPnP device disappears.
+     * 
+     * @param aUuid Device that disappeared.
+     */
+    void DeviceDisappearedL( const TDesC8& aUuid );
+    
+    /**
+     * Return a reference to the control point
+     *
+     * @return reference to the control point
+     */
+    CUpnpAVControlPoint& ControlPoint();
+
+
+    /**
+     * Return a reference to the callback dispatcher
+     *
+     * @return reference to the callback dispatcher
+     */
+    CUPnPAVDispatcher& Dispatcher();
+    
+    /**
+     * Return a reference to the device repository
+     *
+     * @return reference to the device repository
+     */
+    CUPnPDeviceRepository& DeviceRepository();
+    
+    /**
+     * Return a IAP
+     *
+     * @return a IAP
+     */
+    TInt IAP();
+         
+    /**
+     * First stage startup for the server thread
+     * 
+     * @return return KErrNone or panics thread
+     */
+    static TInt ThreadFunction();
+        
+    /**
+     * Observer callback for Connection Manager GetProtocolInfo function.
+     * 
+     * @param aUuid Source device UUID. 
+     * @param aSessionId 
+     * @param aErr UPnP error code.
+     * @param aSource
+     * @param aSink
+     */ 
+    void CmProtocolInfoResponse(
+        const TDesC8& aUuid,
+        TInt aErr,
+        const TDesC8& aSource, 
+        const TDesC8& aSink );
+
+    /**
+     * Transfers device icon file to the client
+     * 
+     * @param aMessage message from client
+     * @param aSlot message slot to be used
+     * @param aDeviceUuid the device that's icon is transferred
+     */
+    void TransferDeviceIconFileToClientL( const RMessage2& aMessage, TInt aSlot,
+        const TDesC8& aDeviceUuid );
+
+private:  // From CActive
+
+    /**
+     * Process any errors
+     * @param aError the leave code reported.
+     * @result return KErrNone if leave is handled
+     */
+    TInt RunError( TInt aError );
+    
+private: // From MUPnPAVTimerCallback
+
+    /**
+     * See upnpavtimercallback.h
+     */
+    void UPnPAVTimerCallback( CUPnPAVTimer::TAVTimerType aType ); 
+
+private: // From CUPnPConnectionMonitorObserver
+
+    /**
+     * See upnpconnectionmonitorobserver.h
+     */
+    void ConnectionLost( TBool aUserOriented );
+
+private: // 2nd phase construct
+
+    /**
+     * Constructs the server 
+     *
+     * @param aPriority CServer2 input parameter
+     */
+    CUpnpAVControllerServer(TInt aPriority);
+
+    /**
+     * Perform the second phase construction of a CUpnpMessageHandler object
+     */
+    void ConstructL() ;
+
+public:
+        
+    /**
+     * Perform the second phase startup. Starts up AV Control Point and
+     * Dispatcher
+     */
+    void StartUpL();
+
+    /**
+     * Perform the second phase startup. Starts up AV Control Point and
+     * Dispatcher
+     */
+    void CancelStartUp();
+    
+private: // MUpnpAVControlPointObserver
+
+    /**
+    * @see MUpnpAVControlPointObserver::ActionResponseL
+    */
+    void ActionResponseL( CUpnpAction* aAction );
+    
+    /**
+    * @see MUpnpAVControlPointObserver::StateUpdatedL
+    */
+    void StateUpdatedL( CUpnpService* aService );
+    
+    /**
+    * @see MUpnpAVControlPointObserver::HttpResponseL
+    */
+    void HttpResponseL( CUpnpHttpMessage* aMessage );
+    
+    /**
+    * @see MUpnpAVControlPointObserver::DeviceDiscoveredL
+    */
+    void DeviceDiscoveredL( CUpnpDevice* aDevice );
+    
+    /**
+    * @see MUpnpAVControlPointObserver::DeviceDisappearedL
+    */
+    void DeviceDisappearedL( CUpnpDevice* aDevice );
+    
+private: // New methods 
+
+    /**
+     * Panic client. 
+     *
+     * @param aMessage RMessage2
+     * @param aPanic panic code
+     */
+    static void PanicClient( const RMessage2& aMessage,
+        TAVControllerServerPanic aPanic );
+  
+    /**
+     * Panic the server. 
+     *
+     * @param param aPanic the panic code
+     * @return a updateId of container
+     */
+    static void PanicServer(TAVControllerServerPanic aPanic);
+  
+    /**
+     * Second stage startup for the server thread 
+     */
+    static void ThreadFunctionL();
+            
+    /**
+     * Stops the local media server
+     */
+    void StopMediaServer();
+    
+    /**
+     * Error handler for failed protocolinfo-action
+     *
+     * @param aUuid device uuid
+     * @param aDev pointer to the device in repository
+     */
+    void HandleFailedProtocolInfoResponse( const TDesC8& aUuid );
+    
+    /**
+     * Change server state.
+     */
+    void ChangeState( TAVControllerServerState aState );
+
+private: // From CServer
+
+    /**
+     * Create a time server session, and return a pointer to the created
+     * object
+     * @param aVersion the client version 
+     * @result pointer to new session
+     */
+    CSession2* NewSessionL( const TVersion& aVersion,
+        const RMessage2& aMessage )  const;
+    
+
+private: // MUpnpDeviceIconDownloadObserver
+
+    void DeviceIconDownloadedL( const TDesC8& aDeviceUuid, TInt aError );
+
+private:
+    
+    /** @var iSessionCount the number of session owned by this server */
+    TInt iSessionCount;
+    
+    CUpnpAVControlPoint*        iAVControlPoint; // Own
+    
+    CUPnPAVDispatcher*          iDispatcher; // Own
+
+    CUPnPAVTimer*               iServerTimer; // Own
+    
+    CUPnPConnectionMonitor*     iMonitor; // Own
+            
+    CUPnPDeviceRepository*      iDeviceRepository; // Own
+        
+    TInt                        iShutdownTimeoutValue;
+    
+    TInt                        iIAP;    
+
+    TAVControllerServerState    iState;
+    
+    CUpnpSettings*              iUpnpSettings; // Own
+
+    CUpnpDeviceIconDownloader*  iIconDownloader; // Own
+    };
+
+
+#endif // C_CUPNPAVCONTROLLERSERVER_H
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpavcontrollersession.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpavcontrollersession.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,124 +1,161 @@
-/*
-* Copyright (c) 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:      AV Controller server session
-*
-*/
-
-
-
-
-
-
-#ifndef C_CUPNPAVCONTROLLERSESSION_H
-#define C_CUPNPAVCONTROLLERSESSION_H
-
-// INCLUDES
-#include "upnpavcontrollerglobals.h"
-
-#include <e32base.h>
-#include "upnpconnectionmonitorobserver.h"
-
-
-// FORWARD DECLARATIONS
-class CUpnpAVControllerServer;
-class CUPnPAVControllerImpl;
-class CUpnpAVDeviceExtended;
-class CUpnpDevice;
-
-// CLASS DECLARATION
-
-/** 
-  An instance of class CUpnpAVControllerSession is created for each client
-  */
-class CUpnpAVControllerSession :    public CSession2,
-                                    public MUPnPConnectionMonitorObserver
-{
-
-public: // New methods
-
-    /**
-    * Create a CUpnpAVControllerSession object using two phase construction,
-    * and return a pointer to the created object
-    * @result pointer to new session
-    */
-    static CUpnpAVControllerSession* NewL(
-        CUpnpAVControllerServer& aServer );
-
-    /**
-    * Create a CUpnpAVControllerSession object using two phase construction,
-    * and return a pointer to the created object
-    * @result pointer to new session
-    */
-    static CUpnpAVControllerSession* NewLC(
-        CUpnpAVControllerServer& aServer );
-
-    /**
-    * Destroy the object and release all memory objects
-    */
-    virtual ~CUpnpAVControllerSession();
-
-
-public: // From CSession
-    /**
-    * Called after a service request from client; from class CSession
-    * @param aMessage message from client
-    *        (containing requested operation and any data)
-    */
-    void ServiceL( const RMessage2& aMessage );
-public: // From MUPnPConnectionMonitorObserver
-
-    /**
-     * Handles UPnP device discoveries.
-     * @since Series 60 2.6
-     * @param aDevice Device that is discovered.
-     */
-    void DeviceDiscoveredL( CUpnpAVDeviceExtended& aDevice );
-
-    /**
-     * Handles UPnP device disappears.
-     * @since Series 60 2.6
-     * @param aDevice Device that disappeared.
-     */
-    void DeviceDisappearedL( CUpnpAVDeviceExtended& aDevice );
-
-
-    void ConnectionLost();
-
-private: // New methods
-
-    /**
-    * Perform the first phase of two phase construction 
-    */
-    CUpnpAVControllerSession( CUpnpAVControllerServer& aServer );
-
-    /**
-    * Perform the second phase construction of the object
-    */
-    void ConstructL() ;
-
-    /**
-    * Causes the client thread to panic
-    * @param panic code
-    */
-    void PanicClient( const RMessage2& aMessage, TInt aPanic ) const;
-
-private: 
-
-    /** @var iMediaServer pointer to Media Server */
-    
-    CUpnpAVControllerServer&    iAVControllerServer;
-    CUPnPAVControllerImpl*      iAVController;
-};
-
+/*
+* Copyright (c) 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:      AV Controller server session
+*
+*/
+
+
+
+
+
+
+#ifndef C_CUPNPAVCONTROLLERSESSION_H
+#define C_CUPNPAVCONTROLLERSESSION_H
+
+// INCLUDES
+#include "upnpavcontrollerglobals.h"
+
+#include <e32base.h>
+
+
+// FORWARD DECLARATIONS
+class CUpnpAVControllerServer;
+class CUPnPAVControllerImpl;
+class CUpnpAVDeviceExtended;
+class CUpnpDevice;
+
+// CLASS DECLARATION
+
+/** 
+  An instance of class CUpnpAVControllerSession is created for each client
+  */
+class CUpnpAVControllerSession :    public CSession2
+{
+
+public: // New methods
+
+    /**
+    * Create a CUpnpAVControllerSession object using two phase construction,
+    * and return a pointer to the created object
+    * @result pointer to new session
+    */
+    static CUpnpAVControllerSession* NewL(
+        CUpnpAVControllerServer& aServer );
+
+    /**
+    * Create a CUpnpAVControllerSession object using two phase construction,
+    * and return a pointer to the created object
+    * @result pointer to new session
+    */
+    static CUpnpAVControllerSession* NewLC(
+        CUpnpAVControllerServer& aServer );
+
+    /**
+    * Destroy the object and release all memory objects
+    */
+    virtual ~CUpnpAVControllerSession();
+
+
+public: // From CSession
+    /**
+    * Called after a service request from client; from class CSession
+    * @param aMessage message from client
+    *        (containing requested operation and any data)
+    */
+    void ServiceL( const RMessage2& aMessage );
+	
+public:
+
+    /**
+     * Handles UPnP device discoveries.
+     * @since Series 60 2.6
+     * @param aDevice Device that is discovered.
+     */
+    void DeviceDiscoveredL( CUpnpAVDeviceExtended& aDevice );
+
+    /**
+     * Handles UPnP device disappears.
+     * @since Series 60 2.6
+     * @param aDevice Device that disappeared.
+     */
+    void DeviceDisappearedL( CUpnpAVDeviceExtended& aDevice );
+
+    /**
+     * Handles UPnP device icon download completions.
+     * @param aDevice Device that icon was downloaded.
+     */
+    void DeviceIconDownloadedL( CUpnpAVDeviceExtended& aDevice );
+
+    /**
+     * Handles connection lost.
+     */
+    void ConnectionLost();
+
+private: // New methods
+
+    /**
+    * Perform the first phase of two phase construction 
+    */
+    CUpnpAVControllerSession( CUpnpAVControllerServer& aServer );
+
+    /**
+    * Perform the second phase construction of the object
+    */
+    void ConstructL() ;
+
+    /**
+    * Causes the client thread to panic
+    * @param panic code
+    */
+    void PanicClient( const RMessage2& aMessage, TInt aPanic ) const;
+    
+    /**
+     * ServiceL method extended ( cyclomatic complexity reduced)
+     */
+    void ServiceAvTransportCommandsL( const RMessage2& aMessage );
+    
+    /**
+     * ServiceL method extended ( cyclomatic complexity reduced)
+     */
+    void ServiceAvTransportVariablesL( const RMessage2& aMessage );
+    
+    /**
+     * ServiceL method extended ( cyclomatic complexity reduced)
+     */
+    void ServiceDeviceL( const RMessage2& aMessage );
+    
+    /**
+     * ServiceL method extended ( cyclomatic complexity reduced)
+     */
+    void ServiceSearchandBrowseL( const RMessage2& aMessage );
+   
+    /**
+     * ServiceL method extended ( cyclomatic complexity reduced)
+     */
+    void ServiceDownloadandUploadL( const RMessage2& aMessage );
+    
+    /**
+     * ServiceL method extended ( cyclomatic complexity reduced)
+     */
+    void ServiceCommonL( const RMessage2& aMessage );
+
+private: 
+
+    /** @var iMediaServer pointer to Media Server */
+    
+    CUpnpAVControllerServer&    iAVControllerServer;
+    CUPnPAVControllerImpl*      iAVController;
+};
+
 #endif // C_CUPNPAVCONTROLLERSESSION_H
\ No newline at end of file
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpavdeviceextended.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpavdeviceextended.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,366 +1,447 @@
-/*
-* 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:      a device data class used internally in AVC server
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPAVDEVICEEXTENDED_H_
-#define C_UPNPAVDEVICEEXTENDED_H_
-
-// Include files
-#include <e32base.h>
-#include "upnpavdevice.h"
-
-// FORWARD DECLARATIONS
-class CUpnpDlnaProtocolInfo;
-class CUpnpItem;
-
-/**
- * Extended UPnP device. Contains protocolinfo and a reference count for
- * subscibe actions.
- *
- */
-class CUpnpAVDeviceExtended: public CUpnpAVDevice
-    {
- 
-public:
-
-    enum TDLNADeviceType
-        {
-        EUPnP = 0,
-        EDMR,
-        EDMP,
-        EDMS
-        }; 
- 
-public:
-
-    /**
-     * Static 1st phase constructor
-     * 
-     * @param aDevice base device
-     * @return new instance
-     */    
-    static CUpnpAVDeviceExtended* NewL( const CUpnpAVDevice& aDevice );
-
-    /**
-     * Static 1st phase constructor
-     * 
-     * @param aDevice base device
-     * @return new instance
-     */    
-    static CUpnpAVDeviceExtended* NewL(
-        const CUpnpAVDeviceExtended& aDevice );
-
-    /**
-     * Static 1st phase constructor
-     *
-     * @return new timer instance
-     */    
-    static CUpnpAVDeviceExtended* NewL();
-
-    /**
-     * Destructor
-     */    
-    virtual ~CUpnpAVDeviceExtended();
-    
-private:
-
-    /**
-     * Private constructor
-     */
-    CUpnpAVDeviceExtended();
-
-    /**
-     * 2nd phase constructor
-     */    
-    void ConstructL();
-    
-
-public: // New functions
-
-    /**
-     * Sets sink protocolinfo
-     * 
-     * @param aProtocolInfo sink protocolinfo
-     */    
-    void SetSinkProtocolInfoL( const TDesC8& aProtocolInfo );
-    
-    /**
-     * Returns devices sink protocolinfos as an array
-     * 
-     * @return array of protocolinfos
-     */    
-    const RPointerArray<CUpnpDlnaProtocolInfo>&
-        SinkProtocolInfo() const;
-    
-    /**
-     * Sets source protocolinfo
-     * 
-     * @param aProtocolInfo source protocolinfo
-     */    
-    void SetSourceProtocolInfoL( const TDesC8& aProtocolInfo );
-    
-    /**
-     * Returns devices source protocolinfos as an array
-     * 
-     * @return array of protocolinfos
-     */    
-    const RPointerArray<CUpnpDlnaProtocolInfo>&
-        SourceProtocolInfo() const;
-    
-    /**
-     * Increases devices subscription count
-     * 
-     * @return subscription count
-     */    
-    TInt IncreaseSubscriptionCount();
-    
-    /**
-     * Decreases devices subscription count
-     * 
-     * @return subscription count
-     */    
-    TInt DecreaseSubscriptionCount();
-    
-    /**
-     * Returns subscription count
-     * 
-     * @return subscription count
-     */    
-    TInt SubscriptionCount() const;
-    
-    /**
-     * Sets device capabilities
-     * 
-     * @param aListOfMimeTypes
-     */    
-    void SetCapabilitiesBySupportedMimeTypesL(
-        const TDesC8& aListOfMimeTypes );
-        
-    /**
-     * Sets if the device is a local device (S60 Media Server)
-     * 
-     * @param aLocal
-     */    
-    void SetLocal( TBool aLocal );
-    
-    /**
-     * Return if the device is local
-     * 
-     * @return ETrue if the device is local
-     */    
-    TBool Local() const;
-    
-    /**
-     * Matches protocolinfo and return ETrue if it matches
-     * 
-     * @param aProtocolInfo objects protocolinfo
-     * @return ETrue if it matches
-     */    
-    TBool MatchSinkProtocolInfo( const TDesC8& aInfo ) const;
-    
-    /**
-     * Validates transfer
-     * 
-     * @param aProtocolInfo objects protocolinfo
-     * @return ETrue if it matches
-     */    
-    TBool ValidateTransfer( const TDesC8& aInfo ) const;
-        
-    /**
-     * Sets sink protocolinfo
-     * 
-     * @param aProtocolInfo
-     */    
-    const TDesC8& FindFirstMatchingInSinkL(
-        const CUpnpItem& aItem ) const;
-
-    /**
-     * Matches objectclass to protocolInfo
-     * 
-     * @param aObjectClass
-     * @param aProtocolInfo
-     */    
-    TBool MatchType( const TDesC8& aObjectClass, const TDesC8&
-        aProtocolInfo ) const;
-    
-    /**
-     * Sets if the device supports audio upload
-     * 
-     * @param aAudioUpload
-     */    
-    void SetAudioUpload( TBool aAudioUpload );
-    
-    /**
-     * Return if the device supports audio upload
-     * 
-     * @return ETrue if the device supports audio upload
-     */    
-    TBool AudioUpload() const;
-    
-    /**
-     * Sets if the device supports image upload
-     * 
-     * @param aImageUpload
-     */    
-    void SetImageUpload( TBool aImageUpload );
-    
-    /**
-     * Return if the device supports image upload
-     * 
-     * @return ETrue if the device supports image upload
-     */    
-    TBool ImageUpload() const;
-    
-    /**
-     * Sets if the device supports video upload
-     * 
-     * @param aVideoUpload
-     */    
-    void SetVideoUpload( TBool aVideoUpload );
-    
-    /**
-     * Return if the device supports video upload
-     * 
-     * @return ETrue if the device supports video upload
-     */    
-    TBool VideoUpload() const;    
-
-    /**
-     * Sets if the device supports CreateChildContainer
-     * 
-     * @param aCreateChildContainer
-     */    
-    void SetCreateChildContainer( TBool aCreateChildContainer );
-    
-    /**
-     * Return if the device supports video upload
-     * 
-     * @return ETrue if the device supports video upload
-     */    
-    TBool CreateChildContainer() const;
-    
-    /**
-     * Sets if the device supports DestroyObject
-     * 
-     * @param aDestroyObject
-     */    
-    void SetDestroyObject( TBool aDestroyObject );
-    
-    /**
-     * Return if the device supports DestroyObject
-     * 
-     * @return ETrue if the device is local
-     */    
-    TBool DestroyObject() const;
-    
-    /**
-     * Sets if the protocolInfo has been received
-     * 
-     * @param aPInfoReceived
-     */    
-    void SetPInfoReceived( TBool aPInfoReceived );
-    
-     /**
-     * Return if the device has received protocolInfo
-     * 
-     * @return ETrue if the device has received protocolInfo
-     */    
-   TBool PInfoReceived() const;
-   
-   void SetDLNADeviceType( TDLNADeviceType aDeviceType );
-   
-   TDLNADeviceType DLNADeviceType() const;
-    
-private:
-    
-    /**
-     * Sets source protocolinfo
-     * 
-     * @param aProtocolInfo source protocolinfo
-     */    
-    void SetSourceProtocolInfoL(
-        const RPointerArray<CUpnpDlnaProtocolInfo>& aProtocolInfo );
-    
-    /**
-     * Sets sink protocolinfo
-     * 
-     * @param aProtocolInfo sink protocolinfo
-     */    
-    void SetSinkProtocolInfoL(
-        const RPointerArray<CUpnpDlnaProtocolInfo>& aProtocolInfo );
-        
-    /**
-     * Parses descriptor to a delimeter
-     * 
-     * @param aLexer lexer representing a descriptor
-     * @param aDelimeter delimeter character
-     */    
-    void ParseToDelimeter( TLex8& aLex, TChar aDelimeter );
-    
-    /**
-     * Judge character to be able remove 
-     * 
-     * @param aCharacter is a character
-     * @return ETrue if the character can be removed
-     */    
-    TBool IsIllegalCharacter( TChar aCharacter ) const;   
-    
-    /**
-     * Parses descriptor perhaps have illegal characters
-     * 
-     * @param aPtr representing a descriptor
-     * @return a new hbufc8 buffer 
-     */    
-    HBufC8* RemoveIllegalCharactersL( const TDesC8& aPtr ) const;
-    
-    TBool MatchSourceProfileId( const TDesC8& aInfo ) const;
-
-    TBool MatchSinkProfileId( const TDesC8& aInfo ) const;
-    
-    TBool MatchSinkMime( const TDesC8& aInfo ) const;
-       
-private:
-    
-    RPointerArray<CUpnpDlnaProtocolInfo> iSourceProtocolInfo;
-    
-    RPointerArray<CUpnpDlnaProtocolInfo> iSinkProtocolInfo;
-    
-    TInt iSubscriptionCount;
-    
-    TBool iLocal;
-    
-    TBool iAudioUpload;
-    
-    TBool iImageUpload;
-    
-    TBool iVideoUpload;
-    
-    TBool iCreateChildContainer;
-    
-    TBool iDestroyObject;
-    
-    TBool iPInfoReceived;
-    
-    TDLNADeviceType iDLNADeviceType;
-    };
-
-
-#endif // C_UPNPAVDEVICEEXTENDED_H_
+/*
+* 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:      a device data class used internally in AVC server
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPAVDEVICEEXTENDED_H_
+#define C_UPNPAVDEVICEEXTENDED_H_
+
+// Include files
+#include <e32base.h>
+#include "upnpavdevice.h"
+
+// FORWARD DECLARATIONS
+class CUpnpDlnaProtocolInfo;
+class CUpnpItem;
+class TInetAddr;
+
+/**
+ * Extended UPnP device. Contains protocolinfo and a reference count for
+ * subscibe actions.
+ *
+ */
+class CUpnpAVDeviceExtended: public CUpnpAVDevice
+    {
+ 
+public:
+
+    /**
+     * Defines DLNA device types.
+     */    
+    enum TDLNADeviceType
+        {
+        EUPnP = 0,
+        EDMR,
+        EDMP,
+        EDMS
+        }; 
+ 
+public:
+
+    /**
+     * Static 1st phase constructor
+     * 
+     * @param aDevice base device
+     * @return new instance
+     */    
+    static CUpnpAVDeviceExtended* NewL( const CUpnpAVDevice& aDevice );
+
+    /**
+     * Static 1st phase constructor
+     * 
+     * @param aDevice base device
+     * @return new instance
+     */    
+    static CUpnpAVDeviceExtended* NewL(
+        const CUpnpAVDeviceExtended& aDevice );
+
+    /**
+     * Static 1st phase constructor
+     *
+     * @return new timer instance
+     */    
+    static CUpnpAVDeviceExtended* NewL();
+
+    /**
+     * Destructor
+     */    
+    virtual ~CUpnpAVDeviceExtended();
+    
+private:
+
+    /**
+     * Private constructor
+     */
+    CUpnpAVDeviceExtended();
+
+    /**
+     * 2nd phase constructor
+     */    
+    void ConstructL();
+    
+
+public: // New functions
+
+    /**
+     * Sets sink protocolinfo
+     * 
+     * @param aProtocolInfo sink protocolinfo
+     */    
+    void SetSinkProtocolInfoL( const TDesC8& aProtocolInfo );
+    
+    /**
+     * Returns devices sink protocolinfos as an array
+     * 
+     * @return array of protocolinfos
+     */    
+    const RPointerArray<CUpnpDlnaProtocolInfo>&
+        SinkProtocolInfo() const;
+    
+    /**
+     * Sets source protocolinfo
+     * 
+     * @param aProtocolInfo source protocolinfo
+     */    
+    void SetSourceProtocolInfoL( const TDesC8& aProtocolInfo );
+    
+    /**
+     * Returns devices source protocolinfos as an array
+     * 
+     * @return array of protocolinfos
+     */    
+    const RPointerArray<CUpnpDlnaProtocolInfo>&
+        SourceProtocolInfo() const;
+    
+    /**
+     * Increases devices subscription count
+     * 
+     * @return subscription count
+     */    
+    TInt IncreaseSubscriptionCount();
+    
+    /**
+     * Decreases devices subscription count
+     * 
+     * @return subscription count
+     */    
+    TInt DecreaseSubscriptionCount();
+    
+    /**
+     * Returns subscription count
+     * 
+     * @return subscription count
+     */    
+    TInt SubscriptionCount() const;
+    
+    /**
+     * Sets device capabilities
+     * 
+     * @param aListOfMimeTypes
+     */    
+    void SetCapabilitiesBySupportedMimeTypesL(
+        const TDesC8& aListOfMimeTypes );
+        
+    /**
+     * Sets if the device is a local device (S60 Media Server)
+     * 
+     * @param aLocal
+     */    
+    void SetLocal( TBool aLocal );
+    
+    /**
+     * Return if the device is local
+     * 
+     * @return ETrue if the device is local
+     */    
+    TBool Local() const;
+    
+    /**
+     * Matches protocolinfo and return ETrue if it matches
+     * 
+     * @param aProtocolInfo objects protocolinfo
+     * @return ETrue if it matches
+     */    
+    TBool MatchSinkProtocolInfo( const TDesC8& aInfo ) const;
+    
+    /**
+     * Validates transfer
+     * 
+     * @param aProtocolInfo objects protocolinfo
+     * @return ETrue if it matches
+     */    
+    TBool ValidateTransfer( const TDesC8& aInfo ) const;
+        
+    /**
+     * Sets sink protocolinfo
+     * 
+     * @param aProtocolInfo
+     */    
+    const TDesC8& FindFirstMatchingInSinkL(
+        const CUpnpItem& aItem ) const;
+
+    /**
+     * Matches objectclass to protocolInfo
+     * 
+     * @param aObjectClass
+     * @param aProtocolInfo
+     */    
+    TBool MatchType( const TDesC8& aObjectClass, const TDesC8&
+        aProtocolInfo ) const;
+    
+    /**
+     * Sets if the device supports audio upload
+     * 
+     * @param aAudioUpload
+     */    
+    void SetAudioUpload( TBool aAudioUpload );
+    
+    /**
+     * Return if the device supports audio upload
+     * 
+     * @return ETrue if the device supports audio upload
+     */    
+    TBool AudioUpload() const;
+    
+    /**
+     * Sets if the device supports image upload
+     * 
+     * @param aImageUpload
+     */    
+    void SetImageUpload( TBool aImageUpload );
+    
+    /**
+     * Return if the device supports image upload
+     * 
+     * @return ETrue if the device supports image upload
+     */    
+    TBool ImageUpload() const;
+    
+    /**
+     * Sets if the device supports video upload
+     * 
+     * @param aVideoUpload
+     */    
+    void SetVideoUpload( TBool aVideoUpload );
+    
+    /**
+     * Return if the device supports video upload
+     * 
+     * @return ETrue if the device supports video upload
+     */    
+    TBool VideoUpload() const;    
+
+    /**
+     * Sets if the device supports CreateChildContainer
+     * 
+     * @param aCreateChildContainer
+     */    
+    void SetCreateChildContainer( TBool aCreateChildContainer );
+    
+    /**
+     * Return if the device supports video upload
+     * 
+     * @return ETrue if the device supports video upload
+     */    
+    TBool CreateChildContainer() const;
+    
+    /**
+     * Sets if the device supports DestroyObject
+     * 
+     * @param aDestroyObject
+     */    
+    void SetDestroyObject( TBool aDestroyObject );
+    
+    /**
+     * Return if the device supports DestroyObject
+     * 
+     * @return ETrue if the device is local
+     */    
+    TBool DestroyObject() const;
+    
+    /**
+     * Sets if the protocolInfo has been received
+     * 
+     * @param aPInfoReceived
+     */    
+    void SetPInfoReceived( TBool aPInfoReceived );
+    
+     /**
+     * Return if the device has received protocolInfo
+     * 
+     * @return ETrue if the device has received protocolInfo
+     */    
+    TBool PInfoReceived() const;
+     
+    /**
+     * Setter for CM:PrepareForConnection availibility
+     * 
+     * @param aPrepareForConnection
+     */    
+    void SetPrepareForConnection( TBool aPrepareForConnection );
+
+    /**
+     * Getter for CM:PrepareForConnection availibility
+     * 
+     * @return ETrue if the device supports CM:PrepareForConnection
+     */    
+    TBool PrepareForConnection() const;
+    
+    /**
+     * Setter for DLNA device type
+     * 
+     * @param aDeviceType
+     */    
+    void SetDLNADeviceType( TDLNADeviceType aDeviceType );
+   
+    /**
+     * Getter for DLNA device type
+     * 
+     * @return DLNA device type
+     */    
+    TDLNADeviceType DLNADeviceType() const;
+
+    /**
+     * Setter for icon url
+     *
+     * @param aAddress address of device
+     * @param aUrlBase base url for icon url
+     * @param aIconUrl icon url relative to base url
+     */    
+    void SetIconUrlL( const TInetAddr& aAddress, const TDesC8& aUrlBase,
+        const TDesC8& aIconUrl );
+
+    /**
+     * Getter for icon url
+     *
+     * @return Icon url
+     */    
+    TPtrC8 IconUrl() const;
+    
+private: // MUpnpDeviceIconDownloadObserver
+
+    void DeviceIconDownloadCompleted( const TDesC8& aDeviceUuid, TInt aError );
+
+private:
+    
+    /**
+     * Sets source protocolinfo
+     * 
+     * @param aProtocolInfo source protocolinfo
+     */    
+    void SetSourceProtocolInfoL(
+        const RPointerArray<CUpnpDlnaProtocolInfo>& aProtocolInfo );
+    
+    /**
+     * Sets sink protocolinfo
+     * 
+     * @param aProtocolInfo sink protocolinfo
+     */    
+    void SetSinkProtocolInfoL(
+        const RPointerArray<CUpnpDlnaProtocolInfo>& aProtocolInfo );
+        
+    /**
+     * Parses descriptor to a delimeter
+     * 
+     * @param aLexer lexer representing a descriptor
+     * @param aDelimeter delimeter character
+     */    
+    void ParseToDelimeter( TLex8& aLex, TChar aDelimeter );
+    
+    /**
+     * Judge character to be able remove 
+     * 
+     * @param aCharacter is a character
+     * @return ETrue if the character can be removed
+     */    
+    TBool IsIllegalCharacter( TChar aCharacter ) const;   
+    
+    /**
+     * Parses descriptor perhaps have illegal characters
+     * 
+     * @param aPtr representing a descriptor
+     * @return a new hbufc8 buffer 
+     */    
+    HBufC8* RemoveIllegalCharactersL( const TDesC8& aPtr ) const;
+    
+    /**
+     * Match given protocolInfo to source protocolinfo.
+     * 
+     * @param aInfo protocolInfo
+     * @return ETrue if given protocolInfo matches to source protocolInfo
+     */    
+    TBool MatchSourceProfileId( const TDesC8& aInfo ) const;
+
+public:
+    
+    /**
+     * Match given protocolInfo to sink protocolinfo
+     * (DLNA profile id based mathing)
+     * 
+     * @param aInfo protocolInfo
+     * @return ETrue if given protocolInfo matches to sink protocolInfo
+     */    
+    TBool MatchSinkProfileId( const TDesC8& aInfo ) const;
+    
+    /**
+     * Match given protocolInfo to sink protocolinfo.
+     * (MIME type based matching)
+     * 
+     * @param aInfo protocolInfo
+     * @return ETrue if given protocolInfo matches to sink protocolInfo
+     */    
+    TBool MatchSinkMime( const TDesC8& aInfo ) const;
+       
+private:
+    
+    /**
+     * Source protocolinfo. Own.
+     */    
+    RPointerArray<CUpnpDlnaProtocolInfo> iSourceProtocolInfo;
+    
+    /**
+     * Sink protocolinfo. Own.
+     */    
+    RPointerArray<CUpnpDlnaProtocolInfo> iSinkProtocolInfo;
+    
+    TInt iSubscriptionCount;
+    
+    TBool iLocal;
+    
+    TBool iAudioUpload;
+    
+    TBool iImageUpload;
+    
+    TBool iVideoUpload;
+    
+    TBool iCreateChildContainer;
+    
+    TBool iDestroyObject;
+    
+    TBool iPInfoReceived;
+    
+    TBool iPrepareForConnection;
+    
+    TDLNADeviceType iDLNADeviceType;
+
+    HBufC8* iIconUrl; // Own, can be NULL
+    };
+
+
+#endif // C_UPNPAVDEVICEEXTENDED_H_
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpavdispatcher.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpavdispatcher.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,893 +1,158 @@
-/*
-* Copyright (c) 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:      dispatches control point indications for clients
-*
-*/
-
-
-
-
-
-
-#ifndef C_CUPNPAVDISPATCHER_H
-#define C_CUPNPAVDISPATCHER_H
-
-
-#include <e32base.h>
-#include <upnpavcontrolpointobserver.h>
-
-// FORWARD DECLARATIONS
-class CUPnPAVActionInfo;
-class CUPnPAVControllerImpl;
-class CUpnpAVControllerServer;
-// CLASS DECLARATION
-
-/**
-*  UPnP AV Controller callback dispatcher
-*  
-*
-*  @lib - 
-*  @since Series 60 3.1
-*/
-
-class CUPnPAVDispatcher : public CBase,
-                          public MUpnpAVControlPointObserver
-    {
-public:  // Constructors and destructor
-        
-    /**
-    * Two-phased constructor.
-    */
-    static CUPnPAVDispatcher* NewLC( CUpnpAVControllerServer& aServer );
-    
-    /**
-    * Two-phased constructor.
-    */
-    static CUPnPAVDispatcher* NewL( CUpnpAVControllerServer& aServer );    
-
-    /**
-    * Destructor.
-    */
-    virtual ~CUPnPAVDispatcher();
-
-private: // New methods
-
-    /**
-    * Constructs the server 
-    * @param aPriority CServer2 input parameter
-    */
-    CUPnPAVDispatcher( CUpnpAVControllerServer& aServer );
-
-    /**
-     * Perform the second phase construction of a CUpnpMessageHandler object
-     */
-    void ConstructL();
-
-protected:
-
-    /**
-    * Observer callback for rendering control Set Volume.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aInstance rendering instance.
-    * @param aChannel audio channel.
-    * @param aDesiredVolume 
-    */
-    void RcSetVolumeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aDesiredVolume);
-    /**
-    * Observer callback for rendering control Get Volume.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aInstance rendering instance.
-    * @param aChannel audio channel.
-    * @param aCurrentVolume 
-    */
-    void RcVolumeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aCurrentVolume); 
-    /**
-    * Observer callback for rendering control Set Mute.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aInstance rendering instance.
-    * @param aChannel audio channel.
-    * @param aDesiredMute 
-    */
-    void RcSetMuteResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aDesiredMute);
-    /**
-    * Observer callback for rendering control Get Mute.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aInstance rendering instance.
-    * @param aChannel audio channel.
-    * @param aCurrentMute 
-    */
-    void RcMuteResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aCurrentMute); 
-
-
-    /**
-    * Observer callback for rendering control AV set transport uri.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aInstance rendering instance.
-    * @param aCurrentUri Current transport URI.
-    * @param Current transport URI Metadata. 
-    */
-    void AvtSetTransportUriResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aCurrentUri,
-        const TDesC8& aCurrentUriMetaData);
-    /**
-    * Observer callback for rendering control AV set next transport uri.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aInstance rendering instance.
-    * @param aCurrentUri Current transport URI.
-    * @param Current transport URI Metadata. 
-    */
-    void AvtSetNextTransportUriResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNextUri,
-        const TDesC8& aNextUriMetaData);
-    /**
-    * Observer callback for rendering control AV get media info response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aInstance rendering instance.
-    * @param aNrTracks Number of tracks.
-    * @param aMediaDuration 
-    * @param aCurrentUri Current transport URI.
-    * @param aCurrentUriMetaData Metadata of current trransport uri. 
-    * @param aNextUri Next transport URI.
-    * @param aNextUriMetaData Metadata of next trransport uri.
-    * @param aPlayMedium
-    * @param aRecordMedium
-    * @param aWriteStatus
-    */
-    void AvtMediaInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNrTracks,
-        const TDesC8& aMediaDuration,
-        const TDesC8& aCurrentUri,
-        const TDesC8& aCurrentUriMetaData,
-        const TDesC8& aNextUri,
-        const TDesC8& aNextUriMetaData,
-        const TDesC8& aPlayMedium,
-        const TDesC8& aRecordMedium,
-        const TDesC8& aWriteStatus);
-    /**
-    * Observer callback for rendering control AV get transport info response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId
-    * @param aErr UPnP error code.
-    * @param aInstance rendering instance.
-    * @param aCurrenTransportState
-    * @param aCurrentTransportStatus
-    * @param aCurrentUri aCurrentSpeed
-    */
-    void AvtGetTransportInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aCurrenTransportState,
-        const TDesC8& aCurrentTransportStatus,
-        const TDesC8& aCurrentSpeed);
-    /**
-    * Observer callback for rendering control AV get position info response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aTrack rendering instance.
-    * @param aTrackDuration 
-    * @param aTrackMetaData
-    * @param aTrackURI
-    * @param aRelTime
-    * @param aAbsTime
-    * @param aRelCount
-    * @param aAbsCount
-    */
-    void AvtPositionInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aTrack,
-        const TDesC8& aTrackDuration,
-        const TDesC8& aTrackMetaData,
-        const TDesC8& aTrackURI,
-        const TDesC8& aRelTime,
-        const TDesC8& aAbsTime,
-        const TDesC8& aRelCount,
-        const TDesC8& aAbsCount);
-    /**
-    * Observer callback for rendering control AV get device
-    * capabilities response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aPlayMedia
-    * @param aRecMedia 
-    * @param aRecQualityModes
-    */
-    void AvtDeviceCapabilitiesResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aPlayMedia,
-        const TDesC8& aRecMedia,
-        const TDesC8& aRecQualityMode);
-    /**
-    * Observer callback for rendering control AV get transport
-    * settings response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId
-    * @param aInstanceId
-    * @param aErr UPnP error code.        
-    * @param aPlayMode
-    * @param aRecQualityMode
-    */
-    void AvtTransportSettingsResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aPlayMode,
-        const TDesC8& aRecQualityMode);
-    /**
-    * Observer callback for rendering control AV Stop response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    */
-    void AvtStopResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-    /**
-    * Observer callback for rendering control AV Play response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aSpeed
-    */
-    void AvtPlayResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aSpeed);
-    /**
-    * Observer callback for rendering control AV Pause response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    */
-    void AvtPauseResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-    /**
-    * Observer callback for rendering control AV Record response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    */
-    void AvtRecordResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-    /**
-    * Observer callback for rendering control AV Seek response.
-    * @since Series 60 2.6
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aUnit
-    * @param aTarget
-    */
-    void AvtSeekResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aUnit,
-        const TDesC8& aTarget);
-    /**
-    * Observer callback for rendering control AV Next response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    */
-    void AvtNextResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-    /**
-    * Observer callback for rendering control AV Previous response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    */
-    void AvtPreviousResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-    /**
-    * Observer callback for rendering control AV setplay mode response.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aNewPlayMode
-    */
-    void AvtSetPlayModeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNewPlayMode);
-    /**
-    * Observer callback for rendering control AV set record qualityresponse.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aNewRecordQuality
-    */
-    void AvtSetRecordModeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNewRecordQuality);
-    /**
-    * Observer callback for Content Directory GetSearchCapabilities function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aSearchCaps
-    */
-    void CdsSearchCapabilitiesResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSearchCaps);
-    /**
-    * Observer callback for Content Directory GetSortCapabilities function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aSortCaps
-    */
-    void CdsSortCapabilitiesResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSortCaps);
-    /**
-    * Observer callback for Content Directory GetSystemUpdateID function.
-    * @since Series 60 2.6
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aSystemUpdateId
-    */
-    void CdsSystemUpdateIdResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        TInt aSystemUpdateId);
-    /**
-    * Observer callback for Content Directory Browse function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aObjectID
-    * @param aBrowseFlag
-    * @param aFilter
-    * @param aIndex
-    * @param arequest
-    * @param aSortCriteria
-    * @param aResult
-    * @param aReturned
-    * @param aMatches
-    * @param aUpdateID
-    */
-    void CdsBrowseResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aObjectID,
-        const TDesC8&  aBrowseFlag,
-        const TDesC8&  aFilter,
-        TInt aIndex,
-        TInt aRequest,
-        const TDesC8&  aSortCriteria,
-        const TDesC8&  aResult,
-        TInt aReturned,
-        TInt aMatches,
-        const TDesC8&  aUpdateID);
-    /**
-    * Observer callback for Content Directory Search function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aContainerId
-    * @param aSearchCriteria
-    * @param aFilter
-    * @param aIndex
-    * @param arequest
-    * @param aSortCriteria
-    * @param aResult
-    * @param aReturned
-    * @param aMatches
-    * @param aUpdateID
-    */
-    void CdsSearchResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aContainerId,
-        const TDesC8& aSearchCriteria,
-        const TDesC8& aFilter,
-        TInt aIndex,
-        TInt aRequest,
-        const TDesC8& aSortCriteria,
-        const TDesC8& aResult,
-        TInt aReturned,
-        TInt aMatches,
-        const TDesC8& aUpdateID);
-    /**
-    * Observer callback for Content Directory DestroyObject function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aObjectId
-    */
-    void CdsDestroyObjectResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aObjectId );
-    /**
-    * Observer callback for Content Directory UpdateObject function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aObjectId
-    * @param aCurrentTagValue
-    * @param aNewTagValue
-    */
-    void CdsUpdateObjectResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aObjectId,
-        const TDesC8& aCurrentTagValue,
-        const TDesC8& aNewTagValue );
-    /**
-    * Observer callback for Content Directory ImportResource function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aSourceURI
-    * @param aDestinationURI
-    * @param aTransferId
-    */       
-    void CdsImportResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSourceURI,
-        const TDesC8& aDestinationURI,
-        const TDesC8& aTransferId );
-    /**
-    * Observer callback for Content Directory ExportResource function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aSourceURI
-    * @param aDestinationURI
-    * @param aTransferId
-    */       
-    void CdsExportResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSourceURI,
-        const TDesC8& aDestinationURI,
-        const TDesC8& aTransferId );
-    /**
-    * Observer callback for Content Directory StopTransfer function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aSourceURI
-    * @param aDestinationURI
-    * @param aTransferId
-    */       
-    void CdsStopTransferResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aTransferId );
-    /**
-    * Observer callback for Content Directory GetTransferProgress function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aTransferId
-    * @param aTransferStatus
-    * @param aTransferTotal
-    */         
-    void CdsCTransferProgressResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aTransferId,
-        const TDesC8& aTransferStatus,
-        const TDesC8& aTransferLength,            
-        const TDesC8& aTransferTotal );
-    /**
-    * Observer callback for Content Directory DeleteResource function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aResourceUri Resource to be deleted.
-    */ 
-    void CdsDeleteResourceResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aResourceUri );
-    /**
-    * Observer callback for Content Directory CreateReference function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aContainerId Destination folder.
-    * @param aObjectId Source object.
-    * @param aNewId Created reference.
-    */ 
-    void CdsCreateReferenceResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aContainerId, 
-        const TDesC8& aObjectId, 
-        const TDesC8& aNewId );
-    /**
-    * Observer callback for Content Directory CreateReference function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aContainerID Container in which new object is created.
-    * @param aElements Elements for item creation.
-    * @param aObjectID New objects ID.
-    * @param aResult Result of the action.
-    */ 
-    void CdsCreateObjectResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aContainerID, 
-        const TDesC8& aElements, 
-        const TDesC8& aObjectID, 
-        const TDesC8& aResult );
-
-    /**
-    * Observer callback for Connection Manager GetProtocolInfo function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aSource
-    * @param aSink
-    */ 
-    void CmProtocolInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSource, 
-        const TDesC8& aSink );
-    /**
-    * Observer callback for Connection Manager PrepareForConnection 
-    * function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aRemoteProtocolInfo
-    * @param aPeerConnectionManager
-    * @param aPeerConnectionId
-    * @param aDirection
-    * @param aConnection
-    * @param aTransport
-    * @param aRsc
-    */        
-    void CmPrepareResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aRemoteProtocolInfo,
-        const TDesC8& aPeerConnectionManager,
-        const TDesC8& aPeerConnectionId,
-        const TDesC8& aDirection,
-        TInt aConnection,
-        TInt aTransport,
-        TInt aRsc );
-    /**
-    * Observer callback for Connection Manager ConnectionComplete 
-    * function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aConnection
-    */         
-    void CmComplete(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        TInt aConnection );
-    /**
-    * Observer callback for Connection Manager GetCurrentConnectionIDs
-    * function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aConnection
-    */         
-    void CmCurrentConnections(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aConnections);
-    /**
-    * Observer callback for Connection Manager GetCurrentConnectionInfo
-    * function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param rscId
-    * @param aProtocolInfo
-    * @param aPeerConnectionManager
-    * @param peerId
-    * @param aStatus
-    */   
-    void CmCurrentInfo(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        TInt rscId, 
-        TInt transportId, 
-        const TDesC8& aProtocolInfo,
-        const TDesC8& aPeerConnectionManager, 
-        TInt peerId, 
-        const TDesC8& aDirection, 
-        const TDesC8& aStatus );
-
-    //*****************************************************************
-    //Functions for UPnP event handling
-    //*****************************************************************
-    /**
-    * Content Directory SystemUpdateId event handler.
-    * @since Series 60 2.6
-    * @param aUuid Device UUID.
-    * @param aSystemUpdateId Device systemUpdateId.
-    */
-    void CdsUpdateEvent(
-            const TDesC8& aUuid,
-            TInt aSystemUpdateId
-            ) ;
-    /**
-    * Content Directory ContainerUpdateIDs event handler.
-    * @since Series 60 2.6
-    * @param aUuid Device UUID.
-    * @param aConteinerIds Device container update ids.
-    */
-    void CdsContainerEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aConteinerIds
-            );
-    /**
-    * Content Directory TransferIDs event handler.
-    * @since Series 60 2.6
-    * @param aUuid Device UUID.
-    * @param aTransferIds Device transfer ids.
-    */
-    void CdsTransferEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aTransferIds
-            );
-    /**
-    * Rendering Control LastChange event handler.
-    * @since Series 60 2.6
-    * @param aUuid Device UUID.
-    * @param aLastChange Device LastChange statevariable.
-    */
-    void RcLastChangeEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aLastChange
-            );
-    /**
-    * AV Transport LastChange event handler.
-    * @since Series 60 2.6
-    * @param aUuid Device UUID.
-    * @param aLastChange Device LastChange statevariable.
-    */
-    void AvtLastChangeEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aLastChange
-            );
-    /**
-    * Connection Manager SourceEvent event handler.
-    * @since Series 60 2.6
-    * @param aUuid Device UUID.
-    * @param aSource Device's source info.
-    */
-    void CmSourceEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aSource
-            );
-    /**
-    * Connection Manager SinkEvent event handler.
-    * @since Series 60 2.6
-    * @param aUuid Device UUID.
-    * @param aSink Device's sink info.
-    */
-    void CmSinkEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aSink
-            );
-    /**
-    * Connection Manager ConnectionsEvent event handler.
-    * @since Series 60 2.6
-    * @param aUuid Device UUID.
-    * @param aConnections Devices connections.
-    */
-    void CmConnectionsEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aConnections
-            );
-    //*****************************************************************
-    // Device and http functions.
-    //*****************************************************************
-    /**
-    * Handles HTTP messages.
-    * @since Series 60 2.6
-    * @param aMessage Incoming HTTP message.
-    */
-    void HttpResponseL(CUpnpHttpMessage* aMessage) ;
-
-    /**
-    * Handles UPnP device discoveries.
-    * @since Series 60 2.6
-    * @param aDevice Device that is discovered.
-    */
-    void DeviceDiscoveredL(CUpnpDevice* aDevice);
-
-    /**
-    * Handles UPnP device disappears.
-    * @since Series 60 2.6
-    * @param aDevice Device that disappeared.
-    */
-    void DeviceDisappearedL(CUpnpDevice* aDevice);
-    
-public: // New methods
-
-    void RegisterL( TInt aSessionId,
-        MUpnpAVControlPointObserver& aObserver/*, const TDesC8& aUuid*/ );
-
-    void UnRegister( TInt aSessionId /*, const TDesC8& aUuid*/ );
-
-    void RegisterForEventsL( MUpnpAVControlPointObserver& aObserver,
-        const TDesC8& aUuid );
-
-    void UnRegisterEvents( MUpnpAVControlPointObserver& aObserver );
-
-private: // New methods
-
-    MUpnpAVControlPointObserver& FindObserver( TInt aSessionId );   
-
-private:
-    
-    CUpnpAVControllerServer&            iServer;            
-
-    /** @var iSessionCount the number of session owned by this server */
-    RPointerArray<CUPnPAVActionInfo>    iActionInfos;
-
-    //RPointerArray<CUPnPAVActionInfo>    iActionInfosDevice;
-
-    RPointerArray<CUPnPAVActionInfo>    iActionInfosEvent;
-    
-    };
-
-
+/*
+* Copyright (c) 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:      dispatches control point indications for clients
+*
+*/
+
+
+
+
+
+
+#ifndef C_CUPNPAVDISPATCHER_H
+#define C_CUPNPAVDISPATCHER_H
+
+
+#include <e32base.h>
+#include "upnpavcontrolpointobserver.h"
+
+// FORWARD DECLARATIONS
+class CUpnpAction;
+class CUpnpService;
+class CUpnpHttpMessage;
+class CUpnpDevice;
+class CUPnPAVActionInfo;
+class CUPnPAVControllerImpl;
+class CUpnpAVControllerServer;
+
+
+// CLASS DECLARATION
+
+/**
+*  UPnP AV Controller callback dispatcher
+*  
+*
+*  @lib - 
+*  @since Series 60 3.1
+*/
+
+class CUPnPAVDispatcher : public CBase,
+                          public MUpnpAVControlPointObserver
+    {
+public:  // Constructors and destructor
+        
+    /**
+    * Two-phased constructor.
+    */
+    static CUPnPAVDispatcher* NewLC( CUpnpAVControllerServer& aServer );
+    
+    /**
+    * Two-phased constructor.
+    */
+    static CUPnPAVDispatcher* NewL( CUpnpAVControllerServer& aServer );    
+
+    /**
+    * Destructor.
+    */
+    virtual ~CUPnPAVDispatcher();
+
+private: // New methods
+
+    /**
+    * Constructs the server 
+    * @param aPriority CServer2 input parameter
+    */
+    CUPnPAVDispatcher( CUpnpAVControllerServer& aServer );
+
+    /**
+     * Perform the second phase construction of a CUpnpMessageHandler object
+     */
+    void ConstructL();
+
+private: // from MUpnpAVControlPointObserver
+
+    // dispatches this event to its true handler based on who's registered
+    void ActionResponseL(CUpnpAction* aAction );
+
+    // dispatches this event to its true handler based on who's registered
+    void StateUpdatedL(CUpnpService* aService);
+
+    // dispatches this event to its true handler based on who's registered
+    void HttpResponseL(CUpnpHttpMessage* aMessage);
+
+    // dispatches this event to its true handler based on who's registered
+    void DeviceDiscoveredL(CUpnpDevice* aDevice);
+
+    // dispatches this event to its true handler based on who's registered
+    void DeviceDisappearedL(CUpnpDevice* aDevice);
+
+public: // New methods
+    
+    /**
+     * Register itself to get any observer call from AV control point
+     * @param TInt the session id
+     * @param MUpnpAVControlPointObserver& observer reference
+     *
+     * @return none
+     */
+    void RegisterL( TInt aSessionId,
+        MUpnpAVControlPointObserver& aObserver );
+
+    /**
+     * UnRegister itself Not to get any observer call from AV control point
+     * @param TInt the session id
+     *
+     * @return none
+     */
+    void UnRegister( TInt aSessionId /*, const TDesC8& aUuid*/ );
+
+    /**
+     * Register itself to get any events call from AV control point
+     * @param MUpnpAVControlPointObserver& observer reference
+     * @param TDesC8 the uid
+     *
+     * @return none
+     */
+    void RegisterForEventsL( MUpnpAVControlPointObserver& aObserver,
+        const TDesC8& aUuid );
+    
+    /**
+     * UnRegister itself Not to get any events call from AV control point
+     * @param MUpnpAVControlPointObserver& observer reference
+     *
+     * @return none
+     */
+    void UnRegisterEvents( MUpnpAVControlPointObserver& aObserver );
+
+private: // New methods
+    
+    /**
+     * Find the observer via the session id
+     * @param TInt session id
+     *
+     * @return MUpnpAVControlPointObserver& the reference to the observer
+     */
+    MUpnpAVControlPointObserver& FindObserver( TInt aSessionId );   
+
+private:
+    
+    CUpnpAVControllerServer&            iServer;            
+
+    RPointerArray<CUPnPAVActionInfo>    iActionInfos; //owned
+
+    RPointerArray<CUPnPAVActionInfo>    iActionInfosEvent; //owned
+    
+    };
+
 #endif // C_CUPNPAVDISPATCHER_H
\ No newline at end of file
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpavtimer.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpavtimer.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,127 +1,130 @@
-/*
-* 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:      provides timing services for AVController server
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPAVTIMER_H_
-#define C_UPNPAVTIMER_H_
-
-// Include files
-#include <e32base.h>
-
-const TInt KTimerCycle3         = 3;
-const TInt KTimerCycle10        = 10;
-const TInt KTimerCycle30        = 30;
-const TInt KTimerCycle300       = 300;
-
-// Forward declarations
-class CUPnPBrowsingSession;
-class MUPnPAVTimerCallback;
-
-/**
- * Timer class. Used as a server (AVC and S60 Media Server) shutdown timer.
- *
- */
-class CUPnPAVTimer: public CTimer
-    {
-
-public:
-
-    /**
-     * Timer type defination
-     */    
-    enum TAVTimerType
-        {
-        ETimerServerShutdown = 0,
-        ETimerMediaServer
-        };
- 
-public:
-
-    /**
-     * Static 1st phase constructor
-     * @param aObserver Observer
-     * @param aType timer type
-     * @return A new timer instance
-     */    
-    static CUPnPAVTimer* NewL( MUPnPAVTimerCallback& aObserver,
-        TAVTimerType aType );
-
-    /**
-     * Destructor
-     */    
-    virtual ~CUPnPAVTimer();
-    
-    
-private:
-
-    /**
-     * Private constructor
-     * @param aObserver Observer
-     * @param aType timer type
-     */
-    CUPnPAVTimer( MUPnPAVTimerCallback& aObserver, TAVTimerType aType );
-    
-    /**
-     * 2nd phase construct
-     */
-    void ConstructL();
-    
-protected: // From CTimer (CActive)
-
-    /**
-     * See e32base.h
-     */
-    void RunL();
-
-public: // New functions
-
-    /**
-     * Starts the timer
-     * @param aType Type of timing interval
-     */
-    void Start( TInt aIntervalInSecs );
-        
-private:
-    
-    MUPnPAVTimerCallback& iObserver; // Not Own
-    
-    TAVTimerType iTimerType;
-    
-    };
-
-/**
- * Timer observer
- *
- */
-class MUPnPAVTimerCallback
-    {
-public:
-
-    /**
-     * Called when timer expires
-     *
-     * @param aType time-out type
-     */
-    virtual void UPnPAVTimerCallback( CUPnPAVTimer::TAVTimerType aType ) = 0;
-    
-    };
-
+/*
+* 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:      provides timing services for AVController server
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPAVTIMER_H_
+#define C_UPNPAVTIMER_H_
+
+// Include files
+#include <e32base.h>
+
+const TInt KTimerCycle1         = 1;
+const TInt KTimerCycle3         = 3;
+const TInt KTimerCycle5         = 5;
+const TInt KTimerCycle10        = 10;
+const TInt KTimerCycle30        = 30;
+const TInt KTimerCycle300       = 300;
+
+// Forward declarations
+class CUPnPBrowsingSession;
+class MUPnPAVTimerCallback;
+
+/**
+ * Timer class. Used as a server (AVC and S60 Media Server) shutdown timer.
+ *
+ */
+class CUPnPAVTimer: public CTimer
+    {
+
+public:
+
+    /**
+     * Timer type defination
+     */    
+    enum TAVTimerType
+        {
+        ETimerServerShutdown = 0,
+        ETimerMediaServer,
+        ETimerFailSafe
+        };
+ 
+public:
+
+    /**
+     * Static 1st phase constructor
+     * @param aObserver Observer
+     * @param aType timer type
+     * @return A new timer instance
+     */    
+    static CUPnPAVTimer* NewL( MUPnPAVTimerCallback& aObserver,
+        TAVTimerType aType );
+
+    /**
+     * Destructor
+     */    
+    virtual ~CUPnPAVTimer();
+    
+    
+private:
+
+    /**
+     * Private constructor
+     * @param aObserver Observer
+     * @param aType timer type
+     */
+    CUPnPAVTimer( MUPnPAVTimerCallback& aObserver, TAVTimerType aType );
+    
+    /**
+     * 2nd phase construct
+     */
+    void ConstructL();
+    
+protected: // From CTimer (CActive)
+
+    /**
+     * See e32base.h
+     */
+    void RunL();
+
+public: // New functions
+
+    /**
+     * Starts the timer
+     * @param aType Type of timing interval
+     */
+    void Start( TInt aIntervalInSecs );
+        
+private:
+    
+    MUPnPAVTimerCallback& iObserver; // Not Own
+    
+    TAVTimerType iTimerType;
+    
+    };
+
+/**
+ * Timer observer
+ *
+ */
+class MUPnPAVTimerCallback
+    {
+public:
+
+    /**
+     * Called when timer expires
+     *
+     * @param aType time-out type
+     */
+    virtual void UPnPAVTimerCallback( CUPnPAVTimer::TAVTimerType aType ) = 0;
+    
+    };
+
 #endif // C_UPNPAVTIMER_H_
\ No newline at end of file
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpbrowsingsession.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpbrowsingsession.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1290 +1,355 @@
-/*
-* Copyright (c) 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:      implementation for session towards a media server
-*
-*/
-
-
-
-
-
-
-
-#ifndef C_UPNPBROWSINGSESSION_H
-#define C_UPNPBROWSINGSESSION_H
-
-// INCLUDE FILES
-#include <e32base.h>
-#include "upnpavcontroller.h"
-#include <upnpavcontrolpointobserver.h>
-#include <upnpmediaserverobserver.h>
-#include "upnpavbrowsingsession.h"
-
-
-// FORWARD DECLARATIONS
-class CUpnpItem;
-class CUpnpObject;
-class CUpnpAVRequest;
-class CUpnpAVBrowseRequest;
-class CUPnPFileSharingActive;
-class CUpnpMediaServerNotifier;
-class RUpnpMediaServerClient;
-class CUpnpAVDeviceExtended;
-class CUpnpMediaServerSettings;
-class CRepository;
-class CUpnpAVControllerServer;
-/**
- * Implements server side browsing session functionality. Implements
- * browsing, searching, copying etc.  
- *
- * @since S60 v3.1
- */
-class CUPnPBrowsingSession :    public CBase,
-                                public MUpnpAVControlPointObserver,
-                                public MUpnpMediaServerObserver
-    {
-
-private:
-
-    /**
-     * Defines the internal state of browsing session
-     */
-    enum TInternalBrowseState
-        {
-        ENone,
-        EBrowse,
-        EDestroyObject,
-        ECopyLocal,
-        ECreateContainer,
-        ECopyToPhone
-        };
-
-    enum TInternalCopyState
-        {
-        EIdle,
-        EObjectCreated,
-        ECopying
-        };
-
-public:
-
-    /**
-     * Static 1st phase constructor
-     *
-     * @param aControlPoint AV Control Point reference
-     * @param aClient S60 Media Server session reference
-     * @param aDispatcher observer callback dispatcher reference
-     * @param aSessionId session id
-     * @param aUuid device Uuid
-     */
-    static CUPnPBrowsingSession* NewL
-        (
-        RUpnpMediaServerClient& aClient,
-        CUpnpAVControllerServer& aServer,
-        TInt aSessionId,   
-        const TDesC8& aUuid
-        );
-    
-    /**
-     * Destructor
-     */
-    virtual ~CUPnPBrowsingSession();
-    
-private:
-
-    /**
-     * Private constructor
-     *
-     * @param aControlPoint AV Control Point reference
-     * @param aClient S60 Media Server session reference
-     * @param aDispatcher observer callback dispatcher reference
-     * @param aSessionId session id
-     */
-    CUPnPBrowsingSession
-        (
-        RUpnpMediaServerClient& aClient,
-        CUpnpAVControllerServer& aServer,
-        TInt aSessionId
-        );    
-    
-    /**
-     * 2ns phase constructor
-     */
-    void ConstructL( const TDesC8& aUuid );
-
-protected: // From MUpnpAVControlPointObserver
-
-    /**
-     * Observer callback for rendering control Set Volume.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aChannel audio channel.
-     * @param aDesiredVolume 
-     */
-    void RcSetVolumeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aDesiredVolume);
-        
-    /**
-     * Observer callback for rendering control Get Volume.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aChannel audio channel.
-     * @param aCurrentVolume 
-     */
-    void RcVolumeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aCurrentVolume);
-         
-    /**
-     * Observer callback for rendering control Set Mute.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aChannel audio channel.
-     * @param aDesiredMute 
-     */
-    void RcSetMuteResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aDesiredMute);
-        
-    /**
-     * Observer callback for rendering control Get Mute.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aChannel audio channel.
-     * @param aCurrentMute 
-     */
-    void RcMuteResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aCurrentMute); 
-
-
-    /**
-     * Observer callback for rendering control AV set transport uri.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aCurrentUri Current transport URI.
-     * @param Current transport URI Metadata. 
-     */
-    void AvtSetTransportUriResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aCurrentUri,
-        const TDesC8& aCurrentUriMetaData);
-        
-    /**
-     * Observer callback for rendering control AV set next transport uri.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aCurrentUri Current transport URI.
-     * @param Current transport URI Metadata. 
-     */
-    virtual void AvtSetNextTransportUriResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNextUri,
-        const TDesC8& aNextUriMetaData);
-        
-    /**
-     * Observer callback for rendering control AV get media info response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aNrTracks Number of tracks.
-     * @param aMediaDuration 
-     * @param aCurrentUri Current transport URI.
-     * @param aCurrentUriMetaData Metadata of current trransport uri. 
-     * @param aNextUri Next transport URI.
-     * @param aNextUriMetaData Metadata of next trransport uri.
-     * @param aPlayMedium
-     * @param aRecordMedium
-     * @param aWriteStatus
-     */
-    void AvtMediaInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNrTracks,
-        const TDesC8& aMediaDuration,
-        const TDesC8& aCurrentUri,
-        const TDesC8& aCurrentUriMetaData,
-        const TDesC8& aNextUri,
-        const TDesC8& aNextUriMetaData,
-        const TDesC8& aPlayMedium,
-        const TDesC8& aRecordMedium,
-        const TDesC8& aWriteStatus);
-        
-    /**
-     * Observer callback for rendering control AV get transport info response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aCurrenTransportState
-     * @param aCurrentTransportStatus
-     * @param aCurrentUri aCurrentSpeed
-     */
-    void AvtGetTransportInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aCurrenTransportState,
-        const TDesC8& aCurrentTransportStatus,
-        const TDesC8& aCurrentSpeed);
-        
-    /**
-     * Observer callback for rendering control AV get position info response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aTrack rendering instance.
-     * @param aTrackDuration 
-     * @param aTrackMetaData
-     * @param aTrackURI
-     * @param aRelTime
-     * @param aAbsTime
-     * @param aRelCount
-     * @param aAbsCount
-     */
-    void AvtPositionInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aTrack,
-        const TDesC8& aTrackDuration,
-        const TDesC8& aTrackMetaData,
-        const TDesC8& aTrackURI,
-        const TDesC8& aRelTime,
-        const TDesC8& aAbsTime,
-        const TDesC8& aRelCount,
-        const TDesC8& aAbsCount);
-        
-    /**
-     * Observer callback for rendering control AV get device
-     * capabilities response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aPlayMedia
-     * @param aRecMedia 
-     * @param aRecQualityModes
-     */
-    void AvtDeviceCapabilitiesResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aPlayMedia,
-        const TDesC8& aRecMedia,
-        const TDesC8& aRecQualityMode);
-        
-    /**
-     * Observer callback for rendering control AV get transport
-     * settings response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId
-     * @param aInstanceId
-     * @param aErr UPnP error code.        
-     * @param aPlayMode
-     * @param aRecQualityMode
-     */
-    void AvtTransportSettingsResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aPlayMode,
-        const TDesC8& aRecQualityMode);
-        
-    /**
-     * Observer callback for rendering control AV Stop response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     */
-    void AvtStopResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-        
-    /**
-     * Observer callback for rendering control AV Play response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSpeed
-     */
-    void AvtPlayResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aSpeed);
-    
-    /**
-     * Observer callback for rendering control AV Pause response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     */
-    void AvtPauseResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-        
-    /**
-     * Observer callback for rendering control AV Record response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     */
-    void AvtRecordResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-        
-    /**
-     * Observer callback for rendering control AV Seek response.
-     * @since Series 60 2.6
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aUnit
-     * @param aTarget
-     */
-    void AvtSeekResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aUnit,
-        const TDesC8& aTarget);
-        
-    /**
-     * Observer callback for rendering control AV Next response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     */
-    void AvtNextResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-        
-    /**
-     * Observer callback for rendering control AV Previous response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     */
-    void AvtPreviousResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-    
-    /**
-     * Observer callback for rendering control AV setplay mode response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aNewPlayMode
-     */
-    void AvtSetPlayModeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNewPlayMode);
-        
-    /**
-     * Observer callback for rendering control AV set record qualityresponse.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aNewRecordQuality
-     */
-    void AvtSetRecordModeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNewRecordQuality);
-        
-    /**
-     * Observer callback for Content Directory GetSearchCapabilities function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSearchCaps
-     */
-    void CdsSearchCapabilitiesResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSearchCaps);
-        
-    /**
-     * Observer callback for Content Directory GetSortCapabilities function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSortCaps
-     */
-    void CdsSortCapabilitiesResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSortCaps);
-
-    /**
-     * Observer callback for Content Directory GetSystemUpdateID function.
-     * @since Series 60 2.6
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSystemUpdateId
-     */
-    void CdsSystemUpdateIdResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        TInt aSystemUpdateId);
-    /**
-    * Observer callback for Content Directory Browse function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aObjectID
-    * @param aBrowseFlag
-    * @param aFilter
-    * @param aIndex
-    * @param arequest
-    * @param aSortCriteria
-    * @param aResult
-    * @param aReturned
-    * @param aMatches
-    * @param aUpdateID
-    */
-    
-    void CdsBrowseResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aObjectID,
-        const TDesC8&  aBrowseFlag,
-        const TDesC8&  aFilter,
-        TInt aIndex,
-        TInt aRequest,
-        const TDesC8&  aSortCriteria,
-        const TDesC8&  aResult,
-        TInt aReturned,
-        TInt aMatches,
-        const TDesC8&  aUpdateID);
-        
-    /**
-     * Observer callback for Content Directory Search function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aContainerId
-     * @param aSearchCriteria
-     * @param aFilter
-     * @param aIndex
-     * @param arequest
-     * @param aSortCriteria
-     * @param aResult
-     * @param aReturned
-     * @param aMatches
-     * @param aUpdateID
-     */
-     
-    void CdsSearchResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aContainerId,
-        const TDesC8& aSearchCriteria,
-        const TDesC8& aFilter,
-        TInt aIndex,
-        TInt aRequest,
-        const TDesC8& aSortCriteria,
-        const TDesC8& aResult,
-        TInt aReturned,
-        TInt aMatches,
-        const TDesC8& aUpdateID);
-        
-    /**
-     * Observer callback for Content Directory DestroyObject function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aObjectId
-     */
-    void CdsDestroyObjectResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aObjectId );
-        
-    /**
-     * Observer callback for Content Directory UpdateObject function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aObjectId
-     * @param aCurrentTagValue
-     * @param aNewTagValue
-     */
-    void CdsUpdateObjectResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aObjectId,
-        const TDesC8& aCurrentTagValue,
-        const TDesC8& aNewTagValue );
-        
-    /**
-     * Observer callback for Content Directory ImportResource function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSourceURI
-     * @param aDestinationURI
-     * @param aTransferId
-     */       
-    void CdsImportResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSourceURI,
-        const TDesC8& aDestinationURI,
-        const TDesC8& aTransferId );
-        
-    /**
-     * Observer callback for Content Directory ExportResource function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSourceURI
-     * @param aDestinationURI
-     * @param aTransferId
-     */       
-    void CdsExportResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSourceURI,
-        const TDesC8& aDestinationURI,
-        const TDesC8& aTransferId );
-        
-    /**
-     * Observer callback for Content Directory StopTransfer function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSourceURI
-     * @param aDestinationURI
-     * @param aTransferId
-     */       
-    void CdsStopTransferResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aTransferId );
-    
-    /**
-     * Observer callback for Content Directory GetTransferProgress function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aTransferId
-     * @param aTransferStatus
-     * @param aTransferTotal
-     */         
-    virtual void CdsCTransferProgressResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aTransferId,
-        const TDesC8& aTransferStatus,
-        const TDesC8& aTransferLength,            
-        const TDesC8& aTransferTotal );
-        
-    /**
-     * Observer callback for Content Directory DeleteResource function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aResourceUri Resource to be deleted.
-     */ 
-    void CdsDeleteResourceResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aResourceUri );
-        
-    /**
-     * Observer callback for Content Directory CreateReference function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aContainerId Destination folder.
-     * @param aObjectId Source object.
-     * @param aNewId Created reference.
-     */ 
-    void CdsCreateReferenceResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aContainerId, 
-        const TDesC8& aObjectId, 
-        const TDesC8& aNewId );
-        
-    /**
-     * Observer callback for Content Directory CreateReference function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aContainerID Container in which new object is created.
-     * @param aElements Elements for item creation.
-     * @param aObjectID New objects ID.
-     * @param aResult Result of the action.
-     */ 
-    void CdsCreateObjectResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aContainerID, 
-        const TDesC8& aElements, 
-        const TDesC8& aObjectID, 
-        const TDesC8& aResult );
-        
-
-    /**
-     * Observer callback for Connection Manager GetProtocolInfo function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSource
-     * @param aSink
-     */ 
-    void CmProtocolInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSource, 
-        const TDesC8& aSink );
-    
-    /**
-     * Observer callback for Connection Manager PrepareForConnection 
-     * function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aRemoteProtocolInfo
-     * @param aPeerConnectionManager
-     * @param aPeerConnectionId
-     * @param aDirection
-     * @param aConnection
-     * @param aTransport
-     * @param aRsc
-     */        
-    void CmPrepareResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aRemoteProtocolInfo,
-        const TDesC8& aPeerConnectionManager,
-        const TDesC8& aPeerConnectionId,
-        const TDesC8& aDirection,
-        TInt aConnection,
-        TInt aTransport,
-        TInt aRsc );
-    
-    /**
-     * Observer callback for Connection Manager ConnectionComplete 
-     * function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aConnection
-     */         
-    void CmComplete(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        TInt aConnection );
-        
-    /**
-     * Observer callback for Connection Manager GetCurrentConnectionIDs
-     * function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aConnection
-     */         
-    void CmCurrentConnections(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aConnections);
-        
-    /**
-     * Observer callback for Connection Manager GetCurrentConnectionInfo
-     * function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param rscId
-     * @param aProtocolInfo
-     * @param aPeerConnectionManager
-     * @param peerId
-     * @param aStatus
-     */   
-    void CmCurrentInfo(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        TInt rscId, 
-        TInt transportId, 
-        const TDesC8& aProtocolInfo,
-        const TDesC8& aPeerConnectionManager, 
-        TInt peerId, 
-        const TDesC8& aDirection, 
-        const TDesC8& aStatus );
-
-    //*****************************************************************
-    //Functions for UPnP event handling
-    //*****************************************************************
-    /**
-     * Content Directory SystemUpdateId event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aSystemUpdateId Device systemUpdateId.
-     */
-    void CdsUpdateEvent(
-            const TDesC8& aUuid,
-            TInt aSystemUpdateId
-            );
-            
-    /**
-     * Content Directory ContainerUpdateIDs event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aConteinerIds Device container update ids.
-     */
-    void CdsContainerEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aConteinerIds
-            );
-            
-    /**
-     * Content Directory TransferIDs event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aTransferIds Device transfer ids.
-     */
-    void CdsTransferEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aTransferIds
-            );
-            
-    /**
-     * Rendering Control LastChange event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aLastChange Device LastChange statevariable.
-     */
-    void RcLastChangeEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aLastChange
-            );
-            
-    /**
-     * AV Transport LastChange event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aLastChange Device LastChange statevariable.
-     */
-    void AvtLastChangeEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aLastChange
-            );
-    /**
-     * Connection Manager SourceEvent event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aSource Device's source info.
-     */
-    void CmSourceEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aSource
-            );
-            
-    /**
-     * Connection Manager SinkEvent event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aSink Device's sink info.
-     */
-    void CmSinkEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aSink
-            );
-            
-    /**
-     * Connection Manager ConnectionsEvent event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aConnections Devices connections.
-     */
-    void CmConnectionsEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aConnections
-            );
-    //*****************************************************************
-    // Device and http functions.
-    //*****************************************************************
-    /**
-     * Handles HTTP messages.
-     * @since Series 60 2.6
-     * @param aMessage Incoming HTTP message.
-     */
-    void HttpResponseL( CUpnpHttpMessage* aMessage );
-
-public:
-
-    /**
-     * Handles UPnP device discoveries.
-     * @since Series 60 2.6
-     * @param aDevice Device that is discovered.
-     */
-    void DeviceDiscoveredL( CUpnpDevice* aDevice );
-
-    /**
-     * Handles UPnP device disappears.
-     * @since Series 60 2.6
-     * @param aDevice Device that disappeared.
-     */
-    void DeviceDisappearedL( CUpnpDevice* aDevice );    
- 
-protected: // From CUpnpMediaServerNotifier
-
-    /**
-     * Called when Content Directory file transfer is finished
-     * either with success or failure.
-     * See CUpnpFileTransferEvent class description for details.
-     *
-     * @since Series 60 3.1
-     * @param aEvents Media Server event
-     * @return notifier object
-     */
-    void FileTransferEvent( CUpnpFileTransferEvent *aEvent );
-    
-    /**
-     * Called when Content Directory file transfer is finished
-     * and iInternalState == ECopyToPhone
-     * @since Series 60 3.2
-     * @param aEvent Media Server event
-     * @param aError from FileTransferEvent
-     */
-    void HandleCopyToPhoneEventL( 
-        CUpnpFileTransferEvent& aEvent, 
-        TInt aError );
-
-    /**
-     * Called in case of CUpnpMediaServerNotifier internal error.
-     * Should be used for event handling recovery.
-     *
-     * @since Series 60 3.1
-     * @param aObserver event observer
-     * @return notifier object
-     */
-    void NotifierError( TInt aError );
-    
-public: // New functions
-
-    /**
-     * Handles UPnP device disappears.
-     *
-     * @param aDevice Device that disappeared.
-     */
-    void DeviceDisappearedL( CUpnpAVDeviceExtended& aDevice );
-
-    /**
-     * Sets local (S60) Media Server Uuid
-     *
-     * @param aUuid device Uuid
-     */
-    void SetLocalMSUuidL( const TDesC8& aUuid );
-
-    /**
-     * Returns Session Id
-     *
-     * @return session id
-     */
-    TInt SessionId() const;
-    
-    /**
-     * Returns device Uuid 
-     *
-     * @return device Uuid
-     */
-    const TDesC8& Uuid() const;
-    
-public:
-
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void GetBrowseResponseSizeL( const RMessage2& aMessage );  
-
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelGetBrowseResponseSizeL();
-
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void GetBrowseResponseL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void GetSearchResponseSizeL( const RMessage2& aMessage );
-
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelGetSearchResponseSizeL();
-
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void GetSearchResponseL( const RMessage2& aMessage );
-
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void GetSearchCapabitiesSizeL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelGetSearchCapabitiesSizeL();     
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void GetSearchCapabitiesL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CreateContainerL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelCreateContainerL();
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void DeleteObjectL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelDeleteObjectL();
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void DeviceDisappearedRequestL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelDeviceDisappearedRequestL();
-                                   
-private:
-
-    /**
-     * Parses create object -action response and returns import uri.
-     *
-     * @param aResponse create object -action response
-     * @return import uri (ownership is transferred)
-     */
-    HBufC8* ParseCreateObjectResponseL( const TDesC8& aResponse );
-
-    /**
-     * Parses browse response and checks if the container supports the 
-     * media type we are about to copy into it
-     *
-     * @param aResponse browse response
-     */
-    void CheckIsCreateObjectSupportedL( const TDesC8& aResponse );
-
-    /**
-     * Parses browse response and checks if the container supports the 
-     * media type we are about to copy into it. After that it sends
-     * a create object -action.
-     *
-     * @param aResponse browse response
-     */
-    void CheckAndSendCreateObjectActionL( const TDesC8& aResponse );
-
-    /**
-     * Parses browse response and checks if the object can be deleted. If
-     * supported, sends destroyobject-action.
-     *
-     * @param aResponse browse response
-     */
-    void CheckAndSendDestroyObjectActionL( const TDesC8& aResponse );    
-    
-    /**
-     * Sends a create object -action
-     *
-     * @param aUuid device uuid
-     * @param aContainerId container id
-     * @param aResponse elements xml
-     */
-    void SendCreateObjectActionL( const TDesC8& aUuid,
-        const TDesC8& aContainerId, const TDesC8& aResponse );
-
-    /**
-     * Sends export resource -action
-     */
-    void SendExportActionL();
-    
-    /**
-     * Sends import resource -action
-     */
-    void SendImportActionL();
-
-    /**
-     * Resets internal state
-     */
-    void ResetL();
-        
-    /**
-     * Postprocesses copy operation
-     *
-     * @param aError error code in copying
-     * @param aFinished state of copy (create object/ import/export action)
-     */
-    void CopyFinished( TInt aError, TBool aFinished ); 
-    
-    /**
-     * Reads an object from a message
-     *
-     * @param aMessage client/server message
-     * @param aSlot message slot number
-     * @param aObj UPnP object
-     */
-    void ReadObjFromMessageL( const RMessage2& aMessage, TInt aSlot,
-        CUpnpObject* aObj );
-        
-    /**
-     * Reads a request from a message
-     *
-     * @param aMessage client/server message
-     * @param aSlot message slot number
-     * @param aReq request
-     */
-    void ReadReqFromMessageL( const RMessage2& aMessage, TInt aSlot,
-        CUpnpAVRequest* aReq );
-        
-    /**
-     * Reads a browse request from a message
-     *
-     * @param aMessage client/server message
-     * @param aSlot message slot number
-     * @param aReq browse request
-     */
-    void ReadBrowseReqFromMessageL( const RMessage2& aMessage, TInt aSlot,
-        CUpnpAVBrowseRequest* aReq );
-
-    /**
-     * Reads a buffer from a message
-     *
-     * @param aMessage client/server message
-     * @param aSlot message slot number
-     * @return a buffer (heap descriptor)
-     */
-    HBufC8* ReadBufFromMessageLC( const RMessage2& aMessage, TInt aSlot );
-
-    /**
-     * Sets download settings. Not currently needed, for future use.
-     *
-     * @param aType download location
-     */
-    void SetDownloadSettingsL( MUPnPAVBrowsingSession::TMemoryType aType );
-    
-    /**
-     * Restores download settings. Not currently needed, for future use.
-     *
-     * @return error code
-     */
-    TInt RestoreDownloadSettings();
-    
-    /**
-     * Checks sharing status. Determines if the copied file is left shared or
-     * not.
-     *
-     * @return error code
-     */
-    TInt CheckSharingStatus();                      
-
-private:
-
-    RUpnpMediaServerClient&     iMediaServer; // Not own
-
-    CUpnpAVControllerServer&    iServer;
-    
-    TInt                        iSessionId;
-
-    TInt                        iInstanceId;
-    
-    TInt                        iIPSessionId;
-
-    TInt                        iTransferId;
-    
-    TBool                       iTransferEventReceived;
-    
-    TInternalBrowseState        iInternalState;
-    
-    TInternalCopyState          iCopyState;
-    
-    RMessage2*                  iActionMessage; // Own
-    
-    RMessage2*                  iDeviceMessage; // Own
-    
-    CUpnpAVDeviceExtended*      iDevice; // Own
-    
-    HBufC8*                     iLocalMediaServerUuid; // Own
-    
-    HBufC8*                     iRespBuf; // Own
-    
-    HBufC8*                     iRespBuf2; // Own  
-        
-    HBufC8*                     iImportURI; // Own
-    
-    HBufC8*                     iSourceURI; // Own
-    
-    HBufC8*                     iItemId; // Own
-    
-    HBufC8*                     iContainerId; // Own
-    
-    CUpnpItem*                  iSharedItem; // Own  
-    
-    CUPnPFileSharingActive*     iFileSharing; // Own
-      
-    CUpnpMediaServerNotifier*   iMediaServerNotifier; // Own
-    
-    HBufC8*                     iOriginalLocation; // Own
-    
-    HBufC8*                     iFilePath; // Own
-    
-    CUpnpMediaServerSettings*   iMSSettings; // Own, For future use
-    
-    CRepository*                iAppSettings; // Own
-
-    MUPnPAVBrowsingSession::TFileSharing iShareFlag;    
-    
-    TBool                       iMusic;
-    
-    TInt                        iAsyncErr;
-    
-    };
-
-#endif // C_UPNPBROWSINGSESSION_H
+/*
+* Copyright (c) 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:      implementation for session towards a media server
+*
+*/
+
+
+
+#ifndef C_UPNPBROWSINGSESSION_H
+#define C_UPNPBROWSINGSESSION_H
+
+// INCLUDE FILES
+#include <e32base.h>
+#include "upnpavcontroller.h"
+#include <upnpmediaserverobserver.h>
+#include "upnpavbrowsingsession.h"
+
+#include "upnpavcontrolpointobserver.h"
+
+
+// FORWARD DECLARATIONS
+class CUpnpObject;
+class CUpnpDevice;
+class CUpnpAVRequest;
+class CUpnpAVBrowseRequest;
+class CUpnpAVDeviceExtended;
+class CUpnpAVControllerServer;
+
+/**
+ * Implements server side browsing session functionality. Implements
+ * browsing, searching, copying etc.  
+ *
+ * @since S60 v3.1
+ */
+class CUPnPBrowsingSession : public CBase,
+                             private MUpnpAVControlPointObserver
+    {
+
+private:
+
+    /**
+     * Defines the internal state of browsing session
+     */
+    enum TInternalBrowseState
+        {
+        ENone,
+        EBrowse,
+        EDestroyObject,
+        ECreateContainer,
+        };
+
+
+public:
+
+    /**
+     * Static 1st phase constructor
+     *
+     * @param aControlPoint AV Control Point reference
+     * @param aClient S60 Media Server session reference
+     * @param aDispatcher observer callback dispatcher reference
+     * @param aSessionId session id
+     * @param aUuid device Uuid
+     */
+    static CUPnPBrowsingSession* NewL
+        (
+        CUpnpAVControllerServer& aServer,
+        TInt aSessionId,   
+        const TDesC8& aUuid
+        );
+    
+    /**
+     * Destructor
+     */
+    virtual ~CUPnPBrowsingSession();
+    
+private:
+
+    /**
+     * Private constructor
+     *
+     * @param aControlPoint AV Control Point reference
+     * @param aClient S60 Media Server session reference
+     * @param aDispatcher observer callback dispatcher reference
+     * @param aSessionId session id
+     */
+    CUPnPBrowsingSession
+        (
+        CUpnpAVControllerServer& aServer,
+        TInt aSessionId
+        );    
+    
+    /**
+     * 2ns phase constructor
+     */
+    void ConstructL( const TDesC8& aUuid );
+
+private: // From MUpnpAVControlPointObserver
+
+    void ActionResponseL(CUpnpAction* aAction );
+    void StateUpdatedL(CUpnpService* aService);
+    void HttpResponseL(CUpnpHttpMessage* aMessage);
+    void DeviceDiscoveredL(CUpnpDevice* aDevice);
+    void DeviceDisappearedL(CUpnpDevice* aDevice);
+
+private: // network event handling
+
+    /**
+     * Handles response for ContentDirectory SearchCapabilities command
+     */
+    void CdsSearchCapabilitiesResponse(
+        TInt aErr,
+        const TDesC8& aSearchCaps );
+
+    /**
+     * Handles response for ContentDirectory Browse command
+     */
+    void CdsBrowseResponseL(
+        TInt aErr,
+        const TDesC8&  aBrowseFlag,
+        const TDesC8&  aResult,
+        TInt aReturned,
+        TInt aMatches,
+        const TDesC8& aUpdateID );
+
+    /**
+     * Handles response for ContentDirectory Search command
+     */
+    void CdsSearchResponse(
+        TInt aErr,
+        const TDesC8& aResult,
+        TInt aReturned,
+        TInt aMatches,
+        const TDesC8& aUpdateID );
+
+    /**
+     * Handles response for ContentDirectory DestroyObject command
+     */
+    void CdsDestroyObjectResponse(
+        TInt aErr );
+
+    /**
+     * Handles response for ContentDirectory CreateObject command
+     */
+    void CdsCreateObjectResponse(
+        TInt aErr,
+        const TDesC8& aObjectID, 
+        const TDesC8& aResult );
+
+public: // New functions
+
+    /**
+     * Handles UPnP device disappears.
+     *
+     * @param aDevice Device that disappeared.
+     */
+    void DeviceDisappearedL( CUpnpAVDeviceExtended& aDevice );
+
+    /**
+     * Sets local (S60) Media Server Uuid
+     *
+     * @param aUuid device Uuid
+     */
+    void SetLocalMSUuidL( const TDesC8& aUuid );
+
+    /**
+     * Returns Session Id
+     *
+     * @return session id
+     */
+    TInt SessionId() const;
+    
+    /**
+     * Returns device Uuid 
+     *
+     * @return device Uuid
+     */
+    const TDesC8& Uuid() const;
+    
+public:
+
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void GetBrowseResponseSizeL( const RMessage2& aMessage );  
+
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelGetBrowseResponseSizeL();
+
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void GetBrowseResponseL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void GetSearchResponseSizeL( const RMessage2& aMessage );
+
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelGetSearchResponseSizeL();
+
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void GetSearchResponseL( const RMessage2& aMessage );
+
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void GetSearchCapabitiesSizeL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelGetSearchCapabitiesSizeL();     
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void GetSearchCapabitiesL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CreateContainerL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelCreateContainerL();
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void DeleteObjectL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelDeleteObjectL();
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void DeviceDisappearedRequestL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelDeviceDisappearedRequestL();
+                                   
+private:
+
+
+    /**
+     * Parses browse response and checks if the object can be deleted. If
+     * supported, sends destroyobject-action.
+     *
+     * @param aResponse browse response
+     */
+    void CheckAndSendDestroyObjectActionL( const TDesC8& aResponse );    
+    
+
+    /**
+     * Resets internal state
+     */
+    void ResetL();
+        
+
+    /**
+     * Reads an object from a message
+     *
+     * @param aMessage client/server message
+     * @param aSlot message slot number
+     * @param aObj UPnP object
+     */
+    void ReadObjFromMessageL( const RMessage2& aMessage, TInt aSlot,
+        CUpnpObject* aObj );
+        
+    /**
+     * Reads a request from a message
+     *
+     * @param aMessage client/server message
+     * @param aSlot message slot number
+     * @param aReq request
+     */
+    void ReadReqFromMessageL( const RMessage2& aMessage, TInt aSlot,
+        CUpnpAVRequest* aReq );
+        
+    /**
+     * Reads a browse request from a message
+     *
+     * @param aMessage client/server message
+     * @param aSlot message slot number
+     * @param aReq browse request
+     */
+    void ReadBrowseReqFromMessageL( const RMessage2& aMessage, TInt aSlot,
+        CUpnpAVBrowseRequest* aReq );
+
+    /**
+     * Reads a buffer from a message
+     *
+     * @param aMessage client/server message
+     * @param aSlot message slot number
+     * @return a buffer (heap descriptor)
+     */
+    HBufC8* ReadBufFromMessageLC( const RMessage2& aMessage, TInt aSlot );
+
+
+private:
+
+    CUpnpAVControllerServer&    iServer;
+    
+    TInt                        iSessionId;
+
+    TInt                        iInstanceId;
+    
+    TInt                        iIPSessionId;
+
+    TInternalBrowseState        iInternalState;
+    
+    RMessage2*                  iActionMessage; // Own
+    
+    RMessage2*                  iDeviceMessage; // Own
+    
+    CUpnpAVDeviceExtended*      iDevice; // Own
+
+    const CUpnpDevice*          iCpDevice; // Not own.    
+    
+    HBufC8*                     iLocalMediaServerUuid; // Own
+    
+    HBufC8*                     iRespBuf; // Own
+    
+    HBufC8*                     iRespBuf2; // Own  
+        
+    HBufC8*                     iItemId; // Own
+    
+    };
+
+#endif // C_UPNPBROWSINGSESSION_H
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpdevicerepository.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpdevicerepository.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,158 +1,165 @@
-/*
-* 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:      a list of devices with extended information
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPDEVICEREPOSITORY_H_
-#define C_UPNPDEVICEREPOSITORY_H_
-
-// Include files
-#include <e32base.h>
-
-// FORWARD DECLARATIONS
-class CUpnpAVDevice;
-class CUpnpAVDeviceExtended;
-class CUpnpDevice;
-class CUpnpAVControlPoint;
-
-/**
- * UPnP Device Repository. Stores UPnP devices with additional (protocolinfo)
- * information.
- */
-class CUPnPDeviceRepository: public CBase
-    {
- 
-public:
-
-    /**
-     * Static 1st phase constructor
-     *
-     * @param aControlPoint AV Control Point instance
-     * @return new instance
-     */    
-    static CUPnPDeviceRepository* NewL
-        (
-        CUpnpAVControlPoint& aControlPoint
-        );
-
-    /**
-     * Destructor
-     */    
-    virtual ~CUPnPDeviceRepository();
-      
-private:
-
-    /**
-     * Private constructor
-     */
-    CUPnPDeviceRepository
-        (
-        CUpnpAVControlPoint& aControlPoint
-        );
-
-    /**
-     * 2nd phase constructor
-     */    
-    void ConstructL();    
-
-public: // New functions
-
-    /**
-     * Adds a new device to repository
-     *
-     * @param aDevice UPnP Device
-     */    
-    void AddDeviceL( CUpnpDevice& aDevice );
-    
-    /**
-     * Adds protoconinfo to a device
-     *
-     * @param aUuid device uuid
-     * @param aSource source protocolinfo
-     * @param aSink sink protocolinfo
-     * @return UPnP device with protocolinfo
-     */    
-    CUpnpAVDeviceExtended& AddProtocolInfoL( const TDesC8& aUuid,
-        const TDesC8& aSource, const TDesC8& aSink );
-        
-    /**
-     * Removes a device from repository
-     *
-     * @param aUuid device Uuid
-     */    
-    void Remove( const TDesC8& aUuid );
-    
-    /**
-     * Finds and return a device
-     *
-     * @param aUuid device Uuid
-     * @return device reference
-     */    
-    CUpnpAVDeviceExtended& FindDeviceL( const TDesC8& aUuid );
-    
-    /**
-     * Return a list of devices
-     *
-     * @return list of device
-     */    
-    const RPointerArray<CUpnpAVDeviceExtended>& DeviceList() const;
-    
-    /**
-     * Subscibe device for events (sends subscribe action)
-     *
-     * @param aUuid device Uuid
-     */    
-    void SubscribeDeviceL( const TDesC8& aUuid );     
-
-    /**
-     * Unsubscibe device for events (sends unsubscribe action)
-     *
-     * @param aUuid device Uuid
-     */    
-    void UnSubscribeDeviceL( const TDesC8& aUuid );
-    
-    void ConnectionLost();
-    
-    TBool IsWlanActive(); 
-    
-private:
-
-    /**
-     * Parses devices services (goes through actions and determines what's
-     * supported.
-     *
-     * @param aSource source device
-     * @param aTarget target device
-     */    
-    void ParseDeviceServicesL( CUpnpDevice& aSource,
-        CUpnpAVDeviceExtended& aTarget );
-
-   
-private:
-
-    CUpnpAVControlPoint&        iControlPoint; // Not own        
-   
-    RPointerArray<CUpnpAVDeviceExtended> iDevices; // Own
-    
-    TBool iIsWlanActive;
-    };
-
-
+/*
+* 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:      a list of devices with extended information
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPDEVICEREPOSITORY_H_
+#define C_UPNPDEVICEREPOSITORY_H_
+
+// Include files
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CUpnpAVDevice;
+class CUpnpAVDeviceExtended;
+class CUpnpDevice;
+class CUpnpAVControlPoint;
+class CUpnpStateVariable;
+
+/**
+ * UPnP Device Repository. Stores UPnP devices with additional (protocolinfo)
+ * information.
+ */
+class CUPnPDeviceRepository: public CBase
+    {
+ 
+public:
+
+    /**
+     * Static 1st phase constructor
+     *
+     * @param aControlPoint AV Control Point instance
+     * @return new instance
+     */    
+    static CUPnPDeviceRepository* NewL
+        (
+        CUpnpAVControlPoint& aControlPoint
+        );
+
+    /**
+     * Destructor
+     */    
+    virtual ~CUPnPDeviceRepository();
+      
+private:
+
+    /**
+     * Private constructor
+     */
+    CUPnPDeviceRepository
+        (
+        CUpnpAVControlPoint& aControlPoint
+        );
+
+    /**
+     * 2nd phase constructor
+     */    
+    void ConstructL();    
+
+public: // New functions
+
+    /**
+     * Adds a new device to repository
+     *
+     * @param aDevice UPnP Device
+     */    
+    CUpnpAVDeviceExtended& AddDeviceL( CUpnpDevice& aDevice );
+    
+    /**
+     * Adds protoconinfo to a device
+     *
+     * @param aUuid device uuid
+     * @param aSource source protocolinfo
+     * @param aSink sink protocolinfo
+     * @return UPnP device with protocolinfo
+     */    
+    CUpnpAVDeviceExtended& AddProtocolInfoL( const TDesC8& aUuid,
+        const TDesC8& aSource, const TDesC8& aSink );
+        
+    /**
+     * Removes a device from repository
+     *
+     * @param aUuid device Uuid
+     */    
+    void Remove( const TDesC8& aUuid );
+    
+    /**
+     * Finds and return a device
+     *
+     * @param aUuid device Uuid
+     * @return device reference
+     */    
+    CUpnpAVDeviceExtended& FindDeviceL( const TDesC8& aUuid );
+    
+    /**
+     * Return a list of devices
+     *
+     * @return list of device
+     */    
+    const RPointerArray<CUpnpAVDeviceExtended>& DeviceList() const;
+    
+    /**
+     * Subscibe device for events (sends subscribe action)
+     *
+     * @param aUuid device Uuid
+     */    
+    void SubscribeDeviceL( const TDesC8& aUuid );     
+
+    /**
+     * Unsubscibe device for events (sends unsubscribe action)
+     *
+     * @param aUuid device Uuid
+     */    
+    void UnSubscribeDeviceL( const TDesC8& aUuid );
+    
+    void ConnectionLost();
+    
+    TBool IsWlanActive(); 
+    
+private:
+
+    /**
+     * Parses devices services (goes through actions and determines what's
+     * supported.
+     *
+     * @param aSource source device
+     * @param aTarget target device
+     */    
+    void ParseDeviceServicesL( CUpnpDevice& aSource,
+        CUpnpAVDeviceExtended& aTarget );
+    
+    void SetMaxVolume(CUpnpStateVariable* aVolumeState, CUpnpAVDeviceExtended& aTarget);
+    
+    void SetSeekCapabilityL(CUpnpStateVariable* seekModeStateVariable,
+        CUpnpAVDeviceExtended& aTarget);
+
+    void SelectDeviceIconL( CUpnpDevice& aSource, CUpnpAVDeviceExtended& aTarget );
+
+private:
+
+    CUpnpAVControlPoint&        iControlPoint; // Not own        
+   
+    RPointerArray<CUpnpAVDeviceExtended> iDevices; // Own
+    
+    TBool iIsWlanActive;
+    };
+
+
 #endif // C_UPNPDEVICEREPOSITORY_H_
\ No newline at end of file
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpfiletransfersessionbase.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpfiletransfersessionbase.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,192 +1,196 @@
-/*
-* Copyright (c) 2007 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:      implementation for session towards a media server
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPFILETRANSFERSESSIONBASE_H
-#define C_UPNPFILETRANSFERSESSIONBASE_H
-
-// INCLUDES
-// System
-#include <e32base.h>
-
-// upnpframework
-#include "upnpavcontroller.h"
-#include "httptransferobserver.h"
-#include "tupnpfiletransferevent.h"
-
-// FORWARD DECLARATIONS
-class CUpnpAVDeviceExtended;
-class CUpnpFileTransferItem;
-class CUpnpAVControllerServer;
-
-// CLASS DECLARATION
-/**
- * Filetransfer session base class
- *
- * @since S60 v3.2
- */
-class CUPnPFileTransferSessionBase : public CBase
-    {
-
-public:
-    
-    /**
-     * Destructor
-     */
-    virtual ~CUPnPFileTransferSessionBase();
-    
-protected:
-
-    /**
-     * Private constructor
-     *
-     * @param aSessionId session id
-     */
-    CUPnPFileTransferSessionBase( CUpnpAVControllerServer& aServer,
-        TInt aSessionId );    
-    
-    /**
-     * 2ns phase constructor
-     */
-    void ConstructL( const TDesC8& aUuid );
-     
-public: // New functions
-
-    /**
-     * Returns Session Id
-     *
-     * @return session id
-     */
-    TInt SessionId() const;
-    
-    /**
-     * Returns device Uuid 
-     *
-     * @return device Uuid
-     */
-    const TDesC8& Uuid() const;
-     
-protected:
-    
-    /**
-     * Checks if the given key (filetransfer item) exists in the transfer
-     * que
-     *
-     * @param aKey filetransfer identifier
-     * @return ETrue if the key exists
-     */
-    TBool CheckIfKeyExists( TInt aKey );
-    
-    /**
-     * Checks if the given key (filetransfer item) exists in the transfer
-     * que and returns the index
-     *
-     * @param aKey filetransfer identifier
-     * @param aIndex reference to the index
-     * @return ETrue if the key exists
-     */
-    TBool CheckIfKeyExists( TInt aKey, TInt& aIndex );
-
-    /**
-     * Finds and returns filetransfer item
-     *
-     * @param aItem filetransfer item
-     * @param aKey filetransfer identifier
-     * @return status (error) code
-     */
-    TInt FindItemByKey( TUpnpFileTransferEvent& aItem, TInt aKey );
-    
-    /**
-     * Finds and returns filetransfer item
-     *
-     * @param aItem filetransfer item
-     * @param aKey filetransfer identifier
-     * @param aIndex reference to the index
-     * @return status (error) code
-     */
-    TInt FindItemByKey( TUpnpFileTransferEvent& aItem, TInt aKey,
-        TInt& aIndex );
-
-    /**
-     * Reads filetransfer item from the message received from the client
-     *
-     * @param aMessage message from the client side
-     * @param aSlot message slot number
-     * @param aItem filetransfer item
-     */
-    void ReadTransferItemFromMessageL( const RMessage2& aMessage, TInt aSlot,
-        CUpnpFileTransferItem* aItem );
-    
-    /**
-     * Completes an event
-     *
-     * @param aEvent event to complete
-     */
-    void Complete( const TUpnpFileTransferEvent& aEvent );
-            
-protected:
-
-    /**
-     * AV Controller server
-     *
-     * Not own
-     */
-    CUpnpAVControllerServer&        iServer;
-    
-    /**
-     * Session id
-     */
-    TInt                            iSessionId;
-    
-    /**
-     * Target/source device
-     *
-     * Own
-     */
-    CUpnpAVDeviceExtended*          iDevice;
-    
-    /**
-     * Array of filetransfer items
-     */
-    RArray<TUpnpFileTransferEvent>  iTransferItems;
-    
-    /**
-     * Que of events
-     */
-    RArray<TUpnpFileTransferEvent>  iEventQueu;
-    
-    /**
-     * Async message, used to report a filetransfer event to the client side
-     *
-     * Own
-     */
-    RMessage2*                      iEventMsg;
-    
-    /**
-     * Flag to track if progress tracking is enabled or not
-     */
-    TBool                           iProgressTrackingEnabled;
-      
-    };
-
-#endif // C_UPNPFILETRANSFERSESSIONBASE_H
-
-// End of file
+/*
+* Copyright (c) 2007 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:      implementation for session towards a media server
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPFILETRANSFERSESSIONBASE_H
+#define C_UPNPFILETRANSFERSESSIONBASE_H
+
+// INCLUDES
+// System
+#include <e32base.h>
+
+// upnp stack api's
+#include <httptransferobserver.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavcontroller.h"
+
+// dlnasrv/ avcontroller client internal
+#include "tupnpfiletransferevent.h"
+
+// FORWARD DECLARATIONS
+class CUpnpAVDeviceExtended;
+class CUpnpFileTransferItem;
+class CUpnpAVControllerServer;
+
+// CLASS DECLARATION
+/**
+ * Filetransfer session base class
+ *
+ * @since S60 v3.2
+ */
+class CUPnPFileTransferSessionBase : public CBase
+    {
+
+public:
+    
+    /**
+     * Destructor
+     */
+    virtual ~CUPnPFileTransferSessionBase();
+    
+protected:
+
+    /**
+     * Private constructor
+     *
+     * @param aSessionId session id
+     */
+    CUPnPFileTransferSessionBase( CUpnpAVControllerServer& aServer,
+        TInt aSessionId );    
+    
+    /**
+     * 2ns phase constructor
+     */
+    void ConstructL( const TDesC8& aUuid );
+     
+public: // New functions
+
+    /**
+     * Returns Session Id
+     *
+     * @return session id
+     */
+    TInt SessionId() const;
+    
+    /**
+     * Returns device Uuid 
+     *
+     * @return device Uuid
+     */
+    const TDesC8& Uuid() const;
+     
+protected:
+    
+    /**
+     * Checks if the given key (filetransfer item) exists in the transfer
+     * que
+     *
+     * @param aKey filetransfer identifier
+     * @return ETrue if the key exists
+     */
+    TBool CheckIfKeyExists( TInt aKey );
+    
+    /**
+     * Checks if the given key (filetransfer item) exists in the transfer
+     * que and returns the index
+     *
+     * @param aKey filetransfer identifier
+     * @param aIndex reference to the index
+     * @return ETrue if the key exists
+     */
+    TBool CheckIfKeyExists( TInt aKey, TInt& aIndex );
+
+    /**
+     * Finds and returns filetransfer item
+     *
+     * @param aItem filetransfer item
+     * @param aKey filetransfer identifier
+     * @return status (error) code
+     */
+    TInt FindItemByKey( TUpnpFileTransferEvent& aItem, TInt aKey );
+    
+    /**
+     * Finds and returns filetransfer item
+     *
+     * @param aItem filetransfer item
+     * @param aKey filetransfer identifier
+     * @param aIndex reference to the index
+     * @return status (error) code
+     */
+    TInt FindItemByKey( TUpnpFileTransferEvent& aItem, TInt aKey,
+        TInt& aIndex );
+
+    /**
+     * Reads filetransfer item from the message received from the client
+     *
+     * @param aMessage message from the client side
+     * @param aSlot message slot number
+     * @param aItem filetransfer item
+     */
+    void ReadTransferItemFromMessageL( const RMessage2& aMessage, TInt aSlot,
+        CUpnpFileTransferItem* aItem );
+    
+    /**
+     * Completes an event
+     *
+     * @param aEvent event to complete
+     */
+    void Complete( const TUpnpFileTransferEvent& aEvent );
+            
+protected:
+
+    /**
+     * AV Controller server
+     *
+     * Not own
+     */
+    CUpnpAVControllerServer&        iServer;
+    
+    /**
+     * Session id
+     */
+    TInt                            iSessionId;
+    
+    /**
+     * Target/source device
+     *
+     * Own
+     */
+    CUpnpAVDeviceExtended*          iDevice;
+    
+    /**
+     * Array of filetransfer items
+     */
+    RArray<TUpnpFileTransferEvent>  iTransferItems;
+    
+    /**
+     * Que of events
+     */
+    RArray<TUpnpFileTransferEvent>  iEventQueu;
+    
+    /**
+     * Async message, used to report a filetransfer event to the client side
+     *
+     * Own
+     */
+    RMessage2*                      iEventMsg;
+    
+    /**
+     * Flag to track if progress tracking is enabled or not
+     */
+    TBool                           iProgressTrackingEnabled;
+      
+    };
+
+#endif // C_UPNPFILETRANSFERSESSIONBASE_H
+
+// End of file
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpplaybacksession.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpplaybacksession.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1233 +1,628 @@
-/*
-* Copyright (c) 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:      implements playback state machinery for media renderer
-*
-*/
-
-
-
-
-
-
-
-#ifndef C_UPNPPLAYBACKSESSION_H
-#define C_UPNPPLAYBACKSESSION_H
-
-// INCLUDE FILES
-// System
-#include <e32base.h>
-
-// upnp stack api
-#include <upnpavcontrolpointobserver.h>
-
-// upnpframework / avcontroller api
-#include "upnpavcontroller.h"
-#include "upnpavrenderingsessionobserver.h"
-
-// FORWARD DECLARATIONS
-class MUPnPAVMediaObserver;
-class CUpnpItem;
-class CUpnpObject;
-class CUPnPFileSharingActive;
-class RUpnpMediaServerClient;
-class CUpnpAVRequest;
-class CUpnpAVDeviceExtended;
-class TUnsolicitedEventC;
-class CUPnPXMLEventParser;
-class CUpnpAVControllerServer;
-class CUpnpAttribute;
-class CUpnpAVControlPoint;
-class CUPnPPeriodic;
-
-/**
- * Implements the server side playback session. Provides functionality to
- * Set URI/Next URI, control playback and to get position info.
- *
- * @since S60 v3.1
- */
-class CUPnPPlaybackSession :    public CBase,
-                                public MUpnpAVControlPointObserver
-    {
-
-private:
-	
-    /**
-     * Defines current playback state.
-     */
-    enum TPlaybackState
-        {
-        EUninitialized = 0,
-        EStopped,
-        EPlaying,
-        EPaused,
-        EPlaySent
-        };
-        
-    enum TMuteState
-        {
-        EUnknown    = -1,
-        ENotMuted   = 0,
-        EMuted      = 1
-        };    
-
-public:
-
-    /**
-     * Static 1st phase constructor.
-     *
-     * @param aControlPoint AV Control Point reference
-     * @param aClient S60 Media Server session reference
-     * @param aDispatcher observer callback disparcher reference
-     * @param aRepository device repository
-     * @param aSessionId session id
-     * @param aUuid device Uuid
-     * @return new instance
-     */
-    static CUPnPPlaybackSession* NewL
-        (
-        RUpnpMediaServerClient& aClient,
-        CUpnpAVControllerServer& aServer,
-        TInt aSessionId,   
-        const TDesC8& aUuid
-        );
-    
-    /**
-     * Destructor
-     */
-    virtual ~CUPnPPlaybackSession();
-    
-private:
-
-    /**
-     * Private constructor.
-     *
-     * @param aControlPoint AV Control Point reference
-     * @param aClient S60 Media Server session reference
-     * @param aDispatcher observer callback disparcher reference
-     * @param aRepository device repository
-     * @param aSessionId session id
-     * @param aUuid device Uuid
-     */
-    CUPnPPlaybackSession
-        (
-        RUpnpMediaServerClient& aClient,
-        CUpnpAVControllerServer& aServer,
-        TInt aSessionId
-        );    
-    
-    /**
-     * 2nd phase construct
-     *
-     * @param aUuid device Uuid
-     */
-    void ConstructL( const TDesC8& aUuid );
-  
-protected: // From MUpnpAVControlPointObserver
-
-    /**
-     * Observer callback for rendering control Set Volume.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aChannel audio channel.
-     * @param aDesiredVolume 
-     */
-    void RcSetVolumeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aDesiredVolume);
-        
-    /**
-     * Observer callback for rendering control Get Volume.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aChannel audio channel.
-     * @param aCurrentVolume 
-     */
-    void RcVolumeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aCurrentVolume);
-         
-    /**
-     * Observer callback for rendering control Set Mute.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aChannel audio channel.
-     * @param aDesiredMute 
-     */
-    void RcSetMuteResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aDesiredMute);
-        
-    /**
-     * Observer callback for rendering control Get Mute.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aChannel audio channel.
-     * @param aCurrentMute 
-     */
-    void RcMuteResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr, 
-        const TDesC8& aInstance, 
-        const TDesC8& aChannel, 
-        const TDesC8& aCurrentMute); 
-
-
-    /**
-     * Observer callback for rendering control AV set transport uri.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aCurrentUri Current transport URI.
-     * @param Current transport URI Metadata. 
-     */
-    void AvtSetTransportUriResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aCurrentUri,
-        const TDesC8& aCurrentUriMetaData);
-        
-    /**
-     * Observer callback for rendering control AV set next transport uri.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aCurrentUri Current transport URI.
-     * @param Current transport URI Metadata. 
-     */
-    virtual void AvtSetNextTransportUriResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNextUri,
-        const TDesC8& aNextUriMetaData);
-        
-    /**
-     * Observer callback for rendering control AV get media info response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aNrTracks Number of tracks.
-     * @param aMediaDuration 
-     * @param aCurrentUri Current transport URI.
-     * @param aCurrentUriMetaData Metadata of current trransport uri. 
-     * @param aNextUri Next transport URI.
-     * @param aNextUriMetaData Metadata of next trransport uri.
-     * @param aPlayMedium
-     * @param aRecordMedium
-     * @param aWriteStatus
-     */
-    void AvtMediaInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNrTracks,
-        const TDesC8& aMediaDuration,
-        const TDesC8& aCurrentUri,
-        const TDesC8& aCurrentUriMetaData,
-        const TDesC8& aNextUri,
-        const TDesC8& aNextUriMetaData,
-        const TDesC8& aPlayMedium,
-        const TDesC8& aRecordMedium,
-        const TDesC8& aWriteStatus);
-        
-    /**
-     * Observer callback for rendering control AV get transport info response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId
-     * @param aErr UPnP error code.
-     * @param aInstance rendering instance.
-     * @param aCurrenTransportState
-     * @param aCurrentTransportStatus
-     * @param aCurrentUri aCurrentSpeed
-     */
-    void AvtGetTransportInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aCurrenTransportState,
-        const TDesC8& aCurrentTransportStatus,
-        const TDesC8& aCurrentSpeed);
-        
-    /**
-     * Observer callback for rendering control AV get position info response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aTrack rendering instance.
-     * @param aTrackDuration 
-     * @param aTrackMetaData
-     * @param aTrackURI
-     * @param aRelTime
-     * @param aAbsTime
-     * @param aRelCount
-     * @param aAbsCount
-     */
-    void AvtPositionInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aTrack,
-        const TDesC8& aTrackDuration,
-        const TDesC8& aTrackMetaData,
-        const TDesC8& aTrackURI,
-        const TDesC8& aRelTime,
-        const TDesC8& aAbsTime,
-        const TDesC8& aRelCount,
-        const TDesC8& aAbsCount);
-        
-    /**
-     * Observer callback for rendering control AV get device
-     * capabilities response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aPlayMedia
-     * @param aRecMedia 
-     * @param aRecQualityModes
-     */
-    void AvtDeviceCapabilitiesResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aPlayMedia,
-        const TDesC8& aRecMedia,
-        const TDesC8& aRecQualityMode);
-        
-    /**
-     * Observer callback for rendering control AV get transport
-     * settings response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId
-     * @param aInstanceId
-     * @param aErr UPnP error code.        
-     * @param aPlayMode
-     * @param aRecQualityMode
-     */
-    void AvtTransportSettingsResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aPlayMode,
-        const TDesC8& aRecQualityMode);
-        
-    /**
-     * Observer callback for rendering control AV Stop response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     */
-    void AvtStopResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-        
-    /**
-     * Observer callback for rendering control AV Play response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSpeed
-     */
-    void AvtPlayResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aSpeed);
-    
-    /**
-     * Observer callback for rendering control AV Pause response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     */
-    void AvtPauseResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-        
-    /**
-     * Observer callback for rendering control AV Record response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     */
-    void AvtRecordResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-        
-    /**
-     * Observer callback for rendering control AV Seek response.
-     * @since Series 60 2.6
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aUnit
-     * @param aTarget
-     */
-    void AvtSeekResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aUnit,
-        const TDesC8& aTarget);
-        
-    /**
-     * Observer callback for rendering control AV Next response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     */
-    void AvtNextResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-        
-    /**
-     * Observer callback for rendering control AV Previous response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     */
-    void AvtPreviousResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId);
-    
-    /**
-     * Observer callback for rendering control AV setplay mode response.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aNewPlayMode
-     */
-    void AvtSetPlayModeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNewPlayMode);
-        
-    /**
-     * Observer callback for rendering control AV set record qualityresponse.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aNewRecordQuality
-     */
-    void AvtSetRecordModeResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aInstanceId,
-        const TDesC8& aNewRecordQuality);
-        
-    /**
-     * Observer callback for Content Directory GetSearchCapabilities function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSearchCaps
-     */
-    void CdsSearchCapabilitiesResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSearchCaps);
-        
-    /**
-     * Observer callback for Content Directory GetSortCapabilities function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSortCaps
-     */
-    void CdsSortCapabilitiesResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSortCaps);
-
-    /**
-     * Observer callback for Content Directory GetSystemUpdateID function.
-     * @since Series 60 2.6
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSystemUpdateId
-     */
-    void CdsSystemUpdateIdResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        TInt aSystemUpdateId);
-    /**
-    * Observer callback for Content Directory Browse function.
-    * @since Series 60 2.6
-    * @param aUuid Source device UUID. 
-    * @param aSessionId 
-    * @param aErr UPnP error code.
-    * @param aObjectID
-    * @param aBrowseFlag
-    * @param aFilter
-    * @param aIndex
-    * @param arequest
-    * @param aSortCriteria
-    * @param aResult
-    * @param aReturned
-    * @param aMatches
-    * @param aUpdateID
-    */
-    
-    void CdsBrowseResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aObjectID,
-        const TDesC8&  aBrowseFlag,
-        const TDesC8&  aFilter,
-        TInt aIndex,
-        TInt aRequest,
-        const TDesC8&  aSortCriteria,
-        const TDesC8&  aResult,
-        TInt aReturned,
-        TInt aMatches,
-        const TDesC8&  aUpdateID);
-        
-    /**
-     * Observer callback for Content Directory Search function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aContainerId
-     * @param aSearchCriteria
-     * @param aFilter
-     * @param aIndex
-     * @param arequest
-     * @param aSortCriteria
-     * @param aResult
-     * @param aReturned
-     * @param aMatches
-     * @param aUpdateID
-     */
-     
-    void CdsSearchResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aContainerId,
-        const TDesC8& aSearchCriteria,
-        const TDesC8& aFilter,
-        TInt aIndex,
-        TInt aRequest,
-        const TDesC8& aSortCriteria,
-        const TDesC8& aResult,
-        TInt aReturned,
-        TInt aMatches,
-        const TDesC8& aUpdateID);
-        
-    /**
-     * Observer callback for Content Directory DestroyObject function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aObjectId
-     */
-    void CdsDestroyObjectResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aObjectId );
-        
-    /**
-     * Observer callback for Content Directory UpdateObject function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aObjectId
-     * @param aCurrentTagValue
-     * @param aNewTagValue
-     */
-    void CdsUpdateObjectResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aObjectId,
-        const TDesC8& aCurrentTagValue,
-        const TDesC8& aNewTagValue );
-        
-    /**
-     * Observer callback for Content Directory ImportResource function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSourceURI
-     * @param aDestinationURI
-     * @param aTransferId
-     */       
-    void CdsImportResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSourceURI,
-        const TDesC8& aDestinationURI,
-        const TDesC8& aTransferId );
-        
-    /**
-     * Observer callback for Content Directory ExportResource function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSourceURI
-     * @param aDestinationURI
-     * @param aTransferId
-     */       
-    void CdsExportResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSourceURI,
-        const TDesC8& aDestinationURI,
-        const TDesC8& aTransferId );
-        
-    /**
-     * Observer callback for Content Directory StopTransfer function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSourceURI
-     * @param aDestinationURI
-     * @param aTransferId
-     */       
-    void CdsStopTransferResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aTransferId );
-    
-    /**
-     * Observer callback for Content Directory GetTransferProgress function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aTransferId
-     * @param aTransferStatus
-     * @param aTransferTotal
-     */         
-    virtual void CdsCTransferProgressResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aTransferId,
-        const TDesC8& aTransferStatus,
-        const TDesC8& aTransferLength,            
-        const TDesC8& aTransferTotal );
-        
-    /**
-     * Observer callback for Content Directory DeleteResource function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aResourceUri Resource to be deleted.
-     */ 
-    void CdsDeleteResourceResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aResourceUri );
-        
-    /**
-     * Observer callback for Content Directory CreateReference function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aContainerId Destination folder.
-     * @param aObjectId Source object.
-     * @param aNewId Created reference.
-     */ 
-    void CdsCreateReferenceResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aContainerId, 
-        const TDesC8& aObjectId, 
-        const TDesC8& aNewId );
-        
-    /**
-     * Observer callback for Content Directory CreateReference function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aContainerID Container in which new object is created.
-     * @param aElements Elements for item creation.
-     * @param aObjectID New objects ID.
-     * @param aResult Result of the action.
-     */ 
-    void CdsCreateObjectResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aContainerID, 
-        const TDesC8& aElements, 
-        const TDesC8& aObjectID, 
-        const TDesC8& aResult );
-        
-
-    /**
-     * Observer callback for Connection Manager GetProtocolInfo function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aSource
-     * @param aSink
-     */ 
-    void CmProtocolInfoResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aSource, 
-        const TDesC8& aSink );
-    
-    /**
-     * Observer callback for Connection Manager PrepareForConnection 
-     * function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aRemoteProtocolInfo
-     * @param aPeerConnectionManager
-     * @param aPeerConnectionId
-     * @param aDirection
-     * @param aConnection
-     * @param aTransport
-     * @param aRsc
-     */        
-    void CmPrepareResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aRemoteProtocolInfo,
-        const TDesC8& aPeerConnectionManager,
-        const TDesC8& aPeerConnectionId,
-        const TDesC8& aDirection,
-        TInt aConnection,
-        TInt aTransport,
-        TInt aRsc );
-    
-    /**
-     * Observer callback for Connection Manager ConnectionComplete 
-     * function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aConnection
-     */         
-    void CmComplete(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        TInt aConnection );
-        
-    /**
-     * Observer callback for Connection Manager GetCurrentConnectionIDs
-     * function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param aConnection
-     */         
-    void CmCurrentConnections(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aConnections);
-        
-    /**
-     * Observer callback for Connection Manager GetCurrentConnectionInfo
-     * function.
-     * @since Series 60 2.6
-     * @param aUuid Source device UUID. 
-     * @param aSessionId 
-     * @param aErr UPnP error code.
-     * @param rscId
-     * @param aProtocolInfo
-     * @param aPeerConnectionManager
-     * @param peerId
-     * @param aStatus
-     */   
-    void CmCurrentInfo(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        TInt rscId, 
-        TInt transportId, 
-        const TDesC8& aProtocolInfo,
-        const TDesC8& aPeerConnectionManager, 
-        TInt peerId, 
-        const TDesC8& aDirection, 
-        const TDesC8& aStatus );
-
-    //*****************************************************************
-    //Functions for UPnP event handling
-    //*****************************************************************
-    /**
-     * Content Directory SystemUpdateId event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aSystemUpdateId Device systemUpdateId.
-     */
-    void CdsUpdateEvent(
-            const TDesC8& aUuid,
-            TInt aSystemUpdateId
-            );
-            
-    /**
-     * Content Directory ContainerUpdateIDs event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aConteinerIds Device container update ids.
-     */
-    void CdsContainerEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aConteinerIds
-            );
-            
-    /**
-     * Content Directory TransferIDs event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aTransferIds Device transfer ids.
-     */
-    void CdsTransferEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aTransferIds
-            );
-            
-    /**
-     * Rendering Control LastChange event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aLastChange Device LastChange statevariable.
-     */
-    void RcLastChangeEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aLastChange
-            );
-            
-    /**
-     * AV Transport LastChange event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aLastChange Device LastChange statevariable.
-     */
-    void AvtLastChangeEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aLastChange
-            );
-    /**
-     * Connection Manager SourceEvent event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aSource Device's source info.
-     */
-    void CmSourceEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aSource
-            );
-            
-    /**
-     * Connection Manager SinkEvent event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aSink Device's sink info.
-     */
-    void CmSinkEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aSink
-            );
-            
-    /**
-     * Connection Manager ConnectionsEvent event handler.
-     * @since Series 60 2.6
-     * @param aUuid Device UUID.
-     * @param aConnections Devices connections.
-     */
-    void CmConnectionsEvent(
-            const TDesC8& aUuid,
-            const TDesC8& aConnections
-            );
-    //*****************************************************************
-    // Device and http functions.
-    //*****************************************************************
-    /**
-     * Handles HTTP messages.
-     * @since Series 60 2.6
-     * @param aMessage Incoming HTTP message.
-     */
-    void HttpResponseL( CUpnpHttpMessage* aMessage );
-
-public:
-
-    /**
-     * Handles UPnP device discoveries.
-     * @since Series 60 2.6
-     * @param aDevice Device that is discovered.
-     */
-    void DeviceDiscoveredL( CUpnpDevice* aDevice );
-
-    /**
-     * Handles UPnP device disappears.
-     * @since Series 60 2.6
-     * @param aDevice Device that disappeared.
-     */
-    void DeviceDisappearedL( CUpnpDevice* aDevice );    
-   
-public: // New functions
-    
-    /**
-     * Device disappeared callback
-     *
-     * @param aDevice disappeared device
-     */
-    void DeviceDisappearedL( CUpnpAVDeviceExtended& aDevice );
-    
-    /**
-     * Sets Uuid of the local Media Server
-     *
-     * @param aUuid device Uuid
-     */
-    void SetLocalMSUuidL( const TDesC8& aUuid );
-
-    /**
-     * Returns session id
-     *
-     * @return session id
-     */
-    TInt SessionId() const;
-        
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void EventRequestL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelEventRequestL();
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void SetURIL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelSetURIL();
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void SetNextURIL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelSetNextURIL();
-
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void PlayL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelPlayL();
-
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void StopL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelStopL();
-
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void PauseL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelPauseL();
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void SetVolumeL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelSetVolumeL();
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void GetVolumeL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelGetVolumeL();
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void SetMuteL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelSetMuteL();
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void GetMuteL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelGetMuteL();
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void GetPositionInfoL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelGetPositionInfoL();
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void DeviceDisappearedRequestL( const RMessage2& aMessage );
-    
-    /**
-     * See upnpavcontrollerimpl.h
-     */
-    void CancelDeviceDisappearedRequestL();        
-    
-    /**
-     * Returns device Uuid
-     */
-    const TDesC8& Uuid() const;     
-    
-private:
-
-    /**
-     * Parses a browse response and returns the importuri
-     *
-     * @param aResponse browse response
-     * @return importuri (ownership is transferred) 
-     */
-    HBufC8* ParseBrowseResponseL( const TDesC8& aResponse );
-    
-    /**
-     * Encodes given xml-document
-     *
-     * @param aResult xml-document
-     * @return encoded xml-document
-     */
-    HBufC8* EncodeXmlL( const TDesC8& aResult );
-    
-    /**
-     * Reset function
-     */
-    void ResetL();
-    
-    /**
-     * Reads object from a message
-     *
-     * @param aMessage message from client
-     * @param aSlot message slot numer
-     * @param aObj object pointer
-     */
-    void ReadObjFromMessageL( const RMessage2& aMessage, TInt aSlot,
-        CUpnpObject* aObj );        
-
-    /**
-     * Reads request from a message
-     *
-     * @param aMessage message from client
-     * @param aSlot message slot numer
-     * @param aReq request pointer
-     */
-    void ReadReqFromMessageL( const RMessage2& aMessage, TInt aSlot,
-        CUpnpAVRequest* aReq );
-        
-    void ValidateProtocolInfoL( const CUpnpAttribute& aProtocolInfo );        
-   
-    /**
-     * Send Play action if it has been requested.
-     */   
-    void SendPlayIfNeededL();
-    
-   /**
-     * Play delay timer callback
-     *
-     * @param TAny* aPtr this pointer for callback
-     * @return TInt
-     */
-    static TInt PlayDelayTimeExpired( TAny* aPtr );
-        
-
-private:
-
-    CUpnpAVControllerServer&    iServer;
-    
-    RUpnpMediaServerClient&     iMediaServer; // Not own
-    
-    CUPnPFileSharingActive*     iFileSharing; // Own
-    
-    TInt                        iSessionId;
-    
-    TInt                        iInstanceId;
-
-    TInt                        iIPSessionIdCommand;
-    
-    TInt                        iIPSessionIdSetting;
-
-    TBool                       iEventingActive;
-    
-    RMessage2*                  iCommandMessage; // Own
-    
-    RMessage2*                  iSettingMessage; // Own
-    
-    RMessage2*                  iDeviceMessage; // Own
-        
-    CUpnpAVDeviceExtended*      iDevice;
-    
-    HBufC8*                     iLocalMediaServerUuid; // Own
-    
-    CUpnpItem*                  iSharedItem; // Own
-    
-    TBool                       iItemShared;
-    
-    CUpnpItem*                  iNextSharedItem; // Own    
-    
-    TBool                       iNextItemShared;
-        
-    RMessage2*                  iEventMessage; // Own
-    
-    TPlaybackState              iPlaybackState;
-    
-    CUPnPXMLEventParser*        iEventParser;
-    
-    RArray<TUnsolicitedEventC>  iEventQue; // Own
-    
-    TMuteState                  iMuteState;
-    
-    TInt                        iVolume;
-    
-    // iPlayDelayTimer is started when we set transporturi.    
-    // The meaning of the timer is to delay the sending of play action in 
-    // order to achieve better IOP with some HW renderers like Kiss DP1600.
-    CUPnPPeriodic*              iPlayDelayTimer; // Own
-
-    // iPlayRequested will be set to ETrue if the playdelay timer is running    
-    // and somebody requests play action in the meantime
-    TBool                       iPlayRequested;
-    };
-
-#endif // C_UPNPPLAYBACKSESSION_H
+/*
+* Copyright (c) 2006-2009 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:      implements playback state machinery for media renderer
+*
+*/
+
+#ifndef C_UPNPPLAYBACKSESSION_H
+#define C_UPNPPLAYBACKSESSION_H
+
+// INCLUDE FILES
+// System
+#include <e32base.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavcontroller.h"
+#include "upnpavrenderingsessionobserver.h"
+#include "upnpavtevent.h"
+
+// dlnasrv / avcontroller server internal
+#include "upnpavtimer.h"
+#include "upnpavcontrolpointobserver.h"
+
+// FORWARD DECLARATIONS
+class CUpnpItem;
+class CUpnpObject;
+class CUpnpDevice;
+class CUpnpAVRequest;
+class CUpnpAVDeviceExtended;
+class TUnsolicitedEventC;
+class CUPnPXMLEventParser;
+class CUpnpAVControllerServer;
+class CUpnpAttribute;
+
+/**
+ * Implements the server side playback session. Provides functionality to
+ * Set URI, control playback and to get position info.
+ *
+ * @since S60 v3.1
+ */
+class CUPnPPlaybackSession : public CBase,
+                             private MUpnpAVControlPointObserver,
+                             private MUPnPAVTimerCallback
+    {
+
+private:
+
+    /**
+     * Defines current playback state.
+     */
+    enum TPlaybackState
+        {
+        EUninitialized = -1,
+        ENoMedia,
+        EStopped,
+        EPlaying,
+        EPaused,
+        EHalted // Go to this state if rendering is interrupted by another CP
+        };
+  
+    /**
+     * Defines the event we are expecting to get.
+     */
+    enum TExpectedEvent
+        {
+        EEventNone = 0,
+        EEventStopped,
+        EEventAVTransportUri,
+        EEventPlaying,
+        EEventPaused
+        };
+    
+    /**
+     * Defines current mute state.
+     */
+    enum TMuteState
+        {
+        EUnknown    = -1,
+        ENotMuted   = 0,
+        EMuted      = 1
+        };    
+
+public:
+
+    /**
+     * Static 1st phase constructor.
+     *
+     * @param aControlPoint AV Control Point reference
+     * @param aDispatcher observer callback disparcher reference
+     * @param aRepository device repository
+     * @param aSessionId session id
+     * @param aUuid device Uuid
+     * @return new instance
+     */
+    static CUPnPPlaybackSession* NewL
+        (
+        CUpnpAVControllerServer& aServer,
+        TInt aSessionId,   
+        const TDesC8& aUuid
+        );
+    
+    /**
+     * Destructor
+     */
+    virtual ~CUPnPPlaybackSession();
+    
+private:
+
+    /**
+     * Private constructor.
+     *
+     * @param aControlPoint AV Control Point reference
+     * @param aDispatcher observer callback disparcher reference
+     * @param aRepository device repository
+     * @param aSessionId session id
+     * @param aUuid device Uuid
+     */
+    CUPnPPlaybackSession
+        (
+        CUpnpAVControllerServer& aServer,
+        TInt aSessionId
+        );    
+    
+    /**
+     * 2nd phase construct
+     *
+     * @param aUuid device Uuid
+     */
+    void ConstructL( const TDesC8& aUuid );
+  
+private: // From MUpnpAVControlPointObserver
+
+    void ActionResponseL(CUpnpAction* aAction );
+    void StateUpdatedL(CUpnpService* aService);
+    void HttpResponseL(CUpnpHttpMessage* aMessage);
+    void DeviceDiscoveredL(CUpnpDevice* aDevice);
+    void DeviceDisappearedL(CUpnpDevice* aDevice);
+
+private: // network event handling
+
+    /**
+     * Handles response for RenderingControl SetVolume command
+     */
+    void RcSetVolumeResponse(
+        TInt aErr, 
+        const TDesC8& aDesiredVolume );
+
+    /**
+     * Handles response for RenderingControl GetVolume command
+     */
+    void RcVolumeResponse(
+        TInt aErr, 
+        const TDesC8& aCurrentVolume);
+
+    /**
+     * Handles response for RenderingControl SetMute command
+     */
+    void RcSetMuteResponse(
+        TInt aErr, 
+        const TDesC8& aDesiredMute );
+
+    /**
+     * Handles response for RenderingControl GetMute command
+     */
+    void RcMuteResponse(
+        TInt aErr, 
+        const TDesC8& aCurrentMute );
+
+    /**
+     * Handles response for AVTransport SetTransportURI command
+     */
+    void AvtSetTransportUriResponse(
+        TInt aErr );
+
+    /**
+     * Handles response for AVTransport GetMediaInfo command
+     */
+    void AvtGetMediaInfoResponse(
+        TInt aErr,
+        const TDesC8& aCurrentURI );
+    
+    /**
+     * Handles response for AVTransport GetTransportInfo command
+     */
+    void AvtGetTransportInfoResponse(
+        TInt aErr,
+        const TDesC8& aCurrenTransportState );
+
+    /**
+     * Handles response for AVTransport GetPositionInfo command
+     */
+    void AvtPositionInfoResponse(
+        TInt aErr,
+        const TDesC8& aTrackDuration,
+        const TDesC8& aRelTime );
+
+    /**
+     * Handles response for AVTransport Stop command
+     */
+    void AvtStopResponse(
+        TInt aErr );
+
+    /**
+     * Handles response for AVTransport Play command
+     */
+    void AvtPlayResponse(
+        TInt aErr );
+
+    /**
+     * Handles response for AVTransport Pause command
+     */
+    void AvtPauseResponse(
+        TInt aErr );
+
+    /**
+     * Handles response for AVTransport Seek command
+     */
+    void AvtSeekResponse(
+        TInt aErr );
+
+    /**
+     * Handles response for ConnectionManager Prepare command
+     */
+    void CmPrepareResponse(
+        TInt aErr,
+        TInt aConnection,
+        TInt aTransport,
+        TInt aRsc );
+
+    /**
+     * Processes a state change in RenderingControl
+     */
+    void RcLastChangeEvent(
+        const TDesC8& aLastChange );
+
+    /**
+     * Processes a state change in AVTransport
+     */
+    void AvtLastChangeEvent(
+        const TDesC8& aLastChange );
+
+
+private: // From MUPnPAVTimerCallback
+    
+    // see upnpavtimer.h
+    void UPnPAVTimerCallback( CUPnPAVTimer::TAVTimerType aType );
+    
+
+public: // New functions
+    
+    /**
+     * Device disappeared callback
+     *
+     * @param aDevice disappeared device
+     */
+    void DeviceDisappearedL( CUpnpAVDeviceExtended& aDevice );
+    
+    /**
+     * Sets Uuid of the local Media Server
+     *
+     * @param aUuid device Uuid
+     */
+    void SetLocalMSUuidL( const TDesC8& aUuid );
+
+    /**
+     * Returns session id
+     *
+     * @return session id
+     */
+    TInt SessionId() const;
+        
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void EventRequestL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelEventRequestL();
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void SetURIL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelSetURIL();
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void SetNextURIL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelSetNextURIL();
+
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void PlayL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelPlayL();
+
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void StopL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelStopL();
+
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void PauseL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelPauseL();
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void SetVolumeL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelSetVolumeL();
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void GetVolumeL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelGetVolumeL();
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void SetMuteL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelSetMuteL();
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void GetMuteL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelGetMuteL();
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void GetPositionInfoL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelGetPositionInfoL();
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void SeekRelTimeL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelSeekRelTimeL();
+
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void GetRendererStateL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void DeviceDisappearedRequestL( const RMessage2& aMessage );
+    
+    /**
+     * See upnpavcontrollerimpl.h
+     */
+    void CancelDeviceDisappearedRequestL();        
+    
+    /**
+     * Returns device Uuid
+     */
+    const TDesC8& Uuid() const;     
+    
+private:
+
+    /**
+     * Encodes given xml-document
+     *
+     * @param aResult xml-document
+     * @return encoded xml-document
+     */
+    HBufC8* EncodeXmlL( const TDesC8& aResult );
+    
+    /**
+     * Reset function
+     */
+    void ResetL();
+    
+    /**
+     * Reads object from a message
+     *
+     * @param aMessage message from client
+     * @param aSlot message slot numer
+     * @param aObj object pointer
+     */
+    void ReadObjFromMessageL( const RMessage2& aMessage, TInt aSlot,
+        CUpnpObject* aObj );        
+
+    /**
+     * Reads request from a message
+     *
+     * @param aMessage message from client
+     * @param aSlot message slot numer
+     * @param aReq request pointer
+     */
+    void ReadReqFromMessageL( const RMessage2& aMessage, TInt aSlot,
+        CUpnpAVRequest* aReq );
+        
+    /**
+     * Validates protocolinfo.
+     *
+     * @param aProtocolInfo
+     */
+    void ValidateProtocolInfoL( const CUpnpAttribute& aProtocolInfo );        
+        
+    /**
+     * Checks if we have a valid connection with Media Renderer
+     *
+     * @param aProtocolInfo items protocolinfo
+     * @return ETrue if we have a valid connection
+     */
+    TBool CheckConnectionL( const TDesC8& aProtocolInfo );
+    
+    /**
+     * Sends AVTransportUri-action
+     */
+    void SendAVTransportUriActionL();
+    
+    /**
+     * removes DNLA.ORG* flags profile id etc. from protocol info of 
+     * res element
+     */
+    void RemoveDlnaFlagsFromResElementsL();
+    
+    /**
+     * removes dlna profile id (DLNA.ORG_PN=*) from protocol info of 
+     * res element
+     */
+    void RemoveDlnaProfileFromResElementsL();
+
+    /**
+     * Sends GetMediaInfo-action
+     */
+    void SendGetMediaInfoActionL();
+    
+    /**
+     * Sends GetAVTransportUri-action
+     */
+    void SendGetTransportInfoActionL();
+        
+    /**
+     * Handles "PLAYING" event
+     */
+    void PlayingEventReceived();
+    
+    /**
+     * Handles "STOPPED" event
+     */
+    void StoppedEventReceived();
+    
+    /**
+     * Handles "PAUSED" event
+     */
+    void PausedEventReceived();
+    
+    /**
+     * Handles "NO_MEDIA_PRESENT" event
+     */
+    void NoMediaEventReceived();
+    
+    /**
+     * Handles AVTransportUri event
+     */
+    void AVTransportUriEventReceived( const TDesC8& aUri,
+        CUPnPAVTEvent::TTransportState aTransportState );
+    
+    /**
+     * Propagates an event to the client (complete or queu).
+     */
+    void PropagateEvent( TUnsolicitedEventC event );
+    
+    /**
+     * Stops possible playback.
+     */
+    void EmergencyStopL();
+    
+    /**
+     * Returns CUpnpDevice from control point.
+     */
+    const CUpnpDevice* CpDeviceL();
+    
+    /**
+     * Propagates (transition) state to clients.
+     */
+    void PropagateState( CUPnPAVTEvent::TTransportState aTransportState );
+    
+    /**
+     * Responds to requested stop command.
+     */
+    void RespondToStopRequest();
+    
+private:
+
+    CUpnpAVControllerServer&    iServer;
+    
+    TInt                        iSessionId;
+    
+    TInt                        iAVTInstanceId;
+    
+    TInt                        iRCInstanceId;
+    
+    TInt                        iConnectionId;
+    
+    TInt                        iIPSessionIdCommand;
+    
+    TInt                        iIPSessionIdSetting;
+
+    TBool                       iEventingActive;
+    
+    RMessage2*                  iCommandMessage; // Own
+    
+    RMessage2*                  iSettingMessage; // Own
+    
+    RMessage2*                  iDeviceMessage; // Own
+        
+    CUpnpAVDeviceExtended*      iDevice;
+    
+    HBufC8*                     iLocalMediaServerUuid; // Own
+        
+    RMessage2*                  iEventMessage; // Own
+    
+    RMessage2*                  iInitialEventMsg; // Own
+    
+    TPlaybackState              iPlaybackState;
+    
+    CUPnPXMLEventParser*        iEventParser;
+    
+    RArray<TUnsolicitedEventC>  iEventQue; // Own
+    
+    TMuteState                  iMuteState;
+    
+    TInt                        iVolume;
+    
+    /**
+     * Protocol info for currently played item.    
+     * Own.
+     */
+    CUpnpDlnaProtocolInfo*      iPInfoForPrevious;
+    
+    /**
+     * Uri for currently played item.  
+     * Own.
+     */
+    HBufC8*                     iCurrentUri;
+    
+    TBool                       iCheckForHijackedRenderer;
+    
+    /**
+     * Currently played item.
+     * Own.
+     */
+    CUpnpItem*                  iCurrentItem;
+    
+    /**
+     * Fail safe timer.
+     * Own.
+     */
+    CUPnPAVTimer*               iTimer;
+    
+    TExpectedEvent              iExpectedEvent;
+     
+    TBool                       iInitialEventReceived;
+    
+    HBufC8*                     iUuid;
+    
+    CUPnPAVTEvent::TTransportState iPreviousTransportState;
+    
+    };
+
+#endif // C_UPNPPLAYBACKSESSION_H
--- a/upnpavcontroller/upnpavcontrollerserver/inc/upnpuploadsession.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/inc/upnpuploadsession.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,801 +1,334 @@
-/*
-* Copyright (c) 2007 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:      implementation for session towards a media server
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPUPLOADSESSION_H
-#define C_UPNPUPLOADSESSION_H
-
-// EXTERNAL INCLUDES
-#include <e32base.h>
-#include <upnpavcontrolpointobserver.h>
-
-// INTERNAL INCLUDES
-#include "httptransferobserver.h"
-#include "upnpfiletransfersessionbase.h"
-#include "tupnpfiletransferevent.h"
-
-// FORWARD DECLARATIONS
-class CHttpUploader;
-class CUpnpFileTransferItem;
-class CUPnPResourceHelper;
-class CUpnpDlnaProtocolInfo;
-class CUpnpObject;
-class CUpnpAttribute;
-
-// CLASS DECLARATION
-/**
- * Implements AV Controller server side upload session
- *
- * @since S60 v3.2
- */
-class CUPnPUploadSession :  public CUPnPFileTransferSessionBase,
-                            public MHttpTransferObserver,
-                            public MUpnpAVControlPointObserver
-    {
-        
-public:
-
-    /**
-     * Static 1st phase constructor
-     *
-     * @param aServer AV Controller server handle
-     * @param aSessionId session id
-     * @param aUuid device Uuid
-     */
-    static CUPnPUploadSession* NewL( CUpnpAVControllerServer& aServer,
-        TInt aSessionId, const TDesC8& aUuid );
-    
-    /**
-     * Destructor
-     */
-    virtual ~CUPnPUploadSession();
-    
-private:
-
-    /**
-     * Private constructor
-     *
-     * @param aServer AV Controller server handle
-     * @param aSessionId session id
-     */
-    CUPnPUploadSession( CUpnpAVControllerServer& aServer,
-        TInt aSessionId );
-    
-    /**
-     * 2ns phase constructor
-     *
-     * @param aUuid device uuid
-     */
-    void ConstructL( const TDesC8& aUuid );
-
-private: // From MHttpTransferObserver
-    
-    /**
-     * See httptransferobserver.h
-     */
-    void TransferProgress( TAny* aKey, TInt aBytes, TInt aTotalBytes );
-
-    /**
-     * See httptransferobserver.h
-     */
-    void ReadyForTransferL( TAny* aKey );
-
-    /**
-     * See httptransferobserver.h
-     */
-    void TransferCompleted( TAny* aKey, TInt aStatus );
-
-private: // From MUpnpAVControlPointObserver
-
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void RcSetVolumeResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/, 
-        const TDesC8& /*aInstance*/, 
-        const TDesC8& /*aChannel*/, 
-        const TDesC8& /*aDesiredVolume*/ ) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void RcVolumeResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/, 
-        const TDesC8& /*aInstance*/, 
-        const TDesC8& /*aChannel*/, 
-        const TDesC8& /*aCurrentVolume*/) {}
-         
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void RcSetMuteResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/, 
-        const TDesC8& /*aInstance*/, 
-        const TDesC8& /*aChannel*/, 
-        const TDesC8& /*aDesiredMute*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void RcMuteResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/, 
-        const TDesC8& /*aInstance*/, 
-        const TDesC8& /*aChannel*/, 
-        const TDesC8& /*aCurrentMute*/) {} 
-
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtSetTransportUriResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aCurrentUri*/,
-        const TDesC8& /*aCurrentUriMetaData*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    virtual void AvtSetNextTransportUriResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aNextUri*/,
-        const TDesC8& /*aNextUriMetaData*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtMediaInfoResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aNrTracks*/,
-        const TDesC8& /*aMediaDuration*/,
-        const TDesC8& /*aCurrentUri*/,
-        const TDesC8& /*aCurrentUriMetaData*/,
-        const TDesC8& /*aNextUri*/,
-        const TDesC8& /*aNextUriMetaData*/,
-        const TDesC8& /*aPlayMedium*/,
-        const TDesC8& /*aRecordMedium*/,
-        const TDesC8& /*aWriteStatus*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtGetTransportInfoResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aCurrenTransportState*/,
-        const TDesC8& /*aCurrentTransportStatus*/,
-        const TDesC8& /*aCurrentSpeed*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtPositionInfoResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aTrack*/,
-        const TDesC8& /*aTrackDuration*/,
-        const TDesC8& /*aTrackMetaData*/,
-        const TDesC8& /*aTrackURI*/,
-        const TDesC8& /*aRelTime*/,
-        const TDesC8& /*aAbsTime*/,
-        const TDesC8& /*aRelCount*/,
-        const TDesC8& /*aAbsCount*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtDeviceCapabilitiesResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aPlayMedia*/,
-        const TDesC8& /*aRecMedia*/,
-        const TDesC8& /*aRecQualityMode*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtTransportSettingsResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aPlayMode*/,
-        const TDesC8& /*aRecQualityMode*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtStopResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtPlayResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aSpeed*/) {}
-    
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtPauseResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtRecordResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtSeekResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aUnit*/,
-        const TDesC8& /*aTarget*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtNextResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtPreviousResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/) {}
-    
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtSetPlayModeResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aNewPlayMode*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtSetRecordModeResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aInstanceId*/,
-        const TDesC8& /*aNewRecordQuality*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsSearchCapabilitiesResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aSearchCaps*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsSortCapabilitiesResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aSortCaps*/) {}
-
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsSystemUpdateIdResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        TInt /*aSystemUpdateId*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsBrowseResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aObjectID*/,
-        const TDesC8& /*aBrowseFlag*/,
-        const TDesC8& /*aFilter*/,
-        TInt /*aIndex*/,
-        TInt /*aRequest*/,
-        const TDesC8& /*aSortCriteria*/,
-        const TDesC8& /*aResult*/,
-        TInt /*aReturned*/,
-        TInt /*aMatches*/,
-        const TDesC8& /*aUpdateID*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsSearchResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aContainerId*/,
-        const TDesC8& /*aSearchCriteria*/,
-        const TDesC8& /*aFilter*/,
-        TInt /*aIndex*/,
-        TInt /*aRequest*/,
-        const TDesC8& /*aSortCriteria*/,
-        const TDesC8& /*aResult*/,
-        TInt /*aReturned*/,
-        TInt /*aMatches*/,
-        const TDesC8& /*aUpdateID*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsDestroyObjectResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aObjectId*/ ) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsUpdateObjectResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aObjectId*/,
-        const TDesC8& /*aCurrentTagValue*/,
-        const TDesC8& /*aNewTagValue*/ ) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsImportResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aSourceURI*/,
-        const TDesC8& /*aDestinationURI*/,
-        const TDesC8& /*aTransferId*/ ) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsExportResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aSourceURI*/,
-        const TDesC8& /*aDestinationURI*/,
-        const TDesC8& /*aTransferId*/ ) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsStopTransferResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aTransferId*/ ) {}
-    
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    virtual void CdsCTransferProgressResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aTransferId*/,
-        const TDesC8& /*aTransferStatus*/,
-        const TDesC8& /*aTransferLength*/,            
-        const TDesC8& /*aTransferTotal*/ ) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsDeleteResourceResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aResourceUri*/ ) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsCreateReferenceResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aContainerId*/, 
-        const TDesC8& /*aObjectId*/, 
-        const TDesC8& /*aNewId*/ ) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsCreateObjectResponse(
-        const TDesC8& aUuid,
-        TInt aSessionId,
-        TInt aErr,
-        const TDesC8& aContainerID, 
-        const TDesC8& aElements, 
-        const TDesC8& aObjectID, 
-        const TDesC8& aResult );
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CmProtocolInfoResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aSource*/, 
-        const TDesC8& /*aSink*/ ) {}
-    
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CmPrepareResponse(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aRemoteProtocolInfo*/,
-        const TDesC8& /*aPeerConnectionManager*/,
-        const TDesC8& /*aPeerConnectionId*/,
-        const TDesC8& /*aDirection*/,
-        TInt /*aConnection*/,
-        TInt /*aTransport*/,
-        TInt /*aRsc*/ ) {}
-    
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CmComplete(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        TInt /*aConnection*/ ) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CmCurrentConnections(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        const TDesC8& /*aConnections*/) {}
-        
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CmCurrentInfo(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSessionId*/,
-        TInt /*aErr*/,
-        TInt /*rscId*/, 
-        TInt /*transportId*/, 
-        const TDesC8& /*aProtocolInfo*/,
-        const TDesC8& /*aPeerConnectionManager*/, 
-        TInt /*peerId*/, 
-        const TDesC8& /*aDirection*/, 
-        const TDesC8& /*aStatus*/ ) {}
-
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsUpdateEvent(
-            const TDesC8& /*aUuid*/,
-            TInt /*aSystemUpdateId*/
-            ) {}
-            
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsContainerEvent(
-            const TDesC8& /*aUuid*/,
-            const TDesC8& /*aConteinerIds*/
-            ) {}
-            
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CdsTransferEvent(
-            const TDesC8& /*aUuid*/,
-            const TDesC8& /*aTransferIds*/
-            ) {}
-            
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void RcLastChangeEvent(
-            const TDesC8& /*aUuid*/,
-            const TDesC8& /*aLastChange*/
-            ) {}
-            
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void AvtLastChangeEvent(
-            const TDesC8& /*aUuid*/,
-            const TDesC8& /*aLastChange*/
-            ) {}
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CmSourceEvent(
-            const TDesC8& /*aUuid*/,
-            const TDesC8& /*aSource*/
-            ) {}
-            
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CmSinkEvent(
-            const TDesC8& /*aUuid*/,
-            const TDesC8& /*aSink*/
-            ) {}
-            
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void CmConnectionsEvent(
-            const TDesC8& /*aUuid*/,
-            const TDesC8& /*aConnections*/
-            ) {}
-
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void HttpResponseL( CUpnpHttpMessage* /*aMessage*/ ) {}
-
-public:
-
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void DeviceDiscoveredL( CUpnpDevice* /*aDevice*/ ) {} 
-
-    /**
-     * See upnpavcontrolpointobserver.h
-     */
-    void DeviceDisappearedL( CUpnpDevice* /*aDevice*/ ) {}
-     
-public: // New functions
-
-    /**
-     * Starts upload
-     *
-     * @param aMessage message
-     */
-    void StartUploadL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels upload
-     *
-     * @param aMessage message
-     */
-    void CancelUploadL( const RMessage2& aMessage );
-
-    /**
-     * Cancels uploads
-     *
-     * @param aMessage message
-     */
-    void CancelAllUploadsL( const RMessage2& aMessage );
-    
-    /**
-     * Start tracking progress
-     *
-     * @param aMessage message
-     */
-    void StartTrackingUploadProgressL( const RMessage2& aMessage );
-
-    /**
-     * Stop tracking progress
-     *
-     * @param aMessage message
-     */
-    void StopTrackingUploadProgressL( const RMessage2& aMessage );
-
-    /**
-     * Saves a message to receive events
-     *
-     * @param aMessage message
-     */
-    void GetUploadEventL( const RMessage2& aMessage );
-    
-    /**
-     * Cancels events
-     *
-     * @param aMessage message
-     */
-    void CancelGetUploadEventL( const RMessage2& aMessage );
-
-    /**
-     * Handles UPnP device disappears.
-     *
-     * @param aDevice Device that disappeared.
-     */
-    void DeviceDisappearedL( CUpnpAVDeviceExtended& aDevice );
-
-private:
-
-    /**
-     * Set mandatory transfer headers
-     *
-     * @param aInfo protocolInfo
-     * @param aKey transfer id
-     */
-    void SetHeadersL( const TDesC8& aInfo, TAny* aKey );
-    
-    /**
-     * Prepares for upload
-     *
-     * @param aEvent transfer event
-     */
-    void ReadyForTransferL( TUpnpFileTransferEvent& aEvent );
-  
-    /**
-     * Parsers CreateObject-response
-     *
-     * @param aResponse CreateObject-response
-     * @return importUri
-     */
-    HBufC8* ParseCreateObjectResponseL( const TDesC8& aResponse );
-    
-    
-    /**
-     * Handles CreateObject-response
-     *
-     * @param aResponse aObjectID object id
-     * @param aResult CreateObject-response
-     */
-    void HandleObjectResponseL( const TDesC8& aObjectID,
-        const TDesC8& aResult );
-        
-    /**
-     * Finds and return importUri from an item
-     *
-     * @param aObject UPnP item
-     * @return importUri
-     */
-    HBufC8* ImportURIFromItemL( const CUpnpObject& aObject );
-    
-    /**
-     * Converts DLNA compliant protocolInfo to UPnP protocolInfo
-     *
-     * @param aInfo DLNA protolInfo
-     */
-    void ProtocolInfoToUPnPL( const CUpnpAttribute* aInfo );    
-    
-    /**
-     * Issues active scheduler's wait stop request(with/without callback)
-     *
-     * @param none
-     * @return none
-     */
-    void StopWait();
-
-    /**
-     * Callback for active scheduler's wait stop request
-     *
-     */
-    static TInt SchedulerStoppedCallBack( TAny* aPtr );
-    
-    /**
-     * Does necessary action on active scheduler's wait stop complete
-     *
-     * @param none
-     * @return none
-     */
-    void DoSchedulerStoppedCallBack();
-    
-private:
-
-    /**
-     * Http Uploader, used to upload files
-     *
-     * Owned
-     */
-    CHttpUploader*                          iUploader;
-    
-    /**
-     * Used to synchronize CreateObject-action 
-     */
-    CActiveSchedulerWait                    iWait;
-            
-    /**
-     * Resource helper array
-     *
-     * Owned
-     */
-    RPointerArray<CUPnPResourceHelper>      iResources;
-        
-    /**
-     * Resource index
-     */
-    TInt                                    iResourceIndex;
-    
-    /**
-     * Stores error (status) code from CreateObject-action
-     */
-    TInt                                    iAsyncError;
-    
-    /**
-     * Session id for CreateObject-action
-     */
-    TInt                                    iIPSessionId;
-    
-    /**
-     * Scheduler stop request
-     */
-    TBool                                   iSchedulerStopped;
-    };
-
-#endif // C_UPNPUPLOADSESSION_H
-
-// End of file
-
+/*
+* Copyright (c) 2007 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:      implementation for session towards a media server
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPUPLOADSESSION_H
+#define C_UPNPUPLOADSESSION_H
+
+// EXTERNAL INCLUDES
+#include <e32base.h>
+
+// INTERNAL INCLUDES
+#include "httptransferobserver.h"
+#include "upnpfiletransfersessionbase.h"
+#include "tupnpfiletransferevent.h"
+#include "upnpavcontrolpointobserver.h"
+
+// FORWARD DECLARATIONS
+class CHttpUploader;
+class CUPnPResourceHelper;
+class CUpnpObject;
+class CUpnpAttribute;
+class CUpnpDevice;
+
+// CLASS DECLARATION
+/**
+ * Implements AV Controller server side upload session
+ *
+ * @since S60 v3.2
+ */
+class CUPnPUploadSession : public CUPnPFileTransferSessionBase,
+                           private MHttpTransferObserver,
+                           private MUpnpAVControlPointObserver
+    {
+        
+public:
+
+    /**
+     * Static 1st phase constructor
+     *
+     * @param aServer AV Controller server handle
+     * @param aSessionId session id
+     * @param aUuid device Uuid
+     */
+    static CUPnPUploadSession* NewL( CUpnpAVControllerServer& aServer,
+        TInt aSessionId, const TDesC8& aUuid );
+    
+    /**
+     * Destructor
+     */
+    virtual ~CUPnPUploadSession();
+    
+private:
+
+    /**
+     * Private constructor
+     *
+     * @param aServer AV Controller server handle
+     * @param aSessionId session id
+     */
+    CUPnPUploadSession( CUpnpAVControllerServer& aServer,
+        TInt aSessionId );
+    
+    /**
+     * 2ns phase constructor
+     *
+     * @param aUuid device uuid
+     */
+    void ConstructL( const TDesC8& aUuid );
+
+private: // From MHttpTransferObserver
+    
+    /**
+     * See httptransferobserver.h
+     */
+    void TransferProgress( TAny* aKey, TInt aBytes, TInt aTotalBytes );
+
+    /**
+     * See httptransferobserver.h
+     */
+    void ReadyForTransferL( TAny* aKey );
+
+    /**
+     * See httptransferobserver.h
+     */
+    void TransferCompleted( TAny* aKey, TInt aStatus );
+
+private: // From MUpnpAVControlPointObserver
+
+    /**
+    * @see MUpnpAVControlPointObserver::ActionResponseL
+    */
+    void ActionResponseL( CUpnpAction* aAction );
+    
+    /**
+    * @see MUpnpAVControlPointObserver::StateUpdatedL
+    */
+    void StateUpdatedL( CUpnpService* aService );
+
+    /**
+    * @see MUpnpAVControlPointObserver::HttpResponseL
+    */
+    void HttpResponseL( CUpnpHttpMessage* aMessage );
+    
+    /**
+    * @see MUpnpAVControlPointObserver::DeviceDiscoveredL
+    */
+    void DeviceDiscoveredL( CUpnpDevice* aDevice );
+    
+    /**
+    * @see MUpnpAVControlPointObserver::DeviceDisappearedL
+    */
+    void DeviceDisappearedL( CUpnpDevice* aDevice );
+
+private: // network event handling
+
+    /**
+     * Handles response for ContentDirectory CreateObject command
+     */
+    void CdsCreateObjectResponse(
+        TInt aErr,
+        const TDesC8& aObjectID, 
+        const TDesC8& aResult );
+
+public: // New functions
+
+    /**
+     * Starts upload
+     *
+     * @param aMessage message
+     */
+    void StartUploadL( const RMessage2& aMessage );
+
+    /**
+     * Cancels upload
+     *
+     * @param aMessage message
+     */
+    void CancelUploadL( const RMessage2& aMessage );
+
+    /**
+     * Cancels uploads
+     *
+     * @param aMessage message
+     */
+    void CancelAllUploadsL( const RMessage2& aMessage );
+    
+    /**
+     * Start tracking progress
+     *
+     * @param aMessage message
+     */
+    void StartTrackingUploadProgressL( const RMessage2& aMessage );
+
+    /**
+     * Stop tracking progress
+     *
+     * @param aMessage message
+     */
+    void StopTrackingUploadProgressL( const RMessage2& aMessage );
+
+    /**
+     * Saves a message to receive events
+     *
+     * @param aMessage message
+     */
+    void GetUploadEventL( const RMessage2& aMessage );
+    
+    /**
+     * Cancels events
+     *
+     * @param aMessage message
+     */
+    void CancelGetUploadEventL( const RMessage2& aMessage );
+
+    /**
+     * Handles UPnP device disappears.
+     *
+     * @param aDevice Device that disappeared.
+     */
+    void DeviceDisappearedL( CUpnpAVDeviceExtended& aDevice );
+
+private:
+
+    /**
+     * Set mandatory transfer headers
+     *
+     * @param aInfo protocolInfo
+     * @param aKey transfer id
+     */
+    void SetHeadersL( const TDesC8& aInfo, TAny* aKey );
+    
+    /**
+     * Prepares for upload
+     *
+     * @param aEvent transfer event
+     */
+    void ReadyForTransferL( TUpnpFileTransferEvent& aEvent );
+  
+    /**
+     * Parsers CreateObject-response
+     *
+     * @param aResponse CreateObject-response
+     * @return importUri
+     */
+    HBufC8* ParseCreateObjectResponseL( const TDesC8& aResponse );
+    
+    
+    /**
+     * Handles CreateObject-response
+     *
+     * @param aResponse aObjectID object id
+     * @param aResult CreateObject-response
+     */
+    void HandleObjectResponseL( const TDesC8& aObjectID,
+        const TDesC8& aResult );
+        
+    /**
+     * Finds and return importUri from an item
+     *
+     * @param aObject UPnP item
+     * @return importUri
+     */
+    HBufC8* ImportURIFromItemL( const CUpnpObject& aObject );
+    
+    /**
+     * Converts DLNA compliant protocolInfo to UPnP protocolInfo
+     *
+     * @param aInfo DLNA protolInfo
+     */
+    void ProtocolInfoToUPnPL( const CUpnpAttribute* aInfo );    
+    
+    /**
+     * Issues active scheduler's wait stop request(with/without callback)
+     *
+     * @param none
+     * @return none
+     */
+    void StopWait();
+
+    /**
+     * Callback for active scheduler's wait stop request
+     *
+     */
+    static TInt SchedulerStoppedCallBack( TAny* aPtr );
+    
+    /**
+     * Does necessary action on active scheduler's wait stop complete
+     *
+     * @param none
+     * @return none
+     */
+    void DoSchedulerStoppedCallBack();
+
+    /**
+     * Sends CreateObject command to remote CDS
+     * returns the related HTTP session id
+     */
+    int CreateObjectL( const TDesC8& aContainerId, const TDesC8& aElements );
+
+    /**
+     * Sends DestroyObject command to remote CDS
+     * returns the related HTTP session id
+     */
+    int DestroyObjectL( const TDesC8& aObjectId );
+
+private:
+
+    /**
+     * Http Uploader, used to upload files
+     *
+     * Owned
+     */
+    CHttpUploader*                          iUploader;
+    
+    /**
+     * Used to synchronize CreateObject-action 
+     */
+    CActiveSchedulerWait                    iWait;
+            
+    /**
+     * Resource helper array
+     *
+     * Owned
+     */
+    RPointerArray<CUPnPResourceHelper>      iResources;
+    
+    /**
+     * CUpnpDevice used by AvControlPoint.
+     */
+    const CUpnpDevice*                      iCpDevice; // Not own.    
+        
+    /**
+     * Resource index
+     */
+    TInt                                    iResourceIndex;
+    
+    /**
+     * Stores error (status) code from CreateObject-action
+     */
+    TInt                                    iAsyncError;
+    
+    /**
+     * Session id for CreateObject-action
+     */
+    TInt                                    iIPSessionId;
+    
+    /**
+     * Scheduler stop request
+     */
+    TBool                                   iSchedulerStopped;
+    };
+
+#endif // C_UPNPUPLOADSESSION_H
+
+// End of file
+
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpavcontrollerimpl.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpavcontrollerimpl.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,2144 +1,2310 @@
-/*
-* Copyright (c) 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:      AVController server side root class
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// upnp stack api
-#include <upnpdevice.h>
-#include <upnpcontainer.h>
-#include <upnpservice.h>
-#include <upnpstatevariable.h>
-#include <upnpaction.h>
-#include <upnpobjectlist.h>
-#include <upnpavcontrolpoint.h>
-
-// upnpframework / avcontroller api
-#include "upnpavdeviceobserver.h"
-#include "upnpavdevicelist.h"
-
-// avcontroller internal
-#include "upnpavcontrollerimpl.h"
-#include "upnpavcontrollerserver.h"
-#include "upnpavdispatcher.h"
-#include "upnpavdeviceextended.h"
-#include "upnpdevicerepository.h"
-#include "upnpaverrorhandler.h"
-#include "upnpplaybacksession.h"
-#include "upnpbrowsingsession.h"
-#include "upnpdevicediscoverymessage.h"
-
-#include "upnpuploadsession.h"
-#include "upnpdownloadsession.h"
-
-
-
-#include "upnpsecaccesscontroller.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
-#include "upnplog.h"
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::NewL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-CUPnPAVControllerImpl* CUPnPAVControllerImpl::NewL(
-    RUpnpMediaServerClient& aClient,
-    CUpnpAVControllerServer& aServer )
-    {
-    CUPnPAVControllerImpl* self = new (ELeave) CUPnPAVControllerImpl( 
-        aClient, aServer );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CUPnPAVControllerImpl
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-CUPnPAVControllerImpl::CUPnPAVControllerImpl(
-    RUpnpMediaServerClient& aClient,
-    CUpnpAVControllerServer& aServer ) :
-    iMediaServer( aClient ),
-    iServer( aServer ),
-    iDeviceDiscoveryEnabled( EFalse),
-    iDeviceMsgQue( CUpnpDeviceDiscoveryMessage::LinkOffset() ),
-    iDeviceMsgQueIter( iDeviceMsgQue )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::~CUPnPAVControllerImpl
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-CUPnPAVControllerImpl::~CUPnPAVControllerImpl()
-    {
-    __LOG( "CUPnPAVControllerImpl::~CUPnPAVControllerImpl" );
-    
-    delete iDeviceRespBuf;
-    delete iDeviceListRespBuf;
-    
-    iPlaybackSessions.ResetAndDestroy();
-    iBrowsingSessions.ResetAndDestroy();
-    
-    iUploadSessions.ResetAndDestroy();
-    iDownloadSessions.ResetAndDestroy();
-    
-    CUpnpDeviceDiscoveryMessage* devMsg = NULL;
-    iDeviceMsgQueIter.SetToFirst(); 
-    while ( ( devMsg = iDeviceMsgQueIter++ ) != NULL )
-        {
-        iDeviceMsgQue.Remove( *devMsg );
-        delete devMsg;
-        };    
-
-    delete iConnectionMsg; iConnectionMsg = NULL;
-    delete iDeviceDiscoveryMsg; iDeviceDiscoveryMsg = NULL;        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::ConstructL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::ConstructL()
-    {
-    __LOG( "CUPnPAVControllerImpl::ConstructL" );    
-       
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::ConnectionLost
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::ConnectionLost()
-    {
-    if( iConnectionMsg )
-        {
-        iConnectionMsg->Complete( EAVControllerConnectionLost );
-        delete iConnectionMsg; iConnectionMsg = NULL;
-        
-        }
-    else
-        {
-        // No msg, no can do
-        }    
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DeviceDiscoveredL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::DeviceDiscoveredL(
-    CUpnpAVDeviceExtended& aDevice )
-    {
-    __LOG( "CUPnPAVControllerImpl::DeviceDiscoveredL" );
-
-    if( aDevice.DeviceType() == CUpnpAVDevice::EMediaServer &&
-        ( aDevice.Local() ) )
-        {
-        TInt i;
-        TInt count = iPlaybackSessions.Count();
-        for( i = 0; i < count; i++ )
-            {
-            iPlaybackSessions[ i ]->SetLocalMSUuidL( aDevice.Uuid() );
-            }
-        
-        count = iBrowsingSessions.Count();
-        for( i = 0; i < count; i++ )
-            {
-            iBrowsingSessions[ i ]->SetLocalMSUuidL( aDevice.Uuid() );
-            }
-
-        }
-    else if( iDeviceDiscoveryEnabled )
-        {
-        CUpnpAVDevice* tempDev = CUpnpAVDevice::NewL( aDevice ); 
-                             
-        if( iDeviceDiscoveryMsg )
-            {
-            CleanupStack::PushL( tempDev );
-            
-            delete iDeviceRespBuf; iDeviceRespBuf = NULL;
-            iDeviceRespBuf = tempDev->ToDes8L();
-            
-            CleanupStack::PopAndDestroy( tempDev );
-            
-            // Write back to the client that a device was discovered
-            // of the device and the size
-            TPckg<TAVControllerDeviceDiscovery> resp0( EAVDeviceDiscovered );
-            TPckg<TInt> resp1( iDeviceRespBuf->Length() );
-            
-            iDeviceDiscoveryMsg->WriteL( 0, resp0 );
-            iDeviceDiscoveryMsg->WriteL( 1, resp1 );
-            
-            iDeviceDiscoveryMsg->Complete( EAVControllerDeviceCompleted );
-            delete iDeviceDiscoveryMsg; iDeviceDiscoveryMsg = NULL;
-            }
-        else
-            {
-            // Msg not valid, client is still processing.. 
-            //add the discovered device to queue
-            CUpnpDeviceDiscoveryMessage* tmpDevMsg = 
-                    CUpnpDeviceDiscoveryMessage::NewL( 
-                    tempDev, EAVDeviceDiscovered );
-            iDeviceMsgQue.AddLast( *tmpDevMsg );
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DeviceDisappearedL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::DeviceDisappearedL(
-    CUpnpAVDeviceExtended& aDevice )
-    {
-    __LOG( "CUPnPAVControllerImpl::DeviceDisappearedL" );
-  
-    // Go through browsing and rendering sessions and report if their
-    // device or the local MS disappeared
-    TBool localMs = EFalse;
-    if( aDevice.DeviceType() == CUpnpAVDevice::EMediaServer &&
-        ( aDevice.Local() ) )
-        {
-        __LOG( "CUPnPAVControllerImpl::DeviceDisappearedL\
-        - Local MS disappeared!" );
-        
-         // Local MS disappeared
-         localMs = ETrue;
-        }
-        
-    TInt i;
-    TInt count = iPlaybackSessions.Count();
-    for( i = 0; i < count; i++ )
-        {
-        if( ( iPlaybackSessions[ i ]->Uuid() == aDevice.Uuid() ) ||
-            ( localMs ) )
-            {
-            iPlaybackSessions[ i ]->DeviceDisappearedL( aDevice );
-            }     
-        }
-    
-    count = iBrowsingSessions.Count();
-    for( i = 0; i < count; i++ )
-        {
-        if( ( iBrowsingSessions[ i ]->Uuid() == aDevice.Uuid() ) ||
-            ( localMs ) )
-            {
-            iBrowsingSessions[ i ]->DeviceDisappearedL( aDevice );
-            }     
-        }
-        
-    count = iUploadSessions.Count();
-    for( i = 0; i < count; i++ )
-        {
-        if( iUploadSessions[ i ]->Uuid() == aDevice.Uuid() )
-            {
-            iUploadSessions[ i ]->DeviceDisappearedL( aDevice );
-            }     
-        }
-
-    count = iDownloadSessions.Count();
-    for( i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ]->Uuid() == aDevice.Uuid() )
-            {
-            iDownloadSessions[ i ]->DeviceDisappearedL( aDevice );
-            }     
-        }
-
-    if( iDeviceDiscoveryEnabled )
-        {       
-        // Create a device (buffer)
-        CUpnpAVDevice* tempDev = CUpnpAVDevice::NewL( aDevice );
-            
-         if( iDeviceDiscoveryMsg )
-            {
-            CleanupStack::PushL( tempDev );
-                   
-            delete iDeviceRespBuf; iDeviceRespBuf = NULL;
-            iDeviceRespBuf = tempDev->ToDes8L();
-            CleanupStack::PopAndDestroy( tempDev );
-            
-            // Write back to the client that a device was discovered
-            // and the size of the device
-            TPckg<TAVControllerDeviceDiscovery> resp0(
-                EAVDeviceDisappeared );
-            TPckg<TInt> resp1( iDeviceRespBuf->Length() );
-            
-            iDeviceDiscoveryMsg->WriteL( 0, resp0 );
-            iDeviceDiscoveryMsg->WriteL( 1, resp1 );
-            
-            iDeviceDiscoveryMsg->Complete( EAVControllerDeviceCompleted );
-            delete iDeviceDiscoveryMsg; iDeviceDiscoveryMsg = NULL;
-            }
-        else
-            {
-            // Msg not valid, client is still processing.. 
-            //add the disappeared device to queue
-
-            CUpnpDeviceDiscoveryMessage* tmpDevMsg = 
-                    CUpnpDeviceDiscoveryMessage::NewL( 
-                    tempDev, EAVDeviceDisappeared );
-            iDeviceMsgQue.AddLast( *tmpDevMsg );
-            }
-        }
-    }    
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::EnableDeviceDiscoveryL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::EnableDeviceDiscoveryL(
-    const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPAVControllerImpl::EnableDeviceDiscoveryL" );
-    
-    __ASSERTD( !iDeviceDiscoveryMsg, __FILE__, __LINE__ );
-    
-    if( !iDeviceDiscoveryEnabled )
-        {
-        //iDispatcher.RegisterForDeviceDiscoveryL( *this );
-        iDeviceDiscoveryEnabled = ETrue;    
-        }
-       
-    iDeviceDiscoveryMsg = new (ELeave) RMessage2( aMessage );
-
-    // Check queu's
-    if( !iDeviceMsgQue.IsEmpty() )
-        {
-        CUpnpDeviceDiscoveryMessage* devMsg = iDeviceMsgQue.First();
-        __ASSERTD( devMsg, __FILE__, __LINE__ );
-        CUpnpAVDevice* dev = devMsg->Device();
-        TAVControllerDeviceDiscovery devMsgType = devMsg->MsgType();
-        DequeDeviceL( *dev, devMsgType );
-        iDeviceMsgQue.Remove( *devMsg );
-        delete devMsg;
-        }
-    else
-        {
-        // Empty else
-        }             
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DequeDeviceL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::DequeDeviceL( const CUpnpAVDevice& aDevice,
-    TAVControllerDeviceDiscovery aType )
-    {
-    __LOG( "CUPnPAVControllerImpl::DequeDeviceL" );
-    
-    TPckg<TAVControllerDeviceDiscovery> resp0( aType );
-    iDeviceDiscoveryMsg->WriteL( 0, resp0 );
-    
-    HBufC8* tmp = aDevice.ToDes8L();
-    CleanupStack::PushL( tmp );
-
-    TPckg<TInt> resp1( tmp->Length() );            
-    iDeviceDiscoveryMsg->WriteL( 1, resp1 );
-    
-    CleanupStack::Pop( tmp );
-     
-    delete iDeviceRespBuf; iDeviceRespBuf = NULL;
-    iDeviceRespBuf = tmp;
-            
-    iDeviceDiscoveryMsg->Complete( EAVControllerDeviceCompleted );
-    delete iDeviceDiscoveryMsg; iDeviceDiscoveryMsg = NULL;
-     
-
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetDeviceL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetDeviceL( const RMessage2& aMessage )
-    {
-    __LOG1( "CUPnPAVControllerImpl::GetDeviceL, 0x%d", iDeviceRespBuf );
-    
-    aMessage.WriteL( 0, *iDeviceRespBuf );
-    aMessage.Complete( KErrNone );
-    delete iDeviceRespBuf; iDeviceRespBuf = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DisableDeviceDiscoveryL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::DisableDeviceDiscoveryL(
-    /*const RMessage2& aMessage*/ )
-    {
-    __LOG( "CUPnPAVControllerImpl::DisableDeviceDiscoveryL" );
-    
-    if( iDeviceDiscoveryEnabled )
-        {
-        //iDispatcher.UnRegisterDeviceDiscovery( *this );
-        iDeviceDiscoveryEnabled = EFalse;    
-        }
-    
-    if( iDeviceDiscoveryMsg )
-        { 
-        iDeviceDiscoveryMsg->Complete( KErrCancel );
-        delete iDeviceDiscoveryMsg; iDeviceDiscoveryMsg = NULL;        
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetDeviceListSizeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetDeviceListSizeL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPAVControllerImpl::GetDeviceListSizeL" );
-    
-    // Get the device list from the av control point, create a response buffer
-    // and write the size of the list back to the client
-    TAVControllerDeviceListType deviceListType;
-    TPckg<TAVControllerDeviceListType> resp0( deviceListType );
-    aMessage.ReadL( 0, resp0 );
-    
-    delete iDeviceListRespBuf; iDeviceListRespBuf = NULL;
-    
-    const RPointerArray<CUpnpAVDeviceExtended>& devList =
-        iServer.DeviceRepository().DeviceList();
-    
-    if( deviceListType == EAVMediaServer )
-        {
-        CUpnpAVDeviceList* tempList = CUpnpAVDeviceList::NewLC();
-                
-        TInt count = devList.Count();
-        for( TInt i = 0; i < count; i++ )
-            {
-            if( devList[ i ]->DeviceType() == CUpnpAVDevice::EMediaServer )
-                {
-                if( devList[ i ]->PInfoReceived() &&
-                    !devList[ i ]->Local() )
-                    {
-                    CUpnpAVDevice* tempDev = CUpnpAVDevice::NewL(
-                        *devList[i] );
-                    // Ownership of tempDev transferred
-                    tempList->AppendDeviceL( *tempDev );
-                    }
-                }
-            }
-        iDeviceListRespBuf = tempList->ToDes8L();
-        CleanupStack::PopAndDestroy( tempList );
-        }
-    else
-        {
-        CUpnpAVDeviceList* tempList = CUpnpAVDeviceList::NewLC();
-                
-        TInt count = devList.Count();
-        for( TInt i = 0; i < count; i++ )
-            {
-            if( devList[ i ]->DeviceType() == CUpnpAVDevice::EMediaRenderer )
-                {
-                if( devList[ i ]->PInfoReceived() )
-                    {
-                    CUpnpAVDevice* tempDev = CUpnpAVDevice::NewL(
-                        *devList[i] );
-                    // Ownership of tempDev transferred
-                    tempList->AppendDeviceL( *tempDev );                    
-                    }
-                }
-            }
-        iDeviceListRespBuf = tempList->ToDes8L();
-        CleanupStack::PopAndDestroy( tempList ); 
-        }    
-    
-    // Write the size back to the client
-    TPckg<TInt> resp1( iDeviceListRespBuf->Length() );
-    aMessage.WriteL( 1, resp1 );
-    aMessage.Complete( KErrNone );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetDeviceListL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetDeviceListL( const RMessage2& aMessage )
-    {
-    __LOG1( "CUPnPAVControllerImpl::GetDeviceListL, 0x%d",
-        iDeviceListRespBuf );
-    
-    // Write the device list back to the client
-    aMessage.WriteL( 0, *iDeviceListRespBuf );
-    aMessage.Complete( KErrNone );
-    delete iDeviceListRespBuf; iDeviceListRespBuf = NULL;    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CreateRenderingSessionL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CreateRenderingSessionL(
-    const RMessage2& aMessage )
-    {
-    __LOG1( "CUPnPAVControllerImpl::CreateRenderingSessionL, 0x%d",
-        aMessage.Int0() );
-    
-    // Create a rendering session
-    TInt id = aMessage.Int0();
-    
-    // Read the device UID
-    TInt len = aMessage.GetDesMaxLength( 1 );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( 1, ptr ) );
-
-    CUPnPPlaybackSession* tempPtr = CUPnPPlaybackSession::NewL(
-        iMediaServer, iServer, id, *buf );
-
-    CleanupStack::PopAndDestroy( buf );
-    iPlaybackSessions.AppendL( tempPtr );
-    
-    aMessage.Complete( KErrNone );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DestroyRenderingSessionL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::DestroyRenderingSessionL(
-    const RMessage2& aMessage )
-    {
-    __LOG1( "CUPnPAVControllerImpl::DestroyRenderingSessionL, 0x%d",
-        aMessage.Int0() );
-    
-    // Find and delete a rendering session
-    TInt id = aMessage.Int0();
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            delete iPlaybackSessions[ i ];
-            iPlaybackSessions.Remove( i );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( found )
-        {
-        aMessage.Complete( KErrNone );
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::EventRequestL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::EventRequestL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->EventRequestL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelEventRequestL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelEventRequestL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelEventRequestL();
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( found )
-        {
-        aMessage.Complete( KErrNone );
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::SetURIL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::SetURIL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->SetURIL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelSetURIL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelSetURIL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelSetURIL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }            
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::SetNextURIL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::SetNextURIL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->SetNextURIL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }            
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelSetNextURIL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelSetNextURIL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelSetNextURIL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }            
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::PlayL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::PlayL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->PlayL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-   
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelPlayL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelPlayL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelPlayL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::StopL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::StopL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->StopL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-   
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelStopL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelStopL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelStopL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                
-    }
-   
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::PauseL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::PauseL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->PauseL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelPauseL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelPauseL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelPauseL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::SetVolumeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::SetVolumeL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->SetVolumeL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelSetVolumeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelSetVolumeL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelSetVolumeL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                
-    }  
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetVolumeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetVolumeL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->GetVolumeL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelGetVolumeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelGetVolumeL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelGetVolumeL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::SetMuteL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::SetMuteL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->SetMuteL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelSetMuteL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelSetMuteL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelSetMuteL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                
-    }  
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetMuteL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetMuteL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->GetMuteL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelGetMuteL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelGetMuteL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelGetMuteL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetPositionInfoL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetPositionInfoL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->GetPositionInfoL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelGetPositionInfoL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelGetPositionInfoL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iPlaybackSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iPlaybackSessions[ i ]->SessionId() == id )
-            {
-            iPlaybackSessions[ i ]->CancelGetPositionInfoL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CreateBrowsingSessionL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CreateBrowsingSessionL(
-    const RMessage2& aMessage )
-    {
-    __LOG1( "CUPnPAVControllerImpl::CreateBrowsingSessionL, 0x%d",
-        aMessage.Int0() );
-    
-    // Create a rendering session
-    TInt id = aMessage.Int0();
-    
-    // Read the device UID
-    TInt len = aMessage.GetDesMaxLength( 1 );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( 1, ptr ) );
-    
-    CUPnPBrowsingSession* tempPtr = CUPnPBrowsingSession::NewL(
-        iMediaServer, iServer, id, *buf );
-
-    CleanupStack::PopAndDestroy( buf );
-    iBrowsingSessions.AppendL( tempPtr );
-    
-    aMessage.Complete( KErrNone );    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DestroyBrowsingSessionL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::DestroyBrowsingSessionL(
-    const RMessage2& aMessage )
-    {
-    __LOG1( "CUPnPAVControllerImpl::DestroyBrowsingSessionL, 0x%d",
-        aMessage.Int0() );
-    
-    // Find and delete a rendering session
-    TInt id = aMessage.Int0();
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            delete iBrowsingSessions[ i ];
-            iBrowsingSessions.Remove( i );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( found )
-        {
-        aMessage.Complete( KErrNone );
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetBrowseResponseSizeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetBrowseResponseSizeL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->GetBrowseResponseSizeL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelGetBrowseResponseSizeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelGetBrowseResponseSizeL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->CancelGetBrowseResponseSizeL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetBrowseResponseL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetBrowseResponseL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->GetBrowseResponseL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetSearchResponseSizeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetSearchResponseSizeL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->GetSearchResponseSizeL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelGetSearchResponseSizeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelGetSearchResponseSizeL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->CancelGetSearchResponseSizeL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetSearchResponseL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetSearchResponseL(
-    const RMessage2& aMessage )
-    {
-     TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->GetSearchResponseL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }   
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetSearchCapabitiesSizeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetSearchCapabitiesSizeL(
-    const RMessage2& aMessage )
-    {
-     TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->GetSearchCapabitiesSizeL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }       
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelGetSearchCapabitiesSizeL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelGetSearchCapabitiesSizeL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->CancelGetSearchCapabitiesSizeL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::GetSearchCapabitiesL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::GetSearchCapabitiesL( const RMessage2& aMessage )
-    {
-     TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->GetSearchCapabitiesL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }           
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CreateContainerL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CreateContainerL( const RMessage2& aMessage )
-    {
-     TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->CreateContainerL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }               
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelCreateContainerL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelCreateContainerL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->CancelCreateContainerL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }            
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DeleteObjectL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::DeleteObjectL( const RMessage2& aMessage )
-    {
-     TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->DeleteObjectL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                   
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelDeleteObjectL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelDeleteObjectL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->CancelDeleteObjectL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DeviceDisappearedRequestL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::DeviceDisappearedRequestL(
-    const RMessage2& aMessage )
-    {
-     TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    TInt i;
-    for( i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->DeviceDisappearedRequestL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-        
-    if( !found )
-        {
-        count = iPlaybackSessions.Count();
-        for( i = 0; i < count; i++ )
-            {
-            if( iPlaybackSessions[ i ]->SessionId() == id )
-                {
-                iPlaybackSessions[ i ]->DeviceDisappearedRequestL(
-                    aMessage );
-                found = ETrue;
-                i = count;
-                }
-            }
-        }                       
-
-    if( !found )
-        {  
-        aMessage.Complete( KErrNotFound );
-        }                       
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelDeviceDisappearedRequestL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelDeviceDisappearedRequestL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iBrowsingSessions.Count();
-    TBool found = EFalse;
-    TInt i;
-    for( i = 0; i < count; i++ )
-        {
-        if( iBrowsingSessions[ i ]->SessionId() == id )
-            {
-            iBrowsingSessions[ i ]->CancelDeviceDisappearedRequestL();
-            found = ETrue;
-            i = count;
-            aMessage.Complete( KErrNone );
-            }
-        }
-    if( !found )
-        {
-        count = iPlaybackSessions.Count();
-        for( i = 0; i < count; i++ )
-            {
-            if( iPlaybackSessions[ i ]->SessionId() == id )
-                {
-                iPlaybackSessions[ i ]->CancelDeviceDisappearedRequestL();
-                found = ETrue;
-                i = count;
-                aMessage.Complete( KErrNone );
-                }
-            }        
-        }                    
-
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::MonitorConnectionL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::MonitorConnectionL( const RMessage2& aMessage )
-    {
-    
-    if( iConnectionMsg )
-        {
-        User::Leave( KErrInUse );
-        }
-    else
-        {
-        iConnectionMsg = new (ELeave) RMessage2( aMessage );
-        }  
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CancelMonitorConnectionL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CancelMonitorConnectionL(
-    const RMessage2& aMessage )
-    {
-    
-    if( iConnectionMsg )
-        {
-        iConnectionMsg->Complete( KErrCancel );
-        delete iConnectionMsg; iConnectionMsg = NULL;
-        }
-    aMessage.Complete( KErrNone );       
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::CreateDownloadSessionL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CreateDownloadSessionL(
-    const RMessage2& aMessage )
-    {
-    __LOG1( "CUPnPAVControllerImpl::CreateDownloadSessionL, 0x%d",
-        aMessage.Int0() );
-    
-    // Create a downloading session
-    TInt id = aMessage.Int0();
-    
-    // Read the device UID
-    TInt len = aMessage.GetDesMaxLength( 1 );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( 1, ptr ) );
-
-    CUPnPDownloadSession* tempPtr = CUPnPDownloadSession::NewL(
-        iServer, id, *buf );
-    CleanupStack::PopAndDestroy( buf );
-    iDownloadSessions.AppendL( tempPtr );
-    
-    aMessage.Complete( KErrNone );    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DestroyDownloadSessionL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::DestroyDownloadSessionL(
-    const RMessage2& aMessage )
-    {
-    __LOG1( "CUPnPAVControllerImpl::DestroyDownloadSessionL, 0x%d",
-        aMessage.Int0() );
-    
-    // Find and delete a downloading session
-    TInt id = aMessage.Int0();
-    TInt count = iDownloadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ]->SessionId() == id )
-            {
-            delete iDownloadSessions[ i ];
-            iDownloadSessions.Remove( i );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( found )
-        {
-        aMessage.Complete( KErrNone );
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    }
-
-void CUPnPAVControllerImpl::StartDownloadL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iDownloadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ]->SessionId() == id )
-            {
-            iDownloadSessions[ i ]->StartDownloadL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                       
-    }
-
-void CUPnPAVControllerImpl::StartDownloadFHL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iDownloadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ]->SessionId() == id )
-            {
-            iDownloadSessions[ i ]->StartDownloadFHL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                       
-    }
-    
-void CUPnPAVControllerImpl::CancelDownloadL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iDownloadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ]->SessionId() == id )
-            {
-            iDownloadSessions[ i ]->CancelDownloadL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                           
-    }
-
-void CUPnPAVControllerImpl::CancelAllDownloadsL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iDownloadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ]->SessionId() == id )
-            {
-            iDownloadSessions[ i ]->CancelAllDownloadsL( aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                           
-    }
-    
-void CUPnPAVControllerImpl::StartTrackingDownloadProgressL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iDownloadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ]->SessionId() == id )
-            {
-            iDownloadSessions[ i ]->StartTrackingDownloadProgressL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                           
-    }
-
-void CUPnPAVControllerImpl::StopTrackingDownloadProgressL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iDownloadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ]->SessionId() == id )
-            {
-            iDownloadSessions[ i ]->StopTrackingDownloadProgressL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                           
-    }
-
-void CUPnPAVControllerImpl::GetDownloadEventL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iDownloadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ]->SessionId() == id )
-            {
-            iDownloadSessions[ i ]->GetDownloadEventL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                               
-    }
-    
-void CUPnPAVControllerImpl::CancelGetDownloadEventL(
-    const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iDownloadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDownloadSessions[ i ]->SessionId() == id )
-            {
-            iDownloadSessions[ i ]->CancelGetDownloadEventL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DestroyUploadSessionL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::CreateUploadSessionL(
-    const RMessage2& aMessage )
-    {
-    __LOG1( "CUPnPAVControllerImpl::CreateUploadSessionL, 0x%d",
-        aMessage.Int0() );
-    
-    // Create a downloading session
-    TInt id = aMessage.Int0();
-    
-    // Read the device UID
-    TInt len = aMessage.GetDesMaxLength( 1 );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( 1, ptr ) );
-
-    CUPnPUploadSession* tempPtr = CUPnPUploadSession::NewL(
-        iServer, id, *buf );
-    CleanupStack::PopAndDestroy( buf );
-    iUploadSessions.AppendL( tempPtr );
-    
-    aMessage.Complete( KErrNone );        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVControllerImpl::DestroyUploadSessionL
-// See upnpavcontrollerimpl.h
-// --------------------------------------------------------------------------
-void CUPnPAVControllerImpl::DestroyUploadSessionL(
-    const RMessage2& aMessage )
-    {
-    __LOG1( "CUPnPAVControllerImpl::DestroyUploadSessionL, 0x%d",
-        aMessage.Int0() );
-    
-    // Find and delete an uploading session
-    TInt id = aMessage.Int0();
-    TInt count = iUploadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iUploadSessions[ i ]->SessionId() == id )
-            {
-            delete iUploadSessions[ i ];
-            iUploadSessions.Remove( i );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( found )
-        {
-        aMessage.Complete( KErrNone );
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    }
-
-void CUPnPAVControllerImpl::StartUploadL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iUploadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iUploadSessions[ i ]->SessionId() == id )
-            {
-            iUploadSessions[ i ]->StartUploadL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    }
-    
-void CUPnPAVControllerImpl::CancelUploadL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iUploadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iUploadSessions[ i ]->SessionId() == id )
-            {
-            iUploadSessions[ i ]->CancelUploadL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }            
-    }
-
-void CUPnPAVControllerImpl::CancelAllUploadsL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iUploadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iUploadSessions[ i ]->SessionId() == id )
-            {
-            iUploadSessions[ i ]->CancelAllUploadsL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                
-    }
-    
-void CUPnPAVControllerImpl::StartTrackingUploadProgressL( const RMessage2&
-    aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iUploadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iUploadSessions[ i ]->SessionId() == id )
-            {
-            iUploadSessions[ i ]->StartTrackingUploadProgressL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                    
-    }
-
-void CUPnPAVControllerImpl::StopTrackingUploadProgressL( const RMessage2&
-    aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iUploadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iUploadSessions[ i ]->SessionId() == id )
-            {
-            iUploadSessions[ i ]->StopTrackingUploadProgressL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                        
-    }
-
-void CUPnPAVControllerImpl::GetUploadEventL( const RMessage2& aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iUploadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iUploadSessions[ i ]->SessionId() == id )
-            {
-            iUploadSessions[ i ]->GetUploadEventL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                            
-    }
-    
-void CUPnPAVControllerImpl::CancelGetUploadEventL( const RMessage2&
-    aMessage )
-    {
-    TInt id = aMessage.Int0();
-    
-    // Find the session
-    TInt count = iUploadSessions.Count();
-    TBool found = EFalse;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iUploadSessions[ i ]->SessionId() == id )
-            {
-            iUploadSessions[ i ]->CancelGetUploadEventL(
-                aMessage );
-            found = ETrue;
-            i = count;
-            }
-        }
-    if( !found )
-        {
-        aMessage.Complete( KErrNotFound );
-        }                                
-    }
-
-// end of file
+/*
+* Copyright (c) 2006-2009 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:      AVController server side root class
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// upnp stack api
+#include <upnpaction.h>
+#include <upnpdevice.h>
+#include <upnpservice.h>
+#include <upnpstatevariable.h>
+
+// dlnasrv / mediaserver api
+#include <upnpcontainer.h>
+#include <upnpobjectlist.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavdeviceobserver.h"
+#include "upnpavdevicelist.h"
+
+// dlnasrv / avcontroller internal
+#include "upnpavcontrollerimpl.h"
+#include "upnpavcontrollerserver.h"
+#include "upnpavdispatcher.h"
+#include "upnpavdeviceextended.h"
+#include "upnpdevicerepository.h"
+#include "upnpaverrorhandler.h"
+#include "upnpplaybacksession.h"
+#include "upnpbrowsingsession.h"
+#include "upnpdevicediscoverymessage.h"
+
+#include "upnpuploadsession.h"
+#include "upnpdownloadsession.h"
+
+
+
+#include "upnpsecaccesscontroller.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
+#include "upnplog.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::NewL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+CUPnPAVControllerImpl* CUPnPAVControllerImpl::NewL(
+    CUpnpAVControllerServer& aServer )
+    {
+    CUPnPAVControllerImpl* self = new (ELeave) CUPnPAVControllerImpl( 
+        aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CUPnPAVControllerImpl
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+CUPnPAVControllerImpl::CUPnPAVControllerImpl(
+    CUpnpAVControllerServer& aServer ) :
+    iServer( aServer ),
+    iDeviceDiscoveryEnabled( EFalse),
+    iDeviceMsgQue( CUpnpDeviceDiscoveryMessage::LinkOffset() ),
+    iDeviceMsgQueIter( iDeviceMsgQue )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::~CUPnPAVControllerImpl
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+CUPnPAVControllerImpl::~CUPnPAVControllerImpl()
+    {
+    __LOG( "CUPnPAVControllerImpl::~CUPnPAVControllerImpl" );
+    
+    delete iDeviceRespBuf;
+    delete iDeviceListRespBuf;
+    
+    iPlaybackSessions.ResetAndDestroy();
+    iBrowsingSessions.ResetAndDestroy();
+    
+    iUploadSessions.ResetAndDestroy();
+    iDownloadSessions.ResetAndDestroy();
+    
+    CUpnpDeviceDiscoveryMessage* devMsg = NULL;
+    iDeviceMsgQueIter.SetToFirst(); 
+    while ( ( devMsg = iDeviceMsgQueIter++ ) != NULL )
+        {
+        iDeviceMsgQue.Remove( *devMsg );
+        delete devMsg;
+        };    
+
+    delete iConnectionMsg;
+    delete iDeviceDiscoveryMsg;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::ConstructL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::ConstructL()
+    {
+    __LOG( "CUPnPAVControllerImpl::ConstructL" );    
+       
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::ConnectionLost
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::ConnectionLost()
+    {
+    if( iConnectionMsg )
+        {
+        iConnectionMsg->Complete( EAVControllerConnectionLost );
+        delete iConnectionMsg; iConnectionMsg = NULL;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DeviceDiscoveredL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DeviceDiscoveredL(
+    CUpnpAVDeviceExtended& aDevice )
+    {
+    __LOG( "CUPnPAVControllerImpl::DeviceDiscoveredL" );
+
+    if( aDevice.DeviceType() == CUpnpAVDevice::EMediaServer &&
+        ( aDevice.Local() ) )
+        {
+        TInt i;
+        TInt count = iPlaybackSessions.Count();
+        for( i = 0; i < count; i++ )
+            {
+            iPlaybackSessions[ i ]->SetLocalMSUuidL( aDevice.Uuid() );
+            }
+        
+        count = iBrowsingSessions.Count();
+        for( i = 0; i < count; i++ )
+            {
+            iBrowsingSessions[ i ]->SetLocalMSUuidL( aDevice.Uuid() );
+            }
+
+        }
+    else if( iDeviceDiscoveryEnabled )
+        {
+        CUpnpAVDevice* tempDev = CUpnpAVDevice::NewL( aDevice ); 
+                             
+        if( iDeviceDiscoveryMsg )
+            {
+            CleanupStack::PushL( tempDev );
+            
+            delete iDeviceRespBuf; iDeviceRespBuf = NULL;
+            iDeviceRespBuf = tempDev->ToDes8L();
+            
+            CleanupStack::PopAndDestroy( tempDev );
+            
+            // Write back to the client that a device was discovered
+            // of the device and the size
+            TPckgBuf<TAVControllerDeviceDiscovery> resp0( EAVDeviceDiscovered );
+            TPckgBuf<TInt> resp1( iDeviceRespBuf->Length() );
+            
+            iDeviceDiscoveryMsg->WriteL( 0, resp0 );
+            iDeviceDiscoveryMsg->WriteL( 1, resp1 );
+            
+            iDeviceDiscoveryMsg->Complete( EAVControllerDeviceCompleted );
+            delete iDeviceDiscoveryMsg; iDeviceDiscoveryMsg = NULL;
+            }
+        else
+            {
+            // Msg not valid, client is still processing.. 
+            //add the discovered device to queue
+            CUpnpDeviceDiscoveryMessage* tmpDevMsg = 
+                    CUpnpDeviceDiscoveryMessage::NewL( 
+                    tempDev, EAVDeviceDiscovered );
+            iDeviceMsgQue.AddLast( *tmpDevMsg );
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DeviceDisappearedL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DeviceDisappearedL(
+    CUpnpAVDeviceExtended& aDevice )
+    {
+    __LOG( "CUPnPAVControllerImpl::DeviceDisappearedL" );
+  
+    // Go through browsing and rendering sessions and report if their
+    // device or the local MS disappeared
+    TBool localMs = EFalse;
+    if( aDevice.DeviceType() == CUpnpAVDevice::EMediaServer &&
+        ( aDevice.Local() ) )
+        {
+        __LOG( "CUPnPAVControllerImpl::DeviceDisappearedL\
+        - Local MS disappeared!" );
+        
+         // Local MS disappeared
+         localMs = ETrue;
+        }
+        
+    TInt i;
+    TInt count = iPlaybackSessions.Count();
+    for( i = 0; i < count; i++ )
+        {
+        if( ( iPlaybackSessions[ i ]->Uuid() == aDevice.Uuid() ) ||
+            ( localMs ) )
+            {
+            iPlaybackSessions[ i ]->DeviceDisappearedL( aDevice );
+            }     
+        }
+    
+    count = iBrowsingSessions.Count();
+    for( i = 0; i < count; i++ )
+        {
+        if( ( iBrowsingSessions[ i ]->Uuid() == aDevice.Uuid() ) ||
+            ( localMs ) )
+            {
+            iBrowsingSessions[ i ]->DeviceDisappearedL( aDevice );
+            }     
+        }
+        
+    count = iUploadSessions.Count();
+    for( i = 0; i < count; i++ )
+        {
+        if( iUploadSessions[ i ]->Uuid() == aDevice.Uuid() )
+            {
+            iUploadSessions[ i ]->DeviceDisappearedL( aDevice );
+            }     
+        }
+
+    count = iDownloadSessions.Count();
+    for( i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ]->Uuid() == aDevice.Uuid() )
+            {
+            iDownloadSessions[ i ]->DeviceDisappearedL( aDevice );
+            }     
+        }
+
+    if( iDeviceDiscoveryEnabled )
+        {       
+        // Create a device (buffer)
+        CUpnpAVDevice* tempDev = CUpnpAVDevice::NewL( aDevice );
+            
+         if( iDeviceDiscoveryMsg )
+            {
+            CleanupStack::PushL( tempDev );
+                   
+            delete iDeviceRespBuf; iDeviceRespBuf = NULL;
+            iDeviceRespBuf = tempDev->ToDes8L();
+            CleanupStack::PopAndDestroy( tempDev );
+            
+            // Write back to the client that a device was discovered
+            // and the size of the device
+            TPckgBuf<TAVControllerDeviceDiscovery> resp0(
+                EAVDeviceDisappeared );
+            TPckgBuf<TInt> resp1( iDeviceRespBuf->Length() );
+            
+            iDeviceDiscoveryMsg->WriteL( 0, resp0 );
+            iDeviceDiscoveryMsg->WriteL( 1, resp1 );
+            
+            iDeviceDiscoveryMsg->Complete( EAVControllerDeviceCompleted );
+            delete iDeviceDiscoveryMsg; iDeviceDiscoveryMsg = NULL;
+            }
+        else
+            {
+            // Msg not valid, client is still processing.. 
+            //add the disappeared device to queue
+
+            CUpnpDeviceDiscoveryMessage* tmpDevMsg = 
+                    CUpnpDeviceDiscoveryMessage::NewL( 
+                    tempDev, EAVDeviceDisappeared );
+            iDeviceMsgQue.AddLast( *tmpDevMsg );
+            }
+        }
+    }    
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DeviceIconDownloadedL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DeviceIconDownloadedL( CUpnpAVDeviceExtended& aDevice )
+    {
+    if( iDeviceDiscoveryEnabled )
+        {
+        CUpnpAVDevice* tempDev = CUpnpAVDevice::NewL( aDevice );
+        if( iDeviceDiscoveryMsg )
+            {
+            CleanupStack::PushL( tempDev );
+            delete iDeviceRespBuf;
+            iDeviceRespBuf = NULL;
+            iDeviceRespBuf = tempDev->ToDes8L();
+            CleanupStack::PopAndDestroy( tempDev );
+            TPckgBuf<TAVControllerDeviceDiscovery> resp0( EAVDeviceIconDownloaded );
+            TPckgBuf<TInt> resp1( iDeviceRespBuf->Length() );
+            iDeviceDiscoveryMsg->WriteL( 0, resp0 );
+            iDeviceDiscoveryMsg->WriteL( 1, resp1 );
+            iDeviceDiscoveryMsg->Complete( EAVControllerDeviceCompleted );
+            delete iDeviceDiscoveryMsg;
+            iDeviceDiscoveryMsg = NULL;
+            }
+        else
+            {
+            CUpnpDeviceDiscoveryMessage* tmpDevMsg = CUpnpDeviceDiscoveryMessage::NewL(
+                tempDev, EAVDeviceIconDownloaded );
+            iDeviceMsgQue.AddLast( *tmpDevMsg );
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::EnableDeviceDiscoveryL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::EnableDeviceDiscoveryL(
+    const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPAVControllerImpl::EnableDeviceDiscoveryL" );
+    
+    __ASSERT( !iDeviceDiscoveryMsg, __FILE__, __LINE__ );
+    
+    if( !iDeviceDiscoveryEnabled )
+        {
+        //iDispatcher.RegisterForDeviceDiscoveryL( *this );
+        iDeviceDiscoveryEnabled = ETrue;    
+        }
+       
+    iDeviceDiscoveryMsg = new (ELeave) RMessage2( aMessage );
+
+    // Check queu's
+    if( !iDeviceMsgQue.IsEmpty() )
+        {
+        CUpnpDeviceDiscoveryMessage* devMsg = iDeviceMsgQue.First();
+        __ASSERTD( devMsg, __FILE__, __LINE__ );
+        CUpnpAVDevice* dev = devMsg->Device();
+        TAVControllerDeviceDiscovery devMsgType = devMsg->MsgType();
+        DequeDeviceL( *dev, devMsgType );
+        iDeviceMsgQue.Remove( *devMsg );
+        delete devMsg;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DequeDeviceL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DequeDeviceL( const CUpnpAVDevice& aDevice,
+    TAVControllerDeviceDiscovery aType )
+    {
+    __LOG( "CUPnPAVControllerImpl::DequeDeviceL" );
+    
+    TPckg<TAVControllerDeviceDiscovery> resp0( aType );
+    iDeviceDiscoveryMsg->WriteL( 0, resp0 );
+    
+    HBufC8* tmp = aDevice.ToDes8L();
+    CleanupStack::PushL( tmp );
+
+    TPckgBuf<TInt> resp1( tmp->Length() );            
+    iDeviceDiscoveryMsg->WriteL( 1, resp1 );
+    
+    CleanupStack::Pop( tmp );
+     
+    delete iDeviceRespBuf; iDeviceRespBuf = NULL;
+    iDeviceRespBuf = tmp;
+            
+    iDeviceDiscoveryMsg->Complete( EAVControllerDeviceCompleted );
+    delete iDeviceDiscoveryMsg; iDeviceDiscoveryMsg = NULL;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetDeviceL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetDeviceL( const RMessage2& aMessage )
+    {
+    __LOG1( "CUPnPAVControllerImpl::GetDeviceL, 0x%d", iDeviceRespBuf );
+    
+    aMessage.WriteL( 0, *iDeviceRespBuf );
+    aMessage.Complete( KErrNone );
+    delete iDeviceRespBuf; iDeviceRespBuf = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DisableDeviceDiscoveryL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DisableDeviceDiscoveryL(
+    /*const RMessage2& aMessage*/ )
+    {
+    __LOG( "CUPnPAVControllerImpl::DisableDeviceDiscoveryL" );
+    
+    if( iDeviceDiscoveryEnabled )
+        {
+        //iDispatcher.UnRegisterDeviceDiscovery( *this );
+        iDeviceDiscoveryEnabled = EFalse;    
+        }
+    
+    if( iDeviceDiscoveryMsg )
+        { 
+        iDeviceDiscoveryMsg->Complete( KErrCancel );
+        delete iDeviceDiscoveryMsg; iDeviceDiscoveryMsg = NULL;        
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetDeviceListSizeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetDeviceListSizeL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPAVControllerImpl::GetDeviceListSizeL" );
+    
+    // Get the device list from the av control point, create a response buffer
+    // and write the size of the list back to the client
+    TAVControllerDeviceListType deviceListType;
+    TPckg<TAVControllerDeviceListType> resp0( deviceListType );
+    aMessage.ReadL( 0, resp0 );
+    
+    delete iDeviceListRespBuf; iDeviceListRespBuf = NULL;
+    
+    const RPointerArray<CUpnpAVDeviceExtended>& devList =
+        iServer.DeviceRepository().DeviceList();
+    
+    if( deviceListType == EAVMediaServer )
+        {
+        CUpnpAVDeviceList* tempList = CUpnpAVDeviceList::NewLC();
+                
+        TInt count = devList.Count();
+        for( TInt i = 0; i < count; i++ )
+            {
+            if( devList[ i ]->DeviceType() == CUpnpAVDevice::EMediaServer )
+                {
+                if( devList[ i ]->PInfoReceived() &&
+                    !devList[ i ]->Local() )
+                    {
+                    CUpnpAVDevice* tempDev = CUpnpAVDevice::NewL(
+                        *devList[i] );
+                    CleanupStack::PushL( tempDev );
+                    // Ownership of tempDev transferred
+                    tempList->AppendDeviceL( *tempDev );
+                    CleanupStack::Pop( tempDev );
+                    }
+                }
+            }
+        __LOG1( "CUPnPAVControllerImpl::GetDeviceListSizeL servers: %d", tempList->Count() );
+        iDeviceListRespBuf = tempList->ToDes8L();
+        CleanupStack::PopAndDestroy( tempList );
+        }
+    else
+        {
+        CUpnpAVDeviceList* tempList = CUpnpAVDeviceList::NewLC();
+                
+        TInt count = devList.Count();
+        for( TInt i = 0; i < count; i++ )
+            {
+            if( devList[ i ]->DeviceType() == CUpnpAVDevice::EMediaRenderer )
+                {
+                if( devList[ i ]->PInfoReceived() )
+                    {
+                    CUpnpAVDevice* tempDev = CUpnpAVDevice::NewL(
+                        *devList[i] );
+                    CleanupStack::PushL( tempDev );
+                    // Ownership of tempDev transferred
+                    tempList->AppendDeviceL( *tempDev );
+                    CleanupStack::Pop( tempDev );
+                    }
+                }
+            }
+        __LOG1( "CUPnPAVControllerImpl::GetDeviceListSizeL renderers: %d", tempList->Count() );
+        iDeviceListRespBuf = tempList->ToDes8L();
+        CleanupStack::PopAndDestroy( tempList ); 
+        }    
+    
+    // Write the size back to the client
+    TPckgBuf<TInt> resp1( iDeviceListRespBuf->Length() );
+    aMessage.WriteL( 1, resp1 );
+    aMessage.Complete( KErrNone );
+
+    __LOG( "CUPnPAVControllerImpl::GetDeviceListSizeL end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetDeviceListL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetDeviceListL( const RMessage2& aMessage )
+    {
+    __LOG1( "CUPnPAVControllerImpl::GetDeviceListL, 0x%d",
+        iDeviceListRespBuf );
+    
+    // Write the device list back to the client
+    aMessage.WriteL( 0, *iDeviceListRespBuf );
+    aMessage.Complete( KErrNone );
+    delete iDeviceListRespBuf; iDeviceListRespBuf = NULL;    
+
+    __LOG( "CUPnPAVControllerImpl::GetDeviceListL end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetDeviceIconRequestL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetDeviceIconRequestL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPAVControllerImpl::GetDeviceIconRequestL" );
+
+    TInt uuidLen = aMessage.GetDesLengthL( 0 );
+    if ( uuidLen < 0 || uuidLen > KMaxTInt/2 ) // to avoid alloc panic
+        {
+        User::Leave( KErrArgument );
+        }
+    HBufC8* uuid = HBufC8::NewLC( uuidLen );
+    TPtr8 uuidPtr = uuid->Des();
+    aMessage.ReadL( 0, uuidPtr );
+    // Message is completed by the transfer
+    iServer.TransferDeviceIconFileToClientL( aMessage, 1, uuidPtr );
+    CleanupStack::PopAndDestroy( uuid );
+
+    __LOG( "CUPnPAVControllerImpl::GetDeviceIconRequestL end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CreateRenderingSessionL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CreateRenderingSessionL(
+    const RMessage2& aMessage )
+    {
+    __LOG1( "CUPnPAVControllerImpl::CreateRenderingSessionL, 0x%d",
+        aMessage.Int0() );
+    
+    // Create a rendering session
+    TInt id = aMessage.Int0();
+    
+    // Read the device UID
+    TInt len = aMessage.GetDesMaxLength( 1 );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( 1, ptr ) );
+
+    CUPnPPlaybackSession* tempPtr = CUPnPPlaybackSession::NewL(
+        iServer, id, *buf );
+
+    CleanupStack::PopAndDestroy( buf );
+    iPlaybackSessions.Append( tempPtr );
+    
+    aMessage.Complete( KErrNone );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DestroyRenderingSessionL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DestroyRenderingSessionL(
+    const RMessage2& aMessage )
+    {
+    __LOG1( "CUPnPAVControllerImpl::DestroyRenderingSessionL, 0x%d",
+        aMessage.Int0() );
+    
+    // Find and delete a rendering session
+    TInt id = aMessage.Int0();
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            delete iPlaybackSessions[ i ];
+            iPlaybackSessions.Remove( i );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( found )
+        {
+        aMessage.Complete( KErrNone );
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::EventRequestL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::EventRequestL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->EventRequestL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelEventRequestL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelEventRequestL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelEventRequestL();
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( found )
+        {
+        aMessage.Complete( KErrNone );
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::SetURIL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::SetURIL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->SetURIL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelSetURIL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelSetURIL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelSetURIL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }            
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::SetNextURIL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::SetNextURIL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->SetNextURIL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }            
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelSetNextURIL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelSetNextURIL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelSetNextURIL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }            
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::PlayL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::PlayL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->PlayL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+   
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelPlayL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelPlayL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelPlayL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::StopL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::StopL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->StopL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+   
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelStopL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelStopL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelStopL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                
+    }
+   
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::PauseL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::PauseL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->PauseL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelPauseL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelPauseL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelPauseL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::SetVolumeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::SetVolumeL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->SetVolumeL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelSetVolumeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelSetVolumeL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelSetVolumeL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                
+    }  
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetVolumeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetVolumeL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->GetVolumeL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelGetVolumeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelGetVolumeL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelGetVolumeL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::SetMuteL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::SetMuteL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->SetMuteL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelSetMuteL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelSetMuteL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelSetMuteL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                
+    }  
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetMuteL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetMuteL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->GetMuteL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelGetMuteL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelGetMuteL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelGetMuteL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetPositionInfoL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetPositionInfoL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->GetPositionInfoL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelGetPositionInfoL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelGetPositionInfoL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelGetPositionInfoL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::SeekRelTimeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::SeekRelTimeL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->SeekRelTimeL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelSeekRelTimeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelSeekRelTimeL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->CancelSeekRelTimeL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                    
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetRendererStateL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetRendererStateL( const RMessage2& aMessage)
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iPlaybackSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iPlaybackSessions[ i ]->SessionId() == id )
+            {
+            iPlaybackSessions[ i ]->GetRendererStateL( aMessage );
+            found = ETrue;
+            i = count;
+            //aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CreateBrowsingSessionL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CreateBrowsingSessionL(
+    const RMessage2& aMessage )
+    {
+    __LOG1( "CUPnPAVControllerImpl::CreateBrowsingSessionL, 0x%d",
+        aMessage.Int0() );
+    
+    // Create a rendering session
+    TInt id = aMessage.Int0();
+    
+    // Read the device UID
+    TInt len = aMessage.GetDesMaxLength( 1 );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( 1, ptr ) );
+    
+    CUPnPBrowsingSession* tempPtr = CUPnPBrowsingSession::NewL(
+        iServer, id, *buf );
+
+    CleanupStack::PopAndDestroy( buf );
+    iBrowsingSessions.Append( tempPtr );
+    
+    aMessage.Complete( KErrNone );    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DestroyBrowsingSessionL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DestroyBrowsingSessionL(
+    const RMessage2& aMessage )
+    {
+    __LOG1( "CUPnPAVControllerImpl::DestroyBrowsingSessionL, 0x%d",
+        aMessage.Int0() );
+    
+    // Find and delete a rendering session
+    TInt id = aMessage.Int0();
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            delete iBrowsingSessions[ i ];
+            iBrowsingSessions.Remove( i );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( found )
+        {
+        aMessage.Complete( KErrNone );
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetBrowseResponseSizeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetBrowseResponseSizeL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->GetBrowseResponseSizeL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelGetBrowseResponseSizeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelGetBrowseResponseSizeL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->CancelGetBrowseResponseSizeL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetBrowseResponseL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetBrowseResponseL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->GetBrowseResponseL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetSearchResponseSizeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetSearchResponseSizeL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->GetSearchResponseSizeL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelGetSearchResponseSizeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelGetSearchResponseSizeL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->CancelGetSearchResponseSizeL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetSearchResponseL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetSearchResponseL(
+    const RMessage2& aMessage )
+    {
+     TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->GetSearchResponseL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }   
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetSearchCapabitiesSizeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetSearchCapabitiesSizeL(
+    const RMessage2& aMessage )
+    {
+     TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->GetSearchCapabitiesSizeL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }       
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelGetSearchCapabitiesSizeL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelGetSearchCapabitiesSizeL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->CancelGetSearchCapabitiesSizeL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetSearchCapabitiesL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetSearchCapabitiesL( const RMessage2& aMessage )
+    {
+     TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->GetSearchCapabitiesL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }           
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CreateContainerL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CreateContainerL( const RMessage2& aMessage )
+    {
+     TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->CreateContainerL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }               
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelCreateContainerL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelCreateContainerL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->CancelCreateContainerL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }            
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DeleteObjectL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DeleteObjectL( const RMessage2& aMessage )
+    {
+     TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->DeleteObjectL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                   
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelDeleteObjectL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelDeleteObjectL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->CancelDeleteObjectL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DeviceDisappearedRequestL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DeviceDisappearedRequestL(
+    const RMessage2& aMessage )
+    {
+     TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    TInt i;
+    for( i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->DeviceDisappearedRequestL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+        
+    if( !found )
+        {
+        count = iPlaybackSessions.Count();
+        for( i = 0; i < count; i++ )
+            {
+            if( iPlaybackSessions[ i ]->SessionId() == id )
+                {
+                iPlaybackSessions[ i ]->DeviceDisappearedRequestL(
+                    aMessage );
+                found = ETrue;
+                i = count;
+                }
+            }
+        }                       
+
+    if( !found )
+        {  
+        aMessage.Complete( KErrNotFound );
+        }                       
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelDeviceDisappearedRequestL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelDeviceDisappearedRequestL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iBrowsingSessions.Count();
+    TBool found = EFalse;
+    TInt i;
+    for( i = 0; i < count; i++ )
+        {
+        if( iBrowsingSessions[ i ]->SessionId() == id )
+            {
+            iBrowsingSessions[ i ]->CancelDeviceDisappearedRequestL();
+            found = ETrue;
+            i = count;
+            aMessage.Complete( KErrNone );
+            }
+        }
+    if( !found )
+        {
+        count = iPlaybackSessions.Count();
+        for( i = 0; i < count; i++ )
+            {
+            if( iPlaybackSessions[ i ]->SessionId() == id )
+                {
+                iPlaybackSessions[ i ]->CancelDeviceDisappearedRequestL();
+                found = ETrue;
+                i = count;
+                aMessage.Complete( KErrNone );
+                }
+            }        
+        }                    
+
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::MonitorConnectionL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::MonitorConnectionL( const RMessage2& aMessage )
+    {
+    
+    if( iConnectionMsg )
+        {
+        User::Leave( KErrInUse );
+        }
+    else
+        {
+        iConnectionMsg = new (ELeave) RMessage2( aMessage );
+        }  
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelMonitorConnectionL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelMonitorConnectionL(
+    const RMessage2& aMessage )
+    {
+    
+    if( iConnectionMsg )
+        {
+        iConnectionMsg->Complete( KErrCancel );
+        delete iConnectionMsg; iConnectionMsg = NULL;
+        }
+    aMessage.Complete( KErrNone );       
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CreateDownloadSessionL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CreateDownloadSessionL(
+    const RMessage2& aMessage )
+    {
+    __LOG1( "CUPnPAVControllerImpl::CreateDownloadSessionL, 0x%d",
+        aMessage.Int0() );
+    
+    // Create a downloading session
+    TInt id = aMessage.Int0();
+    
+    // Read the device UID
+    TInt len = aMessage.GetDesMaxLength( 1 );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( 1, ptr ) );
+
+    CUPnPDownloadSession* tempPtr = CUPnPDownloadSession::NewL(
+        iServer, id, *buf );
+    CleanupStack::PopAndDestroy( buf );
+    iDownloadSessions.Append( tempPtr );
+    
+    aMessage.Complete( KErrNone );    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DestroyDownloadSessionL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DestroyDownloadSessionL(
+    const RMessage2& aMessage )
+    {
+    __LOG1( "CUPnPAVControllerImpl::DestroyDownloadSessionL, 0x%d",
+        aMessage.Int0() );
+    
+    // Find and delete a downloading session
+    TInt id = aMessage.Int0();
+    TInt count = iDownloadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ]->SessionId() == id )
+            {
+            delete iDownloadSessions[ i ];
+            iDownloadSessions.Remove( i );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( found )
+        {
+        aMessage.Complete( KErrNone );
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::StartDownloadL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::StartDownloadL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iDownloadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ]->SessionId() == id )
+            {
+            iDownloadSessions[ i ]->StartDownloadL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                       
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::StartDownloadFHL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::StartDownloadFHL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iDownloadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ]->SessionId() == id )
+            {
+            iDownloadSessions[ i ]->StartDownloadFHL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                       
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelDownloadL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelDownloadL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iDownloadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ]->SessionId() == id )
+            {
+            iDownloadSessions[ i ]->CancelDownloadL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                           
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelAllDownloadsL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CancelAllDownloadsL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iDownloadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ]->SessionId() == id )
+            {
+            iDownloadSessions[ i ]->CancelAllDownloadsL( aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                           
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::StartTrackingDownloadProgressL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------    
+void CUPnPAVControllerImpl::StartTrackingDownloadProgressL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iDownloadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ]->SessionId() == id )
+            {
+            iDownloadSessions[ i ]->StartTrackingDownloadProgressL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                           
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::StopTrackingDownloadProgressL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::StopTrackingDownloadProgressL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iDownloadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ]->SessionId() == id )
+            {
+            iDownloadSessions[ i ]->StopTrackingDownloadProgressL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                           
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::GetDownloadEventL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::GetDownloadEventL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iDownloadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ]->SessionId() == id )
+            {
+            iDownloadSessions[ i ]->GetDownloadEventL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                               
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::CancelGetDownloadEventL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------    
+void CUPnPAVControllerImpl::CancelGetDownloadEventL(
+    const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iDownloadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDownloadSessions[ i ]->SessionId() == id )
+            {
+            iDownloadSessions[ i ]->CancelGetDownloadEventL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DestroyUploadSessionL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::CreateUploadSessionL(
+    const RMessage2& aMessage )
+    {
+    __LOG1( "CUPnPAVControllerImpl::CreateUploadSessionL, 0x%d",
+        aMessage.Int0() );
+    
+    // Create a downloading session
+    TInt id = aMessage.Int0();
+    
+    // Read the device UID
+    TInt len = aMessage.GetDesMaxLength( 1 );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( 1, ptr ) );
+
+    CUPnPUploadSession* tempPtr = CUPnPUploadSession::NewL(
+        iServer, id, *buf );
+    CleanupStack::PopAndDestroy( buf );
+    iUploadSessions.Append( tempPtr );
+    
+    aMessage.Complete( KErrNone );        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVControllerImpl::DestroyUploadSessionL
+// See upnpavcontrollerimpl.h
+// --------------------------------------------------------------------------
+void CUPnPAVControllerImpl::DestroyUploadSessionL(
+    const RMessage2& aMessage )
+    {
+    __LOG1( "CUPnPAVControllerImpl::DestroyUploadSessionL, 0x%d",
+        aMessage.Int0() );
+    
+    // Find and delete an uploading session
+    TInt id = aMessage.Int0();
+    TInt count = iUploadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iUploadSessions[ i ]->SessionId() == id )
+            {
+            delete iUploadSessions[ i ];
+            iUploadSessions.Remove( i );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( found )
+        {
+        aMessage.Complete( KErrNone );
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+
+void CUPnPAVControllerImpl::StartUploadL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iUploadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iUploadSessions[ i ]->SessionId() == id )
+            {
+            iUploadSessions[ i ]->StartUploadL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    }
+    
+void CUPnPAVControllerImpl::CancelUploadL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iUploadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iUploadSessions[ i ]->SessionId() == id )
+            {
+            iUploadSessions[ i ]->CancelUploadL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }            
+    }
+
+void CUPnPAVControllerImpl::CancelAllUploadsL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iUploadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iUploadSessions[ i ]->SessionId() == id )
+            {
+            iUploadSessions[ i ]->CancelAllUploadsL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                
+    }
+    
+void CUPnPAVControllerImpl::StartTrackingUploadProgressL( const RMessage2&
+    aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iUploadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iUploadSessions[ i ]->SessionId() == id )
+            {
+            iUploadSessions[ i ]->StartTrackingUploadProgressL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                    
+    }
+
+void CUPnPAVControllerImpl::StopTrackingUploadProgressL( const RMessage2&
+    aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iUploadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iUploadSessions[ i ]->SessionId() == id )
+            {
+            iUploadSessions[ i ]->StopTrackingUploadProgressL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                        
+    }
+
+void CUPnPAVControllerImpl::GetUploadEventL( const RMessage2& aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iUploadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iUploadSessions[ i ]->SessionId() == id )
+            {
+            iUploadSessions[ i ]->GetUploadEventL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                            
+    }
+    
+void CUPnPAVControllerImpl::CancelGetUploadEventL( const RMessage2&
+    aMessage )
+    {
+    TInt id = aMessage.Int0();
+    
+    // Find the session
+    TInt count = iUploadSessions.Count();
+    TBool found = EFalse;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iUploadSessions[ i ]->SessionId() == id )
+            {
+            iUploadSessions[ i ]->CancelGetUploadEventL(
+                aMessage );
+            found = ETrue;
+            i = count;
+            }
+        }
+    if( !found )
+        {
+        aMessage.Complete( KErrNotFound );
+        }                                
+    }
+
+// end of file
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpavcontrollerserver.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpavcontrollerserver.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1001 +1,800 @@
-/*
-* Copyright (c) 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:      AVController server
-*
-*/
-
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <e32svr.h>
-#include <f32file.h> 
-
-// upnp stack
-#include <upnpdevice.h>
-
-// upnpframework / avcontroller api
-#include "upnpavcontrollerglobals.h"
-
-// upnpframework / internal api's
-#include "upnpconnectionmonitor.h"
-
-#include "upnpsecaccesscontroller.h"
-
-
-// avcontroller server internal
-#include "upnpavcontrollerserver.h"
-#include "upnpavcontrollersession.h"
-
-#include <upnpsettings.h>
-
-#include "upnpavcontrolpoint.h"
-
-
-#include "upnpavdispatcher.h"
-#include "upnpdevicerepository.h"
-#include "upnpavdeviceextended.h"
-#include "upnpaverrorhandler.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerserver.txt" );
-#include "upnplog.h"
-
-// CONSTANTS
-_LIT8( KMediaServer,                    "MediaServer" );
-_LIT8( KUPnPRootDevice,                 "upnp:rootdevice" );
-
-const TInt KMaxDepth = 4;
-const TInt KMaxDeviceCount = 6;
-
-const TUint myRangeCount = 3;
-
-const TInt myRanges[ myRangeCount ] = 
-    {
-    0, // numbers 0-18
-    18, // numbers 18-81 
-    81 // numbers 81-KMaxInt
-    };
-
-const TUint8 myElementsIndex[ myRangeCount ] = 
-    {
-    0, 
-    1, 
-    CPolicyServer::ENotSupported
-    };
-    
-const CPolicyServer::TPolicyElement myElements[] = 
-    {
-    {_INIT_SECURITY_POLICY_C3(ECapabilityNetworkServices,
-        ECapabilityReadUserData, ECapabilityWriteUserData ),
-        CPolicyServer::EFailClient },
-    {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkServices),
-        CPolicyServer::EFailClient}
-    };
-    
-const CPolicyServer::TPolicy myPolicy =
-    {
-    CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
-    myRangeCount,                   
-    myRanges,
-    myElementsIndex,
-    myElements,
-    };
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::CUpnpAVControllerServer
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-CUpnpAVControllerServer::CUpnpAVControllerServer( TInt aPriority ):
-    CPolicyServer( aPriority, myPolicy ),
-    iShutdownTimeoutValue( KTimerCycle10 ),
-    iServerState( EStateUndefined )
-    {    
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::ConstructL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::ConstructL()
-    {
-    __LOG( "CUpnpAVControllerServer::ConstructL" );
-                               
-    iDispatcher = CUPnPAVDispatcher::NewL( *this );
-    
-    iServerState = EStateStartingUp;
-
-    CUpnpSettings* settings = CUpnpSettings::NewL( KCRUidUPnPStack );
-    settings->Get( CUpnpSettings::KUPnPStackIapId, iIAP );
-    delete settings;    
-
-    User::LeaveIfError( iMediaServer.Connect() );
-    iMonitor = CUPnPConnectionMonitor::NewL( *this, iIAP );
-    
-    StartL( KAVControllerName );   
-    
-    iServerTimer = CUPnPAVTimer::NewL( *this,
-        CUPnPAVTimer::ETimerServerShutdown );
-    
-    iServerTimer->Start( iShutdownTimeoutValue );
-    
-    iMSTimer = CUPnPAVTimer::NewL( *this, CUPnPAVTimer::ETimerMediaServer );
-    __LOG( "CUpnpAVControllerServer::ConstructL - Finished" );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::StartUpL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::StartUpL()
-    {
-    __LOG( "CUpnpAVControllerServer::StartUpL" );
-
-    TInt error = KErrNone;
-    if( iServerState == EStateStartingUp )
-        {
-        __LOG( "StartUpL - Starting up" );
-              
-        
-        if( !iAVControlPoint )
-            {
-            __LOG( "CUpnpAVControllerServer::StartUpL - CP" );
-
-            TRAP( error, iAVControlPoint = CUpnpAVControlPoint::NewL( 
-                                                               *iDispatcher ));
-            // If operation fails for some reason , the 10 second timeout 
-            // is completely useless and wrong in this case. 
-            // The server should be shut down immediately   
-            if( error != KErrNone )
-                {
-                iShutdownTimeoutValue = 0;   
-                User::Leave( error );
-                }
-            }
-        if( !iDeviceRepository )
-            {
-            iDeviceRepository = CUPnPDeviceRepository::NewL( *iAVControlPoint );
-            }
-        iServerState = EStateRunning;  
-        }
-    else if( iServerState == EStateShuttingDown )
-        {
-        __LOG( "StartUpL - Wlan disconnected or shutting down, leave" );
-        User::Leave( KErrDisconnected );
-        }
-    else
-        {
-        __LOG( "StartUpL - Server running" );
-        }        
-
-    __LOG( "StartUpL - Completed" );    
-    }
-
-void CUpnpAVControllerServer::CancelStartUp()
-    {
-    __LOG( "CUpnpAVControllerServer::CancelStartUp" );
-    
-    // Cancel can occur only when the av controller instance is deleted
-    // right after the asyncronous part of the construction has been
-    // started. There is no proper way to cancel, but we can set the
-    // shutdown timer to 0, so the server will shutdown immidiately.
-    
-    if( iSessionCount <= 1 )
-        {
-        iShutdownTimeoutValue = 0;    
-        }  
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::NewLC
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-CUpnpAVControllerServer* CUpnpAVControllerServer::NewLC()
-    {
-    CUpnpAVControllerServer* self = new( ELeave )
-        CUpnpAVControllerServer( EPriorityNormal );   
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::~CUpnpAVControllerServer
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-CUpnpAVControllerServer::~CUpnpAVControllerServer()
-    {
-    __LOG( "CUpnpAVControllerServer::~CUpnpAVControllerServer" );
-    
-    delete iAVControlPoint;
-    delete iDispatcher;
-    delete iDeviceRepository;
-   
-    delete iMonitor;
-    delete iServerTimer;
-    delete iMSTimer;
-
-    iMediaServer.Close();
-
-    for( TInt i = 0; i < iStartMessages.Count(); i++ )
-        {
-        iStartMessages[ i ]->Complete( KErrCancel );
-        }
-    iStartMessages.ResetAndDestroy();  
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::NewSessionL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-CSession2* CUpnpAVControllerServer::NewSessionL( const TVersion& aVersion,
-    const RMessage2& aMessage ) const
-    {
-    __LOG( "CUpnpAVControllerServer::NewSessionL" );
-    
-    if( iServerState == EStateShuttingDown )
-        {
-        __LOG( "NewSessionL - server shutting down, no new sessions \
-are allowed at this point" );
-        User::Leave( KErrDisconnected );
-        }
-    else if( iServerState == EStateStartingUp && iSessionCount > 0 )
-        {
-        __LOG( "NewSessionL - server starting up, no new sessions \
-are allowed at this point" );
-        User::Leave( KErrServerBusy );
-        }
-        
-    // Check we're the right version
-    if ( !User::QueryVersionSupported( TVersion( 
-            KAVControllerMajorVersionNumber,
-            KAVControllerMinorVersionNumber,
-            KAVControllerBuildVersionNumber ),
-            aVersion ) )
-        {
-        User::Leave( KErrNotSupported );
-        }
-
-    // Make new session
-    RThread client;
-    aMessage.Client(client);  
-    return CUpnpAVControllerSession::NewL(
-        *(CUpnpAVControllerServer*)this );
-    }
-    
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::UPnPAVTimerCallback
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::UPnPAVTimerCallback(
-    CUPnPAVTimer::TAVTimerType aType ) 
-    {
-    __LOG( "CUpnpAVControllerServer::UPnPAVTimerCallback" );
-
-
-    if( aType == CUPnPAVTimer::ETimerServerShutdown )
-        {
-        iServerState = EStateShuttingDown;
-           
-        if( iMSTimer->IsActive() )
-            {
-            // if the Media Server timer is still running for some reason
-            iMSTimer->Cancel();
-            StopMediaServer();
-            }
-        CActiveScheduler::Stop();
-        }
-    else if( aType == CUPnPAVTimer::ETimerMediaServer )
-        {
-        if( iStartingMS )
-            {
-            StopMediaServer();
-            TInt count = iStartMessages.Count();
-            for( TInt i = 0; i < count; i++ )
-                {
-                iStartMessages[ i ]->Complete( KErrTimedOut );
-                }
-            iStartMessages.ResetAndDestroy();
-            
-            iStartingMS = EFalse;
-            }
-        else // Shutting down
-            {
-            StopMediaServer();
-            }            
-        }
-    else
-        {
-        
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::ConnectionLost
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::ConnectionLost()
-    {
-    __LOG( "CUpnpAVControllerServer::ConnectionLost" );
-    
-    iShutdownTimeoutValue = 0; // Set shutdown timer value to 0, we want to
-    // shut down the server immidiately after the last session has been
-    // closed
-    
-    if( iServerState == EStateRunning && iDeviceRepository )
-        {
-        __LOG( "ConnectionLost - Server running" );
-        iDeviceRepository->ConnectionLost();    
-
-        CSession2* s;
-        iSessionIter.SetToFirst(); 
-        while ( ( s = iSessionIter++ ) != NULL )
-            {
-            CUpnpAVControllerSession* sess =
-                static_cast<CUpnpAVControllerSession*>(s);
-            if( sess )
-                {
-                sess->ConnectionLost();    
-                }
-            };  
-        iServerState = EStateShuttingDown;
-        }
-    else if (iServerState == EStateStartingUp )
-        {
-        __LOG( "ConnectionLost - Server starting up" );
-        iServerState = EStateShuttingDown;
-        }    
-
-    // If don't have any clients connect to server and current WLAN connection
-    // is lost, we want to shut down the server immidiately.
-    if ( iSessionCount <= 0 )
-        {
-        if ( iServerTimer->IsActive() )
-            {
-            iServerTimer->Cancel();
-            }
-        iServerTimer->Start( iShutdownTimeoutValue );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::RunError
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-TInt CUpnpAVControllerServer::RunError( TInt aError )
-    {
-    __LOG( "CUpnpAVControllerServer::RunError" );
-       
-    if ( aError == KErrBadDescriptor )
-        {
-        PanicClient( Message(), EAVControllerServerBadDescriptor );
-        }
-    else
-        {
-        Message().Complete( aError );
-        }
-        
-    // The leave will result in an early return from CServer::RunL(),
-    // skipping the call to request another message. So do that now in order
-    // to keep the server running.
-    ReStart();
-    // Handled the error fully
-    return KErrNone;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::PanicClient
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::PanicClient(const RMessage2& aMessage,
-    TAVControllerServerPanic aPanic)
-    {
-    __LOG( "CUpnpAVControllerServer::PanicClient" );
-       
-    aMessage.Panic( KAVControllerName, aPanic );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::PanicServer
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::PanicServer(TAVControllerServerPanic aPanic)
-    {
-    __LOG( "CUpnpAVControllerServer::PanicServer" );
-    
-    User::Panic( KAVControllerName, aPanic );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::ThreadFunctionL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::ThreadFunctionL()
-    {
-    __LOG( "CUpnpAVControllerServer::ThreadFunctionL" );
-    
-    // Construct active scheduler
-    CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler;
-    CleanupStack::PushL( activeScheduler );
-    // Install active scheduler
-    // We don't need to check whether an active scheduler is already
-    // installed
-    // as this is a new thread, so there won't be one
-    CActiveScheduler::Install( activeScheduler );    
-    // Construct our server        
-    CUpnpAVControllerServer* server = CUpnpAVControllerServer::NewLC();
-    
-    RProcess::Rendezvous( KErrNone );                
-    // Start handling requests
-    CActiveScheduler::Start();      
-             
-    CleanupStack::PopAndDestroy( server );  
-    CleanupStack::PopAndDestroy( activeScheduler );
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::HandleEmbeddedDiscoveredDevicesL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::HandleEmbeddedDiscoveredDevicesL(
-    CUpnpDevice& aDevice, TInt aDepth )
-    {
-    __LOG( "CUpnpAVControllerServer::HandleEmbeddedDiscoveredDevicesL" );
-    
-    if( aDepth <= KMaxDepth && iDiscoveredDeviceCount <= KMaxDeviceCount )
-        {
-        RPointerArray<CUpnpDevice>& devList = aDevice.DeviceList();
-        TInt count = devList.Count();
-        for( TInt i = 0; i < count; i++ )
-            {
-            iDeviceRepository->AddDeviceL( *devList[ i ] );
-            TInt sessionId = iAVControlPoint->CmProtocolInfoActionL(
-                devList[ i ]->Uuid() );
-            iDiscoveredDeviceCount++;    
-            
-            HandleEmbeddedDiscoveredDevicesL( *devList[ i ], ++aDepth );
-            }        
-        }
-    else
-        {
-        __LOG( "HandleEmbeddedDiscoveredDevicesL - max depth \
-or count reached" );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::HandleEmbeddedDisappearedDevicesL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::HandleEmbeddedDisappearedDevicesL(
-    CUpnpDevice& aDevice, TInt aDepth )
-    {
-    __LOG( "CUpnpAVControllerServer::HandleEmbeddedDisappearedDevicesL" );
-    
-    if( aDepth <= KMaxDepth && iDisappearedDeviceCount <= KMaxDeviceCount )
-        {
-        RPointerArray<CUpnpDevice>& devList = aDevice.DeviceList();
-        TInt count = devList.Count();
-        for( TInt i = 0; i < count; i++ )
-            {
-            CUpnpAVDeviceExtended& ext = iDeviceRepository->FindDeviceL(
-                devList[ i ]->Uuid() );
-            
-            CSession2* s;
-            iSessionIter.SetToFirst(); 
-            while ( ( s = iSessionIter++ ) != NULL )
-                {
-                CUpnpAVControllerSession* sess =
-                    static_cast<CUpnpAVControllerSession*>(s);
-                if( sess )
-                    {
-                    sess->DeviceDisappearedL( ext );    
-                    }
-                };        
-
-            iDeviceRepository->Remove( ext.Uuid() );
-            
-            iDisappearedDeviceCount++;    
-            
-            HandleEmbeddedDisappearedDevicesL( *devList[ i ], ++aDepth );
-            }        
-        }
-    else
-        {
-        __LOG( "HandleEmbeddedDisappearedDevicesL - max depth \
-or count reached" );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::StopMediaServer
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::StopMediaServer()
-    {
-    __LOG( "CUpnpAVControllerServer::StopMediaServer" );
-    
-    if( iShutdownTimeoutValue )
-        {
-        __LOG( "StopMediaServer - normal shutdown" );
-        iMediaServer.Stop( RUpnpMediaServerClient::EStopNormal );
-        }
-    else
-        {
-        __LOG( "StopMediaServer - silent shutdown" );
-        iMediaServer.Stop( RUpnpMediaServerClient::EStopSilent );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::ThreadFunction
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-TInt CUpnpAVControllerServer::ThreadFunction()
-    {
-    __LOG( "CUpnpAVControllerServer::ThreadFunction" );
-    
-    __UHEAP_MARK;
-    
-    User::RenameThread(KAVControllerThreadName);
-    
-    CTrapCleanup* cleanupStack = CTrapCleanup::New();
-    if ( !(cleanupStack) )
-        {
-        PanicServer( EAVControllerServerCreateTrapCleanup );
-        }
-
-    TRAPD( err, ThreadFunctionL() );
-    if ( err != KErrNone )
-        {
-        __LOG1( "ThreadFunction, creation failed: %d", err );
-        //PanicServer( EAVControllerServerSrvCreateServer );
-        }
-
-    delete cleanupStack;
-    cleanupStack = NULL;
-       
-    __UHEAP_MARKEND;
-
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::IncrementSessions
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::IncrementSessions() 
-    {
-    __LOG( "CUpnpAVControllerServer::IncrementSessions" );
-    
-    iSessionCount++;
-    if( iServerTimer->IsActive() )
-        {
-        iServerTimer->Cancel();
-        __LOG( "IncrementSessions - make a search" );
-        if( iAVControlPoint )
-            {
-            TRAP_IGNORE( iAVControlPoint->SearchL( KUPnPRootDevice ) );
-            }
-        }   
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::DecrementSessions
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::DecrementSessions()
-    {
-    __LOG( "CUpnpAVControllerServer::DecrementSessions" );
-    
-    iSessionCount--;
-    if ( iSessionCount <= 0 )
-        {
-        if( iServerTimer->IsActive() )
-            {
-            iServerTimer->Cancel();
-            }
-        iServerTimer->Start( iShutdownTimeoutValue );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::DeviceDiscoveredL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::DeviceDiscoveredL( CUpnpDevice& aDevice )
-    {
-    __LOG( "CUpnpAVControllerServer::DeviceDiscoveredL" );
-
-    if( aDevice.Local() && aDevice.DeviceType().Find( KMediaServer )
-        != KErrNotFound )
-        {
-        // It's the local S60 MS
-        
-        if( iStartingMS )
-            {
-            iMSTimer->Cancel();
-            }   
-        CUpnpSecAccessController* accessController = 
-            CUpnpSecAccessController::NewL();
-            __LOG( "CUpnpAVControllerServer::DeviceDiscoveredL \
-adding the local media server IP to the list of authorized addresses." );
-
-        accessController->AddAllowedAddress( aDevice.Address() );
-        delete accessController; 
-        accessController = NULL;
-        }
-        
-    iDeviceRepository->AddDeviceL( aDevice );
-    TInt sessionId = iAVControlPoint->CmProtocolInfoActionL(
-        aDevice.Uuid() );
-    iDiscoveredDeviceCount = 1; // First (root) device
-
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::DeviceDisappearedL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::DeviceDisappearedL( CUpnpDevice& aDevice )
-    {
-    __LOG( "CUpnpAVControllerServer::DeviceDisappearedL" );
-    
-    if( aDevice.Local() && aDevice.DeviceType().Find( KMediaServer )
-        != KErrNotFound )
-        {  
-        // It's the local S60 MS
-        iMediaServerOnline = EFalse;
-        }
-    
-    // Get a corresponding device from the device repository
-    CUpnpAVDeviceExtended& tmp = iDeviceRepository->FindDeviceL(
-        aDevice.Uuid() ); 
-    
-    // Let the clients know about the disappeared device
-    CSession2* s;
-    iSessionIter.SetToFirst(); 
-    while ( ( s = iSessionIter++ ) != NULL )
-        {
-        CUpnpAVControllerSession* sess =
-            static_cast<CUpnpAVControllerSession*>(s);
-        if( sess )
-            {
-            sess->DeviceDisappearedL( tmp );    
-            }
-        };        
-            // Remove from the device repository
-    iDeviceRepository->Remove( aDevice.Uuid() );
-    iDisappearedDeviceCount = 1;
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::DeviceDisappearedL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::DeviceDisappearedL( const TDesC8& aUuid )
-    {
-    __LOG( "CUpnpAVControllerServer::DeviceDisappearedL uid" );
-    // Get a corresponding device from the device repository
-    CUpnpAVDeviceExtended& tmp = iDeviceRepository->FindDeviceL(
-        aUuid ); 
-    
-    // Let the clients know about the disappeared device
-    CSession2* s;
-    iSessionIter.SetToFirst(); 
-    while ( ( s = iSessionIter++ ) != NULL )
-        {
-        CUpnpAVControllerSession* sess =
-            static_cast<CUpnpAVControllerSession*>( s );
-        if ( sess )
-            {
-            sess->DeviceDisappearedL( tmp );    
-            }
-        }       
-    // Remove from the device repository
-    iDeviceRepository->Remove( aUuid );
-    iDisappearedDeviceCount = 1;
-    __LOG( "CUpnpAVControllerServer::DeviceDisappearedL uid End" );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::StartMediaServerL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::StartMediaServerL( const RMessage2& aMessage )
-    {
-    __LOG( "CUpnpAVControllerServer::StartMediaServerL" );
-
-    if( iMediaServerOnline )
-        {
-        // Started already, complete the msg
-        iMSTimer->Cancel();
-        aMessage.Complete( EAVControllerStartMediaServerCompleted );
-        iServerUserCount++;
-        }
-    else
-        {
-        // Start the media server and timer
-        if( iStartMessages.Count() > 0 )
-            {
-            RMessage2* message = new (ELeave) RMessage2( aMessage );
-            iStartMessages.AppendL( message );
-            }
-        else
-            {
-            // Check if the stack's security is enabled
-            TBool upnpSecurityEnabled = EFalse;
-            TRAPD( secCheckError, upnpSecurityEnabled = 
-                CUpnpSecAccessController::IsMediaServerSecurityEnabledL() );
-
-            // If the security is not enabled, enable it now
-            if( secCheckError == KErrNone &&
-                !upnpSecurityEnabled )
-                {
-                TRAP_IGNORE( 
-                    CUpnpSecAccessController::EnableMediaServerSecurityL() );
-                }
-
-            RMessage2* message = new(ELeave) RMessage2( aMessage );
-            iStartMessages.AppendL( message );
-            User::LeaveIfError( iMediaServer.Start() );
-            iMSTimer->Start( iShutdownTimeoutValue );
-            iStartingMS = ETrue;
-            }    
-        }            
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::CancelStartMediaServerL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::CancelStartMediaServerL(
-    const RMessage2& aMessage )
-    {
-    __LOG( "CUpnpAVControllerServer::CancelStartMediaServerL" );
-
-    if( !iMSActivatedBeforeStart )
-        {
-        StopMediaServer();
-        }
-
-    TInt count = iStartMessages.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        iStartMessages[ i ]->Complete( KErrCancel );
-        }
-    iStartMessages.ResetAndDestroy();
-    iMSTimer->Cancel();
-    
-    aMessage.Complete( KErrNone );
-        
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::StopMediaServerL
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::StopMediaServerL( const RMessage2& aMessage )
-    {
-    __LOG( "CUpnpAVControllerServer::StopMediaServerL" );
-    
-    if( iMediaServerOnline )
-        {
-        iServerUserCount--;
-        if( iServerUserCount <= 0 )
-            {
-            if( !iMSActivatedBeforeStart )
-                {
-                iMSTimer->Start( iShutdownTimeoutValue );
-                }
-            iServerUserCount = 0;
-            }
-        }
-    aMessage.Complete( KErrNone );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::MSServicesInUse
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::MSServicesInUse( const RMessage2& aMessage )
-    {
-    if( iServerUserCount > 0 || iStartingMS
-         || iMSTimer->IsActive()
-        )        
-        {
-        TPckg<TBool> resp0( ETrue );
-        aMessage.Write( 0, resp0 );        
-        }
-    else
-        {
-        TPckg<TBool> resp0( EFalse );
-        aMessage.Write( 0, resp0 );                
-        }    
-    aMessage.Complete( KErrNone );    
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::CmProtocolInfoResponse
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-void CUpnpAVControllerServer::CmProtocolInfoResponse( const TDesC8& aUuid,
-    TInt /*aSessionId*/, TInt aErr, const TDesC8& aSource,
-    const TDesC8& aSink )
-    {
-    __LOG1( "CUpnpAVControllerServer::CmProtocolInfoResponse, \
-aErr = %d", aErr );
-
-    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-        EUPnPConnectionManagerError );    
-
-    if( aErr == KErrNone )
-        {
-        CUpnpAVDeviceExtended* dev = NULL;
-        TRAPD( err, dev = &iDeviceRepository->AddProtocolInfoL(
-            aUuid, aSource, aSink ) );
-        
-        if( err == KErrNone )    
-            {
-            // Device discovered and protocolinfo was retrieved successfully
-            CSession2* s;
-            iSessionIter.SetToFirst(); 
-            while ( ( s = iSessionIter++ ) != NULL )
-                {
-                CUpnpAVControllerSession* sess =
-                    static_cast<CUpnpAVControllerSession*>(s);
-                if( sess )
-                    {
-                    TRAP_IGNORE( sess->DeviceDiscoveredL( *dev ) );    
-                    }
-                };        
-            
-            if( dev->Local() )
-                {
-                iMediaServerOnline = ETrue;
-                
-                if( iStartingMS )
-                    {
-                    TInt count = iStartMessages.Count();
-                    for( TInt i = 0; i < count; i++ )
-                        {
-                        iStartMessages[ i ]->Complete(
-                            EAVControllerStartMediaServerCompleted );
-                        iServerUserCount++;    
-                        }
-                    iStartMessages.ResetAndDestroy();        
-                    
-                    iStartingMS = EFalse;                
-                    }
-                else
-                    {
-                    __LOG( "Sharing was enabled before AVC server start" );
-                    iMSActivatedBeforeStart = ETrue;
-                    }    
-                
-                }    
-            }
-        else
-            {
-            // Could not add protocolinfo, it's invalid or corrupted
-            // Device cannot be used
-            HandleFailedProtocolInfoResponse( aUuid );          
-            }
-        }
-    else
-        {
-        // A problem occured fetching protocolinfo
-        // Device cannot be used
-        HandleFailedProtocolInfoResponse( aUuid );
-        }        
-    }
-
-void CUpnpAVControllerServer::HandleFailedProtocolInfoResponse(
-    const TDesC8& aUuid )
-    {
-    __LOG( "CUpnpAVControllerServer::HandleFailedProtocolInfoResponse" );
-    
-    CUpnpAVDeviceExtended* dev = NULL;
-    TRAPD( err, dev = &iDeviceRepository->FindDeviceL( aUuid ) )
-    if( err == KErrNone )
-        {
-        if( iStartingMS && dev->Local() )
-            {
-            __LOG( "HandleFailedProtocolInfoResponse - local, stop and \
-complete messages" );
-            
-            StopMediaServer();
-            
-            TInt count = iStartMessages.Count();
-            for( TInt i = 0; i < count; i++ )
-                {
-                iStartMessages[ i ]->Complete( err );
-                iServerUserCount++;    
-                }
-            iStartMessages.ResetAndDestroy();        
-            
-            iStartingMS = EFalse;
-            }                           
-        }
-    else
-        {
-        // Not found, no can do
-        __LOG( "HandleFailedProtocolInfoResponse - not found" );
-        }    
-    iDeviceRepository->Remove( aUuid );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::ControlPoint
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-CUpnpAVControlPoint& CUpnpAVControllerServer::ControlPoint()
-    {
-    return *iAVControlPoint;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::MediaServer
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-RUpnpMediaServerClient& CUpnpAVControllerServer::MediaServer()
-    {
-    return iMediaServer;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::Dispatcher
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-CUPnPAVDispatcher& CUpnpAVControllerServer::Dispatcher()
-    {
-    return *iDispatcher;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerServer::DeviceRepository
-// See upnpavcontrollerserver.h
-// --------------------------------------------------------------------------
-CUPnPDeviceRepository& CUpnpAVControllerServer::DeviceRepository()
-    {
-    return *iDeviceRepository;
-    }
-
-TInt CUpnpAVControllerServer::IAP()
-    {
-    return iIAP;
-    }
-    
-// ============================= LOCAL FUNCTIONS ============================
-
-// --------------------------------------------------------------------------
-// E32Main entry point.
-// Returns: KErrNone
-// --------------------------------------------------------------------------
-TInt E32Main()
-    {
-    return CUpnpAVControllerServer::ThreadFunction();
-    }
-
-// End of File
-
+/*
+* Copyright (c) 2006-2009 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:      AVController server
+*
+*/
+
+
+
+
+
+
+
+// INCLUDE FILES
+// System
+#include <e32svr.h>
+#include <f32file.h> 
+
+// upnp stack
+#include <upnpdevice.h>
+#include <upnpsettings.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavcontrollerglobals.h"
+
+// dlnasrv / internal api's
+#include "upnpconnectionmonitor.h"
+
+// dlnasrv / avcontroller server internal
+#include "upnpavcontrollerserver.h"
+#include "upnpavcontrollersession.h"
+#include "upnpavcontrolpoint.h"
+#include "upnpavdispatcher.h"
+#include "upnpdevicerepository.h"
+#include "upnpavdeviceextended.h"
+#include "upnpaverrorhandler.h"
+#include "upnpavcpstrings.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerserver.txt" );
+#include "upnplog.h"
+
+using namespace UpnpAVCPStrings;
+
+// CONSTANTS
+_LIT8( KUPnPRootDevice,                 "upnp:rootdevice" );
+
+const TUint KMyRangeCount = 3;
+
+const TInt KMyRanges[ KMyRangeCount ] = 
+    {
+    0, // numbers 0-18
+    18, // numbers 18-EAVControllerRqstLast
+    EAVControllerRqstLast // numbers EAVControllerRqstLast-KMaxInt
+    };
+
+const TUint8 KMyElementsIndex[ KMyRangeCount ] = 
+    {
+    0, 
+    1, 
+    CPolicyServer::ENotSupported
+    };
+    
+const CPolicyServer::TPolicyElement KMyElements[] = 
+    {
+    {_INIT_SECURITY_POLICY_C3(ECapabilityNetworkServices,
+        ECapabilityReadUserData, ECapabilityWriteUserData ),
+        CPolicyServer::EFailClient },
+    {_INIT_SECURITY_POLICY_C1(ECapabilityNetworkServices),
+        CPolicyServer::EFailClient}
+    };
+    
+const CPolicyServer::TPolicy KMyPolicy =
+    {
+    CPolicyServer::EAlwaysPass, //specifies all connect attempts should pass
+    KMyRangeCount,                   
+    KMyRanges,
+    KMyElementsIndex,
+    KMyElements,
+    };
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::CUpnpAVControllerServer
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+CUpnpAVControllerServer::CUpnpAVControllerServer( TInt aPriority ):
+    CPolicyServer( aPriority, KMyPolicy ),
+    iShutdownTimeoutValue( KTimerCycle10 ),
+    iState( EStateUndefined )
+    {    
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::ConstructL
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::ConstructL()
+    {
+    __LOG( "CUpnpAVControllerServer::ConstructL" );
+
+    ChangeState( EStateStartingServer );
+
+    __LOG( "ConstructL - Starting server" );
+
+    // create av dispatcher
+    iDispatcher = CUPnPAVDispatcher::NewL( *this );
+
+    // create av control point
+    iAVControlPoint = CUpnpAVControlPoint::NewL( *iDispatcher );    
+    
+    // create device repository
+    iDeviceRepository = CUPnPDeviceRepository::NewL( *iAVControlPoint );
+    
+    iUpnpSettings = CUpnpSettings::NewL( KCRUidUPnPStack );
+    iUpnpSettings->Get( CUpnpSettings::KUPnPStackIapId, iIAP );
+    
+    iMonitor = CUPnPConnectionMonitor::NewL( iIAP );
+    iMonitor->SetObserver( *this );
+    
+    StartL( KAVControllerName );   
+    
+    iServerTimer = CUPnPAVTimer::NewL( *this,
+        CUPnPAVTimer::ETimerServerShutdown );
+    
+    iServerTimer->Start( iShutdownTimeoutValue );
+
+    iIconDownloader = CUpnpDeviceIconDownloader::NewL( *this, iIAP );
+
+    __LOG( "CUpnpAVControllerServer::ConstructL - Finished" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::StartUpL
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::StartUpL()
+    {
+    __LOG( "CUpnpAVControllerServer::StartUpL" );
+
+    if( iState == EStateStartingServer )
+        {
+        ChangeState( EStateStartingControlPoint );
+
+        __LOG( "StartUpL - Starting control point" );
+        
+        // start SSPD search
+        TInt err = KErrNone;
+        TRAP( err, iAVControlPoint->StartUpL() );
+        if( err == KErrNone )
+            {
+            __LOG( "StartUpL - Searching root device" );
+            
+            iAVControlPoint->SearchL( KUPnPRootDevice );
+            ChangeState( EStateRunning );
+            }
+        else
+            {
+            iShutdownTimeoutValue = 0;
+            User::Leave( err );
+            }
+        }        
+    else if( iState == EStateShuttingDown )
+        {
+        __LOG( "StartUpL - Wlan disconnected or shutting down, leave" );
+        User::Leave( KErrDisconnected );
+        }
+    else if( iState == EStateStartingControlPoint )
+        {
+        __LOG( "StartUpL - Already starting control point" );
+        }
+    else
+        {
+        __LOG( "StartUpL - Server already running" );
+        }
+
+    __LOG( "StartUpL - Completed" );    
+    }
+
+void CUpnpAVControllerServer::CancelStartUp()
+    {
+    __LOG( "CUpnpAVControllerServer::CancelStartUp" );
+    
+    // Cancel can occur only when the av controller instance is deleted
+    // right after the asyncronous part of the construction has been
+    // started. There is no proper way to cancel, but we can set the
+    // shutdown timer to 0, so the server will shutdown immidiately.
+    
+    if( iSessionCount <= 1 )
+        {
+        iShutdownTimeoutValue = 0;    
+        }  
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::NewLC
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+CUpnpAVControllerServer* CUpnpAVControllerServer::NewLC()
+    {
+    CUpnpAVControllerServer* self = new( ELeave )
+        CUpnpAVControllerServer( EPriorityNormal );   
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::~CUpnpAVControllerServer
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+CUpnpAVControllerServer::~CUpnpAVControllerServer()
+    {
+    __LOG( "CUpnpAVControllerServer::~CUpnpAVControllerServer" );
+    
+    delete iAVControlPoint;
+    delete iDispatcher;
+    delete iDeviceRepository;
+   
+    delete iMonitor;
+    delete iServerTimer;
+    
+    delete iUpnpSettings;
+    delete iIconDownloader;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::NewSessionL
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+CSession2* CUpnpAVControllerServer::NewSessionL( const TVersion& aVersion,
+    const RMessage2& /*aMessage*/ ) const
+    {
+    __LOG( "CUpnpAVControllerServer::NewSessionL" );
+    
+    TInt err = KErrNone;
+    
+    // check if the server is shutting down
+    if( iState == EStateShuttingDown )
+        {
+        __LOG( "NewSessionL - server shutting down, no new sessions are allowed at this point" );
+        err = KErrDisconnected;
+        }
+        
+    // Check we're the right version
+    else if ( !User::QueryVersionSupported( TVersion( 
+            KAVControllerMajorVersionNumber,
+            KAVControllerMinorVersionNumber,
+            KAVControllerBuildVersionNumber ),
+            aVersion ) )
+        {
+        __LOG( "NewSessionL - incorrect client version" );
+        err = KErrNotSupported;
+        }
+    
+    // leave if error
+    User::LeaveIfError( err );
+
+    // Make new session
+    return CUpnpAVControllerSession::NewL(
+        const_cast<CUpnpAVControllerServer&>( *this ) );
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::ActionResponseL
+// From MUpnpAVControlPointObserver
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::ActionResponseL( CUpnpAction* aAction )
+    {
+    if (aAction->Name().Compare( KGetProtocolInfo ) == 0)
+        {
+        const TDesC8& uuid = aAction->Service().Device().Uuid();
+        CmProtocolInfoResponse(
+            uuid,
+            aAction->Error(),
+            aAction->ArgumentValue( KSource ), 
+            aAction->ArgumentValue( KSink )
+            );
+        iDispatcher->UnRegister(aAction->SessionId());
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::StateUpdatedL
+// From MUpnpAVControlPointObserver
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::StateUpdatedL( CUpnpService* /*aService*/ )
+    {
+    // No implementation required        
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::HttpResponseL
+// From MUpnpAVControlPointObserver
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::HttpResponseL( CUpnpHttpMessage* /*aMessage*/ )
+    {
+    // No implementation required        
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::DeviceDiscoveredL
+// From MUpnpAVControlPointObserver
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::DeviceDiscoveredL( CUpnpDevice* /*aDevice*/ )
+    {
+    // No implementation required        
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::DeviceDisappearedL
+// From MUpnpAVControlPointObserver
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::DeviceDisappearedL(CUpnpDevice* /*aDevice*/)
+    {
+    // No implementation required        
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::UPnPAVTimerCallback
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::UPnPAVTimerCallback(
+    CUPnPAVTimer::TAVTimerType aType ) 
+    {
+    __LOG( "CUpnpAVControllerServer::UPnPAVTimerCallback" );
+
+
+    if( aType == CUPnPAVTimer::ETimerServerShutdown )
+        {
+        ChangeState( EStateShutDown );
+        CActiveScheduler::Stop();
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::ConnectionLost
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::ConnectionLost( TBool /*aUserOriented*/ )
+    {
+    __LOG( "CUpnpAVControllerServer::ConnectionLost" );
+    
+    iShutdownTimeoutValue = 0; // Set shutdown timer value to 0, we want to
+    // shut down the server immidiately after the last session has been
+    // closed
+    
+    if( iState == EStateRunning && iDeviceRepository )
+        {
+        __LOG( "ConnectionLost - Server running" );
+        
+        iDeviceRepository->ConnectionLost();    
+
+        CSession2* s;
+        iSessionIter.SetToFirst(); 
+        while ( ( s = iSessionIter++ ) != NULL )
+            {
+            CUpnpAVControllerSession* sess =
+                static_cast<CUpnpAVControllerSession*>(s);
+            if( sess )
+                {
+                sess->ConnectionLost();    
+                }
+            };  
+        ChangeState( EStateShuttingDown );
+        }
+    else if( iState == EStateStartingServer )
+        {
+        __LOG( "ConnectionLost - Server starting" );
+        
+        ChangeState( EStateShuttingDown );
+        }    
+
+    // If don't have any clients connect to server and current WLAN connection
+    // is lost, we want to shut down the server immidiately.
+    if ( iSessionCount <= 0 )
+        {
+        if ( iServerTimer->IsActive() )
+            {
+            iServerTimer->Cancel();
+            }
+        iServerTimer->Start( iShutdownTimeoutValue );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::RunError
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+TInt CUpnpAVControllerServer::RunError( TInt aError )
+    {
+    __LOG2( "CUpnpAVControllerServer::RunError msg: %d err: %d",
+        Message().Function(), aError );
+
+    if ( aError == KErrBadDescriptor )
+        {
+        PanicClient( Message(), EAVControllerServerBadDescriptor );
+        }
+    else if ( !Message().IsNull() )
+        {
+        Message().Complete( aError );
+        }
+        
+    // The leave will result in an early return from CServer::RunL(),
+    // skipping the call to request another message. So do that now in order
+    // to keep the server running.
+    ReStart();
+    // Handled the error fully
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::PanicClient
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::PanicClient(const RMessage2& aMessage,
+    TAVControllerServerPanic aPanic)
+    {
+    __LOG1( "CUpnpAVControllerServer::PanicClient %d", aPanic );
+       
+    aMessage.Panic( KAVControllerName, aPanic );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::PanicServer
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::PanicServer(TAVControllerServerPanic aPanic)
+    {
+    __LOG1( "CUpnpAVControllerServer::PanicServer %d", aPanic );
+    
+    User::Panic( KAVControllerName, aPanic );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::ThreadFunctionL
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::ThreadFunctionL()
+    {
+    __LOG( "CUpnpAVControllerServer::ThreadFunctionL" );
+    
+    // Construct active scheduler
+    CActiveScheduler* activeScheduler = new (ELeave) CActiveScheduler;
+    CleanupStack::PushL( activeScheduler );
+    // Install active scheduler
+    // We don't need to check whether an active scheduler is already
+    // installed
+    // as this is a new thread, so there won't be one
+    CActiveScheduler::Install( activeScheduler );    
+    // Construct our server        
+    CUpnpAVControllerServer* server = CUpnpAVControllerServer::NewLC();
+    
+    RProcess::Rendezvous( KErrNone );                
+    // Start handling requests
+    CActiveScheduler::Start();      
+             
+    CleanupStack::PopAndDestroy( server );  
+    CleanupStack::PopAndDestroy( activeScheduler );
+
+    __LOG( "CUpnpAVControllerServer::ThreadFunctionL end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::ThreadFunction
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+TInt CUpnpAVControllerServer::ThreadFunction()
+    {
+    __LOG( "CUpnpAVControllerServer::ThreadFunction" );
+    
+    __UHEAP_MARK;
+    
+    User::RenameThread(KAVControllerThreadName);
+    
+    CTrapCleanup* cleanupStack = CTrapCleanup::New();
+    if ( !(cleanupStack) )
+        {
+        PanicServer( EAVControllerServerCreateTrapCleanup );
+        }
+
+    TRAPD( err, ThreadFunctionL() );
+    if ( err != KErrNone )
+        {
+        __LOG1( "ThreadFunction, creation failed: %d", err );
+        //PanicServer( EAVControllerServerSrvCreateServer );
+        }
+
+    delete cleanupStack;
+    cleanupStack = NULL;
+       
+    __UHEAP_MARKEND;
+
+    __LOG1( "CUpnpAVControllerServer::ThreadFunction end %d", err );
+
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::IncrementSessions
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::IncrementSessions() 
+    {
+    __LOG2( "CUpnpAVControllerServer::IncrementSessions, %d, %d", 
+            iSessionCount, iState );
+    
+    iSessionCount++;
+    if( iServerTimer->IsActive() )
+        {
+        iServerTimer->Cancel();
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::DecrementSessions
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::DecrementSessions()
+    {
+    __LOG2( "CUpnpAVControllerServer::DecrementSessions, %d, %d", 
+            iSessionCount, iState );
+    
+    iSessionCount--;
+    if( iState != EStateShutDown )
+        {
+        if ( iSessionCount <= 0 )
+            {
+            if( iServerTimer->IsActive() )
+                {
+                iServerTimer->Cancel();
+                }
+            iServerTimer->Start( iShutdownTimeoutValue );
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::DeviceDiscoveredL
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::DeviceDiscoveredL( CUpnpDevice& aDevice )
+    {
+    __LOG( "CUpnpAVControllerServer::DeviceDiscoveredL" );
+
+    iDeviceRepository->AddDeviceL( aDevice );
+
+    CUpnpAction* action = iAVControlPoint->CreateActionLC( 
+            &aDevice, KConnectionManager, KGetProtocolInfo );
+
+    iAVControlPoint->SendL( action ); // takes ownership
+    CleanupStack::Pop( action );
+    iDispatcher->RegisterL( action->SessionId(), *this );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::DeviceDisappearedL
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::DeviceDisappearedL( CUpnpDevice& aDevice )
+    {
+    __LOG( "CUpnpAVControllerServer::DeviceDisappearedL" );
+    
+    // Get a corresponding device from the device repository
+    CUpnpAVDeviceExtended& tmp = iDeviceRepository->FindDeviceL(
+        aDevice.Uuid() ); 
+    
+    // Let the clients know about the disappeared device
+    CSession2* s;
+    iSessionIter.SetToFirst(); 
+    while ( ( s = iSessionIter++ ) != NULL )
+        {
+        CUpnpAVControllerSession* sess =
+            static_cast<CUpnpAVControllerSession*>(s);
+        if( sess )
+            {
+            sess->DeviceDisappearedL( tmp );    
+            }
+        };
+    // Remove from the device repository
+    TPtrC8 uuid( aDevice.Uuid() );
+    iDeviceRepository->Remove( uuid );
+    // Ensure that icon download is canceled
+    iIconDownloader->CancelDownload( uuid );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::DeviceDisappearedL
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::DeviceDisappearedL( const TDesC8& aUuid )
+    {
+    __LOG( "CUpnpAVControllerServer::DeviceDisappearedL uid" );
+    // Get a corresponding device from the device repository
+    CUpnpAVDeviceExtended& tmp = iDeviceRepository->FindDeviceL(
+        aUuid ); 
+    
+    // Let the clients know about the disappeared device
+    CSession2* s;
+    iSessionIter.SetToFirst(); 
+    while ( ( s = iSessionIter++ ) != NULL )
+        {
+        CUpnpAVControllerSession* sess =
+            static_cast<CUpnpAVControllerSession*>( s );
+        if ( sess )
+            {
+            sess->DeviceDisappearedL( tmp );    
+            }
+        }       
+    // Remove from the device repository
+    iDeviceRepository->Remove( aUuid );
+    // Ensure that icon download is canceled
+    iIconDownloader->CancelDownload( aUuid );
+
+    __LOG( "CUpnpAVControllerServer::DeviceDisappearedL uid End" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::CmProtocolInfoResponse
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::CmProtocolInfoResponse( const TDesC8& aUuid,
+    TInt aErr, const TDesC8& aSource,
+    const TDesC8& aSink )
+    {
+    __LOG1( "CUpnpAVControllerServer::CmProtocolInfoResponse, \
+aErr = %d", aErr );
+
+    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+        EUPnPConnectionManagerError );    
+
+    if( aErr == KErrNone )
+        {
+        CUpnpAVDeviceExtended* dev = NULL;
+        TRAPD( err, dev = &iDeviceRepository->AddProtocolInfoL(
+            aUuid, aSource, aSink ) );
+        
+        if( err == KErrNone )    
+            {
+            // Device discovered and protocolinfo was retrieved successfully
+            // Start icon download if icon url is defined
+            TPtrC8 iconUrl( dev->IconUrl() );
+            if ( iconUrl.Length() > 0 )
+                {
+                TRAP_IGNORE( iIconDownloader->StartDownloadL( dev->Uuid(), iconUrl ) );
+                }
+            CSession2* s;
+            iSessionIter.SetToFirst(); 
+            while ( ( s = iSessionIter++ ) != NULL )
+                {
+                CUpnpAVControllerSession* sess =
+                    static_cast<CUpnpAVControllerSession*>(s);
+                if( sess )
+                    {
+                    TRAP_IGNORE( sess->DeviceDiscoveredL( *dev ) );    
+                    }
+                };
+            }
+        else
+            {
+            // Could not add protocolinfo, it's invalid or corrupted
+            // Device cannot be used
+            HandleFailedProtocolInfoResponse( aUuid );          
+            }
+        }
+    else
+        {
+        // A problem occured fetching protocolinfo
+        // Device cannot be used
+        HandleFailedProtocolInfoResponse( aUuid );
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::TransferDeviceIconFileToClientL
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::TransferDeviceIconFileToClientL(
+        const RMessage2& aMessage, TInt aSlot, const TDesC8& aDeviceUuid )
+    {
+    return iIconDownloader->TransferFileToClientL( aMessage, aSlot, aDeviceUuid );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::HandleFailedProtocolInfoResponse
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::HandleFailedProtocolInfoResponse(
+    const TDesC8& aUuid )
+    {
+    __LOG( "CUpnpAVControllerServer::HandleFailedProtocolInfoResponse" );
+    
+    iDeviceRepository->Remove( aUuid );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::ChangeState
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::ChangeState( TAVControllerServerState aState )
+    {
+    __LOG( "CUpnpAVControllerServer::ChangeState" );
+    
+    if( iState != aState )
+        {
+        __LOG2( "ChangeState: Changing state [%d] -> [%d]",
+            iState, aState );
+        iState = aState;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::ControlPoint
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+CUpnpAVControlPoint& CUpnpAVControllerServer::ControlPoint()
+    {
+    return *iAVControlPoint;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::Dispatcher
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+CUPnPAVDispatcher& CUpnpAVControllerServer::Dispatcher()
+    {
+    return *iDispatcher;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::DeviceRepository
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+CUPnPDeviceRepository& CUpnpAVControllerServer::DeviceRepository()
+    {
+    return *iDeviceRepository;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::IAP
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+TInt CUpnpAVControllerServer::IAP()
+    {
+    return iIAP;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerServer::DeviceIconDownloadedL
+// See upnpavcontrollerserver.h
+// --------------------------------------------------------------------------
+void CUpnpAVControllerServer::DeviceIconDownloadedL( const TDesC8& aDeviceUuid,
+        TInt aError )
+    {
+    __LOG( "CUpnpAVControllerServer::DeviceIconDownloadedL" );
+    if ( aError == KErrNone )
+        {
+        // Get a corresponding device from the device repository
+        CUpnpAVDeviceExtended& tmp = iDeviceRepository->FindDeviceL(
+            aDeviceUuid );
+        // Let the clients know about downloaded icon
+        CSession2* s;
+        iSessionIter.SetToFirst(); 
+        while ( ( s = iSessionIter++ ) != NULL )
+            {
+            CUpnpAVControllerSession* sess =
+                static_cast<CUpnpAVControllerSession*>( s );
+            if ( sess )
+                {
+                sess->DeviceIconDownloadedL( tmp );
+                }
+            }
+        }
+    __LOG( "CUpnpAVControllerServer::DeviceIconDownloadedL End" );
+    }
+
+// ============================= LOCAL FUNCTIONS ============================
+
+// --------------------------------------------------------------------------
+// E32Main entry point.
+// Returns: KErrNone
+// --------------------------------------------------------------------------
+TInt E32Main()
+    {
+    return CUpnpAVControllerServer::ThreadFunction();
+    }
+
+// End of File
+
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpavcontrollersession.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpavcontrollersession.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,445 +1,705 @@
-/*
-* Copyright (c) 2002-2004 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:      implementation of a server session
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-#include "upnpavcontrollersession.h"
-#include "upnpavcontrollerserver.pan"
-
-#include "upnpavcontrollerserver.h"
-#include "upnpavcontrollerimpl.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
-#include "upnplog.h"
-
-// ================= MEMBER FUNCTIONS =======================
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerSession::CUpnpAVControllerSession
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// --------------------------------------------------------------------------
-//
-CUpnpAVControllerSession::CUpnpAVControllerSession(
-    CUpnpAVControllerServer& aServer):
-    CSession2(),
-    iAVControllerServer( aServer )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerSession::ConstructL
-// Symbian 2nd phase constructor can leave.
-// --------------------------------------------------------------------------
-//
-void CUpnpAVControllerSession::ConstructL()
-    {
-    __LOG( "CUpnpAVControllerSession::ConstructL" );
-    
-    iAVControllerServer.IncrementSessions();
-    
-    iAVController = CUPnPAVControllerImpl::NewL
-        (
-        iAVControllerServer.MediaServer(),
-        iAVControllerServer
-        );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerSession::~CUpnpAVControllerSession
-// Destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpAVControllerSession::~CUpnpAVControllerSession()
-    {
-    iAVControllerServer.DecrementSessions();        
-    
-    delete iAVController;
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerSession::ServiceL
-// Handle client requests.
-// --------------------------------------------------------------------------
-//
-void CUpnpAVControllerSession::ServiceL( const RMessage2& aMessage )
-    {   
-         
-    switch ( aMessage.Function() )
-        {
-        case EAVControllerStartupRequest:
-            iAVControllerServer.StartUpL();
-            aMessage.Complete( KErrNone );
-            break;
-        
-        case EAVControllerCancelStartupRequest:
-            iAVControllerServer.CancelStartUp();
-            aMessage.Complete( KErrNone );
-            break;        
-        
-        case EAVControllerDeviceRequest:           
-            iAVController->EnableDeviceDiscoveryL( aMessage );
-            break;
-            
-        case EAVControllerGetDeviceRequest:
-            iAVController->GetDeviceL( aMessage );
-            break;                      
-
-        case EAVControllerCancelDeviceRequest:
-            iAVController->DisableDeviceDiscoveryL();
-            aMessage.Complete( KErrNone );
-            break;                      
-        
-        case EAVControllerGetDeviceListSizeRequest:
-            iAVController->GetDeviceListSizeL( aMessage );
-            break;
-
-        case EAVControllerGetDeviceListRequest:
-            iAVController->GetDeviceListL( aMessage );
-            break;
-
-        case EAVControllerCreateRenderingSession:
-            iAVController->CreateRenderingSessionL( aMessage );
-            break;
-
-        case EAVControllerDestroyRenderingSession:
-            iAVController->DestroyRenderingSessionL( aMessage );
-            break;
-            
-        case EAVControllerEventRequest:
-            iAVController->EventRequestL( aMessage );
-            break;
-            
-        case EAVControllerCancelEventRequest:
-            iAVController->CancelEventRequestL( aMessage );
-            break;
-
-        case EAVControllerSetURI:
-            iAVController->SetURIL( aMessage );
-            break;
-            
-        case EAVControllerCancelSetURI:
-            iAVController->CancelSetURIL( aMessage );
-            break;
-    
-        case EAVControllerSetNextURI:
-            iAVController->SetNextURIL( aMessage );
-            break;
-            
-        case EAVControllerCancelSetNextURI:
-            iAVController->CancelSetNextURIL( aMessage );
-            break;
-
-        case EAVControllerPlay:
-            iAVController->PlayL( aMessage );
-            break;
-    
-        case EAVControllerCancelPlay:
-            iAVController->CancelPlayL( aMessage );
-            break;
-            
-        case EAVControllerStop:
-            iAVController->StopL( aMessage );
-            break;
-    
-        case EAVControllerCancelStop:
-            iAVController->CancelStopL( aMessage );
-            break;
-            
-        case EAVControllerPause:
-            iAVController->PauseL( aMessage );
-            break;
-            
-        case EAVControllerCancelPause:
-            iAVController->CancelPauseL( aMessage );
-            break;
-    
-        case EAVControllerSetVolume:
-            iAVController->SetVolumeL( aMessage );
-            break;
-
-        case EAVControllerCancelSetVolume:
-            iAVController->CancelSetVolumeL( aMessage );
-            break;
-    
-        case EAVControllerGetVolume:
-            iAVController->GetVolumeL( aMessage );
-            break;
-    
-        case EAVControllerCancelGetVolume:
-            iAVController->CancelGetVolumeL( aMessage );
-            break;
-    
-        case EAVControllerSetMute:
-            iAVController->SetMuteL( aMessage );
-            break;
-
-        case EAVControllerCancelSetMute:
-            iAVController->CancelSetMuteL( aMessage );
-            break;
-    
-        case EAVControllerGetMute:
-            iAVController->GetMuteL( aMessage );
-            break;
-            
-        case EAVControllerCancelGetMute:
-            iAVController->CancelGetMuteL( aMessage );
-            break;
-            
-        case EAVControllerGetPositionInfo:
-            iAVController->GetPositionInfoL( aMessage );
-            break;
-            
-        case EAVControllerCancelGetPositionInfo:
-            iAVController->CancelGetPositionInfoL( aMessage );
-            break;
-            
-        case EAVControllerCreateBrowsingSession:
-            iAVController->CreateBrowsingSessionL( aMessage );
-            break;
-            
-        case EAVControllerDestroyBrowsingSession:
-            iAVController->DestroyBrowsingSessionL( aMessage );
-            break;
-
-        case EAVControllerGetBrowseResponseSize:
-            iAVController->GetBrowseResponseSizeL( aMessage );
-            break;
-        
-        case EAVControllerCancelGetBrowseResponseSize:
-            iAVController->CancelGetBrowseResponseSizeL( aMessage );
-            break;
-        
-        case EAVControllerGetBrowseResponse:
-            iAVController->GetBrowseResponseL( aMessage );
-            break;
-                    
-        case EAVControllerGetSearchResponseSize:
-            iAVController->GetSearchResponseSizeL( aMessage );
-            break;
-            
-        case EAVControllerCancelGetSearchResponseSize:
-            iAVController->CancelGetSearchResponseSizeL( aMessage );
-            break;
-        
-        case EAVControllerGetSearchResponse:
-            iAVController->GetSearchResponseL( aMessage );
-            break;
-                    
-        case EAVControllerGetSearchCapabilitiesSize:
-            iAVController->GetSearchCapabitiesSizeL( aMessage );
-            break;    
-                            
-        case EAVControllerCancelGetSearchCapabilitiesSize:
-            iAVController->CancelGetSearchCapabitiesSizeL( aMessage );
-            break;
-            
-        case EAVControllerGetSearchCapabilities:
-            iAVController->GetSearchCapabitiesL( aMessage );
-            break;
-
-        case EAVControllerCreateContainer:
-            iAVController->CreateContainerL( aMessage );
-            break;
-        
-        case EAVControllerCancelCreateContainer:
-            iAVController->CancelCreateContainerL( aMessage );
-            break;  
-
-        case EAVControllerDeleteObject:
-            iAVController->DeleteObjectL( aMessage );
-            break;
-            
-        case EAVControllerCancelDeleteObject:
-            iAVController->CancelDeleteObjectL( aMessage );
-            break;
-            
-        case EAVControllerDeviceDisappearedRequest:
-            iAVController->DeviceDisappearedRequestL( aMessage );
-            break;
-            
-        case EAVControllerCancelDeviceDisappearedRequest:
-            iAVController->CancelDeviceDisappearedRequestL( aMessage );
-            break;              
-
-        case EAVControllerStartMediaServer:
-            iAVControllerServer.StartMediaServerL( aMessage );
-            break;
-            
-        case EAVControllerCancelStartMediaServer:
-            iAVControllerServer.CancelStartMediaServerL( aMessage );
-            break;
-
-        case EAVControllerStopMediaServer:
-            iAVControllerServer.StopMediaServerL( aMessage );
-            break;
-            
-        case EAVControllerMonitorConnection:
-            iAVController->MonitorConnectionL( aMessage );
-            break;
-
-        case EAVControllerCancelMonitorConnection:
-            iAVController->CancelMonitorConnectionL( aMessage );
-            break;
-        
-        case EAVControllerMSServicesInUse:
-            iAVControllerServer.MSServicesInUse( aMessage );
-            break;
-            
-        case EAVControllerCreateDownloadSession:
-            iAVController->CreateDownloadSessionL( aMessage );
-            break;
-            
-        case EAVControllerCreateUploadSession:
-            iAVController->CreateUploadSessionL( aMessage );       
-            break;
-        
-        case EAVControllerDestroyDownloadSession:
-            iAVController->DestroyDownloadSessionL( aMessage );
-            break;
-        
-        case EAVControllerDestroyUploadSession:
-            iAVController->DestroyUploadSessionL( aMessage );
-            break;
-        
-        case EAVControllerStartDownload:
-            iAVController->StartDownloadL( aMessage );
-            break;
-        
-        case EAVControllerCancelDownload:
-            iAVController->CancelDownloadL( aMessage );
-            break;
-        
-        case EAVControllerCancelAllDownloads:
-            iAVController->CancelAllDownloadsL( aMessage );
-            break;
-        
-        case EAVControllerStartUpload:
-            iAVController->StartUploadL( aMessage );
-            break;
-        
-        case EAVControllerCancelUpload:
-            iAVController->CancelUploadL( aMessage );
-            break;
-        
-        case EAVControllerCancelAllUploads:
-            iAVController->CancelAllUploadsL( aMessage );
-            break;
-        
-        case EAVControllerStartTrackingUploadProgress:
-            iAVController->StartTrackingUploadProgressL( aMessage );
-            break;
-        
-        case EAVControllerStartTrackingDownloadProgress:
-            iAVController->StartTrackingDownloadProgressL( aMessage );
-            break;
-        
-        case EAVControllerGetDownloadEvent:
-            iAVController->GetDownloadEventL( aMessage );
-            break;
-        
-        case EAVControllerCancelDownloadEvent:
-            iAVController->CancelGetDownloadEventL( aMessage );
-            break;
-        
-        case EAVControllerGetUploadEvent:
-            iAVController->GetUploadEventL( aMessage );
-            break;
-        
-        case EAVControllerCancelUploadEvent:
-            iAVController->CancelGetUploadEventL( aMessage );
-            break;
-        
-        case EAVControllerStartDownloadFH:
-            iAVController->StartDownloadFHL( aMessage );
-            break;
-
-        default:
-            PanicClient( aMessage, EAVControllerServerBadRequest );
-            break;
-        }
-    }
-
-
-void CUpnpAVControllerSession::DeviceDiscoveredL(
-    CUpnpAVDeviceExtended& aDevice )
-    {
-    iAVController->DeviceDiscoveredL( aDevice );
-    }
-
- 
-void CUpnpAVControllerSession::DeviceDisappearedL(
-    CUpnpAVDeviceExtended& aDevice )
-    {
-    iAVController->DeviceDisappearedL( aDevice );
-    }
-
-
-void CUpnpAVControllerSession::ConnectionLost()
-    {
-    iAVController->ConnectionLost();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerSession::PanicClient
-// Panic client.
-// --------------------------------------------------------------------------
-//
-void CUpnpAVControllerSession::PanicClient( const RMessage2 &aMessage,
-    TInt aPanic ) const
-    {
-     // Note: this panics the client thread, not server
-    aMessage.Panic( KAVControllerName, aPanic );
-    }
-// --------------------------------------------------------------------------
-// CUpnpAVControllerSession::NewL
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-CUpnpAVControllerSession* CUpnpAVControllerSession::NewL(
-    CUpnpAVControllerServer& aServer )
-    {
-    CUpnpAVControllerSession* self =
-        CUpnpAVControllerSession::NewLC(aServer); 
-    CleanupStack::Pop( self ) ;
-    return self ;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVControllerSession::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-CUpnpAVControllerSession* CUpnpAVControllerSession::NewLC( 
-    CUpnpAVControllerServer& aServer )
-    {
-    CUpnpAVControllerSession* self =
-        new (ELeave) CUpnpAVControllerSession(aServer);
-    CleanupStack::PushL( self );
-    self->ConstructL() ;
-    return self ;
-    }
-
-// End of File
-
-
-
+/*
+* Copyright (c) 2002-2009 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:      implementation of a server session
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+#include "upnpavcontrollersession.h"
+#include "upnpavcontrollerserver.pan"
+
+#include "upnpavcontrollerserver.h"
+#include "upnpavcontrollerimpl.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
+#include "upnplog.h"
+
+// ================= MEMBER FUNCTIONS =======================
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::CUpnpAVControllerSession
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// --------------------------------------------------------------------------
+//
+CUpnpAVControllerSession::CUpnpAVControllerSession(
+    CUpnpAVControllerServer& aServer):
+    CSession2(),
+    iAVControllerServer( aServer )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::ConstructL
+// Symbian 2nd phase constructor can leave.
+// --------------------------------------------------------------------------
+//
+void CUpnpAVControllerSession::ConstructL()
+    {
+    __LOG( "CUpnpAVControllerSession::ConstructL" );
+    
+    iAVControllerServer.IncrementSessions();
+    
+    iAVController = CUPnPAVControllerImpl::NewL( iAVControllerServer );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::~CUpnpAVControllerSession
+// Destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpAVControllerSession::~CUpnpAVControllerSession()
+    {
+    iAVControllerServer.DecrementSessions();        
+    
+    delete iAVController;
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::ServiceL
+// Handle client requests.
+// --------------------------------------------------------------------------
+//
+void CUpnpAVControllerSession::ServiceL( const RMessage2& aMessage )
+    {
+    switch(aMessage.Function())
+        {
+        case EAVControllerStartupRequest:
+            {
+            iAVControllerServer.StartUpL();
+            aMessage.Complete( KErrNone );
+            }
+            break;        
+        case EAVControllerCancelStartupRequest:
+            {
+            iAVControllerServer.CancelStartUp();
+            aMessage.Complete( KErrNone );
+            }
+            break;
+
+        case EAVControllerCreateRenderingSession:
+            {
+            iAVController->CreateRenderingSessionL( aMessage );
+            }
+            break;
+        case EAVControllerDestroyRenderingSession:
+            {
+            iAVController->DestroyRenderingSessionL( aMessage );
+            }
+            break;
+        case EAVControllerCreateBrowsingSession:
+            {
+            iAVController->CreateBrowsingSessionL( aMessage );
+            }
+            break;
+            
+        case EAVControllerDestroyBrowsingSession:
+            {
+            iAVController->DestroyBrowsingSessionL( aMessage );
+            }
+            break;  
+
+        case EAVControllerCreateDownloadSession:
+            {
+            iAVController->CreateDownloadSessionL( aMessage );
+            }
+            break;
+            
+        case EAVControllerCreateUploadSession:
+            {
+            iAVController->CreateUploadSessionL( aMessage );       
+            }
+            break;
+        
+        case EAVControllerDestroyDownloadSession:
+            {
+            iAVController->DestroyDownloadSessionL( aMessage );
+            }
+            break;
+        
+        case EAVControllerDestroyUploadSession:
+            {
+            iAVController->DestroyUploadSessionL( aMessage );
+            }
+            break; 
+            
+        default:
+            {
+            ServiceAvTransportCommandsL(aMessage);
+            }
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::ServiceAvTransportCommandsL
+// Handle client requests.
+// --------------------------------------------------------------------------
+//
+void CUpnpAVControllerSession::ServiceAvTransportCommandsL( 
+        const RMessage2& aMessage )
+    {
+    switch(aMessage.Function())
+        {
+        case EAVControllerSetURI:
+            {
+            iAVController->SetURIL( aMessage );
+            }
+            break;
+            
+        case EAVControllerCancelSetURI:
+            {
+            iAVController->CancelSetURIL( aMessage );
+            }
+            break;
+    
+        case EAVControllerSetNextURI:
+            {
+            iAVController->SetNextURIL( aMessage );
+            }
+            break;
+            
+        case EAVControllerCancelSetNextURI:
+            {
+            iAVController->CancelSetNextURIL( aMessage );
+            }
+            break;
+
+        case EAVControllerPlay:
+            {
+            iAVController->PlayL( aMessage );
+            }
+            break;
+    
+        case EAVControllerCancelPlay:
+            {
+            iAVController->CancelPlayL( aMessage );
+            }
+            break;
+            
+        case EAVControllerStop:
+            {
+            iAVController->StopL( aMessage );
+            }
+            break;
+    
+        case EAVControllerCancelStop:
+            {
+            iAVController->CancelStopL( aMessage );
+            }
+            break;
+            
+        case EAVControllerPause:
+            {
+            iAVController->PauseL( aMessage );
+            }
+            break;
+            
+        case EAVControllerCancelPause:
+            {
+            iAVController->CancelPauseL( aMessage );
+            }
+            break;
+        case EAVControllerSeekRelTime:
+            {
+            iAVController->SeekRelTimeL( aMessage );
+            }
+            break;
+            
+        case EAVControllerCancelSeekRelTime:
+            {
+            iAVController->CancelSeekRelTimeL( aMessage );
+            }
+            break;  
+            
+        default:
+            {
+            ServiceAvTransportVariablesL(aMessage);
+            }
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::ServiceAvTransportVariablesL
+// Handle client requests.
+// --------------------------------------------------------------------------
+//
+void CUpnpAVControllerSession::ServiceAvTransportVariablesL( 
+        const RMessage2& aMessage )
+    {
+    switch(aMessage.Function())
+        {
+        case EAVControllerGetRendererState:
+            {
+            iAVController->GetRendererStateL( aMessage );
+            }
+            break;
+            
+        case EAVControllerEventRequest:
+            {
+            iAVController->EventRequestL( aMessage );
+            }
+            break;
+            
+        case EAVControllerCancelEventRequest:
+            {
+            iAVController->CancelEventRequestL( aMessage );
+            }
+            break;
+
+        case EAVControllerSetVolume:
+            {
+            iAVController->SetVolumeL( aMessage );
+            }
+            break;
+
+        case EAVControllerCancelSetVolume:
+            {
+            iAVController->CancelSetVolumeL( aMessage );
+            }
+            break;
+    
+        case EAVControllerGetVolume:
+            {
+            iAVController->GetVolumeL( aMessage );
+            }
+            break;
+    
+        case EAVControllerCancelGetVolume:
+            {
+            iAVController->CancelGetVolumeL( aMessage );
+            }
+            break;
+    
+        case EAVControllerSetMute:
+            {
+            iAVController->SetMuteL( aMessage );
+            }
+            break;
+
+        case EAVControllerCancelSetMute:
+            {
+            iAVController->CancelSetMuteL( aMessage );
+            }
+            break;
+    
+        case EAVControllerGetMute:
+            {
+            iAVController->GetMuteL( aMessage );
+            }
+            break;
+            
+        case EAVControllerCancelGetMute:
+            {
+            iAVController->CancelGetMuteL( aMessage );
+            }
+            break;
+            
+        case EAVControllerGetPositionInfo:
+            {
+            iAVController->GetPositionInfoL( aMessage );
+            }
+            break;
+            
+        case EAVControllerCancelGetPositionInfo:
+            {
+            iAVController->CancelGetPositionInfoL( aMessage );
+            }
+            break;          
+            
+        default:
+            {
+            ServiceDeviceL(aMessage);
+            }
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::ServiceDeviceL
+// Handle client requests.
+// --------------------------------------------------------------------------
+//
+void CUpnpAVControllerSession::ServiceDeviceL( const RMessage2& aMessage )
+{
+    switch(aMessage.Function())
+        {
+        case EAVControllerDeviceRequest:           
+            {
+            iAVController->EnableDeviceDiscoveryL( aMessage );
+            }
+            break;
+            
+        case EAVControllerGetDeviceRequest:
+            {
+            iAVController->GetDeviceL( aMessage );
+            }
+            break;                      
+
+        case EAVControllerCancelDeviceRequest:
+            {
+            iAVController->DisableDeviceDiscoveryL();
+            aMessage.Complete( KErrNone );
+            }
+            break;                      
+        
+        case EAVControllerGetDeviceListSizeRequest:
+            {
+            iAVController->GetDeviceListSizeL( aMessage );
+            }
+            break;
+
+        case EAVControllerGetDeviceListRequest:
+            {
+            iAVController->GetDeviceListL( aMessage );
+            }
+            break;
+            
+        case EAVControllerDeviceDisappearedRequest:
+            {
+            iAVController->DeviceDisappearedRequestL( aMessage );
+            }
+            break;
+            
+        case EAVControllerCancelDeviceDisappearedRequest:
+            {
+            iAVController->CancelDeviceDisappearedRequestL( aMessage );
+            }
+            break;
+
+        case EAVControllerGetDeviceIconRequest:
+            {
+            iAVController->GetDeviceIconRequestL( aMessage );
+            }
+            break;
+            
+        default:
+            {
+            ServiceSearchandBrowseL(aMessage);
+            }
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::ServiceSearchandBrowseL
+// Handle client requests.
+// --------------------------------------------------------------------------
+//
+void CUpnpAVControllerSession::ServiceSearchandBrowseL( 
+        const RMessage2& aMessage )
+{
+    switch(aMessage.Function())
+        {
+        case EAVControllerGetBrowseResponseSize:
+            {
+            iAVController->GetBrowseResponseSizeL( aMessage );
+            }
+            break;
+        
+        case EAVControllerCancelGetBrowseResponseSize:
+            {
+            iAVController->CancelGetBrowseResponseSizeL( aMessage );
+            }
+            break;
+        
+        case EAVControllerGetBrowseResponse:
+            {
+            iAVController->GetBrowseResponseL( aMessage );
+            }
+            break;
+                    
+        case EAVControllerGetSearchResponseSize:
+            {
+            iAVController->GetSearchResponseSizeL( aMessage );
+            }
+            break;
+            
+        case EAVControllerCancelGetSearchResponseSize:
+            {
+            iAVController->CancelGetSearchResponseSizeL( aMessage );
+            }
+            break;
+        
+        case EAVControllerGetSearchResponse:
+            {
+            iAVController->GetSearchResponseL( aMessage );
+            }
+            break;
+                    
+        case EAVControllerGetSearchCapabilitiesSize:
+            {
+            iAVController->GetSearchCapabitiesSizeL( aMessage );
+            }
+            break;    
+                            
+        case EAVControllerCancelGetSearchCapabilitiesSize:
+            {
+            iAVController->CancelGetSearchCapabitiesSizeL( aMessage );
+            }
+            break;
+            
+        case EAVControllerGetSearchCapabilities:
+            {
+            iAVController->GetSearchCapabitiesL( aMessage );
+            }
+            break;  
+            
+        default:
+            {
+            ServiceDownloadandUploadL(aMessage);
+            }
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::ServiceDownloadandUploadL
+// Handle client requests.
+// --------------------------------------------------------------------------
+//
+void CUpnpAVControllerSession::ServiceDownloadandUploadL( 
+        const RMessage2& aMessage )
+    {
+    switch(aMessage.Function())
+        {
+        case EAVControllerStartDownload:
+            {
+            iAVController->StartDownloadL( aMessage );
+            }
+            break;
+        
+        case EAVControllerCancelDownload:
+            {
+            iAVController->CancelDownloadL( aMessage );
+            }
+            break;
+        
+        case EAVControllerCancelAllDownloads:
+            {
+            iAVController->CancelAllDownloadsL( aMessage );
+            }
+            break;
+        
+        case EAVControllerStartUpload:
+            {
+            iAVController->StartUploadL( aMessage );
+            }
+            break;
+        
+        case EAVControllerCancelUpload:
+            {
+            iAVController->CancelUploadL( aMessage );
+            }
+            break;
+        
+        case EAVControllerCancelAllUploads:
+            {
+            iAVController->CancelAllUploadsL( aMessage );
+            }
+            break;
+            
+        case EAVControllerStartTrackingUploadProgress:
+            {
+            iAVController->StartTrackingUploadProgressL( aMessage );
+            }
+            break;
+        
+        case EAVControllerStartTrackingDownloadProgress:
+            {
+            iAVController->StartTrackingDownloadProgressL( aMessage );
+            }
+            break;
+        
+        case EAVControllerGetDownloadEvent:
+            {
+            iAVController->GetDownloadEventL( aMessage );
+            }
+            break;
+        
+        case EAVControllerCancelDownloadEvent:
+            {
+            iAVController->CancelGetDownloadEventL( aMessage );
+            }
+            break;
+        
+        case EAVControllerGetUploadEvent:
+            {
+            iAVController->GetUploadEventL( aMessage );
+            }
+            break;
+        
+        case EAVControllerCancelUploadEvent:
+            {
+            iAVController->CancelGetUploadEventL( aMessage );
+            }
+            break;
+        
+        case EAVControllerStartDownloadFH:
+            {
+            iAVController->StartDownloadFHL( aMessage );
+            }
+            break;   
+            
+        default:
+            {
+            ServiceCommonL(aMessage);
+            }
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::ServiceCommonL
+// Handle client requests.
+// --------------------------------------------------------------------------
+//
+void CUpnpAVControllerSession::ServiceCommonL( const RMessage2& aMessage )
+    {
+    switch(aMessage.Function())
+        {
+        case EAVControllerCreateContainer:
+            {
+            iAVController->CreateContainerL( aMessage );
+            }
+            break;
+        
+        case EAVControllerCancelCreateContainer:
+            {
+            iAVController->CancelCreateContainerL( aMessage );
+            }
+            break;  
+        
+        case EAVControllerDeleteObject:
+            {
+            iAVController->DeleteObjectL( aMessage );
+            }
+            break;
+        
+        case EAVControllerCancelDeleteObject:
+            {
+            iAVController->CancelDeleteObjectL( aMessage );
+            }
+            break;
+                
+        case EAVControllerMonitorConnection:
+            {
+            iAVController->MonitorConnectionL( aMessage );
+            }
+            break;
+        
+        case EAVControllerCancelMonitorConnection:
+            {
+            iAVController->CancelMonitorConnectionL( aMessage );
+            }
+            break;
+        
+        default:
+            {
+            PanicClient( aMessage, EAVControllerServerBadRequest );
+            }
+            break;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::DeviceDiscoveredL
+// --------------------------------------------------------------------------
+//
+void CUpnpAVControllerSession::DeviceDiscoveredL(
+    CUpnpAVDeviceExtended& aDevice )
+    {
+    iAVController->DeviceDiscoveredL( aDevice );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::DeviceDisappearedL
+// --------------------------------------------------------------------------
+// 
+void CUpnpAVControllerSession::DeviceDisappearedL(
+    CUpnpAVDeviceExtended& aDevice )
+    {
+    iAVController->DeviceDisappearedL( aDevice );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::DeviceIconDownloadedL
+// --------------------------------------------------------------------------
+// 
+void CUpnpAVControllerSession::DeviceIconDownloadedL(
+    CUpnpAVDeviceExtended& aDevice )
+    {
+    iAVController->DeviceIconDownloadedL( aDevice );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::ConnectionLost
+// --------------------------------------------------------------------------
+// 
+void CUpnpAVControllerSession::ConnectionLost()
+    {
+    iAVController->ConnectionLost();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::PanicClient
+// Panic client.
+// --------------------------------------------------------------------------
+//
+void CUpnpAVControllerSession::PanicClient( const RMessage2 &aMessage,
+    TInt aPanic ) const
+    {
+     // Note: this panics the client thread, not server
+    aMessage.Panic( KAVControllerName, aPanic );
+    }
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::NewL
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+//
+CUpnpAVControllerSession* CUpnpAVControllerSession::NewL(
+    CUpnpAVControllerServer& aServer )
+    {
+    CUpnpAVControllerSession* self =
+        CUpnpAVControllerSession::NewLC(aServer); 
+    CleanupStack::Pop( self ) ;
+    return self ;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVControllerSession::NewLC
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+//
+CUpnpAVControllerSession* CUpnpAVControllerSession::NewLC( 
+    CUpnpAVControllerServer& aServer )
+    {
+    CUpnpAVControllerSession* self =
+        new (ELeave) CUpnpAVControllerSession(aServer);
+    CleanupStack::PushL( self );
+    self->ConstructL() ;
+    return self ;
+    }
+
+// End of File
+
+
+
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpavdeviceextended.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpavdeviceextended.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,874 +1,981 @@
-/*
-* 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:      device with extended information - used in AVC server
-*
-*/
-
-
-
-
-
-
-// INCLUDES
-// upnp stack api
-#include <upnpdlnaprotocolinfo.h>
-#include <upnpitem.h>
-
-// upnpframework / avcontroller helper api
-#include "upnpitemutility.h"
-#include "upnpconstantdefs.h" // for upnp-specific stuff
-
-// upnpframework / internal api's
-#include "upnpcommonutils.h"
-
-// avcontroller internal
-#include "upnpavdeviceextended.h"
-
-
-_LIT8( KAudioSupport,        "audio/" );
-_LIT8( KImageSupport,        "image/" );
-_LIT8( KVideoSupport,        "video/" );
-_LIT8( KDlnaPn,              "DLNA.ORG_PN" );
-
-
-const TInt KProtocolInfoDelimeter = 44;
-const TInt KUnicodeC0RangeStart = 0;// the begin character of C0 range
-const TInt KUnicodeC0RangeEnd = 32;// the end character of C0 range 
-const TInt KUnicodeC1RangeStart = 127;// the begin character of C1 range
-const TInt KUnicodeC1RangeEnd = 159;// the end character of C1 range
-const TInt KSlash = 92;
-_LIT8( KProtocolInfo,       "protocolInfo" );
-_LIT8( KAsterisk,           "*" );
-
-_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
-#include "upnplog.h"
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::NewL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-CUpnpAVDeviceExtended* CUpnpAVDeviceExtended::NewL(
-    const CUpnpAVDevice& aDevice )
-    {
-    CUpnpAVDeviceExtended* dev = new(ELeave) CUpnpAVDeviceExtended();
-    CleanupStack::PushL( dev );
-    
-    dev->iDeviceType = aDevice.DeviceType();
-    dev->SetFriendlyNameL( aDevice.FriendlyName() );
-    dev->SetUuidL( aDevice.Uuid() );
-    dev->iCopyCapability = aDevice.CopyCapability();
-    dev->iSearchCapability = aDevice.SearchCapability();
-    dev->iPauseCapability = aDevice.PauseCapability();
-    dev->iVolumeCapability = aDevice.VolumeCapability();
-    dev->iMuteCapability = aDevice.MuteCapability();
-    dev->iAudioMediaCapability = aDevice.AudioCapability();
-    dev->iImageMediaCapability = aDevice.ImageCapability();
-    dev->iVideoMediaCapability = aDevice.VideoCapability();
-    dev->iNextAVTransportUri = aDevice.NextAVTransportUri();
-    dev->iMaxVolume = aDevice.MaxVolume();
-    dev->iDlnaCompatible = aDevice.DlnaCompatible();
-           
-    dev->ConstructL();
-    CleanupStack::Pop();
-    return dev;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::NewL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-CUpnpAVDeviceExtended* CUpnpAVDeviceExtended::NewL(
-    const CUpnpAVDeviceExtended& aDevice )
-    {
-    CUpnpAVDeviceExtended* dev = new(ELeave) CUpnpAVDeviceExtended();
-    CleanupStack::PushL( dev );
-    
-    dev->iDeviceType = aDevice.DeviceType();
-    dev->SetFriendlyNameL( aDevice.FriendlyName() );
-    dev->SetUuidL( aDevice.Uuid() );
-    dev->iCopyCapability = aDevice.CopyCapability();
-    dev->iSearchCapability = aDevice.SearchCapability();
-    dev->iPauseCapability = aDevice.PauseCapability();
-    dev->iVolumeCapability = aDevice.VolumeCapability();
-    dev->iMuteCapability = aDevice.MuteCapability();
-    dev->iAudioMediaCapability = aDevice.AudioCapability();
-    dev->iImageMediaCapability = aDevice.ImageCapability();
-    dev->iVideoMediaCapability = aDevice.VideoCapability();
-    dev->iNextAVTransportUri = aDevice.NextAVTransportUri();
-    dev->iMaxVolume = aDevice.MaxVolume();
-    dev->iDlnaCompatible = aDevice.DlnaCompatible();
-        
-    dev->SetSinkProtocolInfoL( aDevice.SinkProtocolInfo() );
-    dev->SetSourceProtocolInfoL( aDevice.SourceProtocolInfo() );
-    dev->iSubscriptionCount = aDevice.SubscriptionCount();   
-    dev->iLocal = aDevice.Local();
-    dev->iAudioUpload = aDevice.AudioUpload();
-    dev->iImageUpload = aDevice.ImageUpload();
-    dev->iVideoUpload = aDevice.VideoUpload(); 
-    dev->iCreateChildContainer = aDevice.CreateChildContainer();
-    dev->iDestroyObject = aDevice.DestroyObject();
-    dev->iPInfoReceived = aDevice.PInfoReceived();
-    dev->iDLNADeviceType = aDevice.DLNADeviceType();
-    
-    dev->ConstructL();
-    CleanupStack::Pop();
-    return dev;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::NewL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-CUpnpAVDeviceExtended* CUpnpAVDeviceExtended::NewL()
-    {
-    CUpnpAVDeviceExtended* dev = new(ELeave) CUpnpAVDeviceExtended();
-    CleanupStack::PushL( dev );        
-    dev->ConstructL();
-    CleanupStack::Pop();
-    return dev;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::~CUpnpAVDeviceExtended
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-CUpnpAVDeviceExtended::~CUpnpAVDeviceExtended()
-    {     
-    iSinkProtocolInfo.ResetAndDestroy();
-    iSourceProtocolInfo.ResetAndDestroy();
-    }
-    
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::CUpnpAVDeviceExtended
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-CUpnpAVDeviceExtended::CUpnpAVDeviceExtended() :
-    CUpnpAVDevice()
-    {     
-    }
-   
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::IncreaseSubscriptionCount
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TInt CUpnpAVDeviceExtended::IncreaseSubscriptionCount()
-    {
-    return ++iSubscriptionCount; 
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::DecreaseSubscriptionCount
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TInt CUpnpAVDeviceExtended::DecreaseSubscriptionCount()
-    {
-    iSubscriptionCount--;
-    if( iSubscriptionCount < 0 )
-        {
-        iSubscriptionCount = 0;
-        }
-    return iSubscriptionCount;    
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SubscriptionCount
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TInt CUpnpAVDeviceExtended::SubscriptionCount() const
-    {
-    return iSubscriptionCount;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::ConstructL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::ConstructL()
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetSinkProtocolInfoL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetSinkProtocolInfoL(
-    const TDesC8& aProtocolInfo )
-    {
-    __LOG( "CUpnpAVDeviceExtended::SetSinkProtocolInfoL" );
-    HBufC8* buffer = RemoveIllegalCharactersL( aProtocolInfo );
-    if( buffer )
-        {
-        CleanupStack::PushL( buffer );
-        TLex8 input( *buffer );
-        
-        while( !input.Eos() )
-            {
-            ParseToDelimeter( input, TChar( KProtocolInfoDelimeter ) );
-            CUpnpDlnaProtocolInfo* tmpInfo = NULL;
-            TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL(
-                input.MarkedToken() ) );
-             
-            if( err == KErrNone && tmpInfo )
-                {
-                // Transfer ownership of tmpInfo
-                iSinkProtocolInfo.AppendL( tmpInfo );
-                }
-            else
-                {
-                __LOG1( "CUpnpDlnaProtocolInfo::NewL failed: %d", err );
-                }
-                
-            if( !input.Eos() )
-                {
-                input.SkipAndMark( 1 ); // Skip the delimeter
-                }
-            }
-        CleanupStack::PopAndDestroy( buffer );
-        }
-    __LOG( "CUpnpAVDeviceExtended::SetSinkProtocolInfoL end" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SinkProtocolInfo
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-const RPointerArray<CUpnpDlnaProtocolInfo>&
-    CUpnpAVDeviceExtended::SinkProtocolInfo() const
-    {
-    return iSinkProtocolInfo;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetSourceProtocolInfoL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetSourceProtocolInfoL(
-    const TDesC8& aProtocolInfo )
-    {
-    __LOG( "CUpnpAVDeviceExtended::SetSourceProtocolInfoL" );
-    HBufC8* buffer = RemoveIllegalCharactersL( aProtocolInfo );
-    if( buffer )
-        {
-        CleanupStack::PushL( buffer );
-        TLex8 input( *buffer );
-        
-        while( !input.Eos() )
-            {
-            ParseToDelimeter( input, TChar( KProtocolInfoDelimeter ) );
-            CUpnpDlnaProtocolInfo* tmpInfo = NULL;
-            TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL(
-                input.MarkedToken() ) );
-               
-            if( err == KErrNone && tmpInfo )
-                {
-                // Transfer ownership of tmpInfo
-                iSourceProtocolInfo.AppendL( tmpInfo );
-                }
-            else
-                {
-                __LOG1( "CUpnpDlnaProtocolInfo::NewL failed: %d", err );
-                }
-                
-            if( !input.Eos() )
-                {
-                input.SkipAndMark( 1 ); // Skip the delimeter
-                }
-            }
-        CleanupStack::PopAndDestroy( buffer );
-        }
-    __LOG( "CUpnpAVDeviceExtended::SetSourceProtocolInfoL end" );
-    }
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SourceProtocolInfo
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-const RPointerArray<CUpnpDlnaProtocolInfo>&
-    CUpnpAVDeviceExtended::SourceProtocolInfo() const
-    {
-    return iSourceProtocolInfo;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetLocal
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetLocal( TBool aLocal )
-    {
-    iLocal = aLocal;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::Local
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::Local() const
-    {
-    return iLocal;
-    }    
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::MatchSinkProtocolInfo
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::MatchSinkProtocolInfo(
-    const TDesC8& aInfo ) const
-    {
-    __LOG( "CUpnpAVDeviceExtended::MatchSinkProtocolInfo" );
-
-    TBool match = EFalse;
-
-    if( DlnaCompatible() )
-        {
-        // The device is DLNA compatible
-        
-        // Try try find PN parameter to determine if it's dlna content
-        if( aInfo.Find( KDlnaPn ) != KErrNotFound )
-            {
-            __LOG( "MatchSinkProtocolInfo - DLNA content and the renderer \
-is DLNA compatible, start matching..." );
-
-            match = MatchSinkProfileId( aInfo );
-            }
-        else
-            {
-            __LOG( "MatchSinkProtocolInfo - Non DLNA content and the \
-renderer is DLNA compatible, start matching..." );            
-            match = MatchSinkMime( aInfo );
-            }    
-        }
-    else
-        {
-        __LOG( "MatchSinkProtocolInfo - Renderer is not DLNA compatible, \
-start matching..." );            
-        match = MatchSinkMime( aInfo );
-        }    
-        
-    return match;
-    }      
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::MatchSourceProtocolInfo
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::ValidateTransfer(
-    const TDesC8& aInfo ) const
-    {
-    __LOG( "CUpnpAVDeviceExtended::MatchSourceProtocolInfo" );
-
-    // Try try find PN parameter to determine if it's dlna content
-    TBool match = EFalse;
-    if( aInfo.Find( KDlnaPn ) != KErrNotFound )
-        {
-        match = MatchSourceProfileId( aInfo );     
-        }
-
-    return match;
-    }      
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::MatchSinkProfileId
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::MatchSinkProfileId(
-    const TDesC8& aInfo ) const
-    {
-    __LOG( "CUpnpAVDeviceExtended::MatchSinkProfileId" );
-    
-    TBool match = EFalse;
-    CUpnpDlnaProtocolInfo* tmpInfo = NULL;
-    TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo ) );
-    if ( err == KErrNone )
-        {      
-        // Match the first parameter and PN parameter
-        TInt count = iSinkProtocolInfo.Count();
-        for( TInt i = 0; i < count; i++ )
-            {
-            if( iSinkProtocolInfo[ i ]->PnParameter() ==
-                tmpInfo->PnParameter() ||
-                iSinkProtocolInfo[ i ]->FourthField() == KAsterisk )
-                {
-                // PN parameter matches, try matching the first
-                // parameter
-                if( iSinkProtocolInfo[ i ]->FirstField() ==
-                    tmpInfo->FirstField() ||
-                    iSinkProtocolInfo[ i ]->FirstField() ==
-                    KAsterisk )
-                    {
-                    __LOG( "MatchSinkProfileId - a match" );
-                    
-                    // We have a match!
-                    i = count;
-                    match = ETrue;
-                    }
-                }     
-            }
-        delete tmpInfo;
-        }            
-    return match;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::MatchSourceProfileId
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::MatchSourceProfileId(
-    const TDesC8& aInfo ) const
-    {
-    __LOG( "CUpnpAVDeviceExtended::MatchSourceProfileId" );
-    
-    TBool match = EFalse;
-    CUpnpDlnaProtocolInfo* tmpInfo = NULL;
-    TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo ) );
-    if ( err == KErrNone )
-        {      
-        // Match the first parameter and PN parameter
-        TInt count = iSourceProtocolInfo.Count();
-        for( TInt i = 0; i < count; i++ )
-            {
-            if( iSourceProtocolInfo[ i ]->PnParameter() ==
-                tmpInfo->PnParameter() )
-                {
-                // PN parameter matches, try matching the first
-                // parameter
-                if( iSourceProtocolInfo[ i ]->FirstField() ==
-                    tmpInfo->FirstField() ||
-                    iSourceProtocolInfo[ i ]->FirstField() ==
-                    KAsterisk )
-                    {
-                    __LOG( "MatchSourceProfileId - a match" );
-                                        
-                    // We have a match!
-                    i = count;
-                    match = ETrue;
-                    }
-                }     
-            }
-        delete tmpInfo;
-        }            
-    return match;
-    }
-   
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::MatchSinkMime
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::MatchSinkMime( const TDesC8& aInfo ) const
-    {
-    __LOG( "CUpnpAVDeviceExtended::MatchSinkMime" );
-
-    TBool match = EFalse;
-    CUpnpDlnaProtocolInfo* tmpInfo = NULL;
-    TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo ) );
-    if ( err == KErrNone )
-        {      
-        // Match the first parameter and mime-type
-        TInt count = iSinkProtocolInfo.Count();
-        for( TInt i = 0; i < count; i++ )
-            {
-            if( iSinkProtocolInfo[ i ]->ThirdField() ==
-                tmpInfo->ThirdField() )
-                {
-                // Mime-parameter matches, try matching the first
-                // parameter
-                if( iSinkProtocolInfo[ i ]->FirstField() ==
-                    tmpInfo->FirstField() )
-                    {
-                    __LOG( "MatchSinkMime - a match" );
-                    
-                    // We have a match!
-                    i = count;
-                    match = ETrue;
-                    }
-                }     
-            }
-        delete tmpInfo;
-        }            
-    return match;    
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::FindFirstMatchingInSinkL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-const TDesC8& CUpnpAVDeviceExtended::FindFirstMatchingInSinkL(
-    const CUpnpItem& aItem ) const
-    {
-    __LOG( "CUpnpAVDeviceExtended::FindFirstMatchingInSinkL" );
-    
-    RUPnPElementsArray array;
-    CleanupClosePushL( array );
-    
-    UPnPItemUtility::GetResElements( aItem, array );
-    TBool match = EFalse;
-    TInt i;
-    
-    TInt count = array.Count();
-    for( i = 0; i < count; i ++ )
-        {
-        const CUpnpAttribute& protocolInfo =
-            UPnPItemUtility::FindAttributeByNameL(
-            *array[ i ], KProtocolInfo );
-            
-        if( MatchType( aItem.ObjectClass(), protocolInfo.Value() ) )
-            {
-            if( MatchSinkProtocolInfo( protocolInfo.Value() ) )
-                {
-                // We have a match!
-                __LOG( "FindFirstMatchingInSinkL - a match" );
-                
-                match = ETrue;
-                break;
-                }
-            else
-                {
-                __LOG( "FindFirstMatchingInSinkL - not a match" );
-                }                
-            }
-        else
-            {
-            // Res-elements mime-type does not match to object-class
-            // Ignore
-            __LOG( "FindFirstMatchingInSinkL - Res doesn't match \
-to objectclass" );
-            }              
-        }
-    
-    if( !match )
-        {
-        __LOG( "FindFirstMatchingInSinkL - No match" );
-        
-        User::Leave( KErrNotSupported );
-        }
-    
-    const TDesC8& uri = array[ i ]->Value();
-    
-    CleanupStack::PopAndDestroy( &array );
-    
-    return uri;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::MatchType
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::MatchType( const TDesC8& aObjectClass,
-    const TDesC8& aProtocolInfo ) const
-    {
-    __LOG( "CUpnpAVDeviceExtended::MatchType" );
-    
-    TBool retVal = EFalse;
-    if( aObjectClass.Find( KClassAudio ) == 0 )
-        {
-        if( aProtocolInfo.Find( KAudioSupport ) >= 0 )
-            {
-            retVal = ETrue;
-            }
-        }
-    else if( aObjectClass.Find( KClassImage ) == 0 )
-        {
-        if( aProtocolInfo.Find( KImageSupport ) >= 0 )
-            {
-            retVal = ETrue;
-            }        
-        }
-    else if( aObjectClass.Find( KClassVideo ) == 0 )
-        {
-        if( aProtocolInfo.Find( KVideoSupport ) >= 0 )
-            {
-            retVal = ETrue;
-            }        
-        }
-    else
-        {
-        __PANICD( __FILE__, __LINE__ );
-        }
-    return retVal;        
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetCapabilitiesBySupportedMimeTypesL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetCapabilitiesBySupportedMimeTypesL( 
-    const TDesC8& aListOfMimeTypes )
-    {
-    __LOG( "CUpnpAVDeviceExtended::SetCapabilitiesBySupportedMimeTypesL" );
-    
-    if( aListOfMimeTypes != KNullDesC8 )
-        {
- 	    // Update the audio media capability
-        if( UPnPCommonUtils::IsAudioSupported( aListOfMimeTypes ) )
-            {
-            iAudioMediaCapability = ETrue;
-            }
-        else
-            {	
-            iAudioMediaCapability = EFalse;
-            }
-
-	    // Update the audio media capability
-        if( UPnPCommonUtils::IsImageSupported( aListOfMimeTypes ) )
-            {
-            iImageMediaCapability = ETrue;
-            }
-        else
-            {	
-            iImageMediaCapability = EFalse;
-            }
-  
-        // Update the video media capability
-        if( UPnPCommonUtils::IsVideoSupported( aListOfMimeTypes ) )
-            {
-            iVideoMediaCapability = ETrue;
-            }
-        else
-            {	
-            iVideoMediaCapability = EFalse;
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetSourceProtocolInfoL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetSourceProtocolInfoL(
-        const RPointerArray<CUpnpDlnaProtocolInfo>& aProtocolInfo )
-    {
-    __LOG( "CUpnpAVDeviceExtended::SetSourceProtocolInfoL" );
-    
-    for( TInt i = 0; i < aProtocolInfo.Count(); i++ )
-        {
-        CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
-            aProtocolInfo[ i ]->ProtocolInfoL() );
-        iSourceProtocolInfo.AppendL( tmpInfo ); // Ownership is transferred
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetSinkProtocolInfoL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetSinkProtocolInfoL(
-        const RPointerArray<CUpnpDlnaProtocolInfo>& aProtocolInfo )
-    {
-    __LOG( "CUpnpAVDeviceExtended::SetSinkProtocolInfoL" );
-    
-    for( TInt i = 0; i < aProtocolInfo.Count(); i++ )
-        {
-        CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
-            aProtocolInfo[ i ]->ProtocolInfoL() );
-        iSinkProtocolInfo.AppendL( tmpInfo ); // Ownership is transferred
-        }
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::ParseToDelimeter
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::ParseToDelimeter( TLex8& aLex, TChar aDelimeter )
-    {
-    aLex.Mark();
-        
-    TChar chr = 0;
-	TChar edchr = 0;
-		
-	while( !aLex.Eos() )
-		{
-		edchr = chr;
-		
-		chr = aLex.Peek();
-		if( chr == aDelimeter && edchr != TChar( KSlash ) )
-			{
-			break;
-			}
-			
-		aLex.Inc();		
-		}
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::RemoveIllegalCharactersL
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------   
- HBufC8* CUpnpAVDeviceExtended::RemoveIllegalCharactersL(
-    const TDesC8& aPtr ) const
-    {
-    HBufC8* ptrResult = NULL;
-    TInt i = KErrNotFound;
-    if ( aPtr.Length() != 0 )
-        {
-        ptrResult = aPtr.AllocL();
-        CleanupStack::PushL( ptrResult );    
-        TPtr8 ptr = ptrResult->Des();
-        while( ++i < ptr.Length() )
-            {       
-            if( IsIllegalCharacter( ptr[i] ) )
-                {     
-                ptr.Delete( i, 1 );
-                i--;
-                }
-                               
-            }       
-        CleanupStack::Pop( ptrResult );       
-        } 
-    return ptrResult;
-   
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::IsIllegalCharacter
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::IsIllegalCharacter( TChar aCharacter ) const
-    {
-    
-    TBool retVal = EFalse;
-    if ( ( ( aCharacter >= TChar( KUnicodeC0RangeStart ) 
-        && aCharacter <= TChar( KUnicodeC0RangeEnd ) ) 
-        || ( aCharacter >= TChar( KUnicodeC1RangeStart ) 
-        && aCharacter <= TChar( KUnicodeC1RangeEnd ) ) ) )
-        {
-        retVal = ETrue;
-        }
-    return retVal;
-    
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetAudioUpload
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetAudioUpload( TBool aAudioUpload )
-    {
-    iAudioUpload = aAudioUpload;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::AudioUpload
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::AudioUpload() const
-    {
-    return iAudioUpload;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetImageUpload
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetImageUpload( TBool aImageUpload )
-    {
-    iImageUpload = aImageUpload;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::ImageUpload
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::ImageUpload() const
-    {
-    return iImageUpload;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetVideoUpload
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetVideoUpload( TBool aVideoUpload )
-    {
-    iVideoUpload = aVideoUpload;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::VideoUpload
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::VideoUpload() const
-    {
-    return iVideoUpload;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetCreateChildContainer
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetCreateChildContainer(
-    TBool aCreateChildContainer )
-    {
-    iCreateChildContainer = aCreateChildContainer;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::CreateChildContainer
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::CreateChildContainer() const
-    {
-    return iCreateChildContainer;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetDestroyObject
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetDestroyObject( TBool aDestroyObject )
-    {
-    iDestroyObject = aDestroyObject;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::DestroyObject
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::DestroyObject() const
-    {
-    return iDestroyObject;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::SetPInfoReceived
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-void CUpnpAVDeviceExtended::SetPInfoReceived( TBool aPInfoReceived )
-    {
-    iPInfoReceived = aPInfoReceived;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAVDeviceExtended::PInfoReceived
-// See upnpavdeviceextended.h
-// --------------------------------------------------------------------------
-TBool CUpnpAVDeviceExtended::PInfoReceived() const
-    {
-    return iPInfoReceived;
-    }
-
-void CUpnpAVDeviceExtended::SetDLNADeviceType( TDLNADeviceType aDeviceType )
-    {
-    iDLNADeviceType = aDeviceType;
-    }
-   
-CUpnpAVDeviceExtended::TDLNADeviceType
-    CUpnpAVDeviceExtended::DLNADeviceType() const
-    {
-    return iDLNADeviceType;
-    }
-
-
-    
-// end of 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:      device with extended information - used in AVC server
+*
+*/
+
+
+
+
+
+
+// INCLUDES
+#include <in_sock.h>
+
+// dlnasrv / mediaserver api
+#include <upnpdlnaprotocolinfo.h>
+#include <upnpitem.h>
+
+// dlnasrv / avcontroller helper api
+#include "upnpitemutility.h"
+#include "upnpconstantdefs.h" // for upnp-specific stuff
+
+// dlnasrv / internal api's
+#include "upnpcommonutils.h"
+
+// dlnasrv / avcontroller internal
+#include "upnpavdeviceextended.h"
+
+
+_LIT8( KAudioSupport,        "audio/" );
+_LIT8( KImageSupport,        "image/" );
+_LIT8( KVideoSupport,        "video/" );
+_LIT8( KDlnaPn,              "DLNA.ORG_PN" );
+
+
+const TInt KProtocolInfoDelimeter = 44;
+const TInt KUnicodeC0RangeStart = 0;// the begin character of C0 range
+const TInt KUnicodeC0RangeEnd = 32;// the end character of C0 range 
+const TInt KUnicodeC1RangeStart = 127;// the begin character of C1 range
+const TInt KUnicodeC1RangeEnd = 159;// the end character of C1 range
+const TInt KSlash = 92;
+_LIT8( KProtocolInfo,       "protocolInfo" );
+_LIT8( KAsterisk,           "*" );
+
+const TInt KUrlIpBufLen = 16; // For IP address e.g. xxx.xxx.xxx.xxx
+const TInt KUrlPortLen = 11; // For HTTP port e.g. yyyyy
+_LIT8( KUrlColon, ":" );
+_LIT8( KUrlSlash, "/" );
+_LIT8( KUrlHttp, "http://" );
+
+_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
+#include "upnplog.h"
+
+// --------------------------------------------------------------------------
+// EnsureFinalSlash
+// --------------------------------------------------------------------------
+static void EnsureFinalSlash( TDes8& aUrl )
+    {
+    TInt len( aUrl.Length() );
+    if ( len > 0 && aUrl[ len - 1 ] != KUrlSlash()[ 0 ] )
+        {
+        aUrl.Append( KUrlSlash );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// RemoveInitial
+// --------------------------------------------------------------------------
+static TPtrC8 RemoveInitial( const TDesC8& aUrl, const TDesC8& aInitial )
+    {
+    return aUrl.Find( aInitial ) == 0 ? aUrl.Mid( aInitial.Length() ) : aUrl;
+    }
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::NewL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+CUpnpAVDeviceExtended* CUpnpAVDeviceExtended::NewL(
+    const CUpnpAVDevice& aDevice )
+    {
+    CUpnpAVDeviceExtended* dev = new(ELeave) CUpnpAVDeviceExtended();
+    CleanupStack::PushL( dev );
+    
+    dev->iDeviceType = aDevice.DeviceType();
+    dev->SetFriendlyNameL( aDevice.FriendlyName() );
+    dev->SetUuidL( aDevice.Uuid() );
+    dev->iCopyCapability = aDevice.CopyCapability();
+    dev->iSearchCapability = aDevice.SearchCapability();
+    dev->iPauseCapability = aDevice.PauseCapability();
+    dev->iVolumeCapability = aDevice.VolumeCapability();
+    dev->iMuteCapability = aDevice.MuteCapability();
+    dev->iAudioMediaCapability = aDevice.AudioCapability();
+    dev->iImageMediaCapability = aDevice.ImageCapability();
+    dev->iVideoMediaCapability = aDevice.VideoCapability();
+    dev->iNextAVTransportUri = aDevice.NextAVTransportUri();
+    dev->iMaxVolume = aDevice.MaxVolume();
+    dev->iDlnaCompatible = aDevice.DlnaCompatible();
+    dev->iSeekCapability = aDevice.SeekCapability();
+           
+    dev->ConstructL();
+    CleanupStack::Pop();
+    return dev;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::NewL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+CUpnpAVDeviceExtended* CUpnpAVDeviceExtended::NewL(
+    const CUpnpAVDeviceExtended& aDevice )
+    {
+    CUpnpAVDeviceExtended* dev = new(ELeave) CUpnpAVDeviceExtended();
+    CleanupStack::PushL( dev );
+    
+    dev->iDeviceType = aDevice.DeviceType();
+    dev->SetFriendlyNameL( aDevice.FriendlyName() );
+    dev->SetUuidL( aDevice.Uuid() );
+    dev->iCopyCapability = aDevice.CopyCapability();
+    dev->iSearchCapability = aDevice.SearchCapability();
+    dev->iPauseCapability = aDevice.PauseCapability();
+    dev->iVolumeCapability = aDevice.VolumeCapability();
+    dev->iMuteCapability = aDevice.MuteCapability();
+    dev->iAudioMediaCapability = aDevice.AudioCapability();
+    dev->iImageMediaCapability = aDevice.ImageCapability();
+    dev->iVideoMediaCapability = aDevice.VideoCapability();
+    dev->iNextAVTransportUri = aDevice.NextAVTransportUri();
+    dev->iMaxVolume = aDevice.MaxVolume();
+    dev->iDlnaCompatible = aDevice.DlnaCompatible();
+    dev->iSeekCapability = aDevice.SeekCapability();
+        
+    dev->SetSinkProtocolInfoL( aDevice.SinkProtocolInfo() );
+    dev->SetSourceProtocolInfoL( aDevice.SourceProtocolInfo() );
+    dev->iSubscriptionCount = aDevice.SubscriptionCount();   
+    dev->iLocal = aDevice.Local();
+    dev->iAudioUpload = aDevice.AudioUpload();
+    dev->iImageUpload = aDevice.ImageUpload();
+    dev->iVideoUpload = aDevice.VideoUpload(); 
+    dev->iCreateChildContainer = aDevice.CreateChildContainer();
+    dev->iDestroyObject = aDevice.DestroyObject();
+    dev->iPInfoReceived = aDevice.PInfoReceived();
+    dev->iDLNADeviceType = aDevice.DLNADeviceType();
+    dev->iPrepareForConnection = aDevice.PrepareForConnection();
+    
+    dev->ConstructL();
+    CleanupStack::Pop();
+    return dev;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::NewL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+CUpnpAVDeviceExtended* CUpnpAVDeviceExtended::NewL()
+    {
+    CUpnpAVDeviceExtended* dev = new(ELeave) CUpnpAVDeviceExtended();
+    CleanupStack::PushL( dev );        
+    dev->ConstructL();
+    CleanupStack::Pop();
+    return dev;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::~CUpnpAVDeviceExtended
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+CUpnpAVDeviceExtended::~CUpnpAVDeviceExtended()
+    {
+    delete iIconUrl;
+    iSinkProtocolInfo.ResetAndDestroy();
+    iSourceProtocolInfo.ResetAndDestroy();
+    }
+    
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::CUpnpAVDeviceExtended
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+CUpnpAVDeviceExtended::CUpnpAVDeviceExtended() :
+    CUpnpAVDevice()
+    {     
+    }
+   
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::IncreaseSubscriptionCount
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TInt CUpnpAVDeviceExtended::IncreaseSubscriptionCount()
+    {
+    return ++iSubscriptionCount; 
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::DecreaseSubscriptionCount
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TInt CUpnpAVDeviceExtended::DecreaseSubscriptionCount()
+    {
+    iSubscriptionCount--;
+    if( iSubscriptionCount < 0 )
+        {
+        iSubscriptionCount = 0;
+        }
+    return iSubscriptionCount;    
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SubscriptionCount
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TInt CUpnpAVDeviceExtended::SubscriptionCount() const
+    {
+    return iSubscriptionCount;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::ConstructL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::ConstructL()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetSinkProtocolInfoL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetSinkProtocolInfoL(
+    const TDesC8& aProtocolInfo )
+    {
+    __LOG( "CUpnpAVDeviceExtended::SetSinkProtocolInfoL" );
+    HBufC8* buffer = RemoveIllegalCharactersL( aProtocolInfo );
+    if( buffer )
+        {
+        CleanupStack::PushL( buffer );
+        TLex8 input( *buffer );
+        
+        while( !input.Eos() )
+            {
+            ParseToDelimeter( input, TChar( KProtocolInfoDelimeter ) );
+            CUpnpDlnaProtocolInfo* tmpInfo = NULL;
+            TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL(
+                input.MarkedToken() ) );
+             
+            if( err == KErrNone && tmpInfo )
+                {
+                // Transfer ownership of tmpInfo
+                iSinkProtocolInfo.Append( tmpInfo );
+                }
+            else
+                {
+                __LOG1( "CUpnpDlnaProtocolInfo::NewL failed: %d", err );
+                }
+                
+            if( !input.Eos() )
+                {
+                input.SkipAndMark( 1 ); // Skip the delimeter
+                }
+            }
+        CleanupStack::PopAndDestroy( buffer );
+        }
+    __LOG( "CUpnpAVDeviceExtended::SetSinkProtocolInfoL end" );
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SinkProtocolInfo
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+const RPointerArray<CUpnpDlnaProtocolInfo>&
+    CUpnpAVDeviceExtended::SinkProtocolInfo() const
+    {
+    return iSinkProtocolInfo;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetSourceProtocolInfoL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetSourceProtocolInfoL(
+    const TDesC8& aProtocolInfo )
+    {
+    __LOG( "CUpnpAVDeviceExtended::SetSourceProtocolInfoL" );
+    HBufC8* buffer = RemoveIllegalCharactersL( aProtocolInfo );
+    if( buffer )
+        {
+        CleanupStack::PushL( buffer );
+        TLex8 input( *buffer );
+        
+        while( !input.Eos() )
+            {
+            ParseToDelimeter( input, TChar( KProtocolInfoDelimeter ) );
+            CUpnpDlnaProtocolInfo* tmpInfo = NULL;
+            TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL(
+                input.MarkedToken() ) );
+               
+            if( err == KErrNone && tmpInfo )
+                {
+                // Transfer ownership of tmpInfo
+                iSourceProtocolInfo.Append( tmpInfo );
+                }
+            else
+                {
+                __LOG1( "CUpnpDlnaProtocolInfo::NewL failed: %d", err );
+                }
+                
+            if( !input.Eos() )
+                {
+                input.SkipAndMark( 1 ); // Skip the delimeter
+                }
+            }
+        CleanupStack::PopAndDestroy( buffer );
+        }
+    __LOG( "CUpnpAVDeviceExtended::SetSourceProtocolInfoL end" );
+    }
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SourceProtocolInfo
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+const RPointerArray<CUpnpDlnaProtocolInfo>&
+    CUpnpAVDeviceExtended::SourceProtocolInfo() const
+    {
+    return iSourceProtocolInfo;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetLocal
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetLocal( TBool aLocal )
+    {
+    iLocal = aLocal;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::Local
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::Local() const
+    {
+    return iLocal;
+    }    
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::MatchSinkProtocolInfo
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::MatchSinkProtocolInfo(
+    const TDesC8& aInfo ) const
+    {
+    __LOG( "CUpnpAVDeviceExtended::MatchSinkProtocolInfo" );
+
+    TBool match = EFalse;
+
+    if( DlnaCompatible() && DLNADeviceType() == CUpnpAVDeviceExtended::EDMR )
+        {
+        // The device is DLNA compatible
+        
+        // Try try find PN parameter to determine if it's dlna content
+        if( aInfo.Find( KDlnaPn ) != KErrNotFound )
+            {
+            __LOG( "MatchSinkProtocolInfo - DLNA content and the renderer \
+is DLNA compatible, start matching..." );
+
+            match = MatchSinkProfileId( aInfo );
+            if( !match )
+                {
+                // if profile id was not found try matching mime 
+                match = MatchSinkMime( aInfo );
+                }
+            }
+        else
+            {
+            __LOG( "MatchSinkProtocolInfo - Non DLNA content and the \
+renderer is DLNA compatible, start matching..." );            
+            match = MatchSinkMime( aInfo );
+            }    
+        }
+    else
+        {
+        __LOG( "MatchSinkProtocolInfo - Renderer is not DLNA compatible, \
+start matching..." );            
+        match = MatchSinkMime( aInfo );
+        }    
+        
+    return match;
+    }      
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::MatchSourceProtocolInfo
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::ValidateTransfer(
+    const TDesC8& aInfo ) const
+    {
+    __LOG( "CUpnpAVDeviceExtended::MatchSourceProtocolInfo" );
+
+    // Try try find PN parameter to determine if it's dlna content
+    TBool match = EFalse;
+    if( aInfo.Find( KDlnaPn ) != KErrNotFound )
+        {
+        match = MatchSourceProfileId( aInfo );     
+        }
+
+    return match;
+    }      
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::MatchSinkProfileId
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::MatchSinkProfileId(
+    const TDesC8& aInfo ) const
+    {
+    __LOG( "CUpnpAVDeviceExtended::MatchSinkProfileId" );
+    
+    TBool match = EFalse;
+    CUpnpDlnaProtocolInfo* tmpInfo = NULL;
+    TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo ) );
+    if ( err == KErrNone )
+        {      
+        // Match the first parameter and PN parameter
+        TInt count = iSinkProtocolInfo.Count();
+        for( TInt i = 0; i < count; i++ )
+            {
+            if( iSinkProtocolInfo[ i ]->PnParameter() ==
+                tmpInfo->PnParameter() )
+                {
+                // PN parameter matches, try matching the first
+                // parameter
+                if( iSinkProtocolInfo[ i ]->FirstField() ==
+                    tmpInfo->FirstField() ||
+                    iSinkProtocolInfo[ i ]->FirstField() ==
+                    KAsterisk )
+                    {
+                    __LOG( "MatchSinkProfileId - a match" );
+                    
+                    // We have a match!
+                    i = count;
+                    match = ETrue;
+                    }
+                }     
+            }
+        delete tmpInfo;
+        }            
+    return match;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::MatchSourceProfileId
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::MatchSourceProfileId(
+    const TDesC8& aInfo ) const
+    {
+    __LOG( "CUpnpAVDeviceExtended::MatchSourceProfileId" );
+    
+    TBool match = EFalse;
+    CUpnpDlnaProtocolInfo* tmpInfo = NULL;
+    TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo ) );
+    if ( err == KErrNone )
+        {      
+        // Match the first parameter and PN parameter
+        TInt count = iSourceProtocolInfo.Count();
+        for( TInt i = 0; i < count; i++ )
+            {
+            if( iSourceProtocolInfo[ i ]->PnParameter() ==
+                tmpInfo->PnParameter() )
+                {
+                // PN parameter matches, try matching the first
+                // parameter
+                if( iSourceProtocolInfo[ i ]->FirstField() ==
+                    tmpInfo->FirstField() ||
+                    iSourceProtocolInfo[ i ]->FirstField() ==
+                    KAsterisk )
+                    {
+                    __LOG( "MatchSourceProfileId - a match" );
+                                        
+                    // We have a match!
+                    i = count;
+                    match = ETrue;
+                    }
+                }     
+            }
+        delete tmpInfo;
+        }            
+    return match;
+    }
+   
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::MatchSinkMime
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::MatchSinkMime( const TDesC8& aInfo ) const
+    {
+    __LOG( "CUpnpAVDeviceExtended::MatchSinkMime" );
+
+    TBool match = EFalse;
+    CUpnpDlnaProtocolInfo* tmpInfo = NULL;
+    TRAPD( err, tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo ) );
+    if ( err == KErrNone )
+        {      
+        // Match the first parameter and mime-type
+        TInt count = iSinkProtocolInfo.Count();
+        for( TInt i = 0; i < count; i++ )
+            {
+            if( iSinkProtocolInfo[ i ]->ThirdField() ==
+                tmpInfo->ThirdField() )
+                {
+                // Mime-parameter matches, try matching the first
+                // parameter
+                if( iSinkProtocolInfo[ i ]->FirstField() ==
+                    tmpInfo->FirstField() )
+                    {
+                    __LOG( "MatchSinkMime - a match" );
+                    
+                    // We have a match!
+                    i = count;
+                    match = ETrue;
+                    }
+                }     
+            }
+        delete tmpInfo;
+        }            
+    return match;    
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::FindFirstMatchingInSinkL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+const TDesC8& CUpnpAVDeviceExtended::FindFirstMatchingInSinkL(
+    const CUpnpItem& aItem ) const
+    {
+    __LOG( "CUpnpAVDeviceExtended::FindFirstMatchingInSinkL" );
+    
+    RUPnPElementsArray array;
+    CleanupClosePushL( array );
+    
+    UPnPItemUtility::GetResElements( aItem, array );
+    TBool match = EFalse;
+    TInt i;
+    
+    TInt count = array.Count();
+    for( i = 0; i < count; i ++ )
+        {
+        const CUpnpAttribute& protocolInfo =
+            UPnPItemUtility::FindAttributeByNameL(
+            *array[ i ], KProtocolInfo );
+            
+        if( MatchType( aItem.ObjectClass(), protocolInfo.Value() ) )
+            {
+            if( MatchSinkProtocolInfo( protocolInfo.Value() ) )
+                {
+                // We have a match!
+                __LOG( "FindFirstMatchingInSinkL - a match" );
+                
+                match = ETrue;
+                break;
+                }
+            else
+                {
+                __LOG( "FindFirstMatchingInSinkL - not a match" );
+                }                
+            }
+        else
+            {
+            // Res-elements mime-type does not match to object-class
+            // Ignore
+            __LOG( "FindFirstMatchingInSinkL - Res doesn't match \
+to objectclass" );
+            }              
+        }
+    
+    if( !match )
+        {
+        __LOG( "FindFirstMatchingInSinkL - No match" );
+        
+        User::Leave( KErrNotSupported );
+        }
+    
+    const TDesC8& uri = array[ i ]->Value();
+    
+    CleanupStack::PopAndDestroy( &array );
+    
+    return uri;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::MatchType
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::MatchType( const TDesC8& aObjectClass,
+    const TDesC8& aProtocolInfo ) const
+    {
+    __LOG( "CUpnpAVDeviceExtended::MatchType" );
+    
+    TBool retVal = EFalse;
+    if( aObjectClass.Find( KClassAudio ) == 0 )
+        {
+        if( aProtocolInfo.Find( KAudioSupport ) >= 0 )
+            {
+            retVal = ETrue;
+            }
+        }
+    else if( aObjectClass.Find( KClassImage ) == 0 )
+        {
+        if( aProtocolInfo.Find( KImageSupport ) >= 0 )
+            {
+            retVal = ETrue;
+            }        
+        }
+    else if( aObjectClass.Find( KClassVideo ) == 0 )
+        {
+        if( aProtocolInfo.Find( KVideoSupport ) >= 0 )
+            {
+            retVal = ETrue;
+            }        
+        }
+    else
+        {
+        __PANICD( __FILE__, __LINE__ );
+        }
+    return retVal;        
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetCapabilitiesBySupportedMimeTypesL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetCapabilitiesBySupportedMimeTypesL( 
+    const TDesC8& aListOfMimeTypes )
+    {
+    __LOG( "CUpnpAVDeviceExtended::SetCapabilitiesBySupportedMimeTypesL" );
+    
+    if( aListOfMimeTypes != KNullDesC8 )
+        {
+        // Update the audio media capability
+        if( UPnPCommonUtils::IsAudioSupported( aListOfMimeTypes ) )
+            {
+            iAudioMediaCapability = ETrue;
+            }
+        else
+            {
+            iAudioMediaCapability = EFalse;
+            }
+
+        // Update the audio media capability
+        if( UPnPCommonUtils::IsImageSupported( aListOfMimeTypes ) )
+            {
+            iImageMediaCapability = ETrue;
+            }
+        else
+            {
+            iImageMediaCapability = EFalse;
+            }
+  
+        // Update the video media capability
+        if( UPnPCommonUtils::IsVideoSupported( aListOfMimeTypes ) )
+            {
+            iVideoMediaCapability = ETrue;
+            }
+        else
+            {
+            iVideoMediaCapability = EFalse;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetSourceProtocolInfoL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetSourceProtocolInfoL(
+        const RPointerArray<CUpnpDlnaProtocolInfo>& aProtocolInfo )
+    {
+    __LOG( "CUpnpAVDeviceExtended::SetSourceProtocolInfoL" );
+    
+    for( TInt i = 0; i < aProtocolInfo.Count(); i++ )
+        {
+        CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
+            aProtocolInfo[ i ]->ProtocolInfoL() );
+        iSourceProtocolInfo.Append( tmpInfo ); // Ownership is transferred
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetSinkProtocolInfoL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetSinkProtocolInfoL(
+        const RPointerArray<CUpnpDlnaProtocolInfo>& aProtocolInfo )
+    {
+    __LOG( "CUpnpAVDeviceExtended::SetSinkProtocolInfoL" );
+    
+    for( TInt i = 0; i < aProtocolInfo.Count(); i++ )
+        {
+        CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
+            aProtocolInfo[ i ]->ProtocolInfoL() );
+        iSinkProtocolInfo.Append( tmpInfo ); // Ownership is transferred
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::ParseToDelimeter
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::ParseToDelimeter( TLex8& aLex, TChar aDelimeter )
+    {
+    aLex.Mark();
+
+    TChar chr = 0;
+    TChar edchr = 0;
+
+    while( !aLex.Eos() )
+        {
+        edchr = chr;
+        chr = aLex.Peek();
+        if( chr == aDelimeter && edchr != TChar( KSlash ) )
+            {
+            break;
+            }
+        aLex.Inc();
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::RemoveIllegalCharactersL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+ HBufC8* CUpnpAVDeviceExtended::RemoveIllegalCharactersL(
+    const TDesC8& aPtr ) const
+    {
+    HBufC8* ptrResult = NULL;
+    TInt i = KErrNotFound;
+    if ( aPtr.Length() != 0 )
+        {
+        ptrResult = aPtr.AllocL();
+        CleanupStack::PushL( ptrResult );    
+        TPtr8 ptr = ptrResult->Des();
+        while( ++i < ptr.Length() )
+            {       
+            if( IsIllegalCharacter( ptr[i] ) )
+                {     
+                ptr.Delete( i, 1 );
+                i--;
+                }
+                               
+            }       
+        CleanupStack::Pop( ptrResult );       
+        } 
+    return ptrResult;
+   
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::IsIllegalCharacter
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::IsIllegalCharacter( TChar aCharacter ) const
+    {
+    
+    TBool retVal = EFalse;
+    if ( ( ( aCharacter >= TChar( KUnicodeC0RangeStart ) 
+        && aCharacter <= TChar( KUnicodeC0RangeEnd ) ) 
+        || ( aCharacter >= TChar( KUnicodeC1RangeStart ) 
+        && aCharacter <= TChar( KUnicodeC1RangeEnd ) ) ) )
+        {
+        retVal = ETrue;
+        }
+    return retVal;
+    
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetAudioUpload
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetAudioUpload( TBool aAudioUpload )
+    {
+    iAudioUpload = aAudioUpload;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::AudioUpload
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::AudioUpload() const
+    {
+    return iAudioUpload;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetImageUpload
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetImageUpload( TBool aImageUpload )
+    {
+    iImageUpload = aImageUpload;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::ImageUpload
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::ImageUpload() const
+    {
+    return iImageUpload;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetVideoUpload
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetVideoUpload( TBool aVideoUpload )
+    {
+    iVideoUpload = aVideoUpload;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::VideoUpload
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::VideoUpload() const
+    {
+    return iVideoUpload;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetCreateChildContainer
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetCreateChildContainer(
+    TBool aCreateChildContainer )
+    {
+    iCreateChildContainer = aCreateChildContainer;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::CreateChildContainer
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::CreateChildContainer() const
+    {
+    return iCreateChildContainer;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetDestroyObject
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetDestroyObject( TBool aDestroyObject )
+    {
+    iDestroyObject = aDestroyObject;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::DestroyObject
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::DestroyObject() const
+    {
+    return iDestroyObject;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetPInfoReceived
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetPInfoReceived( TBool aPInfoReceived )
+    {
+    iPInfoReceived = aPInfoReceived;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::PInfoReceived
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::PInfoReceived() const
+    {
+    return iPInfoReceived;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::PrepareForConnection
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TBool CUpnpAVDeviceExtended::PrepareForConnection() const
+    {
+    return iPrepareForConnection;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetPrepareForConnection
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetPrepareForConnection(
+    TBool aPrepareForConnection )
+    {
+    iPrepareForConnection = aPrepareForConnection;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetDLNADeviceType
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetDLNADeviceType( TDLNADeviceType aDeviceType )
+    {
+    iDLNADeviceType = aDeviceType;
+    }
+   
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::DLNADeviceType
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+CUpnpAVDeviceExtended::TDLNADeviceType
+    CUpnpAVDeviceExtended::DLNADeviceType() const
+    {
+    return iDLNADeviceType;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::SetIconUrlL
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+void CUpnpAVDeviceExtended::SetIconUrlL( const TInetAddr& aAddress,
+    const TDesC8& aUrlBase, const TDesC8& aIconUrl )
+    {
+    __LOG8_1( "CUpnpAVDeviceExtended::SetIconUrlL - Base: %S", &aUrlBase );
+    __LOG8_1( "CUpnpAVDeviceExtended::SetIconUrlL - Icon: %S", &aIconUrl );
+    TBuf< KUrlIpBufLen > ip;
+    aAddress.Output( ip );
+    HBufC8* iconUrl = HBufC8::NewL( KUrlHttp().Length() + ip.Length() + 1 + // 1 for colon
+                                    KUrlPortLen + 1 + // 1 for slash
+                                    aUrlBase.Length() + 1 + // 1 for slash
+                                    aIconUrl.Length() );
+    TPtr8 ptr( iconUrl->Des() );
+    if ( aUrlBase.Find( KUrlHttp ) == KErrNotFound )
+        {
+        ptr.Copy( KUrlHttp );
+        ptr.Append( ip );
+        ptr.Append( KUrlColon );
+        ptr.AppendNumUC( aAddress.Port() );
+        }
+    EnsureFinalSlash( ptr );
+
+    TPtrC8 urlBase( RemoveInitial( aUrlBase, KUrlSlash ) ); // Url base without initial slash
+    ptr.Append( urlBase );
+    EnsureFinalSlash( ptr );
+
+    TPtrC8 icon( RemoveInitial( aIconUrl, KUrlSlash ) ); // Icon url without initial slash
+    ptr.Append( RemoveInitial( icon, urlBase ) ); // Remove base from icon url if it already contains base
+
+    delete iIconUrl;
+    iIconUrl = iconUrl;
+
+    __LOG8_1( "CUpnpAVDeviceExtended::SetIconUrlL - Device: %S", &( FriendlyName() ) );
+    __LOG8_1( "CUpnpAVDeviceExtended::SetIconUrlL - Url: %S", iIconUrl );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAVDeviceExtended::IconUrl
+// See upnpavdeviceextended.h
+// --------------------------------------------------------------------------
+TPtrC8 CUpnpAVDeviceExtended::IconUrl() const
+    {
+    return ( iIconUrl ? *iIconUrl : KNullDesC8() );
+    }
+
+// end of file
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpavdispatcher.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpavdispatcher.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1072 +1,269 @@
-/*
-* Copyright (c) 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:      dispatches control point events to AVController clients
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-
-#include "upnpavdispatcher.h"
-
-#include "upnpavactioninfo.h"
-#include "upnpavcontrolpointobserver.h"
-//#include "upnpavcontrollerimpl.h"
-#include "upnpavcontrollerserver.h"
-
-_LIT( KComponentLogfile, "CUPnPAVDispatcher.txt");
-#include "upnplog.h"
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::CUPnPAVDispatcher
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// --------------------------------------------------------------------------
-//
-CUPnPAVDispatcher::CUPnPAVDispatcher( CUpnpAVControllerServer& aServer ) :
-    iServer( aServer )
-    {    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::ConstructL
-// Symbian 2nd phase constructor can leave.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::ConstructL()
-    {                           
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewL
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-CUPnPAVDispatcher* CUPnPAVDispatcher::NewL( CUpnpAVControllerServer& aServer )
-    {
-    CUPnPAVDispatcher* self = NewLC( aServer);
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-CUPnPAVDispatcher* CUPnPAVDispatcher::NewLC(
-    CUpnpAVControllerServer& aServer )
-    {
-    CUPnPAVDispatcher* self = new( ELeave )
-        CUPnPAVDispatcher( aServer );   
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-    
-// Destructor
-CUPnPAVDispatcher::~CUPnPAVDispatcher()
-    {
-    iActionInfos.ResetAndDestroy(); 
-//    iActionInfosDevice.ResetAndDestroy();
-    iActionInfosEvent.ResetAndDestroy();           
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::RcSetVolumeResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr, 
-    const TDesC8& aInstance, 
-    const TDesC8& aChannel, 
-    const TDesC8& aDesiredVolume)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.RcSetVolumeResponse( aUuid, aSessionId, aErr, aInstance, aChannel,
-            aDesiredVolume );        
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::RcVolumeResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr, 
-    const TDesC8& aInstance, 
-    const TDesC8& aChannel, 
-    const TDesC8& aCurrentVolume)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.RcVolumeResponse( aUuid, aSessionId, aErr, aInstance, aChannel,
-            aCurrentVolume );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::RcSetMuteResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr, 
-    const TDesC8& aInstance, 
-    const TDesC8& aChannel, 
-    const TDesC8& aDesiredMute)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-    
-        obs.RcSetMuteResponse( aUuid, aSessionId, aErr, aInstance, aChannel,
-            aDesiredMute );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::RcMuteResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr, 
-    const TDesC8& aInstance, 
-    const TDesC8& aChannel, 
-    const TDesC8& aCurrentMute)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-       
-        obs.RcMuteResponse( aUuid, aSessionId, aErr, aInstance, aChannel,
-            aCurrentMute );
-        }
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtSetTransportUriResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aInstanceId,
-    const TDesC8& aCurrentUri,
-    const TDesC8& aCurrentUriMetaData)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.AvtSetTransportUriResponse( aUuid, aSessionId, aErr, aInstanceId,
-            aCurrentUri, aCurrentUriMetaData );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtSetNextTransportUriResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aInstanceId,
-    const TDesC8& aNextUri,
-    const TDesC8& aNextUriMetaData )
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.AvtSetNextTransportUriResponse( aUuid, aSessionId, aErr,
-            aInstanceId, aNextUri, aNextUriMetaData );
-        }
-    }
-  
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtMediaInfoResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aNrTracks*/,
-    const TDesC8& /*aMediaDuration*/,
-    const TDesC8& /*aCurrentUri*/,
-    const TDesC8& /*aCurrentUriMetaData*/,
-    const TDesC8& /*aNextUri*/,
-    const TDesC8& /*aNextUriMetaData*/,
-    const TDesC8& /*aPlayMedium*/,
-    const TDesC8& /*aRecordMedium*/,
-    const TDesC8& /*aWriteStatus*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtGetTransportInfoResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aCurrenTransportState*/,
-    const TDesC8& /*aCurrentTransportStatus*/,
-    const TDesC8& /*aCurrentSpeed*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtPositionInfoResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aInstanceId,
-    const TDesC8& aTrack,
-    const TDesC8& aTrackDuration,
-    const TDesC8& aTrackMetaData,
-    const TDesC8& aTrackURI,
-    const TDesC8& aRelTime,
-    const TDesC8& aAbsTime,
-    const TDesC8& aRelCount,
-    const TDesC8& aAbsCount)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.AvtPositionInfoResponse( aUuid, aSessionId, aErr,
-            aInstanceId, aTrack, aTrackDuration, aTrackMetaData,
-            aTrackURI, aRelTime, aAbsTime, aRelCount, aAbsCount );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtDeviceCapabilitiesResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aPlayMedia*/,
-    const TDesC8& /*aRecMedia*/,
-    const TDesC8& /*aRecQualityMode*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtTransportSettingsResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aPlayMode*/,
-    const TDesC8& /*aRecQualityMode*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtStopResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aInstanceId)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.AvtStopResponse( aUuid, aSessionId, aErr, aInstanceId );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtPlayResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aInstanceId,
-    const TDesC8& aSpeed)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.AvtPlayResponse( aUuid, aSessionId, aErr, aInstanceId,
-            aSpeed );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtPauseResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aInstanceId)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.AvtPauseResponse( aUuid, aSessionId, aErr, aInstanceId );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtRecordResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtSeekResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aUnit*/,
-    const TDesC8& /*aTarget*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtNextResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtPreviousResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtSetPlayModeResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aNewPlayMode*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtSetRecordModeResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aNewRecordQuality*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsSearchCapabilitiesResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aSearchCaps)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.CdsSearchCapabilitiesResponse( aUuid, aSessionId, aErr,
-            aSearchCaps );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsSortCapabilitiesResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aSortCaps*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsSystemUpdateIdResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    TInt /*aSystemUpdateId*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsBrowseResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aObjectID,
-    const TDesC8&  aBrowseFlag,
-    const TDesC8&  aFilter,
-    TInt aIndex,
-    TInt aRequest,
-    const TDesC8&  aSortCriteria,
-    const TDesC8&  aResult,
-    TInt aReturned,
-    TInt aMatches,
-    const TDesC8&  aUpdateID)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.CdsBrowseResponse( aUuid, aSessionId, aErr, aObjectID,
-            aBrowseFlag, aFilter, aIndex, aRequest, aSortCriteria,
-            aResult, aReturned, aMatches, aUpdateID );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsSearchResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aContainerId,
-    const TDesC8& aSearchCriteria,
-    const TDesC8& aFilter,
-    TInt aIndex,
-    TInt aRequest,
-    const TDesC8& aSortCriteria,
-    const TDesC8& aResult,
-    TInt aReturned,
-    TInt aMatches,
-    const TDesC8& aUpdateID)
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.CdsSearchResponse( aUuid, aSessionId, aErr, aContainerId,
-            aSearchCriteria, aFilter, aIndex, aRequest, aSortCriteria,
-            aResult, aReturned, aMatches, aUpdateID );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsDestroyObjectResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aObjectId )
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.CdsDestroyObjectResponse( aUuid, aSessionId, aErr, aObjectId );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsUpdateObjectResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aObjectId*/,
-    const TDesC8& /*aCurrentTagValue*/,
-    const TDesC8& /*aNewTagValue*/ )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsImportResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aSourceURI,
-    const TDesC8& aDestinationURI,
-    const TDesC8& aTransferId )
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.CdsImportResponse( aUuid, aSessionId, aErr, aSourceURI,
-            aDestinationURI, aTransferId );
-        }
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsExportResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aSourceURI,
-    const TDesC8& aDestinationURI,
-    const TDesC8& aTransferId )
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.CdsExportResponse( aUuid, aSessionId, aErr, aSourceURI,
-            aDestinationURI, aTransferId );
-        }
-    
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsStopTransferResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aTransferId )
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.CdsStopTransferResponse( aUuid, aSessionId, aErr, aTransferId );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsCTransferProgressResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aTransferId,
-    const TDesC8& aTransferStatus,
-    const TDesC8& aTransferLength,            
-    const TDesC8& aTransferTotal )
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.CdsCTransferProgressResponse( aUuid, aSessionId,
-            aErr, aTransferId, aTransferStatus, aTransferLength,
-            aTransferTotal );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsDeleteResourceResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aResourceUri*/ )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsCreateReferenceResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aContainerId*/, 
-    const TDesC8& /*aObjectId*/, 
-    const TDesC8& /*aNewId*/ )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsCreateObjectResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aContainerID, 
-    const TDesC8& aElements, 
-    const TDesC8& aObjectID, 
-    const TDesC8& aResult )
-    {
-    MUpnpAVControlPointObserver& obs = FindObserver( aSessionId );
-    if( &obs )
-        {
-        obs.CdsCreateObjectResponse( aUuid, aSessionId, aErr, aContainerID,
-            aElements, aObjectID, aResult );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CmProtocolInfoResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aSource, 
-    const TDesC8& aSink )
-    {
-    iServer.CmProtocolInfoResponse( aUuid, aSessionId, aErr, aSource, aSink );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CmPrepareResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aRemoteProtocolInfo*/,
-    const TDesC8& /*aPeerConnectionManager*/,
-    const TDesC8& /*aPeerConnectionId*/,
-    const TDesC8& /*aDirection*/,
-    TInt /*aConnection*/,
-    TInt /*aTransport*/,
-    TInt /*aRsc*/ )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CmComplete(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    TInt /*aConnection*/ )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CmCurrentConnections(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aConnections*/)
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CmCurrentInfo(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    TInt /*rscId*/, 
-    TInt /*transportId*/, 
-    const TDesC8& /*aProtocolInfo*/,
-    const TDesC8& /*aPeerConnectionManager*/, 
-    TInt /*peerId*/, 
-    const TDesC8& /*aDirection*/, 
-    const TDesC8& /*aStatus*/ )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsUpdateEvent(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSystemUpdateId*/
-        )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsContainerEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aConteinerIds*/
-        )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CdsTransferEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aTransferIds*/
-        )
-    {
-
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::RcLastChangeEvent(
-        const TDesC8& aUuid,
-        const TDesC8& aLastChange
-        )
-    {
-    // Forward to each observer
-    TInt tempCount = iActionInfosEvent.Count();
-    
-    for( TInt i = 0; i < tempCount; i++ )
-        {
-        if( aUuid == iActionInfosEvent[ i ]->Uuid() )
-            {
-            iActionInfosEvent[ i ]->Observer().RcLastChangeEvent(
-                aUuid, aLastChange );            
-            }
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::AvtLastChangeEvent(
-        const TDesC8& aUuid,
-        const TDesC8& aLastChange
-        )
-    {
-    // Forward to each observer
-    TInt tempCount = iActionInfosEvent.Count();
-    
-    for( TInt i = 0; i < tempCount; i++ )
-        {
-        if( aUuid == iActionInfosEvent[ i ]->Uuid() )
-            {
-            iActionInfosEvent[ i ]->Observer().AvtLastChangeEvent(
-                aUuid, aLastChange );
-            }
-        }
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CmSourceEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aSource*/
-        )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CmSinkEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aSink*/
-        )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::CmConnectionsEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aConnections*/
-        )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::HttpResponseL( CUpnpHttpMessage* /*aMessage*/ )
-    {
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::DeviceDiscoveredL( CUpnpDevice* aDevice )
-    {
-    __ASSERTD( aDevice, __FILE__, __LINE__  )
-    
-    if( aDevice )
-        {
-        iServer.DeviceDiscoveredL( *aDevice );    
-        }
-    else
-        {
-        // No can do?
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAVDispatcher::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPAVDispatcher::DeviceDisappearedL( CUpnpDevice* aDevice )
-    {
-    __ASSERTD( aDevice, __FILE__, __LINE__  );
-    
-    if( aDevice )
-        {
-        iServer.DeviceDisappearedL( *aDevice );    
-        }
-    else
-        {
-        // No can do?
-        }                
-    }
-
-void CUPnPAVDispatcher::RegisterL( TInt aSessionId,
-    MUpnpAVControlPointObserver& aObserver/*, const TDesC8& aUuid*/ )
-    {
-    CUPnPAVActionInfo* tempInfo = CUPnPAVActionInfo::NewLC();
-    tempInfo->SetSessionId( aSessionId );
-    tempInfo->SetObserver( aObserver );
-    //tempInfo->SetUuidL( aUuid );
-    CleanupStack::Pop( tempInfo );
-    iActionInfos.AppendL( tempInfo );
-    }
-
-void CUPnPAVDispatcher::UnRegister( TInt aSessionId
-    /*, const TDesC8& aUuid*/ )
-    {
-    TInt tempCount = iActionInfos.Count();
-    
-    for( TInt i = 0; i < tempCount; i++ )
-        {
-        if( iActionInfos[ i ]->SessionId() == aSessionId )
-            {
-            delete iActionInfos[ i ];
-            iActionInfos.Remove( i );
-            i = tempCount;
-            }
-        }
-    }
-
-MUpnpAVControlPointObserver& CUPnPAVDispatcher::FindObserver(
-    TInt aSessionId )
-    {
-    MUpnpAVControlPointObserver* tempObserver = NULL;
-    TInt tempCount = iActionInfos.Count();
-    
-    for( TInt i = 0; i < tempCount; i++ )
-        {
-        if( iActionInfos[ i ]->SessionId() == aSessionId )
-            {
-            tempObserver = &( iActionInfos[ i ]->Observer() );
-            i = tempCount;
-            }
-        }
-    return *tempObserver;   
-    }
-
-void CUPnPAVDispatcher::RegisterForEventsL(
-    MUpnpAVControlPointObserver& aObserver, const TDesC8& aUuid )
-    {
-    CUPnPAVActionInfo* tempInfo = CUPnPAVActionInfo::NewLC();
-    tempInfo->SetObserver( aObserver );
-    tempInfo->SetUuidL( aUuid );
-    CleanupStack::Pop( tempInfo );
-    iActionInfosEvent.AppendL( tempInfo );        
-    }
-    
-void CUPnPAVDispatcher::UnRegisterEvents(
-    MUpnpAVControlPointObserver& aObserver )
-    {
-    TInt tempCount = iActionInfosEvent.Count();
-    
-    for( TInt i = 0; i < tempCount; i++ )
-        {
-        if( &aObserver == &iActionInfosEvent[ i ]->Observer() )
-            {
-            delete iActionInfosEvent[ i ];
-            iActionInfosEvent.Remove( i );
-            i = tempCount;
-            }
-        }        
-    }
-
-
-// End of File
-
+/*
+* Copyright (c) 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:      dispatches control point events to AVController clients
+*
+*/
+
+
+
+// INCLUDE FILES
+
+#include "upnpavdispatcher.h"
+
+#include "upnpavactioninfo.h"
+#include "upnpavcontrolpointobserver.h"
+#include "upnpavcontrollerserver.h"
+
+_LIT( KComponentLogfile, "CUPnPAVDispatcher.txt");
+#include "upnplog.h"
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::CUPnPAVDispatcher
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// --------------------------------------------------------------------------
+//
+CUPnPAVDispatcher::CUPnPAVDispatcher( CUpnpAVControllerServer& aServer ) :
+    iServer( aServer )
+    {    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::ConstructL
+// Symbian 2nd phase constructor can leave.
+// --------------------------------------------------------------------------
+//
+void CUPnPAVDispatcher::ConstructL()
+    {                           
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::NewL
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+//
+CUPnPAVDispatcher* CUPnPAVDispatcher::NewL( CUpnpAVControllerServer& aServer )
+    {
+    CUPnPAVDispatcher* self = NewLC( aServer);
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::NewLC
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+//
+CUPnPAVDispatcher* CUPnPAVDispatcher::NewLC(
+    CUpnpAVControllerServer& aServer )
+    {
+    CUPnPAVDispatcher* self = new( ELeave )
+        CUPnPAVDispatcher( aServer );   
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+    
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::~CUPnPAVDispatcher
+// --------------------------------------------------------------------------
+//
+CUPnPAVDispatcher::~CUPnPAVDispatcher()
+    {
+    iActionInfos.ResetAndDestroy(); 
+    iActionInfosEvent.ResetAndDestroy();           
+    }
+
+
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::ActionResponseL
+// --------------------------------------------------------------------------
+//
+void CUPnPAVDispatcher::ActionResponseL(CUpnpAction* aAction )
+    {
+    __LOG( "CUPnPAVDispatcher::ActionResponseL" );
+
+    MUpnpAVControlPointObserver& obs = FindObserver( aAction->SessionId() );
+    if( &obs )
+        {
+        obs.ActionResponseL( aAction );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::StateUpdatedL
+// --------------------------------------------------------------------------
+//
+void CUPnPAVDispatcher::StateUpdatedL(CUpnpService* aService)
+    {
+    __LOG( "CUPnPAVDispatcher::StateUpdatedL" );
+
+    // Forward to each observer
+    TInt tempCount = iActionInfosEvent.Count();
+    
+    //We may have multiple sessions to the same device and 
+    //they are all interested about state changes
+    for( TInt i = 0; i < tempCount; i++ )
+        {
+        if( aService->Device().Uuid() == iActionInfosEvent[i]->Uuid() )
+            {
+            iActionInfosEvent[i]->Observer().StateUpdatedL(aService);
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::HttpResponseL
+// --------------------------------------------------------------------------
+//
+void CUPnPAVDispatcher::HttpResponseL( CUpnpHttpMessage* /*aMessage*/ )
+    {
+    //NO IMPLEMENTATION NEEDED
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::DeviceDiscoveredL
+// --------------------------------------------------------------------------
+//
+void CUPnPAVDispatcher::DeviceDiscoveredL( CUpnpDevice* aDevice )
+    {
+    __ASSERT( aDevice, __FILE__, __LINE__  )
+    
+    iServer.DeviceDiscoveredL( *aDevice );    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::DeviceDisappearedL
+// --------------------------------------------------------------------------
+//
+void CUPnPAVDispatcher::DeviceDisappearedL( CUpnpDevice* aDevice )
+    {
+    __ASSERT( aDevice, __FILE__, __LINE__  );
+    
+    iServer.DeviceDisappearedL( *aDevice );    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::RegisterL
+// --------------------------------------------------------------------------
+//
+void CUPnPAVDispatcher::RegisterL( TInt aSessionId,
+    MUpnpAVControlPointObserver& aObserver )
+    {
+    __LOG1( "CUPnPAVDispatcher::RegisterL session: %d", aSessionId );
+
+    CUPnPAVActionInfo* tempInfo = CUPnPAVActionInfo::NewLC();
+    tempInfo->SetSessionId( aSessionId );
+    tempInfo->SetObserver( aObserver );
+    CleanupStack::Pop( tempInfo );
+    iActionInfos.AppendL( tempInfo );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::UnRegister
+// --------------------------------------------------------------------------
+//
+void CUPnPAVDispatcher::UnRegister( TInt aSessionId
+    /*, const TDesC8& aUuid*/ )
+    {
+    __LOG1( "CUPnPAVDispatcher::UnRegister session: %d", aSessionId );
+
+    TInt tempCount = iActionInfos.Count();
+    
+    for( TInt i = 0; i < tempCount; i++ )
+        {
+        if( iActionInfos[ i ]->SessionId() == aSessionId )
+            {
+            delete iActionInfos[ i ];
+            iActionInfos.Remove( i );
+            i = tempCount;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::FindObserver
+// --------------------------------------------------------------------------
+//
+MUpnpAVControlPointObserver& CUPnPAVDispatcher::FindObserver(
+    TInt aSessionId )
+    {
+    MUpnpAVControlPointObserver* tempObserver = NULL;
+    TInt tempCount = iActionInfos.Count();
+    
+    for( TInt i = 0; i < tempCount; i++ )
+        {
+        if( iActionInfos[ i ]->SessionId() == aSessionId )
+            {
+            tempObserver = &( iActionInfos[ i ]->Observer() );
+            i = tempCount;
+            }
+        }
+    return *tempObserver;   
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::RegisterForEventsL
+// --------------------------------------------------------------------------
+//
+void CUPnPAVDispatcher::RegisterForEventsL(
+    MUpnpAVControlPointObserver& aObserver, const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPAVDispatcher::RegisterForEventsL" );
+
+    TInt tempCount = iActionInfosEvent.Count();
+    for( TInt i = 0; i < tempCount; i++ )
+        {
+        if( &aObserver == &iActionInfosEvent[ i ]->Observer() )
+            {
+            // Must not let to register twice!
+            __PANIC( __FILE__, __LINE__ );
+            }
+        }        
+
+    CUPnPAVActionInfo* tempInfo = CUPnPAVActionInfo::NewLC();
+    tempInfo->SetObserver( aObserver );
+    tempInfo->SetUuidL( aUuid );
+    CleanupStack::Pop( tempInfo );
+    iActionInfosEvent.AppendL( tempInfo );        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPAVDispatcher::UnRegisterEvents
+// --------------------------------------------------------------------------
+//
+void CUPnPAVDispatcher::UnRegisterEvents(
+    MUpnpAVControlPointObserver& aObserver )
+    {
+    __LOG( "CUPnPAVDispatcher::UnRegisterEvents" );
+    
+    TInt tempCount = iActionInfosEvent.Count();
+    for( TInt i = 0; i < tempCount; i++ )
+        {
+        if( &aObserver == &iActionInfosEvent[ i ]->Observer() )
+            {
+            delete iActionInfosEvent[ i ];
+            iActionInfosEvent.Remove( i );
+            i = tempCount;
+            }
+        }        
+    }
+
+
+// End of File
+
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpbrowsingsession.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpbrowsingsession.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,2618 +1,1297 @@
-/*
-* Copyright (c) 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:      server impl. of session against media server
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <utf.h> 
-#include <mmf/common/mmfcontrollerpluginresolver.h>
-#include <centralrepository.h>
-
-// upnp stack api
-#include <upnpstring.h>
-#include <upnpdevice.h>
-#include <upnpcontainer.h>
-#include <upnpservice.h>
-#include <upnpitem.h>
-#include <upnpelement.h>
-#include <upnpmediaserversettings.h>
-#include <upnpmediaserverclient.h>
-#include <upnpmediaservernotifier.h>
-#include <upnpfiletransferevent.h>
-
-#include <upnpavcontrolpoint.h>
-
-// upnpframework / avcontroller api
-#include "upnpavrenderingsessionobserver.h"
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h" // for upnp-specific stuff
-#include "upnpfileutility.h"
-#include "upnpitemutility.h"
-
-// upnpframework / xml parser api
-#include "upnpxmlparser.h"
-
-// upnpframework / internal api's
-#include "upnpcontentservercrkeys.h"
-#include "upnpcommonutils.h"
-#include "upnpcdsreselementutility.h"
-#include "upnpmetadatafetcher.h"
-
-// avcontroller internal
-#include "upnpfilesharingactive.h"
-#include "upnpavdispatcher.h"
-#include "upnpavbrowserequest.h"
-#include "upnpavrequest.h"
-#include "upnpaverrorhandler.h"
-#include "upnpavdeviceextended.h"
-#include "upnpdevicerepository.h"
-#include "upnpavbrowserespparams.h"
-#include "upnpavcontrollerserver.h"
-#include "upnpbrowsingsession.h"
-
-// CONSTANTS
-_LIT8( KDirectChildren,         "BrowseDirectChildren" );
-_LIT8( KMetaData,               "BrowseMetadata" );
-_LIT8( KImportUri,              "importUri" );
-_LIT8( KCreateClass,            "upnp:createClass" );
-_LIT8( KBrowseMetadata,         "BrowseMetadata" );
-const TInt KDefaultInstanceId   = 0;
-const TInt KExpectedCount       = 1;
-
-_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
-#include "upnplog.h"
-
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::NewL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-CUPnPBrowsingSession* CUPnPBrowsingSession::NewL
-    (
-    RUpnpMediaServerClient& aClient,
-    CUpnpAVControllerServer& aServer,
-    TInt aSessionId,
-    const TDesC8& aUuid
-    )
-    {
-    CUPnPBrowsingSession* self = new (ELeave) CUPnPBrowsingSession(
-        aClient, aServer, aSessionId );
-    CleanupStack::PushL( self );    
-    
-    self->ConstructL( aUuid );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CUPnPBrowsingSession
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-CUPnPBrowsingSession::CUPnPBrowsingSession
-    (
-    RUpnpMediaServerClient& aClient,
-    CUpnpAVControllerServer& aServer,
-    TInt aSessionId
-    ):
-    iMediaServer( aClient ),
-    iServer( aServer ),
-    iSessionId( aSessionId ),
-    
-    iInstanceId( KDefaultInstanceId ),
-    iIPSessionId( KErrNotFound ),
-
-    iTransferId( KErrNotFound ),
-
-    iTransferEventReceived( EFalse ),
-    iInternalState( ENone ),
-    iCopyState( EIdle )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::~CUPnPBrowsingSession
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-CUPnPBrowsingSession::~CUPnPBrowsingSession()
-    {
-    iIPSessionId = KErrNotFound;
-    
-    delete iDevice;
-    delete iRespBuf;
-    delete iRespBuf2;
-    
-    delete iImportURI;
-    delete iSourceURI;
-    
-    delete iItemId;
-    
-    delete iContainerId;
-    
-    delete iSharedItem;
-    
-    delete iMediaServerNotifier;
-    
-    delete iFileSharing;      
-    
-    delete iLocalMediaServerUuid; 
-    
-    delete iOriginalLocation;
-    
-    delete iFilePath;
-    
-    delete iMSSettings; 
-    delete iAppSettings;
-    
-    delete iActionMessage;
-    delete iDeviceMessage;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::ConstructL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::ConstructL( const TDesC8& aUuid )
-    {
-    __LOG( "CUPnPBrowsingSession::ConstructL" );
-    
-    iMediaServerNotifier = CUpnpMediaServerNotifier::NewL( this );
-    iFileSharing = CUPnPFileSharingActive::NewL();
-
-    // Get the local Media Server Uuid, if available
-    const RPointerArray<CUpnpAVDeviceExtended>& devList =
-        iServer.DeviceRepository().DeviceList();
-    TInt count = devList.Count();
-    TInt i;
-    for( i = 0; i < count; i++ )
-        {
-        if( devList[ i ]->Local() )
-            {
-            __ASSERTD( !iLocalMediaServerUuid, __FILE__, __LINE__ );
-            iLocalMediaServerUuid = devList[i]->Uuid().AllocL();
-            }
-        if( devList[ i ]->Uuid() == aUuid )
-            {
-            __ASSERTD( !iDevice, __FILE__, __LINE__ );
-            iDevice = CUpnpAVDeviceExtended::NewL( *devList[ i ] );
-            }             
-        }
-    if( !iDevice )
-        {
-        if( aUuid == KNullDesC8 ) // Fix to enable AV Controller helper usage
-            {
-            iDevice = CUpnpAVDeviceExtended::NewL();
-            }
-        else
-            {
-            User::Leave( KErrNotFound );    
-            }    
-        }
-        
-    iMSSettings = CUpnpMediaServerSettings::NewL();
-    iAppSettings = CRepository::NewL( KCrUidUpnpContentserver );   
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::RcSetVolumeResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::RcSetVolumeResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/, 
-    const TDesC8& /*aInstance*/, 
-    const TDesC8& /*aChannel*/, 
-    const TDesC8& /*aDesiredVolume*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::RcVolumeResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::RcVolumeResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/, 
-    const TDesC8& /*aInstance*/, 
-    const TDesC8& /*aChannel*/, 
-    const TDesC8& /*aCurrentVolume*/)
-    {
-    // No implementation required                           
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::RcSetMuteResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::RcSetMuteResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/, 
-    const TDesC8& /*aInstance*/, 
-    const TDesC8& /*aChannel*/, 
-    const TDesC8& /*aDesiredMute*/ )
-    {
-    // No implementation required   
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::RcMuteResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::RcMuteResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/, 
-    const TDesC8& /*aInstance*/, 
-    const TDesC8& /*aChannel*/, 
-    const TDesC8& /*aCurrentMute*/ )
-    {
-    // No implementation required                      
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtSetTransportUriResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtSetTransportUriResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aCurrentUri*/,
-    const TDesC8& /*aCurrentUriMetaData*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtSetNextTransportUriResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtSetNextTransportUriResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aNextUri*/,
-    const TDesC8& /*aNextUriMetaData*/)
-    {
-    // No implementation required        
-    }
-  
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtMediaInfoResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtMediaInfoResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aNrTracks*/,
-    const TDesC8& /*aMediaDuration*/,
-    const TDesC8& /*aCurrentUri*/,
-    const TDesC8& /*aCurrentUriMetaData*/,
-    const TDesC8& /*aNextUri*/,
-    const TDesC8& /*aNextUriMetaData*/,
-    const TDesC8& /*aPlayMedium*/,
-    const TDesC8& /*aRecordMedium*/,
-    const TDesC8& /*aWriteStatus*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtGetTransportInfoResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtGetTransportInfoResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aCurrenTransportState*/,
-    const TDesC8& /*aCurrentTransportStatus*/,
-    const TDesC8& /*aCurrentSpeed*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtPositionInfoResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtPositionInfoResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aTrack*/,
-    const TDesC8& /*aTrackDuration*/,
-    const TDesC8& /*aTrackMetaData*/,
-    const TDesC8& /*aTrackURI*/,
-    const TDesC8& /*aRelTime*/,
-    const TDesC8& /*aAbsTime*/,
-    const TDesC8& /*aRelCount*/,
-    const TDesC8& /*aAbsCount*/)
-    {
-    // No implementation required                
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtDeviceCapabilitiesResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtDeviceCapabilitiesResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aPlayMedia*/,
-    const TDesC8& /*aRecMedia*/,
-    const TDesC8& /*aRecQualityMode*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtTransportSettingsResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtTransportSettingsResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aPlayMode*/,
-    const TDesC8& /*aRecQualityMode*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtStopResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtStopResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtPlayResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtPlayResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aSpeed*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtPauseResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtPauseResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtRecordResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtRecordResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtSeekResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtSeekResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aUnit*/,
-    const TDesC8& /*aTarget*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtNextResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtNextResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtPreviousResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtPreviousResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtSetPlayModeResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtSetPlayModeResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aNewPlayMode*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtSetRecordModeResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtSetRecordModeResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aNewRecordQuality*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsSearchCapabilitiesResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsSearchCapabilitiesResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aSearchCaps)
-    {
-    __LOG1( "CUPnPBrowsingSession::CdsSearchCapabilitiesResponse: %d",
-        aErr );
-    
-    __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionId );
-    iIPSessionId = KErrNotFound;
-    //iActionPending = EFalse;
-    
-    if( iActionMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPContentDirectoryError );    
-        
-        if( aErr == KErrNone )
-            {
-            if(  aSearchCaps != KNullDesC8 )
-                {
-                delete iRespBuf; iRespBuf = NULL;
-                iRespBuf = aSearchCaps.Alloc();
-                if( iRespBuf )
-                    {
-                    TPckg<TInt> resp1( aSearchCaps.Length() );
-                    iActionMessage->Write( 1, resp1 );
-                    }
-                else
-                    {
-                    TPckg<TInt> resp1( 0 );
-                    iActionMessage->Write( 1, resp1 );
-                    }
-                
-                iActionMessage->Complete(
-                    EAVControllerGetSearchCapabilitiesSizeCompleted );      
-                delete iActionMessage; iActionMessage = NULL;
-                }
-            else
-                {
-                TPckg<TInt> resp1( 0 );
-                iActionMessage->Write( 1, resp1 );
-
-                iActionMessage->Complete(
-                    EAVControllerGetSearchCapabilitiesSizeCompleted );
-                delete iActionMessage; iActionMessage = NULL;
-                }    
-            }
-        else
-            {
-            iActionMessage->Complete( aErr );
-            delete iActionMessage; iActionMessage = NULL;
-            }        
-        }
-    else
-        {
-        __LOG( "CdsSearchCapabilitiesResponse - no msg" );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsSortCapabilitiesResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsSortCapabilitiesResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aSortCaps*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsSystemUpdateIdResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsSystemUpdateIdResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    TInt /*aSystemUpdateId*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsBrowseResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsBrowseResponse(
-    const TDesC8& aUuid,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aObjectID*/,
-    const TDesC8&  aBrowseFlag,
-    const TDesC8&  /*aFilter*/,
-    TInt /*aIndex*/,
-    TInt /*aRequest*/,
-    const TDesC8&  /*aSortCriteria*/,
-    const TDesC8&  aResult,
-    TInt aReturned,
-    TInt aMatches,
-    const TDesC8&  aUpdateID )
-    {
-    __LOG1( "CUPnPBrowsingSession::CdsBrowseResponse: %d", aErr );
-    
-    __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionId );
-    iIPSessionId = KErrNotFound;
-    
-    if( iActionMessage )
-        {
-        if (  aBrowseFlag.CompareF( KBrowseMetadata ) == 0 && aReturned == 0 
-                && aErr != KErrCouldNotConnect && aErr != KErrHostUnreach )
-            {
-            aErr = ENoSuchObject;  //the file not exist;
-            }
-        
-        if ( aErr != KErrCouldNotConnect && aErr != KErrHostUnreach )
-            {
-            aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPContentDirectoryError );
-            __LOG1( "CUPnPBrowsingSession::CdsBrowseResponse:001 %d", aErr );
-            }    
-    
-        if( aErr == KErrNone )
-            {
-            if(  aResult != KNullDesC8 )
-                {
-                
-                if( iInternalState == ECopyToPhone )
-                    {
-                    TRAP( aErr, SendCreateObjectActionL(
-                        *iLocalMediaServerUuid, KContainerIdAny, aResult ) );
-                    if( aErr )
-                        {
-                        iInternalState = ENone;
-                        iActionMessage->Complete( aErr );
-                        delete iActionMessage; iActionMessage = NULL;
-                        }                    
-                    }
-                else if( iInternalState == ECopyLocal )
-                    {
-                    TRAP( aErr, CheckAndSendCreateObjectActionL( aResult ) );
-                    if( aErr )
-                        {
-                        iInternalState = ENone;
-                        iActionMessage->Complete( aErr );
-                        delete iActionMessage; iActionMessage = NULL;
-                        }
-                    }
-                else if( iInternalState == EDestroyObject )
-                    {
-                    TRAP( aErr, CheckAndSendDestroyObjectActionL( aResult) );
-                    if( aErr )    
-                        {
-                        iInternalState = ENone;
-                        iActionMessage->Complete( aErr );
-                        delete iActionMessage; iActionMessage = NULL;
-                        }
-                    }    
-                else // Browse
-                    {
-                    delete iRespBuf; iRespBuf = NULL;
-                    delete iRespBuf2; iRespBuf2 = NULL;
-                    iRespBuf = aResult.Alloc();
-                    iRespBuf2 = aUpdateID.Alloc();
-                         
-                    if( iRespBuf && iRespBuf2 )
-                        {
-                        TUpnpAVBrowseRespParams params;
-                        TPckg<TUpnpAVBrowseRespParams> resp2( params );
-                        params.iMatches = aReturned ;
-                        params.iTotalCount = aMatches;
-                        params.iResponseSize = aResult.Length();
-                        params.iUpdateIdSize = aUpdateID.Length();
-                        iActionMessage->Write( 2, resp2 );
-                        iActionMessage->Complete( 
-                            EAVControllerGetBrowseResponseSizeCompleted );
-                        }
-                    else
-                        {
-                        delete iRespBuf; iRespBuf = NULL;
-                        delete iRespBuf2; iRespBuf2 = NULL;
-                        iActionMessage->Complete( KErrNoMemory );
-                        }
-                    iInternalState = ENone;
-                    delete iActionMessage; iActionMessage = NULL;      
-                    }    
-                }
-            else
-                {
-                if( iInternalState == EBrowse )
-                    {
-                    TUpnpAVBrowseRespParams params;
-                    TPckg<TUpnpAVBrowseRespParams> resp2( params );
-                    params.iMatches = 0;
-                    params.iTotalCount = 0;
-                    params.iResponseSize = 0;
-                    params.iUpdateIdSize = 0;
-                    iActionMessage->Write( 2, resp2 );
-
-                    iInternalState = ENone;
-                    iActionMessage->Complete(
-                        EAVControllerGetBrowseResponseSizeCompleted );
-                    delete iActionMessage; iActionMessage = NULL;
-                    }
-                else
-                    {
-                    iInternalState = ENone;
-                    iActionMessage->Complete( aErr );
-                    delete iActionMessage; iActionMessage = NULL;
-                    }        
-                }    
-            }
-        else
-            {
-            iInternalState = ENone;
-            iActionMessage->Complete( aErr );
-            delete iActionMessage; iActionMessage = NULL;
-            if ( KErrCouldNotConnect == aErr || KErrHostUnreach == aErr )
-                {                 
-                iServer.DeviceDisappearedL( aUuid );
-                }
-            }            
-        }
-    else
-        {
-        __LOG( "CdsBrowseResponse - no msg" );
-        }    
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsSearchResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsSearchResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aContainerId*/,
-    const TDesC8& /*aSearchCriteria*/,
-    const TDesC8& /*aFilter*/,
-    TInt /*aIndex*/,
-    TInt /*aRequest*/,
-    const TDesC8& /*aSortCriteria*/,
-    const TDesC8& aResult,
-    TInt aReturned,
-    TInt aMatches,
-    const TDesC8& aUpdateID )
-    {
-    __LOG1( "CUPnPBrowsingSession::CdsSearchResponse: %d", aErr );
-    
-    __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionId );
-    //iActionPending = EFalse;
-    iIPSessionId = KErrNotFound;
-    
-    if( iActionMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPContentDirectoryError );    
-        
-        if( aErr == KErrNone )
-            {
-            if(  aResult != KNullDesC8 )
-                {
-                delete iRespBuf; iRespBuf = NULL;
-                delete iRespBuf2; iRespBuf2 = NULL;
-                iRespBuf = aResult.Alloc();
-                iRespBuf2 = aUpdateID.Alloc();
-
-                if( iRespBuf && iRespBuf2 )
-                    {
-                    TUpnpAVBrowseRespParams params;
-                    TPckg<TUpnpAVBrowseRespParams> resp2( params );
-                    params.iMatches = aReturned ;
-                    params.iTotalCount = aMatches;
-                    params.iResponseSize = aResult.Length();
-                    params.iUpdateIdSize = aUpdateID.Length();
-                    iActionMessage->Write( 2, resp2 );                    
-                    iActionMessage->Complete(
-                         EAVControllerGetSearchResponseSizeCompleted );
-                    }
-                else
-                    {
-                    delete iRespBuf; iRespBuf = NULL;
-                    delete iRespBuf2; iRespBuf2 = NULL;
-                    iActionMessage->Complete( KErrNoMemory );
-                    }
-                delete iActionMessage; iActionMessage = NULL;       
-                }
-            else
-                {
-                TUpnpAVBrowseRespParams params;
-                TPckg<TUpnpAVBrowseRespParams> resp2( params );
-                params.iMatches = 0;
-                params.iTotalCount = 0;
-                params.iResponseSize = 0;
-                params.iUpdateIdSize = 0;
-                iActionMessage->Write( 2, resp2 );                    
-
-                iActionMessage->Complete(
-                    EAVControllerGetSearchResponseSizeCompleted );
-                delete iActionMessage; iActionMessage = NULL;       
-                }    
-            }
-        else
-            {
-            iActionMessage->Complete( aErr );
-            delete iActionMessage; iActionMessage = NULL;       
-            }                                     
-        }
-    else
-        {
-        __LOG( "CdsSearchResponse - no msg" );
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsDestroyObjectResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsDestroyObjectResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aObjectId*/ )
-    {
-    __LOG1( "CUPnPBrowsingSession::CdsDestroyObjectResponse: %d", aErr );
-    
-    __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionId );
-    iIPSessionId = KErrNotFound;
-    
-    iInternalState = ENone;
-    
-    if( iActionMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPContentDirectoryError );    
-        
-        if( aErr == KErrNone )
-            {
-            iActionMessage->Complete( EAVControllerDeleteObjectCompleted );
-            delete iActionMessage; iActionMessage = NULL;
-            }
-        else
-            {
-            iActionMessage->Complete( aErr );
-            delete iActionMessage; iActionMessage = NULL;
-            }            
-        }
-    else
-        {
-        __LOG( "CdsDestroyObjectResponse - no msg" );
-        }      
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsUpdateObjectResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsUpdateObjectResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aObjectId*/,
-    const TDesC8& /*aCurrentTagValue*/,
-    const TDesC8& /*aNewTagValue*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsImportResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsImportResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aSourceURI*/,
-    const TDesC8& /*aDestinationURI*/,
-    const TDesC8& aTransferId )
-    {
-    __LOG1( "CUPnPBrowsingSession::CdsImportResponse: %d", aErr );
-    
-    __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionId );
-    iIPSessionId = KErrNotFound;
-    
-    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-        EUPnPContentDirectoryError );    
-    
-    if( aErr == KErrNone )
-        {
-        
-        TLex8 lex( aTransferId );
-        aErr = lex.Val( iTransferId );
-        
-        CopyFinished( aErr, EFalse );
-        }
-    else
-        {
-        CopyFinished( aErr, EFalse );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsExportResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsExportResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aSourceURI*/,
-    const TDesC8& /*aDestinationURI*/,
-    const TDesC8& aTransferId )
-    {
-    __LOG1( "CUPnPBrowsingSession::CdsExportResponse: %d", aErr );
-    
-    __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionId );
-    iIPSessionId = KErrNotFound;
-    
-    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-        EUPnPContentDirectoryError );    
-    
-    if( aErr == KErrNone )
-        {
-        TLex8 lex( aTransferId );
-        aErr = lex.Val( iTransferId );        
-
-        CopyFinished( aErr, EFalse );            
-        }
-    else
-        {
-                    
-        CopyFinished( aErr, EFalse );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsStopTransferResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsStopTransferResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aTransferId*/ )
-    {
-    // No implementation required
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsCTransferProgressResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsCTransferProgressResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aTransferId*/,
-    const TDesC8& /*aTransferStatus*/,
-    const TDesC8& /*aTransferLength*/,            
-    const TDesC8& /*aTransferTotal*/ )
-    { 
-    // No implementation required              
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsDeleteResourceResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsDeleteResourceResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aResourceUri*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsCreateReferenceResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsCreateReferenceResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aContainerId*/, 
-    const TDesC8& /*aObjectId*/, 
-    const TDesC8& /*aNewId*/ )
-    {
-    // No implementation required            
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsCreateObjectResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsCreateObjectResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aContainerID*/, 
-    const TDesC8& /*aElements*/, 
-    const TDesC8& aObjectID, 
-    const TDesC8& aResult )
-    {
-    __LOG1( "CUPnPBrowsingSession::CdsCreateObjectResponse: %d" , aErr );
-    
-    __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionId );
-    //iActionPending = EFalse;
-    iIPSessionId = KErrNotFound;
-    
-    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-        EUPnPContentDirectoryError );
-        
-    if( aErr == KErrNone )
-        {
-        if( iInternalState == ECopyLocal ||
-            iInternalState == ECopyToPhone )
-            {      
-            delete iImportURI; iImportURI = NULL;
-            TRAP( aErr, iImportURI = ParseCreateObjectResponseL( aResult ) );
-            if( aErr == KErrNone )
-                {
-                if( iSourceURI )
-                    {
-                    if( iInternalState == ECopyLocal )
-                        {
-                        // Export from the local Media Server to the
-                        // Remote Media Server
-                        delete iItemId;
-                        iItemId = aObjectID.Alloc(); // Null ok at this point
-                        
-                        TRAP( aErr, SendExportActionL() );
-                        if( aErr )
-                            {
-                            CopyFinished( aErr, EFalse );
-                            }                                          
-                        }
-                    else // iInternalState == ECopyToPhone
-                        {
-                        TRAP( aErr, SendImportActionL() );
-                        if( aErr )
-                            {
-                            CopyFinished( aErr, EFalse );
-                            }
-                        }        
-                    }
-                else
-                    {
-                    CopyFinished( KErrGeneral, EFalse );
-                    }                
-                }
-            else
-                {
-                CopyFinished( aErr, EFalse );
-                } 
-            }
-        else // Create container
-            {
-            if( iActionMessage )
-                {
-                HBufC8* objectID = HBufC8::New( aObjectID.Length() );
-                if( objectID )
-                    {
-                    objectID->Des().Copy( aObjectID );
-                    iActionMessage->Write( 1, *objectID );
-                    iActionMessage->Complete(
-                        EAVControllerCreateContainerCompleted );
-                    delete objectID;                
-                    }
-                else
-                    {
-                    iActionMessage->Write( 1, KNullDesC8 );
-                    iActionMessage->Complete( KErrNoMemory );
-                    }    
-                delete iActionMessage; iActionMessage = NULL;
-                }
-            iInternalState = ENone;                                
-            }                
-        }
-    else
-        {
-        if( iInternalState == ECopyLocal ||
-            iInternalState == ECopyToPhone )
-            {
-            CopyFinished( aErr, EFalse );
-            }
-        else
-            {
-            // Create container failed
-            iInternalState = ENone;
-            iActionMessage->Complete( aErr );
-            delete iActionMessage; iActionMessage = NULL;                    
-            }
-        }                                       
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CmProtocolInfoResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CmProtocolInfoResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aSource*/, 
-    const TDesC8& /*aSink*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CmPrepareResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CmPrepareResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aRemoteProtocolInfo*/,
-   const TDesC8& /*aPeerConnectionManager*/,
-    const TDesC8& /*aPeerConnectionId*/,
-    const TDesC8& /*aDirection*/,
-    TInt /*aConnection*/,
-    TInt /*aTransport*/,
-    TInt /*aRsc*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CmComplete
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CmComplete(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    TInt /*aConnection*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CmCurrentConnections
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CmCurrentConnections(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aConnections*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CmCurrentInfo
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CmCurrentInfo(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    TInt /*rscId*/, 
-    TInt /*transportId*/, 
-    const TDesC8& /*aProtocolInfo*/,
-    const TDesC8& /*aPeerConnectionManager*/, 
-    TInt /*peerId*/, 
-    const TDesC8& /*aDirection*/, 
-    const TDesC8& /*aStatus*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsUpdateEvent
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsUpdateEvent(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSystemUpdateId*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsContainerEvent
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsContainerEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aConteinerIds*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CdsTransferEvent
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CdsTransferEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aTransferIds*/
-        )
-    {
-    // No implementation required
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::RcLastChangeEvent
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::RcLastChangeEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aLastChange*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::AvtLastChangeEvent
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::AvtLastChangeEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aLastChange*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CmSourceEvent
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CmSourceEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aSource*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CmSinkEvent
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CmSinkEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aSink*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CmConnectionsEvent
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CmConnectionsEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aConnections*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::HttpResponseL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::HttpResponseL( CUpnpHttpMessage* /*aMessage*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::DeviceDiscoveredL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::DeviceDiscoveredL( CUpnpDevice* /*aDevice*/ )
-    {
-    // No implementation required            
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::DeviceDisappearedL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::DeviceDisappearedL( CUpnpDevice* /*aDevice*/ )
-    {
-    // No implementation required                  
-    }    
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::FileTransferEvent
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::FileTransferEvent(
-    CUpnpFileTransferEvent *aEvent )
-    {
-    __ASSERTD( aEvent, __FILE__, __LINE__ );
-    
-    __LOG1( "CUPnPBrowsingSession::FileTransferEvent, %d",
-        aEvent->ErrorCode() );
-    
-    TInt err = UPnPAVErrorHandler::ConvertToSymbianErrorCode(
-        aEvent->ErrorCode(), EUPnPContentDirectoryError );    
-
-    if( aEvent->TransferId() == iTransferId )
-        {
-        iTransferId = KErrNotFound;            
-        if( iInternalState == ECopyLocal )
-            {
-            if( iActionMessage )
-                {
-                CopyFinished( err, ETrue );    
-                }
-            else
-                {
-                // Msg not received, set the flag instead
-                iAsyncErr = err;
-                iTransferEventReceived = ETrue;
-                }                  
-            }
-        else if( iInternalState == ECopyToPhone )
-            {                  
-            TRAPD( err, HandleCopyToPhoneEventL( *aEvent, err ) );
-            if ( err )
-                {
-                 __LOG1( "CUPnPBrowsingSession::FileTransferEvent, %d",
-                         err );
-                }                                          
-            }
-        }
-
-    delete aEvent;        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::HandleCopyToPhoneEventL
-// Handle CopyToPhoneEvent,and all leave function will move 
-// to this function
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::HandleCopyToPhoneEventL( 
-         CUpnpFileTransferEvent& aEvent,
-         TInt aError )
-    {
-    HBufC8* filepath = HBufC8::NewL( KMaxPath );
-    CleanupStack::PushL( filepath );
-    
-    HBufC8* eventpath = CnvUtfConverter::ConvertFromUnicodeToUtf8L( 
-        aEvent.FilePath() );
-    filepath->Des().Copy( *eventpath );
-    delete eventpath;
-    eventpath = NULL;
-
-    if ( iActionMessage )
-        {
-        TInt res = iActionMessage->Write( 1, *filepath );
-        if ( res )
-            {
-            __LOG1( "CUPnPBrowsingSession::HandleCopyToPhoneEventL, %d",
-                    res );
-            }
-        // clean up
-        CleanupStack::PopAndDestroy( filepath );
-        }
-    else
-        {
-        iFilePath = filepath;
-        
-        // clean up
-        CleanupStack::Pop( filepath );        
-        }
-
-    if ( iActionMessage )
-        {
-        CopyFinished( aError, ETrue );
-        }
-    else
-        {
-        // Msg not received yet, set the flag instead
-        iAsyncErr = aError;
-        iTransferEventReceived = ETrue;
-        }  
-    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::NotifierError
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::NotifierError( TInt aError )
-    {
-    __LOG( "CUPnPBrowsingSession::NotifierError" );
-    
-    if( iActionMessage )
-        {
-        if( iInternalState == ECopyLocal ||
-            iInternalState == ECopyToPhone )
-            {
-            CopyFinished( aError, ETrue );
-            }
-        }
-    else
-        {
-        // Msg not received yet, set the flag instead
-        iAsyncErr = aError;
-        iTransferEventReceived = ETrue;        
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::DeviceDisappearedL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::DeviceDisappearedL(
-    CUpnpAVDeviceExtended& aDevice )
-    {
-    __LOG( "CUPnPBrowsingSession::DeviceDisappearedL" );
-    
-    if( aDevice.Local() )
-        {
-        delete iLocalMediaServerUuid; iLocalMediaServerUuid = NULL; 
-        }
-    else if( iDeviceMessage ) // Target device
-        {
-        iDeviceMessage->Complete( KErrNone );
-        delete iDeviceMessage; iDeviceMessage = NULL;
-        }     
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::SetLocalMSUuidL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::SetLocalMSUuidL( const TDesC8& aUuid )
-    {
-    HBufC8* tmp = aUuid.AllocL();
-    delete iLocalMediaServerUuid;
-    iLocalMediaServerUuid = tmp; 
-    }
- 
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::SessionId
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-TInt CUPnPBrowsingSession::SessionId() const
-    {
-    return iSessionId;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::Uuid
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-const TDesC8& CUPnPBrowsingSession::Uuid() const
-    {
-    if( iDevice )
-        {
-        return iDevice->Uuid();
-        }
-    else
-        {
-        return KNullDesC8;
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::GetBrowseResponseSizeL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::GetBrowseResponseSizeL(
-    const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPBrowsingSession::GetBrowseResponseSizeL" );
-    
-    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
-
-    ResetL();
-        
-    CUpnpAVBrowseRequest* tmpRequest = CUpnpAVBrowseRequest::NewLC();
-    
-    ReadBrowseReqFromMessageL( aMessage, 1, tmpRequest );
-        
-    if( tmpRequest->BrowseFlag() == MUPnPAVBrowsingSession::EDirectChildren )
-        {
-        iIPSessionId = iServer.ControlPoint().CdsBrowseActionL(
-                iDevice->Uuid(),
-                tmpRequest->Id(),
-                KDirectChildren,
-                tmpRequest->Filter(), 
-                tmpRequest->StartIndex(),
-                tmpRequest->RequestedCount(),
-                tmpRequest->SortCriteria() );        
-        }
-    else
-        {
-        iIPSessionId = iServer.ControlPoint().CdsBrowseActionL(
-                iDevice->Uuid(),
-                tmpRequest->Id(),
-                KMetaData,
-                tmpRequest->Filter(), 
-                tmpRequest->StartIndex(),
-                tmpRequest->RequestedCount(),
-                tmpRequest->SortCriteria() );                
-        }    
-    
-
-    CleanupStack::PopAndDestroy( tmpRequest );
-   
-     if( iIPSessionId > 0 )
-        {
-        // Register
-        iInternalState = EBrowse;
-        iServer.Dispatcher().RegisterL( iIPSessionId, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionId );
-        }
-        
-    iActionMessage = new (ELeave) RMessage2( aMessage );    
-    }
- 
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CancelGetBrowseResponseSizeL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CancelGetBrowseResponseSizeL()
-    {
-    __LOG( "CUPnPBrowsingSession::CancelGetBrowseResponseSizeL" );
-    
-    if( iActionMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionId );
-        iActionMessage->Complete( KErrCancel );
-        delete iActionMessage; iActionMessage = NULL;         
-        }
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::GetBrowseResponseL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::GetBrowseResponseL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPBrowsingSession::GetBrowseResponseL" );
-    
-   __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
-
-    iIPSessionId = KErrNotFound;
-    if( iRespBuf && iRespBuf2 )
-        {
-        aMessage.WriteL( 1, *iRespBuf );
-        aMessage.WriteL( 2, *iRespBuf2 );
-        delete iRespBuf; iRespBuf = NULL;
-        delete iRespBuf2; iRespBuf2 = NULL;
-        aMessage.Complete( EAVControllerGetBrowseResponseCompleted );    
-        }
-    else
-        {
-        //Memory allocaton failed
-        delete iRespBuf; iRespBuf = NULL;
-        delete iRespBuf2; iRespBuf2 = NULL;
-        User::Leave( KErrNoMemory );
-        }
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::GetSearchResponseSizeL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::GetSearchResponseSizeL(
-    const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPBrowsingSession::GetSearchResponseSizeL" );
-    
-    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
-
-    ResetL();
-    
-    
-    CUpnpAVBrowseRequest* tmpRequest = CUpnpAVBrowseRequest::NewLC();
-    
-    ReadBrowseReqFromMessageL( aMessage, 1, tmpRequest );
-  
-    iIPSessionId = iServer.ControlPoint().CdsSearchActionL(
-        iDevice->Uuid(),
-        tmpRequest->Id(),
-        tmpRequest->SearchCriteria(),
-        tmpRequest->Filter(), 
-        tmpRequest->StartIndex(),
-        tmpRequest->RequestedCount(),
-        tmpRequest->SortCriteria() );                
-
-    CleanupStack::PopAndDestroy( tmpRequest );
-    
-     if( iIPSessionId > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionId, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionId );
-        }
-    iActionMessage = new (ELeave) RMessage2( aMessage );      
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CancelGetSearchResponseSizeL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CancelGetSearchResponseSizeL()
-    {
-    __LOG( "CUPnPBrowsingSession::CancelGetSearchResponseSizeL" );
-    
-    if( iActionMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionId );
-        iActionMessage->Complete( KErrCancel );
-        delete iActionMessage; iActionMessage = NULL;               
-        }
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::GetSearchResponseL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::GetSearchResponseL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPBrowsingSession::GetSearchResponseL" );
-    
-    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
-
-    iIPSessionId = KErrNotFound;
-    if( iRespBuf && iRespBuf2 )
-        {
-        aMessage.WriteL( 1, *iRespBuf );
-        aMessage.WriteL( 2, *iRespBuf2 );
-        delete iRespBuf; iRespBuf = NULL;
-        delete iRespBuf2; iRespBuf2 = NULL;
-        aMessage.Complete( EAVControllerGetSearchResponseCompleted );    
-        }
-    else
-        {
-        //Memory allocaton failed
-        delete iRespBuf; iRespBuf = NULL;
-        delete iRespBuf2; iRespBuf2 = NULL;
-        User::Leave( KErrNoMemory );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::GetSearchCapabitiesSizeL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::GetSearchCapabitiesSizeL(
-    const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPBrowsingSession::GetSearchCapabitiesSizeL" );
-    
-    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
-
-    ResetL();
-  
-    iIPSessionId = iServer.ControlPoint().CdsSearchCapabilitiesActionL(
-        iDevice->Uuid() );
-    
-    if( iIPSessionId > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionId, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionId );
-        }
-    iActionMessage = new (ELeave) RMessage2( aMessage );    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CancelGetSearchCapabitiesSizeL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CancelGetSearchCapabitiesSizeL()
-    {
-    __LOG( "CUPnPBrowsingSession::CancelGetSearchCapabitiesSizeL" );
-    
-    if( iActionMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionId );
-        iActionMessage->Complete( KErrCancel );
-        delete iActionMessage; iActionMessage = NULL;                   
-        }
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::GetSearchCapabitiesL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::GetSearchCapabitiesL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPBrowsingSession::GetSearchCapabitiesL" );
-    
-    iIPSessionId = KErrNotFound;
-    
-    aMessage.WriteL( 1, *iRespBuf );
-    aMessage.Complete( EAVControllerGetSearchCapabilitiesCompleted );    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CreateContainerL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CreateContainerL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPBrowsingSession::CreateContainerL" );       
-    
-    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
-    
-    ResetL();
-        
-    // Title
-    TInt len = aMessage.GetDesMaxLength( 1 );
-    HBufC8* tempTitle = HBufC8::NewLC( len );
-    TPtr8 ptr( tempTitle->Des() );
-    aMessage.ReadL( 1, ptr );
-
-    // Container ID
-    len = aMessage.GetDesMaxLength( 2 );
-    HBufC8* tempId = HBufC8::NewLC( len );
-    ptr.Set( tempId->Des() );
-    aMessage.ReadL( 2, ptr );
-    
-    if( iDevice->DlnaCompatible() && !iDevice->CreateChildContainer()
-        && *tempId != KContainerIdAny )
-        {
-        // The device is DLNA compatible and does not support creation
-        // of a child container
-        User::Leave( KErrNotSupported );
-        }
-            
-    // Container type
-    MUPnPAVBrowsingSession::TContainerType type =
-            (MUPnPAVBrowsingSession::TContainerType)aMessage.Int3();
-
-    // Create a container object
-    CUpnpContainer* tmpContainer = CUpnpContainer::NewL();
-    CleanupStack::PushL( tmpContainer );
-    
-    // Set the title and the parent ID
-    tmpContainer->SetTitleL( *tempTitle );
-    tmpContainer->SetParentIdL( *tempId );
-    
-    // Set the object type
-    if( type == MUPnPAVBrowsingSession::EPlaylistContainer )
-        {
-        tmpContainer->SetObjectClassL( KClassPlaylist() );
-        }
-    else
-        {
-        tmpContainer->SetObjectClassL( KClassStorage() );
-        }
-
-    HBufC8* xmlDoc = CUPnPXMLParser::ContainerToXmlLC( *tmpContainer );  
-
-    iIPSessionId = iServer.ControlPoint().CdsCreateObjectActionL(
-        iDevice->Uuid(), *tempId, *xmlDoc );
-
-
-    CleanupStack::PopAndDestroy( xmlDoc );
-    CleanupStack::PopAndDestroy( tmpContainer );
-    CleanupStack::PopAndDestroy( tempId );
-    CleanupStack::PopAndDestroy( tempTitle );
-   
-     if( iIPSessionId > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionId, *this );
-        iInternalState = ECreateContainer; 
-        }
-    else
-        {
-        User::Leave( iIPSessionId );
-        }
-    iActionMessage = new (ELeave) RMessage2( aMessage );         
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CancelCreateContainerL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CancelCreateContainerL()
-    {
-    __LOG( "CUPnPBrowsingSession::CancelCreateContainerL" );       
-    
-    if( iActionMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionId );
-        iActionMessage->Complete( KErrCancel );
-        delete iActionMessage; iActionMessage = NULL;        
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::DeleteObjectL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::DeleteObjectL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPBrowsingSession::DeleteObjectL" );       
-    
-    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
-    
-    ResetL();
-    
-    TInt len = aMessage.GetDesMaxLength( 1 );
-    HBufC8* tempId = HBufC8::NewLC( len );
-    TPtr8 ptr( tempId->Des() );
-    aMessage.ReadL( 1, ptr );
-    
-    CleanupStack::Pop( tempId );
-    delete iItemId;
-    iItemId = tempId;
-    
-            
-    iIPSessionId = iServer.ControlPoint().CdsBrowseActionL(
-        iDevice->Uuid(), *iItemId, KMetaData, KFilterCommon, 0, 1,
-        KNullDesC8 );                
-    
-    if( iIPSessionId > 0 )
-        {
-        // Register
-        iInternalState = EDestroyObject;
-        iServer.Dispatcher().RegisterL( iIPSessionId, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionId );
-        }
-    iActionMessage = new (ELeave) RMessage2( aMessage );   
-    }
-        
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CancelDeleteObjectL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CancelDeleteObjectL()
-    {
-    __LOG( "CUPnPBrowsingSession::CancelDeleteObjectL" );       
-    
-    if( iActionMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionId );
-        iActionMessage->Complete( KErrCancel );    
-        delete iActionMessage; iActionMessage = NULL;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::DeviceDisappearedRequestL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::DeviceDisappearedRequestL(
-    const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPBrowsingSession::DeviceDisappearedRequestL" );       
-    
-    __ASSERTD( !iDeviceMessage, __FILE__, __LINE__ );
-    
-    iDeviceMessage = new (ELeave) RMessage2( aMessage );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CancelDeviceDisappearedRequestL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CancelDeviceDisappearedRequestL()
-    {
-    __LOG( "CUPnPBrowsingSession::CancelDeviceDisappearedRequestL" );       
-    
-    if( iDeviceMessage )
-        {
-        iDeviceMessage->Complete( KErrCancel );    
-        delete iDeviceMessage; iDeviceMessage = NULL;    
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::ParseCreateObjectResponseL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-HBufC8* CUPnPBrowsingSession::ParseCreateObjectResponseL(
-    const TDesC8& aResponse )
-    {
-    __LOG( "CUPnPBrowsingSession::ParseCreateObjectResponseL" );          
-    
-    HBufC8* importURI = NULL;
-    
-    CUPnPXMLParser* parser = CUPnPXMLParser::NewL();
-    CleanupStack::PushL( parser );
-    
-    RPointerArray<CUpnpObject> array;
-    CleanupResetAndDestroyPushL( array );
-    
-    parser->ParseResultDataL( array, aResponse );
-    
-    if( array.Count() == KExpectedCount )
-        {
-        if( array[ 0 ]->ObjectType() == EUPnPItem )
-            {
-            HBufC8* tmp = array[ 0 ]->Id().AllocL(); 
-            delete iItemId;
-            iItemId = tmp;
-            
-            if( array[ 0 ]->ObjectClass().Find( KClassAudio )
-                != KErrNotFound )
-                {
-                iMusic = ETrue;
-                }
-            
-            // Get the res-elements
-            RUPnPElementsArray elArray;
-            CleanupClosePushL( elArray );
-            UPnPItemUtility::GetResElements( *array[ 0 ], elArray );
-            
-            // Find the import uri            
-            for( TInt i = 0; i < elArray.Count(); i++ )
-                {
-                const CUpnpAttribute* attribute = NULL;
-                TRAPD( err, attribute =
-                    &UPnPItemUtility::FindAttributeByNameL(
-                    *elArray[ i ], KImportUri ) );
-                if( err == KErrNone )
-                    {
-                    // import uri found!
-                    i = elArray.Count();
-                    importURI = attribute->Value().AllocL();
-                    }
-                }
-                        
-            CleanupStack::PopAndDestroy( &elArray );
-            }
-        else
-            {
-            User::Leave( KErrGeneral );
-            }    
-        }
-    else
-        {
-        User::Leave( KErrGeneral );
-        }    
-    
-    CleanupStack::PopAndDestroy( &array );
-    CleanupStack::PopAndDestroy( parser );  
-          
-    if( !importURI )
-        {
-        User::Leave( KErrGeneral );
-        }
-    
-    if( !UpnpCdsResElementUtility::IsUriAbsolute( *importURI ) )
-        {
-        // Import uri is not absolute
-        delete importURI; importURI = NULL;
-        User::Leave( KErrGeneral );
-        }
-      
-    return importURI;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CheckIsCreateObjectSupportedL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CheckIsCreateObjectSupportedL(
-    const TDesC8& aResponse )
-    {
-    __LOG( "CUPnPBrowsingSession::CheckIsCreateObjectSupportedL" );
-    
-    CUPnPXMLParser* parser = CUPnPXMLParser::NewL();
-    CleanupStack::PushL( parser );
-    
-    RPointerArray<CUpnpObject> array;
-    CleanupResetAndDestroyPushL( array );
-    
-    parser->ParseResultDataL( array, aResponse );
-    
-    if( array.Count() == KExpectedCount )
-        {
-        if( array[ 0 ]->ObjectType() == EUPnPContainer )
-            {
-            // Try to get upnp:createClass elements
-            const CUpnpElement* elem = UPnPItemUtility::FindElementByName(
-                *array[ 0 ], KCreateClass );
-
-            if ( !elem )
-                {
-                // No createClass elements, copy not supported
-                User::Leave( KErrNotSupported );
-                }
-
-            RUPnPElementsArray resultArray;
-            CleanupClosePushL( resultArray );
-            UPnPItemUtility::GetResElements( *array[ 0 ], resultArray );
-            TInt count = resultArray.Count();
-
-            for( TInt i = 0; i < count; i++ )
-                {
-                if( iSharedItem->ObjectClass().Find( KClassAudio ) !=
-                    KErrNotFound )
-                    {
-                    // We are going to create a music item, check that the
-                    // target container supports that
-                    if( resultArray[ i ]->Value().Find( KClassAudio ) ==
-                    KErrNotFound )
-                        {
-                        User::Leave( KErrNotSupported );
-                        }
-                    }
-                else if( iSharedItem->ObjectClass().Find( KClassImage ) !=
-                    KErrNotFound )
-                    {
-                    // We are going to create an image item, check that the
-                    // target container supports that
-                    if( resultArray[ i ]->Value().Find( KClassImage ) ==
-                    KErrNotFound )
-                        {
-                        User::Leave( KErrNotSupported );
-                        }                    
-                    }
-                else if( iSharedItem->ObjectClass().Find( KClassVideo ) !=
-                    KErrNotFound )
-                    {
-                    // We are going to create a video item, check that the
-                    // target container supports that
-                    if( resultArray[ i ]->Value().Find( KClassVideo ) ==
-                    KErrNotFound )
-                        {
-                        User::Leave( KErrNotSupported );
-                        }                                        
-                    }
-                else
-                    {
-                    // Unknown object class, leave
-                    User::Leave( KErrNotSupported );
-                    }      
-                }                            
-            CleanupStack::PopAndDestroy( &resultArray );
-            }
-        else
-            {
-            User::Leave( KErrNotSupported );
-            }            
-        }
-    else
-        {
-        User::Leave( KErrGeneral );
-        }    
-    CleanupStack::PopAndDestroy( &array );
-    CleanupStack::PopAndDestroy( parser );              
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CheckAndSendDestroyObjectActionL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CheckAndSendDestroyObjectActionL(
-    const TDesC8& aResponse )
-    {
-    __LOG( "CUPnPBrowsingSession::CheckAndSendDestroyObjectActionL" );
-    
-    CUPnPXMLParser* parser = CUPnPXMLParser::NewL();
-    CleanupStack::PushL( parser );
-    
-    RPointerArray<CUpnpObject> array;
-    CleanupResetAndDestroyPushL( array );
-    
-    parser->ParseResultDataL( array, aResponse );
-    
-    if( array.Count() == KExpectedCount )
-        {
-        if( array[ 0 ]->Restricted() )
-            {
-            User::Leave( KErrArgument );
-            }
-        else
-            {
-            // Not restricted, ok to destroy
-            TInt sessionId = iServer.ControlPoint().CdsDestroyObjectActionL(
-                iDevice->Uuid(), *iItemId );
-            if( sessionId > 0 )
-                {
-                iServer.Dispatcher().RegisterL( sessionId, *this );
-                iIPSessionId = sessionId;                   
-                }
-            else
-                {
-                User::Leave( sessionId );
-                }                
-            }    
-        }
-    else
-        {
-        User::Leave( KErrGeneral );
-        }    
-    CleanupStack::PopAndDestroy( &array );
-    CleanupStack::PopAndDestroy( parser );    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CheckAndSendCreateObjectActionL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CheckAndSendCreateObjectActionL( 
-    const TDesC8& aResponse )
-    {
-    __LOG( "CUPnPBrowsingSession::CheckAndSendCreateObjectActionL" );
-      
-    CheckIsCreateObjectSupportedL( aResponse );
-    
-    HBufC8* xmlDoc = CUPnPXMLParser::XmlForCreateObjectLC( *iSharedItem );
-    SendCreateObjectActionL( iDevice->Uuid(), *iContainerId, *xmlDoc );
-    CleanupStack::PopAndDestroy( xmlDoc );   
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::SendCreateObjectActionL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::SendCreateObjectActionL( const TDesC8& aUUid,
-    const TDesC8& aContainerId, const TDesC8& aResponse )
-    {
-    __LOG( "CUPnPBrowsingSession::SendCreateObjectActionL" );
-    
-    TInt sessionId = iServer.ControlPoint().CdsCreateObjectActionL( aUUid,
-        aContainerId, aResponse );
-    
-    if( sessionId > 0 )
-        {
-        iServer.Dispatcher().RegisterL( sessionId, *this );
-        iIPSessionId = sessionId;                   
-        }
-    else
-        {
-        User::Leave( sessionId );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::SendExportActionL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::SendExportActionL()
-    {
-    __LOG( "CUPnPBrowsingSession::SendExportActionL" );
-    //__LOG8( *iSourceURI );
-    //__LOG8( *iImportURI );
-    
-    HBufC8* tempSourceUri = UpnpString::EncodeXmlStringL( 
-                                            iSourceURI );
-    delete iSourceURI;
-    iSourceURI = tempSourceUri;
-    tempSourceUri = NULL;
-    
-    TInt sessionId = iServer.ControlPoint().CdsExportResourceActionL(
-        *iLocalMediaServerUuid, *iSourceURI, *iImportURI );
-    if( sessionId > 0 )
-        {
-        iServer.Dispatcher().RegisterL( sessionId, *this );
-        iIPSessionId = sessionId;
-        }
-    else
-        {
-        User::Leave( sessionId );
-        }
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::SendImportActionL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::SendImportActionL()
-    {
-    __LOG( "CUPnPBrowsingSession::SendImportActionL" );
-    //__LOG8( *iSourceURI );
-    //__LOG8( *iImportURI );
-
-    HBufC8* tempSourceUri = UpnpString::EncodeXmlStringL( 
-                                            iSourceURI );
-    delete iSourceURI;
-    iSourceURI = tempSourceUri;
-    tempSourceUri = NULL;
-    
-    TInt sessionId = iServer.ControlPoint().CdsImportResourceActionL(
-        *iLocalMediaServerUuid, *iSourceURI, *iImportURI );
-    if( sessionId > 0 )
-        {
-        iServer.Dispatcher().RegisterL( sessionId, *this );
-        iIPSessionId = sessionId;
-        }
-    else
-        {
-        User::Leave( sessionId );
-        }    
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CopyFinished
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::CopyFinished( TInt aError, TBool aFinished )
-    {
-    __LOG( "CUPnPBrowsingSession::CopyFinished" );
-          
-    if( iInternalState == ECopyLocal ) // Local to remote copy
-        {
-        if( aError == KErrNone )
-            {
-            if( aFinished )
-                {
-                // Local to remote copy completed successfully!
-
-                if( iSharedItem )
-                    {
-                    // Remove shared item
-                    TRAP_IGNORE( iFileSharing->UnShareItemL(
-                        iSharedItem->Id() ) );    
-                    delete iSharedItem; iSharedItem = NULL;        
-                    }
-
-                iInternalState = ENone;
-                if( iActionMessage )
-                    {
-                    iActionMessage->Complete(
-                        EAVControllerCopyLocalItemFinishCompleted );
-                    delete iActionMessage; iActionMessage = NULL;
-                    }
-                }
-            else
-                {
-                // First phase of copy completed (export action succeeded)
-                if( iActionMessage )
-                    {
-                    iActionMessage->Complete(
-                        EAVControllerCopyLocalItemStartCompleted );
-                    delete iActionMessage; iActionMessage = NULL;
-                    }
-                }                
-            }
-        else // Error occured, cleanup.
-            {
-            if( iSharedItem )
-                {
-                // Remove shared item     
-                TRAP_IGNORE( iFileSharing->UnShareItemL(
-                    iSharedItem->Id() ) );    
-                }
-            delete iSharedItem; iSharedItem = NULL;        
-            if( iItemId )
-                {
-                // Destroy object from the remote media server                
-                TRAP_IGNORE( iServer.ControlPoint().CdsDestroyObjectActionL( 
-                    iDevice->Uuid(), *iItemId ) );
-                delete iItemId; iItemId = NULL;
-                }
-            
-            iInternalState = ENone;
-            if( iActionMessage )
-                {
-                iActionMessage->Complete( aError );
-                delete iActionMessage; iActionMessage = NULL;    
-                }
-            
-            }    
-        }
-    else if( iInternalState == ECopyToPhone ) // Remote to local copy
-        {        
-        if( aError == KErrNone )
-            {
-            if( aFinished )
-                {
-                // Remote to local copy successful, check sharing status
-                CheckSharingStatus();
-                
-                // Restore original download settings
-                RestoreDownloadSettings(); // ignore error
-                                
-                iInternalState = ENone;
-                if( iActionMessage )
-                    {
-                    iActionMessage->Complete(
-                        EAVControllerCopyToPhoneFinishCompleted );
-                    delete iActionMessage; iActionMessage = NULL;
-                    }
-                }
-            else
-                {
-                // First phase of copy completed (import action succeeded)
-                if( iActionMessage )
-                    {
-                    iActionMessage->Complete(
-                        EAVControllerCopyToPhoneStartCompleted );
-                    delete iActionMessage; iActionMessage = NULL;
-                    }
-                }    
-            }
-        else // Error occured, cleanup.
-            {
-            // Restore original download settings
-            RestoreDownloadSettings(); // ignore error
-
-            if( iItemId )
-                {
-                // Destroy object from the local media server
-                TRAP_IGNORE( iServer.ControlPoint().CdsDestroyObjectActionL( 
-                    *iLocalMediaServerUuid, *iItemId ) );
-                delete iItemId; iItemId = NULL;
-                }
-
-            iInternalState = ENone;
-            if( iActionMessage )
-                {
-                iActionMessage->Complete( aError );
-                delete iActionMessage; iActionMessage = NULL;
-                }
-            }        
-        }
-    else
-        {      
-        __PANICD( __FILE__, __LINE__ );     
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::ResetL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::ResetL()
-    {
-    __LOG( "CUPnPBrowsingSession::ResetL" );
-    
-    iIPSessionId = KErrNotFound;
-    
-    if( !iServer.DeviceRepository().IsWlanActive() )    
-        {
-        __LOG( "Reset - disconnected" );
-        User::Leave( KErrDisconnected );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::ReadObjFromMessageL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::ReadObjFromMessageL( const RMessage2& aMessage, 
-    TInt aSlot, CUpnpObject* aObj ) 
-    {
-    // create buffer
-    TInt len = aMessage.GetDesMaxLength( aSlot );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
-    
-    // read stream
-    RDesReadStream stream( *buf );
-    CleanupClosePushL( stream );
-    
-    // internalize object
-    stream >> *aObj;
-    
-    // clean up
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buf );
-    }    
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::ReadReqFromMessageL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::ReadReqFromMessageL( const RMessage2& aMessage, 
-    TInt aSlot, CUpnpAVRequest* aReq ) 
-    {
-    // create buffer
-    TInt len = aMessage.GetDesMaxLength( aSlot );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
-    
-    // read stream
-    RDesReadStream stream( *buf );
-    CleanupClosePushL( stream );
-    
-    // internalize object
-    stream >> *aReq;
-    
-    // clean up
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buf );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::ReadBrowseReqFromMessageL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::ReadBrowseReqFromMessageL(
-    const RMessage2& aMessage, TInt aSlot, CUpnpAVBrowseRequest* aReq ) 
-    {
-    // create buffer
-    TInt len = aMessage.GetDesMaxLength( aSlot );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
-    
-    // read stream
-    RDesReadStream stream( *buf );
-    CleanupClosePushL( stream );
-    
-    // internalize object
-    stream >> *aReq;
-    
-    // clean up
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buf );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::ReadBufFromMessageLC
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-HBufC8* CUPnPBrowsingSession::ReadBufFromMessageLC(
-    const RMessage2& aMessage, TInt aSlot ) 
-    {
-    // create buffer
-    TInt len = aMessage.GetDesMaxLength( aSlot );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );        
-    return buf;
-    }    
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::SetDownloadSettingsL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPBrowsingSession::SetDownloadSettingsL(
-    MUPnPAVBrowsingSession::TMemoryType aType )
-    {
-    if( aType == MUPnPAVBrowsingSession::EDefault )
-        {
-        // Downloading to default location is the only supported target
-        }
-    else
-        {
-        User::Leave( KErrNotSupported );
-        }    
-    
-    // EMemoryCard, ERAMDrive or EPhone are not supported, but the code is
-    // left in place for possible future use
-    /*    
-    // Read the original download location and store it
-    HBufC8* buf = iMSSettings->GetL(
-        UpnpMediaServerSettings::EUploadDirectory );
-    delete iOriginalLocation;
-    iOriginalLocation = buf;
-   
-    // Set the new download location
-    if( aType == MUPnPAVBrowsingSession::EMemoryCard )
-        {
-        User::LeaveIfError( iMSSettings->SetL(
-            UpnpMediaServerSettings::EUploadDirectory,
-            KDownloadMemoryCard ) );
-        }
-    else if( aType == MUPnPAVBrowsingSession::ERAMDrive )
-        {
-        User::LeaveIfError( iMSSettings->SetL(
-            UpnpMediaServerSettings::EUploadDirectory,
-            KDownloadRAMDrive ) );        
-        }
-    else if( aType == MUPnPAVBrowsingSession::EPhone )
-        {
-        User::LeaveIfError( iMSSettings->SetL(
-            UpnpMediaServerSettings::EUploadDirectory,
-            KDownloadPhoneMemory ) );        
-        }
-    else
-        {
-        // Default, no change needed
-        }
-    */    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::RestoreDownloadSettings
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-TInt CUPnPBrowsingSession::RestoreDownloadSettings()
-    {
-    // Restore the download settings
-    TInt err = KErrNone;
-    
-    if( iOriginalLocation && iShareFlag !=
-        MUPnPAVBrowsingSession::EDefault )
-        {
-        TRAP( err, err = iMSSettings->SetL(
-            UpnpMediaServerSettings::EUploadDirectory,
-            *iOriginalLocation ) );        
-        }
-    else
-        {
-        err = KErrGeneral;
-        } 
-            
-    return err;    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPBrowsingSession::CheckSharingStatus
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-TInt CUPnPBrowsingSession::CheckSharingStatus()
-    {
-    TInt err = KErrNone;
-
-    if( iShareFlag == MUPnPAVBrowsingSession::EFileIsNotShared )
-        {
-        // Unshare the item
-        if( iItemId )
-            {
-            TRAP( err, iFileSharing->UnShareItemL( *iItemId ) );
-            delete iItemId; iItemId = NULL;
-            }
-        }
-    else if( MUPnPAVBrowsingSession::EShareBySettings )
-        {
-        // Check settings to determine should we keep the item shared or not
-        TInt share = 0;
-        if( iMusic ) // It's a music item
-            {       
-            err = iAppSettings->Get( KUPnPAppShareAllMusicFiles, share );
-            }
-        else // Image or video item
-            {
-            err = iAppSettings->Get( KUPnPAppShareAllVisualFiles, share );
-            }    
-        
-        if( err == KErrNone && !share )
-            {
-            if( iItemId )
-                {
-                TRAP( err, iFileSharing->UnShareItemL( *iItemId ) );
-                delete iItemId; iItemId = NULL;
-                }            
-            }
-        }
-    else
-        {
-        // File is shared already, do nothing
-        }    
-
-    return err;
-    }
-    
-// End of file
+/*
+* Copyright (c) 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:      server impl. of session against media server
+*
+*/
+
+
+// INCLUDE FILES
+// System
+#include <utf.h> 
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+#include <centralrepository.h>
+
+// upnp stack api
+#include <upnpstring.h>
+#include <upnpdevice.h>
+#include <upnpservice.h>
+
+// dlnasrv / mediaserver api
+#include <upnpcontainer.h>
+#include <upnpitem.h>
+#include <upnpelement.h>
+#include <upnpmediaserversettings.h>
+#include <upnpmediaserverclient.h>
+#include <upnpmediaservernotifier.h>
+#include <upnpfiletransferevent.h>
+
+// dlnasrv / avcontroller api
+#include "upnpavrenderingsessionobserver.h"
+
+// dlnasrv / avcontroller helper api
+#include "upnpconstantdefs.h" // for upnp-specific stuff
+#include "upnpfileutility.h"
+#include "upnpitemutility.h"
+
+// dlnasrv / xmlparser api
+#include "upnpxmlparser.h"
+
+// dlnasrv / internal api's
+#include "upnpcdsreselementutility.h"
+#include "upnpmetadatafetcher.h"
+
+// dlnasrv / avcontroller internal
+#include "upnpavdispatcher.h"
+#include "upnpavbrowserequest.h"
+#include "upnpavrequest.h"
+#include "upnpaverrorhandler.h"
+#include "upnpavdeviceextended.h"
+#include "upnpdevicerepository.h"
+#include "upnpavbrowserespparams.h"
+#include "upnpavcontrollerserver.h"
+#include "upnpavcpstrings.h"
+#include "upnpbrowsingsession.h"
+#include "upnpavcontrolpoint.h"
+
+using namespace UpnpAVCPStrings;
+
+
+// CONSTANTS
+_LIT8( KDirectChildren,         "BrowseDirectChildren" );
+_LIT8( KMetaData,               "BrowseMetadata" );
+_LIT8( KBrowseMetadata,         "BrowseMetadata" );
+_LIT8( KDefaultStartingIndex,   "0" );
+_LIT8( KDefaultRequestedCount,  "1" );
+
+const TInt KDefaultInstanceId   = 0;
+const TInt KExpectedCount       = 1;
+const TInt KMaxIntLength        = 10;
+
+_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
+#include "upnplog.h"
+
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::NewL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+CUPnPBrowsingSession* CUPnPBrowsingSession::NewL
+    (
+    CUpnpAVControllerServer& aServer,
+    TInt aSessionId,
+    const TDesC8& aUuid
+    )
+    {
+    CUPnPBrowsingSession* self = new (ELeave) CUPnPBrowsingSession(
+        aServer, aSessionId );
+    CleanupStack::PushL( self );    
+    
+    self->ConstructL( aUuid );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CUPnPBrowsingSession
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+CUPnPBrowsingSession::CUPnPBrowsingSession
+    (
+    CUpnpAVControllerServer& aServer,
+    TInt aSessionId
+    ):
+    iServer( aServer ),
+    iSessionId( aSessionId ),
+    
+    iInstanceId( KDefaultInstanceId ),
+    iIPSessionId( KErrNotFound ),
+
+    iInternalState( ENone )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::~CUPnPBrowsingSession
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+CUPnPBrowsingSession::~CUPnPBrowsingSession()
+    {
+    iIPSessionId = KErrNotFound;
+    
+    delete iDevice;
+    delete iRespBuf;
+    delete iRespBuf2;
+    
+    delete iItemId;
+    
+    delete iLocalMediaServerUuid; 
+    
+    delete iActionMessage;
+    delete iDeviceMessage;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::ConstructL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::ConstructL( const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPBrowsingSession::ConstructL" );
+
+    // Get the local Media Server Uuid, if available
+    const RPointerArray<CUpnpAVDeviceExtended>& devList =
+        iServer.DeviceRepository().DeviceList();
+    TInt count = devList.Count();
+    TInt i;
+    for( i = 0; i < count; i++ )
+        {
+        if( devList[ i ]->Local() )
+            {
+            __ASSERT( !iLocalMediaServerUuid, __FILE__, __LINE__ );
+            iLocalMediaServerUuid = devList[i]->Uuid().AllocL();
+            }
+        if( devList[ i ]->Uuid() == aUuid )
+            {
+            __ASSERT( !iDevice, __FILE__, __LINE__ );
+            iDevice = CUpnpAVDeviceExtended::NewL( *devList[ i ] );
+            }             
+        }
+    if( !iDevice )
+        {
+        if( aUuid == KNullDesC8 ) // Fix to enable AV Controller helper usage
+            {
+            iDevice = CUpnpAVDeviceExtended::NewL();
+            }
+        else
+            {
+            User::Leave( KErrNotFound );    
+            }    
+        }
+    else
+        {
+        //
+        // Gets related control point device (CUpnpDevice) only if aUuid 
+        // is provided. It is needed when CUpnpAVControlPoint is really 
+        // used.
+        //
+        // In some cases CUPnPBrowsingSession is be instantiated with dummy
+        // device uuid (KNullDesC8). In these cases we shouldn't leave nor
+        // get the control point device.
+        iCpDevice = iServer.ControlPoint().Device( aUuid );
+        if ( !iCpDevice ) 
+            {
+            User::Leave( KErrNotFound );
+            }
+        }
+    }
+
+
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::ActionResponseL
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::ActionResponseL(CUpnpAction* aAction)
+    {
+    __ASSERT( aAction->SessionId()==iIPSessionId, __FILE__, __LINE__ );
+
+    if (aAction->Name().Compare(KGetSearchCapabilities) == 0)
+        {
+        CdsSearchCapabilitiesResponse(
+            aAction->Error(),
+            aAction->ArgumentValue( KSearchCaps ) );
+        }
+    else if (aAction->Name().Compare(KBrowse) == 0)
+        {
+        const TDesC8& numberReturned = aAction->ArgumentValue( 
+                KNumberReturned );
+        TLex8 returnedLex( numberReturned );
+        TInt numberReturnedInt;
+        User::LeaveIfError( returnedLex.Val( numberReturnedInt ) );
+        
+        const TDesC8& totalmatches = aAction->ArgumentValue( KTotalMatches );
+        TLex8 matchesLex( totalmatches );
+        TInt totalMatchesInt;
+        User::LeaveIfError( matchesLex.Val( totalMatchesInt ) );
+   
+        CdsBrowseResponseL(
+            aAction->Error(),
+            aAction->ArgumentValue( KBrowseFlag ),
+            aAction->ArgumentValue( KResult ),
+            numberReturnedInt,
+            totalMatchesInt,
+            aAction->ArgumentValue( KUpdateID ) );
+        }
+    else if (aAction->Name().Compare(KSearch) == 0)
+        {		
+        const TDesC8& numberReturned = aAction->ArgumentValue( 
+                KNumberReturned );
+        TLex8 returnedLex( numberReturned );
+        TInt numberReturnedInt;
+        User::LeaveIfError( returnedLex.Val( numberReturnedInt ) );
+
+        const TDesC8& totalmatches = aAction->ArgumentValue( KTotalMatches );
+        TLex8 matchesLex( totalmatches );
+        TInt totalMatchesInt;
+        User::LeaveIfError( matchesLex.Val( totalMatchesInt ) );
+
+        CdsSearchResponse(
+            aAction->Error(),
+            aAction->ArgumentValue( KResult ),
+            numberReturnedInt,
+            totalMatchesInt,
+            aAction->ArgumentValue( KUpdateID )
+            );
+        }
+    else if (aAction->Name().Compare(KDestroyObject) == 0)
+        {		
+        CdsDestroyObjectResponse(
+            aAction->Error() );
+        }
+    else if (aAction->Name().Compare(KCreateObject) == 0)
+        {
+        CdsCreateObjectResponse(
+            aAction->Error(),
+            aAction->ArgumentValue(KObjectID), 
+            aAction->ArgumentValue(KResult)
+            );
+        }
+    else
+        {
+        __LOG( "response not expected, ignore" );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::StateUpdatedL
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::StateUpdatedL(CUpnpService* /*aService*/)
+    {
+    // No implementation required        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::HttpResponseL
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::HttpResponseL(CUpnpHttpMessage* /*aMessage*/)
+    {
+    // No implementation required        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::DeviceDiscoveredL
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::DeviceDiscoveredL(CUpnpDevice* /*aDevice*/)
+    {
+    // No implementation required        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::DeviceDisappearedL
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::DeviceDisappearedL(CUpnpDevice* /*aDevice*/)
+    {
+    // No implementation required        
+    }
+
+
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CdsSearchCapabilitiesResponse
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CdsSearchCapabilitiesResponse(
+    TInt aErr,
+    const TDesC8& aSearchCaps)
+    {
+    __LOG1( "CUPnPBrowsingSession::CdsSearchCapabilitiesResponse: %d",
+        aErr );
+
+    iServer.Dispatcher().UnRegister( iIPSessionId );
+    iIPSessionId = KErrNotFound;
+    
+    if( iActionMessage )
+        {
+        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPContentDirectoryError );    
+        
+        if( aErr == KErrNone )
+            {
+            if(  aSearchCaps != KNullDesC8 )
+                {
+                delete iRespBuf; iRespBuf = NULL;
+                iRespBuf = aSearchCaps.Alloc();
+                if( iRespBuf )
+                    {
+                    TPckgBuf<TInt> resp1( aSearchCaps.Length() );
+                    iActionMessage->Write( 1, resp1 );
+                    }
+                else
+                    {
+                    TPckgBuf<TInt> resp1( 0 );
+                    iActionMessage->Write( 1, resp1 );
+                    }
+                
+                iActionMessage->Complete(
+                    EAVControllerGetSearchCapabilitiesSizeCompleted );      
+                delete iActionMessage; iActionMessage = NULL;
+                }
+            else
+                {
+                TPckgBuf<TInt> resp1( 0 );
+                iActionMessage->Write( 1, resp1 );
+
+                iActionMessage->Complete(
+                    EAVControllerGetSearchCapabilitiesSizeCompleted );
+                delete iActionMessage; iActionMessage = NULL;
+                }    
+            }
+        else
+            {
+            iActionMessage->Complete( aErr );
+            delete iActionMessage; iActionMessage = NULL;
+            }        
+        }
+    else
+        {
+        __LOG( "CdsSearchCapabilitiesResponse - no msg" );
+        }
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CdsBrowseResponseL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CdsBrowseResponseL(
+    TInt aErr,
+    const TDesC8&  aBrowseFlag,
+    const TDesC8&  aResult,
+    TInt aReturned,
+    TInt aMatches,
+    const TDesC8&  aUpdateID )
+    {
+    __LOG1( "CUPnPBrowsingSession::CdsBrowseResponseL: %d", aErr );
+
+    iServer.Dispatcher().UnRegister( iIPSessionId );
+    iIPSessionId = KErrNotFound;
+    
+    if( iActionMessage )
+        {
+        if (  aBrowseFlag.CompareF( KBrowseMetadata ) == 0 && aReturned == 0 
+                && aErr != KErrCouldNotConnect && aErr != KErrHostUnreach )
+            {
+            aErr = ENoSuchObject;  //the file not exist;
+            }
+        
+        if ( aErr != KErrCouldNotConnect && aErr != KErrHostUnreach )
+            {
+            aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPContentDirectoryError );
+            __LOG1( "CUPnPBrowsingSession::CdsBrowseResponseL:001 %d", 
+                    aErr );
+            }    
+    
+        if( aErr == KErrNone )
+            {
+            if( aResult != KNullDesC8 )
+                {
+                if( iInternalState == EDestroyObject )
+                    {
+                    TRAP( aErr, CheckAndSendDestroyObjectActionL( aResult) );
+                    if( aErr )    
+                        {
+                        iInternalState = ENone;
+                        iActionMessage->Complete( aErr );
+                        delete iActionMessage; iActionMessage = NULL;
+                        }
+                    }    
+                else // Browse
+                    {
+                    delete iRespBuf; iRespBuf = NULL;
+                    delete iRespBuf2; iRespBuf2 = NULL;
+                    iRespBuf = aResult.Alloc();
+                    iRespBuf2 = aUpdateID.Alloc();
+                         
+                    if( iRespBuf && iRespBuf2 )
+                        {
+                        TUpnpAVBrowseRespParams params;
+                        TPckg<TUpnpAVBrowseRespParams> resp2( params );
+                        params.iMatches = aReturned ;
+                        params.iTotalCount = aMatches;
+                        params.iResponseSize = aResult.Length();
+                        params.iUpdateIdSize = aUpdateID.Length();
+                        iActionMessage->Write( 2, resp2 );
+                        iActionMessage->Complete( 
+                            EAVControllerGetBrowseResponseSizeCompleted );
+                        }
+                    else
+                        {
+                        delete iRespBuf; iRespBuf = NULL;
+                        delete iRespBuf2; iRespBuf2 = NULL;
+                        iActionMessage->Complete( KErrNoMemory );
+                        }
+                    iInternalState = ENone;
+                    delete iActionMessage; iActionMessage = NULL;      
+                    }    
+                }
+            else
+                {
+                if( iInternalState == EBrowse )
+                    {
+                    TUpnpAVBrowseRespParams params;
+                    TPckg<TUpnpAVBrowseRespParams> resp2( params );
+                    params.iMatches = 0;
+                    params.iTotalCount = 0;
+                    params.iResponseSize = 0;
+                    params.iUpdateIdSize = 0;
+                    iActionMessage->Write( 2, resp2 );
+
+                    iInternalState = ENone;
+                    iActionMessage->Complete(
+                        EAVControllerGetBrowseResponseSizeCompleted );
+                    delete iActionMessage; iActionMessage = NULL;
+                    }
+                else
+                    {
+                    iInternalState = ENone;
+                    iActionMessage->Complete( aErr );
+                    delete iActionMessage; iActionMessage = NULL;
+                    }        
+                }    
+            }
+        else
+            {
+            iInternalState = ENone;
+            iActionMessage->Complete( aErr );
+            delete iActionMessage; iActionMessage = NULL;
+            if ( KErrCouldNotConnect == aErr || KErrHostUnreach == aErr )
+                {
+                iServer.DeviceDisappearedL( iDevice->Uuid() );
+                }
+            }            
+        }
+    else
+        {
+        __LOG( "CdsBrowseResponseL - no msg" );
+        }    
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CdsSearchResponse
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CdsSearchResponse(
+    TInt aErr,
+    const TDesC8& aResult,
+    TInt aReturned,
+    TInt aMatches,
+    const TDesC8& aUpdateID )
+    {
+    __LOG1( "CUPnPBrowsingSession::CdsSearchResponse: %d", aErr );
+
+    iServer.Dispatcher().UnRegister( iIPSessionId );
+    iIPSessionId = KErrNotFound;
+    
+    if( iActionMessage )
+        {
+        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPContentDirectoryError );    
+        
+        if( aErr == KErrNone )
+            {
+            if(  aResult != KNullDesC8 )
+                {
+                delete iRespBuf; iRespBuf = NULL;
+                delete iRespBuf2; iRespBuf2 = NULL;
+                iRespBuf = aResult.Alloc();
+                iRespBuf2 = aUpdateID.Alloc();
+
+                if( iRespBuf && iRespBuf2 )
+                    {
+                    TUpnpAVBrowseRespParams params;
+                    TPckg<TUpnpAVBrowseRespParams> resp2( params );
+                    params.iMatches = aReturned ;
+                    params.iTotalCount = aMatches;
+                    params.iResponseSize = aResult.Length();
+                    params.iUpdateIdSize = aUpdateID.Length();
+                    iActionMessage->Write( 2, resp2 );                    
+                    iActionMessage->Complete(
+                         EAVControllerGetSearchResponseSizeCompleted );
+                    }
+                else
+                    {
+                    delete iRespBuf; iRespBuf = NULL;
+                    delete iRespBuf2; iRespBuf2 = NULL;
+                    iActionMessage->Complete( KErrNoMemory );
+                    }
+                delete iActionMessage; iActionMessage = NULL;       
+                }
+            else
+                {
+                TUpnpAVBrowseRespParams params;
+                TPckg<TUpnpAVBrowseRespParams> resp2( params );
+                params.iMatches = 0;
+                params.iTotalCount = 0;
+                params.iResponseSize = 0;
+                params.iUpdateIdSize = 0;
+                iActionMessage->Write( 2, resp2 );                    
+
+                iActionMessage->Complete(
+                    EAVControllerGetSearchResponseSizeCompleted );
+                delete iActionMessage; iActionMessage = NULL;       
+                }    
+            }
+        else
+            {
+            iActionMessage->Complete( aErr );
+            delete iActionMessage; iActionMessage = NULL;       
+            }                                     
+        }
+    else
+        {
+        __LOG( "CdsSearchResponse - no msg" );
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CdsDestroyObjectResponse
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CdsDestroyObjectResponse(
+    TInt aErr )
+    {
+    __LOG1( "CUPnPBrowsingSession::CdsDestroyObjectResponse: %d", aErr );
+
+    iServer.Dispatcher().UnRegister( iIPSessionId );
+    iIPSessionId = KErrNotFound;
+
+    iInternalState = ENone;
+    
+    if( iActionMessage )
+        {
+        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPContentDirectoryError );    
+        
+        if( aErr == KErrNone )
+            {
+            iActionMessage->Complete( EAVControllerDeleteObjectCompleted );
+            delete iActionMessage; iActionMessage = NULL;
+            }
+        else
+            {
+            iActionMessage->Complete( aErr );
+            delete iActionMessage; iActionMessage = NULL;
+            }            
+        }
+    else
+        {
+        __LOG( "CdsDestroyObjectResponse - no msg" );
+        }      
+    }
+
+
+
+
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CdsCreateObjectResponse
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CdsCreateObjectResponse(
+    TInt aErr,
+    const TDesC8& aObjectID, 
+    const TDesC8& /*aResult*/ )
+    {
+    __LOG1( "CUPnPBrowsingSession::CdsCreateObjectResponse: %d" , aErr );
+    
+    iServer.Dispatcher().UnRegister( iIPSessionId );
+    iIPSessionId = KErrNotFound;
+    
+    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+        EUPnPContentDirectoryError );
+
+    if( aErr == KErrNone )
+        {
+        if( iActionMessage )
+            {
+            HBufC8* objectID = HBufC8::New( aObjectID.Length() );
+            if( objectID )
+                {
+                objectID->Des().Copy( aObjectID );
+                iActionMessage->Write( 1, *objectID );
+                iActionMessage->Complete(
+                    EAVControllerCreateContainerCompleted );
+                delete objectID;                
+                }
+            else
+                {
+                iActionMessage->Write( 1, KNullDesC8 );
+                iActionMessage->Complete( KErrNoMemory );
+                }    
+            delete iActionMessage; iActionMessage = NULL;
+            }
+        iInternalState = ENone;                                
+        }
+    else
+        {
+        // Create container failed
+        iInternalState = ENone;
+        iActionMessage->Complete( aErr );
+        delete iActionMessage; iActionMessage = NULL;                    
+        }                                       
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::DeviceDisappearedL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::DeviceDisappearedL(
+    CUpnpAVDeviceExtended& aDevice )
+    {
+    __LOG( "CUPnPBrowsingSession::DeviceDisappearedL" );
+
+    if( aDevice.Local() )
+        {
+        delete iLocalMediaServerUuid; iLocalMediaServerUuid = NULL; 
+        }
+    else if( iDeviceMessage ) // Target device
+        {
+        iDeviceMessage->Complete( KErrNone );
+        delete iDeviceMessage; iDeviceMessage = NULL;
+        }     
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::SetLocalMSUuidL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::SetLocalMSUuidL( const TDesC8& aUuid )
+    {
+    HBufC8* tmp = aUuid.AllocL();
+    delete iLocalMediaServerUuid;
+    iLocalMediaServerUuid = tmp; 
+    }
+ 
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::SessionId
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+TInt CUPnPBrowsingSession::SessionId() const
+    {
+    return iSessionId;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::Uuid
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+const TDesC8& CUPnPBrowsingSession::Uuid() const
+    {
+    if( iDevice )
+        {
+        return iDevice->Uuid();
+        }
+    else
+        {
+        return KNullDesC8;
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::GetBrowseResponseSizeL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::GetBrowseResponseSizeL(
+    const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPBrowsingSession::GetBrowseResponseSizeL" );
+    
+    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
+
+    ResetL();
+        
+    CUpnpAVBrowseRequest* tmpRequest = CUpnpAVBrowseRequest::NewLC();
+    
+    ReadBrowseReqFromMessageL( aMessage, 1, tmpRequest );
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            iCpDevice, KContentDirectory, KBrowse );
+    
+    TBuf8<KMaxIntLength> startingIndexStr;
+    startingIndexStr.Num(tmpRequest->StartIndex());
+    TBuf8<KMaxIntLength> requestedCountStr;
+    requestedCountStr.Num(tmpRequest->RequestedCount());
+    action->SetArgumentL( KObjectID, tmpRequest->Id() );
+    if( tmpRequest->BrowseFlag() == MUPnPAVBrowsingSession::EDirectChildren )
+        {
+        action->SetArgumentL( KBrowseFlag, KDirectChildren ); 
+        }
+    else
+        {
+        action->SetArgumentL( KBrowseFlag, KMetaData ); 
+        }
+    action->SetArgumentL( KFilter, tmpRequest->Filter() ); 
+    action->SetArgumentL( KStartingIndex, startingIndexStr ); 
+    action->SetArgumentL( KRequestedCount, requestedCountStr ); 
+    action->SetArgumentL( 
+            UpnpAVCPStrings::KSortCriteria, 
+            tmpRequest->SortCriteria() ); 
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionId = action->SessionId();
+    CleanupStack::PopAndDestroy( tmpRequest );
+   
+    // Register
+    iInternalState = EBrowse;
+    iServer.Dispatcher().RegisterL( iIPSessionId, *this );
+    iActionMessage = new (ELeave) RMessage2( aMessage );    
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CancelGetBrowseResponseSizeL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CancelGetBrowseResponseSizeL()
+    {
+    __LOG( "CUPnPBrowsingSession::CancelGetBrowseResponseSizeL" );
+    
+    if( iActionMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionId );
+        iActionMessage->Complete( KErrCancel );
+        delete iActionMessage; iActionMessage = NULL;         
+        }
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::GetBrowseResponseL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::GetBrowseResponseL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPBrowsingSession::GetBrowseResponseL" );
+    
+   __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
+
+    iIPSessionId = KErrNotFound;
+    if( iRespBuf && iRespBuf2 )
+        {
+        aMessage.WriteL( 1, *iRespBuf );
+        aMessage.WriteL( 2, *iRespBuf2 );
+        delete iRespBuf; iRespBuf = NULL;
+        delete iRespBuf2; iRespBuf2 = NULL;
+        aMessage.Complete( EAVControllerGetBrowseResponseCompleted );    
+        }
+    else
+        {
+        //Memory allocaton failed
+        delete iRespBuf; iRespBuf = NULL;
+        delete iRespBuf2; iRespBuf2 = NULL;
+        User::Leave( KErrNoMemory );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::GetSearchResponseSizeL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::GetSearchResponseSizeL(
+    const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPBrowsingSession::GetSearchResponseSizeL" );
+    
+    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
+
+    ResetL();
+    
+    CUpnpAVBrowseRequest* tmpRequest = CUpnpAVBrowseRequest::NewLC();
+    
+    ReadBrowseReqFromMessageL( aMessage, 1, tmpRequest );
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            iCpDevice, KContentDirectory, KSearch );
+    
+    TBuf8<KMaxIntLength> startingIndexStr;
+    startingIndexStr.Num(tmpRequest->StartIndex());
+    TBuf8<KMaxIntLength> requestedCountStr;
+    requestedCountStr.Num(tmpRequest->RequestedCount());
+    action->SetArgumentL( KContainerID, tmpRequest->Id() );
+    action->SetArgumentL( KSearchCriteria, tmpRequest->SearchCriteria() ); 
+    action->SetArgumentL( KFilter, tmpRequest->Filter() ); 
+    action->SetArgumentL( KStartingIndex, startingIndexStr ); 
+    action->SetArgumentL( KRequestedCount, requestedCountStr ); 
+    action->SetArgumentL( 
+            UpnpAVCPStrings::KSortCriteria, 
+            tmpRequest->SortCriteria() ); 
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionId = action->SessionId();
+    CleanupStack::PopAndDestroy( tmpRequest );
+
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionId, *this );
+    iActionMessage = new (ELeave) RMessage2( aMessage );      
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CancelGetSearchResponseSizeL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CancelGetSearchResponseSizeL()
+    {
+    __LOG( "CUPnPBrowsingSession::CancelGetSearchResponseSizeL" );
+    
+    if( iActionMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionId );
+        iActionMessage->Complete( KErrCancel );
+        delete iActionMessage; iActionMessage = NULL;               
+        }
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::GetSearchResponseL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::GetSearchResponseL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPBrowsingSession::GetSearchResponseL" );
+    
+    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
+
+    iIPSessionId = KErrNotFound;
+    if( iRespBuf && iRespBuf2 )
+        {
+        aMessage.WriteL( 1, *iRespBuf );
+        aMessage.WriteL( 2, *iRespBuf2 );
+        delete iRespBuf; iRespBuf = NULL;
+        delete iRespBuf2; iRespBuf2 = NULL;
+        aMessage.Complete( EAVControllerGetSearchResponseCompleted );    
+        }
+    else
+        {
+        //Memory allocaton failed
+        delete iRespBuf; iRespBuf = NULL;
+        delete iRespBuf2; iRespBuf2 = NULL;
+        User::Leave( KErrNoMemory );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::GetSearchCapabitiesSizeL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::GetSearchCapabitiesSizeL(
+    const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPBrowsingSession::GetSearchCapabitiesSizeL" );
+    
+    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
+
+    ResetL();
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            iCpDevice, KContentDirectory, KGetSearchCapabilities );
+    
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionId = action->SessionId();
+
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionId, *this );
+    iActionMessage = new (ELeave) RMessage2( aMessage );    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CancelGetSearchCapabitiesSizeL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CancelGetSearchCapabitiesSizeL()
+    {
+    __LOG( "CUPnPBrowsingSession::CancelGetSearchCapabitiesSizeL" );
+    
+    if( iActionMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionId );
+        iActionMessage->Complete( KErrCancel );
+        delete iActionMessage; iActionMessage = NULL;                   
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::GetSearchCapabitiesL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::GetSearchCapabitiesL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPBrowsingSession::GetSearchCapabitiesL" );
+    
+    iIPSessionId = KErrNotFound;
+    
+    aMessage.WriteL( 1, *iRespBuf );
+    aMessage.Complete( EAVControllerGetSearchCapabilitiesCompleted );    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CreateContainerL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CreateContainerL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPBrowsingSession::CreateContainerL" );       
+    
+    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
+    
+    ResetL();
+
+    // Title
+    TInt len = aMessage.GetDesMaxLength( 1 );
+    HBufC8* tempTitle = HBufC8::NewLC( len );
+    TPtr8 ptr( tempTitle->Des() );
+    aMessage.ReadL( 1, ptr );
+
+    // Container ID
+    len = aMessage.GetDesMaxLength( 2 );
+    HBufC8* tempId = HBufC8::NewLC( len );
+    ptr.Set( tempId->Des() );
+    aMessage.ReadL( 2, ptr );
+    
+    if( iDevice->DlnaCompatible() && !iDevice->CreateChildContainer()
+        && *tempId != KContainerIdAny )
+        {
+        // The device is DLNA compatible and does not support creation
+        // of a child container
+        User::Leave( KErrNotSupported );
+        }
+            
+    // Container type
+    MUPnPAVBrowsingSession::TContainerType type =
+            (MUPnPAVBrowsingSession::TContainerType)aMessage.Int3();
+
+    // Create a container object
+    CUpnpContainer* tmpContainer = CUpnpContainer::NewL();
+    CleanupStack::PushL( tmpContainer );
+    
+    // Set the title and the parent ID
+    tmpContainer->SetTitleL( *tempTitle );
+    tmpContainer->SetParentIdL( *tempId );
+    
+    // Set the object type
+    if( type == MUPnPAVBrowsingSession::EPlaylistContainer )
+        {
+        tmpContainer->SetObjectClassL( KClassPlaylist() );
+        }
+    else
+        {
+        tmpContainer->SetObjectClassL( KClassStorage() );
+        }
+
+    HBufC8* xmlDoc = CUPnPXMLParser::ContainerToXmlLC( *tmpContainer );  
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            iCpDevice, KContentDirectory, KCreateObject );
+    
+    action->SetArgumentL( KContainerID, *tempId );
+    action->SetArgumentL( KElements, *xmlDoc );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionId = action->SessionId();
+
+    CleanupStack::PopAndDestroy( xmlDoc );
+    CleanupStack::PopAndDestroy( tmpContainer );
+    CleanupStack::PopAndDestroy( tempId );
+    CleanupStack::PopAndDestroy( tempTitle );
+   
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionId, *this );
+    iInternalState = ECreateContainer; 
+    iActionMessage = new (ELeave) RMessage2( aMessage );         
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CancelCreateContainerL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CancelCreateContainerL()
+    {
+    __LOG( "CUPnPBrowsingSession::CancelCreateContainerL" );       
+    
+    if( iActionMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionId );
+        iActionMessage->Complete( KErrCancel );
+        delete iActionMessage; iActionMessage = NULL;        
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::DeleteObjectL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::DeleteObjectL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPBrowsingSession::DeleteObjectL" );       
+    
+    __ASSERTD( !iActionMessage, __FILE__, __LINE__ );
+    
+    ResetL();
+    
+    TInt len = aMessage.GetDesMaxLength( 1 );
+    HBufC8* tempId = HBufC8::NewLC( len );
+    TPtr8 ptr( tempId->Des() );
+    aMessage.ReadL( 1, ptr );
+    
+    CleanupStack::Pop( tempId );
+    delete iItemId;
+    iItemId = tempId;
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            iCpDevice, KContentDirectory, KBrowse );
+    
+    action->SetArgumentL( KObjectID, *iItemId );
+    action->SetArgumentL( KBrowseFlag, KMetaData ); 
+    action->SetArgumentL( KFilter, KFilterCommon ); 
+    action->SetArgumentL( KStartingIndex, KDefaultStartingIndex ); 
+    action->SetArgumentL( KRequestedCount, KDefaultRequestedCount ); 
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionId = action->SessionId();
+
+    // Register
+    iInternalState = EDestroyObject;
+    iServer.Dispatcher().RegisterL( iIPSessionId, *this );
+    iActionMessage = new (ELeave) RMessage2( aMessage );   
+    }
+        
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CancelDeleteObjectL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CancelDeleteObjectL()
+    {
+    __LOG( "CUPnPBrowsingSession::CancelDeleteObjectL" );       
+    
+    if( iActionMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionId );
+        iActionMessage->Complete( KErrCancel );    
+        delete iActionMessage; iActionMessage = NULL;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::DeviceDisappearedRequestL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::DeviceDisappearedRequestL(
+    const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPBrowsingSession::DeviceDisappearedRequestL" );       
+    
+    __ASSERTD( !iDeviceMessage, __FILE__, __LINE__ );
+    
+    iDeviceMessage = new (ELeave) RMessage2( aMessage );
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CancelDeviceDisappearedRequestL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CancelDeviceDisappearedRequestL()
+    {
+    __LOG( "CUPnPBrowsingSession::CancelDeviceDisappearedRequestL" );       
+    
+    if( iDeviceMessage )
+        {
+        iDeviceMessage->Complete( KErrCancel );    
+        delete iDeviceMessage; iDeviceMessage = NULL;    
+        }
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::CheckAndSendDestroyObjectActionL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::CheckAndSendDestroyObjectActionL(
+    const TDesC8& aResponse )
+    {
+    __LOG( "CUPnPBrowsingSession::CheckAndSendDestroyObjectActionL" );
+    
+    CUPnPXMLParser* parser = CUPnPXMLParser::NewL();
+    CleanupStack::PushL( parser );
+    
+    RPointerArray<CUpnpObject> array;
+    CleanupResetAndDestroyPushL( array );
+    
+    parser->ParseResultDataL( array, aResponse );
+    
+    if( array.Count() == KExpectedCount )
+        {
+        if( array[ 0 ]->Restricted() )
+            {
+            User::Leave( KErrArgument );
+            }
+        else
+            {
+            // Not restricted, ok to destroy
+            CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+                    iCpDevice, KContentDirectory, KDestroyObject );
+            
+            action->SetArgumentL( KObjectID, *iItemId );
+
+            iServer.ControlPoint().SendL( action );
+            CleanupStack::Pop( action );
+            if (action->SessionId() < 0) 
+                {
+                User::Leave( action->SessionId() );   
+                }
+            iIPSessionId = action->SessionId();
+            iServer.Dispatcher().RegisterL( iIPSessionId, *this );
+            }    
+        }
+    else
+        {
+        User::Leave( KErrGeneral );
+        }    
+    CleanupStack::PopAndDestroy( &array );
+    CleanupStack::PopAndDestroy( parser );    
+    }
+
+
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::ResetL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::ResetL()
+    {
+    __LOG( "CUPnPBrowsingSession::ResetL" );
+    
+    iIPSessionId = KErrNotFound;
+    
+    if( !iServer.DeviceRepository().IsWlanActive() )    
+        {
+        __LOG( "Reset - disconnected" );
+        User::Leave( KErrDisconnected );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::ReadObjFromMessageL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::ReadObjFromMessageL( const RMessage2& aMessage, 
+    TInt aSlot, CUpnpObject* aObj ) 
+    {
+    // create buffer
+    TInt len = aMessage.GetDesMaxLength( aSlot );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
+    
+    // read stream
+    RDesReadStream stream( *buf );
+    CleanupClosePushL( stream );
+    
+    // internalize object
+    stream >> *aObj;
+    
+    // clean up
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buf );
+    }    
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::ReadReqFromMessageL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::ReadReqFromMessageL( const RMessage2& aMessage, 
+    TInt aSlot, CUpnpAVRequest* aReq ) 
+    {
+    // create buffer
+    TInt len = aMessage.GetDesMaxLength( aSlot );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
+    
+    // read stream
+    RDesReadStream stream( *buf );
+    CleanupClosePushL( stream );
+    
+    // internalize object
+    stream >> *aReq;
+    
+    // clean up
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buf );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::ReadBrowseReqFromMessageL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPBrowsingSession::ReadBrowseReqFromMessageL(
+    const RMessage2& aMessage, TInt aSlot, CUpnpAVBrowseRequest* aReq ) 
+    {
+    // create buffer
+    TInt len = aMessage.GetDesMaxLength( aSlot );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
+    
+    // read stream
+    RDesReadStream stream( *buf );
+    CleanupClosePushL( stream );
+    
+    // internalize object
+    stream >> *aReq;
+    
+    // clean up
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buf );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPBrowsingSession::ReadBufFromMessageLC
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+HBufC8* CUPnPBrowsingSession::ReadBufFromMessageLC(
+    const RMessage2& aMessage, TInt aSlot ) 
+    {
+    // create buffer
+    TInt len = aMessage.GetDesMaxLength( aSlot );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );        
+    return buf;
+    }    
+    
+// End of file
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpdevicerepository.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpdevicerepository.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,613 +1,751 @@
-/*
-* 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:      storage for devices with extended information
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-#include "upnpdevicerepository.h"
-
-#include "upnpavdeviceextended.h"
-
-#include <upnpservice.h>
-#include <upnpdevice.h>
-#include <upnpavcontrolpoint.h>
-
-// CONSTANTS
-_LIT8( KSearch,                     "Search" );
-_LIT8( KVolume,                     "Volume" );
-_LIT8( KCreateObject,               "CreateObject" );
-_LIT8( KPause,                      "Pause");
-_LIT8( KSetVolume,                  "SetVolume");
-_LIT8( KGetVolume,                  "GetVolume");
-_LIT8( KGetMute,                    "GetMute");
-_LIT8( KSetMute,                    "SetMute");
-_LIT8( KMediaServer,                "MediaServer" );
-_LIT8( KFriendlyName,               "friendlyName" );
-_LIT8( KAVTransportService,         "AVTransport" );
-_LIT8( KRenderingControlService,    "RenderingControl" );
-_LIT8( KSetNextUri,                 "SetNextAVTransportURI" );
-_LIT8( KDestroyObject,              "DestroyObject" );
-_LIT8( KDlnaDoc,                    "dlna:X_DLNADOC" );
-_LIT8( KDlnaCap,                    "dlna:X_DLNACAP" );
-_LIT8( KAudioUpload,                "audio-upload" );
-_LIT8( KImageUpload,                "image-upload" );
-_LIT8( KVideoUpload,                "av-upload" );
-_LIT8( KCreateChildContainer,       "create-child-container" );
-_LIT8( KDMS,                        "DMS" );
-_LIT8( KDMP,                        "DMP" );
-_LIT8( KDMR,                        "DMR" );
-
-const TInt KFirstSubscription = 1;
-
-_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
-#include "upnplog.h"
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::NewL
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-CUPnPDeviceRepository* CUPnPDeviceRepository::NewL
-    (
-    CUpnpAVControlPoint& aControlPoint
-    )
-    {
-    CUPnPDeviceRepository* rep= new(ELeave)
-        CUPnPDeviceRepository( aControlPoint );
-    CleanupStack::PushL( rep );
-    rep->ConstructL();
-    CleanupStack::Pop();
-    return rep;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::~CUPnPDeviceRepository
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-CUPnPDeviceRepository::~CUPnPDeviceRepository()
-    {     
-    iDevices.ResetAndDestroy();
-    iDevices.Close();
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::CUPnPDeviceRepository
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-CUPnPDeviceRepository::CUPnPDeviceRepository
-    (
-    CUpnpAVControlPoint& aControlPoint
-    ):
-    iControlPoint( aControlPoint ),
-    iIsWlanActive( ETrue )    
-    {
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::ConstructL
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-void CUPnPDeviceRepository::ConstructL()
-    {
-    __LOG( "CUPnPDeviceRepository::ConstructL" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::AddDeviceL
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-void CUPnPDeviceRepository::AddDeviceL( CUpnpDevice& aDevice )
-    {
-    __LOG( "CUPnPDeviceRepository::AddDeviceL" );
-        
-    CUpnpAVDeviceExtended* dev = CUpnpAVDeviceExtended::NewL();
-    CleanupStack::PushL( dev );
-    
-    // Check if it's a dlna device
-    TPtrC8 ptr = aDevice.GetProperty( KDlnaDoc );
-    if( ptr.Length() > 0 )
-        {
-        __LOG( "Dlna compatible device!" );
-        // It's a dlna device
-        dev->SetDlnaCompatible( ETrue );
-        
-        if( ptr.FindC( KDMS ) != KErrNotFound )
-            {
-            dev->SetDLNADeviceType( CUpnpAVDeviceExtended::EDMS );
-            }
-        else if( ptr.FindC( KDMR ) != KErrNotFound )
-            {
-            dev->SetDLNADeviceType( CUpnpAVDeviceExtended::EDMR );
-            }
-        else if( ptr.FindC( KDMP ) != KErrNotFound )
-            {
-            dev->SetDLNADeviceType( CUpnpAVDeviceExtended::EDMP );
-            }        
-        
-        // Check dlna capabilities
-        ptr.Set( aDevice.GetProperty( KDlnaCap ) );
-        if( ptr.Find( KAudioUpload ) != KErrNotFound )        
-            {
-            __LOG( "Audio upload supported!" );
-            dev->SetAudioUpload( ETrue );
-            }
-        if( ptr.Find( KImageUpload ) != KErrNotFound )
-            {
-            __LOG( "Image upload supported!" );
-            dev->SetImageUpload( ETrue );
-            }
-        if( ptr.Find( KVideoUpload ) != KErrNotFound )
-            {
-            __LOG( "Video upload supported!" );
-            dev->SetVideoUpload( ETrue );
-            }
-        if( ptr.Find( KCreateChildContainer ) != KErrNotFound )
-            {
-            __LOG( "Create child container supported!" );
-            dev->SetCreateChildContainer( ETrue );
-            }        
-        }   
-        
-    if( aDevice.DeviceType().Find( KMediaServer ) != KErrNotFound )
-        {
-        dev->SetDeviceType( CUpnpAVDevice::EMediaServer );
-        }
-    else
-        {
-        dev->SetDeviceType( CUpnpAVDevice::EMediaRenderer );
-        }
-
-    dev->SetFriendlyNameL( aDevice.DescriptionProperty( KFriendlyName ) );
-
-    dev->SetUuidL( aDevice.Uuid() );   
-    
-    dev->SetLocal( aDevice.Local() );
-    
-    ParseDeviceServicesL( aDevice, *dev );
-    CleanupStack::Pop( dev );
-    iDevices.AppendL( dev );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::AddProtocolInfoL
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-CUpnpAVDeviceExtended& CUPnPDeviceRepository::AddProtocolInfoL(
-    const TDesC8& aUuid, const TDesC8& aSource, const TDesC8& aSink )
-    {
-    __LOG( "CUPnPDeviceRepository::AddProtocolInfoL" );
-    
-    // Find the device
-    TInt count = iDevices.Count();
-    CUpnpAVDeviceExtended* dev = NULL;
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDevices[ i ]->Uuid() == aUuid )
-            {
-            dev = iDevices[ i ];
-            i = count;
-            }
-        }
-    if( dev )
-        {
-        if( dev->DeviceType() == CUpnpAVDevice::EMediaServer )
-            {
-            dev->SetSourceProtocolInfoL( aSource );
-            dev->SetSinkProtocolInfoL( aSink );
-            dev->SetCapabilitiesBySupportedMimeTypesL( aSource );
-            }
-        else
-            {
-            dev->SetSourceProtocolInfoL( aSource );
-            dev->SetSinkProtocolInfoL( aSink );
-            dev->SetCapabilitiesBySupportedMimeTypesL( aSink );    
-            }
-        dev->SetPInfoReceived( ETrue );        
-        }
-    else
-        {
-        User::Leave( KErrNotFound );
-        }    
-    return *dev;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::Remove
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-void CUPnPDeviceRepository::Remove( const TDesC8& aUuid )
-    {
-    __LOG( "CUPnPDeviceRepository::Remove" );
-    
-    TInt count = iDevices.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDevices[ i ]->Uuid() == aUuid )
-            {
-            delete iDevices[ i ];
-            iDevices.Remove( i );
-            i = count;
-            }
-        }
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::FindDeviceL
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-CUpnpAVDeviceExtended& CUPnPDeviceRepository::FindDeviceL(
-    const TDesC8& aUuid )
-    {
-    __LOG( "CUPnPDeviceRepository::FindDeviceL" );
-    
-    CUpnpAVDeviceExtended* tmp = NULL;
-    TInt count = iDevices.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iDevices[ i ]->Uuid() == aUuid )
-            {
-            tmp = iDevices[ i ];
-            i = count;
-            }
-        }
-    if( !tmp )
-        {
-        __LOG( "FindDeviceL - not found" );
-        
-        User::Leave( KErrNotFound );
-        }
-    return *tmp;    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::DeviceList
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-const RPointerArray<CUpnpAVDeviceExtended>&
-    CUPnPDeviceRepository::DeviceList() const
-    {
-    __LOG( "CUPnPDeviceRepository::DeviceList" );
-    
-    return iDevices;
-    }
-   
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::SubscribeDeviceL
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-void CUPnPDeviceRepository::SubscribeDeviceL( const TDesC8& aUuid )
-    {
-    __LOG( "CUPnPDeviceRepository::SubscribeDeviceL" );
-    __LOG8( aUuid );
-    
-    // Find the device and increase subscription count/check if we have
-    // subscribed already
-    TInt count = iDevices.Count();
-    TInt subscriptionCount = KErrNotFound;
-    TInt index;
-    for( index = 0; index < count; index++ )
-        {
-        if( aUuid.Compare( iDevices[ index ]->Uuid() ) == 0 )
-            {
-            subscriptionCount = iDevices[ index ]->IncreaseSubscriptionCount();
-            index = count;
-            }
-        }
-    if( subscriptionCount == KFirstSubscription )
-        {
-        __LOG( "SubscribeDeviceL - First subscription" ); 
-        
-        // Start subsciption for AVTransport and RenderingControl services
-        // Find the device
-        const RPointerArray<CUpnpDevice>& devList =
-            iControlPoint.DeviceList();
-        count = devList.Count();
-        for( index = 0; index < count; index++ )
-            {
-            if( aUuid.Compare( devList[ index ]->Uuid() ) == 0 )
-                {
-                break;
-                }
-            }
-
-        // Find the AVTransport service and subscribe
-        RPointerArray<CUpnpService>& servList =
-            devList[ index ]->ServiceList();
-        count = servList.Count();
-        CUpnpService* tempService = NULL;
-        for( index = 0; index < count; index++ )
-            {
-            if( servList[ index ]->ServiceType().Find(
-                KAVTransportService ) >= 0 )
-                {
-                tempService = servList[ index ];
-                index = count;
-                }
-            }
-        if( tempService && iIsWlanActive )
-            {
-            // AVTransport service found for the device, subscribe
-            __LOG( "SubscribeDeviceL - Subscribe for AVTransport" ); 
-            iControlPoint.SubscribeL( tempService ); 
-            }
-        else
-            {     
-            // Service not found, can't subscribe
-            __LOG( "SubscribeDeviceL - AVTransport service not found" );
-            }
-            
-        tempService = NULL;
-        for( index = 0; index < count; index++ )
-            {
-            if( servList[ index ]->ServiceType().Find(
-                KRenderingControlService ) >= 0 )
-                {
-                tempService = servList[ index ];
-                index = count;
-                }
-            }
-        if( tempService && iIsWlanActive )
-            {
-            // RenderingControl service found for the device, subscribe
-            __LOG( "SubscribeDeviceL - Subscribe for RenderingControl" ); 
-            iControlPoint.SubscribeL( tempService ); 
-            }
-        else
-            {     
-            // Service not found, can't subscribe
-            __LOG( "SubscribeDeviceL - RenderingControl service not found" );
-            }                    
-        }
-    else if( subscriptionCount == KErrNotFound ) 
-        {
-        __LOG( "SubscribeDeviceL - device not found" );
-        }
-    else
-        {
-        // Subscribed already, do nothing
-        __LOG( "SubscribeDeviceL - Subscription done already, ignoring!" ); 
-        }        
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::UnSubscribeDeviceL
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-void CUPnPDeviceRepository::UnSubscribeDeviceL( const TDesC8& aUuid )
-    {
-    __LOG( "CUPnPDeviceRepository::UnSubscribeDeviceL" );
-    __LOG8( aUuid );
-    
-    // Find the device and decrease subscription count/check if it's needed
-    // to unsubscribe
-    TInt count = iDevices.Count();
-    TInt subscriptionCount = KErrNotFound;
-    TInt index;
-    for( index = 0; index < count; index++ )
-        {
-        if( aUuid.Compare( iDevices[ index ]->Uuid() ) == 0 )
-            {
-            subscriptionCount = 
-                iDevices[ index ]->DecreaseSubscriptionCount();
-            index = count;
-            }
-        }    
-    
-    if( subscriptionCount == 0 )
-        {   
-        // Start unsubsciption for AVTransport and RenderingControl services
-        // Find the device
-        const RPointerArray<CUpnpDevice>& devList =
-            iControlPoint.DeviceList();
-        count = devList.Count();
-        for( index = 0; index < count; index++ )
-            {
-            if( aUuid.Compare( devList[ index ]->Uuid() ) == 0 )
-                {
-                break;
-                }
-            }
-
-        // Find the AVTransport service and unsubscribe
-        RPointerArray<CUpnpService>& servList =
-            devList[ index ]->ServiceList();
-        count = servList.Count();
-        CUpnpService* tempService = NULL;
-        for( index = 0; index < count; index++ )
-            {
-            if( servList[ index ]->ServiceType().Find(
-                KAVTransportService ) >= 0 )
-                {
-                tempService = servList[ index ];
-                index = count;
-                }
-            }
-        if( tempService && iIsWlanActive )
-            {
-            // AVTransport service found for the device, unsubscribe
-            __LOG( "UnSubscribeDeviceL - UnSubscribe AVTransport" ); 
-            iControlPoint.UnsubscribeL( tempService ); 
-            }
-        else
-            {     
-            // Service not found, can't unsubscribe
-            __LOG( "UnSubscribeDeviceL - AVTransport service not found" );
-            }
-            
-        tempService = NULL;
-        for( index = 0; index < count; index++ )
-            {
-            if( servList[ index ]->ServiceType().Find(
-                KRenderingControlService ) >= 0 )
-                {
-                tempService = servList[ index ];
-                index = count;
-                }
-            }
-        if( tempService && iIsWlanActive )
-            {
-            // RenderingControl service found for the device, subscribe
-            __LOG( "UnSubscribeDeviceL - UnSubscribe RenderingControl" ); 
-            iControlPoint.UnsubscribeL( tempService ); 
-            }
-        else
-            {     
-            // Service not found, can't subscribe
-            __LOG( "UnSubscribeDeviceL - RenderingControl service not\
-found" );
-            }                    
-        }
-    else if( subscriptionCount == KErrNotFound ) 
-        {
-        __LOG( "UnSubscribeDeviceL - device not found" );
-        }
-    else
-        {
-        // No need to unsubscibe
-        }           
-    }
-
-void CUPnPDeviceRepository::ConnectionLost()
-    {
-    __LOG( "CUPnPDeviceRepository::ConnectionLost" );
-    iIsWlanActive = EFalse;
-    iDevices.ResetAndDestroy();
-    }
-
-TBool CUPnPDeviceRepository::IsWlanActive()
-    {
-    __LOG1( "CUPnPDeviceRepository::IsWlanActive, %d", (TInt)iIsWlanActive );
-    return iIsWlanActive;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDeviceRepository::ParseDeviceServicesL
-// See upnpdevicerepository.h
-// --------------------------------------------------------------------------
-void CUPnPDeviceRepository::ParseDeviceServicesL( CUpnpDevice& aSource,
-    CUpnpAVDeviceExtended& aTarget )
-    {
-    __LOG( "CUPnPDeviceRepository::ParseDeviceServicesL" );
-    
-    TBool createObjectSupported = EFalse;
-    TBool getMuteSupported = EFalse;
-    TBool setMuteSupported = EFalse;
-    TBool getVolumeSupported = EFalse;
-    TBool setVolumeSupported = EFalse;
-
-    RPointerArray<CUpnpService>services = aSource.ServiceList();
-
-    TInt i;
-    TInt count = services.Count(); 
-    for( i = 0; i < count; i++ )
-        {
-        // Get max volume if it exists
-        CUpnpStateVariable* volumeState = 
-                services[ i ]->StateVariable( KVolume );
-
-        // If volume info found, save it to the device
-        if( volumeState )
-            {
-            TInt maxVolume = volumeState->MaxValue();
-            // If max volume not defined, it is set to 100
-            if( maxVolume == KErrNotFound )
-                {
-                maxVolume = 100;
-                }
-            aTarget.SetMaxVolume( maxVolume );
-            }
-
-        // Get the actions
-        RPointerArray<CUpnpAction> actions;
-        services[ i ]->GetActionList( actions );
-
-        // Go through the action elements
-        TInt j;
-        TInt count2 = actions.Count();
-        for( j = 0; j < count2; j++ )
-            {
-            TDesC8& actionName = actions[ j ]->Name();
-
-            if( actionName != KNullDesC8 )
-                {
-                if( actionName.Find( KCreateObject ) >= 0 )
-                    {
-                    createObjectSupported = ETrue;
-                    }
-                if( actionName.Compare( KSearch ) == 0 )
-                    {
-                    aTarget.SetSearchCapability( ETrue );
-                    }
-                if( actionName.Find( KPause ) >= 0 )
-                    {
-                    aTarget.SetPauseCapability( ETrue );
-                    }
-                if( actionName.Find( KGetVolume ) >= 0 )
-                    {
-                    getVolumeSupported = ETrue;
-                    }
-                if( actionName.Find( KSetVolume ) >= 0 )
-                    {
-                    setVolumeSupported = ETrue;
-                    }
-                if( actionName.Find( KGetMute ) >= 0 )
-                    {
-                    getMuteSupported = ETrue;
-                    }
-                if( actionName.Find( KSetMute ) >= 0 )
-                    {
-                    setMuteSupported = ETrue;
-                    }
-                if( actionName.Find( KSetNextUri ) >= 0 )
-                    {
-                    aTarget.SetNextAVTransportUri( ETrue );
-                    }
-                if( actionName.Find( KDestroyObject ) >= 0 )
-                    {
-                    aTarget.SetDestroyObject( ETrue );
-                    }                    
-                }
-            }
-        }
-
-    // Set copy support
-    if( createObjectSupported )
-        {
-        aTarget.SetCopyCapability( ETrue );
-        }
-
-    // Set volume support
-    if( getVolumeSupported &&
-        setVolumeSupported )
-        {
-        aTarget.SetVolumeCapability( ETrue );
-        }
-
-    // Set mute support
-    if( getMuteSupported &&
-        setMuteSupported )
-        {
-        aTarget.SetMuteCapability( ETrue );
-        }
-    }        
-
-// end of 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:      storage for devices with extended information
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+#include "upnpdevicerepository.h"
+
+#include "upnpavdeviceextended.h"
+#include "upnpavcontrolpoint.h"
+
+#include <upnpservice.h>
+#include <upnpdevice.h>
+#include <upnpicon.h>
+#include "upnpavcontrollerglobals.h"    // For KRel_Time
+
+// CONSTANTS
+_LIT8( KSearch,                     "Search" );
+_LIT8( KVolume,                     "Volume" );
+_LIT8( KCreateObject,               "CreateObject" );
+_LIT8( KPause,                      "Pause");
+_LIT8( KSetVolume,                  "SetVolume");
+_LIT8( KGetVolume,                  "GetVolume");
+_LIT8( KGetMute,                    "GetMute");
+_LIT8( KSetMute,                    "SetMute");
+_LIT8( KMediaServer,                "MediaServer" );
+_LIT8( KFriendlyName,               "friendlyName" );
+_LIT8( KModelName,                  "modelName" );
+_LIT8( KAVTransportService,         "AVTransport" );
+_LIT8( KRenderingControlService,    "RenderingControl" );
+_LIT8( KSetNextUri,                 "SetNextAVTransportURI" );
+_LIT8( KPrepareForConnection,       "PrepareForConnection" );
+_LIT8( KDestroyObject,              "DestroyObject" );
+_LIT8( KDlnaDoc,                    "dlna:X_DLNADOC" );
+_LIT8( KDlnaCap,                    "dlna:X_DLNACAP" );
+_LIT8( KAudioUpload,                "audio-upload" );
+_LIT8( KImageUpload,                "image-upload" );
+_LIT8( KVideoUpload,                "av-upload" );
+_LIT8( KCreateChildContainer,       "create-child-container" );
+_LIT8( KDMS,                        "DMS" );
+_LIT8( KDMP,                        "DMP" );
+_LIT8( KDMR,                        "DMR" );
+_LIT8( KJpg,                        "jpg" );
+_LIT8( KJpeg,                       "jpeg" );
+_LIT8( KPng,                        "png" );
+// Prefer 48x48 color icons and then greater size color icons
+const TInt KPreferredIconSize = 48;
+
+// Seek mode argument type string
+_LIT8( KArgumentTypeSeekMode, "A_ARG_TYPE_SeekMode" );
+
+const TInt KFirstSubscription = 1;
+
+_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
+#include "upnplog.h"
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::NewL
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+CUPnPDeviceRepository* CUPnPDeviceRepository::NewL
+    (
+    CUpnpAVControlPoint& aControlPoint
+    )
+    {
+    CUPnPDeviceRepository* rep= new(ELeave)
+        CUPnPDeviceRepository( aControlPoint );
+    CleanupStack::PushL( rep );
+    rep->ConstructL();
+    CleanupStack::Pop();
+    return rep;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::~CUPnPDeviceRepository
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+CUPnPDeviceRepository::~CUPnPDeviceRepository()
+    {     
+    iDevices.ResetAndDestroy();
+    iDevices.Close();
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::CUPnPDeviceRepository
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+CUPnPDeviceRepository::CUPnPDeviceRepository
+    (
+    CUpnpAVControlPoint& aControlPoint
+    ):
+    iControlPoint( aControlPoint ),
+    iIsWlanActive( ETrue )    
+    {
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::ConstructL
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+void CUPnPDeviceRepository::ConstructL()
+    {
+    __LOG( "CUPnPDeviceRepository::ConstructL" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::AddDeviceL
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+CUpnpAVDeviceExtended& CUPnPDeviceRepository::AddDeviceL( CUpnpDevice& aDevice )
+    {
+    __LOG( "CUPnPDeviceRepository::AddDeviceL" );
+        
+    CUpnpAVDeviceExtended* dev = CUpnpAVDeviceExtended::NewL();
+    CleanupStack::PushL( dev );
+    
+    // Check if it's a dlna device
+    TPtrC8 ptr = aDevice.GetProperty( KDlnaDoc );
+    if( ptr.Length() > 0 )
+        {
+        __LOG( "Dlna compatible device!" );
+        // It's a dlna device
+        dev->SetDlnaCompatible( ETrue );
+        
+        if( ptr.FindC( KDMS ) != KErrNotFound )
+            {
+            dev->SetDLNADeviceType( CUpnpAVDeviceExtended::EDMS );
+            }
+        else if( ptr.FindC( KDMR ) != KErrNotFound )
+            {
+            dev->SetDLNADeviceType( CUpnpAVDeviceExtended::EDMR );
+            }
+        else if( ptr.FindC( KDMP ) != KErrNotFound )
+            {
+            dev->SetDLNADeviceType( CUpnpAVDeviceExtended::EDMP );
+            }        
+        
+        // Check dlna capabilities
+        ptr.Set( aDevice.GetProperty( KDlnaCap ) );
+        if( ptr.Find( KAudioUpload ) != KErrNotFound )        
+            {
+            __LOG( "Audio upload supported!" );
+            dev->SetAudioUpload( ETrue );
+            }
+        if( ptr.Find( KImageUpload ) != KErrNotFound )
+            {
+            __LOG( "Image upload supported!" );
+            dev->SetImageUpload( ETrue );
+            }
+        if( ptr.Find( KVideoUpload ) != KErrNotFound )
+            {
+            __LOG( "Video upload supported!" );
+            dev->SetVideoUpload( ETrue );
+            }
+        if( ptr.Find( KCreateChildContainer ) != KErrNotFound )
+            {
+            __LOG( "Create child container supported!" );
+            dev->SetCreateChildContainer( ETrue );
+            }        
+        }   
+        
+    if( aDevice.DeviceType().Find( KMediaServer ) != KErrNotFound )
+        {
+        dev->SetDeviceType( CUpnpAVDevice::EMediaServer );
+        }
+    else
+        {
+        dev->SetDeviceType( CUpnpAVDevice::EMediaRenderer );
+        }
+
+    dev->SetFriendlyNameL( aDevice.DescriptionProperty( KFriendlyName ) );
+
+    dev->SetModelNameL( aDevice.DescriptionProperty( KModelName ) );
+    
+    dev->SetUuidL( aDevice.Uuid() );   
+    
+    dev->SetLocal( aDevice.Local() );
+
+    ParseDeviceServicesL( aDevice, *dev );
+
+    SelectDeviceIconL( aDevice, *dev );
+
+    CleanupStack::Pop( dev );
+    iDevices.AppendL( dev );
+    return *dev;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::AddProtocolInfoL
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+CUpnpAVDeviceExtended& CUPnPDeviceRepository::AddProtocolInfoL(
+    const TDesC8& aUuid, const TDesC8& aSource, const TDesC8& aSink )
+    {
+    __LOG( "CUPnPDeviceRepository::AddProtocolInfoL" );
+    
+    // Find the device
+    TInt count = iDevices.Count();
+    CUpnpAVDeviceExtended* dev = NULL;
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDevices[ i ]->Uuid() == aUuid )
+            {
+            dev = iDevices[ i ];
+            i = count;
+            }
+        }
+    if( dev )
+        {
+        if( dev->DeviceType() == CUpnpAVDevice::EMediaServer )
+            {
+            dev->SetSourceProtocolInfoL( aSource );
+            dev->SetSinkProtocolInfoL( aSink );
+            dev->SetCapabilitiesBySupportedMimeTypesL( aSource );
+            }
+        else
+            {
+            dev->SetSourceProtocolInfoL( aSource );
+            dev->SetSinkProtocolInfoL( aSink );
+            dev->SetCapabilitiesBySupportedMimeTypesL( aSink );    
+            }
+        dev->SetPInfoReceived( ETrue );        
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }    
+    return *dev;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::Remove
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+void CUPnPDeviceRepository::Remove( const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPDeviceRepository::Remove" );
+    
+    TInt count = iDevices.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDevices[ i ]->Uuid() == aUuid )
+            {
+            delete iDevices[ i ];
+            iDevices.Remove( i );
+            i = count;
+            }
+        }
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::FindDeviceL
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+CUpnpAVDeviceExtended& CUPnPDeviceRepository::FindDeviceL(
+    const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPDeviceRepository::FindDeviceL" );
+    
+    CUpnpAVDeviceExtended* tmp = NULL;
+    TInt count = iDevices.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iDevices[ i ]->Uuid() == aUuid )
+            {
+            tmp = iDevices[ i ];
+            i = count;
+            }
+        }
+    if( !tmp )
+        {
+        __LOG( "FindDeviceL - not found" );
+        
+        User::Leave( KErrNotFound );
+        }
+    return *tmp;    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::DeviceList
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+const RPointerArray<CUpnpAVDeviceExtended>&
+    CUPnPDeviceRepository::DeviceList() const
+    {
+    __LOG( "CUPnPDeviceRepository::DeviceList" );
+    
+    return iDevices;
+    }
+   
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::SubscribeDeviceL
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+void CUPnPDeviceRepository::SubscribeDeviceL( const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPDeviceRepository::SubscribeDeviceL" );
+    __LOG8( aUuid );
+    
+    // Find the device and increase subscription count/check if we have
+    // subscribed already
+    TInt count = iDevices.Count();
+    TInt subscriptionCount = KErrNotFound;
+    TInt index;
+    for( index = 0; index < count; index++ )
+        {
+        if( aUuid.Compare( iDevices[ index ]->Uuid() ) == 0 )
+            {
+            subscriptionCount = iDevices[ index ]->IncreaseSubscriptionCount();
+            index = count;
+            }
+        }
+    if( subscriptionCount == KFirstSubscription )
+        {
+        __LOG( "SubscribeDeviceL - First subscription" ); 
+        
+        // Start subsciption for AVTransport and RenderingControl services
+        // Find the device
+        const RPointerArray<CUpnpDevice>& devList =
+            iControlPoint.DeviceList();
+        count = devList.Count();
+        for( index = 0; index < count; index++ )
+            {
+            if( aUuid.Compare( devList[ index ]->Uuid() ) == 0 )
+                {
+                break;
+                }
+            }
+
+        // Find the AVTransport service and subscribe
+        RPointerArray<CUpnpService>& servList =
+            devList[ index ]->ServiceList();
+        count = servList.Count();
+        CUpnpService* tempService = NULL;
+        for( index = 0; index < count; index++ )
+            {
+            if( servList[ index ]->ServiceType().Find(
+                KAVTransportService ) >= 0 )
+                {
+                tempService = servList[ index ];
+                index = count;
+                }
+            }
+        if( tempService && iIsWlanActive )
+            {
+            // AVTransport service found for the device, subscribe
+            __LOG( "SubscribeDeviceL - Subscribe for AVTransport" ); 
+            iControlPoint.SubscribeL( tempService ); 
+            }
+        else
+            {     
+            // Service not found, can't subscribe
+            __LOG( "SubscribeDeviceL - AVTransport service not found" );
+            }
+            
+        tempService = NULL;
+        for( index = 0; index < count; index++ )
+            {
+            if( servList[ index ]->ServiceType().Find(
+                KRenderingControlService ) >= 0 )
+                {
+                tempService = servList[ index ];
+                index = count;
+                }
+            }
+        if( tempService && iIsWlanActive )
+            {
+            // RenderingControl service found for the device, subscribe
+            __LOG( "SubscribeDeviceL - Subscribe for RenderingControl" ); 
+            iControlPoint.SubscribeL( tempService ); 
+            }
+        else
+            {     
+            // Service not found, can't subscribe
+            __LOG( "SubscribeDeviceL - RenderingControl service not found" );
+            }                    
+        }
+    else if( subscriptionCount == KErrNotFound ) 
+        {
+        __LOG( "SubscribeDeviceL - device not found" );
+        }
+    else
+        {
+        // Subscribed already, do nothing
+        __LOG( "SubscribeDeviceL - Subscription done already, ignoring!" ); 
+        }        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::UnSubscribeDeviceL
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+void CUPnPDeviceRepository::UnSubscribeDeviceL( const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPDeviceRepository::UnSubscribeDeviceL" );
+    __LOG8( aUuid );
+    
+    // Find the device and decrease subscription count/check if it's needed
+    // to unsubscribe
+    TInt count = iDevices.Count();
+    TInt subscriptionCount = KErrNotFound;
+    TInt index;
+    for( index = 0; index < count; index++ )
+        {
+        if( aUuid.Compare( iDevices[ index ]->Uuid() ) == 0 )
+            {
+            subscriptionCount = 
+                iDevices[ index ]->DecreaseSubscriptionCount();
+            index = count;
+            }
+        }    
+    
+    if( subscriptionCount == 0 )
+        {   
+        // Start unsubsciption for AVTransport and RenderingControl services
+        // Find the device
+        const RPointerArray<CUpnpDevice>& devList =
+            iControlPoint.DeviceList();
+        count = devList.Count();
+        for( index = 0; index < count; index++ )
+            {
+            if( aUuid.Compare( devList[ index ]->Uuid() ) == 0 )
+                {
+                break;
+                }
+            }
+
+        // Find the AVTransport service and unsubscribe
+        RPointerArray<CUpnpService>& servList =
+            devList[ index ]->ServiceList();
+        count = servList.Count();
+        CUpnpService* tempService = NULL;
+        for( index = 0; index < count; index++ )
+            {
+            if( servList[ index ]->ServiceType().Find(
+                KAVTransportService ) >= 0 )
+                {
+                tempService = servList[ index ];
+                index = count;
+                }
+            }
+        if( tempService && iIsWlanActive )
+            {
+            // AVTransport service found for the device, unsubscribe
+            __LOG( "UnSubscribeDeviceL - UnSubscribe AVTransport" ); 
+            iControlPoint.UnsubscribeL( tempService ); 
+            }
+        else
+            {     
+            // Service not found, can't unsubscribe
+            __LOG( "UnSubscribeDeviceL - AVTransport service not found" );
+            }
+            
+        tempService = NULL;
+        for( index = 0; index < count; index++ )
+            {
+            if( servList[ index ]->ServiceType().Find(
+                KRenderingControlService ) >= 0 )
+                {
+                tempService = servList[ index ];
+                index = count;
+                }
+            }
+        if( tempService && iIsWlanActive )
+            {
+            // RenderingControl service found for the device, subscribe
+            __LOG( "UnSubscribeDeviceL - UnSubscribe RenderingControl" ); 
+            iControlPoint.UnsubscribeL( tempService ); 
+            }
+        else
+            {     
+            // Service not found, can't subscribe
+            __LOG( "UnSubscribeDeviceL - RenderingControl service not\
+found" );
+            }                    
+        }
+    else if( subscriptionCount == KErrNotFound ) 
+        {
+        __LOG( "UnSubscribeDeviceL - device not found" );
+        }
+    else
+        {
+        // No need to unsubscibe
+        }           
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::ConnectionLost
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+void CUPnPDeviceRepository::ConnectionLost()
+    {
+    __LOG( "CUPnPDeviceRepository::ConnectionLost" );
+    iIsWlanActive = EFalse;
+    iDevices.ResetAndDestroy();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::IsWlanActive
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+TBool CUPnPDeviceRepository::IsWlanActive()
+    {
+    __LOG1( "CUPnPDeviceRepository::IsWlanActive, %d", (TInt)iIsWlanActive );
+    return iIsWlanActive;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::SetMaxVolume
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+void CUPnPDeviceRepository::SetMaxVolume(CUpnpStateVariable* aVolumeState,
+        CUpnpAVDeviceExtended& aTarget)
+    {
+    if( aVolumeState )
+        {
+        // If volume info found, save it to the device
+        TInt maxVolume = aVolumeState->MaxValue();
+        // If max volume not defined, it is set to 100
+        if( maxVolume == KErrNotFound )
+            {
+            maxVolume = 100;
+            }
+        aTarget.SetMaxVolume( maxVolume );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::SetSeekCapabilityL
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+void CUPnPDeviceRepository::SetSeekCapabilityL(CUpnpStateVariable* seekModeStateVariable,
+        CUpnpAVDeviceExtended& aTarget)
+    {
+    if ( seekModeStateVariable ) 
+        {
+        CDesC8Array* allowedSeekModes = 
+            seekModeStateVariable->AllowedValuesLC();
+        if ( allowedSeekModes ) 
+            {
+            for ( TInt i=0 ; i < allowedSeekModes->Count() ; i++ ) 
+                {
+                if ( 0 == allowedSeekModes->
+                            operator[](i).CompareC( KRel_Time() ) )
+                    {
+                    aTarget.SetSeekCapability( CUpnpAVDevice::ERelTime );
+                    break;
+                    }
+                }               
+            }
+        CleanupStack::PopAndDestroy( allowedSeekModes );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::ParseDeviceServicesL
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+void CUPnPDeviceRepository::ParseDeviceServicesL( CUpnpDevice& aSource,
+    CUpnpAVDeviceExtended& aTarget )
+    {
+    __LOG( "CUPnPDeviceRepository::ParseDeviceServicesL" );
+    
+    TBool createObjectSupported = EFalse;
+    TBool getMuteSupported = EFalse;
+    TBool setMuteSupported = EFalse;
+    TBool getVolumeSupported = EFalse;
+    TBool setVolumeSupported = EFalse;
+
+    RPointerArray<CUpnpService>& services = aSource.ServiceList();
+
+    TInt i;
+    TInt count = services.Count(); 
+    for( i = 0; i < count; i++ )
+        {
+       CUpnpStateVariable* volumeState = 
+                services[ i ]->StateVariable( KVolume );
+
+       SetMaxVolume(volumeState, aTarget);
+
+        CUpnpStateVariable* seekModeStateVariable = 
+            services[i]->StateVariable( KArgumentTypeSeekMode() );
+        
+        SetSeekCapabilityL(seekModeStateVariable, aTarget);
+
+        // Get the actions
+        RPointerArray<CUpnpAction> actions;
+        // 'actions' cannot be closed, it is the same instance that is inside 'service'
+        services[ i ]->GetActionList( actions );
+
+        // Go through the action elements
+        TInt j;
+        TInt count2 = actions.Count();
+        for( j = 0; j < count2; j++ )
+            {
+            TDesC8& actionName = actions[ j ]->Name();
+
+            if( actionName != KNullDesC8 )
+                {
+                if( actionName.Find( KCreateObject ) >= 0 )
+                    {
+                    createObjectSupported = ETrue;
+                    }
+                if( actionName.Compare( KSearch ) == 0 )
+                    {
+                    aTarget.SetSearchCapability( ETrue );
+                    }
+                if( actionName.Find( KPause ) >= 0 )
+                    {
+                    aTarget.SetPauseCapability( ETrue );
+                    }
+                if( actionName.Find( KGetVolume ) >= 0 )
+                    {
+                    getVolumeSupported = ETrue;
+                    }
+                if( actionName.Find( KSetVolume ) >= 0 )
+                    {
+                    setVolumeSupported = ETrue;
+                    }
+                if( actionName.Find( KGetMute ) >= 0 )
+                    {
+                    getMuteSupported = ETrue;
+                    }
+                if( actionName.Find( KSetMute ) >= 0 )
+                    {
+                    setMuteSupported = ETrue;
+                    }
+                if( actionName.Find( KSetNextUri ) >= 0 )
+                    {
+                    aTarget.SetNextAVTransportUri( ETrue );
+                    }
+                if( actionName.Find( KDestroyObject ) >= 0 )
+                    {
+                    aTarget.SetDestroyObject( ETrue );
+                    }
+                if( actionName.Find( KPrepareForConnection ) >= 0 )
+                    {
+                    aTarget.SetPrepareForConnection( ETrue );
+                    }
+                }
+            }
+        }
+
+    // Set copy support
+    if( createObjectSupported )
+        {
+        aTarget.SetCopyCapability( ETrue );
+        }
+
+    // Set volume support
+    if( getVolumeSupported &&
+        setVolumeSupported )
+        {
+        aTarget.SetVolumeCapability( ETrue );
+        }
+
+    // Set mute support
+    if( getMuteSupported &&
+        setMuteSupported )
+        {
+        aTarget.SetMuteCapability( ETrue );
+        }
+        
+     }
+
+// --------------------------------------------------------------------------
+// CUPnPDeviceRepository::SelectDeviceIconL
+// See upnpdevicerepository.h
+// --------------------------------------------------------------------------
+void CUPnPDeviceRepository::SelectDeviceIconL( CUpnpDevice& aSource,
+    CUpnpAVDeviceExtended& aTarget )
+    {
+    // Icon selection rules:
+    // 1. Select any if none selected
+    // 2. Select the most colorful
+    // 3. Select greater until preferred size reached
+    // 4. Select the closest greater size after preferred size has passed
+    TPtrC8 deviceName( aTarget.FriendlyName() );
+    __LOG8_1( "CUPnPDeviceRepository::SelectDeviceIconL - Device: %S", &deviceName );
+    RPointerArray< CUpnpIcon >& icons( aSource.Icons() );
+    TInt iconCount( icons.Count() );
+    CUpnpIcon* selectedIcon = NULL;
+    TInt selectedDepth( 0 );
+    TInt selectedWd( 0 );
+    TInt selectedHd( 0 );
+    TInt selectedWhdSquare( 0 );
+    for ( TInt i( 0 ); i < iconCount; ++i )
+        {
+        CUpnpIcon* icon = icons[ i ];
+        TPtrC8 iconMimeType( icon->MimeType() );
+        __LOG8_1( "CUPnPDeviceRepository::SelectDeviceIconL - Found: %S", &iconMimeType );
+        __LOG3( "CUPnPDeviceRepository::SelectDeviceIconL - Width: %d Height: %d Depth: %d",
+                icon->Width(), icon->Height(), icon->Depth() );
+        if ( iconMimeType.FindF( KJpg ) != KErrNotFound ||
+             iconMimeType.FindF( KJpeg ) != KErrNotFound ||
+             iconMimeType.FindF( KPng ) != KErrNotFound )
+            {
+            TInt depth( icon->Depth() );
+            TInt wd( icon->Width() - KPreferredIconSize ); // Width diff to preferred size
+            TInt hd( icon->Height() - KPreferredIconSize ); // Height diff to preferred size
+            TInt whdSquare( wd * wd + hd * hd ); // Diffs combined
+            if ( !selectedIcon || // Rule 1
+                 ( depth >= selectedDepth && // Rule 2
+                   ( ( selectedWd < 0 && selectedWd < 0 && ( wd > selectedWd || hd > selectedHd ) ) || // Rule 3
+                     ( whdSquare < selectedWhdSquare && ( wd >= 0 || hd >= 0 ) ) ) // Rule 4
+                   )
+                 )
+                {
+                selectedIcon = icon;
+                selectedDepth = depth;
+                selectedWd = wd;
+                selectedHd = hd;
+                selectedWhdSquare = whdSquare;
+                }
+            }
+        }
+    if ( selectedIcon )
+        {
+        TPtrC8 iconMimeType( selectedIcon->MimeType() );
+        __LOG8_1( "CUPnPDeviceRepository::SelectDeviceIconL - Selected: %S", &iconMimeType );
+        __LOG3( "CUPnPDeviceRepository::SelectDeviceIconL - Width: %d Height: %d Depth: %d",
+                selectedIcon->Width(), selectedIcon->Height(), selectedIcon->Depth() );
+        aTarget.SetIconUrlL( aSource.Address(), aSource.UrlBase(), selectedIcon->Url() );
+        }
+    else
+        {
+        __LOG( "CUPnPDeviceRepository::SelectDeviceIconL - None selected" );
+        }
+    }
+
+// end of file
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpdownloadsession.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpdownloadsession.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,589 +1,591 @@
-/*
-* Copyright (c) 2008 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:      server impl. of session against media server
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <f32file.h>
-
-// upnp stack api
-#include <upnpmediaserversettings.h>
-#include <upnpstring.h>
-#include <upnpdlnaprotocolinfo.h>
-#include <upnpdlnaprotocolinfocons.h>
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h" // for upnp-specific stuff
-
-// upnpframework / internal api's
-#include "upnpcommonutils.h"
-#include "httpdownloader.h"
-
-// avcontroller internal
-#include "upnpdownloadsession.h"
-#include "upnpavdeviceextended.h"
-#include "upnpfiletransferitem.h"
-#include "upnpavcontrollerserver.h"
-#include "upnpaverrorhandler.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-const TUint32 KBufferSize       = 0x40000; // 256K
-const TInt KParallerTransfers   = 1;
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::NewL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-CUPnPDownloadSession* CUPnPDownloadSession::NewL( CUpnpAVControllerServer&
-    aServer, TInt aSessionId, const TDesC8& aUuid )
-    {
-    __LOG( "CUPnPDownloadSession::NewL" );
-    
-    CUPnPDownloadSession* self = new (ELeave) CUPnPDownloadSession(
-        aServer, aSessionId );
-    CleanupStack::PushL( self );    
-    self->ConstructL( aUuid );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::CUPnPDownloadSession
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-CUPnPDownloadSession::CUPnPDownloadSession( CUpnpAVControllerServer&
-    aServer, TInt aSessionId ) :
-    CUPnPFileTransferSessionBase( aServer, aSessionId )
-    {
-    __LOG( "CUPnPDownloadSession::CUPnPDownloadSession" );
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::~CUPnPDownloadSession
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-CUPnPDownloadSession::~CUPnPDownloadSession()
-    {
-    __LOG( "CUPnPDownloadSession::~CUPnPDownloadSession" );
-    
-    delete iDownloader;
-    
-    __LOG( "CUPnPDownloadSession::~CUPnPDownloadSession - end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::ConstructL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::ConstructL( const TDesC8& aUuid )
-    {
-    __LOG( "CUPnPDownloadSession::ConstructL" );
-    
-    CUPnPFileTransferSessionBase::ConstructL( aUuid );
-
-    iDownloader = CHttpDownloader::NewL( *this, (TUint32)iServer.IAP(),
-        KBufferSize, KParallerTransfers );
-    }
-   
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::TransferProgress
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::TransferProgress( TAny* aKey, TInt aBytes,
-    TInt aTotalBytes )
-    {
-    __LOG( "CUPnPDownloadSession::TransferProgress" );
-    
-    if( iProgressTrackingEnabled )
-        {
-        TUpnpFileTransferEvent item;
-        TInt err = FindItemByKey( item, (TInt)aKey );
-        if( err == KErrNone )
-            {
-            item.iStatus = KErrNone;
-            item.iParam2 = aTotalBytes;
-            item.iParam1 = aBytes;
-            item.iEvent = TUpnpFileTransferEvent::ETransferProgress;
-
-            Complete( item );                            
-            }
-        else
-            {
-            __LOG( "TransferProgress - Not enabled!" );
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::ReadyForTransfer
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::ReadyForTransferL( TAny* aKey )
-    {
-    __LOG( "CUPnPDownloadSession::ReadyForTransfer" );
-
-    TUpnpFileTransferEvent item;
-    TInt err = FindItemByKey( item, (TInt)aKey );
-    if( err == KErrNone )
-        {       
-        iDownloader->StartTransferL( aKey );        
-    
-        item.iEvent = TUpnpFileTransferEvent::ETransferStarted;
-        Complete( item );
-        }
-    else
-        {
-        __LOG( "ReadyForTransfer - key not found" );
-
-        // Not found
-        item.iStatus = KErrGeneral;
-        item.iParam2 = 0;
-        item.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
-        
-        Complete( item );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::TransferCompleted
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::TransferCompleted( TAny* aKey, TInt aStatus )
-    {
-    __LOG( "CUPnPDownloadSession::TransferCompleted" );
-    
-    TUpnpFileTransferEvent item;
-    TInt index;
-    TInt err = FindItemByKey( item, (TInt)aKey, index );
-    if( err == KErrNone )
-        {
-        item.iStatus = UPnPAVErrorHandler::ConvertToSymbianErrorCode( 
-                aStatus,
-                EUPnPHTTPError );
-        item.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
-        item.iParam3 = 0;
-
-        const HBufC* path = NULL;
-        TRAPD( err, path = iDownloader->GetPropertyL( aKey,
-            CHttpTransferBase::ETargetPath ) );
-
-        if( iEventMsg )
-            {
-            if( err == KErrNone && path )
-                {
-                // Write path using slot 2
-                iEventMsg->Write( 2, *path );                            
-                }
-            else
-                {
-                __LOG( "Error in path handling" );
-                }    
-            }
-        else
-            {
-            if( err == KErrNone && path )
-                {
-                HBufC* buf = HBufC::New( path->Length() );
-                if( buf )
-                    {
-                    buf->Des().Copy( *path );
-                    item.iParam3 = (TAny*)buf;
-                    }
-                else
-                    {
-                    __LOG( "Error in path handling" );
-                    }    
-                }
-            }    
-        Complete( item );
-        
-        iTransferItems.Remove( index );      
-        }
-    else
-        {
-        // Corresponding key was not found!
-        __LOG( "TransferCompleted - key not found" );
-
-        // Not found
-        item.iStatus = KErrGeneral;
-        item.iParam2 = 0;
-        item.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
-        
-        Complete( item );        
-        }
-        
-    if( aStatus == KErrDisconnected )
-        {
-        __LOG( "TransferCompleted - Target device lost" );
-        
-        TInt count = iTransferItems.Count();
-        for( TInt i = 0; i < count; i++ )
-            {
-            iDownloader->CancelTransfer( (TAny*)iTransferItems[i].iKey );
-            }
-        iTransferItems.Reset();
-        iEventQueu.Reset();            
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::StartDownloadL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::StartDownloadL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPDownloadSession::StartDownloadL" );
-    
-    CUpnpFileTransferItem* tmpTransferItem = CUpnpFileTransferItem::NewLC();
-        
-    ReadTransferItemFromMessageL( aMessage, 1 ,tmpTransferItem );
-        
-    TUpnpFileTransferEvent transferItem;
-    
-    if( CheckIfKeyExists( tmpTransferItem->Key() ) )
-        {
-        User::Leave( KErrInUse );
-        }
-        
-    transferItem.iKey = tmpTransferItem->Key();
-    
-    HBufC* path = HBufC::NewLC( KMaxPath );
-    if( tmpTransferItem->Path() == KNullDesC )
-        {
-        // Read path from the settings
-        CUpnpMediaServerSettings* msSettings =
-            CUpnpMediaServerSettings::NewL();
-        CleanupStack::PushL( msSettings );
-               
-        HBufC8* buf = msSettings->GetL(
-            UpnpMediaServerSettings::EUploadDirectory );
-            
-        CleanupStack::PopAndDestroy( msSettings );    
-        
-        path->Des().Copy( *buf );
-        delete buf;
-        }
-    else
-        {
-        // Get path from the transfer item
-        path->Des().Copy( tmpTransferItem->Path() );
-        }    
-    
-    __LOG8( tmpTransferItem->Title() );
-    
-    HBufC* title16 = UpnpString::ToUnicodeL( tmpTransferItem->Title() );
-    CleanupStack::PushL( title16 );
-    
-    HBufC* title16checked =
-        UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( *title16 );
-    CleanupStack::PopAndDestroy( title16 );
-    CleanupStack::PushL( title16checked );
-    
-    CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
-        tmpTransferItem->ProtocolInfo() );
-    CleanupStack::PushL( tmpInfo );    
-    HBufC* fileExt = UPnPCommonUtils::FileExtensionByMimeTypeL(
-        tmpInfo->ThirdField() );  
-    path->Des().Append( *title16checked  );
-    
-    if( fileExt )
-        {
-        path->Des().Append( *fileExt );
-        delete fileExt;        
-        }
-
-    iDownloader->InsertFileIntoWaitQueueL( (TAny*)transferItem.iKey,
-        *path, tmpTransferItem->Uri() );
-        
-    SetHeadersL( *tmpInfo, (TAny*)transferItem.iKey );    
-    CleanupStack::PopAndDestroy( tmpInfo );    
-    CleanupStack::PopAndDestroy( title16checked );
-    
-    iTransferItems.Append( transferItem );
-           
-    iDownloader->MoveToTransferQueueL( (TAny*)transferItem.iKey );
-    
-    CleanupStack::PopAndDestroy( path );
-    
-    CleanupStack::PopAndDestroy( tmpTransferItem );
-    
-    aMessage.Complete( KErrNone );        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::StartDownloadFHL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::StartDownloadFHL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPDownloadSession::StartDownloadFHL" );
-
-    RFile fHandle;
-    // handle is stored in slots 2 and 3
-    User::LeaveIfError( fHandle.AdoptFromClient( aMessage, 2, 3 ) );
-    CleanupClosePushL( fHandle );
-    
-    CUpnpFileTransferItem* tmpTransferItem = CUpnpFileTransferItem::NewLC();
-        
-    ReadTransferItemFromMessageL( aMessage, 1 ,tmpTransferItem );
-        
-    TUpnpFileTransferEvent transferItem;
-    transferItem.iKey = tmpTransferItem->Key();
-    
-    if( CheckIfKeyExists( tmpTransferItem->Key() ) )
-        {
-        User::Leave( KErrInUse );
-        }
-    
-    CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
-        tmpTransferItem->ProtocolInfo() );
-    CleanupStack::PushL( tmpInfo );     
-    
-    iDownloader->InsertFileIntoWaitQueueL( (TAny*)transferItem.iKey, fHandle,
-        tmpTransferItem->Uri() );
-    
-    SetHeadersL( *tmpInfo, (TAny*)transferItem.iKey );
-    
-    CleanupStack::PopAndDestroy( tmpInfo );
-        
-    iTransferItems.Append( transferItem );
-
-    iDownloader->MoveToTransferQueueL( (TAny*)transferItem.iKey );
-        
-    CleanupStack::PopAndDestroy( tmpTransferItem );
-    
-    CleanupStack::PopAndDestroy( &fHandle );
-    
-    aMessage.Complete( KErrNone );  
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::CancelDownloadL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::CancelDownloadL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPDownloadSession::CancelDownloadL" );
-    
-    TInt key = aMessage.Int1();
-
-    TInt index;
-    if( CheckIfKeyExists( key, index ) )
-        {
-        iDownloader->CancelTransfer( (TAny*)key );
-        aMessage.Complete( KErrNone );
-        iTransferItems.Remove( index );
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::CancelAllDownloadsL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::CancelAllDownloadsL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPDownloadSession::CancelAllDownloadsL" );
-    
-    TInt count = iTransferItems.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        iDownloader->CancelTransfer( (TAny*)iTransferItems[i].iKey );
-        }
-    iTransferItems.Reset();
-    iEventQueu.Reset();    
-    aMessage.Complete( KErrNone );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::StartTrackingDownloadProgressL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::StartTrackingDownloadProgressL(
-    const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPDownloadSession::StartTrackingDownloadProgressL" );
-    
-    TInt key = aMessage.Int1();
-    if( CheckIfKeyExists( key ) )
-        {
-        iDownloader->TrackProgress( (TAny*)key, ETrue );
-        iProgressTrackingEnabled = ETrue;        
-        aMessage.Complete( KErrNone );
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::StopTrackingDownloadProgressL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::StopTrackingDownloadProgressL(
-    const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPDownloadSession::StopTrackingDownloadProgressL" );
-    
-    TInt key = aMessage.Int1();
-    if( CheckIfKeyExists( key ) )
-        {
-        iDownloader->TrackProgress( (TAny*)key, EFalse );
-        iProgressTrackingEnabled = EFalse;        
-        aMessage.Complete( KErrNone );
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::GetDownloadEventL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::GetDownloadEventL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPDownloadSession::GetDownloadEventL" );
-    
-    if( iEventQueu.Count() )
-        {
-        __LOG1( "GetDownloadEventL, events in queu: %d",
-            iEventQueu.Count() );
-        
-        // There are events in the queu, write the first queued event back
-        // to client
-        TUpnpFileTransferEvent event = iEventQueu[0];
-        iEventQueu.Remove( 0 );
-        TPckg<TUpnpFileTransferEvent> resp1( event );
-        
-        if( event.iEvent ==
-            TUpnpFileTransferEvent::ETransferCompleted &&
-            event.iParam3 )
-            {
-            // Write path using slot 2
-            __LOG16( *( (HBufC*)event.iParam3 ) );
-            aMessage.Write( 2, *( (HBufC*)event.iParam3 ) );
-            delete (HBufC*)event.iParam3;
-            }
-        aMessage.Write( 1, resp1  ); // Write event using slot 1    
-        aMessage.Complete( KErrNone );       
-        }
-    else
-        {
-        iEventMsg = new (ELeave) RMessage2( aMessage );    
-        }
-    __LOG( "CUPnPDownloadSession::GetDownloadEventL - end" );        
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::CancelGetDownloadEventL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::CancelGetDownloadEventL(
-    const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPDownloadSession::CancelGetDownloadEventL" );
-    
-    if( iEventMsg )
-        {
-        iEventMsg->Complete( KErrCancel );
-        delete iEventMsg; iEventMsg = NULL;
-        }
-    aMessage.Complete( KErrNone );
-    }
-
-void CUPnPDownloadSession::DeviceDisappearedL(
-    CUpnpAVDeviceExtended& aDevice )
-    {
-    __LOG( "CUPnPDownloadSession::DeviceDisappearedL" );
-    
-    if( aDevice.Uuid().Compare( iDevice->Uuid() ) == 0 )
-        {
-        TUpnpFileTransferEvent event;
-        event.iEvent = TUpnpFileTransferEvent::EDeviceDisconnected;
-        
-        Complete( event );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::SetHeadersL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPDownloadSession::SetHeadersL( CUpnpDlnaProtocolInfo& aInfo,
-    TAny* aKey )
-    {
-    __LOG( "CUPnPDownloadSession::SetHeadersL" );
-    
-    // Check supported transfermodes
-    // We MUST use background, if it's supported
-    if( aInfo.DlnaFlag( UpnpDlnaProtocolInfo::TM_B_FLAG ) )
-        {
-        iDownloader->SetHeaderL( aKey, KTransferMode, KBackgroundMode );
-        }
-    else if( aInfo.DlnaFlag( UpnpDlnaProtocolInfo::TM_S_FLAG ) )
-        {
-        iDownloader->SetHeaderL( aKey, KTransferMode, KStreamingMode );
-        }
-    else if( aInfo.DlnaFlag( UpnpDlnaProtocolInfo::TM_I_FLAG ) )
-        { 
-        iDownloader->SetHeaderL( aKey, KTransferMode, KInteractiveMode );
-        }      
-    else 
-        {
-        __LOG( "SetHeadersL - No DLNA flags" );
-        
-        // Transfermode is not defined by any flag
-        // Correction for HALA-7B6FA5
-        if( UPnPCommonUtils::IsImageSupported( aInfo.ProtocolInfoL() ) )
-            {
-            __LOG( "SetHeadersL - Image -> Interactive" );
-            // It's an image, we should use Interactive-mode
-            iDownloader->SetHeaderL( aKey, KTransferMode, KInteractiveMode );
-            }
-        else if(
-            UPnPCommonUtils::IsAudioSupported( aInfo.ProtocolInfoL() ) ||
-            UPnPCommonUtils::IsVideoSupported( aInfo.ProtocolInfoL() ) )
-            {
-            __LOG( "SetHeadersL - A/V -> Streaming" );
-            iDownloader->SetHeaderL( aKey, KTransferMode, KStreamingMode );
-            }
-        else
-            {
-            __LOG( "SetHeadersL - Unknown type -> No mode" );
-            // It' something other
-            }                    
-        }        
-    }
-   
-// End of file
+/*
+* Copyright (c) 2008 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:      server impl. of session against media server
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// System
+#include <f32file.h>
+
+// upnp stack api
+#include <upnpstring.h>
+
+// dlnasrv / mediaserver api
+#include <upnpmediaserversettings.h>
+#include <upnpdlnaprotocolinfo.h>
+#include <upnpdlnaprotocolinfocons.h>
+
+// dlnasrv / avcontroller helper api
+#include "upnpconstantdefs.h" // for upnp-specific stuff
+
+// dlnasrv / internal api's
+#include "upnpcommonutils.h"
+#include "httpdownloader.h"
+
+// dlnasrv / avcontroller internal
+#include "upnpdownloadsession.h"
+#include "upnpavdeviceextended.h"
+#include "upnpfiletransferitem.h"
+#include "upnpavcontrollerserver.h"
+#include "upnpaverrorhandler.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+const TUint32 KBufferSize       = 0x40000; // 256K
+const TInt KParallerTransfers   = 1;
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::NewL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+CUPnPDownloadSession* CUPnPDownloadSession::NewL( CUpnpAVControllerServer&
+    aServer, TInt aSessionId, const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPDownloadSession::NewL" );
+    
+    CUPnPDownloadSession* self = new (ELeave) CUPnPDownloadSession(
+        aServer, aSessionId );
+    CleanupStack::PushL( self );    
+    self->ConstructL( aUuid );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::CUPnPDownloadSession
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+CUPnPDownloadSession::CUPnPDownloadSession( CUpnpAVControllerServer&
+    aServer, TInt aSessionId ) :
+    CUPnPFileTransferSessionBase( aServer, aSessionId )
+    {
+    __LOG( "CUPnPDownloadSession::CUPnPDownloadSession" );
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::~CUPnPDownloadSession
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+CUPnPDownloadSession::~CUPnPDownloadSession()
+    {
+    __LOG( "CUPnPDownloadSession::~CUPnPDownloadSession" );
+    
+    delete iDownloader;
+    
+    __LOG( "CUPnPDownloadSession::~CUPnPDownloadSession - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::ConstructL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::ConstructL( const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPDownloadSession::ConstructL" );
+    
+    CUPnPFileTransferSessionBase::ConstructL( aUuid );
+
+    iDownloader = CHttpDownloader::NewL( *this, (TUint32)iServer.IAP(),
+        KBufferSize, KParallerTransfers );
+    }
+   
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::TransferProgress
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::TransferProgress( TAny* aKey, TInt aBytes,
+    TInt aTotalBytes )
+    {
+    __LOG( "CUPnPDownloadSession::TransferProgress" );
+    
+    if( iProgressTrackingEnabled )
+        {
+        TUpnpFileTransferEvent item;
+        TInt err = FindItemByKey( item, (TInt)aKey );
+        if( err == KErrNone )
+            {
+            item.iStatus = KErrNone;
+            item.iParam2 = aTotalBytes;
+            item.iParam1 = aBytes;
+            item.iEvent = TUpnpFileTransferEvent::ETransferProgress;
+
+            Complete( item );                            
+            }
+        else
+            {
+            __LOG( "TransferProgress - Not enabled!" );
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::ReadyForTransfer
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::ReadyForTransferL( TAny* aKey )
+    {
+    __LOG( "CUPnPDownloadSession::ReadyForTransfer" );
+
+    TUpnpFileTransferEvent item;
+    TInt err = FindItemByKey( item, (TInt)aKey );
+    if( err == KErrNone )
+        {       
+        iDownloader->StartTransferL( aKey );        
+    
+        item.iEvent = TUpnpFileTransferEvent::ETransferStarted;
+        Complete( item );
+        }
+    else
+        {
+        __LOG( "ReadyForTransfer - key not found" );
+
+        // Not found
+        item.iStatus = KErrGeneral;
+        item.iParam2 = 0;
+        item.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
+        
+        Complete( item );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::TransferCompleted
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::TransferCompleted( TAny* aKey, TInt aStatus )
+    {
+    __LOG( "CUPnPDownloadSession::TransferCompleted" );
+    
+    TUpnpFileTransferEvent item;
+    TInt index;
+    TInt err = FindItemByKey( item, (TInt)aKey, index );
+    if( err == KErrNone )
+        {
+        item.iStatus = UPnPAVErrorHandler::ConvertToSymbianErrorCode( 
+                aStatus,
+                EUPnPHTTPError );
+        item.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
+        item.iParam3 = 0;
+
+        const HBufC* path = NULL;
+        TRAPD( err, path = iDownloader->GetPropertyL( aKey,
+            CHttpTransferBase::ETargetPath ) );
+
+        if( iEventMsg )
+            {
+            if( err == KErrNone && path )
+                {
+                // Write path using slot 2
+                iEventMsg->Write( 2, *path );                            
+                }
+            else
+                {
+                __LOG( "Error in path handling" );
+                }    
+            }
+        else
+            {
+            if( err == KErrNone && path )
+                {
+                HBufC* buf = HBufC::New( path->Length() );
+                if( buf )
+                    {
+                    buf->Des().Copy( *path );
+                    item.iParam3 = (TAny*)buf;
+                    }
+                else
+                    {
+                    __LOG( "Error in path handling" );
+                    }    
+                }
+            }    
+        Complete( item );
+        
+        iTransferItems.Remove( index );      
+        }
+    else
+        {
+        // Corresponding key was not found!
+        __LOG( "TransferCompleted - key not found" );
+
+        // Not found
+        item.iStatus = KErrGeneral;
+        item.iParam2 = 0;
+        item.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
+        
+        Complete( item );        
+        }
+        
+    if( aStatus == KErrDisconnected )
+        {
+        __LOG( "TransferCompleted - Target device lost" );
+        
+        TInt count = iTransferItems.Count();
+        for( TInt i = 0; i < count; i++ )
+            {
+            iDownloader->CancelTransfer( (TAny*)iTransferItems[i].iKey );
+            }
+        iTransferItems.Reset();
+        iEventQueu.Reset();            
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::StartDownloadL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::StartDownloadL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPDownloadSession::StartDownloadL" );
+    
+    CUpnpFileTransferItem* tmpTransferItem = CUpnpFileTransferItem::NewLC();
+        
+    ReadTransferItemFromMessageL( aMessage, 1 ,tmpTransferItem );
+        
+    TUpnpFileTransferEvent transferItem;
+    
+    if( CheckIfKeyExists( tmpTransferItem->Key() ) )
+        {
+        User::Leave( KErrInUse );
+        }
+        
+    transferItem.iKey = tmpTransferItem->Key();
+    
+    HBufC* path = HBufC::NewLC( KMaxPath );
+    if( tmpTransferItem->Path() == KNullDesC )
+        {
+        // Read path from the settings
+        CUpnpMediaServerSettings* msSettings =
+            CUpnpMediaServerSettings::NewL();
+        CleanupStack::PushL( msSettings );
+               
+        HBufC8* buf = msSettings->GetL(
+            UpnpMediaServerSettings::EUploadDirectory );
+            
+        CleanupStack::PopAndDestroy( msSettings );    
+        
+        path->Des().Copy( *buf );
+        delete buf;
+        }
+    else
+        {
+        // Get path from the transfer item
+        path->Des().Copy( tmpTransferItem->Path() );
+        }    
+    
+    __LOG8( tmpTransferItem->Title() );
+    
+    HBufC* title16 = UpnpString::ToUnicodeL( tmpTransferItem->Title() );
+    CleanupStack::PushL( title16 );
+    
+    HBufC* title16checked =
+        UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( *title16 );
+    CleanupStack::PopAndDestroy( title16 );
+    CleanupStack::PushL( title16checked );
+    
+    CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
+        tmpTransferItem->ProtocolInfo() );
+    CleanupStack::PushL( tmpInfo );    
+    HBufC* fileExt = UPnPCommonUtils::FileExtensionByMimeTypeL(
+        tmpInfo->ThirdField() );  
+    path->Des().Append( *title16checked  );
+    
+    if( fileExt )
+        {
+        path->Des().Append( *fileExt );
+        delete fileExt;        
+        }
+
+    iDownloader->InsertFileIntoWaitQueueL( (TAny*)transferItem.iKey,
+        *path, tmpTransferItem->Uri() );
+        
+    SetHeadersL( *tmpInfo, (TAny*)transferItem.iKey );    
+    CleanupStack::PopAndDestroy( tmpInfo );    
+    CleanupStack::PopAndDestroy( title16checked );
+    
+    iTransferItems.Append( transferItem );
+           
+    iDownloader->MoveToTransferQueueL( (TAny*)transferItem.iKey );
+    
+    CleanupStack::PopAndDestroy( path );
+    
+    CleanupStack::PopAndDestroy( tmpTransferItem );
+    
+    aMessage.Complete( KErrNone );        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::StartDownloadFHL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::StartDownloadFHL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPDownloadSession::StartDownloadFHL" );
+
+    RFile fHandle;
+    // handle is stored in slots 2 and 3
+    User::LeaveIfError( fHandle.AdoptFromClient( aMessage, 2, 3 ) );
+    CleanupClosePushL( fHandle );
+    
+    CUpnpFileTransferItem* tmpTransferItem = CUpnpFileTransferItem::NewLC();
+        
+    ReadTransferItemFromMessageL( aMessage, 1 ,tmpTransferItem );
+        
+    TUpnpFileTransferEvent transferItem;
+    transferItem.iKey = tmpTransferItem->Key();
+    
+    if( CheckIfKeyExists( tmpTransferItem->Key() ) )
+        {
+        User::Leave( KErrInUse );
+        }
+    
+    CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
+        tmpTransferItem->ProtocolInfo() );
+    CleanupStack::PushL( tmpInfo );     
+    
+    iDownloader->InsertFileIntoWaitQueueL( (TAny*)transferItem.iKey, fHandle,
+        tmpTransferItem->Uri() );
+    
+    SetHeadersL( *tmpInfo, (TAny*)transferItem.iKey );
+    
+    CleanupStack::PopAndDestroy( tmpInfo );
+        
+    iTransferItems.Append( transferItem );
+
+    iDownloader->MoveToTransferQueueL( (TAny*)transferItem.iKey );
+        
+    CleanupStack::PopAndDestroy( tmpTransferItem );
+    
+    CleanupStack::PopAndDestroy( &fHandle );
+    
+    aMessage.Complete( KErrNone );  
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::CancelDownloadL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::CancelDownloadL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPDownloadSession::CancelDownloadL" );
+    
+    TInt key = aMessage.Int1();
+
+    TInt index;
+    if( CheckIfKeyExists( key, index ) )
+        {
+        iDownloader->CancelTransfer( (TAny*)key );
+        aMessage.Complete( KErrNone );
+        iTransferItems.Remove( index );
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::CancelAllDownloadsL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::CancelAllDownloadsL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPDownloadSession::CancelAllDownloadsL" );
+    
+    TInt count = iTransferItems.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        iDownloader->CancelTransfer( (TAny*)iTransferItems[i].iKey );
+        }
+    iTransferItems.Reset();
+    iEventQueu.Reset();    
+    aMessage.Complete( KErrNone );
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::StartTrackingDownloadProgressL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::StartTrackingDownloadProgressL(
+    const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPDownloadSession::StartTrackingDownloadProgressL" );
+    
+    TInt key = aMessage.Int1();
+    if( CheckIfKeyExists( key ) )
+        {
+        iDownloader->TrackProgress( (TAny*)key, ETrue );
+        iProgressTrackingEnabled = ETrue;        
+        aMessage.Complete( KErrNone );
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::StopTrackingDownloadProgressL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::StopTrackingDownloadProgressL(
+    const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPDownloadSession::StopTrackingDownloadProgressL" );
+    
+    TInt key = aMessage.Int1();
+    if( CheckIfKeyExists( key ) )
+        {
+        iDownloader->TrackProgress( (TAny*)key, EFalse );
+        iProgressTrackingEnabled = EFalse;        
+        aMessage.Complete( KErrNone );
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::GetDownloadEventL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::GetDownloadEventL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPDownloadSession::GetDownloadEventL" );
+    
+    if( iEventQueu.Count() )
+        {
+        __LOG1( "GetDownloadEventL, events in queu: %d",
+            iEventQueu.Count() );
+        
+        // There are events in the queu, write the first queued event back
+        // to client
+        TUpnpFileTransferEvent event = iEventQueu[0];
+        iEventQueu.Remove( 0 );
+        TPckg<TUpnpFileTransferEvent> resp1( event );
+        
+        if( event.iEvent ==
+            TUpnpFileTransferEvent::ETransferCompleted &&
+            event.iParam3 )
+            {
+            // Write path using slot 2
+            __LOG16( *( (HBufC*)event.iParam3 ) );
+            aMessage.Write( 2, *( (HBufC*)event.iParam3 ) );
+            delete (HBufC*)event.iParam3;
+            }
+        aMessage.Write( 1, resp1  ); // Write event using slot 1    
+        aMessage.Complete( KErrNone );       
+        }
+    else
+        {
+        iEventMsg = new (ELeave) RMessage2( aMessage );    
+        }
+    __LOG( "CUPnPDownloadSession::GetDownloadEventL - end" );        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::CancelGetDownloadEventL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::CancelGetDownloadEventL(
+    const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPDownloadSession::CancelGetDownloadEventL" );
+    
+    if( iEventMsg )
+        {
+        iEventMsg->Complete( KErrCancel );
+        delete iEventMsg; iEventMsg = NULL;
+        }
+    aMessage.Complete( KErrNone );
+    }
+
+void CUPnPDownloadSession::DeviceDisappearedL(
+    CUpnpAVDeviceExtended& aDevice )
+    {
+    __LOG( "CUPnPDownloadSession::DeviceDisappearedL" );
+    
+    if( aDevice.Uuid().Compare( iDevice->Uuid() ) == 0 )
+        {
+        TUpnpFileTransferEvent event;
+        event.iEvent = TUpnpFileTransferEvent::EDeviceDisconnected;
+        
+        Complete( event );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::SetHeadersL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPDownloadSession::SetHeadersL( CUpnpDlnaProtocolInfo& aInfo,
+    TAny* aKey )
+    {
+    __LOG( "CUPnPDownloadSession::SetHeadersL" );
+    
+    // Check supported transfermodes
+    // We MUST use background, if it's supported
+    if( aInfo.DlnaFlag( UpnpDlnaProtocolInfo::TM_B_FLAG ) )
+        {
+        iDownloader->SetHeaderL( aKey, KTransferMode, KBackgroundMode );
+        }
+    else if( aInfo.DlnaFlag( UpnpDlnaProtocolInfo::TM_S_FLAG ) )
+        {
+        iDownloader->SetHeaderL( aKey, KTransferMode, KStreamingMode );
+        }
+    else if( aInfo.DlnaFlag( UpnpDlnaProtocolInfo::TM_I_FLAG ) )
+        { 
+        iDownloader->SetHeaderL( aKey, KTransferMode, KInteractiveMode );
+        }      
+    else 
+        {
+        __LOG( "SetHeadersL - No DLNA flags" );
+        
+        // Transfermode is not defined by any flag
+        // Correction for HALA-7B6FA5
+        if( UPnPCommonUtils::IsImageSupported( aInfo.ProtocolInfoL() ) )
+            {
+            __LOG( "SetHeadersL - Image -> Interactive" );
+            // It's an image, we should use Interactive-mode
+            iDownloader->SetHeaderL( aKey, KTransferMode, KInteractiveMode );
+            }
+        else if(
+            UPnPCommonUtils::IsAudioSupported( aInfo.ProtocolInfoL() ) ||
+            UPnPCommonUtils::IsVideoSupported( aInfo.ProtocolInfoL() ) )
+            {
+            __LOG( "SetHeadersL - A/V -> Streaming" );
+            iDownloader->SetHeaderL( aKey, KTransferMode, KStreamingMode );
+            }
+        else
+            {
+            __LOG( "SetHeadersL - Unknown type -> No mode" );
+            // It' something other
+            }                    
+        }        
+    }
+   
+// End of file
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpfiletransfersessionbase.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpfiletransfersessionbase.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,261 +1,261 @@
-/*
-* Copyright (c) 2007 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:      server impl. of session against media server
-*
-*/
-
-
-
-
-
-
-// INTERNAL INCLUDES
-#include "upnpfiletransfersessionbase.h"
-#include "upnpavdeviceextended.h"
-#include "upnpavcontrollerserver.h"
-#include "upnpdevicerepository.h"
-#include "upnpfiletransferitem.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
-#include "upnplog.h"
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::CUPnPFileTransferSessionBase
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-CUPnPFileTransferSessionBase::CUPnPFileTransferSessionBase(
-    CUpnpAVControllerServer& aServer, TInt aSessionId ) :
-    iServer( aServer ),
-    iSessionId( aSessionId )
-    {
-    __LOG( "CUPnPFileTransferSessionBase::CUPnPFileTransferSessionBase" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::~CUPnPFileTransferSessionBase
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-CUPnPFileTransferSessionBase::~CUPnPFileTransferSessionBase()
-    {
-    __LOG( "CUPnPFileTransferSessionBase::~CUPnPFileTransferSessionBase" );
-    
-    delete iDevice;
-    iTransferItems.Close();
-    iEventQueu.Close();
-    if( iEventMsg )
-        {
-        iEventMsg->Complete( KErrCancel );
-        delete iEventMsg;
-        }
-    
-    __LOG( "CUPnPFileTransferSessionBase::~CUPnPFileTransferSessionBase \
-- end" );    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::ConstructL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPFileTransferSessionBase::ConstructL( const TDesC8& aUuid )
-    {
-    __LOG( "CUPnPFileTransferSessionBase::ConstructL" );
-    
-    const RPointerArray<CUpnpAVDeviceExtended>& devList =
-        iServer.DeviceRepository().DeviceList();
-    TInt count = devList.Count();
-    TInt i;
-    for( i = 0; i < count; i++ )
-        {
-        if( devList[ i ]->Uuid() == aUuid )
-            {
-            iDevice = CUpnpAVDeviceExtended::NewL( *devList[ i ] );
-            }             
-        }
-    if( !iDevice )
-        {
-        User::Leave( KErrNotFound );
-        }        
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::SessionId
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-TInt CUPnPFileTransferSessionBase::SessionId() const
-    {
-    __LOG( "CUPnPFileTransferSessionBase::SessionId" );
-    
-    return iSessionId;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::Uuid
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-const TDesC8& CUPnPFileTransferSessionBase::Uuid() const
-    {
-    __LOG( "CUPnPFileTransferSessionBase::Uuid" );
-    
-    return iDevice->Uuid();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::CheckIfKeyExists
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-TBool CUPnPFileTransferSessionBase::CheckIfKeyExists( TInt aKey )
-    {
-    __LOG( "CUPnPFileTransferSessionBase::CheckIfKeyExists" );
-    
-    TBool retVal = EFalse;
-    TInt count = iTransferItems.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iTransferItems[ i ].iKey == aKey )
-            {
-            retVal = ETrue;
-            i = count;
-            }
-        }
-    return retVal;    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::CheckIfKeyExists
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-TBool CUPnPFileTransferSessionBase::CheckIfKeyExists( TInt aKey,
-    TInt& aIndex )
-    {
-    __LOG( "CUPnPFileTransferSessionBase::CheckIfKeyExists" );
-    
-    TBool retVal = EFalse;
-    TInt count = iTransferItems.Count();
-    for( aIndex = 0; aIndex < count; aIndex++ )
-        {
-        if( iTransferItems[ aIndex ].iKey == aKey )
-            {
-            retVal = ETrue;
-            break;
-            }
-        }
-    return retVal;    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::FindItemByKey
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-TInt CUPnPFileTransferSessionBase::FindItemByKey( TUpnpFileTransferEvent&
-    aItem, TInt aKey )
-    {
-    __LOG( "CUPnPFileTransferSessionBase::FindItemByKey" );
-    
-    TBool retVal = KErrNotFound;
-    TInt count = iTransferItems.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        if( iTransferItems[ i ].iKey == aKey )
-            {
-            aItem = iTransferItems[ i ];
-            retVal = KErrNone;
-            i = count;
-            }
-        }
-    return retVal;        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::FindItemByKey
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-TInt CUPnPFileTransferSessionBase::FindItemByKey( TUpnpFileTransferEvent&
-    aItem, TInt aKey, TInt& aIndex )
-    {
-    __LOG( "CUPnPFileTransferSessionBase::FindItemByKey" );
-    
-    TBool retVal = KErrNotFound;
-    TInt count = iTransferItems.Count();
-    for( aIndex = 0; aIndex < count; aIndex++ )
-        {
-        if( iTransferItems[ aIndex ].iKey == aKey )
-            {
-            aItem = iTransferItems[ aIndex ];
-            retVal = KErrNone;
-            break;
-            }
-        }
-    return retVal;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::ReadTransferItemFromMessageL
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPFileTransferSessionBase::ReadTransferItemFromMessageL(
-    const RMessage2& aMessage, TInt aSlot, CUpnpFileTransferItem* aItem ) 
-    {
-    __LOG( "CUPnPFileTransferSessionBase::ReadTransferItemFromMessageL" );
-    
-    // create buffer
-    TInt len = aMessage.GetDesMaxLength( aSlot );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
-    
-    // read stream
-    RDesReadStream stream( *buf );
-    CleanupClosePushL( stream );
-    
-    // internalize object
-    stream >> *aItem;
-    
-    // clean up
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buf );
-    }    
-
-// --------------------------------------------------------------------------
-// CUPnPFileTransferSessionBase::Complete
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPFileTransferSessionBase::Complete(
-    const TUpnpFileTransferEvent& aEvent )
-    {
-    __LOG( "CUPnPFileTransferSessionBase::Complete" );          
-    
-    if( iEventMsg )
-        {
-        __LOG( "Complete" );
-        __LOG1( "iEvent = %d", aEvent.iEvent );
-        __LOG1( "iKey = %d", aEvent.iKey );
-        __LOG1( "iStatus = %d", aEvent.iStatus );        
-        TPckg<TUpnpFileTransferEvent> resp1( aEvent );
-        iEventMsg->Write( 1, resp1  ); // Write response using slot 1
-        iEventMsg->Complete( KErrNone );
-        delete iEventMsg; iEventMsg = NULL;
-        }
-    else
-        {
-        __LOG( "Complete - Add to queu" );
-        __LOG1( "iEvent = %d", aEvent.iEvent );
-        __LOG1( "iKey = %d", aEvent.iKey );
-        __LOG1( "iStatus = %d", aEvent.iStatus );        
-        iEventQueu.AppendL( aEvent );
-        }
-    }
-    
-// End of file
+/*
+* Copyright (c) 2007 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:      server impl. of session against media server
+*
+*/
+
+
+
+
+
+
+// INTERNAL INCLUDES
+#include "upnpfiletransfersessionbase.h"
+#include "upnpavdeviceextended.h"
+#include "upnpavcontrollerserver.h"
+#include "upnpdevicerepository.h"
+#include "upnpfiletransferitem.h"
+
+_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
+#include "upnplog.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::CUPnPFileTransferSessionBase
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+CUPnPFileTransferSessionBase::CUPnPFileTransferSessionBase(
+    CUpnpAVControllerServer& aServer, TInt aSessionId ) :
+    iServer( aServer ),
+    iSessionId( aSessionId )
+    {
+    __LOG( "CUPnPFileTransferSessionBase::CUPnPFileTransferSessionBase" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::~CUPnPFileTransferSessionBase
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+CUPnPFileTransferSessionBase::~CUPnPFileTransferSessionBase()
+    {
+    __LOG( "CUPnPFileTransferSessionBase::~CUPnPFileTransferSessionBase" );
+    
+    delete iDevice;
+    iTransferItems.Close();
+    iEventQueu.Close();
+    if( iEventMsg )
+        {
+        iEventMsg->Complete( KErrCancel );
+        delete iEventMsg;
+        }
+    
+    __LOG( "CUPnPFileTransferSessionBase::~CUPnPFileTransferSessionBase \
+- end" );    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::ConstructL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPFileTransferSessionBase::ConstructL( const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPFileTransferSessionBase::ConstructL" );
+    
+    const RPointerArray<CUpnpAVDeviceExtended>& devList =
+        iServer.DeviceRepository().DeviceList();
+    TInt count = devList.Count();
+    TInt i;
+    for( i = 0; i < count; i++ )
+        {
+        if( devList[ i ]->Uuid() == aUuid )
+            {
+            iDevice = CUpnpAVDeviceExtended::NewL( *devList[ i ] );
+            }             
+        }
+    if( !iDevice )
+        {
+        User::Leave( KErrNotFound );
+        }        
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::SessionId
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+TInt CUPnPFileTransferSessionBase::SessionId() const
+    {
+    __LOG( "CUPnPFileTransferSessionBase::SessionId" );
+    
+    return iSessionId;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::Uuid
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+const TDesC8& CUPnPFileTransferSessionBase::Uuid() const
+    {
+    __LOG( "CUPnPFileTransferSessionBase::Uuid" );
+    
+    return iDevice->Uuid();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::CheckIfKeyExists
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+TBool CUPnPFileTransferSessionBase::CheckIfKeyExists( TInt aKey )
+    {
+    __LOG( "CUPnPFileTransferSessionBase::CheckIfKeyExists" );
+    
+    TBool retVal = EFalse;
+    TInt count = iTransferItems.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iTransferItems[ i ].iKey == aKey )
+            {
+            retVal = ETrue;
+            i = count;
+            }
+        }
+    return retVal;    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::CheckIfKeyExists
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+TBool CUPnPFileTransferSessionBase::CheckIfKeyExists( TInt aKey,
+    TInt& aIndex )
+    {
+    __LOG( "CUPnPFileTransferSessionBase::CheckIfKeyExists" );
+    
+    TBool retVal = EFalse;
+    TInt count = iTransferItems.Count();
+    for( aIndex = 0; aIndex < count; aIndex++ )
+        {
+        if( iTransferItems[ aIndex ].iKey == aKey )
+            {
+            retVal = ETrue;
+            break;
+            }
+        }
+    return retVal;    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::FindItemByKey
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+TInt CUPnPFileTransferSessionBase::FindItemByKey( TUpnpFileTransferEvent&
+    aItem, TInt aKey )
+    {
+    __LOG( "CUPnPFileTransferSessionBase::FindItemByKey" );
+    
+    TBool retVal = KErrNotFound;
+    TInt count = iTransferItems.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        if( iTransferItems[ i ].iKey == aKey )
+            {
+            aItem = iTransferItems[ i ];
+            retVal = KErrNone;
+            i = count;
+            }
+        }
+    return retVal;        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::FindItemByKey
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+TInt CUPnPFileTransferSessionBase::FindItemByKey( TUpnpFileTransferEvent&
+    aItem, TInt aKey, TInt& aIndex )
+    {
+    __LOG( "CUPnPFileTransferSessionBase::FindItemByKey" );
+    
+    TBool retVal = KErrNotFound;
+    TInt count = iTransferItems.Count();
+    for( aIndex = 0; aIndex < count; aIndex++ )
+        {
+        if( iTransferItems[ aIndex ].iKey == aKey )
+            {
+            aItem = iTransferItems[ aIndex ];
+            retVal = KErrNone;
+            break;
+            }
+        }
+    return retVal;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::ReadTransferItemFromMessageL
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPFileTransferSessionBase::ReadTransferItemFromMessageL(
+    const RMessage2& aMessage, TInt aSlot, CUpnpFileTransferItem* aItem ) 
+    {
+    __LOG( "CUPnPFileTransferSessionBase::ReadTransferItemFromMessageL" );
+    
+    // create buffer
+    TInt len = aMessage.GetDesMaxLength( aSlot );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
+    
+    // read stream
+    RDesReadStream stream( *buf );
+    CleanupClosePushL( stream );
+    
+    // internalize object
+    stream >> *aItem;
+    
+    // clean up
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buf );
+    }    
+
+// --------------------------------------------------------------------------
+// CUPnPFileTransferSessionBase::Complete
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPFileTransferSessionBase::Complete(
+    const TUpnpFileTransferEvent& aEvent )
+    {
+    __LOG( "CUPnPFileTransferSessionBase::Complete" );          
+    
+    if( iEventMsg )
+        {
+        __LOG( "Complete" );
+        __LOG1( "iEvent = %d", aEvent.iEvent );
+        __LOG1( "iKey = %d", aEvent.iKey );
+        __LOG1( "iStatus = %d", aEvent.iStatus );        
+        TPckg<TUpnpFileTransferEvent> resp1( aEvent );
+        iEventMsg->Write( 1, resp1  ); // Write response using slot 1
+        iEventMsg->Complete( KErrNone );
+        delete iEventMsg; iEventMsg = NULL;
+        }
+    else
+        {
+        __LOG( "Complete - Add to queu" );
+        __LOG1( "iEvent = %d", aEvent.iEvent );
+        __LOG1( "iKey = %d", aEvent.iKey );
+        __LOG1( "iStatus = %d", aEvent.iStatus );        
+        iEventQueu.Append( aEvent );
+        }
+    }
+    
+// End of file
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpplaybacksession.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpplaybacksession.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,2557 +1,2883 @@
-/*
-* Copyright (c) 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:      implements a renderer playback state machine
-*
-*/
-
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <in_sock.h>
-#include <mmf/common/mmfcontrollerpluginresolver.h>
-
-// upnp stack api
-#include <upnpdevice.h>
-#include <upnpcontainer.h>
-#include <upnpservice.h>
-#include <upnpitem.h>
-#include <upnpelement.h>
-#include <upnpstring.h>
-#include <upnpmediaserverclient.h>
-#include <upnpdlnaprotocolinfo.h>
-#include <upnpavcontrolpoint.h>
-
-// upnpframework / xmlparser api
-#include "upnpxmlparser.h"
-
-// upnpframework / avcontroller api
-#include "upnpavcontrollerglobals.h"
-
-// upnpframework / avcontroller helper api
-#include "upnpitemutility.h"
-#include "upnpconstantdefs.h" // for upnp-specific stuff
-
-// upnpframework / internal api's
-#include "upnpmetadatafetcher.h"
-#include "upnpcommonutils.h"
-#include "upnpcdsreselementutility.h"
-#include "upnpxmleventparser.h"
-
-// avcontroller internal
-#include "upnpavcontrollerserver.h"
-#include "upnpavrequest.h"
-#include "upnpfilesharingactive.h"
-#include "upnpavdispatcher.h"
-#include "upnpaverrorhandler.h"
-#include "upnpavdeviceextended.h"
-#include "upnpdevicerepository.h"
-#include "upnpplaybacksession.h"
-#include "upnpperiodic.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
-#include "upnplog.h"
-
-_LIT8( KPlaying,            "PLAYING" );
-_LIT8( KPaused,             "PAUSED_PLAYBACK" );
-_LIT8( KStopped,            "STOPPED" );
-_LIT8( KNormalSpeed,        "1" );
-_LIT8( KMasterVolume,       "Master" );
-_LIT8( KMuteOn,             "1" );
-_LIT8( KMuteOff,            "0" );
-_LIT8( KAsterisk,           "*" );
-
-const TInt KDefaultInstanceId   = 0;
-const TInt KExpectedCount       = 1;
-const TInt KMaxVolume           = 100;
-
-// Timer to wait until sending the play action after set transport uri.
-// For some reason, some equipments can not responce play action 
-// immediately after set transport uri, eg. Kiss 1600.  
-const TInt KPlayDelayTimerInterval = 1000000;
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::NewL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-CUPnPPlaybackSession* CUPnPPlaybackSession::NewL
-    (
-    RUpnpMediaServerClient& aClient,
-    CUpnpAVControllerServer& aServer,
-    TInt aSessionId,
-    const TDesC8& aUuid
-    )
-    {
-    CUPnPPlaybackSession* self = new (ELeave) CUPnPPlaybackSession(
-        aClient, aServer, aSessionId );
-    CleanupStack::PushL( self );
-    self->ConstructL( aUuid );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CUPnPPlaybackSession
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-CUPnPPlaybackSession::CUPnPPlaybackSession
-    (
-    RUpnpMediaServerClient& aClient,
-    CUpnpAVControllerServer& aServer,
-    TInt aSessionId
-    ):
-    iServer( aServer ),
-    iMediaServer( aClient ),
-    iSessionId( aSessionId ),
-    iInstanceId( KDefaultInstanceId ),
-    iIPSessionIdCommand( KErrNotFound ),
-    iIPSessionIdSetting( KErrNotFound ),
-    iEventingActive( EFalse ),
-    iMuteState( EUnknown ),
-    iVolume( -1 )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::~CUPnPPlaybackSession
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-CUPnPPlaybackSession::~CUPnPPlaybackSession()
-    {
-    __LOG( "CUPnPPlaybackSession::~CUPnPPlaybackSession" );
-    
-    if( iPlaybackState == EPlaying || iPlaybackState == EPaused ||
-        iPlaybackState == EPlaySent )
-        {
-        if( iDevice && iServer.DeviceRepository().IsWlanActive() )
-            {
-            __LOG( "~CUPnPPlaybackSession - \
-playback still ongoing, send stop" );    
-            TRAP_IGNORE( iServer.ControlPoint().AvtStopActionL( 
-                iDevice->Uuid(), iInstanceId ) );            
-            }
-        else
-            {
-            __LOG( "~CUPnPPlaybackSession - \
-playback still ongoing, wlan not active" );    
-            }    
-        }
-        
-    if( iSharedItem && iItemShared && iFileSharing )
-        {
-        TRAP_IGNORE( iFileSharing->UnShareItemL( iSharedItem->Id() ) );
-        }
-
-    if( iNextSharedItem && iNextItemShared && iFileSharing )
-        {
-        TRAP_IGNORE( iFileSharing->UnShareItemL( iNextSharedItem->Id() ) );
-        }
-    delete iFileSharing;
-        
-    //iMediaServer.Close();
-
-    delete iSharedItem;
-    delete iNextSharedItem;
-
-    delete iEventMessage;
-    delete iSettingMessage;
-    delete iCommandMessage;
-    delete iDeviceMessage;
-    
-    delete iLocalMediaServerUuid;
-    delete iEventParser;
-    
-    iEventQue.Reset();
-    iEventQue.Close();
-
-    if( iEventingActive && iDevice )
-        {
-        __LOG( "~CUPnPPlaybackSession - UnSubscribeDeviceL" );
-        TRAP_IGNORE( iServer.DeviceRepository().UnSubscribeDeviceL(
-            iDevice->Uuid() ) );
-        iServer.Dispatcher().UnRegisterEvents( *this );
-        iEventingActive = EFalse;            
-        }
-        
-    delete iDevice;        
-    
-    // delete the playdelay timer
-    if( iPlayDelayTimer )
-        {
-        iPlayDelayTimer->Cancel();
-        delete iPlayDelayTimer;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::ConstructL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::ConstructL( const TDesC8& aUuid )
-    {
-    __LOG( "CUPnPPlaybackSession::ConstructL" );
-
-    iFileSharing = CUPnPFileSharingActive::NewL();
-    
-    iEventParser = CUPnPXMLEventParser::NewL();
-    
-    const RPointerArray<CUpnpAVDeviceExtended>& devList =
-        iServer.DeviceRepository().DeviceList();
-    TInt count = devList.Count();
-    TInt i;
-    for( i = 0; i < count; i++ )
-        {
-        if( devList[ i ]->Local() )
-            {
-            __LOG( "CUPnPPlaybackSession::ConstructL - Local MS found!" );
-            
-            __ASSERTD( !iLocalMediaServerUuid, __FILE__, __LINE__ );
-            iLocalMediaServerUuid = devList[i]->Uuid().AllocL();
-            }
-        if( devList[ i ]->Uuid() == aUuid )
-            {
-            __ASSERTD( !iDevice, __FILE__, __LINE__ );
-            iDevice = CUpnpAVDeviceExtended::NewL( *devList[ i ] );
-            }
-        }        
-    if( !iDevice )
-        {
-        User::Leave( KErrNotFound );
-        }
-
-    // create the playdelaytimer
-    iPlayDelayTimer = CUPnPPeriodic::NewL( CActive::EPriorityStandard );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::RcSetVolumeResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::RcSetVolumeResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr, 
-    const TDesC8& /*aInstance*/, 
-    const TDesC8& /*aChannel*/, 
-    const TDesC8& aDesiredVolume )
-    {
-    __LOG1( "CUPnPPlaybackSession::RcSetVolumeResponse: %d", aErr );
-    
-    __ASSERTD( iIPSessionIdSetting == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
-    //iSettingPending = EFalse;
-    iIPSessionIdSetting = KErrNotFound;
-    
-    if( iSettingMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPRenderingControlError );    
-        
-        if( aErr == KErrNone )
-            {
-            TInt vol;
-            TLex8 lex( aDesiredVolume );
-            TInt err = lex.Val( vol );
-            if(  err == KErrNone )
-                {
-                TInt maxVolume = iDevice->MaxVolume();
-                // If max volume not KMaxVolume
-                if( maxVolume != KMaxVolume )
-                    {
-                    // Convert volume to match max volume 100
-                    TReal tempVolumeLevel = vol;
-                    TReal tempMaxVolume = maxVolume;
-                       
-                    vol = KMaxVolume * tempVolumeLevel / tempMaxVolume;
-                    }
-                iVolume = vol;
-                TPckg<TInt> resp2( vol );
-                iSettingMessage->Write( 2, resp2 );
-
-                iSettingMessage->Complete( EAVControllerSetVolumeCompleted );
-                delete iSettingMessage; iSettingMessage = NULL;       
-                }
-            else
-                {
-                iSettingMessage->Complete( err );
-                delete iSettingMessage; iSettingMessage = NULL;
-                }    
-            }
-        else
-            {
-            iSettingMessage->Complete( aErr );
-            delete iSettingMessage; iSettingMessage = NULL;
-            }                   
-        }
-    else
-        {
-        __LOG( "RcSetVolumeResponse - no msg" );
-        }    
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::RcVolumeResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::RcVolumeResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr, 
-    const TDesC8& /*aInstance*/, 
-    const TDesC8& /*aChannel*/, 
-    const TDesC8& aCurrentVolume)
-    {
-    __LOG1( "CUPnPPlaybackSession::RcVolumeResponse: %d", aErr );    
-    
-    __ASSERTD( iIPSessionIdSetting == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
-    //iSettingPending = EFalse;
-    iIPSessionIdSetting = KErrNotFound;
-
-    if( iSettingMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPRenderingControlError );
-        
-        if( aErr == KErrNone )
-            {
-            TInt vol;
-            TLex8 lex( aCurrentVolume );
-            TInt err = lex.Val( vol );
-            if(  err == KErrNone )
-                {
-                
-               // Get device's maximum volume value
-                TInt maxVolume = iDevice->MaxVolume();
-
-                // If max volume not KMaxVolume
-                if( maxVolume != KMaxVolume )
-                    {
-                    // Convert volume to match max volume KMaxVolume
-                    TReal tempVolumeLevel = vol;
-                    TReal tempMaxVolume = maxVolume;
-                    
-                    vol = KMaxVolume * tempVolumeLevel / tempMaxVolume;
-                    }            
-                iVolume = vol;
-                TPckg<TInt> resp1( vol );
-                iSettingMessage->Write( 1, resp1 );
-
-                iSettingMessage->Complete( EAVControllerGetVolumeCompleted );
-                delete iSettingMessage; iSettingMessage = NULL;      
-                }
-            else
-                {
-                iSettingMessage->Complete( err );
-                delete iSettingMessage; iSettingMessage = NULL;      
-                }    
-            }
-        else
-            {
-            iSettingMessage->Complete( aErr );
-            delete iSettingMessage; iSettingMessage = NULL;      
-            }                               
-        }
-    else
-        {
-        __LOG( "RcVolumeResponse - no msg" );
-        }    
-
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::RcSetMuteResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::RcSetMuteResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr, 
-    const TDesC8& /*aInstance*/, 
-    const TDesC8& /*aChannel*/, 
-    const TDesC8& aDesiredMute )
-    {
-    __LOG1( "CUPnPPlaybackSession::RcSetMuteResponse: %d", aErr );    
-    
-    __ASSERTD( iIPSessionIdSetting == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
-    //iSettingPending = EFalse;
-    iIPSessionIdSetting = KErrNotFound;
-    
-    if( iSettingMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPRenderingControlError );    
-        
-        if( aErr == KErrNone )
-            {
-            TInt mute( EUnknown );
-            TLex8 lex( aDesiredMute );
-            TInt err = lex.Val( mute );
-            
-            // If mute's value isn't ENotMuted or EMuted, 
-            // we think the value is incorrect.
-            if ( err == KErrNone && mute != ENotMuted && mute != EMuted )
-                {
-                err = KErrArgument;
-                }
-
-            if(  err == KErrNone )
-                {
-                iMuteState = (TMuteState)mute;
-                TPckg<TInt> resp2( mute );
-                iSettingMessage->Write( 2, resp2 );
-
-                iSettingMessage->Complete( EAVControllerSetMuteCompleted );
-                delete iSettingMessage; iSettingMessage = NULL;            
-                }
-            else
-                {
-                iSettingMessage->Complete( err );
-                delete iSettingMessage; iSettingMessage = NULL;      
-                }    
-            }
-        else
-            {
-            iSettingMessage->Complete( aErr );
-            delete iSettingMessage; iSettingMessage = NULL;      
-            }                           
-        }
-    else
-        {
-        __LOG( "RcSetMuteResponse - no msg" );
-        }    
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::RcMuteResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::RcMuteResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr, 
-    const TDesC8& /*aInstance*/, 
-    const TDesC8& /*aChannel*/, 
-    const TDesC8& aCurrentMute )
-    {
-    __LOG1( "CUPnPPlaybackSession::RcMuteResponse: %d" , aErr );
-    
-    __ASSERTD( iIPSessionIdSetting == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
-    iIPSessionIdSetting = KErrNotFound;
-
-    if( iSettingMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPRenderingControlError );
-        
-        if( aErr == KErrNone )
-            {
-            TInt mute( EUnknown );
-            TLex8 lex( aCurrentMute );
-            TInt err = lex.Val( mute );
-
-            // If mute's value isn't ENotMuted or EMuted, 
-            // we think the value is incorrect.
-            if ( err == KErrNone && mute != ENotMuted && mute != EMuted )
-                {
-                err = KErrArgument;
-                }
-
-            if(  err == KErrNone )
-                {
-                iMuteState = (TMuteState)mute;
-                TPckg<TInt> resp1( mute );
-                iSettingMessage->Write( 1, resp1 );
-
-                iSettingMessage->Complete( EAVControllerGetMuteCompleted );
-                delete iSettingMessage; iSettingMessage = NULL;
-                }
-            else
-                {
-                iSettingMessage->Complete( err );
-                delete iSettingMessage; iSettingMessage = NULL;
-                }    
-            }
-        else
-            {
-            iSettingMessage->Complete( aErr );
-            delete iSettingMessage; iSettingMessage = NULL;
-            }                                   
-        }
-    else
-        {
-        __LOG( "RcMuteResponse - no msg" );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtSetTransportUriResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtSetTransportUriResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aInstanceId,
-    const TDesC8& /*aCurrentUri*/,
-    const TDesC8& /*aCurrentUriMetaData*/)
-    {
-    __LOG1( "CUPnPPlaybackSession::AvtSetTransportUriResponse: %d", aErr );
-    
-    __ASSERTD( iIPSessionIdCommand == aSessionId, __FILE__, __LINE__ );  
-    
-    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
-    iIPSessionIdCommand = KErrNotFound;
-    TInt temp;
-    TLex8 lex( aInstanceId );
-    TInt err = lex.Val( temp );
-    if( err == KErrNone )
-        {
-        __LOG1( "AvtSetTransportUriResponse, instance id: %d", temp );
-        iInstanceId = temp;
-        iPlaybackState = EStopped;
-        }
-    
-    if( iCommandMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPAVTransportError );    
-        
-        if( aErr == KErrNone )
-            {
-            iCommandMessage->Complete( EAVControllerSetURICompleted );
-            delete iCommandMessage; iCommandMessage = NULL;      
-            }
-        else
-            {
-            iCommandMessage->Complete( aErr );
-            delete iCommandMessage; iCommandMessage = NULL;      
-            }                
-        }
-    else
-        {
-        __LOG( "AvtSetTransportUriResponse - no msg" );
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtSetNextTransportUriResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtSetNextTransportUriResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& aInstanceId,
-    const TDesC8& /*aNextUri*/,
-    const TDesC8& /*aNextUriMetaData*/)
-    {
-    __LOG1( "CUPnPPlaybackSession::AvtSetNextTransportUriResponse: %d",
-        aErr );
-    
-    __ASSERTD( iIPSessionIdCommand == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
-    iIPSessionIdCommand = KErrNotFound;
-
-    TInt temp;
-    TLex8 lex( aInstanceId );
-    TInt err = lex.Val( temp );
-    if( err == KErrNone )
-        {
-        __LOG1( "AvtSetNextTransportUriResponse, instance id: %d", temp );
-        //iInstanceId = temp;
-        }
-
-    if( iCommandMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPAVTransportError );
-        
-        if( aErr == KErrNone )
-            {
-            iCommandMessage->Complete( EAVControllerSetNextURICompleted );
-            delete iCommandMessage; iCommandMessage = NULL;            
-            }
-        else
-            {
-            iCommandMessage->Complete( aErr );
-            delete iCommandMessage; iCommandMessage = NULL;      
-            }            
-        }
-    else
-        {
-        __LOG( "AvtSetNextTransportUriResponse - no msg" );
-        }    
-
-    }
-  
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtMediaInfoResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtMediaInfoResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aNrTracks*/,
-    const TDesC8& /*aMediaDuration*/,
-    const TDesC8& /*aCurrentUri*/,
-    const TDesC8& /*aCurrentUriMetaData*/,
-    const TDesC8& /*aNextUri*/,
-    const TDesC8& /*aNextUriMetaData*/,
-    const TDesC8& /*aPlayMedium*/,
-    const TDesC8& /*aRecordMedium*/,
-    const TDesC8& /*aWriteStatus*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtGetTransportInfoResponse
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-void CUPnPPlaybackSession::AvtGetTransportInfoResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aCurrenTransportState*/,
-    const TDesC8& /*aCurrentTransportStatus*/,
-    const TDesC8& /*aCurrentSpeed*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtPositionInfoResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtPositionInfoResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aTrack*/,
-    const TDesC8& aTrackDuration,
-    const TDesC8& /*aTrackMetaData*/,
-    const TDesC8& /*aTrackURI*/,
-    const TDesC8& aRelTime,
-    const TDesC8& /*aAbsTime*/,
-    const TDesC8& /*aRelCount*/,
-    const TDesC8& /*aAbsCount*/)
-    {
-    __LOG1( "CUPnPPlaybackSession::AvtPositionInfoResponse: %d", aErr );    
-    
-    __ASSERTD( iIPSessionIdSetting == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
-    iIPSessionIdSetting = KErrNotFound;
-    
-    if( iSettingMessage )
-        {
-        TInt err = iSettingMessage->Write( 1, aTrackDuration );
-        err = iSettingMessage->Write( 2, aRelTime );
-        // Howto handle err?
-
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPAVTransportError );    
-           
-        if( aErr == KErrNone )
-            {
-            iSettingMessage->Complete( EAVControllerPositionInfoCompleted );
-            delete iSettingMessage; iSettingMessage = NULL;      
-            }
-        else
-            {
-            iSettingMessage->Complete( aErr ); 
-            delete iSettingMessage; iSettingMessage = NULL; 
-            }        
-        }
-    else
-        {
-        __LOG( "AvtPositionInfoResponse - no msg" );    
-        }       
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtDeviceCapabilitiesResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtDeviceCapabilitiesResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aPlayMedia*/,
-    const TDesC8& /*aRecMedia*/,
-    const TDesC8& /*aRecQualityMode*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtTransportSettingsResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtTransportSettingsResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aPlayMode*/,
-    const TDesC8& /*aRecQualityMode*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtStopResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtStopResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aInstanceId*/)
-    {
-    __LOG1( "CUPnPPlaybackSession::AvtStopResponse: %d", aErr );    
-    
-    __ASSERTD( iIPSessionIdCommand == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
-    //iCommandPending = EFalse;
-    iIPSessionIdCommand = KErrNotFound;
-    
-    if( iCommandMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPAVTransportError );        
-        
-        if( aErr == KErrNone )
-            {
-            iPlaybackState = EStopped;
-            iCommandMessage->Complete( EAVControllerStopCompleted );
-            delete iCommandMessage; iCommandMessage = NULL;       
-            }
-        else
-            {
-            iCommandMessage->Complete( aErr );
-            delete iCommandMessage; iCommandMessage = NULL;       
-            }                
-        }
-    else
-        {
-        __LOG( "AvtStopResponse - no msg" );
-        }      
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtPlayResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtPlayResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aSpeed*/)
-    {
-    __LOG1( "CUPnPPlaybackSession::AvtPlayResponse: %d", aErr );    
-    
-    __ASSERTD( iIPSessionIdCommand == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
-    //iCommandPending = EFalse;
-    iIPSessionIdCommand = KErrNotFound;
-    
-    if( iCommandMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPAVTransportError );        
-        
-        if( aErr == KErrNone )
-            {
-            iPlaybackState = EPlaying;
-            iCommandMessage->Complete( EAVControllerPlayCompleted );
-            delete iCommandMessage; iCommandMessage = NULL;             
-            }
-        else
-            {
-            iCommandMessage->Complete( aErr );
-            delete iCommandMessage; iCommandMessage = NULL;
-            }                    
-        }
-    else
-        {
-        __LOG( "AvtPlayResponse - no msg" );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtPauseResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtPauseResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aInstanceId*/)
-    {
-    __LOG1( "CUPnPPlaybackSession::AvtPauseResponse: %d", aErr );    
-    
-    __ASSERTD( iIPSessionIdCommand == aSessionId, __FILE__, __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
-    //iCommandPending = EFalse;
-    iIPSessionIdCommand = KErrNotFound;
-    
-    if( iCommandMessage )
-        {
-        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-            EUPnPAVTransportError );        
-        
-        if( aErr == KErrNone )
-            {
-            iPlaybackState = EPaused;
-            iCommandMessage->Complete( EAVControllerPauseCompleted );
-            delete iCommandMessage; iCommandMessage = NULL;                   
-            }
-        else
-            {
-            iCommandMessage->Complete( aErr );
-            delete iCommandMessage; iCommandMessage = NULL;             
-            }                    
-        }
-    else
-        {
-        __LOG( "AvtPauseResponse - no msg" );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtRecordResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtRecordResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtSeekResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtSeekResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aUnit*/,
-    const TDesC8& /*aTarget*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtNextResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtNextResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtPreviousResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtPreviousResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtSetPlayModeResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtSetPlayModeResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aNewPlayMode*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtSetRecordModeResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtSetRecordModeResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aInstanceId*/,
-    const TDesC8& /*aNewRecordQuality*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsSearchCapabilitiesResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsSearchCapabilitiesResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aSearchCaps*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsSortCapabilitiesResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsSortCapabilitiesResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aSortCaps*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsSystemUpdateIdResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsSystemUpdateIdResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    TInt /*aSystemUpdateId*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsBrowseResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsBrowseResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aObjectID*/,
-    const TDesC8&  /*aBrowseFlag*/,
-    const TDesC8&  /*aFilter*/,
-    TInt /*aIndex*/,
-    TInt /*aRequest*/,
-    const TDesC8&  /*aSortCriteria*/,
-    const TDesC8&  /*aResult*/,
-    TInt /*aReturned*/,
-    TInt /*aMatches*/,
-    const TDesC8&  /*aUpdateID*/ )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsSearchResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsSearchResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aContainerId*/,
-    const TDesC8& /*aSearchCriteria*/,
-    const TDesC8& /*aFilter*/,
-    TInt /*aIndex*/,
-    TInt /*aRequest*/,
-    const TDesC8& /*aSortCriteria*/,
-    const TDesC8& /*aResult*/,
-    TInt /*aReturned*/,
-    TInt /*aMatches*/,
-    const TDesC8& /*aUpdateID*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsDestroyObjectResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsDestroyObjectResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aObjectId*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsUpdateObjectResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsUpdateObjectResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aObjectId*/,
-    const TDesC8& /*aCurrentTagValue*/,
-    const TDesC8& /*aNewTagValue*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsImportResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsImportResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aSourceURI*/,
-    const TDesC8& /*aDestinationURI*/,
-    const TDesC8& /*aTransferId*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsExportResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsExportResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aSourceURI*/,
-    const TDesC8& /*aDestinationURI*/,
-    const TDesC8& /*aTransferId*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsStopTransferResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsStopTransferResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aTransferId*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsCTransferProgressResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsCTransferProgressResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aTransferId*/,
-    const TDesC8& /*aTransferStatus*/,
-    const TDesC8& /*aTransferLength*/,            
-    const TDesC8& /*aTransferTotal*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsDeleteResourceResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsDeleteResourceResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aResourceUri*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsCreateReferenceResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsCreateReferenceResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aContainerId*/, 
-    const TDesC8& /*ObjectId*/,
-    const TDesC8& /*aNewId*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsCreateObjectResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsCreateObjectResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aContainerID*/, 
-    const TDesC8& /*aElements*/, 
-    const TDesC8& /*aObjectID*/, 
-    const TDesC8& /*aResult*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CmProtocolInfoResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CmProtocolInfoResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aSource*/, 
-    const TDesC8& /*aSink*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CmPrepareResponse
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CmPrepareResponse(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aRemoteProtocolInfo*/,
-    const TDesC8& /*aPeerConnectionManager*/,
-    const TDesC8& /*aPeerConnectionId*/,
-    const TDesC8& /*aDirection*/,
-    TInt /*aConnection*/,
-    TInt /*aTransport*/,
-    TInt /*aRsc*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CmComplete
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CmComplete(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    TInt /*aConnection*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CmCurrentConnections
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CmCurrentConnections(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    const TDesC8& /*aConnections*/)
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CmCurrentInfo
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CmCurrentInfo(
-    const TDesC8& /*aUuid*/,
-    TInt /*aSessionId*/,
-    TInt /*aErr*/,
-    TInt /*rscId*/, 
-    TInt /*transportId*/, 
-    const TDesC8& /*aProtocolInfo*/,
-    const TDesC8& /*aPeerConnectionManager*/, 
-    TInt /*peerId*/, 
-    const TDesC8& /*aDirection*/, 
-    const TDesC8& /*aStatus*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsUpdateEvent
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsUpdateEvent(
-        const TDesC8& /*aUuid*/,
-        TInt /*aSystemUpdateId*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsContainerEvent
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsContainerEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aConteinerIds*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CdsTransferEvent
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CdsTransferEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aTransferIds*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::RcLastChangeEvent
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::RcLastChangeEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& aLastChange
-        )
-    {
-    // No implementation required
-    if( iPlaybackState != EUninitialized )
-        {        
-        __LOG( "CUPnPPlaybackSession::RcLastChangeEvent" );
-        //__LOG8( aLastChange );
-
-        TInt instanceId = -1;
-        TInt volume = -1;
-        TBool mute = EFalse;
-        if( iMuteState == EMuted )
-            {
-            mute = ETrue;
-            }
-
-        TRAPD( err, iEventParser->ParseResultDataL( aLastChange, instanceId,
-            volume, mute ) );
-        if( err == KErrNone && instanceId == iInstanceId )
-            {
-            TUnsolicitedEventC unEvent;
-            if( iMuteState != (TMuteState)mute )
-                {
-                // State of mute changed, create an event and send it to
-                // the client side
-                unEvent.iEvent = EMute;
-                unEvent.iValue = (TInt)mute;
-                
-                // If mute's value isn't ENotMuted or EMuted, 
-                // we think the value is incorrect.
-                if ( mute != ENotMuted && mute != EMuted )
-                    {    
-                    err = KErrArgument;
-                    }
-                else 
-                    {
-                iMuteState = (TMuteState)mute;
-                    }
-                if( iEventMessage )
-                    {
-                    TPckg<TUnsolicitedEventC> resp1( unEvent );
-                    TInt error = iEventMessage->Write( 1, resp1 );
-                    if ( error == KErrNone )
-                        {
-                        error = err;
-                        }
-                    iEventMessage->Complete( error );
-                    delete iEventMessage; iEventMessage = NULL;
-                    }
-                else if ( err == KErrNone )
-                    {
-                    // If iEventMessage is invalid and mute's value is
-                    // right, we will append event to iEventQue.
-                    // Else nothing to do.
-                    iEventQue.AppendL( unEvent );
-                    }                            
-                }
-
-            // Scale the volume level
-            // Get device's maximum volume value
-            TInt maxVolume = iDevice->MaxVolume();
-            // If max volume not KMaxVolume
-            if( maxVolume != KMaxVolume )
-                {
-                // Convert volume to match max volume 100
-                TReal tempVolumeLevel = volume;
-                TReal tempMaxVolume = maxVolume;
-                   
-                volume = KMaxVolume * tempVolumeLevel / tempMaxVolume;
-                }            
-            
-            if( iVolume != volume && volume >= 0 )
-                {
-                // State of volume changed, create an event and send it to
-                // the client side
-                unEvent.iEvent = EVolume;
-                unEvent.iValue = volume;
-                iVolume = volume;
-                if( iEventMessage )
-                    {
-                    TPckg<TUnsolicitedEventC> resp1( unEvent );
-                    TInt err = iEventMessage->Write( 1, resp1 );
-                    iEventMessage->Complete( err );
-                    delete iEventMessage; iEventMessage = NULL;
-                    }
-                else
-                    {
-                    iEventQue.AppendL( unEvent );
-                    }                            
-                }
-            
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::AvtLastChangeEvent
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::AvtLastChangeEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& aLastChange
-        )
-    {
-    // Is it for this device?
-    if( iPlaybackState != EUninitialized )
-        {
-        __LOG( "CUPnPPlaybackSession::AvtLastChangeEvent" );
-        
-        TUnsolicitedEventC event;
-        if( aLastChange.Find( KPlaying ) >= 0 )
-            {
-            __LOG( "AvtLastChangeEvent - PlayUser received" );
-            event.iEvent = EPlay;                            
-            iPlaybackState = EPlaying;
-            if( iEventMessage )
-                {
-                TPckg<TUnsolicitedEventC> resp1( event );
-                TInt err = iEventMessage->Write( 1, resp1 );
-                iEventMessage->Complete( err ); // Ok to complete with err?
-                delete iEventMessage; iEventMessage = NULL;
-                }
-            else
-                {
-                __LOG( "AvtLastChangeEvent - appending playuser" );
-                iEventQue.AppendL( event );
-                }            
-            }
-        else if( aLastChange.Find( KStopped ) >= 0 &&
-                 iPlaybackState != EStopped )
-            {
-            __LOG( "AvtLastChangeEvent - StopUser received" );
-            event.iEvent = EStop;                
-            iPlaybackState = EStopped;
-            if( iEventMessage )
-                {
-                TPckg<TUnsolicitedEventC> resp1( event );
-                TInt err = iEventMessage->Write( 1, resp1 );
-                iEventMessage->Complete( err ); // Ok to complete with err?
-                delete iEventMessage; iEventMessage = NULL;
-                }
-            else
-                {
-                __LOG( "AvtLastChangeEvent - appending stopuser" );
-                iEventQue.AppendL( event );
-                }    
-            }
-        else if( aLastChange.Find( KPaused ) >= 0 &&
-                 iPlaybackState != EPaused )
-            {
-            __LOG( "AvtLastChangeEvent - PauseUser received" );
-            event.iEvent = EPause;
-            iPlaybackState = EPaused;
-            if( iEventMessage )
-                {
-                __LOG( "CUPnPPlaybackSession::AvtLastChangeEvent" );
-                TPckg<TUnsolicitedEventC> resp1( event );
-                TInt err = iEventMessage->Write( 1, resp1 );
-                iEventMessage->Complete( err ); // Ok to complete with err?
-                delete iEventMessage; iEventMessage = NULL;
-                }
-            else
-                {
-                __LOG( "AvtLastChangeEvent - appending pauseuser" );
-                iEventQue.AppendL( event );
-                }
-            }
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CmSourceEvent
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CmSourceEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aSource*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CmSinkEvent
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CmSinkEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aSink*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CmConnectionsEvent
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CmConnectionsEvent(
-        const TDesC8& /*aUuid*/,
-        const TDesC8& /*aConnections*/
-        )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::HttpResponseL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::HttpResponseL( CUpnpHttpMessage* /*aMessage*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::DeviceDiscoveredL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::DeviceDiscoveredL( CUpnpDevice* /*aDevice*/ )
-    {
-    // No implementation required        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::DeviceDisappearedL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::DeviceDisappearedL( CUpnpDevice* /*aDevice*/ )
-    {
-    // No implementation required                   
-    }    
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::DeviceDisappearedL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::DeviceDisappearedL(
-    CUpnpAVDeviceExtended& aDevice )
-    {
-    __LOG( "CUPnPPlaybackSession::DeviceDisappearedL" );
-   
-    if( aDevice.Local() )
-        {
-        delete iLocalMediaServerUuid; iLocalMediaServerUuid = NULL; 
-        }
-    else if( iDeviceMessage ) // Target device
-        {
-        iDeviceMessage->Complete( KErrNone );
-        delete iDeviceMessage; iDeviceMessage = NULL;
-        }    
-    }
- 
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::SetLocalMSUuidL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::SetLocalMSUuidL( const TDesC8& aUuid )
-    {
-    HBufC8* tmp = aUuid.AllocL();
-    delete iLocalMediaServerUuid;
-    iLocalMediaServerUuid = tmp; 
-    } 
- 
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::SessionId
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-TInt CUPnPPlaybackSession::SessionId() const
-    {
-    return iSessionId;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::EventRequestL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::EventRequestL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::EventRequestL" );
-    
-    __ASSERTD( !iEventMessage, __FILE__, __LINE__ );
-    
-    TInt count = iEventQue.Count(); 
-    if( count )
-        {
-        __LOG( "EventRequestL - events in the que" );
-        // Events pending, get the event from que and complete the msg
-        TPckg<TUnsolicitedEventC> resp1( iEventQue[ count - 1 ] );
-        TInt err = aMessage.Write( 1, resp1 );
-        iEventQue.Remove( count - 1 ); 
-        aMessage.Complete( err ); // Ok to complete with err?
-        }
-    else
-        {
-        __LOG( "EventRequestL - storing the msg" );
-        iEventMessage = new (ELeave) RMessage2( aMessage );
-        
-        if( !iEventingActive )
-            {
-            __LOG( "EventRequestL - subscribing.." );
-            iServer.DeviceRepository().SubscribeDeviceL( iDevice->Uuid() );
-            iServer.Dispatcher().RegisterForEventsL( *this,
-                iDevice->Uuid() );
-            iEventingActive = ETrue;
-            }           
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelEventRequestL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelEventRequestL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelEventRequestL" );
-           
-    if( iEventingActive )
-        {
-        __LOG( "CancelEventRequestL - unsubscribing.." );
-        iServer.DeviceRepository().UnSubscribeDeviceL( iDevice->Uuid() );
-        iServer.Dispatcher().UnRegisterEvents( *this );
-        iEventingActive = EFalse;            
-        }
-        
-    if( iEventMessage )
-        {
-        __LOG( "CancelEventRequestL - cancelling the msg.." );
-        iEventMessage->Complete( KErrCancel );
-        delete iEventMessage; iEventMessage = NULL;   
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::SetURIL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::SetURIL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::SetURIL" );
-    
-    __ASSERTD( !iCommandMessage, __FILE__, __LINE__ );
-    
-    ResetL();
-
-    if( iPlaybackState == EPlaying || iPlaybackState == EPaused ||
-        iPlaybackState == EPlaySent )
-        {
-        iServer.ControlPoint().AvtStopActionL( iDevice->Uuid(),
-            iInstanceId );
-        }
-    
-    if( iItemShared )
-        {
-        iFileSharing->UnShareItemL( iSharedItem->Id() );
-        iItemShared = EFalse; 
-        }
-
-    // Uri is set by providing an item. Convert the item to xml document and
-    // send the action
-
-    __LOG( "SetURIL" );
-    
-    CUpnpAVRequest* tmpRequest = CUpnpAVRequest::NewLC();
-    
-    ReadReqFromMessageL( aMessage, 1 ,tmpRequest );
-    
-    CUpnpItem* tmpItem = CUpnpItem::NewL();
-    CleanupStack::PushL( tmpItem );
-    
-    ReadObjFromMessageL( aMessage, 2 ,tmpItem );
-
-    TPtrC8 uri = tmpRequest->URI();
-
-    const CUpnpElement& res = 
-        UPnPItemUtility::ResourceFromItemL( *tmpItem );
-    const CUpnpAttribute* protocolInfo = 
-        UPnPItemUtility::FindAttributeByName( 
-        res, KAttributeProtocolInfo );
-
-    if( !iDevice->MatchSinkProtocolInfo( protocolInfo->Value() ) )
-        {
-        // Did not match, try to find a match
-        TRAPD( err, uri.Set( iDevice->FindFirstMatchingInSinkL(
-            *tmpItem ) ) );
-        if( err == KErrNone )
-            {
-            // Suitable res-element found!
-            __LOG( "Suitable element found!" );
-            }
-        else if( err == KErrNotSupported )
-            {
-            // No suitable res-element
-            if( iDevice->DLNADeviceType() ==
-                CUpnpAVDeviceExtended::EDMR )
-                {
-                // DLNA content, DLNA device, no match -> leave
-                User::Leave( KErrNotSupported );                    
-                }
-            else
-                {
-                // Not a dlna device, try to set the uri of
-                // original res-element anyways
-                }
-            }
-        else
-            {
-            // Some error occured
-            User::Leave( err );
-            }    
-        }
-
-    ValidateProtocolInfoL( *protocolInfo );
-           
-    // Create metadata xml document
-    HBufC8* xmlDoc = CUPnPXMLParser::ItemAsXmlLC( *tmpItem );
-
-    iIPSessionIdCommand = iServer.ControlPoint().
-        AvtSetTransportUriActionL( iDevice->Uuid(), iInstanceId, uri,
-        //KNullDesC8 );
-        *xmlDoc );
-            
-    CleanupStack::PopAndDestroy( xmlDoc );
-    CleanupStack::PopAndDestroy( tmpItem );        
-    CleanupStack::PopAndDestroy( tmpRequest );      
-                         
-                
-    if( iIPSessionIdCommand > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionIdCommand );
-        }                             
-           
-    iCommandMessage = new (ELeave) RMessage2( aMessage );
-    
-    // after settransporturi, there is a delay to send play action.
-    if ( !iPlayDelayTimer->IsActive() )
-        {
-        iPlayDelayTimer->Start( 
-            0, KPlayDelayTimerInterval, 
-            TCallBack( PlayDelayTimeExpired , this ) );
-        }
-    else
-        {
-        iPlayDelayTimer->Cancel();
-        iPlayDelayTimer->Start( 
-            0, KPlayDelayTimerInterval, 
-            TCallBack( PlayDelayTimeExpired , this ) );
-        }
-    __LOG( "CUPnPPlaybackSession::SetURIL - end" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelSetURIL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelSetURIL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelSetURIL" );
-    
-    if( iCommandMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
-        iIPSessionIdCommand = KErrNotFound;
-        iCommandMessage->Complete( KErrCancel );
-        delete iCommandMessage; iCommandMessage = NULL;             
-        }
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::SetNextURIL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::SetNextURIL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::SetNextURIL" );
-    
-    __ASSERTD( !iCommandMessage, __FILE__, __LINE__ );
-    
-    ResetL();
-    
-    if( iNextItemShared )
-        {
-        iFileSharing->UnShareItemL( iNextSharedItem->Id() );
-        iNextItemShared = EFalse; 
-        }
-    
-    // Uri is set by providing an item. Convert the item to xml document and
-    // send the action
-    CUpnpAVRequest* tmpRequest = CUpnpAVRequest::NewLC();
-    
-    ReadReqFromMessageL( aMessage, 1 ,tmpRequest );
-    
-    CUpnpItem* tmpItem = CUpnpItem::NewL();
-    CleanupStack::PushL( tmpItem );
-    
-    ReadObjFromMessageL( aMessage, 2 ,tmpItem );
-
-    TPtrC8 uri = tmpRequest->URI();
-    
-    const CUpnpElement& res = 
-        UPnPItemUtility::ResourceFromItemL( *tmpItem );
-    const CUpnpAttribute* protocolInfo = 
-        UPnPItemUtility::FindAttributeByName( 
-        res, KAttributeProtocolInfo );
-          
-    if( !iDevice->MatchSinkProtocolInfo( protocolInfo->Value() ) )
-        {
-        // Did not match, try to find a match
-        TRAPD( err, uri.Set( iDevice->FindFirstMatchingInSinkL(
-            *tmpItem ) ) );
-        if( err == KErrNone )
-            {
-            // Suitable res-element found!
-            }
-        else if( err == KErrNotSupported )
-            {
-            // No suitable res-element
-            if( iDevice->DLNADeviceType() ==
-                CUpnpAVDeviceExtended::EDMR )
-                {
-                // DLNA content, DLNA device, no match -> leave
-                User::Leave( KErrNotSupported );                    
-                }
-            else
-                {
-                // Not a dlna device, try to set the uri of
-                // original res-element anyways
-                }    
-            }
-        else
-            {
-            // Some error occured
-            User::Leave( err );
-            }    
-        }
-
-    // Create metadata xml document
-    HBufC8* xmlDoc = CUPnPXMLParser::ItemAsXmlLC( *tmpItem );
-    
-    iIPSessionIdCommand = iServer.ControlPoint().
-        AvtSetNextTransportUriActionL( iDevice->Uuid(), iInstanceId, uri,
-        *xmlDoc );
-            
-
-    CleanupStack::PopAndDestroy( xmlDoc );
-    CleanupStack::PopAndDestroy( tmpItem );
-    CleanupStack::PopAndDestroy( tmpRequest );          
-                
-    if( iIPSessionIdCommand > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionIdCommand );
-        }                             
-           
-    iCommandMessage = new (ELeave) RMessage2( aMessage );
-    
-    __LOG( "CUPnPPlaybackSession::SetNextURIL - end" );
- 
-   }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelSetNextURIL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelSetNextURIL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelSetNextURIL" );
-    
-    //__ASSERTD( iCommandPending, User::Panic( KPanicText, __LINE__ ) );
-    if( iCommandMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
-        iIPSessionIdCommand = KErrNotFound;
-        iCommandMessage->Complete( KErrCancel );
-        delete iCommandMessage; iCommandMessage = NULL;            
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::PlayL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::PlayL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::PlayL" );
-    if ( !iPlayDelayTimer->IsActive() )
-        {
-        // timer is not running so some time has passed since subscribing
-    __ASSERTD( !iCommandMessage, __FILE__, __LINE__ );
-
-    ResetL();
-    
-    iIPSessionIdCommand = iServer.ControlPoint().AvtPlayActionL(
-        iDevice->Uuid(), iInstanceId, KNormalSpeed );
-    
-     if( iIPSessionIdCommand > 0 )
-        {
-        __LOG( "CUPnPPlaybackSession::PlayL - registering" );
-        // Register
-        iPlaybackState = EPlaySent;
-        iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionIdCommand );
-            }
-
-        }
-    else // less than KPlayDelayInterval passed since subscribe.
-        {
-        // issue the play after the timer expires to make sure some HW 
-        // renderers are not confused when beginning the playback.
-        iPlayRequested = ETrue;
-        }
-
-    iCommandMessage = new (ELeave) RMessage2( aMessage );
-    __LOG( "CUPnPPlaybackSession::PlayL - end" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelPlayL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelPlayL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelPlayL" );
-    
-    //__ASSERTD( iCommandPending, User::Panic( KPanicText, __LINE__ ) );
-    if( iCommandMessage )
-        {
-        // cancel postponed play
-        if ( iPlayDelayTimer->IsActive() )
-            {
-            iPlayDelayTimer->Cancel();
-            }
-
-        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
-        iIPSessionIdCommand = KErrNotFound;
-        iCommandMessage->Complete( KErrCancel );
-        delete iCommandMessage; iCommandMessage = NULL;            
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::StopL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::StopL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::StopL" );
-    
-    __ASSERTD( !iCommandMessage, __FILE__, __LINE__ );
-
-    ResetL();
-    // state stopped must be check before stopped action    
-    if( iPlaybackState != EStopped )
-        {
-        iIPSessionIdCommand = iServer.ControlPoint().AvtStopActionL(
-            iDevice->Uuid(), iInstanceId );
-        }
-    
-     if( iIPSessionIdCommand > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionIdCommand );
-        }        
-    iCommandMessage = new (ELeave) RMessage2( aMessage );
-    
-    __LOG( "CUPnPPlaybackSession::StopL - end" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelStopL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelStopL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelStopL" );
-    
-    if( iCommandMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
-        iIPSessionIdCommand = KErrNotFound;
-        iCommandMessage->Complete( KErrCancel );
-        delete iCommandMessage; iCommandMessage = NULL;            
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::PauseL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::PauseL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::PauseL" );
-    
-    __ASSERTD( !iCommandMessage, __FILE__, __LINE__ );
-
-    ResetL();
-    
-    iIPSessionIdCommand = iServer.ControlPoint().AvtPauseActionL(
-        iDevice->Uuid(), iInstanceId );
-    
-     if( iIPSessionIdCommand > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionIdCommand );
-        }
-    iCommandMessage = new (ELeave) RMessage2( aMessage );
-    
-    __LOG( "CUPnPPlaybackSession::PauseL - end" );                
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelPauseL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelPauseL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelPauseL" );                
-    
-    if( iCommandMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
-        iIPSessionIdCommand = KErrNotFound;
-        iCommandMessage->Complete( KErrCancel );
-        delete iCommandMessage; iCommandMessage = NULL;            
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::SetVolumeL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::SetVolumeL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::SetVolumeL" );                
-    
-    __ASSERTD( !iSettingMessage, __FILE__, __LINE__ );
-
-    ResetL();
-    
-    TInt volume = aMessage.Int1();
-    
-    TInt maxVolume = iDevice->MaxVolume();
-
-    // If max volume not KMaxVolume
-    if( maxVolume != KMaxVolume )
-        {
-        // Convert volume to match device's max volume
-        TReal tempVolumeLevel = volume;
-        TReal tempMaxVolume = maxVolume;
-        
-        volume = tempMaxVolume * tempVolumeLevel / KMaxVolume;
-        }
-       
-
-
-    iIPSessionIdSetting = iServer.ControlPoint().RcSetVolumetActionL(
-        iDevice->Uuid(), iInstanceId, KMasterVolume, volume );
-    
-     if( iIPSessionIdSetting > 0 )
-        {
-        __LOG( "CUPnPPlaybackSession::SetVolumeL - registering" );
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionIdSetting );
-        }
-        
-    iSettingMessage = new (ELeave) RMessage2( aMessage );                
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelSetVolumeL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelSetVolumeL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelSetVolumeL" );                
-    
-    if( iSettingMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
-        iIPSessionIdSetting = KErrNotFound;
-        iSettingMessage->Complete( KErrCancel );
-        delete iSettingMessage; iSettingMessage = NULL;            
-        }
-    }    
-   
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::GetVolumeL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::GetVolumeL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::GetVolumeL" );                
-    
-    __ASSERTD( !iSettingMessage, __FILE__, __LINE__ );
-
-    ResetL();
-    
-    iIPSessionIdSetting = iServer.ControlPoint().RcGetVolumetActionL(
-        iDevice->Uuid(), iInstanceId, KMasterVolume );
-    
-     if( iIPSessionIdSetting > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionIdSetting );
-        }
-    iSettingMessage = new (ELeave) RMessage2( aMessage );                    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelGetVolumeL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelGetVolumeL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelGetVolumeL" );                
-    
-    if( iSettingMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
-        iIPSessionIdSetting = KErrNotFound;
-        iSettingMessage->Complete( KErrCancel );
-        delete iSettingMessage; iSettingMessage = NULL;            
-        }
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::SetMuteL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::SetMuteL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::SetMuteL" );                
-    
-    __ASSERTD( !iSettingMessage, __FILE__, __LINE__ );
-
-    ResetL();
-
-    TInt mute = aMessage.Int1();
-    if( mute )
-        {
-        iIPSessionIdSetting = iServer.ControlPoint().RcSetMuteActionL(
-            iDevice->Uuid(), iInstanceId, KMasterVolume, KMuteOn );        
-        }
-    else
-        {
-        iIPSessionIdSetting = iServer.ControlPoint().RcSetMuteActionL(
-            iDevice->Uuid(), iInstanceId, KMasterVolume, KMuteOff );                
-        }    
-    
-     if( iIPSessionIdSetting > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionIdSetting );
-        }
-        
-    iSettingMessage = new (ELeave) RMessage2( aMessage );                 
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelSetMuteL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelSetMuteL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelSetMuteL" );                
-    
-    if( iSettingMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
-        iIPSessionIdSetting = KErrNotFound;
-        iSettingMessage->Complete( KErrCancel );
-        delete iSettingMessage; iSettingMessage = NULL;            
-        }
-    }    
-   
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::GetMuteL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::GetMuteL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::GetMuteL" );                
-    
-    __ASSERTD( !iSettingMessage, __FILE__, __LINE__ );
-
-    ResetL();
-    
-    iIPSessionIdSetting = iServer.ControlPoint().RcGetMuteActionL(
-        iDevice->Uuid(), iInstanceId, KMasterVolume );
-    
-     if( iIPSessionIdSetting > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionIdSetting );
-        }
-    iSettingMessage = new (ELeave) RMessage2( aMessage );                    
-    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelGetMuteL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelGetMuteL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelGetMuteL" );                
-    
-    if( iSettingMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
-        iIPSessionIdSetting = KErrNotFound;
-        iSettingMessage->Complete( KErrCancel );
-        delete iSettingMessage; iSettingMessage = NULL;            
-        }
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::GetPositionInfoL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::GetPositionInfoL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::GetPositionInfoL" );                
-    
-    __ASSERTD( !iSettingMessage, __FILE__, __LINE__ );
-
-    ResetL();
-
-    iIPSessionIdSetting = iServer.ControlPoint().AvtPositionInfoActionL(
-        iDevice->Uuid(), iInstanceId );
-    
-     if( iIPSessionIdSetting > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionIdSetting );
-        }
-    iSettingMessage = new (ELeave) RMessage2( aMessage );
-    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelGetPositionInfoL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelGetPositionInfoL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelGetPositionInfoL" );                
-    
-    if( iSettingMessage )
-        {
-        iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
-        iIPSessionIdSetting = KErrNotFound;
-        iSettingMessage->Complete( KErrCancel );
-        delete iSettingMessage; iSettingMessage = NULL;            
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::DeviceDisappearedRequestL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::DeviceDisappearedRequestL(
-    const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPPlaybackSession::DeviceDisappearedRequestL" );
-    
-    __ASSERTD( !iDeviceMessage, __FILE__, __LINE__ );
-    
-    iDeviceMessage = new (ELeave ) RMessage2( aMessage );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::CancelDeviceDisappearedRequestL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::CancelDeviceDisappearedRequestL()
-    {
-    __LOG( "CUPnPPlaybackSession::CancelDeviceDisappearedRequestL" );
-    
-    if( iDeviceMessage )
-        {
-        iDeviceMessage->Complete( KErrCancel );
-        delete iDeviceMessage; iDeviceMessage = NULL;             
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::ParseBrowseResponseL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-HBufC8* CUPnPPlaybackSession::ParseBrowseResponseL( const TDesC8& aResponse )
-    {
-    __LOG( "CUPnPPlaybackSession::ParseBrowseResponseL" );                
-    
-    HBufC8* resource = NULL;
-    
-    CUPnPXMLParser* parser = CUPnPXMLParser::NewL();
-    CleanupStack::PushL( parser );
-    
-    RPointerArray<CUpnpObject> array;
-    CleanupResetAndDestroyPushL( array );
-    
-    parser->ParseResultDataL( array, aResponse );
-    
-    if( array.Count() == KExpectedCount )
-        {
-        if( array[ 0 ]->ObjectType() == EUPnPItem )
-            {
-            CUpnpItem* item = static_cast<CUpnpItem*>( array[ 0 ] );
-            resource = UPnPItemUtility::ResourceFromItemL(
-                *item ).Value().AllocL();
-            CleanupStack::PushL( resource );
-
-            const CUpnpElement& res = 
-                UPnPItemUtility::ResourceFromItemL( *item );
-            const CUpnpAttribute* protocolInfo = 
-                UPnPItemUtility::FindAttributeByName( 
-                res, KAttributeProtocolInfo );
-
-            if( !iDevice->MatchSinkProtocolInfo( protocolInfo->Value() ) )
-                {
-               TPtrC8 uri;
-                // Did not match, try to find a match
-                TRAPD( err, uri.Set( iDevice->FindFirstMatchingInSinkL(
-                    *item ) ) );
-                if( err == KErrNone )
-                    {
-                    // Suitable res-element found!
-                    CleanupStack::PopAndDestroy( resource );
-                    resource = uri.AllocL();
-                    }
-                else if( err == KErrNotSupported )
-                    {
-                    // No suitable res-element
-                    if( iDevice->DLNADeviceType() ==
-                        CUpnpAVDeviceExtended::EDMR )
-                        {
-                        // DLNA content, DLNA device, no match -> leave
-                        User::Leave( KErrNotSupported );                    
-                        }
-                    else
-                        {
-                        // Not a dlna device, try to set the uri of
-                        // original res-element anyways
-                        CleanupStack::Pop( resource );
-                        }    
-                    }
-                else
-                    {
-                    // Some error occured
-                    User::Leave( err );
-                    }    
-                }
-            }
-        else
-            {
-            User::Leave( KErrGeneral );
-            }    
-        }
-    else
-        {
-        User::Leave( KErrGeneral );
-        }    
-        
-    CleanupStack::PopAndDestroy( &array );
-    CleanupStack::PopAndDestroy( parser );
-       
-    __LOG( "CUPnPPlaybackSession::ParseBrowseResponseL - end" );
-    
-    if( !resource )
-        {
-        User::Leave( KErrGeneral );
-        }
-        
-    return resource;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::Uuid
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-const TDesC8& CUPnPPlaybackSession::Uuid() const
-    {
-    if( iDevice )
-        {
-        return iDevice->Uuid();
-        }
-    else
-        {
-        return KNullDesC8;
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::EncodeXmlL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-HBufC8* CUPnPPlaybackSession::EncodeXmlL( const TDesC8& aResult )
-    {
-    HBufC8* tmpBuf = aResult.AllocLC();
-    HBufC8* result = UpnpString::EncodeXmlStringL( tmpBuf );
-    CleanupStack::PopAndDestroy( tmpBuf );
-    return result;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::Reset
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::ResetL()
-    {
-    __LOG( "CUPnPPlaybackSession::ResetL" );
-    
-    if( !iServer.DeviceRepository().IsWlanActive() )    
-        {
-        __LOG( "Reset - disconnected" );
-        User::Leave( KErrDisconnected );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::ReadObjFromMessageL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::ReadObjFromMessageL( const RMessage2& aMessage, 
-    TInt aSlot, CUpnpObject* aObj )
-    {
-    // create buffer
-    TInt len = aMessage.GetDesMaxLength( aSlot );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
-    
-    // read stream
-    RDesReadStream stream( *buf );
-    CleanupClosePushL( stream );
-    
-    // internalize object
-    stream >> *aObj;
-    
-    // clean up
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buf );
-    }    
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::ReadReqFromMessageL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::ReadReqFromMessageL( const RMessage2& aMessage, 
-    TInt aSlot, CUpnpAVRequest* aReq ) 
-    {
-    // create buffer
-    TInt len = aMessage.GetDesMaxLength( aSlot );
-    HBufC8* buf = HBufC8::NewLC( len );
-    TPtr8 ptr( buf->Des() );
-    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
-    
-    // read stream
-    RDesReadStream stream( *buf );
-    CleanupClosePushL( stream );
-    
-    // internalize object
-    stream >> *aReq;
-    
-    // clean up
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buf );
-    }    
-
-void CUPnPPlaybackSession::ValidateProtocolInfoL( const CUpnpAttribute&
-    aResource )
-    {
-    __LOG( "CUPnPPlaybackSession::ValidateProtocolInfoL" );
-    
-    // Whe'd like to modify the original protocolInfo, that's why constness
-    // is casted away
-    CUpnpAttribute& attr = const_cast<CUpnpAttribute&>( aResource );
-    
-    // ProtocolInfo-wrapper takes care of 4th field validation, omitting
-    // invalid optional parameters
-    CUpnpDlnaProtocolInfo* tmpInfo = 
-        CUpnpDlnaProtocolInfo::NewL( attr.Value() );
-    CleanupStack::PushL( tmpInfo );
-    
-    tmpInfo->SetSecondFieldL( KAsterisk ); // Second field must be '*'
-    
-    attr.SetValueL( tmpInfo->ProtocolInfoL() );
-        
-    CleanupStack::PopAndDestroy( tmpInfo );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::SendPlayIfNeededL
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-void CUPnPPlaybackSession::SendPlayIfNeededL()
-    {
-    __LOG( "CUPnPPlaybackSession::SendPlayIfNeededL" );
-    if ( iPlayRequested )
-        {
-        // during the timer was running, there was a play request.
-        // handle it here
-        iPlayRequested = EFalse; // play request is being handled
-
-        ResetL();
-
-        iIPSessionIdCommand = iServer.ControlPoint().AvtPlayActionL(
-            iDevice->Uuid(), iInstanceId, KNormalSpeed );
-
-        if( iIPSessionIdCommand > 0 )
-            {
-            __LOG( "CUPnPPlaybackSession::SendPlayIfNeededL - registering" );
-            // Register
-            iPlaybackState = EPlaySent;
-            iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
-            }
-        else
-            {
-            User::Leave( iIPSessionIdCommand );
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPPlaybackSession::PlayDelayTimeExpired
-// See upnpplaybacksession.h
-// --------------------------------------------------------------------------
-TInt CUPnPPlaybackSession::PlayDelayTimeExpired( TAny* aPtr )
-    {
-    __LOG( "CUPnPPlaybackSession::PlayDelayTimeExpired" );
-    TRAPD( err, ( static_cast< CUPnPPlaybackSession* >( aPtr ) )->
-           SendPlayIfNeededL() );
-    
-    if ( err )
-        {
-        __LOG( "CUPnPPlaybackSession::PlayDelayTimeExpired error" );
-        }
-
-    return ETrue;
-    }
-
-// end of file
+/*
+* Copyright (c) 2006-2009 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:      implements a renderer playback state machine
+*
+*/
+
+// INCLUDE FILES
+// System
+#include <in_sock.h>
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+
+// upnp stack api
+#include <upnpdevice.h>
+#include <upnpservice.h>
+#include <upnpstring.h>
+
+// dlnasrv / mediaserver api
+#include <upnpcontainer.h>
+#include <upnpitem.h>
+#include <upnpelement.h>
+#include <upnpdlnaprotocolinfo.h>
+
+// dlnasrv / xmlparser api
+#include "upnpxmlparser.h"
+
+// dlnasrv / avcontroller api
+#include "upnpavcontrollerglobals.h"
+
+// dlnasrv / avcontroller helper api
+#include "upnpitemutility.h"
+#include "upnpconstantdefs.h" // for upnp-specific stuff
+
+// dlnasrv / internal api
+#include "upnpmetadatafetcher.h"
+#include "upnpcommonutils.h"
+#include "upnpcdsreselementutility.h"
+#include "upnpxmleventparser.h"
+
+// dlnasrv / avcontroller internal
+#include "upnpavcontrollerserver.h"
+#include "upnpavrequest.h"
+#include "upnpavdispatcher.h"
+#include "upnpaverrorhandler.h"
+#include "upnpavdeviceextended.h"
+#include "upnpdevicerepository.h"
+#include "upnpplaybacksession.h"
+#include "upnpavcontrolpoint.h"
+#include "upnpavcpstrings.h"
+
+using namespace UpnpAVCPStrings;
+
+_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
+#include "upnplog.h"
+
+_LIT8( KNormalSpeed,        "1" );
+_LIT8( KMasterVolume,       "Master" );
+_LIT8( KMuteOn,             "1" );
+_LIT8( KMuteOff,            "0" );
+_LIT8( KAsterisk,           "*" );
+_LIT8( KConnectioMgr,       "urn:upnp-org:serviceId:ConnectionManager" );
+_LIT8( KInput,              "Input" );
+_LIT8( KDefaultPeerConnectionID, "-1" );
+
+const TInt KDefaultInstanceId   = 0;
+const TInt KMaxVolume           = 100;
+const TInt KMaxIntLength        = 10;
+
+_LIT8( KNoMedia, "NO_MEDIA_PRESENT" );
+_LIT8( KPlaying, "PLAYING" );
+_LIT8( KPausedPlayback, "PAUSED_PLAYBACK" );
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::NewL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+CUPnPPlaybackSession* CUPnPPlaybackSession::NewL
+    (
+    CUpnpAVControllerServer& aServer,
+    TInt aSessionId,
+    const TDesC8& aUuid
+    )
+    {
+    CUPnPPlaybackSession* self = new (ELeave) CUPnPPlaybackSession(
+        aServer, aSessionId );
+    CleanupStack::PushL( self );
+    self->ConstructL( aUuid );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CUPnPPlaybackSession
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+CUPnPPlaybackSession::CUPnPPlaybackSession
+    (
+    CUpnpAVControllerServer& aServer,
+    TInt aSessionId
+    ):
+    iServer( aServer ),
+    iSessionId( aSessionId ),
+    iAVTInstanceId( KDefaultInstanceId ),
+    iRCInstanceId( KDefaultInstanceId ),
+    iConnectionId( KErrNotFound ),
+    iIPSessionIdCommand( KErrNotFound ),
+    iIPSessionIdSetting( KErrNotFound ),
+    iEventingActive( EFalse ),
+    iPlaybackState( EUninitialized ),
+    iMuteState( EUnknown ),
+    iVolume( KErrNotFound ),
+    iInitialEventReceived(EFalse),
+    iPreviousTransportState( CUPnPAVTEvent::ENoMediaPresent )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::~CUPnPPlaybackSession
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+CUPnPPlaybackSession::~CUPnPPlaybackSession()
+    {
+    __LOG( "CUPnPPlaybackSession::~CUPnPPlaybackSession" );
+    
+    if( ( iPlaybackState == EPlaying || iPlaybackState == EPaused ) && 
+         !iInitialEventReceived )
+        {
+        if( iDevice && iServer.DeviceRepository().IsWlanActive() )
+            {
+            __LOG( "~CUPnPPlaybackSession - \
+playback still ongoing, send stop" );    
+            TRAP_IGNORE( EmergencyStopL() );
+            }
+        else
+            {
+            __LOG( "~CUPnPPlaybackSession - \
+playback still ongoing, wlan not active" );    
+            }    
+        }
+
+    delete iEventMessage;
+    delete iSettingMessage;
+    delete iCommandMessage;
+    delete iDeviceMessage;
+    delete iInitialEventMsg;
+    
+    delete iLocalMediaServerUuid;
+    delete iEventParser;
+    
+    iEventQue.Reset();
+    iEventQue.Close();
+
+    if( iEventingActive && iDevice )
+        {
+        __LOG( "~CUPnPPlaybackSession - UnSubscribeDeviceL" );
+        TRAP_IGNORE( iServer.DeviceRepository().UnSubscribeDeviceL(
+            iDevice->Uuid() ) );
+        iServer.Dispatcher().UnRegisterEvents( *this );
+        iEventingActive = EFalse;            
+        }
+        
+    delete iDevice;        
+    
+    delete iPInfoForPrevious;
+    delete iCurrentUri;
+    delete iCurrentItem;
+    
+    if( iTimer )
+        {
+        iTimer->Cancel();
+        delete iTimer;
+        }
+	delete iUuid;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::ConstructL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::ConstructL( const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPPlaybackSession::ConstructL" );
+    
+    iEventParser = CUPnPXMLEventParser::NewL();
+    
+    const RPointerArray<CUpnpAVDeviceExtended>& devList =
+        iServer.DeviceRepository().DeviceList();
+    TInt count = devList.Count();
+    TInt i;
+    for( i = 0; i < count; i++ )
+        {
+        if( devList[ i ]->Local() )
+            {
+            __LOG( "CUPnPPlaybackSession::ConstructL - Local MS found!" );
+            
+            __ASSERT( !iLocalMediaServerUuid, __FILE__, __LINE__ );
+            iLocalMediaServerUuid = devList[i]->Uuid().AllocL();
+            }
+        if( devList[ i ]->Uuid() == aUuid )
+            {
+            __ASSERT( !iDevice, __FILE__, __LINE__ );
+            iDevice = CUpnpAVDeviceExtended::NewL( *devList[ i ] );
+            }
+        }        
+    if( !iDevice )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    iUuid = HBufC8::NewL( aUuid.Length() );
+    TPtr8 uuidPtr( iUuid->Des() );
+    uuidPtr.Copy( aUuid );
+    
+    iTimer = CUPnPAVTimer::NewL( *this, CUPnPAVTimer::ETimerFailSafe );
+
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CpDeviceL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+const CUpnpDevice* CUPnPPlaybackSession::CpDeviceL()
+    {
+    const CUpnpDevice* device = iServer.ControlPoint().Device( iUuid->Des() );
+    if( !device )
+        {
+		// Control point resets device information once renderer or wlan 
+		// connection lost. Avoid panicing by leaving.
+        __LOG( "CUPnPPlaybackSession::CpDeviceL - no device, leaving" );
+        User::Leave( KErrNotReady );
+        }
+    return device;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::ActionResponseL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::ActionResponseL( CUpnpAction* aAction )
+    {
+    if ( aAction->Name().Compare( KSetVolume ) == 0 )
+        {
+        RcSetVolumeResponse(
+            aAction->Error(),
+            aAction->ArgumentValue( KDesiredVolume ) );
+        }
+    else if ( aAction->Name().Compare( KGetVolume ) == 0 )
+        {
+        RcVolumeResponse( 
+            aAction->Error(),
+            aAction->ArgumentValue( KCurrentVolume ) );
+        }
+    else if ( aAction->Name().Compare( KSetMute ) == 0 )
+        {
+        RcSetMuteResponse( 
+            aAction->Error(),
+            aAction->ArgumentValue( KDesiredMute ) );
+        }
+    else if ( aAction->Name().Compare( KGetMute ) == 0 )
+        {
+        RcMuteResponse( 
+             aAction->Error(),
+             aAction->ArgumentValue( KCurrentMute ) );
+        }
+    else if ( aAction->Name().Compare( KSetAVTransportURI ) == 0 )
+        {
+        AvtSetTransportUriResponse(
+            aAction->Error() );
+        }
+    else if ( aAction->Name().Compare( KGetMediaInfo ) == 0 )
+        {
+        AvtGetMediaInfoResponse(
+            aAction->Error(),
+            aAction->ArgumentValue( KCurrentURI ) );
+        }
+    else if ( aAction->Name().Compare( KGetTransportInfo ) == 0 )
+        {
+        AvtGetTransportInfoResponse(
+            aAction->Error(),
+            aAction->ArgumentValue( KCurrentTransportState ) );
+        }
+    else if ( aAction->Name().Compare( KGetPositionInfo ) == 0 )
+        {
+        AvtPositionInfoResponse(
+            aAction->Error(),
+            aAction->ArgumentValue( KTrackDuration ),
+            aAction->ArgumentValue( KRelTime ) );
+        }
+    else if ( aAction->Name().Compare( KStop ) == 0 )
+        {				
+        AvtStopResponse(
+            aAction->Error() );
+        }
+    else if ( aAction->Name().Compare( KPlay ) == 0 )
+        {				
+        AvtPlayResponse(
+            aAction->Error() );
+        }
+    else if ( aAction->Name().Compare( KPause ) == 0 )
+        {		
+        AvtPauseResponse(
+            aAction->Error() );
+        }
+    else if ( aAction->Name().Compare( KSeek ) == 0 )
+        {	
+        AvtSeekResponse(
+            aAction->Error() );
+        }
+    else if (aAction->Name().Compare( KPrepareForConnection ) == 0)
+        {
+        TLex8 connectionLex1( aAction->ArgumentValue( KConnectionId ) );
+        TInt connectionId;
+        User::LeaveIfError( connectionLex1.Val( connectionId ) );
+        TLex8 transportLex1( aAction->ArgumentValue( KAVTransportId ) );
+        TInt transportId;
+        User::LeaveIfError( transportLex1.Val( transportId ) );
+        TLex8 rscLex3( aAction->ArgumentValue( KRcsID ) );
+        TInt rscId;
+        User::LeaveIfError( rscLex3.Val( rscId ) );
+        CmPrepareResponse(
+            aAction->Error(),
+            connectionId,
+            transportId,
+            rscId );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::StateUpdatedL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::StateUpdatedL(CUpnpService* aService)
+    {
+    if (aService->ServiceType().Match( KRenderingControl ) != KErrNotFound )
+        {
+        CUpnpStateVariable* lastChange = aService->StateVariable( KLastChange );
+        if( lastChange ) 
+            {
+            RcLastChangeEvent(
+                lastChange->Value() );
+            }
+        }
+    else if (aService->ServiceType().Match( KAVTransport ) != KErrNotFound )
+        {
+        CUpnpStateVariable* lastChange = aService->StateVariable( KLastChange );
+        if( lastChange )
+            {
+            AvtLastChangeEvent(
+                lastChange->Value() );
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::HttpResponseL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::HttpResponseL( CUpnpHttpMessage* /*aMessage*/ )
+    {
+    // No implementation required
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::DeviceDiscoveredL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::DeviceDiscoveredL( CUpnpDevice* /*aDevice*/ )
+    {
+    // No implementation required
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::DeviceDisappearedL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::DeviceDisappearedL( CUpnpDevice* /*aDevice*/ )    {
+    // No implementation required
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::RcSetVolumeResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::RcSetVolumeResponse(
+    TInt aErr, 
+    const TDesC8& aDesiredVolume )
+    {
+    __LOG1( "CUPnPPlaybackSession::RcSetVolumeResponse: %d", aErr );
+    
+    iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
+    iIPSessionIdSetting = KErrNotFound;
+    
+    if( iSettingMessage )
+        {
+        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPRenderingControlError );    
+        if( aErr == KErrNone )
+            {
+            TInt vol;
+            TLex8 lex( aDesiredVolume );
+            TInt err = lex.Val( vol );
+            if(  err == KErrNone )
+                {
+                TInt maxVolume = iDevice->MaxVolume();
+                // If max volume not KMaxVolume
+                if( maxVolume != KMaxVolume )
+                    {
+                    // Convert volume to match max volume 100
+                    TReal tempVolumeLevel = vol;
+                    TReal tempMaxVolume = maxVolume;
+                       
+                    vol = KMaxVolume * tempVolumeLevel / tempMaxVolume;
+                    }
+                iVolume = vol;
+                TPckg<TInt> resp2( vol );
+                iSettingMessage->Write( 2, resp2 );
+
+                iSettingMessage->Complete( EAVControllerSetVolumeCompleted );
+                delete iSettingMessage; iSettingMessage = NULL;       
+                }
+            else
+                {
+                iSettingMessage->Complete( err );
+                delete iSettingMessage; iSettingMessage = NULL;
+                }    
+            }
+        else
+            {
+            iSettingMessage->Complete( aErr );
+            delete iSettingMessage; iSettingMessage = NULL;
+            }                   
+        }
+    else
+        {
+        __LOG( "RcSetVolumeResponse - no msg" );
+        }    
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::RcVolumeResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::RcVolumeResponse(
+    TInt aErr, 
+    const TDesC8& aCurrentVolume)
+    {
+    __LOG1( "CUPnPPlaybackSession::RcVolumeResponse: %d", aErr );    
+    
+    iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
+    iIPSessionIdSetting = KErrNotFound;
+
+    if( iSettingMessage )
+        {
+        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPRenderingControlError );
+        
+        if( aErr == KErrNone )
+            {
+            TInt vol;
+            TLex8 lex( aCurrentVolume );
+            TInt err = lex.Val( vol );
+            if(  err == KErrNone )
+                {
+                
+               // Get device's maximum volume value
+                TInt maxVolume = iDevice->MaxVolume();
+
+                // If max volume not KMaxVolume
+                if( maxVolume != KMaxVolume )
+                    {
+                    // Convert volume to match max volume KMaxVolume
+                    TReal tempVolumeLevel = vol;
+                    TReal tempMaxVolume = maxVolume;
+                    
+                    vol = KMaxVolume * tempVolumeLevel / tempMaxVolume;
+                    }            
+                iVolume = vol;
+                TPckg<TInt> resp1( vol );
+                iSettingMessage->Write( 1, resp1 );
+
+                iSettingMessage->Complete( EAVControllerGetVolumeCompleted );
+                delete iSettingMessage; iSettingMessage = NULL;      
+                }
+            else
+                {
+                iSettingMessage->Complete( err );
+                delete iSettingMessage; iSettingMessage = NULL;      
+                }    
+            }
+        else
+            {
+            iSettingMessage->Complete( aErr );
+            delete iSettingMessage; iSettingMessage = NULL;      
+            }                               
+        }
+    else
+        {
+        __LOG( "RcVolumeResponse - no msg" );
+        }    
+
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::RcSetMuteResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::RcSetMuteResponse(
+    TInt aErr, 
+    const TDesC8& aDesiredMute )
+    {
+    __LOG1( "CUPnPPlaybackSession::RcSetMuteResponse: %d", aErr );    
+
+    iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
+    iIPSessionIdSetting = KErrNotFound;
+    
+    if( iSettingMessage )
+        {
+        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPRenderingControlError );    
+        
+        if( aErr == KErrNone )
+            {
+            TInt mute( EUnknown );
+            TLex8 lex( aDesiredMute );
+            TInt err = lex.Val( mute );
+            
+            // If mute's value isn't ENotMuted or EMuted, 
+            // we think the value is incorrect.
+            if ( err == KErrNone && mute != ENotMuted && mute != EMuted )
+                {
+                err = KErrArgument;
+                }
+
+            if(  err == KErrNone )
+                {
+                iMuteState = (TMuteState)mute;
+                TPckg<TInt> resp2( mute );
+                iSettingMessage->Write( 2, resp2 );
+
+                iSettingMessage->Complete( EAVControllerSetMuteCompleted );
+                delete iSettingMessage; iSettingMessage = NULL;            
+                }
+            else
+                {
+                iSettingMessage->Complete( err );
+                delete iSettingMessage; iSettingMessage = NULL;      
+                }    
+            }
+        else
+            {
+            iSettingMessage->Complete( aErr );
+            delete iSettingMessage; iSettingMessage = NULL;      
+            }                           
+        }
+    else
+        {
+        __LOG( "RcSetMuteResponse - no msg" );
+        }    
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::RcMuteResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::RcMuteResponse(
+    TInt aErr, 
+    const TDesC8& aCurrentMute )
+    {
+    __LOG1( "CUPnPPlaybackSession::RcMuteResponse: %d" , aErr );
+
+    iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
+    iIPSessionIdSetting = KErrNotFound;
+
+    if( iSettingMessage )
+        {
+        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPRenderingControlError );
+        
+        if( aErr == KErrNone )
+            {
+            TInt mute( EUnknown );
+            TLex8 lex( aCurrentMute );
+            TInt err = lex.Val( mute );
+
+            // If mute's value isn't ENotMuted or EMuted, 
+            // we think the value is incorrect.
+            if ( err == KErrNone && mute != ENotMuted && mute != EMuted )
+                {
+                err = KErrArgument;
+                }
+
+            if(  err == KErrNone )
+                {
+                iMuteState = (TMuteState)mute;
+                TPckg<TInt> resp1( mute );
+                iSettingMessage->Write( 1, resp1 );
+
+                iSettingMessage->Complete( EAVControllerGetMuteCompleted );
+                delete iSettingMessage; iSettingMessage = NULL;
+                }
+            else
+                {
+                iSettingMessage->Complete( err );
+                delete iSettingMessage; iSettingMessage = NULL;
+                }    
+            }
+        else
+            {
+            iSettingMessage->Complete( aErr );
+            delete iSettingMessage; iSettingMessage = NULL;
+            }                                   
+        }
+    else
+        {
+        __LOG( "RcMuteResponse - no msg" );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::AvtSetTransportUriResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::AvtSetTransportUriResponse(
+    TInt aErr )
+    {
+    __LOG1( "CUPnPPlaybackSession::AvtSetTransportUriResponse: %d", aErr );  
+
+    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+
+    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+        EUPnPAVTransportError );    
+
+    if( aErr == KErrNone )
+        {
+        if( iPlaybackState == EStopped )
+            {
+            __LOG( "CUPnPPlaybackSession::AvtSetTransportUriResponse - \
+Already in stopped state" );
+            
+            // Lastchangeevent came already!                         
+            }
+        else
+            {
+            iIPSessionIdCommand = KErrNotFound;
+            
+            __LOG( "CUPnPPlaybackSession::AvtSetTransportUriResponse - \
+Start waiting for CurrentUriMetadata" );
+            
+            iTimer->Cancel();
+            iTimer->Start( KTimerCycle10 );
+            }      
+        }
+    else
+        {
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        
+        iPlaybackState = EStopped;
+        iExpectedEvent = EEventNone;
+        iCommandMessage->Complete( aErr );
+        delete iCommandMessage; iCommandMessage = NULL;      
+        }                       
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::AvtGetMediaInfoResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+//
+void CUPnPPlaybackSession::AvtGetMediaInfoResponse(
+    TInt aErr,
+    const TDesC8& aCurrentUri )
+    {
+    // GetMediaInfo action request is issued in playing state when an unexpected 
+    // playing event is received.  If the URI in the renderer does not match with 
+    // iCurrentUri, it is intepreted as a case where the renderer is being 
+    // controlled by some other Control Point and therefore a stop event is propagated.
+        
+    __LOG1( "CUPnPPlaybackSession::AvtGetMediaInfoResponse %d", aErr );
+    
+    if ( iCheckForHijackedRenderer )
+        {
+        __LOG8_1( "CUPnPPlaybackSession::AvtGetMediaInfoResponse: %S",
+                &aCurrentUri );
+
+        __LOG8_1( "CUPnPPlaybackSession::AvtGetMediaInfoResponse, iCurrentUri: %S",
+                iCurrentUri );
+
+        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+        iIPSessionIdCommand = KErrNotFound;
+
+        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+                EUPnPConnectionManagerError );
+            
+        if( aErr == KErrNone && iCurrentUri && *iCurrentUri != aCurrentUri )
+            {
+            // not our URI playing, renderer is hijacked    
+            if( iPlaybackState != EStopped )
+                {
+                // if we're not yet stopped, propagate a stop event    
+                __LOG( "CUPnPPlaybackSession::AvtGetMediaInfoResponse -\
+unexpected Uri, renderer is being controlled by someone else - propagate a stop event" );      
+                iPlaybackState = EHalted;
+                TUnsolicitedEventC event;
+                event.iEvent = EStop;
+                event.iValue = KErrNotReady;
+                PropagateEvent( event );                    
+                }
+            else
+                {
+                // just ignore as someone else keeps controlling the renderer    
+                __LOG( "CUPnPPlaybackSession::AvtGetMediaInfoResponse -\
+unexpected Uri, renderer is still being controlled by someone else - ignoring this event" );                      
+                }
+            }
+        
+        iCheckForHijackedRenderer = EFalse;
+        }            
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::AvtGetTransportInfoResponse
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+//
+void CUPnPPlaybackSession::AvtGetTransportInfoResponse(
+    TInt aErr,
+    const TDesC8& aCurrenTransportState )
+    {
+    __LOG1( "CUPnPPlaybackSession::AvtGetTransportInfoResponse %d", aErr );
+
+    __LOG8_1( "CUPnPPlaybackSession::AvtGetTransportInfoResponse: %S",
+            &aCurrenTransportState );
+
+    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+    iIPSessionIdCommand = KErrNotFound;
+ 
+    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPConnectionManagerError );
+    
+    if( aErr == KErrNone )
+        {            
+        // Send AVTranportUri-action. If an error occurs (leaves), complete
+        // the message with error code. No futher processing can be done
+        
+        if( aCurrenTransportState == KNoMedia )
+            {
+            iPlaybackState = ENoMedia;
+            }
+        else if( aCurrenTransportState == KPlaying )
+            {
+            iPlaybackState = EPlaying;
+            }
+        else if( aCurrenTransportState == KPausedPlayback )
+            {
+            iPlaybackState = EPaused;
+            }
+        else
+            {
+            iPlaybackState = EStopped;
+            }
+        
+        TRAP( aErr, SendAVTransportUriActionL() );
+        if( aErr != KErrNone )
+            {
+            __LOG1( "CUPnPPlaybackSession::AvtGetTransportInfoResponse -\
+SendAVTransportUriActionL failed with code %d", aErr  );
+            iCommandMessage->Complete( aErr );
+            delete iCommandMessage; iCommandMessage = NULL;
+            }
+        }
+    else
+        {
+        // Something wrong with the action. Complete the message with error
+        // code. No further processing can be dome.
+        __LOG1( "CUPnPPlaybackSession::AvtGetTransportInfoResponse - \
+action failed with code %d", aErr  );
+        
+        delete iCurrentItem; iCurrentItem = NULL;
+        delete iCurrentUri; iCurrentUri = NULL;
+        
+        iCommandMessage->Complete( aErr );
+        delete iCommandMessage; iCommandMessage = NULL;        
+        } 
+    
+    __LOG( "CUPnPPlaybackSession::AvtGetTransportInfoResponse - end" );
+          
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::AvtPositionInfoResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::AvtPositionInfoResponse(
+    TInt aErr,
+    const TDesC8& aTrackDuration,
+    const TDesC8& aRelTime )
+    {
+    __LOG1( "CUPnPPlaybackSession::AvtPositionInfoResponse: %d", aErr );    
+
+    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+    iIPSessionIdCommand = KErrNotFound;
+    
+    if( iCommandMessage )
+        {
+        TInt err = iCommandMessage->Write( 1, aTrackDuration );
+        err = iCommandMessage->Write( 2, aRelTime );
+        // Howto handle err?
+
+        aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPAVTransportError );    
+           
+        if( aErr == KErrNone )
+            {
+            iCommandMessage->Complete( EAVControllerPositionInfoCompleted );
+            }
+        else
+            {
+            iCommandMessage->Complete( aErr ); 
+            }        
+        delete iCommandMessage; iCommandMessage = NULL; 
+        }
+    else
+        {
+        __LOG( "AvtPositionInfoResponse - no msg" );    
+        }       
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::AvtStopResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::AvtStopResponse(
+    TInt aErr )
+    {
+    __LOG1( "CUPnPPlaybackSession::AvtStopResponse: %d", aErr );    
+
+    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+    iIPSessionIdCommand = KErrNotFound;
+    
+    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+        EUPnPAVTransportError );        
+    
+    if( aErr == KErrNone )
+        {
+		__LOG( "CUPnPPlaybackSession::AvtStopResponse - \
+Start waiting for stop event" );
+		
+		iTimer->Cancel();
+		iTimer->Start( KTimerCycle10 );      
+        }
+    else
+        {
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        
+        //iWaitingResponse = EFalse;
+        iExpectedEvent = EEventNone;
+        iCommandMessage->Complete( aErr );
+        delete iCommandMessage; iCommandMessage = NULL;       
+        }                
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::AvtPlayResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::AvtPlayResponse(
+    TInt aErr )
+    {
+    __LOG1( "CUPnPPlaybackSession::AvtPlayResponse: %d", aErr );    
+    
+    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+    iIPSessionIdCommand = KErrNotFound;
+    
+    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+        EUPnPAVTransportError );        
+    
+    if( aErr == KErrNone )
+        {
+		__LOG( "CUPnPPlaybackSession::AvtPlayResponse - \
+Start waiting for play event" );
+
+		iTimer->Cancel();
+		iTimer->Start( KTimerCycle10 );      
+        }
+    else
+        {
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        
+        //iWaitingResponse = EFalse;
+        iExpectedEvent = EEventNone;
+        iCommandMessage->Complete( aErr );
+        delete iCommandMessage; iCommandMessage = NULL;
+        }                    
+
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::AvtPauseResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::AvtPauseResponse(
+    TInt aErr )
+    {
+    __LOG1( "CUPnPPlaybackSession::AvtPauseResponse: %d", aErr );    
+    
+    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+    iIPSessionIdCommand = KErrNotFound;
+    
+    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+        EUPnPAVTransportError );        
+    
+    if( aErr == KErrNone )
+        {
+		__LOG( "CUPnPPlaybackSession::AvtPauseResponse - \
+Start waiting for pause event" );
+
+		iTimer->Cancel();
+		iTimer->Start( KTimerCycle10 );
+        }
+    else
+        {
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        
+        //iWaitingResponse = EFalse;
+        iExpectedEvent = EEventNone;
+        iCommandMessage->Complete( aErr );
+        delete iCommandMessage; iCommandMessage = NULL;             
+        }                      
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::AvtSeekResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::AvtSeekResponse(
+    TInt aErr )
+    {
+    __LOG1( "CUPnPPlaybackSession::AvtSeekResponse: %d", aErr );
+
+    __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+    
+    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+    iIPSessionIdCommand = KErrNotFound;
+    
+    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+        EUPnPAVTransportError );        
+    
+    if( aErr == KErrNone )
+        {
+        iCommandMessage->Complete( EAVControllerSeekCompleted );
+        }
+    else
+        {
+        iCommandMessage->Complete( aErr );
+        }
+    delete iCommandMessage; 
+    iCommandMessage = NULL;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CmPrepareResponse
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CmPrepareResponse(
+    TInt aErr,
+    TInt aConnection,
+    TInt aTransport,
+    TInt aRsc )
+    {
+    __LOG1( "CUPnPPlaybackSession::CmPrepareResponse %d", aErr );    
+
+    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+    iIPSessionIdCommand = KErrNotFound;
+ 
+    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+            EUPnPConnectionManagerError );
+    
+    if( aErr == KErrNone )
+        {
+        // FIX IOP problem with RC events with Simple Center
+        // Note that this is likely a problem in SC and needs to be verified
+        // once there is another device supporting CM:PrepareForConnection
+        iRCInstanceId = KDefaultInstanceId; //iRCInstanceId = aRsc; 
+        iAVTInstanceId = aTransport;
+        iConnectionId = aConnection;    
+
+        TRAP( aErr, SendGetTransportInfoActionL() )
+        if( aErr != KErrNone )
+            {
+            __LOG1( "CUPnPPlaybackSession::CmPrepareResponse - \
+SendGetTransportInfoActionL failed with code %d", aErr  );
+            iCommandMessage->Complete( aErr );
+            delete iCommandMessage; iCommandMessage = NULL;
+            }
+
+        __LOG3( "CUPnPPlaybackSession::CmPrepareResponse - \
+AVTid = %d, RCid = %d, connectionid = %d", aTransport, aRsc, aConnection );
+        }
+    else
+        {
+        // Something wrong with the action. Complete the message with error
+        // code. No further processing can be dome.
+        __LOG1( "CUPnPPlaybackSession::CmPrepareResponse - \
+action failed with code %d", aErr  );
+
+        delete iCurrentItem; iCurrentItem = NULL;
+        delete iCurrentUri; iCurrentUri = NULL; 
+
+        iCommandMessage->Complete( aErr );
+        delete iCommandMessage; iCommandMessage = NULL;        
+        } 
+    
+    __LOG( "CUPnPPlaybackSession::CmPrepareResponse - end" );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::RcLastChangeEvent
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::RcLastChangeEvent(
+    const TDesC8& aLastChange )
+    {
+    if( iPlaybackState != EHalted )
+        {        
+        __LOG( "CUPnPPlaybackSession::RcLastChangeEvent" );
+        CUPnPAVTEvent* event = NULL;
+        TRAPD(  err, event = iEventParser->ParseRcEventDataL( aLastChange,
+                iRCInstanceId ) );
+                
+        if( err == KErrNone )
+            {
+            TUnsolicitedEventC unsolicitEvent;
+            TInt volume = event->Volume();
+            TInt mute = event->Mute();
+            // check if it Mute state change
+             if( EUnknown != (TMuteState)mute  &&  
+                     iMuteState != (TMuteState)mute)
+                {
+                unsolicitEvent.iEvent = EMute;
+                unsolicitEvent.iValue = (TInt)mute;
+                iMuteState = (TMuteState)mute;
+                PropagateEvent( unsolicitEvent );
+                }
+             // check if it has valid volume information.
+             if (volume >= 0 )  
+                {
+                // Scale the volume level
+                // Get device's maximum volume value
+                TInt maxVolume = iDevice->MaxVolume();
+                // If max volume not KMaxVolume
+                if( maxVolume != KMaxVolume )
+                    {
+                    // Convert volume to match max volume 100
+                    TReal tempVolumeLevel = volume;
+                    TReal tempMaxVolume = maxVolume;
+                    
+                    volume = KMaxVolume * 
+                                tempVolumeLevel/tempMaxVolume;
+                    }            
+                if( iVolume != volume)
+                    {
+                    // State of volume changed, create an event and send it
+                    // to the client side
+                    unsolicitEvent.iEvent = EVolume;
+                    unsolicitEvent.iValue = volume;
+                    iVolume = volume;
+                    PropagateEvent( unsolicitEvent );                           
+                    }
+                }
+            }
+        delete event; 
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::AvtLastChangeEvent
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::AvtLastChangeEvent(
+    const TDesC8& aLastChange )
+    {
+    __LOG2( "CUPnPPlaybackSession::AvtLastChangeEvent, pb state %d, exp evt %d", 
+        iPlaybackState, iExpectedEvent );
+
+    CUPnPAVTEvent* avtevent = NULL;
+    TRAPD( err, avtevent = iEventParser->ParseAvtEventDataL( aLastChange, 
+           iAVTInstanceId ) );
+    if( err == KErrNone && iPlaybackState != EHalted )
+        {
+        CUPnPAVTEvent::TTransportState transportState = avtevent->TransportState();
+		PropagateState( transportState );
+		
+        if( avtevent->TransportURI().Length() > 0 )
+            {
+            AVTransportUriEventReceived( avtevent->TransportURI(),
+                avtevent->TransportState() );
+            }
+        else
+            {     
+            iInitialEventReceived = EFalse;
+            switch( transportState )
+                {
+                case CUPnPAVTEvent::EPlaying:
+                    {
+                    PlayingEventReceived();
+                    break;
+                    }     
+                case CUPnPAVTEvent::EStopped:
+                    {         
+                    StoppedEventReceived();
+                    break;
+                    }            
+                case CUPnPAVTEvent::EPausedPlayback:
+                    {
+                    PausedEventReceived();
+                    break;
+                    }
+                case CUPnPAVTEvent::ENoMediaPresent:
+                    {
+                    NoMediaEventReceived();
+                    break;
+                    }
+                default:
+                    {
+                    __LOG( "CUPnPPlaybackSession::AvtLastChangeEvent - \
+TRANSITIONING, IDLE, RECORDING or PAUSED_RECORDING" );    
+                    break;
+                    }   
+                }
+            }
+        iPreviousTransportState = transportState;
+        }
+    else
+        {
+        __LOG( "CUPnPPlaybackSession::AvtLastChangeEvent - We are halted, or \
+parsing failed. No can do." );
+        }
+    delete avtevent;
+    __LOG( "CUPnPPlaybackSession::AvtLastChangeEvent" );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::DeviceDisappearedL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::DeviceDisappearedL(
+    CUpnpAVDeviceExtended& aDevice )
+    {
+    __LOG( "CUPnPPlaybackSession::DeviceDisappearedL" );
+   
+    if( aDevice.Local() )
+        {
+        delete iLocalMediaServerUuid; iLocalMediaServerUuid = NULL; 
+        }
+    else if( iDeviceMessage ) // Target device
+        {
+        iDeviceMessage->Complete( KErrNone );
+        delete iDeviceMessage; iDeviceMessage = NULL;
+        }    
+    }
+ 
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::SetLocalMSUuidL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::SetLocalMSUuidL( const TDesC8& aUuid )
+    {
+    HBufC8* tmp = aUuid.AllocL();
+    delete iLocalMediaServerUuid;
+    iLocalMediaServerUuid = tmp; 
+    } 
+ 
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::SessionId
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+TInt CUPnPPlaybackSession::SessionId() const
+    {
+    return iSessionId;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::EventRequestL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::EventRequestL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::EventRequestL" );
+
+    __ASSERT( !iEventMessage, __FILE__, __LINE__ );
+
+    TInt count = iEventQue.Count(); 
+    if( count )
+        {
+        __LOG( "EventRequestL - events in the que" );
+        // Events pending, get the event from que and complete the msg
+        TPckg<TUnsolicitedEventC> resp1( iEventQue[ count - 1 ] );
+        TInt err = aMessage.Write( 1, resp1 );
+        iEventQue.Remove( count - 1 ); 
+        aMessage.Complete( err ); // Ok to complete with err?
+        }
+    else
+        {
+        __LOG( "EventRequestL - storing the msg" );
+        iEventMessage = new (ELeave) RMessage2( aMessage );
+        
+        if( !iEventingActive )
+            {
+            __LOG( "EventRequestL - subscribing.." );
+            if( iDevice->SubscriptionCount() )
+                {
+                __LOG( "CUPnPPlaybackSession::EventRequestL - Subscription \
+has been made already, set state to no media." );
+                // Some session has already subscribed, so we will not
+                // receive the initial state event. Therefore set our state
+                // to no media.
+                iPlaybackState = ENoMedia;
+                }
+            iServer.DeviceRepository().SubscribeDeviceL( iDevice->Uuid() );
+            iServer.Dispatcher().RegisterForEventsL( *this,
+                iDevice->Uuid() );
+            iEventingActive = ETrue;
+            }           
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelEventRequestL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelEventRequestL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelEventRequestL" );
+           
+    if( iEventingActive )
+        {
+        __LOG( "CancelEventRequestL - unsubscribing.." );
+        iServer.DeviceRepository().UnSubscribeDeviceL( iDevice->Uuid() );
+        iServer.Dispatcher().UnRegisterEvents( *this );
+        iEventingActive = EFalse;            
+        }
+        
+    if( iEventMessage )
+        {
+        __LOG( "CancelEventRequestL - cancelling the msg.." );
+        iEventMessage->Complete( KErrCancel );
+        delete iEventMessage; iEventMessage = NULL;   
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::SetURIL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::SetURIL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::SetURIL" );
+    
+    __ASSERT( !iCommandMessage, __FILE__, __LINE__ );
+    
+    ResetL();
+        
+    // Read and store the item and URI from the request
+    CUpnpAVRequest* tmpRequest = CUpnpAVRequest::NewLC();
+    ReadReqFromMessageL( aMessage, 1 ,tmpRequest );
+    
+    CUpnpItem* tmpItem = CUpnpItem::NewL();
+    CleanupStack::PushL( tmpItem );
+
+    ReadObjFromMessageL( aMessage, 2 ,tmpItem );
+
+    HBufC8* tmpUri = tmpRequest->URI().AllocL();
+    
+    CleanupStack::Pop( tmpItem );
+    CleanupStack::PopAndDestroy( tmpRequest );
+    
+    delete iCurrentItem;
+    iCurrentItem = tmpItem;
+
+    delete iCurrentUri;
+    iCurrentUri = tmpUri;
+
+    // Get protocolInfo from the item
+    const CUpnpElement& res = 
+        UPnPItemUtility::ResourceFromItemL( *iCurrentItem );
+    const CUpnpAttribute* protocolInfo = 
+        UPnPItemUtility::FindAttributeByName( 
+        res, KAttributeProtocolInfo );
+
+    // Store the message. We are going to perfom asynchronous operation
+    // so it's needed (completed) afterwards
+    iCommandMessage = new (ELeave) RMessage2( aMessage );     
+
+    // Check if we have a valid connection (or if it's even needed.
+    // Anyway,that does not matter since if no connection, we can used
+    // default instance id)    
+    if( CheckConnectionL( protocolInfo->Value() ) )
+        {
+        // Connection ok, continue with sending AvtSetTransportUri-action
+        __LOG( "CUPnPPlaybackSession::SetURIL - \
+connection ok, or using default" );
+        
+        SendGetTransportInfoActionL();      
+        }
+    else
+        {
+        // Connection needs to be established
+        CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+                CpDeviceL(), KConnectionManager, KPrepareForConnection );
+        
+        action->SetArgumentL( KRemoteProtocolInfo, protocolInfo->Value() );
+	    action->SetArgumentL( KPeerConnectionManager, KConnectioMgr );
+	    action->SetArgumentL( KPeerConnectionID, KDefaultPeerConnectionID );
+	    action->SetArgumentL( KDirection, KInput );
+
+        iServer.ControlPoint().SendL( action );
+        CleanupStack::Pop( action );
+        if (action->SessionId() < 0) User::Leave( action->SessionId() );
+        iIPSessionIdCommand = action->SessionId();
+        iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
+        }
+
+    // Store protocolinfo, so it can be checked in PrepareConnectionL when
+    // a next item is played 
+    CUpnpDlnaProtocolInfo* tmpInfo = 
+         CUpnpDlnaProtocolInfo::NewL( protocolInfo->Value() );
+
+    delete iPInfoForPrevious;    
+    iPInfoForPrevious = tmpInfo;         
+ 
+    __LOG( "CUPnPPlaybackSession::SetURIL - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelSetURIL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelSetURIL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelSetURIL" );
+    
+    if( iCommandMessage )
+        {
+        //iSetUri = EFalse;
+        iExpectedEvent = EEventNone;
+        iPlaybackState = EStopped;
+        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+        iIPSessionIdCommand = KErrNotFound;
+        iCommandMessage->Complete( KErrCancel );
+        delete iCommandMessage; iCommandMessage = NULL;
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::SetNextURIL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::SetNextURIL( const RMessage2& /*aMessage*/ )
+    {
+    __LOG( "CUPnPPlaybackSession::SetNextURIL" );
+ 
+    User::Leave( KErrNotSupported );
+ 
+    __LOG( "CUPnPPlaybackSession::SetNextURIL - end" );
+   }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelSetNextURIL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelSetNextURIL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelSetNextURIL" );
+
+    User::Leave( KErrNotSupported );   
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::PlayL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::PlayL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::PlayL" );
+
+    __ASSERT( !iCommandMessage, __FILE__, __LINE__ );
+
+    ResetL();
+    
+    if( !(iPlaybackState == EPaused || iPlaybackState == EStopped) )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KAVTransport, KPlay );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( iAVTInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+    action->SetArgumentL( KSpeed, KNormalSpeed );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    iIPSessionIdCommand = action->SessionId();
+    iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
+    iCommandMessage = new (ELeave) RMessage2( aMessage );
+    
+    iExpectedEvent = EEventPlaying;
+    
+    __LOG( "CUPnPPlaybackSession::PlayL - end" );
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelPlayL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelPlayL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelPlayL" );
+    
+    //__ASSERT( iCommandPending, User::Panic( KPanicText, __LINE__ ) );
+    if( iCommandMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+        iIPSessionIdCommand = KErrNotFound;
+        iCommandMessage->Complete( KErrCancel );
+        delete iCommandMessage; iCommandMessage = NULL;
+        
+        iExpectedEvent = EEventNone;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::StopL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::StopL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::StopL" );
+    
+    __ASSERT( !iCommandMessage, __FILE__, __LINE__ );
+
+    ResetL();
+    // state stopped must be check before stopped action. According to
+    // AVTransPort specification stop may be requested in any other state
+    // except NO_MEDIA_PRESENT
+    if( iPlaybackState == ENoMedia )
+        {
+        User::Leave( KErrNotReady );
+        }
+    else
+        {
+        __LOG1( "CUPnPPlaybackSession::StopL - sending stop in state %d",
+            iPlaybackState);
+        }
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KAVTransport, KStop );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( iAVTInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+
+    iServer.ControlPoint().SendL( action ); //action ownership is transfered
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionIdCommand = action->SessionId();
+    iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
+    iCommandMessage = new (ELeave) RMessage2( aMessage );
+
+    iExpectedEvent = EEventStopped;
+    __LOG( "CUPnPPlaybackSession::StopL - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::EmergencyStopL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::EmergencyStopL()
+    {
+    __LOG( "CUPnPPlaybackSession::EmergencyStopL" );
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KAVTransport, KStop );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( iAVTInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    __LOG( "CUPnPPlaybackSession::StopL - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::PropagateState
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::PropagateState( 
+    CUPnPAVTEvent::TTransportState aTransportState )
+    {
+    __LOG2( "CUPnPPlaybackSession::PropagateState - curState %d, prevState %d",
+        aTransportState, iPreviousTransportState );
+        
+    if( aTransportState == CUPnPAVTEvent::ETransitioning )
+        {
+        __LOG( "CUPnPPlaybackSession::PropagateState - \
+TRANSITIONING" );
+        TUnsolicitedEventC event;
+        event.iEvent = ETransition;
+        event.iValue = ETransitionEnter; 
+        PropagateEvent( event );
+        }
+    else if( aTransportState != CUPnPAVTEvent::ETransitioning &&
+        iPreviousTransportState == CUPnPAVTEvent::ETransitioning )
+        {
+        __LOG( "CUPnPPlaybackSession::PropagateState - \
+TRANSITIONING ended" );    
+        TUnsolicitedEventC event;
+        event.iEvent = ETransition;
+        event.iValue = ETransitionExit; 
+        PropagateEvent( event );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelStopL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelStopL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelStopL" );
+    
+    if( iCommandMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+        iIPSessionIdCommand = KErrNotFound;
+        iCommandMessage->Complete( KErrCancel );
+        delete iCommandMessage; iCommandMessage = NULL; 
+        
+        iExpectedEvent = EEventNone;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::PauseL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::PauseL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::PauseL" );
+    
+    __ASSERT( !iCommandMessage, __FILE__, __LINE__ );
+
+    ResetL();
+    
+    if( !(iPlaybackState == EPlaying)  )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KAVTransport, KPause );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( iAVTInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionIdCommand = action->SessionId();
+    iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
+    iCommandMessage = new (ELeave) RMessage2( aMessage );
+
+    iExpectedEvent = EEventPaused;
+    
+    __LOG( "CUPnPPlaybackSession::PauseL - end" );                
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelPauseL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelPauseL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelPauseL" );                
+    
+    if( iCommandMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+        iIPSessionIdCommand = KErrNotFound;
+        iCommandMessage->Complete( KErrCancel );
+        delete iCommandMessage; iCommandMessage = NULL; 
+        
+        iExpectedEvent = EEventNone;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::SetVolumeL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::SetVolumeL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::SetVolumeL" );                
+    
+    __ASSERT( !iSettingMessage, __FILE__, __LINE__ );
+
+    ResetL();
+    
+    TInt volume = aMessage.Int1();
+    
+    TInt maxVolume = iDevice->MaxVolume();
+
+    // If max volume not KMaxVolume
+    if( maxVolume != KMaxVolume )
+        {
+        // Convert volume to match device's max volume
+        TReal tempVolumeLevel = volume;
+        TReal tempMaxVolume = maxVolume;
+        
+        volume = tempMaxVolume * tempVolumeLevel / KMaxVolume;
+        }
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KRenderingControl, KSetVolume );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( KDefaultInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+    action->SetArgumentL( KChannel, KMasterVolume );
+    buf.Num( volume );
+    action->SetArgumentL( KDesiredVolume, buf );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionIdSetting = action->SessionId();
+
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this );
+    iSettingMessage = new (ELeave) RMessage2( aMessage );                
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelSetVolumeL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelSetVolumeL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelSetVolumeL" );                
+    
+    if( iSettingMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
+        iIPSessionIdSetting = KErrNotFound;
+        iSettingMessage->Complete( KErrCancel );
+        delete iSettingMessage; iSettingMessage = NULL;            
+        }
+    }    
+   
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::GetVolumeL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::GetVolumeL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::GetVolumeL" );                
+    
+    __ASSERT( !iSettingMessage, __FILE__, __LINE__ );
+
+    ResetL();
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KRenderingControl, KGetVolume );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( KDefaultInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+    action->SetArgumentL( KChannel, KMasterVolume );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionIdSetting = action->SessionId();
+    
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this );
+    iSettingMessage = new (ELeave) RMessage2( aMessage );                    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelGetVolumeL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelGetVolumeL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelGetVolumeL" );                
+    
+    if( iSettingMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
+        iIPSessionIdSetting = KErrNotFound;
+        iSettingMessage->Complete( KErrCancel );
+        delete iSettingMessage; iSettingMessage = NULL;            
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::SetMuteL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::SetMuteL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::SetMuteL" );                
+    
+    __ASSERT( !iSettingMessage, __FILE__, __LINE__ );
+
+    ResetL();
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KRenderingControl, KSetMute );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( KDefaultInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+    action->SetArgumentL( KChannel, KMasterVolume );
+    if ( aMessage.Int1() )
+        {
+        action->SetArgumentL( KDesiredMute, KMuteOn );
+        }
+    else
+        {
+        action->SetArgumentL( KDesiredMute, KMuteOff );
+        }
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionIdSetting = action->SessionId();
+
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this );
+    iSettingMessage = new (ELeave) RMessage2( aMessage );                 
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelSetMuteL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelSetMuteL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelSetMuteL" );                
+    
+    if( iSettingMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
+        iIPSessionIdSetting = KErrNotFound;
+        iSettingMessage->Complete( KErrCancel );
+        delete iSettingMessage; iSettingMessage = NULL;            
+        }
+    }    
+   
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::GetMuteL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::GetMuteL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::GetMuteL" );                
+    
+    __ASSERT( !iSettingMessage, __FILE__, __LINE__ );
+
+    ResetL();
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KRenderingControl, KGetMute );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( KDefaultInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+    action->SetArgumentL( KChannel, KMasterVolume );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionIdSetting = action->SessionId();
+
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionIdSetting, *this );
+    iSettingMessage = new (ELeave) RMessage2( aMessage );                    
+    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelGetMuteL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelGetMuteL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelGetMuteL" );                
+    
+    if( iSettingMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionIdSetting );
+        iIPSessionIdSetting = KErrNotFound;
+        iSettingMessage->Complete( KErrCancel );
+        delete iSettingMessage; iSettingMessage = NULL;            
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::GetPositionInfoL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::GetPositionInfoL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::GetPositionInfoL" );                
+    
+    __ASSERT( !iCommandMessage, __FILE__, __LINE__ );
+
+    ResetL();
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KAVTransport, KGetPositionInfo );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( iAVTInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionIdCommand = action->SessionId();
+
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
+    iCommandMessage = new (ELeave) RMessage2( aMessage );
+    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelGetPositionInfoL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelGetPositionInfoL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelGetPositionInfoL" );                
+    
+    if( iCommandMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+        iIPSessionIdCommand = KErrNotFound;
+        iCommandMessage->Complete( KErrCancel );
+        delete iCommandMessage; iCommandMessage = NULL;            
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::SeekRelTimeL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::SeekRelTimeL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::SeekRelTimeL" );                
+    
+    __ASSERT( !iCommandMessage, __FILE__, __LINE__ );
+
+    ResetL();
+
+    // Get the seek target value from aMessage parameter
+    // create buffer
+    TInt len = aMessage.GetDesMaxLength( 1 );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( 1, ptr ) );
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KAVTransport, KSeek );
+    
+    TBuf8<KMaxIntLength> bufInt;
+    bufInt.Num( iAVTInstanceId );
+    action->SetArgumentL( KInstanceID, bufInt );
+    action->SetArgumentL( KUnit, KRel_Time );
+    action->SetArgumentL( KTarget, *buf );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave( action->SessionId() );
+    iIPSessionIdCommand = action->SessionId();
+
+    CleanupStack::PopAndDestroy( buf );
+    
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
+    iCommandMessage = new (ELeave) RMessage2( aMessage );
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelSeekRelTimeL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelSeekRelTimeL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelSeekRelTimeL" );                
+
+    if( iCommandMessage )
+        {
+        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+        iIPSessionIdCommand = KErrNotFound;
+        iCommandMessage->Complete( KErrCancel );
+        delete iCommandMessage; 
+        iCommandMessage = NULL;            
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::GetRendererStateL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::GetRendererStateL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::GetRendererStateL" );
+    
+    if( iPlaybackState == EStopped || iPlaybackState == ENoMedia )
+        {
+        __LOG( "CUPnPPlaybackSession::GetRendererStateL - \
+Stopped or no_media" );
+        TUnsolicitedEventE event( EStop );
+        TPckg<TUnsolicitedEventE> resp1( event );
+        TInt err = aMessage.Write( 1, resp1 );
+        aMessage.Complete( err );
+        }
+    else if( iPlaybackState == EPlaying )
+        {
+        __LOG( "CUPnPPlaybackSession::GetRendererStateL - Playing" );
+        TUnsolicitedEventE event( EPlay );
+        TPckg<TUnsolicitedEventE> resp1( event );
+        TInt err = aMessage.Write( 1, resp1 );
+        aMessage.Complete( err );
+        }
+    else if( iPlaybackState == EPaused )
+        {
+        __LOG( "CUPnPPlaybackSession::GetRendererStateL - Paused" );
+        TUnsolicitedEventE event( EPause );
+        TPckg<TUnsolicitedEventE> resp1( event );
+        TInt err = aMessage.Write( 1, resp1 );
+        aMessage.Complete( err );  
+        }
+    else
+        {
+        __LOG( "CUPnPPlaybackSession::GetRendererStateL - Waiting.." );
+        // Waiting the initial event
+        __ASSERT( !iInitialEventMsg, __FILE__, __LINE__ );
+        iTimer->Start( KTimerCycle10 );
+        iInitialEventMsg = new (ELeave) RMessage2( aMessage );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::DeviceDisappearedRequestL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::DeviceDisappearedRequestL(
+    const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPPlaybackSession::DeviceDisappearedRequestL" );
+    
+    __ASSERT( !iDeviceMessage, __FILE__, __LINE__ );
+    
+    iDeviceMessage = new (ELeave ) RMessage2( aMessage );
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CancelDeviceDisappearedRequestL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::CancelDeviceDisappearedRequestL()
+    {
+    __LOG( "CUPnPPlaybackSession::CancelDeviceDisappearedRequestL" );
+    
+    if( iDeviceMessage )
+        {
+        iDeviceMessage->Complete( KErrCancel );
+        delete iDeviceMessage; iDeviceMessage = NULL;             
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::Uuid
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+const TDesC8& CUPnPPlaybackSession::Uuid() const
+    {
+    if( iDevice )
+        {
+        return iDevice->Uuid();
+        }
+    else
+        {
+        return KNullDesC8;
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::EncodeXmlL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+HBufC8* CUPnPPlaybackSession::EncodeXmlL( const TDesC8& aResult )
+    {
+    HBufC8* tmpBuf = aResult.AllocLC();
+    HBufC8* result = UpnpString::EncodeXmlStringL( tmpBuf );
+    CleanupStack::PopAndDestroy( tmpBuf );
+    return result;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::Reset
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::ResetL()
+    {
+    __LOG( "CUPnPPlaybackSession::ResetL" );
+    
+    if( !iServer.DeviceRepository().IsWlanActive() )    
+        {
+        __LOG( "Reset - disconnected" );
+        User::Leave( KErrDisconnected );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::ReadObjFromMessageL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::ReadObjFromMessageL( const RMessage2& aMessage, 
+    TInt aSlot, CUpnpObject* aObj )
+    {
+    // create buffer
+    TInt len = aMessage.GetDesMaxLength( aSlot );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
+    
+    // read stream
+    RDesReadStream stream( *buf );
+    CleanupClosePushL( stream );
+    
+    // internalize object
+    stream >> *aObj;
+    
+    // clean up
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buf );
+    }    
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::ReadReqFromMessageL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::ReadReqFromMessageL( const RMessage2& aMessage, 
+    TInt aSlot, CUpnpAVRequest* aReq ) 
+    {
+    // create buffer
+    TInt len = aMessage.GetDesMaxLength( aSlot );
+    HBufC8* buf = HBufC8::NewLC( len );
+    TPtr8 ptr( buf->Des() );
+    User::LeaveIfError( aMessage.Read( aSlot, ptr ) );
+    
+    // read stream
+    RDesReadStream stream( *buf );
+    CleanupClosePushL( stream );
+    
+    // internalize object
+    stream >> *aReq;
+    
+    // clean up
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buf );
+    }    
+
+void CUPnPPlaybackSession::ValidateProtocolInfoL( const CUpnpAttribute&
+    aResource )
+    {
+    __LOG( "CUPnPPlaybackSession::ValidateProtocolInfoL" );
+    
+    // Whe'd like to modify the original protocolInfo, that's why constness
+    // is casted away
+    CUpnpAttribute& attr = const_cast<CUpnpAttribute&>( aResource );
+    
+    // ProtocolInfo-wrapper takes care of 4th field validation, omitting
+    // invalid optional parameters
+    CUpnpDlnaProtocolInfo* tmpInfo = 
+        CUpnpDlnaProtocolInfo::NewL( attr.Value() );
+    CleanupStack::PushL( tmpInfo );
+    
+    tmpInfo->SetSecondFieldL( KAsterisk ); // Second field must be '*'
+    
+    attr.SetValueL( tmpInfo->ProtocolInfoL() );
+        
+    CleanupStack::PopAndDestroy( tmpInfo );
+    
+    __LOG( "CUPnPPlaybackSession::ValidateProtocolInfoL - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CheckConnectionL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+TBool CUPnPPlaybackSession::CheckConnectionL( 
+    const TDesC8& aProtocolInfo )
+    {
+    __LOG( "CUPnPPlaybackSession::CheckConnectionL" );
+    
+    // 1.   Check that is CM:PrepareForConnection supported. If not, return
+    //      true. This means that we don't need to establish a new connection
+    //      (we can just used instance id 0)
+    // 2.   If PrepareForConnection is supported, check that do have a
+    //      connection already (!iPInfoForPrevious). If not, return false
+    //      (a new connection is needed). If we have a connection, check that
+    //      does the type of content change. If it changes, a new connection
+    //      is needed.
+    
+    if( iDevice->PrepareForConnection() )
+        {
+        __LOG( "CUPnPPlaybackSession::CheckConnectionL - \
+CM:PrepareForConnection supported" );
+
+        if( iPInfoForPrevious && ( iConnectionId != KErrNotFound ) )
+            {
+            CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
+                    aProtocolInfo );
+            
+            if( tmpInfo->SecondField() == iPInfoForPrevious->SecondField() &&
+                tmpInfo->PnParameter() == iPInfoForPrevious->PnParameter() )
+                {
+                __LOG( "CUPnPPlaybackSession::CheckConnectionL - \
+same as previous" );
+                delete tmpInfo;
+                return ETrue;
+                }
+            else
+                {
+                __LOG( "CUPnPPlaybackSession::CheckConnectionL - \
+media type changes, a new connection is needed" );
+                // Close existing. Ignore error code (we can do nothing
+                // useful in error case)
+                CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+                        CpDeviceL(), KConnectionManager, KConnectionComplete );
+                
+                TBuf8<KMaxIntLength> buf;
+                buf.Num( iConnectionId );
+                action->SetArgumentL( KConnectionID, buf );
+
+                iServer.ControlPoint().SendL( action );
+                CleanupStack::Pop( action );
+
+                iConnectionId = KErrNotFound;
+                iAVTInstanceId = KDefaultInstanceId;  
+                iRCInstanceId = KDefaultInstanceId;
+                delete tmpInfo;
+                return EFalse;                
+               }
+            }
+        else
+            {
+            // No existing connection, a new connection is needed
+            return EFalse;
+            }
+        }
+    else
+        {
+        __LOG( "CUPnPPlaybackSession::CheckConnectionL - \
+CM:PrepareForConnection not supported" );
+        
+        // CM:PrepareForConnection is not supported
+        return ETrue;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::SendAVTransportUriActionL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::SendAVTransportUriActionL()
+    {
+    __LOG( "CUPnPPlaybackSession::SendAVTransportUriActionL" );
+    
+    const CUpnpElement& res = 
+        UPnPItemUtility::ResourceFromItemL( *iCurrentItem );
+    const CUpnpAttribute* protocolInfo = 
+        UPnPItemUtility::FindAttributeByName( 
+        res, KAttributeProtocolInfo );    
+    
+    TPtrC8 uri( *iCurrentUri );
+    
+    if( !iDevice->MatchSinkProtocolInfo( protocolInfo->Value() ) )
+        {
+        // Did not match, try to find a match
+        TRAPD( err, uri.Set( iDevice->FindFirstMatchingInSinkL(
+            *iCurrentItem ) ) );
+        if( err == KErrNone )
+            {
+            // Suitable res-element found!
+            __LOG( "Suitable element found!" );
+            }
+        else if( err == KErrNotSupported )
+            {
+            // No suitable res-element
+            if( iDevice->DLNADeviceType() ==
+                CUpnpAVDeviceExtended::EDMR )
+                {
+                // DLNA content, DLNA device, no match -> leave
+                User::Leave( KErrNotSupported );                    
+                }
+            else
+                {
+                // Not a dlna device, try to set the uri of
+                // original res-element anyways
+                }
+            }
+        else
+            {
+            // Some error occured
+            User::Leave( err );
+            }    
+        }
+
+    ValidateProtocolInfoL( *protocolInfo );
+           
+   if( !iDevice->DlnaCompatible() )
+        {        
+        // down grade to upnpitem
+        RemoveDlnaFlagsFromResElementsL();
+        }          
+    else if( ( iDevice->DLNADeviceType() != CUpnpAVDeviceExtended::EDMR ) ||
+        ( !iDevice->MatchSinkProfileId( protocolInfo->Value() ) && 
+           iDevice->MatchSinkMime( protocolInfo->Value()) ) )
+        {
+        // remove DLNA profile
+        RemoveDlnaProfileFromResElementsL();
+        }
+    
+    // Create metadata xml document
+    HBufC8* xmlDoc = CUPnPXMLParser::ItemAsXmlLC( *iCurrentItem );
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KAVTransport, KSetAVTransportURI );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( iAVTInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+    action->SetArgumentL( KCurrentURI, uri );
+    action->SetArgumentL( KCurrentURIMetaData, *xmlDoc );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave(action->SessionId());
+    iIPSessionIdCommand = action->SessionId();
+
+    CleanupStack::PopAndDestroy( xmlDoc );      
+                                      
+    iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
+    
+    // Set playback state artificially to no media. This way we can recognize
+    // if renderer has responded with CurrentTrackUri
+    iPlaybackState = ENoMedia;
+    iExpectedEvent = EEventAVTransportUri;
+ 
+    __LOG( "CUPnPPlaybackSession::SendAVTransportUriActionL - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::RemoveDlnaFlagsFromResElementL
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::RemoveDlnaFlagsFromResElementsL()
+    {
+    __LOG( "CUPnPPlaybackSession::RemoveDlnaFlagsFromResElementL" );
+    RUPnPElementsArray& elements = const_cast<RUPnPElementsArray&>(
+                                                iCurrentItem->GetElements());
+
+    for( TInt resIndex(0); resIndex < elements.Count(); ++resIndex )
+        {
+        if( elements[resIndex]->Name() == KElementRes() )
+            {
+            const RUPnPAttributesArray& array = 
+                                    elements[resIndex]->GetAttributes();
+            CUpnpElement* elem = CUpnpElement::NewLC( KElementRes() );
+            for( TInt i = 0; i < array.Count(); i++ )
+                {
+                _LIT8( KProtocolInfo, "protocolInfo" );
+                _LIT8( KDlnaOrg, "DLNA.ORG" );
+                
+                if( array[ i ]->Name() == KProtocolInfo() )
+                    {
+                    // remove dlna stuff from protocolinfo
+                    TPtrC8 protValue( array[ i ]->Value() );
+                    TInt index = protValue.Find( KDlnaOrg() );
+                    __LOG1( "CUPnPPlaybackSession::RemoveDlnaFlagsFromRes\
+                    ElementL dlnaflags found protinfo index = %d",index );
+                    if( index > 0 )
+                        {
+                        _LIT8( KWildCard, ":*" );
+                        CUpnpAttribute* attribute = CUpnpAttribute::NewLC( 
+                                                     array[ i ]->Name() );
+                        HBufC8* tmp = HBufC8::NewLC( 
+                        protValue.Mid(0, index-1).Length() +
+                        KWildCard().Length() );
+                        
+                        tmp->Des().Copy( protValue.Mid(0, index-1) );
+                        tmp->Des().Append( KWildCard() );
+                        
+                        attribute->SetValueL( *tmp );
+                        CleanupStack::PopAndDestroy( tmp );                                                
+                        elem->AddAttributeL(attribute);
+                        CleanupStack::Pop( attribute );
+                        }
+                    else
+                        {
+                        // if item was allready down graded to upnpitem
+                        // clean and break from here
+                        CleanupStack::PopAndDestroy( elem );
+                        elem = NULL;
+                        break;
+                        }
+                    }
+                else
+                    {
+                    CUpnpAttribute* attribute = CUpnpAttribute::NewLC( 
+                                                 array[ i ]->Name() );
+                    attribute->SetValueL( array[ i ]->Value() );
+                    elem->AddAttributeL(attribute);
+                    CleanupStack::Pop( attribute );
+                    }
+                }     
+            if( elem )
+                {
+                elem->SetValueL( elements[resIndex]->Value() );
+                CleanupStack::Pop( elem );
+                
+                if( elements.Insert( elem, resIndex ) )
+                    {
+                    delete elem;
+                    continue;
+                    }
+                
+                delete elements[++resIndex];
+                elements.Remove(resIndex);                    
+
+                __LOG( "CUPnPPlaybackSession::RemoveDlnaFlagsFromResElementL\
+                res found and replaced protocol info without dlna stuff" );
+                }
+            }
+        }
+    __LOG( "CUPnPPlaybackSession::RemoveDlnaFlagsFromResElementL end" );
+    }
+    
+    // --------------------------------------------------------------------------
+// CUPnPPlaybackSession::RemoveDlnaProfileFromResElementsL
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::RemoveDlnaProfileFromResElementsL()
+    {
+    __LOG( "CUPnPPlaybackSession::RemoveDlnaProfileFromResElementsL" );
+    RUPnPElementsArray& elements = const_cast<RUPnPElementsArray&>(
+                                                iCurrentItem->GetElements());
+
+    for( TInt resIndex(0); resIndex < elements.Count(); ++resIndex )
+        {
+        if( elements[resIndex]->Name() == KElementRes() )
+            {
+            const RUPnPAttributesArray& array = 
+                                    elements[resIndex]->GetAttributes();
+            CUpnpElement* elem = CUpnpElement::NewLC( KElementRes() );
+            for( TInt i = 0; i < array.Count(); i++ )
+                {
+                _LIT8( KProtocolInfo, "protocolInfo" );
+                _LIT8( KDlnaOrgPn, "DLNA.ORG_PN=" );
+                _LIT8( KDlnaOrgPnEnd, ";" );
+                
+                if( array[ i ]->Name() == KProtocolInfo() )
+                    {
+                    // remove dlna profile from protocolinfo
+                    TPtrC8 protValue( array[ i ]->Value() );
+                    TInt length = 0;
+                    TInt index = 0;
+                    
+                    __LOG8_1("CUPnPPlaybackSession::RemoveDlnaProfileFromRes protocol info = %S", &protValue);
+                    
+                    index = protValue.Find( KDlnaOrgPn() );
+                    if (index != KErrNotFound)
+                        {
+                        length = protValue.Mid(index).Find( KDlnaOrgPnEnd() );
+                        }
+                    __LOG1( "CUPnPPlaybackSession::RemoveDlnaProfileFromRes ElementsL DLNA profile found protinfo index = %d", index );
+                    if( index > 0 && length > 0 )
+                        {                        
+                        ++length;    
+                        
+                        CUpnpAttribute* attribute = CUpnpAttribute::NewLC( 
+                                                     array[ i ]->Name() );
+                        HBufC8* tmp = HBufC8::NewLC( 
+                        protValue.Length() - 
+                        protValue.Mid( index, length ).Length() );
+                        
+                        tmp->Des().Copy( protValue.Mid ( 0, index ) );                        
+                        tmp->Des().Append( protValue.Mid( index + length ) );
+                                              
+                        attribute->SetValueL( *tmp );
+                        
+                        CleanupStack::PopAndDestroy( tmp );                                                
+                        elem->AddAttributeL(attribute);
+                        CleanupStack::Pop( attribute );
+                        }
+                    else
+                        {
+                        // just clean if profile not found
+                        CleanupStack::PopAndDestroy( elem );
+                        elem = NULL;
+                        break;
+                        }
+                    }
+                else
+                    {
+                    CUpnpAttribute* attribute = CUpnpAttribute::NewLC( 
+                                                 array[ i ]->Name() );
+                    attribute->SetValueL( array[ i ]->Value() );
+                    elem->AddAttributeL(attribute);
+                    CleanupStack::Pop( attribute );
+                    }
+                }     
+            if( elem )
+                {
+                elem->SetValueL( elements[resIndex]->Value() );
+                CleanupStack::Pop( elem );
+                
+                if( elements.Insert( elem, resIndex ) )
+                    {
+                    delete elem;
+                    continue;
+                    }
+                
+                delete elements[++resIndex];
+                elements.Remove(resIndex);                    
+
+                __LOG( "CUPnPPlaybackSession::RemoveDlnaProfileFromResElementsL\
+                res found and replaced protocol info without dlna profile" );
+                }
+            }
+        }
+    __LOG( "CUPnPPlaybackSession::RemoveDlnaProfileFromResElementsL end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::SendGetMediaInfoActionL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::SendGetMediaInfoActionL()
+    {
+    __LOG( "CUPnPPlaybackSession::SendGetMediaInfoActionL" );
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KAVTransport, KGetMediaInfo );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( iAVTInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave(action->SessionId());
+    iIPSessionIdCommand = action->SessionId();
+
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
+
+    __LOG( "CUPnPPlaybackSession::SendGetMediaInfoActionL - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::SendGetTransportInfoActionL
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::SendGetTransportInfoActionL()
+    {
+    __LOG( "CUPnPPlaybackSession::SendGetTransportInfoActionL" );
+
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            CpDeviceL(), KAVTransport, KGetTransportInfo );
+    
+    TBuf8<KMaxIntLength> buf;
+    buf.Num( iAVTInstanceId );
+    action->SetArgumentL( KInstanceID, buf );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0) User::Leave(action->SessionId());
+    iIPSessionIdCommand = action->SessionId();
+
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionIdCommand, *this );
+
+    __LOG( "CUPnPPlaybackSession::SendGetTransportInfoActionL - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::PlayingEventReceived
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::PlayingEventReceived()
+    {
+    __LOG( "CUPnPPlaybackSession::PlayingEventReceived" );
+    
+    if( iExpectedEvent == EEventPlaying )
+        {
+        // We were expecting a state change from stopped to playing since we
+        // sent the play action.        
+        __LOG( "CUPnPPlaybackSession::PlayingEventReceived - \
+Response to play" );
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        iTimer->Cancel();
+        // Unregister from the dispatcher. This way we do not get 
+        // ::AvtPlayResponse callback (it would be ignored, anyway)        
+        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+        iIPSessionIdCommand = KErrNotFound;         
+        iCommandMessage->Complete( EAVControllerPlayCompleted );
+        delete iCommandMessage; iCommandMessage = NULL;
+        iExpectedEvent = EEventNone;
+        }
+    else if( iPlaybackState == EPaused  )
+        {
+        // Unsolicited play event from the renderer. This means that device
+        // is playing. Propagate the event.
+        __LOG( "CUPnPPlaybackSession::PlayingEventReceived - \
+Unsolicited play" );
+        TUnsolicitedEventC event;
+        event.iEvent = EPlay; event.iValue = KErrNone;
+        PropagateEvent( event );
+        }
+    else if( iInitialEventMsg )
+        {
+        __LOG( "CUPnPPlaybackSession::PlayingEventReceived - \
+initial event" );
+        iTimer->Cancel();
+        TUnsolicitedEventE event( EPlay );
+        TPckg<TUnsolicitedEventE> resp1( event );
+        TInt err = iInitialEventMsg->Write( 1, resp1 );
+        iInitialEventMsg->Complete( err );        
+        delete iInitialEventMsg; iInitialEventMsg = NULL; 
+        iInitialEventReceived = ETrue;
+        }
+    else if( iPlaybackState == EPlaying || iPlaybackState == EStopped)
+        {            
+        // Unsolicited play event when we already were in playing state
+        // or already swithced to stopped state due to previous unsolicited play    
+        // - most probably someone else has issued play command, check current URI
+        __LOG( "CUPnPPlaybackSession::PlayingEventReceived - \
+Unsolicited play event, check if renderer is hijacked" );
+            
+        TRAPD( aErr, SendGetMediaInfoActionL() )
+        if( aErr != KErrNone )
+            {
+            __LOG1( "CUPnPPlaybackSession::CmPrepareResponse - \
+            SendGetMediaInfoActionL failed with code %d", aErr  );             
+            }
+        else
+            {
+            iCheckForHijackedRenderer = ETrue;
+            }
+        }
+    
+    iPlaybackState = EPlaying;  
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::StoppedEventReceived
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::StoppedEventReceived()
+    {
+    __LOG( "CUPnPPlaybackSession::StoppedEventReceived" );
+        
+    if( iExpectedEvent == EEventStopped )
+        {
+        // We were expecting a state change from playing/paused to stopped
+        // since we sent the stop action.
+        RespondToStopRequest();
+        }
+    else if( iPlaybackState == EPlaying ||
+             iPlaybackState == EPaused )
+        {
+        // Unsolicted stop event from the renderer. This means that playback
+        // stopped. Propagate the event.
+        __LOG( "CUPnPPlaybackSession::StoppedEventReceived - \
+Unsolicted stop" );
+        TUnsolicitedEventC event;
+        event.iEvent = EStop; event.iValue = KErrNone; 
+        PropagateEvent( event );
+        }
+    else if( iInitialEventMsg )
+        {
+        __LOG( "CUPnPPlaybackSession::StoppedEventReceived - \
+initial event" );
+        iTimer->Cancel();
+        TUnsolicitedEventE event( EStop );
+        TPckg<TUnsolicitedEventE> resp1( event );
+        TInt err = iInitialEventMsg->Write( 1, resp1 );
+        iInitialEventMsg->Complete( err );        
+        delete iInitialEventMsg; iInitialEventMsg = NULL; 
+        }
+    iPlaybackState = EStopped;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::PausedEventReceived
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::PausedEventReceived()
+    {
+    __LOG( "CUPnPPlaybackSession::PausedEventReceived - \
+PauseUser received" );
+    
+    if( iExpectedEvent == EEventPaused )
+        {
+        // We were expecting a state change from playing to paused
+        // since we sent the pause action.
+        __LOG( "CUPnPPlaybackSession::PausedEventReceived - \
+Response to pause" ); 
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        iTimer->Cancel();
+        // Unregister from the dispatcher. This way we do not get 
+        // ::AvtPauseResponse callback (it would be ignored, anyway)
+        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+        iIPSessionIdCommand = KErrNotFound;        
+        iCommandMessage->Complete( EAVControllerPauseCompleted );
+        delete iCommandMessage; iCommandMessage = NULL;
+        iExpectedEvent = EEventNone;
+        }
+    else if( iPlaybackState == EPlaying ) 
+        {
+        // Unsolicted pause event from the renderer. This means that playback
+        // paused. Propagate the event.
+        __LOG( "CUPnPPlaybackSession::PausedEventReceived - \
+Unsolicted pause" );
+        TUnsolicitedEventC event;
+        event.iEvent = EPause; event.iValue = KErrNone;
+        PropagateEvent( event );
+        }
+    else if( iInitialEventMsg )
+        {
+        __LOG( "CUPnPPlaybackSession::PausedEventReceived - \
+initial event" );
+        iTimer->Cancel();
+        TUnsolicitedEventE event( EPause );
+        TPckg<TUnsolicitedEventE> resp1( event );
+        TInt err = iInitialEventMsg->Write( 1, resp1 );
+        iInitialEventMsg->Complete( err );        
+        delete iInitialEventMsg; iInitialEventMsg = NULL; 
+        iInitialEventReceived = ETrue;
+        }     
+    iPlaybackState = EPaused; 
+    }
+void CUPnPPlaybackSession::NoMediaEventReceived()
+    {
+    __LOG( "CUPnPPlaybackSession::NoMediaEventReceived" );
+
+    if( iInitialEventMsg )
+        {
+        __LOG( "CUPnPPlaybackSession::NoMediaEventReceived - \
+initial event" );
+        iTimer->Cancel();
+        TUnsolicitedEventE event( EStop );
+        TPckg<TUnsolicitedEventE> resp1( event );
+        TInt err = iInitialEventMsg->Write( 1, resp1 );
+        iInitialEventMsg->Complete( err );        
+        delete iInitialEventMsg; iInitialEventMsg = NULL; 
+        }
+    else if( iExpectedEvent == EEventStopped )
+        {
+        // After reconnecting to renderer, a stop command may
+        // result to no media present event. 
+        RespondToStopRequest();
+        }
+    
+    if( iPlaybackState == EStopped || iPlaybackState == EUninitialized )
+        {
+        iPlaybackState = ENoMedia;
+        }
+    else
+        {
+        __LOG( "CUPnPPlaybackSession::NoMediaEventReceived - \
+illegal NO_MEDIA_PRESENT -> ignore" );        
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::CurrentTrackUriEventReceived
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::AVTransportUriEventReceived( const TDesC8& aUri,
+    CUPnPAVTEvent::TTransportState aTransportState )
+    {
+    __LOG8_1( "CUPnPPlaybackSession::AVTransportUriEventReceived, uri: %S",
+            &aUri );
+  
+    if( iExpectedEvent == EEventAVTransportUri )
+        {
+        // We were expecting to get AVTransportUri from the renderer
+        // since we sent the SetAVTransportUri - action
+        __LOG( "CUPnPPlaybackSession::AVTransportUriEventReceived - \
+complete seturi" );
+           
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        // Unregister from the dispatcher. This way we do not get 
+        // ::AvtSetUriResponse callback (it would be ignored, anyway)
+        iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+        iIPSessionIdCommand = KErrNotFound;
+        iTimer->Cancel();
+        iCommandMessage->Complete( EAVControllerSetURICompleted );
+        delete iCommandMessage; iCommandMessage = NULL;
+        iExpectedEvent = EEventNone;
+        iPlaybackState = EStopped;          
+        }
+    else if( iCurrentUri && ( *iCurrentUri != aUri ) )
+        {
+        __LOG( "CUPnPPlaybackSession::AVTransportUriEventReceived - \
+different AVTransportUri - propagate a stop event" );  
+        
+        // Uri changes. Some malicous Control Point captured our device
+        // or something else is wrong. Propagate a stop event with error
+        // code KErrNotReady
+        iPlaybackState = EHalted;
+        TUnsolicitedEventC event;
+        event.iEvent = EStop;
+        event.iValue = KErrNotReady;
+        PropagateEvent( event );
+        }
+    else if( iInitialEventMsg )
+        {
+        __LOG( "CUPnPPlaybackSession::AVTransportUriEventReceived - \
+initial event" );
+        iTimer->Cancel();
+        TUnsolicitedEventE event( EStop );
+        iPlaybackState = EStopped;
+        if( aTransportState == CUPnPAVTEvent::EPlaying )
+            {
+            event = EPlay;
+            iPlaybackState = EPlaying;
+            }
+        else if( aTransportState == CUPnPAVTEvent::EPausedPlayback )
+            {
+            event = EPause;
+            iPlaybackState = EPaused;
+            }
+        TPckg<TUnsolicitedEventE> resp1( event );
+        TInt err = iInitialEventMsg->Write( 1, resp1 );
+        iInitialEventMsg->Complete( err );        
+        delete iInitialEventMsg; iInitialEventMsg = NULL; 
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::PropagateEvent
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::PropagateEvent( TUnsolicitedEventC event )
+    {
+    __LOG( "CUPnPPlaybackSession::PropagateEvent" );
+    
+    if( iEventMessage )
+        {
+        TPckg<TUnsolicitedEventC> resp1( event );
+        TInt err = iEventMessage->Write( 1, resp1 );
+        iEventMessage->Complete( err ); 
+        delete iEventMessage; iEventMessage = NULL;
+        }
+    else
+        {
+        __LOG( "CUPnPPlaybackSession::PropagateEvent - add event to queu" );
+        iEventQue.Append( event );
+        }                                        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::UPnPAVTimerCallback
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::UPnPAVTimerCallback(
+    CUPnPAVTimer::TAVTimerType /*aType*/ )
+    {
+    __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback" );
+
+    // Fail safe timer expired. Check what event we were expecting
+    if( iExpectedEvent == EEventAVTransportUri )
+        {   
+        __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - \
+CurrentTrackUri" );
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        iCommandMessage->Complete( EAVControllerSetURICompleted );
+        delete iCommandMessage; iCommandMessage = NULL;
+        iExpectedEvent = EEventNone;
+        iPlaybackState = EStopped;                       
+        }
+    else if( iExpectedEvent == EEventStopped )
+        {
+        __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - Stop" );
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        iCommandMessage->Complete( EAVControllerStopCompleted );
+        delete iCommandMessage; iCommandMessage = NULL;
+        iExpectedEvent = EEventNone;
+        iPlaybackState = EStopped;                  
+        }
+    else if( iExpectedEvent == EEventPlaying )
+        {
+        __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - Play" );
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        iCommandMessage->Complete( EAVControllerPlayCompleted );
+        delete iCommandMessage; iCommandMessage = NULL;
+        iExpectedEvent = EEventNone;
+        iPlaybackState = EPlaying;                          
+        }
+    else if( iExpectedEvent == EEventPaused )
+        {
+        __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - Pause" );
+        __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+        iCommandMessage->Complete( EAVControllerPauseCompleted );
+        delete iCommandMessage; iCommandMessage = NULL;
+        iExpectedEvent = EEventNone;
+        iPlaybackState = EPaused;                          
+        }
+    else if( iInitialEventMsg )
+        {
+        __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - initial event" );
+        TUnsolicitedEventE event( EStop );
+        TPckg<TUnsolicitedEventE> resp1( event );
+        TInt err = iInitialEventMsg->Write( 1, resp1 );
+        iInitialEventMsg->Complete( err );        
+        delete iInitialEventMsg; iInitialEventMsg = NULL; 
+        }
+    else
+        {
+        __LOG( "CUPnPPlaybackSession::UPnPAVTimerCallback - Not Expected!" );
+        __PANIC( __FILE__, __LINE__ );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPPlaybackSession::RespondToStopRequest
+// See upnpplaybacksession.h
+// --------------------------------------------------------------------------
+void CUPnPPlaybackSession::RespondToStopRequest()
+    {
+    __LOG( "CUPnPPlaybackSession::RespondToStopRequest - \
+Response to stop" );
+    __ASSERT( iCommandMessage, __FILE__, __LINE__ );
+    iTimer->Cancel();
+    // Unregister from the dispatcher. This way we do not get 
+    // ::AvtStopResponse callback (it would be ignored, anyway)        
+    iServer.Dispatcher().UnRegister( iIPSessionIdCommand );
+    iIPSessionIdCommand = KErrNotFound;        
+    iCommandMessage->Complete( EAVControllerStopCompleted );
+    delete iCommandMessage; iCommandMessage = NULL;
+    iExpectedEvent = EEventNone;
+    }
+
+// end of file
--- a/upnpavcontroller/upnpavcontrollerserver/src/upnpuploadsession.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpavcontrollerserver/src/upnpuploadsession.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,938 +1,1032 @@
-/*
-* Copyright (c) 2007 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:      server impl. of session against media server
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <mmf/common/mmfcontrollerpluginresolver.h>
-
-// upnp stack api
-#include <upnpitem.h>
-#include <upnpattribute.h>
-#include <upnpstring.h>
-#include <upnpdlnaprotocolinfo.h>
-#include <upnpavcontrolpoint.h>
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h" // for upnp-specific stuff
-#include "upnpitemutility.h" // FindElementByNameL, GetResElements
-
-// upnpframework / xmlparser api
-#include "upnpxmlparser.h"
-
-// upnpframework / internal api's
-#include "upnpcdsreselementutility.h"
-#include "httpuploader.h"
-#include "upnpmetadatafetcher.h"
-#include "upnpcommonutils.h"
-
-// INTERNAL INCLUDES
-#include "upnpuploadsession.h"
-#include "upnpfiletransferitem.h"
-#include "upnpavcontrollerserver.h"
-#include "upnpfiletransferitem.h"
-#include "upnpavdeviceextended.h"
-#include "upnpavdispatcher.h"
-#include "upnpaverrorhandler.h"
-#include "upnpresourcehelper.h"
-
-_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-_LIT8( KImportUri,              "importUri" );
-_LIT8( KAsterisk,               "*" );
-const TUint32 KBufferSize       = 0x40000; // 256K
-const TInt KParallerTransfers   = 1;
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::NewL
-// See upnpuploadsession.h
-// --------------------------------------------------------------------------
-CUPnPUploadSession* CUPnPUploadSession::NewL( CUpnpAVControllerServer&
-    aServer, TInt aSessionId, const TDesC8& aUuid )
-    {
-    CUPnPUploadSession* self = new (ELeave) CUPnPUploadSession(
-        aServer, aSessionId );
-    CleanupStack::PushL( self );    
-    self->ConstructL( aUuid );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::CUPnPUploadSession
-// See upnpuploadsession.h
-// --------------------------------------------------------------------------
-CUPnPUploadSession::CUPnPUploadSession( CUpnpAVControllerServer& aServer,
-    TInt aSessionId ) :
-    CUPnPFileTransferSessionBase( aServer, aSessionId ),
-    iResourceIndex( KErrNotFound ),
-    iAsyncError( KErrNone ),
-    iIPSessionId( KErrNotFound ),
-    iSchedulerStopped( ETrue )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::~CUPnPUploadSession
-// See upnpuploadsession.h
-// --------------------------------------------------------------------------
-CUPnPUploadSession::~CUPnPUploadSession()
-    {
-    __LOG( "CUPnPUploadSession::~CUPnPUploadSession" );
-
-    delete iUploader;
-    iResources.ResetAndDestroy();
-    
-    __LOG( "CUPnPUploadSession::~CUPnPUploadSession - end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::ConstructL
-// See upnpuploadsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::ConstructL( const TDesC8& aUuid )
-    {
-    __LOG( "CUPnPUploadSession::ConstructL" );
-    
-    CUPnPFileTransferSessionBase::ConstructL( aUuid );
-
-    iUploader = CHttpUploader::NewL( *this, (TUint32)iServer.IAP(),
-        KBufferSize, KParallerTransfers );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPDownloadSession::TransferProgress
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::TransferProgress( TAny* aKey, TInt aBytes,
-    TInt aTotalBytes )
-    {
-    __LOG( "CUPnPUploadSession::TransferProgress" );
-    
-    if( iProgressTrackingEnabled )
-        {
-        TUpnpFileTransferEvent item;
-        TInt err = FindItemByKey( item, (TInt)aKey );
-        if( err == KErrNone )
-            {
-            item.iStatus = KErrNone;
-            item.iParam2 = aTotalBytes;
-            item.iParam1 = aBytes;
-            item.iEvent = TUpnpFileTransferEvent::ETransferProgress;
-
-            Complete( item );
-            }
-        else
-            {
-            __LOG( "TransferProgress - Not enabled!" );
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::ReadyForTransfer
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::ReadyForTransferL( TAny* aKey )
-    {
-    __LOG( "CUPnPUploadSession::ReadyForTransferL" );
-    
-    TUpnpFileTransferEvent event;
-    if( FindItemByKey( event, (TInt)aKey, iResourceIndex ) == KErrNone )
-        {
-        ReadyForTransferL( event );
-        
-        event.iEvent = TUpnpFileTransferEvent::ETransferStarted;
-        Complete( event );
-        }
-    else
-        {
-        __LOG( "ReadyForTransfer - Key not found" );
-        
-        // Not found
-        event.iStatus = KErrGeneral;
-        event.iParam2 = 0;
-        event.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
-        
-        Complete( event );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::TransferCompleted
-// See upnpdownloadsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::TransferCompleted( TAny* aKey, TInt aStatus )
-    {
-    __LOG2( "CUPnPUploadSession::TransferCompleted, key = %d, status = %d",
-            (TInt)aKey, aStatus );
-    
-    TUpnpFileTransferEvent item;
-    TInt index;
-    TInt err = FindItemByKey( item, (TInt)aKey, index );
-    if( err == KErrNone )
-        {
-        item.iStatus = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aStatus,
-        EUPnPHTTPError );
-        
-        item.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
-        Complete( item );
-                
-        iTransferItems.Remove( index );
-        delete iResources[ index ];
-        iResources.Remove( index );
-        }
-    else
-        {
-        __LOG( "TransferCompleted - Key not found" );
-        
-        // Not found
-        if( aStatus == KErrCancel )
-            {
-            item.iStatus = aStatus;
-            }
-        else
-            {
-            item.iStatus = KErrGeneral;    
-            }    
-        
-        item.iParam2 = 0;
-        item.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
-        
-        Complete( item );
-        } 
-    
-    if( aStatus == KErrDisconnected )
-        {
-        __LOG( "TransferCompleted - Target device lost" );
-        
-        TInt count = iTransferItems.Count();
-        for( TInt i = 0; i < count; i++ )
-            {
-            iUploader->CancelTransfer( (TAny*)iTransferItems[i].iKey );
-
-            if( iResources[ i ]->ItemId() )
-                {
-                // Send destroyobject
-                __LOG( "CancelAllUploadsL - sending destroyobject" );
-                TRAP_IGNORE( iServer.ControlPoint().CdsDestroyObjectActionL(
-                    iDevice->Uuid(), *iResources[ i ]->ItemId() ) );  
-                }
-            }
-        iResources.ResetAndDestroy();    
-        iTransferItems.Reset();
-        }      
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::CdsCreateObjectResponse
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::CdsCreateObjectResponse(
-    const TDesC8& /*aUuid*/,
-    TInt aSessionId,
-    TInt aErr,
-    const TDesC8& /*aContainerID*/, 
-    const TDesC8& /*aElements*/, 
-    const TDesC8& aObjectID, 
-    const TDesC8& aResult )
-    {
-    __LOG1( "CUPnPUploadSession::CdsCreateObjectResponse: %d" , aErr );
-    
-    __ASSERTD( iIPSessionId == aSessionId, __FILE__, __LINE__ );
-    
-    __ASSERTD( iTransferItems.Count() == iResources.Count(), __FILE__, 
-               __LINE__ );
-    
-    iServer.Dispatcher().UnRegister( iIPSessionId );
-    iIPSessionId = KErrNotFound;
-    
-    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
-        EUPnPContentDirectoryError );
-
-    if( aErr == KErrNone )
-        {
-        TRAP( aErr, HandleObjectResponseL( aObjectID, aResult ) );
-        }        
-    
-    iAsyncError = aErr;
-    StopWait();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::StartUploadL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::StartUploadL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPUploadSession::StartUploadL" );
-    
-    __ASSERTD( iTransferItems.Count() == iResources.Count(), __FILE__, 
-               __LINE__ );
-    
-    CUpnpFileTransferItem* tmpTransferItem = CUpnpFileTransferItem::NewLC();
-        
-    ReadTransferItemFromMessageL( aMessage, 1 ,tmpTransferItem );
-        
-    if( CheckIfKeyExists( tmpTransferItem->Key() ) )
-        {
-        User::Leave( KErrInUse );
-        }
-    
-    TUpnpFileTransferEvent transferItem;        
-    transferItem.iKey = tmpTransferItem->Key();
-            
-    CUpnpItem* tmpUpnpItem = UPnPMetadataFetcher::CreateItemFromFileLC( 
-        tmpTransferItem->Path() );
-        
-    tmpUpnpItem->SetIdL( KNullDesC8 );
-    tmpUpnpItem->SetParentIdL( KContainerIdAny );
-    tmpUpnpItem->SetRestricted( EFalse );
-
-    const CUpnpElement& resEl = UPnPItemUtility::FindElementByNameL(
-        *tmpUpnpItem, KElementRes );
-
-    const CUpnpAttribute* pInfo = UPnPItemUtility::FindAttributeByName(
-        resEl, KAttributeProtocolInfo );  
-      
-    if( iDevice->DlnaCompatible() )
-        {
-        // Dlna device, additional checks required
-        __LOG( "StartUploadL - DLNA device" );
-        
-        TPtrC8 objectClass = tmpUpnpItem->ObjectClass(); 
-        if( objectClass.Find( KClassAudio ) != KErrNotFound &&
-            iDevice->AudioUpload() )
-            {
-            // Trying to upload audio and it's supported
-            }
-        else if( objectClass.Find( KClassImage ) != KErrNotFound &&
-            iDevice->ImageUpload() )
-            {
-            // Trying to upload images and it's supported
-            }
-        else if(  objectClass.Find( KClassVideo ) != KErrNotFound &&
-            iDevice->VideoUpload() )
-            {
-            // Trying to upload video and it's supported
-            }
-        else
-            {
-            // Unknown media type, or copy not supported
-            __LOG( "StartUploadL - Unknown media type, or copy not \
-supported" );
-            User::Leave( KErrNotSupported );
-            }    
-
-            if( iDevice->ValidateTransfer( pInfo->Value() ) )
-                {
-                __LOG( "StartUploadL - Match by protocolInfo succeeded" );
-                // Continue with DLNA upload
-                // ProtocolInfo is in DLNA format
-                }
-            else
-                {
-                __LOG( "StartUploadL - Match by protocolInfo failed, upload \
-as UPnP content" );
-                // Continue with UPnP upload
-                // Check the protocolInfo
-                ProtocolInfoToUPnPL( pInfo );
-                }        
-        }
-    else
-        {
-        __LOG( "StartUploadL - UPnP Device -> UPnP upload" );
-        // Continue with UPnP upload
-        // Check the protocolInfo
-        ProtocolInfoToUPnPL( pInfo );        
-        }
-        
-    iUploader->InsertFileIntoWaitQueueL( (TAny*)transferItem.iKey,
-        tmpTransferItem->Path(), KNullDesC8 );
-    
-    SetHeadersL( pInfo->Value(), (TAny*)transferItem.iKey );
-    
-    iTransferItems.Append( transferItem );
-    
-    CUPnPResourceHelper* helper = CUPnPResourceHelper::NewL();
-    CleanupStack::Pop( tmpUpnpItem );
-    helper->SetItem( tmpUpnpItem ); // Transfer ownership
-    iResources.AppendL( helper );
-    
-    iUploader->MoveToTransferQueueL( (TAny*)transferItem.iKey );
-    
-    CleanupStack::PopAndDestroy( tmpTransferItem );
-    
-    aMessage.Complete( KErrNone );
-    
-    __LOG( "CUPnPUploadSession::StartUploadL - end " );    
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::CancelUploadL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::CancelUploadL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPUploadSession::CancelUploadL" );          
-    
-    __ASSERTD( iTransferItems.Count() == iResources.Count(), __FILE__,
-               __LINE__ );
-    
-    TInt key = aMessage.Int1();
-
-    TInt index;
-    if( CheckIfKeyExists( key, index ) )
-        {
-        iUploader->CancelTransfer( (TAny*)key );
-        aMessage.Complete( KErrNone );
-        iTransferItems.Remove( index );
-        if( iResources[ index ]->ItemId() )
-            {
-            // Send destroyobject
-            iServer.ControlPoint().CdsDestroyObjectActionL( iDevice->Uuid(),
-                *iResources[ index ]->ItemId() );
-            }
-        delete iResources[index ];
-        iResources.Remove( index );   
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }        
-    
-    __LOG( "CUPnPUploadSession::CancelUploadL - end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::CancelAllUploadsL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::CancelAllUploadsL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPUploadSession::CancelAllUploadsL" );          
-    
-    __ASSERTD( iTransferItems.Count() == iResources.Count(), __FILE__,
-               __LINE__ );
-        
-    TInt count = iTransferItems.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        iUploader->CancelTransfer( (TAny*)iTransferItems[i].iKey );
-
-        if( iResources[ i ]->ItemId() )
-            {
-            // Send destroyobject
-            __LOG( "CancelAllUploadsL - sending destroyobject" );
-            iServer.ControlPoint().CdsDestroyObjectActionL( iDevice->Uuid(),
-                *iResources[ i ]->ItemId() );  
-            }
-        }
-    iResources.ResetAndDestroy();
-    iTransferItems.Reset();
-    iEventQueu.Reset();
-
-    // Scheduler loop started, stop it and ignore createobject-resp
-    __LOG( "CancelAllUploadsL - Un register" );
-    iServer.Dispatcher().UnRegister( iIPSessionId );
-    iIPSessionId = KErrNotFound;
-    iAsyncError = KErrCancel;
-
-    __LOG( "CancelAllUploadsL - Stop scheduler loop" );
-    StopWait();
-
-    aMessage.Complete( KErrNone );
-
-    __LOG( "CUPnPUploadSession::CancelAllUploadsL - end" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::StartTrackingUploadProgressL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::StartTrackingUploadProgressL( const RMessage2&
-    aMessage )
-    {
-    __LOG( "CUPnPUploadSession::StartTrackingUploadProgressL" );
-    
-    TInt key = aMessage.Int1();
-    if( CheckIfKeyExists( key ) )
-        {
-        iUploader->TrackProgress( (TAny*)key, ETrue );
-        iProgressTrackingEnabled = ETrue;
-        aMessage.Complete( KErrNone );
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::StopTrackingUploadProgressL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::StopTrackingUploadProgressL( const RMessage2&
-    aMessage )
-    {
-    __LOG( "CUPnPUploadSession::StopTrackingUploadProgressL" );
-    
-    TInt key = aMessage.Int1();
-    if( CheckIfKeyExists( key ) )
-        {
-        iUploader->TrackProgress( (TAny*)key, EFalse );
-        iProgressTrackingEnabled = EFalse;        
-        aMessage.Complete( KErrNone );
-        }
-    else
-        {
-        aMessage.Complete( KErrNotFound );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::GetUploadEventL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::GetUploadEventL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPUploadSession::GetUploadEventL" );
-    
-    if( iEventQueu.Count() )
-        {
-        // There are events in the queu, write the first queued event back
-        // to client
-        __LOG1( "GetUploadEventL - events in queu, count = %d",
-            iEventQueu.Count() );
-        TPckg<TUpnpFileTransferEvent> resp1( iEventQueu[0] );
-        aMessage.Write( 1, resp1  ); // Write response using slot 1
-        aMessage.Complete( KErrNone );
-        
-        iEventQueu.Remove( 0 );
-        }
-    else
-        {
-        __ASSERTD( !iEventMsg, __FILE__, __LINE__ );
-        __LOG( "GetUploadEventL - Store msg" );
-        iEventMsg = new (ELeave) RMessage2( aMessage );
-        } 
-    __LOG( "CUPnPUploadSession::GetUploadEventL - end" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::CancelGetUploadEventL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::CancelGetUploadEventL( const RMessage2& aMessage )
-    {
-    __LOG( "CUPnPUploadSession::CancelGetUploadEventL" );          
-    
-    if( iEventMsg )
-        {
-        iEventMsg->Complete( KErrCancel );
-        delete iEventMsg; iEventMsg = NULL;
-        }
-    aMessage.Complete( KErrNone );    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::DeviceDisappearedL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::DeviceDisappearedL(
-    CUpnpAVDeviceExtended& aDevice )
-    {
-    __LOG( "CUPnPUploadSession::DeviceDisappearedL" );
-
-    if( aDevice.Uuid().Compare( iDevice->Uuid() ) == 0 )
-        {
-        TUpnpFileTransferEvent event;
-        event.iEvent = TUpnpFileTransferEvent::EDeviceDisconnected;
-
-        Complete( event );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::SetHeadersL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::SetHeadersL( const TDesC8& aInfo, TAny* aKey )
-    {
-    CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo );
-    CleanupStack::PushL( tmpInfo );
-
-    // Set the content-type header
-    iUploader->SetHeaderL( aKey, KContentType,
-        tmpInfo->ThirdField() );
-    
-    // Set the expect header
-    iUploader->SetHeaderL( aKey, KExpectHeader, K100Continue );
-
-    CleanupStack::PopAndDestroy( tmpInfo );            
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::ReadyForTransferL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::ReadyForTransferL( TUpnpFileTransferEvent& aEvent )
-    {
-    __LOG( "CUPnPUploadSession::ReadyForTransferL" );
-    
-    if ( !iSchedulerStopped || iWait.IsStarted() )
-        {
-        __LOG1( "CUPnPUploadSession::ReadyForTransferL\
-        IsStarted = %d", (TInt)iWait.IsStarted() );
-        __LOG1( "CUPnPUploadSession::ReadyForTransferL\
-        iSchedulerStopped = %d", (TInt)iSchedulerStopped );
-        User::Leave( KErrNotReady );
-        }
-
-    __ASSERTD( iTransferItems.Count() == iResources.Count(), __FILE__, 
-               __LINE__ );
-    
-    CUpnpItem* tmpUpnpItem = iResources[ iResourceIndex ]->Item();
-    if( !tmpUpnpItem )
-        {
-        User::Leave( KErrCorrupt );
-        }
-    
-    HBufC8* xmlDoc = CUPnPXMLParser::XmlForCreateObjectLC(
-        *tmpUpnpItem );
-    
-    iIPSessionId = iServer.ControlPoint().CdsCreateObjectActionL(
-        iDevice->Uuid(), KContainerIdAny, *xmlDoc );
-
-    if( iIPSessionId > 0 )
-        {
-        // Register
-        iServer.Dispatcher().RegisterL( iIPSessionId, *this );
-        }
-    else
-        {
-        User::Leave( iIPSessionId );
-        }                             
-    
-    CleanupStack::PopAndDestroy( xmlDoc );
-    
-    iWait.Start();
-    
-    __LOG1( "CUPnPUploadSession::ReadyForTransferL\
-        iAsyncError = %d", iAsyncError );
-
-    User::LeaveIfError( iAsyncError );
-
-    const CUpnpElement& resEl = UPnPItemUtility::FindElementByNameL(
-        *iResources[ iResourceIndex ]->Item(), KElementRes );
-
-    const CUpnpAttribute* pInfo = UPnPItemUtility::FindAttributeByName(
-        resEl, KAttributeProtocolInfo );  
-
-    CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
-        pInfo->Value() );
-    CleanupStack::PushL( tmpInfo );      
-    
-    // Set DLNA specific headers    
-    if( tmpInfo->PnParameter().Length() )
-        {
-        // DLNA content, set the content-features header
-        iUploader->SetHeaderL( (TAny*)aEvent.iKey, KContentFeatures,
-            tmpInfo->FourthField() );        
-
-        // Check if background mode is available and use it if it is
-        if( tmpInfo->DlnaFlag( UpnpDlnaProtocolInfo::TM_B_FLAG ) )
-            {
-            __LOG( "ReadyForTransferL - Use background mode" );
-            
-            iUploader->SetHeaderL( (TAny*)aEvent.iKey, KTransferMode,
-                KBackgroundMode );  
-            }
-        else
-            {
-            // Background is not available for some reason.
-            // Check if media specific transfer mode is available
-            if( UPnPCommonUtils::IsImageSupported( tmpInfo->ProtocolInfoL() ) )
-                {
-                // Uploading image, alternative for background is interactive
-                if( tmpInfo->DlnaFlag( UpnpDlnaProtocolInfo::TM_I_FLAG ) )
-                    {
-                    __LOG( "ReadyForTransferL - Use interactive mode" );
-                    iUploader->SetHeaderL( (TAny*)aEvent.iKey, KTransferMode,
-                        KInteractiveMode );
-                    }
-                else
-                    {
-                    // Target DMS does not support appropriate transfer mode
-                    __LOG( "ReadyForTransferL - No appropriate mode" );
-                    // Still, give a try and use background
-                    iUploader->SetHeaderL( (TAny*)aEvent.iKey, KTransferMode,
-                        KBackgroundMode );  
-                    }            
-                }
-            else if( UPnPCommonUtils::IsAudioSupported(
-                        tmpInfo->ProtocolInfoL() ) ||
-                    UPnPCommonUtils::IsVideoSupported(
-                        tmpInfo->ProtocolInfoL() ) )
-                {
-                // Uploading A/V, alternative for background is streaming
-                if( tmpInfo->DlnaFlag( UpnpDlnaProtocolInfo::TM_S_FLAG ) )
-                    {
-                    __LOG( "ReadyForTransferL - Use streaming mode" );
-                    iUploader->SetHeaderL( (TAny*)aEvent.iKey, KTransferMode,
-                    KStreamingMode );
-                    }
-                else
-                    {
-                    // Target DMS does not support appropriate transfer mode
-                    __LOG( "ReadyForTransferL - No appropriate mode" );
-                    // Still, give a try and use background
-                    iUploader->SetHeaderL( (TAny*)aEvent.iKey, KTransferMode,
-                        KBackgroundMode );  
-                    }                 
-                }
-            else
-                {
-                __LOG( "ReadyForTransferL - Unknown media type" );
-                }    
-                        
-            }            
-
-        }                
-    
-    CleanupStack::PopAndDestroy( tmpInfo ); 
-    
-    iUploader->SetPropertyL( (TAny*)aEvent.iKey,
-        CHttpTransferBase::ETargetURI,
-        *iResources[ iResourceIndex ]->Resource() );
-            
-    iUploader->StartTransferL( (TAny*)aEvent.iKey );
-        
-    __LOG( "CUPnPUploadSession::ReadyForTransferL - end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::ParseCreateObjectResponseL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::HandleObjectResponseL( const TDesC8& aObjectID,
-    const TDesC8& aResult )
-    {
-    __LOG( "CUPnPUploadSession::HandleObjectResponseL" );          
-    
-    HBufC8* importUri = ParseCreateObjectResponseL( aResult );
-    CleanupStack::PushL( importUri );
-
-    HBufC8* tmpUri = UpnpString::EncodeXmlStringL( importUri );
-    CleanupStack::PopAndDestroy( importUri );
-    CleanupStack::PushL( tmpUri );
-        
-    HBufC* tmpUri16 = UpnpString::ToUnicodeL( *tmpUri );
-    CleanupStack::PopAndDestroy( tmpUri );
-          
-    iResources[ iResourceIndex ]->SetResource( tmpUri16 );
-        
-    HBufC8* tmpID = aObjectID.AllocL();
-    iResources[ iResourceIndex ]->SetItemId( tmpID );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::ParseCreateObjectResponseL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-HBufC8* CUPnPUploadSession::ParseCreateObjectResponseL(
-    const TDesC8& aResponse )
-    {
-    __LOG( "CUPnPUploadSession::ParseCreateObjectResponseL" );          
-    
-    HBufC8* importURI = NULL;
-    
-    CUPnPXMLParser* parser = CUPnPXMLParser::NewL();
-    CleanupStack::PushL( parser );
-    
-    RPointerArray<CUpnpObject> array;
-    CleanupResetAndDestroyPushL( array );
-    
-    parser->ParseResultDataL( array, aResponse );
-    
-    TInt count = array.Count();
-    
-    // Lets find the first item with an import URI and use that
-    for( TInt i = 0; i < count; i++ )
-        {
-        importURI = ImportURIFromItemL( *array[ i ] );
-        if( importURI )
-            {
-             // Transfer ownership, casting is safe
-             // (array[ 0 ]->ObjectType() == EUPnPItem)
-            CUpnpItem* item = static_cast<CUpnpItem*>( array[ i ] );
-            iResources[ iResourceIndex ]->SetItem( item );
-            array.Remove( i );
-            i = count;
-            }
-        }
-    if( !importURI ) // no suitable items, leave
-        {
-        User::Leave( KErrGeneral );
-        }
-            
-    CleanupStack::PopAndDestroy( &array );
-    CleanupStack::PopAndDestroy( parser );  
-              
-    if( !UpnpCdsResElementUtility::IsUriAbsolute( *importURI ) )
-        {
-        // Import uri is not absolute, upload not supported. leave.
-        delete importURI; importURI = NULL;
-        User::Leave( KErrGeneral );
-        }
-      
-    return importURI;
-    }       
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::ImportURIFromItemL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-HBufC8* CUPnPUploadSession::ImportURIFromItemL( const CUpnpObject& aObject )
-    {
-    HBufC8* importURI = NULL;
-    if( aObject.ObjectType() == EUPnPItem )
-        {
-        // Get the res-elements
-        RUPnPElementsArray elArray;
-        CleanupClosePushL( elArray );
-        UPnPItemUtility::GetResElements( aObject, elArray );
-        
-        // Find the import uri 
-        TInt count = elArray.Count();           
-        for( TInt i = 0; i < count; i++ )
-            {
-            const CUpnpAttribute* attribute = NULL;
-            attribute = &UPnPItemUtility::FindAttributeByNameL(
-                *elArray[ i ], KImportUri );
-            if( attribute )
-                {
-                // import uri found
-                i = count;
-                importURI = attribute->Value().AllocL();
-                }
-            }            
-        CleanupStack::PopAndDestroy( &elArray );        
-        }
-    return importURI;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPUploadSession::ProtocolInfoToUPnPL
-// See upnpbrowsingsession.h
-// --------------------------------------------------------------------------
-void CUPnPUploadSession::ProtocolInfoToUPnPL( const CUpnpAttribute* aInfo )
-    {
-    __LOG( "CUPnPUploadSession::ProtocolInfoToUPnPL" );
-    
-    CUpnpDlnaProtocolInfo* destInfo =
-        CUpnpDlnaProtocolInfo::NewL( aInfo->Value() );
-    CleanupStack::PushL( destInfo );
-    
-    if( destInfo->PnParameter().Length() )
-        {
-        __LOG( "ProtocolInfoToUPnPL - Convert to UPnP" );
-        
-        CUpnpProtocolInfo* targetInfo = CUpnpProtocolInfo::NewL();
-        CleanupStack::PushL( targetInfo );
-        
-        targetInfo->SetFirstFieldL( destInfo->FirstField() );
-        targetInfo->SetSecondFieldL( KAsterisk );
-        targetInfo->SetThirdFieldL( destInfo->ThirdField() );
-        targetInfo->SetFourthFieldL( KAsterisk );
-        
-        // A bit dirty const cast.. but makes implementation much easier
-        CUpnpAttribute* bute = const_cast<CUpnpAttribute*>( aInfo );
-        bute->SetValueL( targetInfo->ProtocolInfoL() );
-        
-        CleanupStack::PopAndDestroy( targetInfo );
-        }
-    else
-        {
-        __LOG( "ProtocolInfoToUPnPL - UPnP content -> do nothing" );
-        // Not DLNA content, do nothing
-        }    
-        
-    CleanupStack::PopAndDestroy( destInfo );
-    }
-
-//---------------------------------------------------------------------------
-// CUPnPUploadSession::StopWait()
-// See upnpbrowsingsession.h
-//---------------------------------------------------------------------------
-//
-void CUPnPUploadSession::StopWait()
-    {
-    __LOG( "ProtocolInfoToUPnPL::StopWait" );
-    if ( iWait.IsStarted() )
-        {
-        if ( iWait.CanStopNow() )
-            {
-            __LOG( "ProtocolInfoToUPnPL::StopWait - stop" );
-            iWait.AsyncStop();
-            iSchedulerStopped = ETrue;
-            }
-        else
-            {
-            __LOG( "CUPnPUploadSession::StopWait\
-- not able to stop now, use callback" );
-            iSchedulerStopped = EFalse;
-            iWait.AsyncStop( TCallBack(
-                                SchedulerStoppedCallBack,
-                                this ) );
-            }
-        }
-    }
-
-//---------------------------------------------------------------------------
-// CUPnPUploadSession::SchedulerStoppedCallBack()
-// See upnpbrowsingsession.h
-//---------------------------------------------------------------------------
-//
-TInt CUPnPUploadSession::SchedulerStoppedCallBack( TAny* aPtr )
-    {
-    CUPnPUploadSession* self = 
-        static_cast<CUPnPUploadSession*>( aPtr );
-    self->DoSchedulerStoppedCallBack();
-    return 0;
-    }
-
-//---------------------------------------------------------------------------
-// CUPnPUploadSession::DoSchedulerStoppedCallBack()
-// See upnpbrowsingsession.h
-//---------------------------------------------------------------------------
-//
-void CUPnPUploadSession::DoSchedulerStoppedCallBack()
-    {
-    __LOG( "ProtocolInfoToUPnPL::DoSchedulerStoppedCallBack" );
-    iSchedulerStopped = ETrue;
-    }
-
-// End of file
+/*
+* Copyright (c) 2007 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:      server impl. of session against media server
+*
+*/
+
+// INCLUDE FILES
+// System
+#include <mmf/common/mmfcontrollerpluginresolver.h>
+
+// upnp stack api
+#include <upnpstring.h>
+
+// dlnasrv / mediaserver api
+#include <upnpitem.h>
+#include <upnpattribute.h>
+#include <upnpdlnaprotocolinfo.h>
+
+// dlnasrv / avcontroller helper api
+#include "upnpconstantdefs.h" // for upnp-specific stuff
+#include "upnpitemutility.h" // FindElementByNameL, GetResElements
+
+// dlnasrv / xmlparser api
+#include "upnpxmlparser.h"
+
+// dlnasrv / internal api's
+#include "upnpcdsreselementutility.h"
+#include "httpuploader.h"
+#include "upnpmetadatafetcher.h"
+#include "upnpcommonutils.h"
+
+// dlnasrv / avcontroller internal api's
+#include "upnpuploadsession.h"
+#include "upnpfiletransferitem.h"
+#include "upnpavcontrollerserver.h"
+#include "upnpfiletransferitem.h"
+#include "upnpavdeviceextended.h"
+#include "upnpavdispatcher.h"
+#include "upnpaverrorhandler.h"
+#include "upnpavcpstrings.h"
+#include "upnpresourcehelper.h"
+#include "upnpavcontrolpoint.h"
+
+using namespace UpnpAVCPStrings;
+
+_LIT( KComponentLogfile, "upnpavcontrollerserver.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+_LIT8( KImportUri,              "importUri" );
+_LIT8( KAsterisk,               "*" );
+const TUint32 KBufferSize       = 0x40000; // 256K
+const TInt KParallerTransfers   = 1;
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::NewL
+// See upnpuploadsession.h
+// --------------------------------------------------------------------------
+CUPnPUploadSession* CUPnPUploadSession::NewL( CUpnpAVControllerServer&
+    aServer, TInt aSessionId, const TDesC8& aUuid )
+    {
+    CUPnPUploadSession* self = new (ELeave) CUPnPUploadSession(
+        aServer, aSessionId );
+    CleanupStack::PushL( self );    
+    self->ConstructL( aUuid );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::CUPnPUploadSession
+// See upnpuploadsession.h
+// --------------------------------------------------------------------------
+CUPnPUploadSession::CUPnPUploadSession( CUpnpAVControllerServer& aServer,
+    TInt aSessionId ) :
+    CUPnPFileTransferSessionBase( aServer, aSessionId ),
+    iResourceIndex( KErrNotFound ),
+    iAsyncError( KErrNone ),
+    iIPSessionId( KErrNotFound ),
+    iSchedulerStopped( ETrue )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::~CUPnPUploadSession
+// See upnpuploadsession.h
+// --------------------------------------------------------------------------
+CUPnPUploadSession::~CUPnPUploadSession()
+    {
+    __LOG( "CUPnPUploadSession::~CUPnPUploadSession" );
+
+    delete iUploader;
+    iResources.ResetAndDestroy();
+    
+    __LOG( "CUPnPUploadSession::~CUPnPUploadSession - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ConstructL
+// See upnpuploadsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::ConstructL( const TDesC8& aUuid )
+    {
+    __LOG( "CUPnPUploadSession::ConstructL" );
+    
+    CUPnPFileTransferSessionBase::ConstructL( aUuid );
+
+    iUploader = CHttpUploader::NewL( *this, (TUint32)iServer.IAP(),
+        KBufferSize, KParallerTransfers );
+    
+    // Gets related ControlPoint device (CUpnpDevice).
+    // It is needed for CUpnpAVControlPoint.
+    iCpDevice = iServer.ControlPoint().Device( aUuid );
+    if ( !iCpDevice ) 
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ActionResponseL
+// From MUpnpAVControlPointObserver
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::ActionResponseL( CUpnpAction* aAction )
+    {
+    if (aAction->Name().Compare(KCreateObject) == 0)
+        {
+        __ASSERT( iIPSessionId == aAction->SessionId(),
+            __FILE__, __LINE__ );
+        CdsCreateObjectResponse(
+            aAction->Error(),
+            aAction->ArgumentValue(KObjectID), 
+            aAction->ArgumentValue(KResult)
+            );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ActionResponseL
+// From MUpnpAVControlPointObserver
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::StateUpdatedL( CUpnpService* /*aService*/ )
+    {
+    // No implementation required
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ActionResponseL
+// From MUpnpAVControlPointObserver
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::HttpResponseL( CUpnpHttpMessage* /*aMessage*/ )
+    {
+    // No implementation required
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ActionResponseL
+// From MUpnpAVControlPointObserver
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::DeviceDiscoveredL( CUpnpDevice* /*aDevice*/ )
+    {
+    // No implementation required
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ActionResponseL
+// From MUpnpAVControlPointObserver
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::DeviceDisappearedL( CUpnpDevice* /*aDevice*/ )
+    {
+    // No implementation required
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPDownloadSession::TransferProgress
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::TransferProgress( TAny* aKey, TInt aBytes,
+    TInt aTotalBytes )
+    {
+    __LOG( "CUPnPUploadSession::TransferProgress" );
+    
+    if( iProgressTrackingEnabled )
+        {
+        TUpnpFileTransferEvent item;
+        TInt err = FindItemByKey( item, (TInt)aKey );
+        if( err == KErrNone )
+            {
+            item.iStatus = KErrNone;
+            item.iParam2 = aTotalBytes;
+            item.iParam1 = aBytes;
+            item.iEvent = TUpnpFileTransferEvent::ETransferProgress;
+
+            Complete( item );
+            }
+        else
+            {
+            __LOG( "TransferProgress - Not enabled!" );
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ReadyForTransfer
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::ReadyForTransferL( TAny* aKey )
+    {
+    __LOG( "CUPnPUploadSession::ReadyForTransferL" );
+    
+    TUpnpFileTransferEvent event;
+    if( FindItemByKey( event, (TInt)aKey, iResourceIndex ) == KErrNone )
+        {
+        ReadyForTransferL( event );
+        
+        event.iEvent = TUpnpFileTransferEvent::ETransferStarted;
+        Complete( event );
+        }
+    else
+        {
+        __LOG( "ReadyForTransfer - Key not found" );
+        
+        // Not found
+        event.iStatus = KErrGeneral;
+        event.iParam2 = 0;
+        event.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
+        
+        Complete( event );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::TransferCompleted
+// See upnpdownloadsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::TransferCompleted( TAny* aKey, TInt aStatus )
+    {
+    __LOG2( "CUPnPUploadSession::TransferCompleted, key = %d, status = %d",
+            (TInt)aKey, aStatus );
+    
+    TUpnpFileTransferEvent item;
+    TInt index;
+    TInt err = FindItemByKey( item, (TInt)aKey, index );
+    if( err == KErrNone )
+        {
+        item.iStatus = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aStatus,
+        EUPnPHTTPError );
+        
+        item.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
+        Complete( item );
+                
+        iTransferItems.Remove( index );
+        delete iResources[ index ];
+        iResources.Remove( index );
+        }
+    else
+        {
+        __LOG( "TransferCompleted - Key not found" );
+        
+        // Not found
+        if( aStatus == KErrCancel )
+            {
+            item.iStatus = aStatus;
+            }
+        else
+            {
+            item.iStatus = KErrGeneral;    
+            }    
+        
+        item.iParam2 = 0;
+        item.iEvent = TUpnpFileTransferEvent::ETransferCompleted;
+        
+        Complete( item );
+        } 
+    
+    if( aStatus == KErrDisconnected )
+        {
+        __LOG( "TransferCompleted - Target device lost" );
+        
+        TInt count = iTransferItems.Count();
+        for( TInt i = 0; i < count; i++ )
+            {
+            iUploader->CancelTransfer( (TAny*)iTransferItems[i].iKey );
+
+            if( iResources[ i ]->ItemId() )
+                {
+                // Send destroyobject
+                __LOG( "CancelAllUploadsL - sending destroyobject" );
+                TRAP_IGNORE( DestroyObjectL( *iResources[ i ]->ItemId() ) );
+                }
+            }
+        iResources.ResetAndDestroy();    
+        iTransferItems.Reset();
+        }      
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::CdsCreateObjectResponse
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::CdsCreateObjectResponse(
+    TInt aErr,
+    const TDesC8& aObjectID, 
+    const TDesC8& aResult )
+    {
+    __LOG1( "CUPnPUploadSession::CdsCreateObjectResponse: %d" , aErr );
+
+    __ASSERTD( iTransferItems.Count() == iResources.Count(), __FILE__, 
+               __LINE__ );
+    
+    iServer.Dispatcher().UnRegister( iIPSessionId );
+    iIPSessionId = KErrNotFound;
+    
+    aErr = UPnPAVErrorHandler::ConvertToSymbianErrorCode( aErr,
+        EUPnPContentDirectoryError );
+
+    if( aErr == KErrNone )
+        {
+        TRAP( aErr, HandleObjectResponseL( aObjectID, aResult ) );
+        }        
+    
+    iAsyncError = aErr;
+    StopWait();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::StartUploadL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::StartUploadL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPUploadSession::StartUploadL" );
+    
+    __ASSERTD( iTransferItems.Count() == iResources.Count(), __FILE__, 
+               __LINE__ );
+    
+    CUpnpFileTransferItem* tmpTransferItem = CUpnpFileTransferItem::NewLC();
+        
+    ReadTransferItemFromMessageL( aMessage, 1 ,tmpTransferItem );
+        
+    if( CheckIfKeyExists( tmpTransferItem->Key() ) )
+        {
+        User::Leave( KErrInUse );
+        }
+    
+    TUpnpFileTransferEvent transferItem;        
+    transferItem.iKey = tmpTransferItem->Key();
+            
+    CUpnpItem* tmpUpnpItem = UPnPMetadataFetcher::CreateItemFromFileLC( 
+        tmpTransferItem->Path() );
+        
+    tmpUpnpItem->SetIdL( KNullDesC8 );
+    tmpUpnpItem->SetParentIdL( KContainerIdAny );
+    tmpUpnpItem->SetRestricted( EFalse );
+
+    const CUpnpElement& resEl = UPnPItemUtility::FindElementByNameL(
+        *tmpUpnpItem, KElementRes );
+
+    const CUpnpAttribute* pInfo = UPnPItemUtility::FindAttributeByName(
+        resEl, KAttributeProtocolInfo );  
+      
+    if( iDevice->DlnaCompatible() )
+        {
+        // Dlna device, additional checks required
+        __LOG( "StartUploadL - DLNA device" );
+        
+        TPtrC8 objectClass = tmpUpnpItem->ObjectClass(); 
+        if( objectClass.Find( KClassAudio ) != KErrNotFound &&
+            iDevice->AudioUpload() )
+            {
+            // Trying to upload audio and it's supported
+            }
+        else if( objectClass.Find( KClassImage ) != KErrNotFound &&
+            iDevice->ImageUpload() )
+            {
+            // Trying to upload images and it's supported
+            }
+        else if(  objectClass.Find( KClassVideo ) != KErrNotFound &&
+            iDevice->VideoUpload() )
+            {
+            // Trying to upload video and it's supported
+            }
+        else
+            {
+            // Unknown media type, or copy not supported
+            __LOG( "StartUploadL - Unknown media type, or copy not \
+supported" );
+            User::Leave( KErrNotSupported );
+            }    
+
+            if( iDevice->ValidateTransfer( pInfo->Value() ) )
+                {
+                __LOG( "StartUploadL - Match by protocolInfo succeeded" );
+                // Continue with DLNA upload
+                // ProtocolInfo is in DLNA format
+                }
+            else
+                {
+                __LOG( "StartUploadL - Match by protocolInfo failed, upload \
+as UPnP content" );
+                // Continue with UPnP upload
+                // Check the protocolInfo
+                ProtocolInfoToUPnPL( pInfo );
+                }        
+        }
+    else
+        {
+        __LOG( "StartUploadL - UPnP Device -> UPnP upload" );
+        // Continue with UPnP upload
+        // Check the protocolInfo
+        ProtocolInfoToUPnPL( pInfo );        
+        }
+        
+    iUploader->InsertFileIntoWaitQueueL( (TAny*)transferItem.iKey,
+        tmpTransferItem->Path(), KNullDesC8 );
+    
+    SetHeadersL( pInfo->Value(), (TAny*)transferItem.iKey );
+    
+    iTransferItems.Append( transferItem );
+    
+    CUPnPResourceHelper* helper = CUPnPResourceHelper::NewL();
+    CleanupStack::Pop( tmpUpnpItem );
+    CleanupStack::PushL( helper );
+    helper->SetItem( tmpUpnpItem ); // Transfer ownership
+    if( iResources.Append( helper )!= KErrNone  )
+        {
+        CleanupStack::PopAndDestroy( helper );
+        }
+    CleanupStack::Pop( helper );
+    
+    iUploader->MoveToTransferQueueL( (TAny*)transferItem.iKey );
+    
+    CleanupStack::PopAndDestroy( tmpTransferItem );
+    
+    aMessage.Complete( KErrNone );
+    
+    __LOG( "CUPnPUploadSession::StartUploadL - end " );    
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::CancelUploadL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::CancelUploadL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPUploadSession::CancelUploadL" );          
+    
+    __ASSERTD( iTransferItems.Count() == iResources.Count(), __FILE__,
+               __LINE__ );
+    
+    TInt key = aMessage.Int1();
+
+    TInt index;
+    if( CheckIfKeyExists( key, index ) )
+        {
+        iUploader->CancelTransfer( (TAny*)key );
+        aMessage.Complete( KErrNone );
+        iTransferItems.Remove( index );
+        if( iResources[ index ]->ItemId() )
+            {
+            // Send destroyobject
+            DestroyObjectL( *iResources[ index ]->ItemId() );
+            }
+        delete iResources[index ];
+        iResources.Remove( index );   
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }        
+    
+    __LOG( "CUPnPUploadSession::CancelUploadL - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::CancelAllUploadsL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::CancelAllUploadsL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPUploadSession::CancelAllUploadsL" );          
+    
+    __ASSERTD( iTransferItems.Count() == iResources.Count(), __FILE__,
+               __LINE__ );
+        
+    TInt count = iTransferItems.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        iUploader->CancelTransfer( (TAny*)iTransferItems[i].iKey );
+
+        if( iResources[ i ]->ItemId() )
+            {
+            // Send destroyobject
+            __LOG( "CancelAllUploadsL - sending destroyobject" );
+            DestroyObjectL( *iResources[ i ]->ItemId() );
+            }
+        }
+    iResources.ResetAndDestroy();
+    iTransferItems.Reset();
+    iEventQueu.Reset();
+
+    // Scheduler loop started, stop it and ignore createobject-resp
+    __LOG( "CancelAllUploadsL - Un register" );
+    iServer.Dispatcher().UnRegister( iIPSessionId );
+    iIPSessionId = KErrNotFound;
+    iAsyncError = KErrCancel;
+
+    __LOG( "CancelAllUploadsL - Stop scheduler loop" );
+    StopWait();
+
+    aMessage.Complete( KErrNone );
+
+    __LOG( "CUPnPUploadSession::CancelAllUploadsL - end" );
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::StartTrackingUploadProgressL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::StartTrackingUploadProgressL( const RMessage2&
+    aMessage )
+    {
+    __LOG( "CUPnPUploadSession::StartTrackingUploadProgressL" );
+    
+    TInt key = aMessage.Int1();
+    if( CheckIfKeyExists( key ) )
+        {
+        iUploader->TrackProgress( (TAny*)key, ETrue );
+        iProgressTrackingEnabled = ETrue;
+        aMessage.Complete( KErrNone );
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::StopTrackingUploadProgressL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::StopTrackingUploadProgressL( const RMessage2&
+    aMessage )
+    {
+    __LOG( "CUPnPUploadSession::StopTrackingUploadProgressL" );
+    
+    TInt key = aMessage.Int1();
+    if( CheckIfKeyExists( key ) )
+        {
+        iUploader->TrackProgress( (TAny*)key, EFalse );
+        iProgressTrackingEnabled = EFalse;        
+        aMessage.Complete( KErrNone );
+        }
+    else
+        {
+        aMessage.Complete( KErrNotFound );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::GetUploadEventL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::GetUploadEventL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPUploadSession::GetUploadEventL" );
+    
+    if( iEventQueu.Count() )
+        {
+        // There are events in the queu, write the first queued event back
+        // to client
+        __LOG1( "GetUploadEventL - events in queu, count = %d",
+            iEventQueu.Count() );
+        TPckg<TUpnpFileTransferEvent> resp1( iEventQueu[0] );
+        aMessage.Write( 1, resp1  ); // Write response using slot 1
+        aMessage.Complete( KErrNone );
+        
+        iEventQueu.Remove( 0 );
+        }
+    else
+        {
+        __ASSERTD( !iEventMsg, __FILE__, __LINE__ );
+        __LOG( "GetUploadEventL - Store msg" );
+        iEventMsg = new (ELeave) RMessage2( aMessage );
+        } 
+    __LOG( "CUPnPUploadSession::GetUploadEventL - end" );
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::CancelGetUploadEventL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::CancelGetUploadEventL( const RMessage2& aMessage )
+    {
+    __LOG( "CUPnPUploadSession::CancelGetUploadEventL" );          
+    
+    if( iEventMsg )
+        {
+        iEventMsg->Complete( KErrCancel );
+        delete iEventMsg; iEventMsg = NULL;
+        }
+    aMessage.Complete( KErrNone );    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::DeviceDisappearedL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::DeviceDisappearedL(
+    CUpnpAVDeviceExtended& aDevice )
+    {
+    __LOG( "CUPnPUploadSession::DeviceDisappearedL" );
+
+    if( aDevice.Uuid().Compare( iDevice->Uuid() ) == 0 )
+        {
+        TUpnpFileTransferEvent event;
+        event.iEvent = TUpnpFileTransferEvent::EDeviceDisconnected;
+
+        Complete( event );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::SetHeadersL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::SetHeadersL( const TDesC8& aInfo, TAny* aKey )
+    {
+    CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL( aInfo );
+    CleanupStack::PushL( tmpInfo );
+
+    // Set the content-type header
+    iUploader->SetHeaderL( aKey, KContentType,
+        tmpInfo->ThirdField() );
+    
+    // Set the expect header
+    iUploader->SetHeaderL( aKey, KExpectHeader, K100Continue );
+
+    CleanupStack::PopAndDestroy( tmpInfo );            
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ReadyForTransferL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::ReadyForTransferL( TUpnpFileTransferEvent& aEvent )
+    {
+    __LOG( "CUPnPUploadSession::ReadyForTransferL" );
+    
+    if ( !iSchedulerStopped || iWait.IsStarted() )
+        {
+        __LOG1( "CUPnPUploadSession::ReadyForTransferL\
+        IsStarted = %d", (TInt)iWait.IsStarted() );
+        __LOG1( "CUPnPUploadSession::ReadyForTransferL\
+        iSchedulerStopped = %d", (TInt)iSchedulerStopped );
+        User::Leave( KErrNotReady );
+        }
+
+    __ASSERTD( iTransferItems.Count() == iResources.Count(), __FILE__, 
+               __LINE__ );
+    
+    CUpnpItem* tmpUpnpItem = iResources[ iResourceIndex ]->Item();
+    if( !tmpUpnpItem )
+        {
+        User::Leave( KErrCorrupt );
+        }
+    
+    HBufC8* xmlDoc = CUPnPXMLParser::XmlForCreateObjectLC(
+        *tmpUpnpItem );
+
+    iIPSessionId = CreateObjectL( KContainerIdAny, *xmlDoc );
+
+    // Register
+    iServer.Dispatcher().RegisterL( iIPSessionId, *this );
+    
+    CleanupStack::PopAndDestroy( xmlDoc );
+    
+    iWait.Start();
+    
+    __LOG1( "CUPnPUploadSession::ReadyForTransferL\
+        iAsyncError = %d", iAsyncError );
+
+    User::LeaveIfError( iAsyncError );
+
+    const CUpnpElement& resEl = UPnPItemUtility::FindElementByNameL(
+        *iResources[ iResourceIndex ]->Item(), KElementRes );
+
+    const CUpnpAttribute* pInfo = UPnPItemUtility::FindAttributeByName(
+        resEl, KAttributeProtocolInfo );  
+
+    CUpnpDlnaProtocolInfo* tmpInfo = CUpnpDlnaProtocolInfo::NewL(
+        pInfo->Value() );
+    CleanupStack::PushL( tmpInfo );      
+    
+    // Set DLNA specific headers    
+    if( tmpInfo->PnParameter().Length() )
+        {
+        // DLNA content, set the content-features header
+        iUploader->SetHeaderL( (TAny*)aEvent.iKey, KContentFeatures,
+            tmpInfo->FourthField() );        
+
+        // Check if background mode is available and use it if it is
+        if( tmpInfo->DlnaFlag( UpnpDlnaProtocolInfo::TM_B_FLAG ) )
+            {
+            __LOG( "ReadyForTransferL - Use background mode" );
+            
+            iUploader->SetHeaderL( (TAny*)aEvent.iKey, KTransferMode,
+                KBackgroundMode );  
+            }
+        else
+            {
+            // Background is not available for some reason.
+            // Check if media specific transfer mode is available
+            if( UPnPCommonUtils::IsImageSupported( 
+                    tmpInfo->ProtocolInfoL() ) )
+                {
+                // Uploading image, alternative for background is interactive
+                if( tmpInfo->DlnaFlag( UpnpDlnaProtocolInfo::TM_I_FLAG ) )
+                    {
+                    __LOG( "ReadyForTransferL - Use interactive mode" );
+                    iUploader->SetHeaderL( (TAny*)aEvent.iKey, KTransferMode,
+                        KInteractiveMode );
+                    }
+                else
+                    {
+                    // Target DMS does not support appropriate transfer mode
+                    __LOG( "ReadyForTransferL - No appropriate mode" );
+                    // Still, give a try and use background
+                    iUploader->SetHeaderL( (TAny*)aEvent.iKey, KTransferMode,
+                        KBackgroundMode );  
+                    }            
+                }
+            else if( UPnPCommonUtils::IsAudioSupported(
+                        tmpInfo->ProtocolInfoL() ) ||
+                    UPnPCommonUtils::IsVideoSupported(
+                        tmpInfo->ProtocolInfoL() ) )
+                {
+                // Uploading A/V, alternative for background is streaming
+                if( tmpInfo->DlnaFlag( UpnpDlnaProtocolInfo::TM_S_FLAG ) )
+                    {
+                    __LOG( "ReadyForTransferL - Use streaming mode" );
+                    iUploader->SetHeaderL( (TAny*)aEvent.iKey, KTransferMode,
+                    KStreamingMode );
+                    }
+                else
+                    {
+                    // Target DMS does not support appropriate transfer mode
+                    __LOG( "ReadyForTransferL - No appropriate mode" );
+                    // Still, give a try and use background
+                    iUploader->SetHeaderL( (TAny*)aEvent.iKey, KTransferMode,
+                        KBackgroundMode );  
+                    }                 
+                }
+            else
+                {
+                __LOG( "ReadyForTransferL - Unknown media type" );
+                }    
+                        
+            }            
+
+        }                
+    
+    CleanupStack::PopAndDestroy( tmpInfo ); 
+    
+    iUploader->SetPropertyL( (TAny*)aEvent.iKey,
+        CHttpTransferBase::ETargetURI,
+        *iResources[ iResourceIndex ]->Resource() );
+            
+    iUploader->StartTransferL( (TAny*)aEvent.iKey );
+        
+    __LOG( "CUPnPUploadSession::ReadyForTransferL - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ParseCreateObjectResponseL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::HandleObjectResponseL( const TDesC8& aObjectID,
+    const TDesC8& aResult )
+    {
+    __LOG( "CUPnPUploadSession::HandleObjectResponseL" );          
+    
+    HBufC8* importUri = ParseCreateObjectResponseL( aResult );
+    CleanupStack::PushL( importUri );
+
+    HBufC8* tmpUri = UpnpString::EncodeXmlStringL( importUri );
+    CleanupStack::PopAndDestroy( importUri );
+    CleanupStack::PushL( tmpUri );
+        
+    HBufC* tmpUri16 = UpnpString::ToUnicodeL( *tmpUri );
+    CleanupStack::PopAndDestroy( tmpUri );
+          
+    iResources[ iResourceIndex ]->SetResource( tmpUri16 );
+        
+    HBufC8* tmpID = aObjectID.AllocL();
+    iResources[ iResourceIndex ]->SetItemId( tmpID );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ParseCreateObjectResponseL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+HBufC8* CUPnPUploadSession::ParseCreateObjectResponseL(
+    const TDesC8& aResponse )
+    {
+    __LOG( "CUPnPUploadSession::ParseCreateObjectResponseL" );          
+    
+    HBufC8* importURI = NULL;
+    
+    CUPnPXMLParser* parser = CUPnPXMLParser::NewL();
+    CleanupStack::PushL( parser );
+    
+    RPointerArray<CUpnpObject> array;
+    CleanupResetAndDestroyPushL( array );
+    
+    parser->ParseResultDataL( array, aResponse );
+    
+    TInt count = array.Count();
+    
+    // Lets find the first item with an import URI and use that
+    for( TInt i = 0; i < count; i++ )
+        {
+        importURI = ImportURIFromItemL( *array[ i ] );
+        if( importURI )
+            {
+             // Transfer ownership, casting is safe
+             // (array[ 0 ]->ObjectType() == EUPnPItem)
+            CUpnpItem* item = static_cast<CUpnpItem*>( array[ i ] );
+            iResources[ iResourceIndex ]->SetItem( item );
+            array.Remove( i );
+            i = count;
+            }
+        }
+    if( !importURI ) // no suitable items, leave
+        {
+        User::Leave( KErrGeneral );
+        }
+            
+    CleanupStack::PopAndDestroy( &array );
+    CleanupStack::PopAndDestroy( parser );  
+              
+    if( !UpnpCdsResElementUtility::IsUriAbsolute( *importURI ) )
+        {
+        // Import uri is not absolute, upload not supported. leave.
+        delete importURI; importURI = NULL;
+        User::Leave( KErrGeneral );
+        }
+      
+    return importURI;
+    }       
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ImportURIFromItemL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+HBufC8* CUPnPUploadSession::ImportURIFromItemL( const CUpnpObject& aObject )
+    {
+    HBufC8* importURI = NULL;
+    if( aObject.ObjectType() == EUPnPItem )
+        {
+        // Get the res-elements
+        RUPnPElementsArray elArray;
+        CleanupClosePushL( elArray );
+        UPnPItemUtility::GetResElements( aObject, elArray );
+        
+        // Find the import uri 
+        TInt count = elArray.Count();           
+        for( TInt i = 0; i < count; i++ )
+            {
+            const CUpnpAttribute* attribute = NULL;
+            attribute = &UPnPItemUtility::FindAttributeByNameL(
+                *elArray[ i ], KImportUri );
+            if( attribute )
+                {
+                // import uri found
+                i = count;
+                importURI = attribute->Value().AllocL();
+                }
+            }            
+        CleanupStack::PopAndDestroy( &elArray );        
+        }
+    return importURI;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPUploadSession::ProtocolInfoToUPnPL
+// See upnpbrowsingsession.h
+// --------------------------------------------------------------------------
+void CUPnPUploadSession::ProtocolInfoToUPnPL( const CUpnpAttribute* aInfo )
+    {
+    __LOG( "CUPnPUploadSession::ProtocolInfoToUPnPL" );
+    
+    CUpnpDlnaProtocolInfo* destInfo =
+        CUpnpDlnaProtocolInfo::NewL( aInfo->Value() );
+    CleanupStack::PushL( destInfo );
+    
+    if( destInfo->PnParameter().Length() )
+        {
+        __LOG( "ProtocolInfoToUPnPL - Convert to UPnP" );
+        
+        CUpnpProtocolInfo* targetInfo = CUpnpProtocolInfo::NewL();
+        CleanupStack::PushL( targetInfo );
+        
+        targetInfo->SetFirstFieldL( destInfo->FirstField() );
+        targetInfo->SetSecondFieldL( KAsterisk );
+        targetInfo->SetThirdFieldL( destInfo->ThirdField() );
+        targetInfo->SetFourthFieldL( KAsterisk );
+        
+        // A bit dirty const cast.. but makes implementation much easier
+        CUpnpAttribute* bute = const_cast<CUpnpAttribute*>( aInfo );
+        bute->SetValueL( targetInfo->ProtocolInfoL() );
+        
+        CleanupStack::PopAndDestroy( targetInfo );
+        }
+    else
+        {
+        __LOG( "ProtocolInfoToUPnPL - UPnP content -> do nothing" );
+        // Not DLNA content, do nothing
+        }    
+        
+    CleanupStack::PopAndDestroy( destInfo );
+    }
+
+//---------------------------------------------------------------------------
+// CUPnPUploadSession::StopWait()
+// See upnpbrowsingsession.h
+//---------------------------------------------------------------------------
+//
+void CUPnPUploadSession::StopWait()
+    {
+    __LOG( "ProtocolInfoToUPnPL::StopWait" );
+    if ( iWait.IsStarted() )
+        {
+        if ( iWait.CanStopNow() )
+            {
+            __LOG( "ProtocolInfoToUPnPL::StopWait - stop" );
+            iWait.AsyncStop();
+            iSchedulerStopped = ETrue;
+            }
+        else
+            {
+            __LOG( "CUPnPUploadSession::StopWait\
+- not able to stop now, use callback" );
+            iSchedulerStopped = EFalse;
+            iWait.AsyncStop( TCallBack(
+                                SchedulerStoppedCallBack,
+                                this ) );
+            }
+        }
+    }
+
+//---------------------------------------------------------------------------
+// CUPnPUploadSession::SchedulerStoppedCallBack()
+// See upnpbrowsingsession.h
+//---------------------------------------------------------------------------
+//
+TInt CUPnPUploadSession::SchedulerStoppedCallBack( TAny* aPtr )
+    {
+    CUPnPUploadSession* self = 
+        static_cast<CUPnPUploadSession*>( aPtr );
+    self->DoSchedulerStoppedCallBack();
+    return 0;
+    }
+
+//---------------------------------------------------------------------------
+// CUPnPUploadSession::DoSchedulerStoppedCallBack()
+// See upnpbrowsingsession.h
+//---------------------------------------------------------------------------
+//
+void CUPnPUploadSession::DoSchedulerStoppedCallBack()
+    {
+    __LOG( "ProtocolInfoToUPnPL::DoSchedulerStoppedCallBack" );
+    iSchedulerStopped = ETrue;
+    }
+
+//---------------------------------------------------------------------------
+// CUPnPUploadSession::CreateObjectL()
+//---------------------------------------------------------------------------
+//
+int CUPnPUploadSession::CreateObjectL( const TDesC8& aContainerId,
+    const TDesC8& aElements )
+    {
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            iCpDevice, KContentDirectory, KCreateObject );
+    
+    action->SetArgumentL( KContainerID, aContainerId );
+    action->SetArgumentL( KElements, aElements );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0)
+        {
+        User::Leave( action->SessionId() );    
+        }
+    return action->SessionId();
+    }
+
+//---------------------------------------------------------------------------
+// CUPnPUploadSession::DestroyObjectL()
+//---------------------------------------------------------------------------
+//
+int CUPnPUploadSession::DestroyObjectL( const TDesC8& aObjectId )
+    {
+    CUpnpAction* action = iServer.ControlPoint().CreateActionLC( 
+            iCpDevice, KContentDirectory, KDestroyObject );
+    
+    action->SetArgumentL( KObjectID, aObjectId );
+
+    iServer.ControlPoint().SendL( action );
+    CleanupStack::Pop( action );
+    if (action->SessionId() < 0)
+        {
+        User::Leave( action->SessionId() );    
+        }
+    return action->SessionId();
+    }
+
+// End of file
--- a/upnpavcontroller/upnpxmlparser/bwins/upnpxmlparseru.def	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/bwins/upnpxmlparseru.def	Mon Nov 01 12:37:49 2010 +0200
@@ -1,24 +1,30 @@
-EXPORTS
-	??1CUpnpObjectLite@@UAE@XZ @ 1 NONAME ; CUpnpObjectLite::~CUpnpObjectLite(void)
-	?ContainerToXmlLC@CUPnPXMLParser@@SAPAVHBufC8@@ABVCUpnpContainer@@@Z @ 2 NONAME ; class HBufC8 * CUPnPXMLParser::ContainerToXmlLC(class CUpnpContainer const &)
-	?IsTypeOf@CUpnpObjectLite@@QBEHW4TObjectType@1@@Z @ 3 NONAME ; int CUpnpObjectLite::IsTypeOf(enum CUpnpObjectLite::TObjectType) const
-	?ItemAsXmlLC@CUPnPXMLParser@@SAPAVHBufC8@@ABVCUpnpItem@@@Z @ 4 NONAME ; class HBufC8 * CUPnPXMLParser::ItemAsXmlLC(class CUpnpItem const &)
-	?NewL@CUPnPXMLEventParser@@SAPAV1@XZ @ 5 NONAME ; class CUPnPXMLEventParser * CUPnPXMLEventParser::NewL(void)
-	?NewL@CUPnPXMLParser@@SAPAV1@XZ @ 6 NONAME ; class CUPnPXMLParser * CUPnPXMLParser::NewL(void)
-	?NewL@CUPnPXMLParserLite@@SAPAV1@XZ @ 7 NONAME ; class CUPnPXMLParserLite * CUPnPXMLParserLite::NewL(void)
-	?NewL@CUpnpObjectLite@@SAPAV1@XZ @ 8 NONAME ; class CUpnpObjectLite * CUpnpObjectLite::NewL(void)
-	?NewLC@CUPnPXMLParser@@SAPAV1@XZ @ 9 NONAME ; class CUPnPXMLParser * CUPnPXMLParser::NewLC(void)
-	?NewLC@CUPnPXMLParserLite@@SAPAV1@XZ @ 10 NONAME ; class CUPnPXMLParserLite * CUPnPXMLParserLite::NewLC(void)
-	?ObjectId@CUpnpObjectLite@@QBEABVTDesC8@@XZ @ 11 NONAME ; class TDesC8 const & CUpnpObjectLite::ObjectId(void) const
-	?ParseResultDataL@CUPnPXMLEventParser@@QAEXABVTDesC8@@AAH11@Z @ 12 NONAME ; void CUPnPXMLEventParser::ParseResultDataL(class TDesC8 const &, int &, int &, int &)
-	?ParseResultDataL@CUPnPXMLParser@@QAEXAAV?$RPointerArray@VCUpnpObject@@@@ABVTDesC8@@@Z @ 13 NONAME ; void CUPnPXMLParser::ParseResultDataL(class RPointerArray<class CUpnpObject> &, class TDesC8 const &)
-	?ParseResultDataL@CUPnPXMLParserLite@@QAEXAAV?$RPointerArray@VCUpnpObjectLite@@@@ABVTDesC8@@ABVTDesC16@@@Z @ 14 NONAME ; void CUPnPXMLParserLite::ParseResultDataL(class RPointerArray<class CUpnpObjectLite> &, class TDesC8 const &, class TDesC16 const &)
-	?RemoveXmlControlCharactersL@UpnpXmlStringUtility@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 15 NONAME ; class HBufC8 * UpnpXmlStringUtility::RemoveXmlControlCharactersL(class TDesC8 const &)
-	?SetObjectClass@CUpnpObjectLite@@QAEXABVTDesC8@@@Z @ 16 NONAME ; void CUpnpObjectLite::SetObjectClass(class TDesC8 const &)
-	?SetObjectIdL@CUpnpObjectLite@@QAEXABVTDesC8@@@Z @ 17 NONAME ; void CUpnpObjectLite::SetObjectIdL(class TDesC8 const &)
-	?SetObjectIdL@CUpnpObjectLite@@QAEXPAVHBufC8@@@Z @ 18 NONAME ; void CUpnpObjectLite::SetObjectIdL(class HBufC8 *)
-	?SetTitleL@CUpnpObjectLite@@QAEXABVTDesC16@@@Z @ 19 NONAME ; void CUpnpObjectLite::SetTitleL(class TDesC16 const &)
-	?SetTitleL@CUpnpObjectLite@@QAEXPAVHBufC16@@@Z @ 20 NONAME ; void CUpnpObjectLite::SetTitleL(class HBufC16 *)
-	?Title@CUpnpObjectLite@@QBEABVTDesC16@@XZ @ 21 NONAME ; class TDesC16 const & CUpnpObjectLite::Title(void) const
-	?XmlForCreateObjectLC@CUPnPXMLParser@@SAPAVHBufC8@@ABVCUpnpItem@@@Z @ 22 NONAME ; class HBufC8 * CUPnPXMLParser::XmlForCreateObjectLC(class CUpnpItem const &)
-
+EXPORTS
+	?RemoveXmlControlCharactersL@UpnpXmlStringUtility@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 1 NONAME ; class HBufC8 * UpnpXmlStringUtility::RemoveXmlControlCharactersL(class TDesC8 const &)
+	?InstanceID@CUPnPAVTEvent@@QBEHXZ @ 2 NONAME ; int CUPnPAVTEvent::InstanceID(void) const
+	??1CUpnpObjectLite@@UAE@XZ @ 3 NONAME ; CUpnpObjectLite::~CUpnpObjectLite(void)
+	?SetTitleL@CUpnpObjectLite@@QAEXABVTDesC16@@@Z @ 4 NONAME ; void CUpnpObjectLite::SetTitleL(class TDesC16 const &)
+	?NewLC@CUPnPXMLParserLite@@SAPAV1@XZ @ 5 NONAME ; class CUPnPXMLParserLite * CUPnPXMLParserLite::NewLC(void)
+	?TransportURI@CUPnPAVTEvent@@QBEABVTDesC8@@XZ @ 6 NONAME ; class TDesC8 const & CUPnPAVTEvent::TransportURI(void) const
+	?IsTypeOf@CUpnpObjectLite@@QBEHW4TObjectType@1@@Z @ 7 NONAME ; int CUpnpObjectLite::IsTypeOf(enum CUpnpObjectLite::TObjectType) const
+	?Volume@CUPnPAVTEvent@@QBEHXZ @ 8 NONAME ; int CUPnPAVTEvent::Volume(void) const
+	?ContainerToXmlLC@CUPnPXMLParser@@SAPAVHBufC8@@ABVCUpnpContainer@@@Z @ 9 NONAME ; class HBufC8 * CUPnPXMLParser::ContainerToXmlLC(class CUpnpContainer const &)
+	?XmlForCreateObjectLC@CUPnPXMLParser@@SAPAVHBufC8@@ABVCUpnpItem@@@Z @ 10 NONAME ; class HBufC8 * CUPnPXMLParser::XmlForCreateObjectLC(class CUpnpItem const &)
+	?SetObjectIdL@CUpnpObjectLite@@QAEXPAVHBufC8@@@Z @ 11 NONAME ; void CUpnpObjectLite::SetObjectIdL(class HBufC8 *)
+	?ParseResultDataL@CUPnPXMLParserLite@@QAEXAAV?$RPointerArray@VCUpnpObjectLite@@@@ABVTDesC8@@ABVTDesC16@@@Z @ 12 NONAME ; void CUPnPXMLParserLite::ParseResultDataL(class RPointerArray<class CUpnpObjectLite> &, class TDesC8 const &, class TDesC16 const &)
+	?Mute@CUPnPAVTEvent@@QBEHXZ @ 13 NONAME ; int CUPnPAVTEvent::Mute(void) const
+	?ItemAsXmlLC@CUPnPXMLParser@@SAPAVHBufC8@@ABVCUpnpItem@@@Z @ 14 NONAME ; class HBufC8 * CUPnPXMLParser::ItemAsXmlLC(class CUpnpItem const &)
+	?NewL@CUPnPXMLParser@@SAPAV1@XZ @ 15 NONAME ; class CUPnPXMLParser * CUPnPXMLParser::NewL(void)
+	?NewL@CUPnPXMLParserLite@@SAPAV1@XZ @ 16 NONAME ; class CUPnPXMLParserLite * CUPnPXMLParserLite::NewL(void)
+	?SetObjectIdL@CUpnpObjectLite@@QAEXABVTDesC8@@@Z @ 17 NONAME ; void CUpnpObjectLite::SetObjectIdL(class TDesC8 const &)
+	?SetObjectClass@CUpnpObjectLite@@QAEXABVTDesC8@@@Z @ 18 NONAME ; void CUpnpObjectLite::SetObjectClass(class TDesC8 const &)
+	?NewLC@CUPnPXMLParser@@SAPAV1@XZ @ 19 NONAME ; class CUPnPXMLParser * CUPnPXMLParser::NewLC(void)
+	?ParseAvtEventDataL@CUPnPXMLEventParser@@QAEPAVCUPnPAVTEvent@@ABVTDesC8@@H@Z @ 20 NONAME ; class CUPnPAVTEvent * CUPnPXMLEventParser::ParseAvtEventDataL(class TDesC8 const &, int)
+	?NewL@CUPnPXMLEventParser@@SAPAV1@XZ @ 21 NONAME ; class CUPnPXMLEventParser * CUPnPXMLEventParser::NewL(void)
+	?TransportState@CUPnPAVTEvent@@QBE?AW4TTransportState@1@XZ @ 22 NONAME ; enum CUPnPAVTEvent::TTransportState CUPnPAVTEvent::TransportState(void) const
+	?SetTitleL@CUpnpObjectLite@@QAEXPAVHBufC16@@@Z @ 23 NONAME ; void CUpnpObjectLite::SetTitleL(class HBufC16 *)
+	?ParseRcEventDataL@CUPnPXMLEventParser@@QAEPAVCUPnPAVTEvent@@ABVTDesC8@@H@Z @ 24 NONAME ; class CUPnPAVTEvent * CUPnPXMLEventParser::ParseRcEventDataL(class TDesC8 const &, int)
+	?ObjectId@CUpnpObjectLite@@QBEABVTDesC8@@XZ @ 25 NONAME ; class TDesC8 const & CUpnpObjectLite::ObjectId(void) const
+	?Title@CUpnpObjectLite@@QBEABVTDesC16@@XZ @ 26 NONAME ; class TDesC16 const & CUpnpObjectLite::Title(void) const
+	?NewL@CUpnpObjectLite@@SAPAV1@XZ @ 27 NONAME ; class CUpnpObjectLite * CUpnpObjectLite::NewL(void)
+	?ParseResultDataL@CUPnPXMLParser@@QAEXAAV?$RPointerArray@VCUpnpObject@@@@ABVTDesC8@@@Z @ 28 NONAME ; void CUPnPXMLParser::ParseResultDataL(class RPointerArray<class CUpnpObject> &, class TDesC8 const &)
+
--- a/upnpavcontroller/upnpxmlparser/eabi/upnpxmlparseru.def	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/eabi/upnpxmlparseru.def	Mon Nov 01 12:37:49 2010 +0200
@@ -1,32 +1,40 @@
-EXPORTS
-	_ZN14CUPnPXMLParser11ItemAsXmlLCERK9CUpnpItem @ 1 NONAME
-	_ZN14CUPnPXMLParser16ContainerToXmlLCERK14CUpnpContainer @ 2 NONAME
-	_ZN14CUPnPXMLParser16ParseResultDataLER13RPointerArrayI11CUpnpObjectERK6TDesC8 @ 3 NONAME
-	_ZN14CUPnPXMLParser20XmlForCreateObjectLCERK9CUpnpItem @ 4 NONAME
-	_ZN14CUPnPXMLParser4NewLEv @ 5 NONAME
-	_ZN14CUPnPXMLParser5NewLCEv @ 6 NONAME
-	_ZN15CUpnpObjectLite12SetObjectIdLEP6HBufC8 @ 7 NONAME
-	_ZN15CUpnpObjectLite12SetObjectIdLERK6TDesC8 @ 8 NONAME
-	_ZN15CUpnpObjectLite14SetObjectClassERK6TDesC8 @ 9 NONAME
-	_ZN15CUpnpObjectLite4NewLEv @ 10 NONAME
-	_ZN15CUpnpObjectLite9SetTitleLEP7HBufC16 @ 11 NONAME
-	_ZN15CUpnpObjectLite9SetTitleLERK7TDesC16 @ 12 NONAME
-	_ZN15CUpnpObjectLiteD0Ev @ 13 NONAME
-	_ZN15CUpnpObjectLiteD1Ev @ 14 NONAME
-	_ZN15CUpnpObjectLiteD2Ev @ 15 NONAME
-	_ZN18CUPnPXMLParserLite16ParseResultDataLER13RPointerArrayI15CUpnpObjectLiteERK6TDesC8RK7TDesC16 @ 16 NONAME
-	_ZN18CUPnPXMLParserLite4NewLEv @ 17 NONAME
-	_ZN18CUPnPXMLParserLite5NewLCEv @ 18 NONAME
-	_ZN19CUPnPXMLEventParser16ParseResultDataLERK6TDesC8RiS3_S3_ @ 19 NONAME
-	_ZN19CUPnPXMLEventParser4NewLEv @ 20 NONAME
-	_ZN20UpnpXmlStringUtility27RemoveXmlControlCharactersLERK6TDesC8 @ 21 NONAME
-	_ZNK15CUpnpObjectLite5TitleEv @ 22 NONAME
-	_ZNK15CUpnpObjectLite8IsTypeOfENS_11TObjectTypeE @ 23 NONAME
-	_ZNK15CUpnpObjectLite8ObjectIdEv @ 24 NONAME
-	_ZTI14CUPnPXMLParser @ 25 NONAME ; #<TI>#
-	_ZTI18CUPnPXMLParserLite @ 26 NONAME ; #<TI>#
-	_ZTI19CUPnPXMLEventParser @ 27 NONAME ; #<TI>#
-	_ZTV14CUPnPXMLParser @ 28 NONAME ; #<VT>#
-	_ZTV18CUPnPXMLParserLite @ 29 NONAME ; #<VT>#
-	_ZTV19CUPnPXMLEventParser @ 30 NONAME ; #<VT>#
-
+EXPORTS
+	_ZN14CUPnPXMLParser11ItemAsXmlLCERK9CUpnpItem @ 1 NONAME
+	_ZN14CUPnPXMLParser16ContainerToXmlLCERK14CUpnpContainer @ 2 NONAME
+	_ZN14CUPnPXMLParser16ParseResultDataLER13RPointerArrayI11CUpnpObjectERK6TDesC8 @ 3 NONAME
+	_ZN14CUPnPXMLParser20XmlForCreateObjectLCERK9CUpnpItem @ 4 NONAME
+	_ZN14CUPnPXMLParser4NewLEv @ 5 NONAME
+	_ZN14CUPnPXMLParser5NewLCEv @ 6 NONAME
+	_ZN15CUpnpObjectLite12SetObjectIdLEP6HBufC8 @ 7 NONAME
+	_ZN15CUpnpObjectLite12SetObjectIdLERK6TDesC8 @ 8 NONAME
+	_ZN15CUpnpObjectLite14SetObjectClassERK6TDesC8 @ 9 NONAME
+	_ZN15CUpnpObjectLite4NewLEv @ 10 NONAME
+	_ZN15CUpnpObjectLite9SetTitleLEP7HBufC16 @ 11 NONAME
+	_ZN15CUpnpObjectLite9SetTitleLERK7TDesC16 @ 12 NONAME
+	_ZN15CUpnpObjectLiteD0Ev @ 13 NONAME
+	_ZN15CUpnpObjectLiteD1Ev @ 14 NONAME
+	_ZN15CUpnpObjectLiteD2Ev @ 15 NONAME
+	_ZN18CUPnPXMLParserLite16ParseResultDataLER13RPointerArrayI15CUpnpObjectLiteERK6TDesC8RK7TDesC16 @ 16 NONAME
+	_ZN18CUPnPXMLParserLite4NewLEv @ 17 NONAME
+	_ZN18CUPnPXMLParserLite5NewLCEv @ 18 NONAME
+	_ZN19CUPnPXMLEventParser17ParseRcEventDataLERK6TDesC8i @ 19 NONAME
+	_ZN19CUPnPXMLEventParser18ParseAvtEventDataLERK6TDesC8i @ 20 NONAME
+	_ZN19CUPnPXMLEventParser4NewLEv @ 21 NONAME
+	_ZN20UpnpXmlStringUtility27RemoveXmlControlCharactersLERK6TDesC8 @ 22 NONAME
+	_ZNK13CUPnPAVTEvent10InstanceIDEv @ 23 NONAME
+	_ZNK13CUPnPAVTEvent12TransportURIEv @ 24 NONAME
+	_ZNK13CUPnPAVTEvent14TransportStateEv @ 25 NONAME
+	_ZNK13CUPnPAVTEvent4MuteEv @ 26 NONAME
+	_ZNK13CUPnPAVTEvent6VolumeEv @ 27 NONAME
+	_ZNK15CUpnpObjectLite5TitleEv @ 28 NONAME
+	_ZNK15CUpnpObjectLite8IsTypeOfENS_11TObjectTypeE @ 29 NONAME
+	_ZNK15CUpnpObjectLite8ObjectIdEv @ 30 NONAME
+	_ZTI13CUPnPAVTEvent @ 31 NONAME ; #<TI>#
+	_ZTI14CUPnPXMLParser @ 32 NONAME ; #<TI>#
+	_ZTI18CUPnPXMLParserLite @ 33 NONAME ; #<TI>#
+	_ZTI19CUPnPXMLEventParser @ 34 NONAME ; #<TI>#
+	_ZTV13CUPnPAVTEvent @ 35 NONAME ; #<VT>#
+	_ZTV14CUPnPXMLParser @ 36 NONAME ; #<VT>#
+	_ZTV18CUPnPXMLParserLite @ 37 NONAME ; #<VT>#
+	_ZTV19CUPnPXMLEventParser @ 38 NONAME ; #<VT>#
+
--- a/upnpavcontroller/upnpxmlparser/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,38 +1,35 @@
-/*
-* Copyright (c) 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:      Upnp XML parser build info file
-*
-*/
-
-
-
-
-
-
-#include "../../../group/upnpplatformvar.hrh"
-
-PRJ_PLATFORMS
-
-PRJ_EXPORTS
-// ADO internal interfaces
-../inc/upnpxmlparser.h                  |../../../inc/upnpxmlparser.h
-../inc/upnpxmlparserlite.h              |../../../inc/upnpxmlparserlite.h
-../inc/upnpobjectlite.h                 |../../../inc/upnpobjectlite.h
-// subsystem internal interfaces
-../inc/upnpxmleventparser.h             |../../inc/upnpxmleventparser.h
-
-PRJ_MMPFILES
-upnpxmlparser.mmp
-
-//  End of File  
+/*
+* Copyright (c) 2006, 2009 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:      Upnp XML parser build info file
+*
+*/
+
+#include "../../../group/upnpplatformvar.hrh"
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+// ADO internal interfaces
+../inc/upnpxmlparser.h                  |../../../inc/upnpxmlparser.h
+../inc/upnpxmlparserlite.h              |../../../inc/upnpxmlparserlite.h
+../inc/upnpobjectlite.h                 |../../../inc/upnpobjectlite.h
+
+// subsystem internal interfaces
+../inc/upnpxmleventparser.h             |../../inc/upnpxmleventparser.h
+../inc/upnpavtevent.h                   |../../inc/upnpavtevent.h
+
+PRJ_MMPFILES
+upnpxmlparser.mmp
+
+//  End of File  
--- a/upnpavcontroller/upnpxmlparser/group/upnpxmlparser.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/group/upnpxmlparser.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,71 +1,67 @@
-/*
-* Copyright (c) 2006-2007 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:      Project specification for XmlParser
-*
-*/
-
-
-
-
-
-
-#include "../../../group/upnpplatformvar.hrh"
-
-// Build target
-TARGET          upnpxmlparser.dll
-TARGETTYPE      DLL
-UID             0x1000008D 0x200075D7
-
-// Platform security
-CAPABILITY      CAP_GENERAL_DLL
-VENDORID        VID_DEFAULT
-
-VERSION         10.1
-paged
-
-// Include paths
-USERINCLUDE     ../inc
-USERINCLUDE     ../../inc
-
-MW_LAYER_SYSTEMINCLUDE
-USERINCLUDE   ../../../inc
-
-// Sources
-SOURCEPATH      ../src
-SOURCE          upnpxmlparser.cpp
-SOURCE          upnpxmlparserlite.cpp
-SOURCE          upnpitemtoxml.cpp
-SOURCE          upnpxmleventparser.cpp
-SOURCE          upnpobjectlite.cpp
-SOURCE          upnpxmlstringutility.cpp
-
-// Core platform
-LIBRARY         euser.lib
-LIBRARY         bafl.lib
-LIBRARY         estor.lib 
-
-// XML
-LIBRARY         xmlframework.lib
-
-// S60 Upnp Stack
-LIBRARY         upnpavobjects.lib
-LIBRARY         upnpipserversutils.lib
-
-// upnp framework
-LIBRARY         upnputilities.lib
-LIBRARY         upnpavcontrollerhelper.lib
-
-DEBUGLIBRARY    flogger.lib
-
-// End of file
+/*
+* Copyright (c) 2006-2007, 2009 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:      Project specification for XmlParser
+*
+*/
+
+#include "../../../group/upnpplatformvar.hrh"
+
+// Build target
+TARGET          upnpxmlparser.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x200075D7
+
+// Platform security
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+VERSION         10.1
+paged
+
+// Include paths
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+USERINCLUDE   ../../../inc
+
+// Sources
+SOURCEPATH      ../src
+SOURCE          upnpxmlparser.cpp
+SOURCE          upnpxmlparserlite.cpp
+SOURCE          upnpitemtoxml.cpp
+SOURCE          upnpxmleventparser.cpp
+SOURCE          upnpobjectlite.cpp
+SOURCE          upnpxmlstringutility.cpp
+SOURCE          upnpavtevent.cpp
+
+// Core platform
+LIBRARY         euser.lib
+LIBRARY         bafl.lib
+LIBRARY         estor.lib 
+
+// XML
+LIBRARY         xmlframework.lib
+
+// S60 Upnp Stack
+LIBRARY         upnpipserversutils.lib
+
+// dlnasrv
+LIBRARY         upnpavobjects.lib
+LIBRARY         upnputilities.lib
+LIBRARY         upnpavcontrollerhelper.lib
+
+DEBUGLIBRARY    flogger.lib
+
+// End of file
--- a/upnpavcontroller/upnpxmlparser/inc/upnpitemtoxml.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/inc/upnpitemtoxml.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,168 +1,170 @@
-/*
-* Copyright (c) 2006-2007 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:      Generates XML from an UPNP Item
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPITEMTOXML_H
-#define C_UPNPITEMTOXML_H
-
-// INCLUDES
-#include <e32base.h>
-#include <s32mem.h>
-
-// CONSTANTS
-// None
-
-// MACROS
-// None
-
-// FORWARD DECLARATIONS
-class CUpnpItem;
-
-/**
- * Converts an UPnP item to xml document
- *
- * @since Series 60 3.2
- * @lib upnpxmlparser.lib
- */
-NONSHARABLE_CLASS( CUpnpItemToXML ) : public CBase
-    {
-public:  // Constructors and destructor
-
-    /**
-     * Two-phased constructor.
-     *
-     * @param aItem
-     * @return new instance
-     */
-    static CUpnpItemToXML* NewL( const CUpnpItem& aItem );
-    
-    /**
-     * Two-phased constructor.
-     *
-     * @param aItem
-     * @return new instance
-     */
-    static CUpnpItemToXML* NewLC( const CUpnpItem& aItem );
-
-    /**
-     * Destructor.
-     */
-    virtual ~CUpnpItemToXML();
-
-
-public: // Functions from CUPnPObject
-
-    /**
-     * Returns object's XML description
-     * Leaves in case of errors.
-     * @since Series 60 3.1
-     * @param none
-     * @return HBufC8 pointer to buffer containing XML data
-     */
-    HBufC8* AsXmlL( const TBool aIncludeChilds = ETrue );
-
-    /**
-     * Returns object's XML description. This version of the method
-     * is used to create the XML with empty <res> tag
-     * Leaves in case of errors.
-     * @since Series 60 3.1
-     * @param None
-     * @return HBufC8 pointer to buffer containing XML data
-     */
-    HBufC8* AsXmlEmptyL();
-
-
-    /**
-     * CUpnpItemToXML::AsResultArgumentL
-     * Returns object's XML description that is embedded inside a
-     * DIDL-LITE tag. The <res> tag of xml description is empty.
-     * The returned value is xml encoded can therefore be used
-     * for example when creating a CreateObject action.
-     * @since Series 60 3.1
-     * @param none
-     * @return TDesC8& the date string
-     */
-    HBufC8* AsResultArgumentL();
-
-    /**
-     * Creates valid XML headers to source data. Do not decode the XML.
-     *
-     * @since Series 60 3.1
-     * @param TDesC8 reference to source data
-     * @return HBufC8 buffer to valid XML
-     */
-    HBufC8* CreateUnDecodedXmlL( const TDesC8& aData );
-
-private:
-
-    /**
-     * Return value from an element
-     *
-     * @param aElemenName (const TDesC8&) name of the element
-     * @return (const TDesC8&) value of the element
-     */
-    const TDesC8& GetValueFromElement(
-                                const TDesC8& aElementName );
-
-    /**
-     * Validates format of dc:date
-     *
-     * @param aDate dc:date string
-     * @return ETrue if format of dc:date is valid
-     */
-    TBool ValidateDateL( const TDesC8& aDate );
-    
-    /**
-     * Validates format of res@duration
-     *
-     * @param aDuration res@duration string
-     * @return ETrue if format of res@duration is valid
-     */
-    TBool ValidateDurationL( const TDesC8& aDuration );
-    
-    /**
-     * Parse to a delimeter
-     *
-     * @param aLexer lexer
-     * @param aDelimeter delimeter character
-     */
-    void ParseToDelimeter( TLex8& aLex, TChar aDelimeter );    
-
-private:
-
-    /**
-     * C++ default constructor.
-     */
-    CUpnpItemToXML( const CUpnpItem& aItem );
-
-    /**
-     * By default Symbian 2nd phase constructor is private.
-     */
-    void ConstructL();
-
-private:    // Data
-
-    CUpnpItem*  iItem; // Not own
-    };
-
-#endif      // C_UPNPITEMTOXML_H
-            
-// End of File
+/*
+* Copyright (c) 2006-2007 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:      Generates XML from an UPNP Item
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPITEMTOXML_H
+#define C_UPNPITEMTOXML_H
+
+// INCLUDES
+#include <e32base.h>
+#include <s32mem.h>
+
+// CONSTANTS
+// None
+
+// MACROS
+// None
+
+// FORWARD DECLARATIONS
+class CUpnpItem;
+
+/**
+ * Converts an UPnP item to xml document
+ *
+ * @since Series 60 3.2
+ * @lib upnpxmlparser.lib
+ */
+NONSHARABLE_CLASS( CUpnpItemToXML ) : public CBase
+    {
+public:  // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     *
+     * @param aItem
+     * @return new instance
+     */
+    static CUpnpItemToXML* NewL( const CUpnpItem& aItem );
+    
+    /**
+     * Two-phased constructor.
+     *
+     * @param aItem
+     * @return new instance
+     */
+    static CUpnpItemToXML* NewLC( const CUpnpItem& aItem );
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUpnpItemToXML();
+
+
+public: // Functions from CUPnPObject
+
+    /**
+     * Returns object's XML description
+     * Leaves in case of errors.
+     * @since Series 60 3.1
+     * @param none
+     * @return HBufC8 pointer to buffer containing XML data
+     */
+    HBufC8* AsXmlL( const TBool aIncludeChilds = ETrue );
+
+    /**
+     * Returns object's XML description. This version of the method
+     * is used to create the XML with empty <res> tag
+     * Leaves in case of errors.
+     * @since Series 60 3.1
+     * @param None
+     * @return HBufC8 pointer to buffer containing XML data
+     */
+    HBufC8* AsXmlEmptyL();
+
+
+    /**
+     * CUpnpItemToXML::AsResultArgumentL
+     * Returns object's XML description that is embedded inside a
+     * DIDL-LITE tag. The <res> tag of xml description is empty.
+     * The returned value is xml encoded can therefore be used
+     * for example when creating a CreateObject action.
+     * @since Series 60 3.1
+     * @param none
+     * @return TDesC8& the date string
+     */
+    HBufC8* AsResultArgumentL();
+
+    /**
+     * Creates valid XML headers to source data. Do not decode the XML.
+     *
+     * @since Series 60 3.1
+     * @param TDesC8 reference to source data
+     * @return HBufC8 buffer to valid XML
+     */
+    HBufC8* CreateUnDecodedXmlL( const TDesC8& aData );
+
+private:
+
+    /**
+     * Return value from an element
+     *
+     * @param aElemenName (const TDesC8&) name of the element
+     * @return (const TDesC8&) value of the element
+     */
+    const TDesC8& GetValueFromElement(
+                                const TDesC8& aElementName );
+
+    /**
+     * Validates format of dc:date
+     *
+     * @param aDate dc:date string
+     * @return ETrue if format of dc:date is valid
+     */
+    TBool ValidateDateL( const TDesC8& aDate );
+    
+    /**
+     * Validates format of res@duration
+     *
+     * @param aDuration res@duration string
+     * @return ETrue if format of res@duration is valid
+     */
+    TBool ValidateDurationL( const TDesC8& aDuration );
+    
+    /**
+     * Parse to a delimeter
+     *
+     * @param aLexer lexer
+     * @param aDelimeter delimeter character
+     */
+    void ParseToDelimeter( TLex8& aLex, TChar aDelimeter );    
+
+    void FillMetaDataL(RBufWriteStream& aStream);
+	
+private:
+
+    /**
+     * C++ default constructor.
+     */
+    CUpnpItemToXML( const CUpnpItem& aItem );
+
+    /**
+     * By default Symbian 2nd phase constructor is private.
+     */
+    void ConstructL();
+
+private:    // Data
+
+    CUpnpItem*  iItem; // Not own
+    };
+
+#endif      // C_UPNPITEMTOXML_H
+            
+// End of File
--- a/upnpavcontroller/upnpxmlparser/inc/upnpxmleventparser.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/inc/upnpxmleventparser.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,205 +1,235 @@
-/*
-* Copyright (c) 2006-2007 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:      XML SAX Parser for UPnP.
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPXMLEVENTPARSER_H_
-#define C_UPNPXMLEVENTPARSER_H_
-
-// INCLUDES
-#include <e32base.h>
-#include <xml/contenthandler.h>
-
-// FORWARD DECLARATIONS
-
-using namespace Xml;
-
-/**
- * XML SAX Parser for UPnP.
- *
- * @since s60 3.1
- * @lib upnpxmlparser.lib
- */
-class CUPnPXMLEventParser :  public CBase,
-                             public MContentHandler
-    {
-
-public:
-
-    enum TParserState
-        {
-        EEvent = 0,
-        EInstanceID,
-        EVolume,
-        EMute,
-        ENotSupported // Brightness etc.
-        };    
-
-public:
-
-    /**
-     * 2-phased constructor.
-     */
-    IMPORT_C static CUPnPXMLEventParser* NewL();
-    
-    /**
-     * Destructor.
-     */
-    virtual ~CUPnPXMLEventParser();
-    
-public:
-
-    /**
-     * Parses xml data to the array of objects.
-     * @param aResultArray, An array for objects in xml root.
-     * @param aData, xml data.
-     */
-    IMPORT_C void ParseResultDataL( const TDesC8& aData,
-        TInt& aInstanceId, TInt& aVolume, TBool& aMute );
-                    
-protected: // from MContentHandler
-
-    /**
-     * From MContentHandler.
-     * @param aDocParam, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnStartDocumentL( const RDocumentParameters& aDocParam, 
-                           TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aErrorCode, not used.
-     */
-    void OnEndDocumentL( TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aElement, holds the element info.
-     * @param aAttributes, holds the element's attributes.
-     * @param aErrorCode, if not KErrNone, the method is ignored.
-     */
-    void OnStartElementL( const RTagInfo& aElement, 
-                          const RAttributeArray& aAttributes, 
-                          TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aElement, holds the element info.
-     * @param aErrorCode, if not KErrNone, the method is ignored.
-     */
-    void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aBytes, The value of the content.
-     * @param aErrorCode, if not KErrNone, the method is ignored.
-     */
-    void OnContentL( const TDesC8& aBytes, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aPrefix, not used.
-     * @param aUri, not used.
-     * @param aErrorCode, not used.
-     */    
-    void OnStartPrefixMappingL( const RString& aPrefix, 
-                                const RString& aUri, 
-                                TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aPrefix, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aBytes, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aName, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnSkippedEntityL( const RString& aName, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aTarget, not used.
-     * @param aData, not used.
-     * @param aErrorCode, not used. 
-     */
-    void OnProcessingInstructionL( const TDesC8& aTarget, 
-                                   const TDesC8& aData, 
-                                   TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aErrorCode
-     */                               
-    void OnError( TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aUid, not used.
-     * @return None.
-     */
-    TAny* GetExtendedInterface( const TInt32 aUid );
-
-                                    
-private:
-
-    /**
-     * Constructor.
-     */
-    CUPnPXMLEventParser();
-    
-    /**
-     * 2nd phase constructor.
-     */
-    void ConstructL();
-    
-private:    
-
-    void SetAttributesL( const RAttributeArray& aAttributes );
-
-    void Reset();
-    
-private: // data
-    
-    TParserState    iParserState;
-        
-    TInt            iInstanceID;
-    
-    TInt            iMute;
-
-    TInt            iVolume;
-    //ETrue:Master Volume is set.EFalse:Master Volume is not set.
-    TBool           iMasterVolumeState;
-    };
-
-#endif // C_UPNPXMLEVENTPARSER_H_
-
-// End of File
+/*
+* Copyright (c) 2006-2007,2009 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:      XML SAX Parser for UPnP.
+*
+*/
+
+#ifndef C_UPNPXMLEVENTPARSER_H_
+#define C_UPNPXMLEVENTPARSER_H_
+
+// INCLUDES
+#include <e32base.h>
+#include <xml/contenthandler.h>
+
+// FORWARD DECLARATIONS
+class CUPnPAVTEvent;
+
+using namespace Xml;
+
+/**
+ * XML SAX Parser for UPnP.
+ *
+ * @since s60 3.1
+ * @lib upnpxmlparser.lib
+ */
+class CUPnPXMLEventParser :  public CBase,
+                             public MContentHandler
+    {
+        
+private:
+
+    /**
+     * Internal parser state.
+     */
+    enum TParserState
+        {
+        EEvent = 0,
+        EInstanceID,
+        EVolume,
+        EMute,
+        ETransportState,
+        ETransportURI,
+        ENotSupported // Brightness etc.
+        }; 
+        
+public:
+
+    /**
+     * 2-phased constructor.
+     */
+    IMPORT_C static CUPnPXMLEventParser* NewL();
+    
+    /**
+     * Destructor.
+     */
+    virtual ~CUPnPXMLEventParser();
+    
+public:
+
+    /**
+     * Parses xml event data to values.
+     * 
+     * @param aData, xml data.
+     * @param aInstanceId, instance id of current session
+     * @return CUPnPAVTEvent*   contains event data. Ownership of event
+     *                          is transferred.
+     */
+    IMPORT_C CUPnPAVTEvent* ParseRcEventDataL( const TDesC8& aData,
+            TInt aInstanceId );
+        
+    /**
+     * Parses xml event data to values.
+     * @param aData, xml data.
+     * @param aInstanceId, instance id of current session
+     * @return CUPnPAVTEvent*   contains event data. Ownership of event
+     *                          is transferred.
+     */
+    IMPORT_C CUPnPAVTEvent* ParseAvtEventDataL( const TDesC8& aData,
+            TInt aInstanceId );
+                    
+protected: // from MContentHandler
+
+    /**
+     * From MContentHandler.
+     * @param aDocParam, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnStartDocumentL( const RDocumentParameters& aDocParam, 
+                           TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aErrorCode, not used.
+     */
+    void OnEndDocumentL( TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aElement, holds the element info.
+     * @param aAttributes, holds the element's attributes.
+     * @param aErrorCode, if not KErrNone, the method is ignored.
+     */
+    void OnStartElementL( const RTagInfo& aElement, 
+                          const RAttributeArray& aAttributes, 
+                          TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aElement, holds the element info.
+     * @param aErrorCode, if not KErrNone, the method is ignored.
+     */
+    void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aBytes, The value of the content.
+     * @param aErrorCode, if not KErrNone, the method is ignored.
+     */
+    void OnContentL( const TDesC8& aBytes, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aPrefix, not used.
+     * @param aUri, not used.
+     * @param aErrorCode, not used.
+     */    
+    void OnStartPrefixMappingL( const RString& aPrefix, 
+                                const RString& aUri, 
+                                TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aPrefix, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aBytes, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aName, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnSkippedEntityL( const RString& aName, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aTarget, not used.
+     * @param aData, not used.
+     * @param aErrorCode, not used. 
+     */
+    void OnProcessingInstructionL( const TDesC8& aTarget, 
+                                   const TDesC8& aData, 
+                                   TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aErrorCode
+     */                               
+    void OnError( TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aUid, not used.
+     * @return None.
+     */
+    TAny* GetExtendedInterface( const TInt32 aUid );
+
+                                    
+private:
+
+    /**
+     * Constructor.
+     */
+    CUPnPXMLEventParser();
+    
+    /**
+     * 2nd phase constructor.
+     */
+    void ConstructL();
+    
+private:  
+  
+    /**
+     * Sets class member variables
+     * @param RAttributeArray& aAttributes
+     * @return None.
+     */
+    void SetAttributesL( const RAttributeArray& aAttributes );
+    
+    /**
+     * Reset temporary variables that are used when parsing event
+     */
+    void Reset();
+    
+    /**
+     * Resets variables where event values are stored
+     */
+     void ResetResult();
+    
+private: // data
+    
+    TParserState    iParserState;
+    
+    TInt            iSessionInstanceID;
+    
+    TInt            iMasterVolumeState;
+    
+
+    // variables used when parsing current event
+    CUPnPAVTEvent*   iAvtEvent;          // own
+    
+    // variables where data from a valid event is stored
+    CUPnPAVTEvent*   iAvtResultEvent;    // own
+    };
+
+#endif // C_UPNPXMLEVENTPARSER_H_
+
+// End of File
--- a/upnpavcontroller/upnpxmlparser/inc/upnpxmlparser.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/inc/upnpxmlparser.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,273 +1,269 @@
-/*
-* Copyright (c) 2006-2007 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:      XML SAX Parser for UPnP.
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPXMLPARSER_H_
-#define C_UPNPXMLPARSER_H_
-
-// INCLUDES
-#include <e32base.h>
-#include <xml/contenthandler.h>
-
-// FORWARD DECLARATIONS
-class CUpnpObject;
-class CUPnPObjectStack; 
-class CUpnpElement;
-class CUpnpItem;
-class CUpnpContainer;
-
-using namespace Xml;
-
-/**
- * XML SAX Parser for UPnP.
- *
- * @since s60 3.1
- * @lib upnpxmlparser.lib
- */
-class CUPnPXMLParser :  public CBase,
-                        public MContentHandler
-    {
-
-public:
-
-    /**
-     * 2-phased constructor.
-     */
-    IMPORT_C static CUPnPXMLParser* NewL();
-    
-    /**
-     * 2-phased constructor.
-     */
-    IMPORT_C static CUPnPXMLParser* NewLC();
-    
-    /**
-     * Destructor.
-     */
-    virtual ~CUPnPXMLParser();
-    
-public:
-
-    /**
-     * Parses xml data to the array of objects.
-     * @param aResultArray, An array for objects in xml root.
-     * @param aData, xml data.
-     */
-    IMPORT_C void ParseResultDataL( RPointerArray<CUpnpObject>& aResultArray,
-        const TDesC8& aData );
-        
-    /**
-     * Creates an xml document from a given item 
-     *
-     * @param aItem item to convert
-     * @return xml document as a heap descriptor
-     */
-    IMPORT_C static HBufC8* ItemAsXmlLC( const CUpnpItem& aItem );
-
-    /**
-     * Creates an xml document from a given item, for CreateObject-action. 
-     *
-     * @param aItem item to convert
-     * @return xml document as a heap descriptor
-     */
-    IMPORT_C static HBufC8* XmlForCreateObjectLC( const CUpnpItem& aItem );
-
-    /**
-     * Creates an xml document from a given item container
-     *
-     * @param aContainer container to convert
-     * @return xml document as a heap descriptor
-     */
-    IMPORT_C static HBufC8* ContainerToXmlLC( 
-                                    const CUpnpContainer& aContainer );
-            
-protected: // from MContentHandler
-
-    /**
-     * From MContentHandler.
-     * @param aDocParam, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnStartDocumentL( const RDocumentParameters& aDocParam, 
-                           TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aErrorCode, not used.
-     */
-    void OnEndDocumentL( TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aElement, holds the element info.
-     * @param aAttributes, holds the element's attributes.
-     * @param aErrorCode, if not KErrNone, the method is ignored.
-     */
-    void OnStartElementL( const RTagInfo& aElement, 
-                          const RAttributeArray& aAttributes, 
-                          TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aElement, holds the element info.
-     * @param aErrorCode, if not KErrNone, the method is ignored.
-     */
-    void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aBytes, The value of the content.
-     * @param aErrorCode, if not KErrNone, the method is ignored.
-     */
-    void OnContentL( const TDesC8& aBytes, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aPrefix, not used.
-     * @param aUri, not used.
-     * @param aErrorCode, not used.
-     */    
-    void OnStartPrefixMappingL( const RString& aPrefix, 
-                                const RString& aUri, 
-                                TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aPrefix, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aBytes, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aName, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnSkippedEntityL( const RString& aName, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aTarget, not used.
-     * @param aData, not used.
-     * @param aErrorCode, not used. 
-     */
-    void OnProcessingInstructionL( const TDesC8& aTarget, 
-                                   const TDesC8& aData, 
-                                   TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aErrorCode
-     */                               
-    void OnError( TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aUid, not used.
-     * @return None.
-     */
-    TAny* GetExtendedInterface( const TInt32 aUid );
-
-                                    
-private:
-
-    /**
-     * Constructor.
-     */
-    CUPnPXMLParser();
-    
-    /**
-     * 2nd phase constructor.
-     */
-    void ConstructL();
-    
-private: 
-
-    /**
-     * Sets element's attributes to the object.
-     *
-     * @param aObject attributes will be set to this object
-     * @param aAttributes attributes to set
-     */
-    void SetAttributesL( CUpnpObject& aObject, 
-                         const RAttributeArray& aAttributes );
-                             
-    /**
-     * Set value to a element
-     * 
-     * @since Series 60 3.1
-     * @param aItem (CUpnpObject&) a item which owns the element
-     * @param aValue element value
-     */
-    void SetValueToElementL( CUpnpObject& aItem,
-        const TDesC8& aValue );
-        
-    /**
-     * Sets element's attributes to the element
-     *
-     * @param aElement attributes will be set to this element
-     * @param aAttributes attributes to set
-     */
-    void SetAttributesL( const RAttributeArray& aAttributes ); 
-
-    /**
-     * Reset member for parse again.
-     */
-	void ResetMember();
-private: // data
-
-    /**
-     * A pointer to result array from the client.
-     * Not own.
-     */      
-    RPointerArray<CUpnpObject>* iResultRoot;
-    
-    /**
-     * A stack for UPnP objects.
-     * Own.
-     */
-    CUPnPObjectStack*           iStack;
-    
-    /**
-     * Element value
-     * Own.
-     */
-    HBufC8*                     iElementValue;
-        
-    /**
-     * Upnp element
-     * Owned until ownership is transferred for an object
-     */
-    CUpnpElement*               iNewElement;
-    
-    TBool                       iTitle;
-    TBool                       iObjectClass;
-    };
-
-#endif // C_UPNPXMLPARSER_H_
-
-// End of File
+/*
+* Copyright (c) 2006-2007,2009 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:      XML SAX Parser for UPnP.
+*
+*/
+
+#ifndef C_UPNPXMLPARSER_H_
+#define C_UPNPXMLPARSER_H_
+
+// INCLUDES
+#include <e32base.h>
+#include <xml/contenthandler.h>
+
+// FORWARD DECLARATIONS
+class CUpnpObject;
+class CUPnPObjectStack; 
+class CUpnpElement;
+class CUpnpItem;
+class CUpnpContainer;
+
+using namespace Xml;
+
+/**
+ * XML SAX Parser for UPnP.
+ *
+ * @since s60 3.1
+ * @lib upnpxmlparser.lib
+ */
+class CUPnPXMLParser :  public CBase,
+                        public MContentHandler
+    {
+
+public:
+
+    /**
+     * 2-phased constructor.
+     */
+    IMPORT_C static CUPnPXMLParser* NewL();
+    
+    /**
+     * 2-phased constructor.
+     */
+    IMPORT_C static CUPnPXMLParser* NewLC();
+    
+    /**
+     * Destructor.
+     */
+    virtual ~CUPnPXMLParser();
+    
+public:
+
+    /**
+     * Parses xml data to the array of objects.
+     * @param aResultArray, An array for objects in xml root.
+     * @param aData, xml data.
+     */
+    IMPORT_C void ParseResultDataL( RPointerArray<CUpnpObject>& aResultArray,
+        const TDesC8& aData );
+        
+    /**
+     * Creates an xml document from a given item 
+     *
+     * @param aItem item to convert
+     * @return xml document as a heap descriptor
+     */
+    IMPORT_C static HBufC8* ItemAsXmlLC( const CUpnpItem& aItem );
+
+    /**
+     * Creates an xml document from a given item, for CreateObject-action. 
+     *
+     * @param aItem item to convert
+     * @return xml document as a heap descriptor
+     */
+    IMPORT_C static HBufC8* XmlForCreateObjectLC( const CUpnpItem& aItem );
+
+    /**
+     * Creates an xml document from a given item container
+     *
+     * @param aContainer container to convert
+     * @return xml document as a heap descriptor
+     */
+    IMPORT_C static HBufC8* ContainerToXmlLC( 
+                                    const CUpnpContainer& aContainer );
+            
+protected: // from MContentHandler
+
+    /**
+     * From MContentHandler.
+     * @param aDocParam, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnStartDocumentL( const RDocumentParameters& aDocParam, 
+                           TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aErrorCode, not used.
+     */
+    void OnEndDocumentL( TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aElement, holds the element info.
+     * @param aAttributes, holds the element's attributes.
+     * @param aErrorCode, if not KErrNone, the method is ignored.
+     */
+    void OnStartElementL( const RTagInfo& aElement, 
+                          const RAttributeArray& aAttributes, 
+                          TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aElement, holds the element info.
+     * @param aErrorCode, if not KErrNone, the method is ignored.
+     */
+    void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aBytes, The value of the content.
+     * @param aErrorCode, if not KErrNone, the method is ignored.
+     */
+    void OnContentL( const TDesC8& aBytes, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aPrefix, not used.
+     * @param aUri, not used.
+     * @param aErrorCode, not used.
+     */    
+    void OnStartPrefixMappingL( const RString& aPrefix, 
+                                const RString& aUri, 
+                                TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aPrefix, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aBytes, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aName, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnSkippedEntityL( const RString& aName, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aTarget, not used.
+     * @param aData, not used.
+     * @param aErrorCode, not used. 
+     */
+    void OnProcessingInstructionL( const TDesC8& aTarget, 
+                                   const TDesC8& aData, 
+                                   TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aErrorCode
+     */                               
+    void OnError( TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aUid, not used.
+     * @return None.
+     */
+    TAny* GetExtendedInterface( const TInt32 aUid );
+
+                                    
+private:
+
+    /**
+     * Constructor.
+     */
+    CUPnPXMLParser();
+    
+    /**
+     * 2nd phase constructor.
+     */
+    void ConstructL();
+    
+private: 
+
+    /**
+     * Sets element's attributes to the object.
+     *
+     * @param aObject attributes will be set to this object
+     * @param aAttributes attributes to set
+     */
+    void SetAttributesL( CUpnpObject& aObject, 
+                         const RAttributeArray& aAttributes );
+                             
+    /**
+     * Set value to a element
+     * 
+     * @since Series 60 3.1
+     * @param aItem (CUpnpObject&) a item which owns the element
+     * @param aValue element value
+     */
+    void SetValueToElementL( CUpnpObject& aItem,
+        const TDesC8& aValue );
+        
+    /**
+     * Sets element's attributes to the element
+     *
+     * @param aElement attributes will be set to this element
+     * @param aAttributes attributes to set
+     */
+    void SetAttributesL( const RAttributeArray& aAttributes ); 
+
+    /**
+     * Reset member for parse again.
+     */
+    void ResetMember();
+
+private: // data
+
+    /**
+     * A pointer to result array from the client.
+     * Not own.
+     */      
+    RPointerArray<CUpnpObject>* iResultRoot;
+    
+    /**
+     * A stack for UPnP objects.
+     * Own.
+     */
+    CUPnPObjectStack*           iStack;
+    
+    /**
+     * Element value
+     * Own.
+     */
+    HBufC8*                     iElementValue;
+        
+    /**
+     * Upnp element
+     * Owned until ownership is transferred for an object
+     */
+    CUpnpElement*               iNewElement;
+    
+    TBool                       iTitle;
+    TBool                       iObjectClass;
+    };
+
+#endif // C_UPNPXMLPARSER_H_
+
+// End of File
--- a/upnpavcontroller/upnpxmlparser/inc/upnpxmlparserlite.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/inc/upnpxmlparserlite.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,230 +1,229 @@
-/*
-* Copyright (c) 2006-2007 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:      XML SAX Parser for UPnP.
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPXMLPARSERLITE_H_
-#define C_UPNPXMLPARSERLITE_H_
-
-// INCLUDES
-#include <e32base.h>
-#include <xml/contenthandler.h>
-
-// FORWARD DECLARATIONS
-class CUpnpObjectLite;
-class CUPnPObjectStackLite; 
-//class CUpnpItem;
-//class CUpnpContainer;
-
-using namespace Xml;
-
-/**
- * XML SAX Parser for UPnP.
- *
- * @since s60 3.1
- * @lib upnpxmlparser.lib
- */
-class CUPnPXMLParserLite :  public CBase,
-                            public MContentHandler
-    {
-
-public:
-
-    /**
-     * 2-phased constructor.
-     */
-    IMPORT_C static CUPnPXMLParserLite* NewL();
-    
-    /**
-     * 2-phased constructor.
-     */
-    IMPORT_C static CUPnPXMLParserLite* NewLC();
-    
-    /**
-     * Destructor.
-     */
-    virtual ~CUPnPXMLParserLite();
-    
-public:
-
-    /**
-     * Parses xml data to the array of objects.
-     * @param aResultArray, An array for objects in xml root.
-     * @param aData, xml data.
-     * @param aFormatString the format of title. If KNullDesC title will be
-     * stored as it is. It's expected that the string is in the following
-     * format: _L( "0\t%S---" ); where "0" is a placeholder for icon index
-     * and %S is a placeholder for title
-     * 
-     */
-    IMPORT_C void ParseResultDataL( RPointerArray<CUpnpObjectLite>&
-        aResultArray, const TDesC8& aData, const TDesC& aFormatString = KNullDesC );
-                    
-protected: // from MContentHandler
-
-    /**
-     * From MContentHandler.
-     * @param aDocParam, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnStartDocumentL( const RDocumentParameters& aDocParam, 
-                           TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aErrorCode, not used.
-     */
-    void OnEndDocumentL( TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aElement, holds the element info.
-     * @param aAttributes, holds the element's attributes.
-     * @param aErrorCode, if not KErrNone, the method is ignored.
-     */
-    void OnStartElementL( const RTagInfo& aElement, 
-                          const RAttributeArray& aAttributes, 
-                          TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aElement, holds the element info.
-     * @param aErrorCode, if not KErrNone, the method is ignored.
-     */
-    void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aBytes, The value of the content.
-     * @param aErrorCode, if not KErrNone, the method is ignored.
-     */
-    void OnContentL( const TDesC8& aBytes, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aPrefix, not used.
-     * @param aUri, not used.
-     * @param aErrorCode, not used.
-     */    
-    void OnStartPrefixMappingL( const RString& aPrefix, 
-                                const RString& aUri, 
-                                TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aPrefix, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aBytes, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aName, not used.
-     * @param aErrorCode, not used.
-     */
-    void OnSkippedEntityL( const RString& aName, TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aTarget, not used.
-     * @param aData, not used.
-     * @param aErrorCode, not used. 
-     */
-    void OnProcessingInstructionL( const TDesC8& aTarget, 
-                                   const TDesC8& aData, 
-                                   TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aErrorCode
-     */                               
-    void OnError( TInt aErrorCode );
-    
-    /**
-     * From MContentHandler.
-     * @param aUid, not used.
-     * @return None.
-     */
-    TAny* GetExtendedInterface( const TInt32 aUid );
-
-                                    
-private:
-
-    /**
-     * Constructor.
-     */
-    CUPnPXMLParserLite();
-    
-    /**
-     * 2nd phase constructor.
-     */
-    void ConstructL();
-    
-private: 
-
-    /**
-     * Sets element's attributes to the object.
-     *
-     * @param aObject attributes will be set to this object
-     * @param aAttributes attributes to set
-     */
-    void SetAttributesL( CUpnpObjectLite& aObject, 
-                         const RAttributeArray& aAttributes );
-                         
-    void SetIconIndex( const CUpnpObjectLite& aObject );                     
-                                         
-private: // data
-
-    /**
-     * A pointer to result array from the client.
-     * Not own.
-     */      
-    RPointerArray<CUpnpObjectLite>* iResultRoot;
-    
-    /**
-     * A stack for UPnP objects.
-     * Own.
-     */
-    CUPnPObjectStackLite*           iStack;
-    
-    /**
-     * Element value
-     * Own.
-     */
-    HBufC8*                     iElementValue;
-    
-    HBufC8*                     iTitleBuf;
-    
-    HBufC*                      iFormatString;
-            
-    TBool                       iTitle;
-    TBool                       iObjectClass;
-    };
-
-#endif // C_UPNPXMLPARSER_H_
-
-// End of File
+/*
+* Copyright (c) 2006-2007 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:      XML SAX Parser for UPnP.
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPXMLPARSERLITE_H_
+#define C_UPNPXMLPARSERLITE_H_
+
+// INCLUDES
+#include <e32base.h>
+#include <xml/contenthandler.h>
+
+// FORWARD DECLARATIONS
+class CUpnpObjectLite;
+class CUPnPObjectStackLite; 
+
+using namespace Xml;
+
+/**
+ * XML SAX Parser for UPnP.
+ *
+ * @since s60 3.1
+ * @lib upnpxmlparser.lib
+ */
+class CUPnPXMLParserLite :  public CBase,
+                            public MContentHandler
+    {
+
+public:
+
+    /**
+     * 2-phased constructor.
+     */
+    IMPORT_C static CUPnPXMLParserLite* NewL();
+    
+    /**
+     * 2-phased constructor.
+     */
+    IMPORT_C static CUPnPXMLParserLite* NewLC();
+    
+    /**
+     * Destructor.
+     */
+    virtual ~CUPnPXMLParserLite();
+    
+public:
+
+    /**
+     * Parses xml data to the array of objects.
+     * @param aResultArray, An array for objects in xml root.
+     * @param aData, xml data.
+     * @param aFormatString the format of title. If KNullDesC title will be
+     * stored as it is. It's expected that the string is in the following
+     * format: _L( "0\t%S---" ); where "0" is a placeholder for icon index
+     * and %S is a placeholder for title
+     * 
+     */
+    IMPORT_C void ParseResultDataL( RPointerArray<CUpnpObjectLite>&
+        aResultArray, const TDesC8& aData, const TDesC& aFormatString =
+        KNullDesC );
+                    
+protected: // from MContentHandler
+
+    /**
+     * From MContentHandler.
+     * @param aDocParam, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnStartDocumentL( const RDocumentParameters& aDocParam, 
+                           TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aErrorCode, not used.
+     */
+    void OnEndDocumentL( TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aElement, holds the element info.
+     * @param aAttributes, holds the element's attributes.
+     * @param aErrorCode, if not KErrNone, the method is ignored.
+     */
+    void OnStartElementL( const RTagInfo& aElement, 
+                          const RAttributeArray& aAttributes, 
+                          TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aElement, holds the element info.
+     * @param aErrorCode, if not KErrNone, the method is ignored.
+     */
+    void OnEndElementL( const RTagInfo& aElement, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aBytes, The value of the content.
+     * @param aErrorCode, if not KErrNone, the method is ignored.
+     */
+    void OnContentL( const TDesC8& aBytes, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aPrefix, not used.
+     * @param aUri, not used.
+     * @param aErrorCode, not used.
+     */    
+    void OnStartPrefixMappingL( const RString& aPrefix, 
+                                const RString& aUri, 
+                                TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aPrefix, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnEndPrefixMappingL( const RString& aPrefix, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aBytes, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnIgnorableWhiteSpaceL( const TDesC8& aBytes, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aName, not used.
+     * @param aErrorCode, not used.
+     */
+    void OnSkippedEntityL( const RString& aName, TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aTarget, not used.
+     * @param aData, not used.
+     * @param aErrorCode, not used. 
+     */
+    void OnProcessingInstructionL( const TDesC8& aTarget, 
+                                   const TDesC8& aData, 
+                                   TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aErrorCode
+     */                               
+    void OnError( TInt aErrorCode );
+    
+    /**
+     * From MContentHandler.
+     * @param aUid, not used.
+     * @return None.
+     */
+    TAny* GetExtendedInterface( const TInt32 aUid );
+
+                                    
+private:
+
+    /**
+     * Constructor.
+     */
+    CUPnPXMLParserLite();
+    
+    /**
+     * 2nd phase constructor.
+     */
+    void ConstructL();
+    
+private: 
+
+    /**
+     * Sets element's attributes to the object.
+     *
+     * @param aObject attributes will be set to this object
+     * @param aAttributes attributes to set
+     */
+    void SetAttributesL( CUpnpObjectLite& aObject, 
+                         const RAttributeArray& aAttributes );
+                         
+    void SetIconIndex( const CUpnpObjectLite& aObject );                     
+                                         
+private: // data
+
+    /**
+     * A pointer to result array from the client.
+     * Not own.
+     */      
+    RPointerArray<CUpnpObjectLite>* iResultRoot;
+    
+    /**
+     * A stack for UPnP objects.
+     * Own.
+     */
+    CUPnPObjectStackLite*           iStack;
+    
+    /**
+     * Element value
+     * Own.
+     */
+    HBufC8*                     iElementValue;
+    
+    HBufC8*                     iTitleBuf;
+    
+    HBufC*                      iFormatString;
+            
+    TBool                       iTitle;
+    TBool                       iObjectClass;
+    };
+
+#endif // C_UPNPXMLPARSER_H_
+
+// End of File
--- a/upnpavcontroller/upnpxmlparser/src/upnpcontainertoxml.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/src/upnpcontainertoxml.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,125 +1,127 @@
-/*
-* Copyright (c) 2005 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:      XML generation from an UPNP container
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <e32base.h>
-#include <s32mem.h>
-
-// upnp stack api
-#include <upnpstring.h>
-#include <upnpcontainer.h>
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h"
-
-// xmlparser internal
-#include    "upnpcontainertoxml.h"
-
-// CONSTANTS
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// --------------------------------------------------------------------------
-// CUpnpContainerToXML::CUpnpContainerToXML
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// --------------------------------------------------------------------------
-CUpnpContainerToXML::CUpnpContainerToXML( const CUpnpContainer& aContainer ) :
-    iContainer( aContainer )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContainerToXML::ConstructL
-// Symbian 2nd phase constructor can leave.
-// --------------------------------------------------------------------------
-void CUpnpContainerToXML::ConstructL()
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContainerToXML::NewL
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-CUpnpContainerToXML* CUpnpContainerToXML::NewL( 
-                                        const CUpnpContainer& aContainer )
-    {
-    CUpnpContainerToXML* self = CUpnpContainerToXML::NewLC( aContainer );    
-    CleanupStack::Pop();
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpContainerToXML::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-CUpnpContainerToXML* CUpnpContainerToXML::NewLC(
-    const CUpnpContainer& aContainer )
-    {
-    CUpnpContainerToXML* self = new( ELeave ) CUpnpContainerToXML(
-        aContainer );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-    
-    
-// Destructor
-CUpnpContainerToXML::~CUpnpContainerToXML()
-    {
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpContainerToXML::AsXmlL
-// Returns XML buffer
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-HBufC8* CUpnpContainerToXML::AsXmlL()
-    {
-    // Not implemented
-    return NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContainerToXML::AsEmptyXmlL
-// Returns XML buffer
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-HBufC8* CUpnpContainerToXML::AsEmptyXmlL()
-    {
-    // Not implemented
-    return NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContainerToXML::CreateUnDecodedXmlL
-// See upnpcontainertoxml.h
-// --------------------------------------------------------------------------
-HBufC8* CUpnpContainerToXML::CreateUnDecodedXmlL( const TDesC8& /*aData*/ )
-    {
-    // Not implemented
-    return NULL;
-    }
-
-//  End of File
+/*
+* Copyright (c) 2005 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:      XML generation from an UPNP container
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// System
+#include <e32base.h>
+#include <s32mem.h>
+
+// upnp stack api
+#include <upnpstring.h>
+
+// dlnasrv / mediaserver api
+#include <upnpcontainer.h>
+
+// dlnasrv / avcontroller helper api
+#include "upnpconstantdefs.h"
+
+// xmlparser internal
+#include    "upnpcontainertoxml.h"
+
+// CONSTANTS
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// --------------------------------------------------------------------------
+// CUpnpContainerToXML::CUpnpContainerToXML
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// --------------------------------------------------------------------------
+CUpnpContainerToXML::CUpnpContainerToXML( const CUpnpContainer& aContainer ) :
+    iContainer( aContainer )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContainerToXML::ConstructL
+// Symbian 2nd phase constructor can leave.
+// --------------------------------------------------------------------------
+void CUpnpContainerToXML::ConstructL()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContainerToXML::NewL
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+CUpnpContainerToXML* CUpnpContainerToXML::NewL( 
+                                        const CUpnpContainer& aContainer )
+    {
+    CUpnpContainerToXML* self = CUpnpContainerToXML::NewLC( aContainer );    
+    CleanupStack::Pop();
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpContainerToXML::NewLC
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+CUpnpContainerToXML* CUpnpContainerToXML::NewLC(
+    const CUpnpContainer& aContainer )
+    {
+    CUpnpContainerToXML* self = new( ELeave ) CUpnpContainerToXML(
+        aContainer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+    
+    
+// Destructor
+CUpnpContainerToXML::~CUpnpContainerToXML()
+    {
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpContainerToXML::AsXmlL
+// Returns XML buffer
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+HBufC8* CUpnpContainerToXML::AsXmlL()
+    {
+    // Not implemented
+    return NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContainerToXML::AsEmptyXmlL
+// Returns XML buffer
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+HBufC8* CUpnpContainerToXML::AsEmptyXmlL()
+    {
+    // Not implemented
+    return NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContainerToXML::CreateUnDecodedXmlL
+// See upnpcontainertoxml.h
+// --------------------------------------------------------------------------
+HBufC8* CUpnpContainerToXML::CreateUnDecodedXmlL( const TDesC8& /*aData*/ )
+    {
+    // Not implemented
+    return NULL;
+    }
+
+//  End of File
--- a/upnpavcontroller/upnpxmlparser/src/upnpitemtoxml.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/src/upnpitemtoxml.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,945 +1,975 @@
-/*
-* Copyright (c) 2005 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:      generates XML from an UPNP item
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <e32base.h>
-
-// upnp stack api
-#include <upnpstring.h>
-#include <upnpitem.h>
-#include <upnpdlnaprotocolinfo.h>
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h" // for upnp definitions
-#include "upnpitemutility.h"
-
-// xmlparser internal
-#include "upnpitemtoxml.h"
-
-_LIT( KComponentLogfile, "upnpxmlparser.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-_LIT8(KItemHeading1,            "<item id=\"");
-_LIT8(KItemHeading2,            "\" parentID=\"");
-_LIT8(KItemHeading3False,       "\" restricted=\"0\">");
-_LIT8(KItemHeading3True,        "\" restricted=\"1\">");
-_LIT8(KItemTitleBegin,          "<dc:title>");
-_LIT8(KItemTitleEnd,            "</dc:title>");
-_LIT8(KItemDateBegin,           "<dc:date>");
-_LIT8(KItemDateEnd,             "</dc:date>");
-_LIT8(KItemClassBegin,          "<upnp:class>");
-_LIT8(KItemClassEnd,            "</upnp:class>");
-_LIT8(KItemPInfoEmpty,          "<res protocolInfo=\"*:*:*:*\"></res>");
-_LIT8(KItemPInfoEmptyDlna,      "<res protocolInfo=\"*:*:");
-_LIT8(KDlnaPn,                  "DLNA.ORG_PN=" );
-_LIT8(KColon,                   ":"); 
-_LIT8(KItemPInfoBegin,          "<res protocolInfo=\"");
-_LIT8(KItemPInfoMiddle,         ">");
-_LIT8(KItemPInfoEnd,            "</res>");
-_LIT8(KItemPInfoEnd2,            "\"></res>");
-_LIT8(KItemEnd,                 "</item>");
-
-_LIT8(KQuotationMark,           "\" ");
-_LIT8(KItemSize,                "size=\"");
-_LIT8(KItemDuration,            "duration=\"");
-_LIT8(KItemResolution,          "resolution=\"");
-
-// Music metadata
-_LIT8(KItemArtistBegin,         "<upnp:artist>");
-_LIT8(KItemArtistEnd,           "</upnp:artist>");
-_LIT8(KItemCreatorBegin,        "<dc:creator>");
-_LIT8(KItemCreatorEnd,          "</dc:creator>");
-_LIT8(KItemAlbumBegin,          "<upnp:album>");
-_LIT8(KItemAlbumEnd,            "</upnp:album>");
-_LIT8(KItemGenreBegin,          "<upnp:genre>");
-_LIT8(KItemGenreEnd,            "</upnp:genre>");
-_LIT8(KItemAlbumArtURIBegin,    "<upnp:albumArtURI>");
-_LIT8(KItemAlbumArtURIEnd,      "</upnp:albumArtURI>");
-
-_LIT8(KDIDLBeginXmlEscaped,
-    "&lt;DIDL-Lite "
-    "xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot; "
-    "xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; "
-    "xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot;"
-    "&gt;");
-_LIT8(KDIDLEndXmlEscaped, "&lt;/DIDL-Lite&gt;");
-
-_LIT8( KAsterisk, "*" );
-
-const TInt KBufLen = 256;
-const TInt KDateStringLength        = 10;
-const TInt KDateTimeStringLength    = 19;
-const TInt KMaxDateStringLength     = 30;
-const TInt KSeparatorAscii          = 58;
-
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::CUpnpItemToXML
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// --------------------------------------------------------------------------
-CUpnpItemToXML::CUpnpItemToXML( const CUpnpItem& aItem ) :
-    iItem( const_cast<CUpnpItem*>(&aItem) )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::ConstructL
-// Symbian 2nd phase constructor can leave.
-// --------------------------------------------------------------------------
-void CUpnpItemToXML::ConstructL()
-    {
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::NewL
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-CUpnpItemToXML* CUpnpItemToXML::NewL( const CUpnpItem& aItem )
-    {
-    CUpnpItemToXML* self = CUpnpItemToXML::NewLC( aItem );
-    
-    CleanupStack::Pop();
-
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-CUpnpItemToXML* CUpnpItemToXML::NewLC( const CUpnpItem& aItem )
-    {
-    CUpnpItemToXML* self = new( ELeave ) CUpnpItemToXML( aItem );
-    
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    
-    return self;
-    }
-    
-// Destructor
-CUpnpItemToXML::~CUpnpItemToXML()
-    {
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::AsXmlL
-// Returns XML buffer
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-HBufC8* CUpnpItemToXML::AsXmlL( const TBool /*aIncludeChilds = ETrue */ ) 
-    {
-    __LOG( "CUpnpItemToXML::AsXmlL" );
-    
-    const TInt bufferSize = 64; // Buffer size, grows dynamicly in 64b steps
-    CBufFlat *pBuf = CBufFlat::NewL( bufferSize );
-    CleanupStack::PushL( pBuf );
-
-    RBufWriteStream stream( *pBuf );
-    CleanupClosePushL( stream );
-
-    // Then add the actual data
-    stream.WriteL( KItemHeading1() );
-    // xml encoding added
-    HBufC8* encodeTemp = HBufC8::NewLC( iItem->Id().Length() );
-    encodeTemp->Des().Copy( iItem->Id() );
-
-    HBufC8* tempPtr = NULL;
-    tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-    CleanupStack::PushL( tempPtr );
-
-    stream.WriteL( *tempPtr );
-    CleanupStack::PopAndDestroy( tempPtr );
-    tempPtr = NULL;
-
-    CleanupStack::PopAndDestroy( encodeTemp );
-    encodeTemp = NULL;
-
-    stream.WriteL( KItemHeading2() );
-
-    stream.WriteL( iItem->ParentId() );
-    if (iItem->Restricted())
-        {
-        stream.WriteL( KItemHeading3True() );
-        }
-    else
-        {
-        stream.WriteL( KItemHeading3False() );
-        }
-    stream.WriteL( KItemTitleBegin() );
-
-    // xml encoding added
-    encodeTemp = HBufC8::NewLC( iItem->Title().Length() );
-    encodeTemp->Des().Copy( iItem->Title() );
-    
-    tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-    CleanupStack::PushL( tempPtr );
-
-    stream.WriteL( *tempPtr );
-    CleanupStack::PopAndDestroy( tempPtr );
-    tempPtr = NULL;
-    
-    CleanupStack::PopAndDestroy( encodeTemp );
-    encodeTemp = NULL;    
-    
-    stream.WriteL( KItemTitleEnd() );
-    stream.WriteL( KItemClassBegin() );
-
-    stream.WriteL( iItem->ObjectClass() );
-    stream.WriteL( KItemClassEnd() );
-    
-     // Music meta data information
-    const TDesC8& artist = GetValueFromElement( KElementArtist ); 
-    if ( artist != KNullDesC8 )
-
-        {
-        stream.WriteL( KItemArtistBegin );
-        // xml encoding added
-        encodeTemp = HBufC8::NewLC( artist.Length() );
-        encodeTemp->Des().Copy( artist );
-
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-        
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;
-
-        stream.WriteL( KItemArtistEnd );
-        }
-    const TDesC8& creator = GetValueFromElement( KElementCreator ); 
-    if ( creator != KNullDesC8 )
-        {
-        stream.WriteL( KItemCreatorBegin );
-        // xml encoding added
-        encodeTemp = HBufC8::NewLC( creator.Length() );
-        encodeTemp->Des().Copy( creator );
-
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-        
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;
-
-        stream.WriteL( KItemCreatorEnd );
-        }
-    const TDesC8& album = GetValueFromElement( KElementAlbum ); 
-    if ( album != KNullDesC8 )
-        {
-        stream.WriteL( KItemAlbumBegin );
-        // xml encoding added
-        encodeTemp = HBufC8::NewLC( album.Length() );
-        encodeTemp->Des().Copy( album );
-        
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-    
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;
-        //stream.WriteL( Album() );
-        stream.WriteL( KItemAlbumEnd );
-        }
-    const TDesC8& genre = GetValueFromElement( KElementGenre );     
-    if ( genre != KNullDesC8 )
-        {
-        stream.WriteL( KItemGenreBegin );
-        // xml encoding added
-        encodeTemp = HBufC8::NewLC( genre.Length() );
-        encodeTemp->Des().Copy( genre );
-
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-    
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;
-        //stream.WriteL( Genre() );
-        stream.WriteL( KItemGenreEnd );
-        } 
-    const TDesC8& albumarturi = GetValueFromElement( KElementAlbumArtUri );     
-    if ( albumarturi != KNullDesC8 )
-        {
-        stream.WriteL( KItemAlbumArtURIBegin );
-        // xml encoding added
-        encodeTemp = HBufC8::NewLC( albumarturi.Length() );
-        encodeTemp->Des().Copy( albumarturi );
-
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-    
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;        
-        stream.WriteL( KItemAlbumArtURIEnd );
-        }
-    const TDesC8& date = GetValueFromElement( KElementDate );         
-    if ( date != KNullDesC8 )
-        {        
-        if( ValidateDateL( date ) )
-            {
-            stream.WriteL( KItemDateBegin );
-            // xml encoding added
-            encodeTemp = HBufC8::NewLC( date.Length() );
-            encodeTemp->Des().Copy( date );
-
-            tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-            CleanupStack::PushL( tempPtr );
-
-            stream.WriteL( *tempPtr );
-            CleanupStack::PopAndDestroy( tempPtr );
-            tempPtr = NULL;
-
-            CleanupStack::PopAndDestroy( encodeTemp );
-            encodeTemp = NULL;
-            stream.WriteL( KItemDateEnd );
-            }
-        }
- 
-    RUPnPElementsArray elArray;
-    CleanupClosePushL( elArray );
-    UPnPItemUtility::GetResElements( *iItem, elArray );
-    TInt count = elArray.Count();
-    for( TInt i = 0; i < count; i++ )
-        {
-        // Res-element starts
-        stream.WriteL( KItemPInfoBegin );
-        
-        const CUpnpAttribute* attrproinfo = UPnPItemUtility
-            ::FindAttributeByName( *elArray[ i ], KAttributeProtocolInfo );
-        if ( attrproinfo )
-            {        
-            stream.WriteL( attrproinfo->Value() );
-            stream.WriteL( KCriteriaQuot );
-            stream.WriteL( KCriteriaSpace );
-            }
-        const CUpnpAttribute* attrsize = UPnPItemUtility
-            ::FindAttributeByName( *elArray[ i ], KAttributeSize );            
-        if ( attrsize )
-            {
-            stream.WriteL( KAttributeSize );
-            stream.WriteL( KCriteriaEQ );
-            stream.WriteL( KCriteriaQuot );
-            stream.WriteL( attrsize->Value() );
-            stream.WriteL( KCriteriaQuot );
-            stream.WriteL( KCriteriaSpace );                   
-            }         
-        const CUpnpAttribute* attrresolution = UPnPItemUtility
-            ::FindAttributeByName( *elArray[ i ], KAttributeResolution );
-        if ( attrresolution )
-            {
-            stream.WriteL( KAttributeResolution );
-            stream.WriteL( KCriteriaEQ );
-            stream.WriteL( KCriteriaQuot );
-            stream.WriteL( attrresolution->Value() );
-            stream.WriteL( KCriteriaQuot );
-            stream.WriteL( KCriteriaSpace );                        
-            }        
-        const CUpnpAttribute* attrduration = UPnPItemUtility
-            ::FindAttributeByName( *elArray[ i ], KAttributeDuration );        
-        if ( attrduration )
-            {           
-            if( ValidateDurationL( attrduration->Value() ) )
-                {
-                stream.WriteL( KAttributeDuration );
-                stream.WriteL( KCriteriaEQ );
-                stream.WriteL( KCriteriaQuot );
-                stream.WriteL( attrduration->Value() );
-                stream.WriteL( KCriteriaQuot );
-                stream.WriteL( KCriteriaSpace );
-                }
-            else
-                {
-                // Format of duration is not valid, do not include it
-                // Fixes ESLX-7AYFD6
-                }    
-            
-            }        
-        const CUpnpAttribute* attrbitrate = UPnPItemUtility
-            ::FindAttributeByName( *elArray[ i ], KAttributeBitrate );
-        if ( attrbitrate )
-            {
-            stream.WriteL( KAttributeBitrate );
-            stream.WriteL( KCriteriaEQ );
-            stream.WriteL( KCriteriaQuot );
-            stream.WriteL( attrbitrate->Value() );
-            stream.WriteL( KCriteriaQuot );
-            stream.WriteL( KCriteriaSpace );
-            } 
-        stream.WriteL( KItemPInfoMiddle );
-        
-        // Get the content URI
-        encodeTemp = HBufC8::NewLC( elArray[ i ]->Value().Length() );
-        encodeTemp->Des().Copy( elArray[ i ]->Value() );
-
-        // Encode the content URI
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        // Write the encoded content URI
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-        
-        // Clean up
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;
-        
-        // Res-element ends
-        stream.WriteL( KItemPInfoEnd );
-        }
-    
-    CleanupStack::PopAndDestroy( &elArray );                  
-
-    stream.WriteL( KItemEnd() );
-
-    CleanupStack::PopAndDestroy(); // stream.Close();
-
-    TPtrC8 start = pBuf->Ptr(0);
-
-    // JLi: Do NOT decode retBuffer since it will be given to XML Parser
-    HBufC8* retBuffer = start.AllocL();
-    CleanupStack::PopAndDestroy( pBuf );
-    
-    return retBuffer;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::AsXmlEmptyL
-// Returns object's XML description. This version of the method is used to
-// create the XML with empty <res> tag.
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-HBufC8* CUpnpItemToXML::AsXmlEmptyL()
-    {
-    __LOG( "CUpnpItemToXML::AsXmlEmptyL" );
-    
-    const TInt bufferSize = 64; // Buffer size, grows dynamicly in 64b steps
-    CBufFlat *pBuf = CBufFlat::NewL( bufferSize );
-    CleanupStack::PushL( pBuf );
-
-    RBufWriteStream stream( *pBuf );
-    CleanupClosePushL( stream );
-
-    // Then add the actual data
-    stream.WriteL( KItemHeading1() );
-    stream.WriteL( iItem->Id() );
-    stream.WriteL( KItemHeading2() );
-    stream.WriteL( iItem->ParentId() );
-    stream.WriteL( KItemHeading3False() );
-    //stream.WriteL( KItemEndTag() );
-    stream.WriteL( KItemTitleBegin() );
-    // xml encode name
-    HBufC8* encodeTemp = HBufC8::NewLC( iItem->Title().Length() );
-    encodeTemp->Des().Copy( iItem->Title() );
-    HBufC8* tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-    CleanupStack::PushL( tempPtr ); 
-    stream.WriteL( *tempPtr );
-    CleanupStack::PopAndDestroy( tempPtr );
-    CleanupStack::PopAndDestroy( encodeTemp );
-    stream.WriteL( KItemTitleEnd() );
-    stream.WriteL( KItemClassBegin() );
-    
-    stream.WriteL( iItem->ObjectClass() );
-    stream.WriteL( KItemClassEnd() );
-    
-    // Music meta data information
-    const TDesC8& artist = GetValueFromElement( KElementArtist ); 
-    if ( artist != KNullDesC8 )
-        {
-        stream.WriteL( KItemArtistBegin );
-        // xml encoding added
-        encodeTemp = HBufC8::NewLC( artist.Length() );
-        encodeTemp->Des().Copy( artist );
-
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-        
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;
-
-        stream.WriteL( KItemArtistEnd );
-        }
-    const TDesC8& creator = GetValueFromElement( KElementCreator ); 
-    if ( creator != KNullDesC8 )
-        {
-        stream.WriteL( KItemCreatorBegin );
-        // xml encoding added
-        encodeTemp = HBufC8::NewLC( creator.Length() );
-        encodeTemp->Des().Copy( creator );
-
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-        
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;
-
-        stream.WriteL( KItemCreatorEnd );        
-        }
-    const TDesC8& album = GetValueFromElement( KElementAlbum ); 
-    if ( album != KNullDesC8 )
-        {
-        stream.WriteL( KItemAlbumBegin );
-        // xml encoding added
-        encodeTemp = HBufC8::NewLC( album.Length() );
-        encodeTemp->Des().Copy( album );
-        
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-    
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;
-        //stream.WriteL( Album() );
-        stream.WriteL( KItemAlbumEnd );        
-        }
-    const TDesC8& genre = GetValueFromElement( KElementGenre );     
-    if ( genre != KNullDesC8 )
-        {
-        stream.WriteL( KItemGenreBegin );
-        // xml encoding added
-        encodeTemp = HBufC8::NewLC( genre.Length() );
-        encodeTemp->Des().Copy( genre );
-
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-    
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;
-        //stream.WriteL( Genre() );
-        stream.WriteL( KItemGenreEnd );        
-        }
-    const TDesC8& albumarturi = GetValueFromElement( KElementAlbumArtUri );     
-    if ( albumarturi != KNullDesC8 )
-        {
-        stream.WriteL( KItemAlbumArtURIBegin );
-        // xml encoding added
-        encodeTemp = HBufC8::NewLC( albumarturi.Length() );
-        encodeTemp->Des().Copy( albumarturi );
-
-        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-        CleanupStack::PushL( tempPtr );
-
-        stream.WriteL( *tempPtr );
-        CleanupStack::PopAndDestroy( tempPtr );
-        tempPtr = NULL;
-    
-        CleanupStack::PopAndDestroy( encodeTemp );
-        encodeTemp = NULL;       
-        stream.WriteL( KItemAlbumArtURIEnd );        
-        }
-    const TDesC8& date = GetValueFromElement( KElementDate );         
-    if ( date != KNullDesC8 )
-        {
-        if( ValidateDateL( date ) )
-            {
-            stream.WriteL( KItemDateBegin );
-            // xml encoding added
-            encodeTemp = HBufC8::NewLC( date.Length() );
-            encodeTemp->Des().Copy( date );
-
-            tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
-            CleanupStack::PushL( tempPtr );
-
-            stream.WriteL( *tempPtr );
-            CleanupStack::PopAndDestroy( tempPtr );
-            tempPtr = NULL;
-
-            CleanupStack::PopAndDestroy( encodeTemp );
-            encodeTemp = NULL;
-            stream.WriteL( KItemDateEnd );
-            }       
-        }
-    
-    // Create dlna compliant protocolinfo
-    const RUPnPElementsArray& elms = iItem->GetElements();
-    CUpnpDlnaProtocolInfo* pInfo = NULL; 
-    HBufC8* duration  = NULL;
-    HBufC8* size  = NULL;
-    HBufC8* resolution  = NULL;
-    HBufC8* info = NULL;
-    for( TInt i = 0; i < elms.Count(); i++)
-        {
-        if( elms[ i ]->Name() == KElementRes )
-            {
-            const RUPnPAttributesArray& attr = elms[ i ]->GetAttributes();
-            for( TInt j = 0; j < attr.Count(); j++ )
-                {
-                if( attr[ j ]->Name() == KAttributeProtocolInfo )
-                    {
-                    pInfo = CUpnpDlnaProtocolInfo::NewL( attr[ j ]->Value() );
-                    if ( pInfo )
-                        {
-                        CleanupStack::PushL( pInfo );
-                        info = HBufC8::NewLC( KBufLen );
-                        }
-                    }
-                if ( attr[ j ]->Name() == KAttributeDuration )
-                    {
-                    duration= HBufC8::NewLC( attr[ j ]->Value().Length() );
-                    duration->Des().Copy( attr[ j ]->Value() );
-                    }
-                if ( attr[ j ]->Name() == KAttributeSize )
-                    {
-                    size = HBufC8::NewLC( attr[ j ]->Value().Length() );
-                    size->Des().Copy( attr[ j ]->Value() );
-                    }
-                if ( attr[ j ]->Name() == KAttributeResolution )
-                    {
-                    resolution = HBufC8::NewLC( attr[ j ]->Value().Length() );
-                    resolution->Des().Copy( attr[ j ]->Value() );
-                    }
-                }
-            i = elms.Count();
-            }
-        }
-    
-    if( pInfo )
-        {
-        info->Des().Copy( KItemPInfoEmptyDlna );
-        info->Des().Append( pInfo->ThirdField() ); // Third param )
-        info->Des().Append( KColon );
-        if( pInfo->PnParameter().Length() > 0 )
-            {
-            info->Des().Append( KDlnaPn );
-            info->Des().Append( pInfo->PnParameter() ); // Fourth param )
-            }
-        else
-            {
-            info->Des().Append( KAsterisk );
-            }    
-        if ( resolution )
-            {
-            info->Des().Append( KQuotationMark );
-            info->Des().Append( KItemResolution );
-            info->Des().Append( *resolution );
-            CleanupStack::PopAndDestroy( resolution );
-            resolution = NULL;
-            }
-        if ( duration )
-            {
-            info->Des().Append( KQuotationMark );
-            info->Des().Append( KItemDuration );
-            info->Des().Append( *duration );
-            CleanupStack::PopAndDestroy( duration );
-            duration = NULL;
-            }
-        if ( size )
-            {
-            info->Des().Append( KQuotationMark );
-            info->Des().Append( KItemSize );
-            info->Des().Append( *size );
-            CleanupStack::PopAndDestroy( size );
-            size = NULL;
-            }
-        
-        info->Des().Append( KItemPInfoEnd2 );
-        stream.WriteL( *info );
-        CleanupStack::PopAndDestroy( info );
-        CleanupStack::PopAndDestroy( pInfo );
-        
-        }
-    else
-        {
-        stream.WriteL( KItemPInfoEmpty );    
-        }    
-            
-    stream.WriteL( KItemEnd() );
-
-    CleanupStack::PopAndDestroy( &stream );
-
-    TPtrC8 start = pBuf->Ptr(0);
-
-    HBufC8* tmpBuffer = start.AllocL();
-
-    CleanupStack::PopAndDestroy( pBuf );
-
-    return tmpBuffer;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::AsResultArgumentL
-// Returns object's XML description that is embedded inside a DIDL-LITE tag. 
-// The <res> tag of xml description is empty.The returned value is xml encoded
-// can therefore be used for example when creating a CreateObject action.
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-HBufC8* CUpnpItemToXML::AsResultArgumentL()
-    {
-    __LOG( "CUpnpItemToXML::AsResultArgumentL" );
-    
-    HBufC8* asEmptyXml = this->AsXmlEmptyL();
-    CleanupStack::PushL( asEmptyXml );
-    
-    // Xml must be encoded because eventually it will be embedded inside 
-    // another Xml tag (Elements tag in CreateObject action).
-    HBufC8* encodedItem = UpnpString::EncodeXmlStringL( asEmptyXml );
-    CleanupStack::PopAndDestroy( asEmptyXml );
-    CleanupStack::PushL( encodedItem );
-    
-    // Put item xml inside DIDL-LITE tag which must also be xml encoded.
-    HBufC8* retval = CreateUnDecodedXmlL( *encodedItem );
-    CleanupStack::PopAndDestroy( encodedItem );
-    
-    return retval;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::CreateUnDecodedXmlL
-// Fills common DIDL-Lite XML headers over the given XML fragment.
-// --------------------------------------------------------------------------
-HBufC8* CUpnpItemToXML::CreateUnDecodedXmlL( const TDesC8& aData )
-    {
-    __LOG( "CUpnpItemToXML::CreateUnDecodedXmlL" );
-    
-    const TInt bufferSize = 128; // Buffer size
-    CBufFlat *pBuf = CBufFlat::NewL( bufferSize );
-    CleanupStack::PushL( pBuf );
-
-    RBufWriteStream stream( *pBuf );
-    CleanupClosePushL( stream );
-
-    stream.WriteL( KDIDLBeginXmlEscaped() );
-    stream.WriteL( aData );
-    stream.WriteL( KDIDLEndXmlEscaped() );
-
-    CleanupStack::PopAndDestroy( &stream ); // stream.Close();
-
-    TPtrC8 start = pBuf->Ptr(0);
-
-    HBufC8* tmpBuffer = start.AllocL();
-
-    CleanupStack::PopAndDestroy( pBuf );
-    return tmpBuffer;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::GetValueFromElement
-// Returns the value of an element.
-// --------------------------------------------------------------------------
-const TDesC8& CUpnpItemToXML::GetValueFromElement(
-    const TDesC8& aElementName )
-    {
-    const RUPnPElementsArray& elms = iItem->GetElements();
-    TInt count = elms.Count();
-    for( TInt i = 0; i < count; i++)
-        {
-        if( elms[ i ]->Name() == aElementName )
-            {
-            return elms[ i ]->Value();
-            }
-        }
-    return KNullDesC8;              
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::ValidateDateL
-// Validates dc:date
-// --------------------------------------------------------------------------
-TBool CUpnpItemToXML::ValidateDateL( const TDesC8& aDate )
-    {
-    TDateTime time;    
-    TBuf<KMaxDateStringLength> formatDateString;
-    HBufC* dateString = HBufC::NewL( aDate.Length() );
-    dateString->Des().Copy( aDate );
-    TInt err = KErrNone;
-    TInt year = 0;
-    TInt month = 1; 
-    TInt day = 1;
-    TInt hours = 0;
-    TInt minutes = 0;
-    TInt seconds = 0;
-
-    if( aDate.Length() >= KDateStringLength )
-    {
-        TLex lex( dateString->Des().Left( 4 ) ); //Year
-        err = lex.Val( year );
-        if(  err == KErrNone )
-        {
-            lex.Assign( dateString->Des().Mid( 5,2 ) ); //Month
-            TInt err = lex.Val( month );
-            if(  err == KErrNone )
-            {
-                lex.Assign( dateString->Des().Mid( 8,2 ) ); //Day
-                TInt err = lex.Val(day);
-            }
-        }
-    }
-        
-    if (err)
-    {
-        return EFalse;
-    }
-        
-    if( aDate.Length() >= KDateTimeStringLength )
-    {
-        TLex lex( dateString->Des().Mid( 11,2 ) ); //Hours
-        err = lex.Val( hours );
-        if(  err == KErrNone )
-        {
-            lex.Assign( dateString->Des().Mid( 14,2 ) ); //Minutes
-            TInt err = lex.Val( hours );
-            if(  err == KErrNone )
-            {
-                lex.Assign( dateString->Des().Mid( 17,2 ) ); //Seconds
-                TInt err = lex.Val( hours );
-            }
-        }
-    }
-
-    if (err)
-    {
-        return EFalse;
-    }
-        
-    TBool retVal = EFalse;
-    //DateTime month and day are 0-based
-    if( time.Set( year, TMonth(month - 1), 
-            day - 1, hours, minutes, seconds,0 ) == KErrNone )
-        {
-        retVal = ETrue;
-        }
-    
-    delete dateString;
-    
-    return retVal;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::ValidateDurationL
-// Validates res@duration
-// --------------------------------------------------------------------------
-TBool CUpnpItemToXML::ValidateDurationL( const TDesC8& aDuration )
-    {
-    
-    TBool retVal = ETrue;
-    TLex8 input( aDuration );
-    
-    // Hours
-    ParseToDelimeter( input, TChar( KSeparatorAscii ) );
-    TInt hours = input.MarkedToken().Length();
-    if( !input.Eos() )
-        {
-        input.SkipAndMark( 1 ); // Skip the delimeter
-        }
-    if( hours < 1 || hours > 5 ) // hours must be 1-5 digits long
-        {
-        retVal = EFalse;
-        }
-    else
-        {
-        // Minutes
-        ParseToDelimeter( input, TChar( KSeparatorAscii ) );   
-        TInt minutes = input.MarkedToken().Length();
-        if( !input.Eos() )
-            {
-            input.SkipAndMark( 1 ); // Skip the delimeter
-            }
-
-        if( minutes != 2 ) // minutes must be 2 digits long
-            {
-            retVal = EFalse;
-            }
-        else
-            {
-            // Seconds
-            ParseToDelimeter( input, TChar( KSeparatorAscii ) );
-            TInt seconds = input.MarkedToken().Length();
-            if( seconds < 2 || seconds > 6 ) // seconds must be 2-6 digits
-            // long
-                {
-                retVal = EFalse;
-                }
-
-            if( !input.Eos() )
-                {
-                // Something is wrong, we should be in the end        
-                retVal = EFalse;
-                }            
-            }    
-        }    
-  
-    return retVal;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpItemToXML::ParseToDelimeter
-// Parse to a given delimeter
-// --------------------------------------------------------------------------
-void CUpnpItemToXML::ParseToDelimeter( TLex8& aLex, TChar aDelimeter )
-    {
-    aLex.Mark();
-        
-    TChar chr = 0;
-    
-    while( !aLex.Eos() )
-        {
-        chr = aLex.Peek();
-        if( chr == aDelimeter )
-            {
-            break;
-            }
-            
-        aLex.Inc();        
-        }
-    }    
-    
-
-//  End of File
+/*
+* Copyright (c) 2005 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:      generates XML from an UPNP item
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// System
+#include <e32base.h>
+
+// upnp stack api
+#include <upnpstring.h>
+
+// dlnasrv / mediaserver api
+#include <upnpitem.h>
+#include <upnpdlnaprotocolinfo.h>
+
+// dlnasrv / avcontroller helper api
+#include "upnpconstantdefs.h" // for upnp definitions
+#include "upnpitemutility.h"
+
+// xmlparser internal
+#include "upnpitemtoxml.h"
+
+_LIT( KComponentLogfile, "upnpxmlparser.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+_LIT8(KItemHeading1,            "<item id=\"");
+_LIT8(KItemHeading2,            "\" parentID=\"");
+_LIT8(KItemHeading3False,       "\" restricted=\"0\">");
+_LIT8(KItemHeading3True,        "\" restricted=\"1\">");
+_LIT8(KItemTitleBegin,          "<dc:title>");
+_LIT8(KItemTitleEnd,            "</dc:title>");
+_LIT8(KItemDateBegin,           "<dc:date>");
+_LIT8(KItemDateEnd,             "</dc:date>");
+_LIT8(KItemClassBegin,          "<upnp:class>");
+_LIT8(KItemClassEnd,            "</upnp:class>");
+_LIT8(KItemPInfoEmpty,          "<res protocolInfo=\"*:*:*:*\"></res>");
+_LIT8(KItemPInfoEmptyDlna,      "<res protocolInfo=\"*:*:");
+_LIT8(KDlnaPn,                  "DLNA.ORG_PN=" );
+_LIT8(KColon,                   ":"); 
+_LIT8(KItemPInfoBegin,          "<res protocolInfo=\"");
+_LIT8(KItemPInfoMiddle,         ">");
+_LIT8(KItemPInfoEnd,            "</res>");
+_LIT8(KItemPInfoEnd2,            "\"></res>");
+_LIT8(KItemEnd,                 "</item>");
+_LIT8(KEqual,                   "=");
+
+_LIT8(KQuotationMark,           "\" ");
+_LIT8(KItemSize,                "size=\"");
+_LIT8(KItemDuration,            "duration=\"");
+_LIT8(KItemResolution,          "resolution=\"");
+
+// Music metadata
+_LIT8(KItemArtistBegin,         "<upnp:artist>");
+_LIT8(KItemArtistEnd,           "</upnp:artist>");
+_LIT8(KItemCreatorBegin,        "<dc:creator>");
+_LIT8(KItemCreatorEnd,          "</dc:creator>");
+_LIT8(KItemAlbumBegin,          "<upnp:album>");
+_LIT8(KItemAlbumEnd,            "</upnp:album>");
+_LIT8(KItemGenreBegin,          "<upnp:genre>");
+_LIT8(KItemGenreEnd,            "</upnp:genre>");
+_LIT8(KItemAlbumArtURIBegin,    "<upnp:albumArtURI>");
+_LIT8(KItemAlbumArtURI,         "<upnp:albumArtURI ");
+_LIT8(KItemAlbumArtURIEnd,      "</upnp:albumArtURI>");
+
+_LIT8(KDIDLBeginXmlEscaped,
+    "&lt;DIDL-Lite "
+    "xmlns=&quot;urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/&quot; "
+    "xmlns:dc=&quot;http://purl.org/dc/elements/1.1/&quot; "
+    "xmlns:upnp=&quot;urn:schemas-upnp-org:metadata-1-0/upnp/&quot;"
+    "&gt;");
+_LIT8(KDIDLEndXmlEscaped, "&lt;/DIDL-Lite&gt;");
+
+_LIT8( KAsterisk, "*" );
+
+const TInt KBufLen = 256;
+const TInt KDateStringLength        = 10;
+const TInt KDateTimeStringLength    = 19;
+const TInt KMaxDateStringLength     = 30;
+const TInt KSeparatorAscii          = 58;
+
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::CUpnpItemToXML
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// --------------------------------------------------------------------------
+CUpnpItemToXML::CUpnpItemToXML( const CUpnpItem& aItem ) :
+    iItem( const_cast<CUpnpItem*>(&aItem) )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::ConstructL
+// Symbian 2nd phase constructor can leave.
+// --------------------------------------------------------------------------
+void CUpnpItemToXML::ConstructL()
+    {
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::NewL
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+CUpnpItemToXML* CUpnpItemToXML::NewL( const CUpnpItem& aItem )
+    {
+    CUpnpItemToXML* self = CUpnpItemToXML::NewLC( aItem );
+    
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::NewLC
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+CUpnpItemToXML* CUpnpItemToXML::NewLC( const CUpnpItem& aItem )
+    {
+    CUpnpItemToXML* self = new( ELeave ) CUpnpItemToXML( aItem );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    
+    return self;
+    }
+    
+// Destructor
+CUpnpItemToXML::~CUpnpItemToXML()
+    {
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::AsXmlL
+// Returns XML buffer
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+HBufC8* CUpnpItemToXML::AsXmlL( const TBool /*aIncludeChilds = ETrue */ ) 
+    {
+    __LOG( "CUpnpItemToXML::AsXmlL" );
+    
+    const TInt bufferSize = 64; // Buffer size, grows dynamicly in 64b steps
+    CBufFlat *pBuf = CBufFlat::NewL( bufferSize );
+    CleanupStack::PushL( pBuf );
+
+    RBufWriteStream stream( *pBuf );
+    CleanupClosePushL( stream );
+
+    // Then add the actual data
+    stream.WriteL( KItemHeading1() );
+    // xml encoding added
+    HBufC8* encodeTemp = HBufC8::NewLC( iItem->Id().Length() );
+    encodeTemp->Des().Copy( iItem->Id() );
+
+    HBufC8* tempPtr = NULL;
+    tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+    CleanupStack::PushL( tempPtr );
+
+    stream.WriteL( *tempPtr );
+    CleanupStack::PopAndDestroy( tempPtr );
+    tempPtr = NULL;
+
+    CleanupStack::PopAndDestroy( encodeTemp );
+    encodeTemp = NULL;
+
+    stream.WriteL( KItemHeading2() );
+
+    stream.WriteL( iItem->ParentId() );
+    if (iItem->Restricted())
+        {
+        stream.WriteL( KItemHeading3True() );
+        }
+    else
+        {
+        stream.WriteL( KItemHeading3False() );
+        }
+    stream.WriteL( KItemTitleBegin() );
+
+    // xml encoding added
+    encodeTemp = HBufC8::NewLC( iItem->Title().Length() );
+    encodeTemp->Des().Copy( iItem->Title() );
+    
+    tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+    CleanupStack::PushL( tempPtr );
+
+    stream.WriteL( *tempPtr );
+    CleanupStack::PopAndDestroy( tempPtr );
+    tempPtr = NULL;
+    
+    CleanupStack::PopAndDestroy( encodeTemp );
+    encodeTemp = NULL;    
+    
+    stream.WriteL( KItemTitleEnd() );
+    stream.WriteL( KItemClassBegin() );
+
+    stream.WriteL( iItem->ObjectClass() );
+    stream.WriteL( KItemClassEnd() );
+    
+     // Music meta data information
+    const TDesC8& artist = GetValueFromElement( KElementArtist ); 
+    if ( artist != KNullDesC8 )
+
+        {
+        stream.WriteL( KItemArtistBegin );
+        // xml encoding added
+        encodeTemp = HBufC8::NewLC( artist.Length() );
+        encodeTemp->Des().Copy( artist );
+
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        stream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+        
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;
+
+        stream.WriteL( KItemArtistEnd );
+        }
+    const TDesC8& creator = GetValueFromElement( KElementCreator ); 
+    if ( creator != KNullDesC8 )
+        {
+        stream.WriteL( KItemCreatorBegin );
+        // xml encoding added
+        encodeTemp = HBufC8::NewLC( creator.Length() );
+        encodeTemp->Des().Copy( creator );
+
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        stream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+        
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;
+
+        stream.WriteL( KItemCreatorEnd );
+        }
+    const TDesC8& album = GetValueFromElement( KElementAlbum ); 
+    if ( album != KNullDesC8 )
+        {
+        stream.WriteL( KItemAlbumBegin );
+        // xml encoding added
+        encodeTemp = HBufC8::NewLC( album.Length() );
+        encodeTemp->Des().Copy( album );
+        
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        stream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+    
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;
+        //stream.WriteL( Album() );
+        stream.WriteL( KItemAlbumEnd );
+        }
+    const TDesC8& genre = GetValueFromElement( KElementGenre );     
+    if ( genre != KNullDesC8 )
+        {
+        stream.WriteL( KItemGenreBegin );
+        // xml encoding added
+        encodeTemp = HBufC8::NewLC( genre.Length() );
+        encodeTemp->Des().Copy( genre );
+
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        stream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+    
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;
+        //stream.WriteL( Genre() );
+        stream.WriteL( KItemGenreEnd );
+        } 
+    const TDesC8& albumarturi = GetValueFromElement( KElementAlbumArtUri );
+    if ( albumarturi != KNullDesC8 )
+        {
+        CUpnpElement* elem = 
+        (CUpnpElement*)(UPnPItemUtility::FindElementByName( *iItem, KElementAlbumArtUri() ));
+        if( elem )
+            {
+            stream.WriteL( KItemAlbumArtURI );
+            const RUPnPAttributesArray& attrArray = elem->GetAttributes();
+            for( TInt i(0); i < attrArray.Count(); ++i )
+                {
+                stream.WriteL( attrArray.operator [](i)->Name() );
+                stream.WriteL( KEqual );
+                stream.WriteL( KCriteriaQuot );
+                stream.WriteL( attrArray.operator [](i)->Value() ); 
+                stream.WriteL( KCriteriaQuot );
+                }            
+            stream.WriteL( KItemPInfoMiddle );
+            }
+        else
+            {
+            stream.WriteL( KItemAlbumArtURIBegin );
+            }
+        // xml encoding added
+        encodeTemp = HBufC8::NewLC( albumarturi.Length() );
+        encodeTemp->Des().Copy( albumarturi );
+
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        stream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+    
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;        
+        stream.WriteL( KItemAlbumArtURIEnd );
+        }
+    const TDesC8& date = GetValueFromElement( KElementDate );         
+    if ( date != KNullDesC8 )
+        {        
+        if( ValidateDateL( date ) )
+            {
+            stream.WriteL( KItemDateBegin );
+            // xml encoding added
+            encodeTemp = HBufC8::NewLC( date.Length() );
+            encodeTemp->Des().Copy( date );
+
+            tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+            CleanupStack::PushL( tempPtr );
+
+            stream.WriteL( *tempPtr );
+            CleanupStack::PopAndDestroy( tempPtr );
+            tempPtr = NULL;
+
+            CleanupStack::PopAndDestroy( encodeTemp );
+            encodeTemp = NULL;
+            stream.WriteL( KItemDateEnd );
+            }
+        }
+ 
+    RUPnPElementsArray elArray;
+    CleanupClosePushL( elArray );
+    UPnPItemUtility::GetResElements( *iItem, elArray );
+    TInt count = elArray.Count();
+    for( TInt i = 0; i < count; i++ )
+        {
+        // Res-element starts
+        stream.WriteL( KItemPInfoBegin );
+        
+        const CUpnpAttribute* attrproinfo = UPnPItemUtility
+            ::FindAttributeByName( *elArray[ i ], KAttributeProtocolInfo );
+        if ( attrproinfo )
+            {        
+            stream.WriteL( attrproinfo->Value() );
+            stream.WriteL( KCriteriaQuot );
+            stream.WriteL( KCriteriaSpace );
+            }
+        const CUpnpAttribute* attrsize = UPnPItemUtility
+            ::FindAttributeByName( *elArray[ i ], KAttributeSize );            
+        if ( attrsize )
+            {
+            stream.WriteL( KAttributeSize );
+            stream.WriteL( KCriteriaEQ );
+            stream.WriteL( KCriteriaQuot );
+            stream.WriteL( attrsize->Value() );
+            stream.WriteL( KCriteriaQuot );
+            stream.WriteL( KCriteriaSpace );                   
+            }         
+        const CUpnpAttribute* attrresolution = UPnPItemUtility
+            ::FindAttributeByName( *elArray[ i ], KAttributeResolution );
+        if ( attrresolution )
+            {
+            stream.WriteL( KAttributeResolution );
+            stream.WriteL( KCriteriaEQ );
+            stream.WriteL( KCriteriaQuot );
+            stream.WriteL( attrresolution->Value() );
+            stream.WriteL( KCriteriaQuot );
+            stream.WriteL( KCriteriaSpace );                        
+            }        
+        const CUpnpAttribute* attrduration = UPnPItemUtility
+            ::FindAttributeByName( *elArray[ i ], KAttributeDuration );
+        if ( attrduration )
+            {           
+            if( ValidateDurationL( attrduration->Value() ) )
+                {
+                stream.WriteL( KAttributeDuration );
+                stream.WriteL( KCriteriaEQ );
+                stream.WriteL( KCriteriaQuot );
+                stream.WriteL( attrduration->Value() );
+                stream.WriteL( KCriteriaQuot );
+                stream.WriteL( KCriteriaSpace );
+                }
+            else
+                {
+                // Format of duration is not valid, do not include it
+                // Fixes ESLX-7AYFD6
+                }    
+            
+            }        
+        const CUpnpAttribute* attrbitrate = UPnPItemUtility
+            ::FindAttributeByName( *elArray[ i ], KAttributeBitrate );
+        if ( attrbitrate )
+            {
+            stream.WriteL( KAttributeBitrate );
+            stream.WriteL( KCriteriaEQ );
+            stream.WriteL( KCriteriaQuot );
+            stream.WriteL( attrbitrate->Value() );
+            stream.WriteL( KCriteriaQuot );
+            stream.WriteL( KCriteriaSpace );
+            } 
+        stream.WriteL( KItemPInfoMiddle );
+        
+        // Get the content URI
+        encodeTemp = HBufC8::NewLC( elArray[ i ]->Value().Length() );
+        encodeTemp->Des().Copy( elArray[ i ]->Value() );
+
+        // Encode the content URI
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        // Write the encoded content URI
+        stream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+        
+        // Clean up
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;
+        
+        // Res-element ends
+        stream.WriteL( KItemPInfoEnd );
+        }
+    
+    CleanupStack::PopAndDestroy( &elArray );                  
+
+    stream.WriteL( KItemEnd() );
+
+    CleanupStack::PopAndDestroy(); // stream.Close();
+
+    TPtrC8 start = pBuf->Ptr(0);
+
+    // JLi: Do NOT decode retBuffer since it will be given to XML Parser
+    HBufC8* retBuffer = start.AllocL();
+    CleanupStack::PopAndDestroy( pBuf );
+    
+    return retBuffer;
+    }
+
+void CUpnpItemToXML::FillMetaDataL(RBufWriteStream& aStream)
+    {
+    HBufC8* encodeTemp = NULL;
+    HBufC8* tempPtr = NULL;
+    const TDesC8& artist = GetValueFromElement( KElementArtist ); 
+    if ( artist != KNullDesC8 )
+        {
+        aStream.WriteL( KItemArtistBegin );
+        // xml encoding added
+        encodeTemp = HBufC8::NewLC( artist.Length() );
+        encodeTemp->Des().Copy( artist );
+
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        aStream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+        
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;
+
+        aStream.WriteL( KItemArtistEnd );
+        }
+    const TDesC8& creator = GetValueFromElement( KElementCreator ); 
+    if ( creator != KNullDesC8 )
+        {
+        aStream.WriteL( KItemCreatorBegin );
+        // xml encoding added
+        encodeTemp = HBufC8::NewLC( creator.Length() );
+        encodeTemp->Des().Copy( creator );
+
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        aStream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+        
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;
+
+        aStream.WriteL( KItemCreatorEnd );        
+        }
+    const TDesC8& album = GetValueFromElement( KElementAlbum ); 
+    if ( album != KNullDesC8 )
+        {
+        aStream.WriteL( KItemAlbumBegin );
+        // xml encoding added
+        encodeTemp = HBufC8::NewLC( album.Length() );
+        encodeTemp->Des().Copy( album );
+        
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        aStream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;
+        //aStream.WriteL( Album() );
+        aStream.WriteL( KItemAlbumEnd );        
+        }
+    const TDesC8& genre = GetValueFromElement( KElementGenre );     
+    if ( genre != KNullDesC8 )
+        {
+        aStream.WriteL( KItemGenreBegin );
+        // xml encoding added
+        encodeTemp = HBufC8::NewLC( genre.Length() );
+        encodeTemp->Des().Copy( genre );
+
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        aStream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;
+        //aStream.WriteL( Genre() );
+        aStream.WriteL( KItemGenreEnd );        
+        }
+    const TDesC8& albumarturi = GetValueFromElement( KElementAlbumArtUri );
+    if ( albumarturi != KNullDesC8 )
+        {
+        aStream.WriteL( KItemAlbumArtURIBegin );
+        // xml encoding added
+        encodeTemp = HBufC8::NewLC( albumarturi.Length() );
+        encodeTemp->Des().Copy( albumarturi );
+
+        tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+        CleanupStack::PushL( tempPtr );
+
+        aStream.WriteL( *tempPtr );
+        CleanupStack::PopAndDestroy( tempPtr );
+        tempPtr = NULL;
+
+        CleanupStack::PopAndDestroy( encodeTemp );
+        encodeTemp = NULL;       
+        aStream.WriteL( KItemAlbumArtURIEnd );        
+        }
+    const TDesC8& date = GetValueFromElement( KElementDate );         
+    if ( date != KNullDesC8 )
+        {
+        if( ValidateDateL( date ) )
+            {
+            aStream.WriteL( KItemDateBegin );
+            // xml encoding added
+            encodeTemp = HBufC8::NewLC( date.Length() );
+            encodeTemp->Des().Copy( date );
+
+            tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+            CleanupStack::PushL( tempPtr );
+
+            aStream.WriteL( *tempPtr );
+            CleanupStack::PopAndDestroy( tempPtr );
+            tempPtr = NULL;
+
+            CleanupStack::PopAndDestroy( encodeTemp );
+            encodeTemp = NULL;
+            aStream.WriteL( KItemDateEnd );
+            }       
+        }
+    }
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::AsXmlEmptyL
+// Returns object's XML description. This version of the method is used to
+// create the XML with empty <res> tag.
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+HBufC8* CUpnpItemToXML::AsXmlEmptyL()
+    {
+    __LOG( "CUpnpItemToXML::AsXmlEmptyL" );
+    
+    const TInt bufferSize = 64; // Buffer size, grows dynamicly in 64b steps
+    CBufFlat *pBuf = CBufFlat::NewL( bufferSize );
+    CleanupStack::PushL( pBuf );
+
+    RBufWriteStream stream( *pBuf );
+    CleanupClosePushL( stream );
+
+    // Then add the actual data
+    stream.WriteL( KItemHeading1() );
+    stream.WriteL( iItem->Id() );
+    stream.WriteL( KItemHeading2() );
+    stream.WriteL( iItem->ParentId() );
+    stream.WriteL( KItemHeading3False() );
+    //stream.WriteL( KItemEndTag() );
+    stream.WriteL( KItemTitleBegin() );
+    // xml encode name
+    HBufC8* encodeTemp = HBufC8::NewLC( iItem->Title().Length() );
+    encodeTemp->Des().Copy( iItem->Title() );
+    HBufC8* tempPtr = UpnpString::EncodeXmlStringL( encodeTemp );
+    CleanupStack::PushL( tempPtr ); 
+    stream.WriteL( *tempPtr );
+    CleanupStack::PopAndDestroy( tempPtr );
+    CleanupStack::PopAndDestroy( encodeTemp );
+    stream.WriteL( KItemTitleEnd() );
+    stream.WriteL( KItemClassBegin() );
+    
+    stream.WriteL( iItem->ObjectClass() );
+    stream.WriteL( KItemClassEnd() );
+
+    FillMetaDataL(stream);    
+    
+    // Create dlna compliant protocolinfo
+    const RUPnPElementsArray& elms = iItem->GetElements();
+    CUpnpDlnaProtocolInfo* pInfo = NULL; 
+    HBufC8* duration  = NULL;
+    HBufC8* size  = NULL;
+    HBufC8* resolution  = NULL;
+    HBufC8* info = NULL;
+    for( TInt i = 0; i < elms.Count(); i++)
+        {
+        if( elms[ i ]->Name() == KElementRes )
+            {
+            const RUPnPAttributesArray& attr = elms[ i ]->GetAttributes();
+            //pInfo must be checked first
+            for( TInt j = 0; j < attr.Count(); j++ )
+                {
+                if( attr[ j ]->Name() == KAttributeProtocolInfo )
+                    {
+                    pInfo = CUpnpDlnaProtocolInfo::NewL(
+                            attr[ j ]->Value() );
+                    if ( pInfo )
+                        {
+                        CleanupStack::PushL( pInfo );
+                        info = HBufC8::NewLC( KBufLen );
+
+                        info->Des().Copy( KItemPInfoEmptyDlna );
+                        info->Des().Append( pInfo->ThirdField() ); // Third param )
+                        info->Des().Append( KColon );
+                        if( pInfo->PnParameter().Length() > 0 )
+                            {
+                            info->Des().Append( KDlnaPn );
+                            info->Des().Append( pInfo->PnParameter() ); // Fourth param )
+                            }
+                        else
+                            {
+                            info->Des().Append( KAsterisk );
+                            }   
+                        break;
+                        }
+                    }
+                }
+            //if there is pInfo we can continue with other elements
+                if (pInfo)
+                    {
+                    for (TInt j = 0; j < attr.Count(); j++)
+                        {
+                        if ( attr[ j ]->Name() == KAttributeDuration )
+                            {
+                            duration= HBufC8::NewLC( attr[ j ]->Value().Length() );
+                            duration->Des().Copy( attr[ j ]->Value() );
+                            info->Des().Append( KQuotationMark );
+                            info->Des().Append( KItemDuration );
+                            info->Des().Append( *duration );
+                            CleanupStack::PopAndDestroy( duration );
+                            duration = NULL;
+                            }
+                        if ( attr[ j ]->Name() == KAttributeSize )
+                            {
+                            size = HBufC8::NewLC( attr[ j ]->Value().Length() );
+                            size->Des().Copy( attr[ j ]->Value() );
+                            info->Des().Append( KQuotationMark );
+                            info->Des().Append( KItemSize );
+                            info->Des().Append( *size );
+                            CleanupStack::PopAndDestroy( size );
+                            size = NULL;
+                            }
+                        if ( attr[ j ]->Name() == KAttributeResolution )
+                            {
+                            resolution = HBufC8::NewLC( attr[ j ]->Value().Length() );
+                            resolution->Des().Copy( attr[ j ]->Value() );
+                            info->Des().Append( KQuotationMark );
+                            info->Des().Append( KItemResolution );
+                            info->Des().Append( *resolution );
+                            CleanupStack::PopAndDestroy( resolution );
+                            resolution = NULL;
+                            }
+                        }
+                    }
+            i = elms.Count();
+            }
+        }
+    
+    if( pInfo )
+        {
+        
+        info->Des().Append( KItemPInfoEnd2 );
+        stream.WriteL( *info );
+        CleanupStack::PopAndDestroy( info );
+        CleanupStack::PopAndDestroy( pInfo );
+        
+        }
+    else
+        {
+        stream.WriteL( KItemPInfoEmpty );    
+        }    
+            
+    stream.WriteL( KItemEnd() );
+
+    CleanupStack::PopAndDestroy( &stream );
+
+    TPtrC8 start = pBuf->Ptr(0);
+
+    HBufC8* tmpBuffer = start.AllocL();
+
+    CleanupStack::PopAndDestroy( pBuf );
+
+    return tmpBuffer;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::AsResultArgumentL
+// Returns object's XML description that is embedded inside a DIDL-LITE tag. 
+// The <res> tag of xml description is empty.The returned value is xml
+// encoded can therefore be used for example when creating a CreateObject
+// action. (other items were commented in a header).
+// --------------------------------------------------------------------------
+HBufC8* CUpnpItemToXML::AsResultArgumentL()
+    {
+    __LOG( "CUpnpItemToXML::AsResultArgumentL" );
+    
+    HBufC8* asEmptyXml = this->AsXmlEmptyL();
+    CleanupStack::PushL( asEmptyXml );
+    
+    // Xml must be encoded because eventually it will be embedded inside 
+    // another Xml tag (Elements tag in CreateObject action).
+    HBufC8* encodedItem = UpnpString::EncodeXmlStringL( asEmptyXml );
+    CleanupStack::PopAndDestroy( asEmptyXml );
+    CleanupStack::PushL( encodedItem );
+    
+    // Put item xml inside DIDL-LITE tag which must also be xml encoded.
+    HBufC8* retval = CreateUnDecodedXmlL( *encodedItem );
+    CleanupStack::PopAndDestroy( encodedItem );
+    
+    return retval;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::CreateUnDecodedXmlL
+// Fills common DIDL-Lite XML headers over the given XML fragment.
+// --------------------------------------------------------------------------
+HBufC8* CUpnpItemToXML::CreateUnDecodedXmlL( const TDesC8& aData )
+    {
+    __LOG( "CUpnpItemToXML::CreateUnDecodedXmlL" );
+    
+    const TInt bufferSize = 128; // Buffer size
+    CBufFlat *pBuf = CBufFlat::NewL( bufferSize );
+    CleanupStack::PushL( pBuf );
+
+    RBufWriteStream stream( *pBuf );
+    CleanupClosePushL( stream );
+
+    stream.WriteL( KDIDLBeginXmlEscaped() );
+    stream.WriteL( aData );
+    stream.WriteL( KDIDLEndXmlEscaped() );
+
+    CleanupStack::PopAndDestroy( &stream ); // stream.Close();
+
+    TPtrC8 start = pBuf->Ptr(0);
+
+    HBufC8* tmpBuffer = start.AllocL();
+
+    CleanupStack::PopAndDestroy( pBuf );
+    return tmpBuffer;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::GetValueFromElement
+// Returns the value of an element.
+// --------------------------------------------------------------------------
+const TDesC8& CUpnpItemToXML::GetValueFromElement(
+    const TDesC8& aElementName )
+    {
+    const RUPnPElementsArray& elms = iItem->GetElements();
+    TInt count = elms.Count();
+    for( TInt i = 0; i < count; i++)
+        {
+        if( elms[ i ]->Name() == aElementName )
+            {
+            return elms[ i ]->Value();
+            }
+        }
+    return KNullDesC8;              
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::ValidateDateL
+// Validates dc:date
+// --------------------------------------------------------------------------
+TBool CUpnpItemToXML::ValidateDateL( const TDesC8& aDate )
+    {
+    TDateTime time;    
+    TBuf<KMaxDateStringLength> formatDateString;
+    HBufC* dateString = HBufC::NewL( aDate.Length() );
+    dateString->Des().Copy( aDate );
+    TInt err = KErrNone;
+    TInt year = 0;
+    TInt month = 1; 
+    TInt day = 1;
+    TInt hours = 0;
+    TInt minutes = 0;
+    TInt seconds = 0;
+
+    if( aDate.Length() >= KDateStringLength )
+    {
+        TLex lex( dateString->Des().Left( 4 ) ); //Year
+        err = lex.Val( year );
+        if(  err == KErrNone )
+        {
+            lex.Assign( dateString->Des().Mid( 5,2 ) ); //Month
+            TInt err = lex.Val( month );
+            if(  err == KErrNone )
+            {
+                lex.Assign( dateString->Des().Mid( 8,2 ) ); //Day
+                TInt err = lex.Val(day);
+            }
+        }
+    }
+        
+    if (err)
+    {
+        return EFalse;
+    }
+        
+    if( aDate.Length() >= KDateTimeStringLength )
+    {
+        TLex lex( dateString->Des().Mid( 11,2 ) ); //Hours
+        err = lex.Val( hours );
+        if(  err == KErrNone )
+        {
+            lex.Assign( dateString->Des().Mid( 14,2 ) ); //Minutes
+            TInt err = lex.Val( hours );
+            if(  err == KErrNone )
+            {
+                lex.Assign( dateString->Des().Mid( 17,2 ) ); //Seconds
+                TInt err = lex.Val( hours );
+            }
+        }
+    }
+
+    if (err)
+    {
+        return EFalse;
+    }
+        
+    TBool retVal = EFalse;
+    //DateTime month and day are 0-based
+    if( time.Set( year, TMonth(month - 1), 
+            day - 1, hours, minutes, seconds,0 ) == KErrNone )
+        {
+        retVal = ETrue;
+        }
+    
+    delete dateString;
+    
+    return retVal;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::ValidateDurationL
+// Validates res@duration
+// --------------------------------------------------------------------------
+TBool CUpnpItemToXML::ValidateDurationL( const TDesC8& aDuration )
+    {
+    
+    TBool retVal = ETrue;
+    TLex8 input( aDuration );
+    
+    // Hours
+    ParseToDelimeter( input, TChar( KSeparatorAscii ) );
+    TInt hours = input.MarkedToken().Length();
+    if( !input.Eos() )
+        {
+        input.SkipAndMark( 1 ); // Skip the delimeter
+        }
+    if( hours < 1 || hours > 5 ) // hours must be 1-5 digits long
+        {
+        retVal = EFalse;
+        }
+    else
+        {
+        // Minutes
+        ParseToDelimeter( input, TChar( KSeparatorAscii ) );   
+        TInt minutes = input.MarkedToken().Length();
+        if( !input.Eos() )
+            {
+            input.SkipAndMark( 1 ); // Skip the delimeter
+            }
+
+        if( minutes != 2 ) // minutes must be 2 digits long
+            {
+            retVal = EFalse;
+            }
+        else
+            {
+            // Seconds
+            ParseToDelimeter( input, TChar( KSeparatorAscii ) );
+            TInt seconds = input.MarkedToken().Length();
+            if( seconds < 2 || seconds > 6 ) // seconds must be 2-6 digits
+            // long
+                {
+                retVal = EFalse;
+                }
+
+            if( !input.Eos() )
+                {
+                // Something is wrong, we should be in the end        
+                retVal = EFalse;
+                }            
+            }    
+        }    
+  
+    return retVal;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpItemToXML::ParseToDelimeter
+// Parse to a given delimeter
+// --------------------------------------------------------------------------
+void CUpnpItemToXML::ParseToDelimeter( TLex8& aLex, TChar aDelimeter )
+    {
+    aLex.Mark();
+        
+    TChar chr = 0;
+    
+    while( !aLex.Eos() )
+        {
+        chr = aLex.Peek();
+        if( chr == aDelimeter )
+            {
+            break;
+            }
+            
+        aLex.Inc();        
+        }
+    }    
+    
+
+//  End of File
--- a/upnpavcontroller/upnpxmlparser/src/upnpxmleventparser.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/src/upnpxmleventparser.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,391 +1,491 @@
-/*
-* Copyright (c) 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:      XML SAX Parser for UPnP.
-*
-*/
-
-
-
-
-
-
-#include <xml/parser.h>
-#include <xml/parserfeature.h>
-#include <upnpstring.h>
-#include <xml/matchdata.h>
-
-#include "upnpxmleventparser.h"
-
-_LIT( KComponentLogfile, "upnpxmlparser.txt");
-#include "upnplog.h"
-
-_LIT8( KXmlMimeType,    "text/xml"     );
-_LIT8( KLIB2XML,        "libxml2" );
-
-_LIT8( KEvent,          "Event"         );
-_LIT8( KInstanceID,     "InstanceID"    );
-_LIT8( KVolume,         "Volume"        );
-_LIT8( KMute,           "Mute"          );
-_LIT8( KDIDL,           "DIDL-Lite"     );
-_LIT8( KDesc,           "desc"          );
-_LIT8( KDlnaDoc,        "X_DLNADOC"     );
-_LIT8( KVal,            "val"           );
-_LIT8( KChannel,        "channel"       );
-_LIT8( KMaster,         "Master"       );
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::CUPnPXMLEventParser()
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-CUPnPXMLEventParser::CUPnPXMLEventParser()
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::ConstructL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::ConstructL()
-    {
-    __LOG( "CUPnPXMLEventParser::CostructL" );
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::NewL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C CUPnPXMLEventParser* CUPnPXMLEventParser::NewL()
-    {
-    __LOG( "CUPnPXMLEventParser::NewL" );
-    CUPnPXMLEventParser* self = new( ELeave ) CUPnPXMLEventParser();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop(self);    
-    return self;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::~CUPnPXMLEventParser
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-CUPnPXMLEventParser::~CUPnPXMLEventParser()
-    {
-    __LOG( "CUPnPXMLEventParser::~CUPnPXMLEventParser" );
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::ParseResultDataL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUPnPXMLEventParser::ParseResultDataL( const TDesC8& aData,
-        TInt& aInstanceId, TInt& aVolume, TBool& aMute )
-    {
-    __LOG( "CUPnPXMLEventParser::ParseResultDataL, begin" );
-    
-    if ( !aData.Length() )
-        {
-        User::Leave( KErrArgument );
-        }
-
-    Reset();
-        
-    // Create parser 
-    CMatchData* matchData = CMatchData::NewLC();
-    matchData->SetMimeTypeL( KXmlMimeType ); 
-    matchData->SetVariantL( KLIB2XML ); 
-    CParser* parser = CParser::NewLC( *matchData, *this ); 
-    parser->EnableFeature( Xml::EReportNamespaceMapping );
-    
-    Xml::ParseL( *parser, aData );    
-    
-    CleanupStack::PopAndDestroy( parser );
-    CleanupStack::PopAndDestroy( matchData );
-    
-    if( iInstanceID != KErrNotFound )
-        {
-        aInstanceId = iInstanceID;
-        if( iVolume != KErrNotFound )
-            {
-            aVolume = iVolume;    
-            }
-        if( iMute != KErrNotFound )
-            {
-            aMute = iMute;    
-            }
-        }
-    else
-        {
-        User::Leave( KErrArgument );
-        }    
-    
-    __LOG( "CUPnPXMLEventParser::ParseResultDataL, end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnStartDocumentL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnStartDocumentL( 
-                                const RDocumentParameters& /*aDocParam*/, 
-                                TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnEndDocumentL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnEndDocumentL( TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnStartElementL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnStartElementL( const RTagInfo& aElement, 
-                                      const RAttributeArray& aAttributes,
-                                      TInt aErrorCode )
-    {
-    __LOG1( "CUPnPXMLEventParser::OnStartElementL, error: %d", aErrorCode );
-    if ( aErrorCode != KErrNone )
-        {
-        return;
-        }
-    const TDesC8& desName = aElement.LocalName().DesC();
-    //const TDesC8& prefix = aElement.Prefix().DesC();
-      
-    if ( !desName.CompareF( KEvent ) )
-        {
-        iParserState = EEvent;
-        }
-    else if ( !desName.CompareF( KInstanceID ) )
-        {
-        iParserState = EInstanceID;
-        SetAttributesL( aAttributes );
-        }
-    else if( !desName.CompareF( KVolume ) )
-        {
-        iParserState = EVolume;
-        SetAttributesL( aAttributes );
-        }
-    else if( !desName.CompareF( KMute ) )
-        {
-        iParserState = EMute;
-        SetAttributesL( aAttributes );
-        }
-    // Ignore DIDL-Lite, desc and X_DLNADOC -elements (DLNA req)
-    else if( desName.Compare( KDIDL ) == KErrNone ||
-             desName.Compare( KDesc ) == KErrNone ||
-             desName.Compare( KDlnaDoc ) == KErrNone    
-           )
-        {
-        // Ignore
-        }
-    else 
-        {
-        __LOG( "OnStartElementL - unknown element!" );
-        __LOG8( desName );
-        }
-    
-    __LOG( "CUPnPXMLEventParser::OnStartElementL, end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnEndElementL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnEndElementL( const RTagInfo& /*aElement*/, 
-                                    TInt /*aErrorCode*/ )
-    {
-    __LOG( "CUPnPXMLSAXParser::OnEndElementL(), begin" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnContentL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnContentL( const TDesC8& /*aBytes*/,
-    TInt /*aErrorCode*/ )
-    {
-    __LOG( "CUPnPXMLSAXParser::OnContentL(), begin" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnStartPrefixMappingL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, 
-                                               const RString& /*aUri*/, 
-                                               TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnEndPrefixMappingL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnEndPrefixMappingL( const RString& /*aPrefix*/, 
-                                             TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnIgnorableWhiteSpaceL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, 
-                                                TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnSkippedEntityL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnSkippedEntityL( const RString& /*aName*/, 
-                                          TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnProcessingInstructionL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnProcessingInstructionL( const TDesC8& /*aTarget*/, 
-                                                  const TDesC8& /*aData*/, 
-                                                  TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::OnError
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::OnError( TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::GetExtendedInterface
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-TAny* CUPnPXMLEventParser::GetExtendedInterface( const TInt32 /*aUid*/ )
-    {    
-    // No implementation needed
-    return NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::SetAttributesL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::SetAttributesL(
-    const RAttributeArray& aAttributes )
-    {
-    __LOG( "CUPnPXMLEventParser::SetAttributesL" );
-
-    RAttribute attribute;
-    TInt count = aAttributes.Count();
-    TInt volume = KErrNotFound;
-    iMasterVolumeState = EFalse;
-    for ( TInt i = 0; i < count ; i++ )
-        {
-        attribute = aAttributes[i];
-        const TDesC8& name = attribute.Attribute().LocalName().DesC();
-
-        if ( iParserState == EVolume )
-            {
-            // assign the value of Volume to volume 
-            if ( name.CompareF( KVal ) == KErrNone )
-                {
-                __LOG( "SetAttributesL - \"val\" found!" );
-                TLex8 lexer( attribute.Value().DesC() );
-                User::LeaveIfError( lexer.Val(volume) );
-                __LOG1( "SetAttributesL - volume = %d", volume );
-                }
-            else if ( name.CompareF( KChannel ) == KErrNone )
-                {
-                // channel is found, check if is Master
-                const TDesC8& channelname = attribute.Value().DesC();
-                if ( channelname.CompareF( KMaster ) == KErrNone )
-                    {
-                    __LOG( "SetAttributesL - MasterVolume found!" );
-                    iMasterVolumeState = ETrue;
-                    }
-                }
-            }
-        else
-            {
-
-            if ( name.Compare( KVal ) == KErrNone )
-                {
-                __LOG( "SetAttributesL - \"val\" found!" );
-
-                TLex8 lexer( attribute.Value().DesC() );
-                if ( iParserState == EInstanceID )
-                    {
-                    User::LeaveIfError( lexer.Val( iInstanceID ) );
-                    }
-                else
-                    if ( iParserState == EMute )
-                        {
-                        User::LeaveIfError( lexer.Val( iMute ) );
-                        }
-                    else
-                        {
-                        __LOG( "SetAttributesL - unknown state!" );
-                        }
-                }
-            }
-        }
-    
-    // check Mastervolume if was found, and volume if was found
-    if ( iParserState == EVolume && 
-         iMasterVolumeState && 
-         volume != KErrNotFound )
-        {
-        // all is found ,so assign the iVolume
-        __LOG1( "SetAttributesL - set iVolume : %d", volume );
-        iVolume = volume;       
-        }
-    
-    __LOG( "CUPnPXMLEventParser::SetAttributesL - End" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLEventParser::Reset
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLEventParser::Reset()
-    {
-    iInstanceID = KErrNotFound;
-    iMute = KErrNotFound;
-    iVolume = KErrNotFound;
-    iParserState = ENotSupported;
-    iMasterVolumeState = EFalse;
-    }
-      
-// end of file
-
+/*
+* Copyright (c) 2006,2009 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:      XML SAX Parser for UPnP.
+*
+*/
+
+#include <xml/parser.h>
+#include <xml/parserfeature.h>
+#include <upnpstring.h>
+#include <xml/matchdata.h>
+
+#include "upnpxmleventparser.h"
+#include "upnpavtevent.h"
+
+_LIT( KComponentLogfile, "upnpxmlparser.txt");
+#include "upnplog.h"
+
+_LIT8( KXmlMimeType,    "text/xml"     );
+_LIT8( KLIB2XML,        "libxml2" );
+
+_LIT8( KEvent,          "Event"         );
+_LIT8( KInstanceID,     "InstanceID"    );
+_LIT8( KVolume,         "Volume"        );
+_LIT8( KMute,           "Mute"          );
+_LIT8( KDIDL,           "DIDL-Lite"     );
+_LIT8( KDesc,           "desc"          );
+_LIT8( KDlnaDoc,        "X_DLNADOC"     );
+_LIT8( KVal,            "val"           );
+_LIT8( KChannel,        "channel"       );
+_LIT8( KMaster,         "Master"       );
+_LIT8( KTransportState, "TransportState" );
+_LIT8( KTransportURI,   "AVTransportURI" );
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::CUPnPXMLEventParser()
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+CUPnPXMLEventParser::CUPnPXMLEventParser()
+    {
+    // No implementation required
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::ConstructL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::ConstructL()
+    {
+    __LOG( "CUPnPXMLEventParser::CostructL" );
+    
+    iAvtEvent = CUPnPAVTEvent::NewL();
+    iAvtResultEvent = CUPnPAVTEvent::NewL();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::NewL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C CUPnPXMLEventParser* CUPnPXMLEventParser::NewL()
+    {
+    __LOG( "CUPnPXMLEventParser::NewL" );
+    CUPnPXMLEventParser* self = new( ELeave ) CUPnPXMLEventParser();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop(self);    
+    return self;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::~CUPnPXMLEventParser
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+CUPnPXMLEventParser::~CUPnPXMLEventParser()
+    {
+    __LOG( "CUPnPXMLEventParser::~CUPnPXMLEventParser" );
+    
+    delete iAvtEvent;
+    delete iAvtResultEvent;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::ParseRcEventDataL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C CUPnPAVTEvent* CUPnPXMLEventParser::ParseRcEventDataL(
+    const TDesC8& aData, const TInt aInstanceId )
+    {
+    __LOG( "CUPnPXMLEventParser::ParseRcEventDataL, begin" );
+    
+    if ( !aData.Length() )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    Reset();
+    ResetResult();
+    iSessionInstanceID = aInstanceId;
+        
+    // Create parser 
+    CMatchData* matchData = CMatchData::NewLC();
+    matchData->SetMimeTypeL( KXmlMimeType ); 
+    matchData->SetVariantL( KLIB2XML ); 
+    CParser* parser = CParser::NewLC( *matchData, *this ); 
+    parser->EnableFeature( Xml::EReportNamespaceMapping );
+    
+    Xml::ParseL( *parser, aData );    
+    
+    CleanupStack::PopAndDestroy( parser );
+    CleanupStack::PopAndDestroy( matchData );
+    
+    if( iAvtResultEvent->InstanceID() == KErrNotFound )
+        {
+        __LOG1( "CUPnPXMLEventParser::ParseRcEventDataL \
+instanceid not matching %d",  iSessionInstanceID );
+        User::Leave( KErrNotFound );
+        }  
+        
+    return CUPnPAVTEvent::CloneL( *iAvtResultEvent );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::ParseAVTEventDataL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C CUPnPAVTEvent* CUPnPXMLEventParser::ParseAvtEventDataL(
+    const TDesC8& aData, const TInt aInstanceId )
+    {
+    __LOG( "CUPnPXMLEventParser::ParseAvtEventDataL, begin" );
+    
+    if ( !aData.Length() )
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    Reset();
+    ResetResult();
+    iSessionInstanceID = aInstanceId;
+        
+    // Create parser 
+    CMatchData* matchData = CMatchData::NewLC();
+    matchData->SetMimeTypeL( KXmlMimeType ); 
+    matchData->SetVariantL( KLIB2XML ); 
+    CParser* parser = CParser::NewLC( *matchData, *this ); 
+    parser->EnableFeature( Xml::EReportNamespaceMapping );
+    
+    Xml::ParseL( *parser, aData );    
+    
+    CleanupStack::PopAndDestroy( parser );
+    CleanupStack::PopAndDestroy( matchData );
+    
+    if( iAvtResultEvent->InstanceID() == KErrNotFound )
+        {
+        __LOG1( "CUPnPXMLEventParser::ParseAvtEventDataL \
+instanceid not matching %d", iSessionInstanceID );
+        User::Leave( KErrNotFound );
+        }
+    
+    return CUPnPAVTEvent::CloneL( *iAvtResultEvent );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnStartDocumentL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnStartDocumentL( 
+                                const RDocumentParameters& /*aDocParam*/, 
+                                TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnEndDocumentL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnEndDocumentL( TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnStartElementL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnStartElementL( const RTagInfo& aElement, 
+                                      const RAttributeArray& aAttributes,
+                                      TInt aErrorCode )
+    {   
+    if ( aErrorCode != KErrNone )
+        {
+        __LOG1( "CUPnPXMLEventParser::OnStartElementL, error: %d",
+                                                                aErrorCode );
+        return;
+        }
+    const TDesC8& desName = aElement.LocalName().DesC();
+    __LOG8_1("CUPnPXMLEventParser::OnStartElementL name = %S", &desName );
+  
+    if ( !desName.CompareF( KEvent ) )
+        {
+        iParserState = EEvent;
+        }
+    else if ( !desName.CompareF( KInstanceID ) )
+        {
+        iParserState = EInstanceID;
+        SetAttributesL( aAttributes );
+        }
+    //Rc events
+    else if( !desName.CompareF( KVolume ) )
+        {
+        iParserState = EVolume;
+        SetAttributesL( aAttributes );
+        }
+    else if( !desName.CompareF( KMute ) )
+        {
+        iParserState = EMute;
+        SetAttributesL( aAttributes );
+        }  
+    // Avt events 
+    else if( !desName.CompareF( KTransportState ) )
+        {
+        iParserState = ETransportState;
+        SetAttributesL( aAttributes );
+        }
+    else if ( !desName.CompareF( KTransportURI ) )
+        {
+        iParserState = ETransportURI;
+        SetAttributesL( aAttributes );
+        }
+    
+    // Ignore DIDL-Lite, desc and X_DLNADOC -elements (DLNA req)
+    else if( desName.Compare( KDIDL ) == KErrNone ||
+             desName.Compare( KDesc ) == KErrNone ||
+             desName.Compare( KDlnaDoc ) == KErrNone    
+           )
+        {
+        // Ignore
+        }
+    else 
+        {
+        // just print attribute values
+        iParserState = ENotSupported;
+        SetAttributesL( aAttributes );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnEndElementL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnEndElementL( const RTagInfo& aElement, 
+                                    TInt /*aErrorCode*/ )
+    {
+    // if we have finished parsing one event,
+    // check that it belongs to our session
+    const TDesC8& desName = aElement.LocalName().DesC();
+    
+    if ( !desName.CompareF( KInstanceID ) )
+        {
+        if( iAvtEvent->InstanceID() == iSessionInstanceID )
+            {
+            iAvtResultEvent->Reset();
+            iAvtResultEvent->SetInstanceID( iAvtEvent->InstanceID() );
+            iAvtResultEvent->SetMute( iAvtEvent->Mute() );
+            iAvtResultEvent->SetVolume( iAvtEvent->Volume() );
+            iAvtResultEvent->SetTransportState( iAvtEvent->TransportState() );
+            iAvtResultEvent->SetTransportURIL( iAvtEvent->TransportURI() );
+            
+            __LOG( "CUPnPXMLEventParser::OnEndElementL() valid event" );
+            }
+        else
+            {
+            __LOG2( "CUPnPXMLEventParser OnEndElementL ERROR instanceid not \
+matching session %d, event %d", iSessionInstanceID, iAvtEvent->InstanceID());
+            }
+            
+        Reset();
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnContentL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnContentL( const TDesC8& /*aBytes*/,
+    TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnStartPrefixMappingL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, 
+                                               const RString& /*aUri*/, 
+                                               TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnEndPrefixMappingL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnEndPrefixMappingL( const RString& /*aPrefix*/, 
+                                             TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnIgnorableWhiteSpaceL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, 
+                                                TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnSkippedEntityL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnSkippedEntityL( const RString& /*aName*/, 
+                                          TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnProcessingInstructionL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnProcessingInstructionL(
+    const TDesC8& /*aTarget*/, const TDesC8& /*aData*/, TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::OnError
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::OnError( TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::GetExtendedInterface
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+TAny* CUPnPXMLEventParser::GetExtendedInterface( const TInt32 /*aUid*/ )
+    {    
+    // No implementation needed
+    return NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::SetAttributesL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::SetAttributesL(
+    const RAttributeArray& aAttributes )
+    {
+    RAttribute attribute;
+    TInt count = aAttributes.Count();
+    TInt volume = KErrNotFound;
+    iMasterVolumeState = EFalse;
+    
+    for ( TInt i = 0; i < count ; i++ )
+        {
+        attribute = aAttributes[i];
+        const TDesC8& name = attribute.Attribute().LocalName().DesC();
+        const TDesC8& value = attribute.Value().DesC();
+        if( value.Length() )
+            {
+            __LOG8_1( "CUPnPXMLEventParser::SetAttributesL value = %S",
+                    &value );
+            }
+        
+        // volume & channel
+        if ( iParserState == EVolume )
+            {
+            // assign the value of Volume to volume 
+            if ( name.CompareF( KVal ) == KErrNone )
+                {
+                TLex8 lexer( value );
+                User::LeaveIfError( lexer.Val(volume) );
+                }
+            else if ( name.CompareF( KChannel ) == KErrNone )
+                {
+                // channel is found, check if is Master
+                if ( value.CompareF( KMaster ) == KErrNone )
+                    {
+                    __LOG( "CUPnPXMLEventParser::SetAttributesL - \
+MasterVolume found!" );
+                    iMasterVolumeState = ETrue;
+                    }
+                }
+            }
+          
+          
+                     
+              
+        // other values
+        else if ( name.Compare( KVal ) == KErrNone )
+            {
+            TLex8 lexer( value );
+            
+            if ( iParserState == EInstanceID )
+                {
+                TInt id = KErrNotFound;
+                User::LeaveIfError( lexer.Val( id ) );
+                iAvtEvent->SetInstanceID( id );
+                }
+            else if ( iParserState == EMute )
+                {
+                TInt mute = KErrNotFound;
+                User::LeaveIfError( lexer.Val( mute ) );
+                iAvtEvent->SetMute( mute );
+                }
+            else if ( iParserState == ETransportState )
+                {
+                iAvtEvent->SetTransportState( value );
+                }
+            else if ( iParserState == ETransportURI )
+                {
+                iAvtEvent->SetTransportURIL( value );
+                }
+            else
+                {
+                __LOG( "CUPnPXMLEventParser::SetAttributesL - \
+unknown state" );
+                }
+            }
+        }
+    
+    // check Mastervolume and volume
+    if ( iParserState == EVolume && 
+         iMasterVolumeState && 
+         volume != KErrNotFound )
+        {
+        // all is found ,so assign the iVolume
+        __LOG1( "CUPnPXMLEventParser::SetAttributesL - set iVolume : %d",
+                                                                     volume );
+        iAvtEvent->SetVolume( volume );       
+        }
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::Reset
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::Reset()
+    {
+    iParserState = ENotSupported;
+    iMasterVolumeState = EFalse;
+    
+    iAvtEvent->Reset();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLEventParser::ResetResult
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLEventParser::ResetResult()
+    {
+    iSessionInstanceID = KErrNotFound;
+    iParserState = ENotSupported;
+    iMasterVolumeState = EFalse;
+    
+    iAvtResultEvent->Reset();
+    }     
+         
+// end of file
+
--- a/upnpavcontroller/upnpxmlparser/src/upnpxmlparser.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/src/upnpxmlparser.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,697 +1,698 @@
-/*
-* Copyright (c) 2008 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:      XML SAX Parser for UPnP.
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// xml parser api
-#include <xml/parser.h>
-#include <xml/parserfeature.h>
-#include <xml/matchdata.h>
-#include <xml/xmlparsererrors.h>
-
-// upnp stack api
-#include "upnpstring.h"
-#include <upnpcontainer.h>
-#include <upnpitem.h>
-#include "upnpelement.h"
-#include "upnpxmlparser.h"
-
-// upnpframework / internal api's
-#include "upnpcdsreselementutility.h"
-
-// xmlparser internal
-#include "upnpobjectstack.h"
-#include "upnpitemtoxml.h"
-#include "upnpxmlstringutility.h"
-#include "upnpxmlparser.h"
-
-_LIT( KComponentLogfile, "upnpxmlparser.txt");
-#include "upnplog.h"
-
-
-_LIT8( KXmlMimeType,    "text/xml"     );
-_LIT8( KLIB2XML,        "libxml2" );
-
-_LIT8( KContainer,      "container"    );
-_LIT8( KItem,           "item"         );
-
-_LIT8( KTitle,          "title"        );
-
-_LIT8( KClass,          "class"        );
-_LIT8( KContentURI,     "res"          );
-_LIT8( KId,             "id"           );
-_LIT8( KParentId,       "parentId"     );
-_LIT8( KRestricted,     "restricted"   );
-_LIT8( KComma,          ":"            );
-_LIT8( KTrue,           "1"            );
-_LIT8( KDIDL,           "DIDL-Lite"    );
-_LIT8( KDesc,           "desc"         );
-_LIT8( KDlnaDoc,        "X_DLNADOC"    );
-_LIT8( KSpace,          " "            );
-_LIT8( KImportUri,      "importUri"    );
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::CUPnPXMLParser()
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-CUPnPXMLParser::CUPnPXMLParser()
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::ConstructL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::ConstructL()
-    {
-    __LOG( "CUPnPXMLParser::CostructL" );
-    iStack = CUPnPObjectStack::NewL();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::NewL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C CUPnPXMLParser* CUPnPXMLParser::NewL()
-    {
-    CUPnPXMLParser* self = CUPnPXMLParser::NewLC();
-    CleanupStack::Pop( self );    
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::NewLC
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C CUPnPXMLParser* CUPnPXMLParser::NewLC()
-    {   
-    CUPnPXMLParser* self = new( ELeave ) CUPnPXMLParser();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::~CUPnPXMLParser
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-CUPnPXMLParser::~CUPnPXMLParser()
-    {
-    __LOG( "CUPnPXMLParser::~CUPnPXMLParser" );
-    if ( iStack )
-        {
-        iStack->ResetAndDestroy();
-        delete iStack;
-        }
-    
-    delete iElementValue;
-    delete iNewElement;
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::ResetMember
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::ResetMember()
-    {
-    iResultRoot->ResetAndDestroy();
-    iResultRoot = NULL;
-    iStack->ResetAndDestroy(); 
-    delete iStack;
-    iStack = NULL;
-
-    delete iElementValue; iElementValue = NULL;
-    delete iNewElement; iNewElement = NULL;
-    iTitle = 0;
-    iObjectClass = 0;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::ParseResultDataL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUPnPXMLParser::ParseResultDataL( 
-    RPointerArray<CUpnpObject>& aResultArray,
-    const TDesC8& aData )
-    {
-    __LOG( "CUPnPXMLParser::ParseResultDataL, begin" );
-    
-    if ( !aData.Length() )
-        {
-        User::Leave( KErrArgument );
-        }
-
-    iResultRoot = &aResultArray;
-
-    // Create parser 
-    CMatchData* matchData = CMatchData::NewLC();
-    matchData->SetMimeTypeL( KXmlMimeType ); 
-    matchData->SetVariantL( KLIB2XML ); 
-    CParser* parser = CParser::NewLC( *matchData, *this );
-    parser->EnableFeature( Xml::EReportNamespaceMapping );
-    
-    TRAPD( err, Xml::ParseL( *parser,aData ) );
-    // if the xml contained control character
-    if( EXmlInvalidToken == err )
-        {
-        __LOG1 ( "CUPnPXMLParser::ParseResultDataL Can not Parse \
-        		error code %d " ,err );
-        HBufC8* FiltrateBuffer = 
-            UpnpXmlStringUtility::RemoveXmlControlCharactersL( aData );
-        //if remove some control characters.
-        if( FiltrateBuffer )
-            {
-            CleanupStack::PushL( FiltrateBuffer );
-            ResetMember();
-
-            iStack = CUPnPObjectStack::NewL();
-            iResultRoot = &aResultArray;
-
-            Xml::ParseL( *parser, *FiltrateBuffer );
-            CleanupStack::PopAndDestroy( FiltrateBuffer );
-            }
-        else
-            {
-            User::Leave( err );
-            }
-        }
-    else if ( KErrNone != err )
-        {
-        User::Leave( err );
-        }
-    CleanupStack::PopAndDestroy( parser );
-    CleanupStack::PopAndDestroy( matchData );
-    
-    iResultRoot = NULL;           
-    __LOG( "CUPnPXMLParser::ParseResultDataL, end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::ItemAsXMLLC
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C HBufC8* CUPnPXMLParser::ItemAsXmlLC( const CUpnpItem& aItem )
-    {
-    CUpnpItemToXML* tmpXmlItem =  CUpnpItemToXML::NewLC( aItem );
-    HBufC8* raw  = tmpXmlItem->AsXmlL();
-    CleanupStack::PushL( raw );
-    
-    HBufC8* encoded = UpnpString::EncodeXmlStringL( raw );
-    CleanupStack::PopAndDestroy( raw );
-    CleanupStack::PushL( encoded );
-    
-    HBufC8* tagged = tmpXmlItem->CreateUnDecodedXmlL( *encoded );
-    CleanupStack::PopAndDestroy( encoded );
-    CleanupStack::PopAndDestroy( tmpXmlItem );
-    CleanupStack::PushL( tagged );
-    
-    return tagged;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::XmlForCreateObjectLC
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C HBufC8* CUPnPXMLParser::XmlForCreateObjectLC(
-    const CUpnpItem& aItem )
-    {
-    CUpnpItemToXML* tmpXmlItem = CUpnpItemToXML::NewLC( aItem );
-    HBufC8* tempXmlDataBlock = tmpXmlItem->AsResultArgumentL();
-    CleanupStack::PopAndDestroy( tmpXmlItem );
-    CleanupStack::PushL( tempXmlDataBlock );
-    
-    return tempXmlDataBlock;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::ContainerToXmlLC
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C HBufC8* CUPnPXMLParser::ContainerToXmlLC(
-    const CUpnpContainer& /*aContainer*/ )
-    {
-    // Not implemented
-    User::Leave( KErrNotSupported );
-    
-    return NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnStartDocumentL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnStartDocumentL( 
-                                const RDocumentParameters& /*aDocParam*/, 
-                                TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnEndDocumentL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnEndDocumentL( TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnStartElementL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnStartElementL( const RTagInfo& aElement, 
-                                      const RAttributeArray& aAttributes,
-                                      TInt aErrorCode )
-    {
-    __LOG1( "CUPnPXMLParser::OnStartElementL, error code: %d", aErrorCode );
-    if ( aErrorCode != KErrNone )
-        {
-        return;
-        }
-    const TDesC8& desName = aElement.LocalName().DesC();
-    const TDesC8& prefix = aElement.Prefix().DesC();
-    
-    // Delete content, since there may be some stuff between the elements
-    // (comments, whitespace etc.)
-    delete iElementValue; iElementValue = NULL;    
-      
-    if ( !desName.CompareF( KContainer ) ) // Container element
-        {
-        CUpnpContainer* tmpContainer = CUpnpContainer::NewL();
-        CleanupStack::PushL( tmpContainer );
-
-        SetAttributesL( *tmpContainer, aAttributes );
-        //push into the stack, ownership is transferred                      
-        iStack->PushL( tmpContainer ); 
-        
-        CleanupStack::Pop( tmpContainer );
-        }
-    else if ( !desName.CompareF( KItem ) ) // Item element
-        {
-        CUpnpItem* tmpItem = CUpnpItem::NewL();
-        CleanupStack::PushL( tmpItem );
-
-        SetAttributesL( *tmpItem, aAttributes );                      
-        //push into the stack, ownership is transferred                      
-        iStack->PushL( tmpItem );
-        
-        CleanupStack::Pop( tmpItem );
-        }
-    else if( !desName.CompareF( KTitle ) ) // Title element
-        {
-        // check that we have item or container. cause leave if not
-        if ( iStack->Count() == 0)
-            {
-            User::Leave( KErrArgument );
-            }
-        // We should have an item or a container already!
-        //__ASSERTD( iStack->Top(), __FILE__, __LINE__ );
-        iTitle = ETrue;
-        }
-    else if( !desName.CompareF( KClass ) ) // Object class element
-        {
-        // check that we have item or container. cause leave if not
-        if ( iStack->Count() == 0)
-            {
-            User::Leave( KErrArgument );
-            }
-        // We should have an item or a container already!
-       // __ASSERTD( iStack->Top(), __FILE__, __LINE__ );
-        iObjectClass = ETrue;
-        }
-    // Ignore DIDL-Lite, desc and X_DLNADOC -elements (DLNA req)
-    else if( desName.Compare( KDIDL ) == KErrNone ||
-             desName.Compare( KDesc ) == KErrNone ||
-             desName.Compare( KDlnaDoc ) == KErrNone    
-           )
-        {
-        // Ignore
-        }
-    else 
-        {
-        // check that we have item or container. cause leave if not
-        if ( iStack->Count() == 0)
-            {
-            User::Leave( KErrArgument );
-            }
-        
-        // We should have an item or a container already!    
-        //__ASSERTD( iStack->Top(), __FILE__, __LINE__ );
-        
-        if( prefix.Length() > 0 ) // If there is a namespace (upnp: etc)
-            {
-            HBufC8* name = HBufC8::NewLC( prefix.Length() +
-            KComma().Length() + desName.Length() ) ;
-            name->Des().Copy( prefix );
-            name->Des().Append( KComma );
-            name->Des().Append( desName );
-            
-            // Create a new element
-            __ASSERTD( !iNewElement, __FILE__, __LINE__ );
-            iNewElement = CUpnpElement::NewL( *name );
-        
-            CleanupStack::PopAndDestroy( name );
-            }
-        else
-            {
-            // Create a new element
-            __ASSERTD( !iNewElement, __FILE__, __LINE__ );
-            iNewElement = CUpnpElement::NewL( desName );
-            }
-        
-        // Set attributes for element
-        SetAttributesL( aAttributes );
-        }
-    __LOG( "CUPnPXMLParser::OnEndElementL, end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnEndElementL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnEndElementL( const RTagInfo& aElement, 
-                                    TInt aErrorCode )
-    {
-    __LOG( "CUPnPXMLSAXParser::OnEndElementL(), begin" );
-    if ( aErrorCode != KErrNone )
-        {
-        return;
-        }
-        
-    const TDesC8& desName = aElement.LocalName().DesC();    
-    if ( !desName.CompareF( KContainer ) || !desName.CompareF( KItem ) )
-        {
-        iResultRoot->AppendL( iStack->Top() );
-        iStack->Pop(); // Remove object from stack.
-        }
-    else if( KErrNone != desName.CompareF( KDIDL ))
-        {        
-        CUpnpObject* obj = (CUpnpObject*)iStack->Top();
-        __ASSERTD( obj, __FILE__, __LINE__ );
-             
-        if ( iElementValue )
-            {
-            SetValueToElementL( *obj, *iElementValue );
-            }
-        else
-            {
-            SetValueToElementL( *obj, KNullDesC8 );
-            }    
-        
-        delete iElementValue; iElementValue = NULL;    
-        }    
-    __LOG( "CUPnPXMLSAXParser::OnEndElementL(), end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnContentL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnContentL( const TDesC8& aBytes, TInt aErrorCode )
-    {
-    __LOG( "CUPnPXMLSAXParser::OnContentL(), begin" );
-    if ( !iStack->Count() || aErrorCode != KErrNone )
-        {
-        return;
-        }
-    
-    if( !iElementValue ) //if 1st time
-        {
-        iElementValue = HBufC8::NewL(aBytes.Length());
-        iElementValue->Des().Copy(aBytes); 
-        }
-    else
-        {
-        HBufC8* previousValue = iElementValue;
-        iElementValue = HBufC8::NewL( previousValue->Des().Length() +
-                                      aBytes.Length() );
-        iElementValue->Des().Append( *previousValue );
-        iElementValue->Des().Append( aBytes );
-        delete previousValue;
-        } 
-    __LOG( "CUPnPXMLSAXParser::OnContentL(), end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnStartPrefixMappingL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, 
-                                               const RString& /*aUri*/, 
-                                               TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnEndPrefixMappingL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnEndPrefixMappingL( const RString& /*aPrefix*/, 
-                                             TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnIgnorableWhiteSpaceL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, 
-                                                TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnSkippedEntityL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnSkippedEntityL( const RString& /*aName*/, 
-                                          TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnProcessingInstructionL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnProcessingInstructionL( const TDesC8& /*aTarget*/, 
-                                                  const TDesC8& /*aData*/, 
-                                                  TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::OnError
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::OnError( TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::GetExtendedInterface
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-TAny* CUPnPXMLParser::GetExtendedInterface( const TInt32 /*aUid*/ )
-    {    
-    // No implementation needed
-    return NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::SetAttributesL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::SetAttributesL( CUpnpObject& aObject, 
-    const RAttributeArray& aAttributes )
-    {
-    __LOG( "CUPnPXMLParser::SetAttributesL" );
-    
-    if ( iStack->Count() )
-        {
-        // Object has a parent.
-        // Should not really happen, but implemented anyways
-        __LOG( "Object has a parent!" );
-        
-        if ( iStack->Top()->ObjectType() != EUPnPContainer )
-            {
-            User::Leave( KErrArgument );
-            }
-        CUpnpContainer* container = (CUpnpContainer*)iStack->Top();
-        container->AppendObjectL( aObject );
-        }
-        
-    RAttribute attribute;
-    TInt count = aAttributes.Count();
-    for ( TInt i = 0 ; i < count; i++ ) // Read attributes.
-        {
-        attribute = aAttributes[ i ];
-        const TDesC8& name = attribute.Attribute().LocalName().DesC();
-        
-        if( !name.CompareF( KId ) )
-            {
-            aObject.SetIdL( attribute.Value().DesC() );
-            }
-        if( !name.CompareF( KParentId ) )
-            {
-            aObject.SetParentIdL( attribute.Value().DesC() );
-            }            
-        if( !name.CompareF( KRestricted ) ) 
-            {
-            if ( !attribute.Value().DesC().CompareF( KTrue ) ) // restricted
-                {
-                aObject.SetRestricted( ETrue );
-                }
-            else // no restriction
-                {
-                aObject.SetRestricted( EFalse );
-                }
-            }
-        }
-    __LOG( "CUPnPXMLParser::SetAttributesL - End" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::SetValueToElementL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::SetValueToElementL( CUpnpObject& aItem,
-    const TDesC8& aValue )
-    {
-    __LOG( "CUPnPXMLParser::SetValueToElementL()" );
-
-    if( iTitle )
-        {
-        __LOG( "SetValueToElementL() - title element" );
-        aItem.SetTitleL( aValue );
-        iTitle = EFalse;
-        }
-    else if( iObjectClass )
-        {
-        __LOG( "SetValueToElementL() - objectclass element" );
-        aItem.SetObjectClassL( aValue );  
-        iObjectClass = EFalse;
-        }
-    // See if it's the res-element   
-    else if( iNewElement && // NULL Check
-             iNewElement->Name().Compare( KContentURI ) == KErrNone )
-        {
-        __LOG( "SetValueToElementL() - res element" ); 
-                
-        // Check that uri is absolute
-        if( UpnpCdsResElementUtility::IsUriAbsolute( aValue ) )
-            {
-            __LOG( "valid res-element" );
-            iNewElement->SetValueL( aValue );
-            aItem.AddElementL( iNewElement ); // Ownership is transferred
-            iNewElement = NULL;                
-            }
-        else
-            { 
-            // if CreateObjectResponse, there is importuri
-            // no need to check res-element
-            TInt found = EFalse;
-            RUPnPAttributesArray elArray = iNewElement->GetAttributes();
-            TInt count = elArray.Count(); 
-            for( TInt i = 0; i < count; i++ )
-                {
-                if( elArray[ i ]->Name() == KImportUri )
-                    {
-                    i = count;
-                    found = ETrue;
-                    __LOG( "SetValueToElementL() - ImportUri found" );
-                    }
-                }
-                              
-            if( found )     
-                {
-                __LOG( "no res-element but import uri found" );
-                iNewElement->SetValueL( KNullDesC8 );
-                aItem.AddElementL( iNewElement ); // Ownership is transferred
-                iNewElement = NULL;                   
-                }  
-            else
-                {
-                __LOG( "invalid res-element" );
-                delete iNewElement;
-                iNewElement = NULL;                
-                }           
-            }
-  
-        }
-    else 
-        {
-        __LOG( "SetValueToElementL() - unknown element" );
-        if( iNewElement )
-            {
-            // Check for empty values
-            if( aValue == KNullDesC8 || aValue == KSpace )
-                {
-                // Do not add empty values
-                delete iNewElement; iNewElement = NULL;                
-                }
-            else
-                {
-                iNewElement->SetValueL( aValue );
-                aItem.AddElementL( iNewElement ); // Ownership is transferred
-                iNewElement = NULL;                
-                }    
-            }
-        }
-        
-    __LOG( "CUPnPXMLParser::SetValueToElementL() End" ); 
-    }
-
-    
-// --------------------------------------------------------------------------
-// CUPnPXMLParser::SetAttributesL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParser::SetAttributesL( const RAttributeArray& aAttributes )
-    {
-    __LOG( "CUPnPXMLParser::SetAttributesL" );
-    
-    RAttribute attribute;
-    TInt count = aAttributes.Count();
-    for ( TInt i = 0; i < count ; i++ )
-        {
-        attribute = aAttributes[i];
-        const TDesC8& name = attribute.Attribute().LocalName().DesC();
-        CUpnpAttribute* att = CUpnpAttribute::NewLC();
-        att->SetNameL( name );
-        att->SetValueL( attribute.Value().DesC() );
-        __ASSERTD( iNewElement, __FILE__, __LINE__ );
-        iNewElement->AddAttributeL( att );
-        CleanupStack::Pop( att );     
-        }
-    __LOG( "CUPnPXMLParser::SetAttributesL End" );    
-    }
-    
-// end of file
-
+/*
+* Copyright (c) 2008 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:      XML SAX Parser for UPnP.
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// system / xml parser api
+#include <xml/parser.h>
+#include <xml/parserfeature.h>
+#include <xml/matchdata.h>
+#include <xml/xmlparsererrors.h>
+
+// upnp stack api
+#include <upnpstring.h>
+
+// dlnasrv / mediaserver api
+#include <upnpcontainer.h>
+#include <upnpitem.h>
+#include <upnpelement.h>
+
+// dlnasrv / internal api's
+#include "upnpcdsreselementutility.h"
+
+// dlnasrv / xmlparser internal
+#include "upnpobjectstack.h"
+#include "upnpitemtoxml.h"
+#include "upnpxmlstringutility.h"
+#include "upnpxmlparser.h"
+
+_LIT( KComponentLogfile, "upnpxmlparser.txt");
+#include "upnplog.h"
+
+
+_LIT8( KXmlMimeType,    "text/xml"     );
+_LIT8( KLIB2XML,        "libxml2" );
+
+_LIT8( KContainer,      "container"    );
+_LIT8( KItem,           "item"         );
+
+_LIT8( KTitle,          "title"        );
+
+_LIT8( KClass,          "class"        );
+_LIT8( KContentURI,     "res"          );
+_LIT8( KId,             "id"           );
+_LIT8( KParentId,       "parentId"     );
+_LIT8( KRestricted,     "restricted"   );
+_LIT8( KComma,          ":"            );
+_LIT8( KTrue,           "1"            );
+_LIT8( KDIDL,           "DIDL-Lite"    );
+_LIT8( KDesc,           "desc"         );
+_LIT8( KDlnaDoc,        "X_DLNADOC"    );
+_LIT8( KSpace,          " "            );
+_LIT8( KImportUri,      "importUri"    );
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::CUPnPXMLParser()
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+CUPnPXMLParser::CUPnPXMLParser()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::ConstructL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::ConstructL()
+    {
+    __LOG( "CUPnPXMLParser::CostructL" );
+    iStack = CUPnPObjectStack::NewL();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::NewL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C CUPnPXMLParser* CUPnPXMLParser::NewL()
+    {
+    CUPnPXMLParser* self = CUPnPXMLParser::NewLC();
+    CleanupStack::Pop( self );    
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::NewLC
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C CUPnPXMLParser* CUPnPXMLParser::NewLC()
+    {   
+    CUPnPXMLParser* self = new( ELeave ) CUPnPXMLParser();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::~CUPnPXMLParser
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+CUPnPXMLParser::~CUPnPXMLParser()
+    {
+    __LOG( "CUPnPXMLParser::~CUPnPXMLParser" );
+    if ( iStack )
+        {
+        iStack->ResetAndDestroy();
+        delete iStack;
+        }
+    
+    delete iElementValue;
+    delete iNewElement;
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::ResetMember
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::ResetMember()
+    {
+    iResultRoot->ResetAndDestroy();
+    iResultRoot = NULL;
+    iStack->ResetAndDestroy(); 
+    delete iStack;
+    iStack = NULL;
+
+    delete iElementValue; iElementValue = NULL;
+    delete iNewElement; iNewElement = NULL;
+    iTitle = 0;
+    iObjectClass = 0;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::ParseResultDataL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUPnPXMLParser::ParseResultDataL( 
+    RPointerArray<CUpnpObject>& aResultArray,
+    const TDesC8& aData )
+    {
+    __LOG( "CUPnPXMLParser::ParseResultDataL, begin" );
+    
+    if ( !aData.Length() )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    iResultRoot = &aResultArray;
+
+    // Create parser 
+    CMatchData* matchData = CMatchData::NewLC();
+    matchData->SetMimeTypeL( KXmlMimeType ); 
+    matchData->SetVariantL( KLIB2XML ); 
+    CParser* parser = CParser::NewLC( *matchData, *this );
+    parser->EnableFeature( Xml::EReportNamespaceMapping );
+    
+    TRAPD( err, Xml::ParseL( *parser,aData ) );
+    // if the xml contained control character
+    if( EXmlInvalidToken == err )
+        {
+        __LOG1 ( "CUPnPXMLParser::ParseResultDataL Can not Parse \
+        		error code %d " ,err );
+        HBufC8* FiltrateBuffer = 
+            UpnpXmlStringUtility::RemoveXmlControlCharactersL( aData );
+        //if remove some control characters.
+        if( FiltrateBuffer )
+            {
+            CleanupStack::PushL( FiltrateBuffer );
+            ResetMember();
+
+            iStack = CUPnPObjectStack::NewL();
+            iResultRoot = &aResultArray;
+
+            Xml::ParseL( *parser, *FiltrateBuffer );
+            CleanupStack::PopAndDestroy( FiltrateBuffer );
+            }
+        else
+            {
+            User::Leave( err );
+            }
+        }
+    else if ( KErrNone != err )
+        {
+        User::Leave( err );
+        }
+    CleanupStack::PopAndDestroy( parser );
+    CleanupStack::PopAndDestroy( matchData );
+    
+    iResultRoot = NULL;           
+    __LOG( "CUPnPXMLParser::ParseResultDataL, end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::ItemAsXMLLC
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C HBufC8* CUPnPXMLParser::ItemAsXmlLC( const CUpnpItem& aItem )
+    {
+    CUpnpItemToXML* tmpXmlItem =  CUpnpItemToXML::NewLC( aItem );
+    HBufC8* raw  = tmpXmlItem->AsXmlL();
+    CleanupStack::PushL( raw );
+    
+    HBufC8* encoded = UpnpString::EncodeXmlStringL( raw );
+    CleanupStack::PopAndDestroy( raw );
+    CleanupStack::PushL( encoded );
+    
+    HBufC8* tagged = tmpXmlItem->CreateUnDecodedXmlL( *encoded );
+    CleanupStack::PopAndDestroy( encoded );
+    CleanupStack::PopAndDestroy( tmpXmlItem );
+    CleanupStack::PushL( tagged );
+    
+    return tagged;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::XmlForCreateObjectLC
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C HBufC8* CUPnPXMLParser::XmlForCreateObjectLC(
+    const CUpnpItem& aItem )
+    {
+    CUpnpItemToXML* tmpXmlItem = CUpnpItemToXML::NewLC( aItem );
+    HBufC8* tempXmlDataBlock = tmpXmlItem->AsResultArgumentL();
+    CleanupStack::PopAndDestroy( tmpXmlItem );
+    CleanupStack::PushL( tempXmlDataBlock );
+    
+    return tempXmlDataBlock;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::ContainerToXmlLC
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C HBufC8* CUPnPXMLParser::ContainerToXmlLC(
+    const CUpnpContainer& /*aContainer*/ )
+    {
+    // Not implemented
+    User::Leave( KErrNotSupported );
+    
+    return NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnStartDocumentL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnStartDocumentL( 
+                                const RDocumentParameters& /*aDocParam*/, 
+                                TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnEndDocumentL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnEndDocumentL( TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnStartElementL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnStartElementL( const RTagInfo& aElement, 
+                                      const RAttributeArray& aAttributes,
+                                      TInt aErrorCode )
+    {
+    __LOG1( "CUPnPXMLParser::OnStartElementL, error code: %d", aErrorCode );
+    if ( aErrorCode != KErrNone )
+        {
+        return;
+        }
+    const TDesC8& desName = aElement.LocalName().DesC();
+    const TDesC8& prefix = aElement.Prefix().DesC();
+    
+    // Delete content, since there may be some stuff between the elements
+    // (comments, whitespace etc.)
+    delete iElementValue; iElementValue = NULL;    
+      
+    if ( !desName.CompareF( KContainer ) ) // Container element
+        {
+        CUpnpContainer* tmpContainer = CUpnpContainer::NewL();
+        CleanupStack::PushL( tmpContainer );
+
+        SetAttributesL( *tmpContainer, aAttributes );
+        //push into the stack, ownership is transferred                      
+        iStack->PushL( tmpContainer ); 
+        
+        CleanupStack::Pop( tmpContainer );
+        }
+    else if ( !desName.CompareF( KItem ) ) // Item element
+        {
+        CUpnpItem* tmpItem = CUpnpItem::NewL();
+        CleanupStack::PushL( tmpItem );
+
+        SetAttributesL( *tmpItem, aAttributes );                      
+        //push into the stack, ownership is transferred                      
+        iStack->PushL( tmpItem );
+        
+        CleanupStack::Pop( tmpItem );
+        }
+    else if( !desName.CompareF( KTitle ) ) // Title element
+        {
+        // check that we have item or container. cause leave if not
+        if ( iStack->Count() == 0)
+            {
+            User::Leave( KErrArgument );
+            }
+        // We should have an item or a container already!
+        //__ASSERTD( iStack->Top(), __FILE__, __LINE__ );
+        iTitle = ETrue;
+        }
+    else if( !desName.CompareF( KClass ) ) // Object class element
+        {
+        // check that we have item or container. cause leave if not
+        if ( iStack->Count() == 0)
+            {
+            User::Leave( KErrArgument );
+            }
+        // We should have an item or a container already!
+       // __ASSERTD( iStack->Top(), __FILE__, __LINE__ );
+        iObjectClass = ETrue;
+        }
+    // Ignore DIDL-Lite, desc and X_DLNADOC -elements (DLNA req)
+    else if( desName.Compare( KDIDL ) == KErrNone ||
+             desName.Compare( KDesc ) == KErrNone ||
+             desName.Compare( KDlnaDoc ) == KErrNone    
+           )
+        {
+        // Ignore
+        }
+    else 
+        {
+        // check that we have item or container. cause leave if not
+        if ( iStack->Count() == 0)
+            {
+            User::Leave( KErrArgument );
+            }
+        
+        // We should have an item or a container already!    
+        //__ASSERTD( iStack->Top(), __FILE__, __LINE__ );
+        
+        if( prefix.Length() > 0 ) // If there is a namespace (upnp: etc)
+            {
+            HBufC8* name = HBufC8::NewLC( prefix.Length() +
+            KComma().Length() + desName.Length() ) ;
+            name->Des().Copy( prefix );
+            name->Des().Append( KComma );
+            name->Des().Append( desName );
+            
+            // Create a new element
+            __ASSERTD( !iNewElement, __FILE__, __LINE__ );
+            iNewElement = CUpnpElement::NewL( *name );
+        
+            CleanupStack::PopAndDestroy( name );
+            }
+        else
+            {
+            // Create a new element
+            __ASSERTD( !iNewElement, __FILE__, __LINE__ );
+            iNewElement = CUpnpElement::NewL( desName );
+            }
+        
+        // Set attributes for element
+        SetAttributesL( aAttributes );
+        }
+    __LOG( "CUPnPXMLParser::OnEndElementL, end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnEndElementL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnEndElementL( const RTagInfo& aElement, 
+                                    TInt aErrorCode )
+    {
+    __LOG( "CUPnPXMLSAXParser::OnEndElementL(), begin" );
+    if ( aErrorCode != KErrNone )
+        {
+        return;
+        }
+        
+    const TDesC8& desName = aElement.LocalName().DesC();    
+    if ( !desName.CompareF( KContainer ) || !desName.CompareF( KItem ) )
+        {
+        iResultRoot->AppendL( iStack->Top() );
+        iStack->Pop(); // Remove object from stack.
+        }
+    else if( KErrNone != desName.CompareF( KDIDL ))
+        {        
+        CUpnpObject* obj = (CUpnpObject*)iStack->Top();
+        __ASSERTD( obj, __FILE__, __LINE__ );
+             
+        if ( iElementValue )
+            {
+            SetValueToElementL( *obj, *iElementValue );
+            }
+        else
+            {
+            SetValueToElementL( *obj, KNullDesC8 );
+            }    
+        
+        delete iElementValue; iElementValue = NULL;    
+        }    
+    __LOG( "CUPnPXMLSAXParser::OnEndElementL(), end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnContentL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnContentL( const TDesC8& aBytes, TInt aErrorCode )
+    {
+    __LOG( "CUPnPXMLSAXParser::OnContentL(), begin" );
+    if ( !iStack->Count() || aErrorCode != KErrNone )
+        {
+        return;
+        }
+    
+    if( !iElementValue ) //if 1st time
+        {
+        iElementValue = HBufC8::NewL(aBytes.Length());
+        iElementValue->Des().Copy(aBytes); 
+        }
+    else
+        {
+        HBufC8* previousValue = iElementValue;
+        iElementValue = HBufC8::NewL( previousValue->Des().Length() +
+                                      aBytes.Length() );
+        iElementValue->Des().Append( *previousValue );
+        iElementValue->Des().Append( aBytes );
+        delete previousValue;
+        } 
+    __LOG( "CUPnPXMLSAXParser::OnContentL(), end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnStartPrefixMappingL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnStartPrefixMappingL( const RString& /*aPrefix*/, 
+                                               const RString& /*aUri*/, 
+                                               TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnEndPrefixMappingL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnEndPrefixMappingL( const RString& /*aPrefix*/, 
+                                             TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnIgnorableWhiteSpaceL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, 
+                                                TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnSkippedEntityL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnSkippedEntityL( const RString& /*aName*/, 
+                                          TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnProcessingInstructionL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnProcessingInstructionL( const TDesC8& /*aTarget*/, 
+                                                  const TDesC8& /*aData*/, 
+                                                  TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::OnError
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::OnError( TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::GetExtendedInterface
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+TAny* CUPnPXMLParser::GetExtendedInterface( const TInt32 /*aUid*/ )
+    {    
+    // No implementation needed
+    return NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::SetAttributesL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::SetAttributesL( CUpnpObject& aObject, 
+    const RAttributeArray& aAttributes )
+    {
+    __LOG( "CUPnPXMLParser::SetAttributesL" );
+    
+    if ( iStack->Count() )
+        {
+        // Object has a parent.
+        // Should not really happen, but implemented anyways
+        __LOG( "Object has a parent!" );
+        
+        if ( iStack->Top()->ObjectType() != EUPnPContainer )
+            {
+            User::Leave( KErrArgument );
+            }
+        CUpnpContainer* container = (CUpnpContainer*)iStack->Top();
+        container->AppendObjectL( aObject );
+        }
+        
+    RAttribute attribute;
+    TInt count = aAttributes.Count();
+    for ( TInt i = 0 ; i < count; i++ ) // Read attributes.
+        {
+        attribute = aAttributes[ i ];
+        const TDesC8& name = attribute.Attribute().LocalName().DesC();
+        
+        if( !name.CompareF( KId ) )
+            {
+            aObject.SetIdL( attribute.Value().DesC() );
+            }
+        if( !name.CompareF( KParentId ) )
+            {
+            aObject.SetParentIdL( attribute.Value().DesC() );
+            }            
+        if( !name.CompareF( KRestricted ) ) 
+            {
+            if ( !attribute.Value().DesC().CompareF( KTrue ) ) // restricted
+                {
+                aObject.SetRestricted( ETrue );
+                }
+            else // no restriction
+                {
+                aObject.SetRestricted( EFalse );
+                }
+            }
+        }
+    __LOG( "CUPnPXMLParser::SetAttributesL - End" );
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::SetValueToElementL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::SetValueToElementL( CUpnpObject& aItem,
+    const TDesC8& aValue )
+    {
+    __LOG( "CUPnPXMLParser::SetValueToElementL()" );
+
+    if( iTitle )
+        {
+        __LOG( "SetValueToElementL() - title element" );
+        aItem.SetTitleL( aValue );
+        iTitle = EFalse;
+        }
+    else if( iObjectClass )
+        {
+        __LOG( "SetValueToElementL() - objectclass element" );
+        aItem.SetObjectClassL( aValue );  
+        iObjectClass = EFalse;
+        }
+    // See if it's the res-element   
+    else if( iNewElement && // NULL Check
+             iNewElement->Name().Compare( KContentURI ) == KErrNone )
+        {
+        __LOG( "SetValueToElementL() - res element" ); 
+                
+        // Check that uri is absolute
+        if( UpnpCdsResElementUtility::IsUriAbsolute( aValue ) )
+            {
+            __LOG( "valid res-element" );
+            iNewElement->SetValueL( aValue );
+            aItem.AddElementL( iNewElement ); // Ownership is transferred
+            iNewElement = NULL;                
+            }
+        else
+            { 
+            // if CreateObjectResponse, there is importuri
+            // no need to check res-element
+            TInt found = EFalse;
+            RUPnPAttributesArray elArray = iNewElement->GetAttributes();
+            TInt count = elArray.Count(); 
+            for( TInt i = 0; i < count; i++ )
+                {
+                if( elArray[ i ]->Name() == KImportUri )
+                    {
+                    i = count;
+                    found = ETrue;
+                    __LOG( "SetValueToElementL() - ImportUri found" );
+                    }
+                }
+                              
+            if( found )     
+                {
+                __LOG( "no res-element but import uri found" );
+                iNewElement->SetValueL( KNullDesC8 );
+                aItem.AddElementL( iNewElement ); // Ownership is transferred
+                iNewElement = NULL;                   
+                }  
+            else
+                {
+                __LOG( "invalid res-element" );
+                delete iNewElement;
+                iNewElement = NULL;                
+                }           
+            }
+  
+        }
+    else 
+        {
+        __LOG( "SetValueToElementL() - unknown element" );
+        if( iNewElement )
+            {
+            // Check for empty values
+            if( aValue == KNullDesC8 || aValue == KSpace )
+                {
+                // Do not add empty values
+                delete iNewElement; iNewElement = NULL;                
+                }
+            else
+                {
+                iNewElement->SetValueL( aValue );
+                aItem.AddElementL( iNewElement ); // Ownership is transferred
+                iNewElement = NULL;                
+                }    
+            }
+        }
+        
+    __LOG( "CUPnPXMLParser::SetValueToElementL() End" ); 
+    }
+
+    
+// --------------------------------------------------------------------------
+// CUPnPXMLParser::SetAttributesL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParser::SetAttributesL( const RAttributeArray& aAttributes )
+    {
+    __LOG( "CUPnPXMLParser::SetAttributesL" );
+    
+    RAttribute attribute;
+    TInt count = aAttributes.Count();
+    for ( TInt i = 0; i < count ; i++ )
+        {
+        attribute = aAttributes[i];
+        const TDesC8& name = attribute.Attribute().LocalName().DesC();
+        CUpnpAttribute* att = CUpnpAttribute::NewLC();
+        att->SetNameL( name );
+        att->SetValueL( attribute.Value().DesC() );
+        __ASSERTD( iNewElement, __FILE__, __LINE__ );
+        iNewElement->AddAttributeL( att );
+        CleanupStack::Pop( att );     
+        }
+    __LOG( "CUPnPXMLParser::SetAttributesL End" );    
+    }
+    
+// end of file
+
--- a/upnpavcontroller/upnpxmlparser/src/upnpxmlparserlite.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpavcontroller/upnpxmlparser/src/upnpxmlparserlite.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,507 +1,512 @@
-/*
-* Copyright (c) 2008 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:      XML SAX Parser for UPnP.
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// xml parser
-#include <xml/parser.h>
-#include <xml/parserfeature.h>
-#include <xml/matchdata.h>
-
-// upnp stack api
-#include <upnpstring.h>
-
-// upnpframework / xmlparser api
-#include "upnpxmlparserlite.h"
-#include "upnpobjectlite.h"
-
-// xmlparser internal
-#include "upnpobjectstacklite.h"
-
-
-_LIT( KComponentLogfile, "upnpxmlparser.txt");
-#include "upnplog.h"
-
-_LIT8( KXmlMimeType,    "text/xml"     );
-_LIT8( KLIB2XML,        "libxml2" );
-
-_LIT8( KContainer,      "container"    );
-_LIT8( KItem,           "item"         );
-_LIT8( KTitle,          "title"        );
-_LIT8( KClass,          "class"        );
-_LIT8( KId,             "id"           );
-//_LIT8( KComma,          ":"            );
-_LIT8( KDIDL,           "DIDL-Lite"    );
-_LIT8( KDesc,           "desc"         );
-_LIT8( KDlnaDoc,        "X_DLNADOC"    );
-
-_LIT( KIndexContainer,  "1" );
-_LIT( KIndexAudio,      "2" );
-_LIT( KIndexVideo,      "3" );
-_LIT( KIndexImage,      "4" );
-_LIT( KIndexOther,      "5" );
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::CUPnPXMLParserLite()
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-CUPnPXMLParserLite::CUPnPXMLParserLite()
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::ConstructL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::ConstructL()
-    {
-    __LOG( "CUPnPXMLParserLite::CostructL" );
-    iStack = CUPnPObjectStackLite::NewL();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::NewL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C CUPnPXMLParserLite* CUPnPXMLParserLite::NewL()
-    {
-    CUPnPXMLParserLite* self = CUPnPXMLParserLite::NewLC();
-    CleanupStack::Pop( self );    
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::NewLC
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C CUPnPXMLParserLite* CUPnPXMLParserLite::NewLC()
-    {   
-    CUPnPXMLParserLite* self = new( ELeave ) CUPnPXMLParserLite();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-    
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::~CUPnPXMLParserLite
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-CUPnPXMLParserLite::~CUPnPXMLParserLite()
-    {
-    __LOG( "CUPnPXMLParserLite::~CUPnPXMLParserLite" );
-    if ( iStack )
-        {
-        iStack->ResetAndDestroy();
-        delete iStack;
-        }
-    
-    delete iElementValue;
-    delete iFormatString;
-    delete iTitleBuf;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::ParseResultDataL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-EXPORT_C void CUPnPXMLParserLite::ParseResultDataL(
-    RPointerArray<CUpnpObjectLite>& aResultArray, const TDesC8& aData,
-    const TDesC& aFormatString )
-    {
-    __LOG( "CUPnPXMLParserLite::ParseResultDataL, begin" );
-    
-    delete iFormatString; iFormatString = NULL;
-    if( aFormatString != KNullDesC )
-        {
-        iFormatString = aFormatString.AllocL();
-        }
-    
-    if ( !aData.Length() )
-        {
-        User::Leave( KErrArgument );
-        }
-        
-    iResultRoot = &aResultArray;
-
-    // Create parser 
-    CMatchData* matchData = CMatchData::NewLC();
-    matchData->SetMimeTypeL( KXmlMimeType ); 
-    matchData->SetVariantL( KLIB2XML ); 
-    CParser* parser = CParser::NewLC( *matchData, *this ); 
-    parser->EnableFeature( Xml::EReportNamespaceMapping );
-    
-    Xml::ParseL( *parser, aData );    
-    
-    CleanupStack::PopAndDestroy( parser );
-    CleanupStack::PopAndDestroy( matchData );
-    
-    iResultRoot = NULL;           
-    __LOG( "CUPnPXMLParserLite::ParseResultDataL, end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnStartDocumentL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnStartDocumentL( 
-                                const RDocumentParameters& /*aDocParam*/, 
-                                TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnEndDocumentL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnEndDocumentL( TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnStartElementL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnStartElementL( const RTagInfo& aElement, 
-                                      const RAttributeArray& aAttributes,
-                                      TInt aErrorCode )
-    {
-    __LOG1( "CUPnPXMLParserLite::OnStartElementL, error code: %d", aErrorCode );
-    if ( aErrorCode != KErrNone )
-        {
-        return;
-        }
-    const TDesC8& desName = aElement.LocalName().DesC();
-    const TDesC8& prefix = aElement.Prefix().DesC();
-    
-    // Delete content, since there may be some stuff between the elements
-    // (comments, whitespace etc.)
-    delete iElementValue; iElementValue = NULL;    
-      
-    if ( !desName.CompareF( KContainer ) ) // Container element
-        {
-        CUpnpObjectLite* tmpContainer = CUpnpObjectLite::NewL();
-        CleanupStack::PushL( tmpContainer );
-
-        SetAttributesL( *tmpContainer, aAttributes );
-        //push into the stack, ownership is transferred                      
-        iStack->PushL( tmpContainer ); 
-        
-        CleanupStack::Pop( tmpContainer );
-        }
-    else if ( !desName.CompareF( KItem ) ) // Item element
-        {
-        CUpnpObjectLite* tmpItem = CUpnpObjectLite::NewL();
-        CleanupStack::PushL( tmpItem );
-
-        SetAttributesL( *tmpItem, aAttributes );                      
-        //push into the stack, ownership is transferred                      
-        iStack->PushL( tmpItem );
-        
-        CleanupStack::Pop( tmpItem );
-        }
-    else if( !desName.CompareF( KTitle ) ) // Title element
-        {
-        // check that we have item or container. cause leave if not
-        if ( iStack->Count() == 0)
-            {
-            User::Leave( KErrArgument );
-            }
-        // We should have an item or a container already!
-        //__ASSERTD( iStack->Top(), __FILE__, __LINE__ );
-        iTitle = ETrue;
-        }
-    else if( !desName.CompareF( KClass ) ) // Object class element
-        {
-        // check that we have item or container. cause leave if not
-        if ( iStack->Count() == 0)
-            {
-            User::Leave( KErrArgument );
-            }
-        // We should have an item or a container already!
-        //__ASSERTD( iStack->Top(), __FILE__, __LINE__ );
-        iObjectClass = ETrue;
-        }
-    // Ignore DIDL-Lite, desc and X_DLNADOC -elements (DLNA req)
-    else if( desName.Compare( KDIDL ) == KErrNone ||
-             desName.Compare( KDesc ) == KErrNone ||
-             desName.Compare( KDlnaDoc ) == KErrNone    
-           )
-        {
-        // Ignore
-        }
-    else 
-        {
-        // check that we have item or container. cause leave if not
-        if ( iStack->Count() == 0)
-            {
-            User::Leave( KErrArgument );
-            }
-        // Ignore rest of the elements
-                }
-    __LOG( "CUPnPXMLParserLite::OnStartElementL, end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnEndElementL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnEndElementL( const RTagInfo& aElement, 
-                                    TInt aErrorCode )
-    {
-    __LOG( "CUPnPXMLParserLite::OnEndElementL(), begin" );
-    if ( aErrorCode != KErrNone )
-        {
-        return;
-        }
-        
-    const TDesC8& desName = aElement.LocalName().DesC();    
-    if ( !desName.CompareF( KContainer ) || !desName.CompareF( KItem ) )
-        {
-        if( iTitleBuf )
-            {
-            CUpnpObjectLite* obj = iStack->Top();
-            __ASSERTD( obj, __FILE__, __LINE__ );
-
-            if( iFormatString )
-                {
-                HBufC* tempBuf = UpnpString::ToUnicodeL( *iTitleBuf );
-                CleanupStack::PushL( tempBuf );
-                HBufC* buf = HBufC::NewL( iFormatString->Length() +
-                    tempBuf->Length() );
-                buf->Des().Format( *iFormatString, tempBuf );
-                CleanupStack::PopAndDestroy( tempBuf );
-                obj->SetTitleL( buf );
-                }
-            else
-                {
-                HBufC* buf = HBufC::NewL( iTitleBuf->Length() );
-                buf->Des().Copy( *iTitleBuf );
-                obj->SetTitleL( buf );
-                }
-            delete iTitleBuf; iTitleBuf = NULL;
-            }
-               
-        iResultRoot->AppendL( iStack->Top() );
-        iStack->Pop(); // Remove object from stack.
-        }
-    else if( KErrNone != desName.CompareF( KDIDL ))
-        {        
-        CUpnpObjectLite* obj = iStack->Top();
-        __ASSERTD( obj, __FILE__, __LINE__ );
-             
-        if ( iElementValue )
-            {
-            if( !desName.CompareF( KTitle ) )
-                {
-                delete iTitleBuf; iTitleBuf = NULL;
-                iTitleBuf = iElementValue;
-                iElementValue = NULL;
-                }
-            else if( !desName.CompareF( KClass ) )
-                {
-                obj->SetObjectClass( *iElementValue );                
-                iObjectClass = EFalse;
-                if( iFormatString )
-                    {
-                    SetIconIndex( *obj );
-                    }                
-                }
-            else
-                {               
-                }          
-            }
-        else
-            {
-            }    
-        
-        delete iElementValue; iElementValue = NULL;    
-        }    
-    __LOG( "CUPnPXMLParserLite::OnEndElementL(), end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnContentL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnContentL( const TDesC8& aBytes, TInt aErrorCode )
-    {
-    __LOG( "CUPnPXMLParserLite::OnContentL(), begin" );
-    if ( !iStack->Count() || aErrorCode != KErrNone )
-        {
-        return;
-        }
-    
-    if( iTitle || iObjectClass ) // We are only interested in title or
-                                 // object class!
-        {
-        if( !iElementValue ) //if 1st time
-            {
-            iElementValue = HBufC8::NewL(aBytes.Length());
-            iElementValue->Des().Copy(aBytes); 
-            }
-        else
-            {
-            HBufC8* previousValue = iElementValue;
-            iElementValue = HBufC8::NewL( previousValue->Des().Length() +
-                                          aBytes.Length() );
-            iElementValue->Des().Append( *previousValue );
-            iElementValue->Des().Append( aBytes );
-            delete previousValue;
-            }         
-        }
-    
-    __LOG( "CUPnPXMLParserLite::OnContentL(), end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnStartPrefixMappingL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnStartPrefixMappingL( const RString& /*aPrefix*/, 
-                                               const RString& /*aUri*/, 
-                                               TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnEndPrefixMappingL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnEndPrefixMappingL( const RString& /*aPrefix*/, 
-                                             TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnIgnorableWhiteSpaceL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, 
-                                                TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnSkippedEntityL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnSkippedEntityL( const RString& /*aName*/, 
-                                          TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnProcessingInstructionL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnProcessingInstructionL( const TDesC8& /*aTarget*/, 
-                                                  const TDesC8& /*aData*/, 
-                                                  TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::OnError
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::OnError( TInt /*aErrorCode*/ )
-    {
-    // No implementation needed
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::GetExtendedInterface
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-TAny* CUPnPXMLParserLite::GetExtendedInterface( const TInt32 /*aUid*/ )
-    {    
-    // No implementation needed
-    return NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPXMLParserLite::SetAttributesL
-// See upnpxmlparser.h
-// --------------------------------------------------------------------------
-void CUPnPXMLParserLite::SetAttributesL( CUpnpObjectLite& aObject, 
-    const RAttributeArray& aAttributes )
-    {
-    __LOG( "CUPnPXMLParserLite::SetAttributesL" );
-    
-    if ( iStack->Count() )
-        {
-        // Object has a parent.
-        // Should not really happen
-        __LOG( "Object has a parent!" );
-        __PANICD(__FILE__, __LINE__);      
-        }
-        
-    RAttribute attribute;
-    TInt count = aAttributes.Count();
-    for ( TInt i = 0 ; i < count; i++ ) // Read attributes.
-        {
-        attribute = aAttributes[ i ];
-        const TDesC8& name = attribute.Attribute().LocalName().DesC();
-        
-        if( !name.CompareF( KId ) )
-            {
-            aObject.SetObjectIdL( attribute.Value().DesC() );
-            }
-        }
-    __LOG( "CUPnPXMLParserLite::SetAttributesL - End" );
-    }
-
-void CUPnPXMLParserLite::SetIconIndex( const CUpnpObjectLite& aObject )
-    {
-    if( aObject.IsTypeOf( CUpnpObjectLite::EContainer ) )
-        {
-        iFormatString->Des().Replace( 0, 1, KIndexContainer );
-        }
-    else if( aObject.IsTypeOf( CUpnpObjectLite::EMusicItem ) )
-        {
-        iFormatString->Des().Replace( 0, 1, KIndexAudio );
-        }
-    else if( aObject.IsTypeOf( CUpnpObjectLite::EImageItem ) )
-        {
-        iFormatString->Des().Replace( 0, 1, KIndexImage );
-        }
-    else if( aObject.IsTypeOf( CUpnpObjectLite::EVideoItem ) )
-        {
-        iFormatString->Des().Replace( 0, 1, KIndexVideo );
-        }
-    else
-        {
-        // Other
-        iFormatString->Des().Replace( 0, 1, KIndexOther );
-        }    
-    }
-        
-// end of file
-
-
+/*
+* Copyright (c) 2008 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:      XML SAX Parser for UPnP.
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// system / xml parser
+#include <xml/parser.h>
+#include <xml/parserfeature.h>
+#include <xml/matchdata.h>
+
+// upnp stack api
+#include <upnpstring.h>
+
+// dlnasrv / xmlparser api
+#include "upnpxmlparserlite.h"
+#include "upnpobjectlite.h"
+
+// dlnasrv / xmlparser internal
+#include "upnpobjectstacklite.h"
+
+
+_LIT( KComponentLogfile, "upnpxmlparser.txt");
+#include "upnplog.h"
+
+_LIT8( KXmlMimeType,    "text/xml"     );
+_LIT8( KLIB2XML,        "libxml2" );
+
+_LIT8( KContainer,      "container"    );
+_LIT8( KItem,           "item"         );
+_LIT8( KTitle,          "title"        );
+_LIT8( KClass,          "class"        );
+_LIT8( KId,             "id"           );
+//_LIT8( KComma,          ":"            );
+_LIT8( KDIDL,           "DIDL-Lite"    );
+_LIT8( KDesc,           "desc"         );
+_LIT8( KDlnaDoc,        "X_DLNADOC"    );
+
+_LIT( KIndexContainer,  "1" );
+_LIT( KIndexAudio,      "2" );
+_LIT( KIndexVideo,      "3" );
+_LIT( KIndexImage,      "4" );
+_LIT( KIndexOther,      "5" );
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::CUPnPXMLParserLite()
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+CUPnPXMLParserLite::CUPnPXMLParserLite()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::ConstructL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::ConstructL()
+    {
+    __LOG( "CUPnPXMLParserLite::CostructL" );
+    iStack = CUPnPObjectStackLite::NewL();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::NewL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C CUPnPXMLParserLite* CUPnPXMLParserLite::NewL()
+    {
+    CUPnPXMLParserLite* self = CUPnPXMLParserLite::NewLC();
+    CleanupStack::Pop( self );    
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::NewLC
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C CUPnPXMLParserLite* CUPnPXMLParserLite::NewLC()
+    {   
+    CUPnPXMLParserLite* self = new( ELeave ) CUPnPXMLParserLite();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+    
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::~CUPnPXMLParserLite
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+CUPnPXMLParserLite::~CUPnPXMLParserLite()
+    {
+    __LOG( "CUPnPXMLParserLite::~CUPnPXMLParserLite" );
+    if ( iStack )
+        {
+        iStack->ResetAndDestroy();
+        delete iStack;
+        }
+    
+    delete iElementValue;
+    delete iFormatString;
+    delete iTitleBuf;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::ParseResultDataL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+EXPORT_C void CUPnPXMLParserLite::ParseResultDataL(
+    RPointerArray<CUpnpObjectLite>& aResultArray, const TDesC8& aData,
+    const TDesC& aFormatString )
+    {
+    __LOG( "CUPnPXMLParserLite::ParseResultDataL, begin" );
+    
+    delete iFormatString; iFormatString = NULL;
+    if( aFormatString != KNullDesC )
+        {
+        iFormatString = aFormatString.AllocL();
+        }
+    
+    if ( !aData.Length() )
+        {
+        User::Leave( KErrArgument );
+        }
+        
+    iResultRoot = &aResultArray;
+
+    // Create parser 
+    CMatchData* matchData = CMatchData::NewLC();
+    matchData->SetMimeTypeL( KXmlMimeType ); 
+    matchData->SetVariantL( KLIB2XML ); 
+    CParser* parser = CParser::NewLC( *matchData, *this ); 
+    parser->EnableFeature( Xml::EReportNamespaceMapping );
+    
+    Xml::ParseL( *parser, aData );    
+    
+    CleanupStack::PopAndDestroy( parser );
+    CleanupStack::PopAndDestroy( matchData );
+    
+    iResultRoot = NULL;           
+    __LOG( "CUPnPXMLParserLite::ParseResultDataL, end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnStartDocumentL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnStartDocumentL( 
+                                const RDocumentParameters& /*aDocParam*/, 
+                                TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnEndDocumentL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnEndDocumentL( TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnStartElementL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnStartElementL( const RTagInfo& aElement, 
+                                      const RAttributeArray& aAttributes,
+                                      TInt aErrorCode )
+    {
+    __LOG1( "CUPnPXMLParserLite::OnStartElementL, error code: %d",
+            aErrorCode );
+    if ( aErrorCode != KErrNone )
+        {
+        return;
+        }
+    const TDesC8& desName = aElement.LocalName().DesC();
+    const TDesC8& prefix = aElement.Prefix().DesC();
+    
+    // Delete content, since there may be some stuff between the elements
+    // (comments, whitespace etc.)
+    delete iElementValue; iElementValue = NULL;    
+      
+    if ( !desName.CompareF( KContainer ) ) // Container element
+        {
+        CUpnpObjectLite* tmpContainer = CUpnpObjectLite::NewL();
+        CleanupStack::PushL( tmpContainer );
+
+        SetAttributesL( *tmpContainer, aAttributes );
+        //push into the stack, ownership is transferred                      
+        iStack->PushL( tmpContainer ); 
+        
+        CleanupStack::Pop( tmpContainer );
+        }
+    else if ( !desName.CompareF( KItem ) ) // Item element
+        {
+        CUpnpObjectLite* tmpItem = CUpnpObjectLite::NewL();
+        CleanupStack::PushL( tmpItem );
+
+        SetAttributesL( *tmpItem, aAttributes );                      
+        //push into the stack, ownership is transferred                      
+        iStack->PushL( tmpItem );
+        
+        CleanupStack::Pop( tmpItem );
+        }
+    else if( !desName.CompareF( KTitle ) ) // Title element
+        {
+        // check that we have item or container. cause leave if not
+        if ( iStack->Count() == 0)
+            {
+            User::Leave( KErrArgument );
+            }
+        // We should have an item or a container already!
+        //__ASSERTD( iStack->Top(), __FILE__, __LINE__ );
+        iTitle = ETrue;
+        }
+    else if( !desName.CompareF( KClass ) ) // Object class element
+        {
+        // check that we have item or container. cause leave if not
+        if ( iStack->Count() == 0)
+            {
+            User::Leave( KErrArgument );
+            }
+        // We should have an item or a container already!
+        //__ASSERTD( iStack->Top(), __FILE__, __LINE__ );
+        iObjectClass = ETrue;
+        }
+    // Ignore DIDL-Lite, desc and X_DLNADOC -elements (DLNA req)
+    else if( desName.Compare( KDIDL ) == KErrNone ||
+             desName.Compare( KDesc ) == KErrNone ||
+             desName.Compare( KDlnaDoc ) == KErrNone    
+           )
+        {
+        // Ignore
+        }
+    else 
+        {
+        // check that we have item or container. cause leave if not
+        if ( iStack->Count() == 0)
+            {
+            User::Leave( KErrArgument );
+            }
+        // Ignore rest of the elements
+                }
+    __LOG( "CUPnPXMLParserLite::OnStartElementL, end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnEndElementL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnEndElementL( const RTagInfo& aElement, 
+                                    TInt aErrorCode )
+    {
+    __LOG( "CUPnPXMLParserLite::OnEndElementL(), begin" );
+    if ( aErrorCode != KErrNone )
+        {
+        return;
+        }
+        
+    const TDesC8& desName = aElement.LocalName().DesC();    
+    if ( !desName.CompareF( KContainer ) || !desName.CompareF( KItem ) )
+        {
+        if( iTitleBuf )
+            {
+            CUpnpObjectLite* obj = iStack->Top();
+            __ASSERTD( obj, __FILE__, __LINE__ );
+
+            if( iFormatString )
+                {
+                HBufC* tempBuf = UpnpString::ToUnicodeL( *iTitleBuf );
+                CleanupStack::PushL( tempBuf );
+                HBufC* buf = HBufC::NewL( iFormatString->Length() +
+                    tempBuf->Length() );
+                CleanupStack::PushL( buf );
+                buf->Des().Format( *iFormatString, tempBuf );
+                obj->SetTitleL( buf );
+                CleanupStack::Pop( buf );
+                CleanupStack::PopAndDestroy( tempBuf );	
+                }
+            else
+                {
+                HBufC* buf = HBufC::NewL( iTitleBuf->Length() );
+                CleanupStack::PushL( buf );
+                buf->Des().Copy( *iTitleBuf );
+                obj->SetTitleL( buf );
+                CleanupStack::Pop( buf );
+                }
+            delete iTitleBuf; iTitleBuf = NULL;
+            }
+               
+        iResultRoot->AppendL( iStack->Top() );
+        iStack->Pop(); // Remove object from stack.
+        }
+    else if( KErrNone != desName.CompareF( KDIDL ))
+        {        
+        CUpnpObjectLite* obj = iStack->Top();
+        __ASSERTD( obj, __FILE__, __LINE__ );
+             
+        if ( iElementValue )
+            {
+            if( !desName.CompareF( KTitle ) )
+                {
+                delete iTitleBuf; iTitleBuf = NULL;
+                iTitleBuf = iElementValue;
+                iElementValue = NULL;
+                }
+            else if( !desName.CompareF( KClass ) )
+                {
+                obj->SetObjectClass( *iElementValue );                
+                iObjectClass = EFalse;
+                if( iFormatString )
+                    {
+                    SetIconIndex( *obj );
+                    }                
+                }
+            else
+                {               
+                }          
+            }
+        else
+            {
+            }    
+        
+        delete iElementValue; iElementValue = NULL;    
+        }    
+    __LOG( "CUPnPXMLParserLite::OnEndElementL(), end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnContentL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnContentL( const TDesC8& aBytes, TInt aErrorCode )
+    {
+    __LOG( "CUPnPXMLParserLite::OnContentL(), begin" );
+    if ( !iStack->Count() || aErrorCode != KErrNone )
+        {
+        return;
+        }
+    
+    if( iTitle || iObjectClass ) // We are only interested in title or
+                                 // object class!
+        {
+        if( !iElementValue ) //if 1st time
+            {
+            iElementValue = HBufC8::NewL(aBytes.Length());
+            iElementValue->Des().Copy(aBytes); 
+            }
+        else
+            {
+            HBufC8* previousValue = iElementValue;
+            iElementValue = HBufC8::NewL( previousValue->Des().Length() +
+                                          aBytes.Length() );
+            iElementValue->Des().Append( *previousValue );
+            iElementValue->Des().Append( aBytes );
+            delete previousValue;
+            }         
+        }
+    
+    __LOG( "CUPnPXMLParserLite::OnContentL(), end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnStartPrefixMappingL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnStartPrefixMappingL( const RString& /*aPrefix*/, 
+                                               const RString& /*aUri*/, 
+                                               TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnEndPrefixMappingL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnEndPrefixMappingL( const RString& /*aPrefix*/, 
+                                             TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnIgnorableWhiteSpaceL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnIgnorableWhiteSpaceL( const TDesC8& /*aBytes*/, 
+                                                TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnSkippedEntityL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnSkippedEntityL( const RString& /*aName*/, 
+                                          TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnProcessingInstructionL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnProcessingInstructionL( const TDesC8& /*aTarget*/, 
+                                                  const TDesC8& /*aData*/, 
+                                                  TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::OnError
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::OnError( TInt /*aErrorCode*/ )
+    {
+    // No implementation needed
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::GetExtendedInterface
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+TAny* CUPnPXMLParserLite::GetExtendedInterface( const TInt32 /*aUid*/ )
+    {    
+    // No implementation needed
+    return NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPXMLParserLite::SetAttributesL
+// See upnpxmlparser.h
+// --------------------------------------------------------------------------
+void CUPnPXMLParserLite::SetAttributesL( CUpnpObjectLite& aObject, 
+    const RAttributeArray& aAttributes )
+    {
+    __LOG( "CUPnPXMLParserLite::SetAttributesL" );
+    
+    if ( iStack->Count() )
+        {
+        // Object has a parent.
+        // Should not really happen
+        __LOG( "Object has a parent!" );
+        __PANICD(__FILE__, __LINE__);      
+        }
+        
+    RAttribute attribute;
+    TInt count = aAttributes.Count();
+    for ( TInt i = 0 ; i < count; i++ ) // Read attributes.
+        {
+        attribute = aAttributes[ i ];
+        const TDesC8& name = attribute.Attribute().LocalName().DesC();
+        
+        if( !name.CompareF( KId ) )
+            {
+            aObject.SetObjectIdL( attribute.Value().DesC() );
+            }
+        }
+    __LOG( "CUPnPXMLParserLite::SetAttributesL - End" );
+    }
+
+void CUPnPXMLParserLite::SetIconIndex( const CUpnpObjectLite& aObject )
+    {
+    if( aObject.IsTypeOf( CUpnpObjectLite::EContainer ) )
+        {
+        iFormatString->Des().Replace( 0, 1, KIndexContainer );
+        }
+    else if( aObject.IsTypeOf( CUpnpObjectLite::EMusicItem ) )
+        {
+        iFormatString->Des().Replace( 0, 1, KIndexAudio );
+        }
+    else if( aObject.IsTypeOf( CUpnpObjectLite::EImageItem ) )
+        {
+        iFormatString->Des().Replace( 0, 1, KIndexImage );
+        }
+    else if( aObject.IsTypeOf( CUpnpObjectLite::EVideoItem ) )
+        {
+        iFormatString->Des().Replace( 0, 1, KIndexVideo );
+        }
+    else
+        {
+        // Other
+        iFormatString->Des().Replace( 0, 1, KIndexOther );
+        }    
+    }
+        
+// end of file
+
+
--- a/upnpframework/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,64 +1,55 @@
-/*
-* Copyright (c) 2006-2008 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:  Build information file for upnpframework
-*
-*/
-
-
-// For compatibility with S60 3.2 and IAD branch
-#include "../../group/upnpplatformvar.hrh"
-
-PRJ_PLATFORMS
-DEFAULT
-
-PRJ_EXPORTS
-// none
-
-PRJ_MMPFILES
-// none
-
-// Build subprojects
-
-// UpnpUtilities
-#include "../upnputilities/group/bld.inf"
-
-#ifdef FF_UPNP_FRAMEWORK_2_0  // UPnP feature flag
-     // UPnP (Home Media) Extension plugin interface
-    #include "../upnpextensionpluginif/group/bld.inf"
-
-    // UpnpFileTransferEngine
-    #include "../upnpfiletransferengine/group/bld.inf"
-
-    // UpnpCommonUi
-    #include "../upnpcommonui/group/bld.inf"
-
-        // UpnpAiwEngine
-    #include "../upnpaiwengine/group/bld.inf"
-
-    // UpnpAiwProvider
-    #include "../upnpaiwprovider/group/bld.inf"
-
-#endif // FF_UPNP_FRAMEWORK_2_0
-
-// UpnpMusicAdapter
-#include "../upnpmusicadapter/group/bld.inf"
-
-// UpnpCommand
-#include "../upnpcommand/group/bld.inf"
-
-// Exports for upnpframework
-#include "../rom/bld.inf"
-
-
-// End of file
+/*
+* Copyright (c) 2006-2008 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:  Build information file for upnpframework
+*
+*/
+
+// For compatibility with S60 3.2 and IAD branch
+#include "../../group/upnpplatformvar.hrh"
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+// LOC files
+UPNP_LOC_EXPORT(upnpframework.loc)
+
+// upnpframework common headers
+../inc/upnpframeworkfeatures_mmp.hrh    |../../inc/upnpframeworkfeatures_mmp.hrh
+../inc/upnplogging.h                    |../../inc/upnplogging.h
+../inc/upnppanic.h                      |../../inc/upnppanic.h
+../inc/upnplog.h                        |../../inc/upnplog.h
+
+PRJ_MMPFILES
+// None
+
+// Build subprojects
+
+    // Upnpthumbnail
+    #include "../upnpthumbnail/group/bld.inf"
+    
+    // UpnpUtilities
+    #include "../upnputilities/group/bld.inf"
+
+    // UpnpCommand
+    #include "../upnpcommand/group/bld.inf"
+    
+    // UpnpFileTransferEngine
+    #include "../upnpfiletransferengine/group/bld.inf"    
+
+    // UpnpMusicAdapter
+    #include "../upnpmusicadapter/group/bld.inf"    
+
+// End of file
--- a/upnpframework/inc/upnplog.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/inc/upnplog.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,213 +1,213 @@
-/*
-* Copyright (c) 2008 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:  log/assert facility of upnp framework
-*
-*/
-
-
-// **************************************************************************
-// *
-// *  HOW TO USE THIS LOGGING FACILITY
-// *
-// * 1. enable log facility in the code.
-// *     _LIT( KComponentLogfile, "component.txt");
-// *     #include "upnplog.h"
-// *
-// * 2. have flogger in mmp-file
-// *     DEBUGLIBRARY FLOGGER.LIB
-// *
-// * 3. use the log interface in the source
-// *     __LOG( char* strz )
-// *     __LOG1( char* strz, p1 )
-// *     __LOG2( char* strz, p1, p2 )
-// *     __LOG3( char* strz, p1, p2, p3 )
-// *     __LOG8( const TDesC8& msg )
-// *     __LOG16( const TDesC16& msg )
-// *     __ASSERTD( test, file, line )
-// *     __ASSERT( test, file, line )
-// *     __PANICD( file, line )
-// *     __PANIC( file, line )
-// *
-// * 4. The default logging/assertion modes are following:
-// *     DEBUG build:    log to console, assertion mode on.
-// *     RELEASE build:  log turned off, assertion mode off.
-// *     To override this preset, you can use following macros:
-// *     MACRO __UPNP_LOG_FILE          (logging to file)
-// *     MACRO __UPNP_LOG_CONSOLE       (logging to console)
-// *     MACRO __UPNP_LOG_OFF           (logging turned off in DEBUG build)
-// *     MACRO __UPNP_DEBUG_ASSERT      (enable D-panic and D-assert)
-// *     MACRO __UPNP_DEBUG_ASSERT_OFF  (disable D-panic and D-assert)
-// *     in case of using logging in RELEASE build, remember to switch
-// *     LIBRARY FLOGGER.LIB instead of DEBUGLIBRARY.
-// *
-// **************************************************************************
-
-
-#ifndef __UPNPLOG_H__
-#define __UPNPLOG_H__
-
-
-#include <e32std.h>
-
-
-// in DEBUG build activate the default modes
-#ifdef _DEBUG
-
-    #if !( defined(__UPNP_LOG_FILE) || \
-        defined(__UPNP_LOG_CONSOLE) || \
-        defined(__UPNP_LOG_OFF) )
-        // activate default logging mode
-        #define __UPNP_LOG_CONSOLE
-    #endif
-
-    #if !( defined(__UPNP_DEBUG_ASSERT) || \
-        defined(__UPNP_DEBUG_ASSERT_OFF) )
-        // activate debug assertion mode
-        #define __UPNP_DEBUG_ASSERT
-    #endif
-
-#endif //_DEBUG
-
-
-// this dummy function is to avoid compiler warning #177-D:
-// variable was declared but never referenced
-inline void __Dummy_KComponentLogfile()
-    {
-    TUint16 c = KComponentLogfile().Size();
-    c = 0;
-    }
-
-//
-// **************************************************************************
-// LOGGING MACROS
-// **************************************************************************
-//
-
-#if defined(__UPNP_LOG_FILE)
-
-    #include <flogger.h>
-
-    // Subdirectory under c:\logs -directory
-    _LIT( KLogDir, "upnpframework" );
-
-    #define __LOG( strz ) Print16(_L(strz))
-    #define __LOG1( strz,p1 ) Print16(_L(strz),p1)
-    #define __LOG2( strz,p1,p2 ) Print16(_L(strz),p1,p2)
-    #define __LOG3( strz,p1,p2,p3 ) \
-        Print16(_L(strz),p1,p2,p3)
-    #define __LOG8( msg ) Print8( _L8( "%S" ), &msg )
-    #define __LOG16( msg ) Print16( _L16( "%S" ), &msg )
-    #define __LOG8_1( strz,p1 ) Print8(_L8(strz),p1)
-
-    // Writes a log text to a file using file logger
-    inline void Print16( const TRefByValue<const TDesC> aFmt, ... )
-        {
-        VA_LIST list;
-        VA_START(list,aFmt);
-        RFileLogger::WriteFormat( KLogDir, KComponentLogfile,
-            EFileLoggingModeAppend, aFmt, list );
-        VA_END( list );
-        }    
-
-        // Writes a log text to a file using file logger
-    inline void Print8( const TRefByValue<const TDesC8> aFmt, ... )
-        {
-        VA_LIST list;
-        VA_START(list,aFmt);
-        RFileLogger::WriteFormat( KLogDir, KComponentLogfile,
-            EFileLoggingModeAppend, aFmt, list );
-        VA_END( list );
-        }
-
-#elif defined(__UPNP_LOG_CONSOLE)
-
-    #include <f32file.h>
-
-    #define __LOG( strz ) RDebug::Print(_L(strz))
-    #define __LOG1( strz,p1 ) RDebug::Print(_L(strz),p1)
-    #define __LOG2( strz,p1,p2 ) RDebug::Print(_L(strz),p1,p2)
-    #define __LOG3( strz,p1,p2,p3 ) \
-        RDebug::Print(_L(strz),p1,p2,p3)
-    #define __LOG8( msg ) Debug8(msg)
-    #define __LOG16( msg ) RDebug::Print(msg)
-    #define __LOG8_1( strz,p1 ) RDebug::Printf(strz, p1)
-
-    inline void Debug8( const TDesC8& aMsg )
-        {
-        __Dummy_KComponentLogfile();
-        RDebug::RawPrint( aMsg );
-        }
-
-#else // __UPNP_LOG_OFF
-
-    #define __LOG( strz ) __Dummy_KComponentLogfile();
-    #define __LOG1( fmt,p1 ) __Dummy_KComponentLogfile();
-    #define __LOG2( fmt,p1,p2 ) __Dummy_KComponentLogfile();
-    #define __LOG3( fmt,p1,p2,p3 ) __Dummy_KComponentLogfile();
-    #define __LOG8( msg ) __Dummy_KComponentLogfile();
-    #define __LOG16( msg ) __Dummy_KComponentLogfile();
-    #define __LOG8_1( strz,p1 ) __Dummy_KComponentLogfile();
-
-#endif // __UPNP_LOG_FILE || __UPNP_LOG_CONSOLE || __UPNP_LOG_OFF
-
-
-//
-// **************************************************************************
-// ASSERTION MACROS
-// **************************************************************************
-//
-
-#define __ASSERT( test, file, line ) \
-    if( !( test ) ) \
-        { \
-        __LOG2( "Assertion failed: %s %d", \
-            file, line ); \
-        User::Panic( _L(file), line ); \
-        }
-
-#define __PANIC( file, line ) \
-    { \
-    __LOG2( "Panic: %s %d", \
-        file, line ); \
-    User::Panic( _L(file), line ) \
-    }
-
-#ifdef __UPNP_DEBUG_ASSERT
-
-    #define __ASSERTD( test, file, line ) \
-        if( !( test ) ) \
-            { \
-            __LOG2( "Assertion failed: %s %d", \
-                file, line ); \
-            User::Panic( _L(file), line ); \
-            }
-
-    #define __PANICD( file, line ) \
-        { \
-        __LOG2( "Panic: %s %d", \
-            file, line ); \
-        User::Panic( _L(file), line ); \
-        }
-
-#else // __UPNP_DEBUG_ASSERT_OFF
-
-    #define __ASSERTD( test, file, line )
-    #define __PANICD( file, line )
-
-#endif // __UPNP_DEBUG_ASSERT || __UPNP_DEBUG_ASSERT_OFF
-
-
-
-#endif // __UPNPLOG_H__
-
+/*
+* Copyright (c) 2008 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:  log/assert facility of upnp framework
+*
+*/
+
+
+// **************************************************************************
+// *
+// *  HOW TO USE THIS LOGGING FACILITY
+// *
+// * 1. enable log facility in the code.
+// *     _LIT( KComponentLogfile, "component.txt");
+// *     #include "upnplog.h"
+// *
+// * 2. have flogger in mmp-file
+// *     DEBUGLIBRARY FLOGGER.LIB
+// *
+// * 3. use the log interface in the source
+// *     __LOG( char* strz )
+// *     __LOG1( char* strz, p1 )
+// *     __LOG2( char* strz, p1, p2 )
+// *     __LOG3( char* strz, p1, p2, p3 )
+// *     __LOG8( const TDesC8& msg )
+// *     __LOG16( const TDesC16& msg )
+// *     __ASSERTD( test, file, line )
+// *     __ASSERT( test, file, line )
+// *     __PANICD( file, line )
+// *     __PANIC( file, line )
+// *
+// * 4. The default logging/assertion modes are following:
+// *     DEBUG build:    log to console, assertion mode on.
+// *     RELEASE build:  log turned off, assertion mode off.
+// *     To override this preset, you can use following macros:
+// *     MACRO __UPNP_LOG_FILE          (logging to file)
+// *     MACRO __UPNP_LOG_CONSOLE       (logging to console)
+// *     MACRO __UPNP_LOG_OFF           (logging turned off in DEBUG build)
+// *     MACRO __UPNP_DEBUG_ASSERT      (enable D-panic and D-assert)
+// *     MACRO __UPNP_DEBUG_ASSERT_OFF  (disable D-panic and D-assert)
+// *     in case of using logging in RELEASE build, remember to switch
+// *     LIBRARY FLOGGER.LIB instead of DEBUGLIBRARY.
+// *
+// **************************************************************************
+
+
+#ifndef __UPNPLOG_H__
+#define __UPNPLOG_H__
+
+
+#include <e32std.h>
+
+
+// in DEBUG build activate the default modes
+#ifdef _DEBUG
+
+    #if !( defined(__UPNP_LOG_FILE) || \
+        defined(__UPNP_LOG_CONSOLE) || \
+        defined(__UPNP_LOG_OFF) )
+        // activate default logging mode
+        #define __UPNP_LOG_CONSOLE
+    #endif
+
+    #if !( defined(__UPNP_DEBUG_ASSERT) || \
+        defined(__UPNP_DEBUG_ASSERT_OFF) )
+        // activate debug assertion mode
+        #define __UPNP_DEBUG_ASSERT
+    #endif
+
+#endif //_DEBUG
+
+
+// this dummy function is to avoid compiler warning #177-D:
+// variable was declared but never referenced
+inline void __Dummy_KComponentLogfile()
+    {
+    TUint16 c = KComponentLogfile().Size();
+    c = 0;
+    }
+
+//
+// **************************************************************************
+// LOGGING MACROS
+// **************************************************************************
+//
+
+#if defined(__UPNP_LOG_FILE)
+
+    #include <flogger.h>
+
+    // Subdirectory under c:\logs -directory
+    _LIT( KLogDir, "upnpframework" );
+
+    #define __LOG( strz ) Print16(_L(strz))
+    #define __LOG1( strz,p1 ) Print16(_L(strz),p1)
+    #define __LOG2( strz,p1,p2 ) Print16(_L(strz),p1,p2)
+    #define __LOG3( strz,p1,p2,p3 ) \
+        Print16(_L(strz),p1,p2,p3)
+    #define __LOG8( msg ) Print8( _L8( "%S" ), &msg )
+    #define __LOG16( msg ) Print16( _L16( "%S" ), &msg )
+    #define __LOG8_1( strz,p1 ) Print8(_L8(strz),p1)
+
+    // Writes a log text to a file using file logger
+    inline void Print16( const TRefByValue<const TDesC> aFmt, ... )
+        {
+        VA_LIST list;
+        VA_START(list,aFmt);
+        RFileLogger::WriteFormat( KLogDir, KComponentLogfile,
+            EFileLoggingModeAppend, aFmt, list );
+        VA_END( list );
+        }    
+
+        // Writes a log text to a file using file logger
+    inline void Print8( const TRefByValue<const TDesC8> aFmt, ... )
+        {
+        VA_LIST list;
+        VA_START(list,aFmt);
+        RFileLogger::WriteFormat( KLogDir, KComponentLogfile,
+            EFileLoggingModeAppend, aFmt, list );
+        VA_END( list );
+        }
+
+#elif defined(__UPNP_LOG_CONSOLE)
+
+    #include <f32file.h>
+
+    #define __LOG( strz ) RDebug::Print(_L(strz))
+    #define __LOG1( strz,p1 ) RDebug::Print(_L(strz),p1)
+    #define __LOG2( strz,p1,p2 ) RDebug::Print(_L(strz),p1,p2)
+    #define __LOG3( strz,p1,p2,p3 ) \
+        RDebug::Print(_L(strz),p1,p2,p3)
+    #define __LOG8( msg ) Debug8(msg)
+    #define __LOG16( msg ) RDebug::Print(msg)
+    #define __LOG8_1( strz,p1 ) RDebug::Printf(strz, p1)
+
+    inline void Debug8( const TDesC8& aMsg )
+        {
+        __Dummy_KComponentLogfile();
+        RDebug::RawPrint( aMsg );
+        }
+
+#else // __UPNP_LOG_OFF
+
+    #define __LOG( strz ) __Dummy_KComponentLogfile();
+    #define __LOG1( fmt,p1 ) __Dummy_KComponentLogfile();
+    #define __LOG2( fmt,p1,p2 ) __Dummy_KComponentLogfile();
+    #define __LOG3( fmt,p1,p2,p3 ) __Dummy_KComponentLogfile();
+    #define __LOG8( msg ) __Dummy_KComponentLogfile();
+    #define __LOG16( msg ) __Dummy_KComponentLogfile();
+    #define __LOG8_1( strz,p1 ) __Dummy_KComponentLogfile();
+
+#endif // __UPNP_LOG_FILE || __UPNP_LOG_CONSOLE || __UPNP_LOG_OFF
+
+
+//
+// **************************************************************************
+// ASSERTION MACROS
+// **************************************************************************
+//
+
+#define __ASSERT( test, file, line ) \
+    if( !( test ) ) \
+        { \
+        __LOG2( "Assertion failed: %s %d", \
+            file, line ); \
+        User::Panic( _L(file), line ); \
+        }
+
+#define __PANIC( file, line ) \
+    { \
+    __LOG2( "Panic: %s %d", \
+        file, line ); \
+    User::Panic( _L(file), line ); \
+    }
+
+#ifdef __UPNP_DEBUG_ASSERT
+
+    #define __ASSERTD( test, file, line ) \
+        if( !( test ) ) \
+            { \
+            __LOG2( "Assertion failed: %s %d", \
+                file, line ); \
+            User::Panic( _L(file), line ); \
+            }
+
+    #define __PANICD( file, line ) \
+        { \
+        __LOG2( "Panic: %s %d", \
+            file, line ); \
+        User::Panic( _L(file), line ); \
+        }
+
+#else // __UPNP_DEBUG_ASSERT_OFF
+
+    #define __ASSERTD( test, file, line )
+    #define __PANICD( file, line )
+
+#endif // __UPNP_DEBUG_ASSERT || __UPNP_DEBUG_ASSERT_OFF
+
+
+
+#endif // __UPNPLOG_H__
+
--- a/upnpframework/loc/upnpframework.loc	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/loc/upnpframework.loc	Mon Nov 01 12:37:49 2010 +0200
@@ -1,404 +1,466 @@
-/*
-* Copyright (c) 2008 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:  Localization strings for upnpframework subsystem.
-*
-*/
-
-
-// --------------------------------------------------------------------------
-// 
-// LOCALISATION STRINGS OF SERVICES PROVIDED FOR EXTERNAL APPLICATIONS
-// (UPnPAiwEngine, UPnPAiwProvider, UPnPCommand) 
-//
-// --------------------------------------------------------------------------
-
-//d:Application interworking (AIW) menu command.
-//d:Enables usage of external UPnP Media Rendering device.
-//l:list_single_pane_t1_cp2
-//r:1.0
-//
-#define qtn_iupnp_aiw_enable_external_string             "Show via home net."
-
-//d:Application interworking (AIW) menu command.
-//d:Disables usage of external UPnP Media Rendering device.
-//l:list_single_pane_t1_cp2
-//r:1.0
-//
-#define qtn_iupnp_aiw_disable_external_string            "Stop showing"
-
-//d:Application interworking (AIW) menu command.
-//d:Copies the selected files to an external UPnP Media Server device.
-//l:list_single_popup_submenu_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_aiw_copy_to_external_string            "Copy to home network"
-
-//d:Application interworking (AIW) menu command.
-//d:Moves the selected files to an external UPnP Media Server device.
-//l:list_single_popup_submenu_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_aiw_move_to_external_string            "Move to home network"
-
-//d:Connecting wait note.
-//d:Shown while waiting for connection to get established. 
-//l:popup_note_wait_window
-//r:wk49/2008
-//
-#define qtn_iupnp_command_connecting            "Connecting"
-
-//d:Preparing playback wait note.
-//d:Shown while waiting playback on remote device to start.
-//l:popup_note_wait_window
-//r:wk49/2008
-//
-#define qtn_iupnp_command_prep_playback         "Preparing playback"
-
-//d:Note shown when one file has been copied to 
-//d:remote server device.
-//l:popup_note_window/opt2
-//r:wk49/2008
-//
-#define qtn_iupnp_info_copy_ext_one             "1 file copied to %U"
-
-//d:Note shown when multiple files have been copied to 
-//d:remote server device. Shown also when no files have been
-//d:copied to remote server device. Happens when all files 
-//d:are drm protected.
-//l:popup_note_window/opt2
-//r:wk49/2008
-//
-#define qtn_iupnp_info_copy_ext_many            "%N files copied to %U"
-
-//d:Note shown when one file has been moved to 
-//d:remote server device. 
-//l:popup_note_window/opt2
-//r:wk49/2008
-//
-#define qtn_iupnp_info_move_ext_one             "1 file moved to %U"
-
-//d:Note shown when multiple files have been copied to 
-//d:remote server device. Shown also when no files have been
-//d:moved to remote server device. Happens when all files 
-//d:are drm protected.
-//l:popup_note_window/opt2
-//r:wk49/2008
-//
-#define qtn_iupnp_info_move_ext_many            "%N files moved to %U"
-
-
-// --------------------------------------------------------------------------
-// 
-// LOCALISATION STRINGS FOR SEARCHING SERVICES
-// (UPnPAdvFind, UPnPBrowseSearchUI)
-//
-// --------------------------------------------------------------------------
-
-//d:Media type selection title
-//l:list_setting_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_media_type               "Media type"
-
-//d:Media type selection list title
-//l:main_pane_set_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_media_type_title         "Media type"
-
-//d:media type selection item
-//d:when selected, images, video clips and music files are searched
-//l:list_set_graphic_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_mt_all                   "All"
-
-//d:media type selection item
-//d:when selected only images are searched
-//l:list_set_graphic_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_mt_image                 "Images"
-
-//d:media type selection item
-//d:when selected only videos are searched
-//l:list_set_graphic_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_mt_video                 "Video clips"
-
-//d:media type selection item
-//d:when selected only music files are searched
-//l:list_set_graphic_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_mt_music                 "Music files"
-
-//d:file name editor title
-//l:list_setting_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_find_file                "Title"
-
-//d:artist editor item title
-//l:list_setting_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_find_artist              "Artist"
-
-//d:album editor item title
-//l:list_setting_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_find_album               "Album name"
-
-//d:genre editor item title
-//l:list_setting_pane_t1
-//r:wk49/2008
-// 
-#define qtn_iupnp_find_genre               "Genre"
-
-//d:date from editor item title
-//l:list_setting_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_find_date_from           "Date from"
-
-//d:date until editor item title
-//l:list_setting_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_find_date_until          "Date until"
-
-//d:find results window title
-//l:title_pane_t2/opt9
-//r:wk49/2008
-//
-#define qtn_iupnp_search_results           "Find results"
-
-//d:wait note text when search is ongoing
-//l:popup_note_wait_window
-//r:wk49/2008
-//
-#define qtn_iupnp_finding_results_note     "Finding results"
-
-//d:text for navi pane. tells the user how many files were found
-//l:navi_text_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_nof_files                 "%N files"
-
-//d:text for navi pane. tells the user how many files were found
-//l:navi_text_pane_t1
-//r:wk49/2008
-//
-#define qtn_iupnp_nof_file                  "%N file"
-
-//d:result window error note text
-//d:error note is shown when too many result files are found
-//l:popup_note_window/opt1
-//r:wk49/2008
-//
-#define qtn_iupnp_too_big_cache_note_text   "Too many items, showing only %N"
-
-
-// --------------------------------------------------------------------------
-// 
-// LOCALISATION STRINGS FOR BROWSING AND RENDERING SERVICES
-// (UPnPCommonUI) 
-//
-// --------------------------------------------------------------------------
-
-//d:Command in options list in short term memories.
-//d:Show image or video on external device.
-//l:list_single_pane_t1_cp2/opt3
-//r:1.0
-//
-#define qtn_iupnp_show_ext_main                "Show"
-
-//d:Command in options list in short term memories.
-//d:Play music file on external device.
-//l:list_single_pane_t1_cp2/opt3
-//r:1.0
-//
-#define qtn_iupnp_play_ext_main                "Play"
-
-//d:Shows or plays an item on the handset
-//d:Item in qtn_iupnp_show_ext_main or qtn_iupnp_play_ext_main
-//l:list_single_popup_submenu_pane_t1
-//r:2.1
-//
-#define qtn_iupnp_on_device                    "On device"
-
-//d:Shows or plays an item via network - on a remote device
-//d:Item in qtn_iupnp_show_ext_main or qtn_iupnp_play_ext_main
-//l:list_single_popup_submenu_pane_t1
-//r:2.1
-//
-#define qtn_iupnp_via_homenet                  "Via home net"
-
-//d:External server dialog navi pane text when searching media servers
-//l:navi_text_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_server_search_main           "Searching" 
-
-//d:External server dialog text if folder is empty
-//l:main_list_empty_pane
-//r:1.0
-//
-#define qtn_iupnp_main_empty                   "(empty)"
-
-//d:Find dialog / container view text if folder is empty
-//l:main_list_empty_pane
-//r:1.0
-//
-#define qtn_iupnp_no_files_found               "No files found"
-
-//d:Time format on navigation pane when playing video on remote device
-//l:navi_text_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_sep_slash                     "%0U/%1U"
-
-//d:Softkey command
-//d:Continue video display
-//l:control_pane_t1/opt7
-//r:1.0
-//
-#define qtn_iupnp_sk_continue                  "Continue"
-
-//d:Softkey command
-//d:Replay video display
-//l:control_pane_t1/opt7
-//r:1.0
-//
-#define qtn_iupnp_sk_replay                    "Replay"
-
-//d:Information note header for UPnP media renderer selection
-//l:heading_pane_t1/opt2
-//r:1.0
-//
-#define qtn_iupnp_select_player                "Select player:"
-
-//d:Information note header for UPnP device selection
-//l:heading_pane_t1/opt2
-//r:1.0
-//
-#define qtn_iupnp_select_device                "Select device:"
-
-//d:Title pane text
-//l:title_pane_t2/opt9
-//r:2.1
-//
-#define qtn_iupnp_title_ext_media_2            "Home Media"   
-
-//d:submenu title when copying file from external device to handset
-//l:list_single_pane_t1_cp2
-//r:2.1
-//
-#define qtn_iupnp_copy_main                     "Copy" 
-
-//d:Dialog title when image showing on a remote renderer is active
-//l:title_pane_t2/opt9
-//r:2.1
-//
-#define qtn_iupnp_title_showing                 "Showing"
-
-//d:Used to describe the result of copying one file
-//l:popup_note_window/opt2
-//r:2.1
-//
-#define qtn_iupnp_info_copy_one                 "1 file copied"
-
-//d:Used to describe the result of copying multiple files
-//l:popup_note_window/opt2
-//r:2.1
-//
-#define qtn_iupnp_info_copy_many                "%N files copied"
-
-//d:Used to describe when UPnP device does not support the operation 
-//d:or is not compatible with given media 
-//l:popup_note_window/opt2
-//r:2.1
-//
-#define qtn_iupnp_err_not_supported             "Selected device does not support this operation"
-
-//d:Wait note shown while content list is updating
-//l:popup_note_wait_window
-//r:wk50/2008
-//
-#define qtn_iupnp_wait_list_update              "Updating list"
-
-//d:Wait note running until the playback starts
-//l:popup_note_wait_window
-//r:2.1
-//
-#define qtn_iupnp_prog_prep_playback            "Preparing playback"
-
-//d:Used when user tries to copy an empty folder 
-//l:popup_note_window/opt2
-//r:2.1
-//
-#define qtn_iupnp_no_items_to_play_text         "Container does not contain any supported items"
-
-
-// --------------------------------------------------------------------------
-// 
-// COMMON LOCALISATION STRINGS
-// Strings are used by multiple components.
-//
-// --------------------------------------------------------------------------
-
-//d:Skipping DRM files note.
-//d:Indicates that DRM protected files will be skipped
-//d:during processing of files (show, play, copy, move).
-//l:popup_note_window/opt2
-//r:1.0
-//
-#define qtn_iupnp_drm_file_text                 "Skipping DRM protected files."
-
-//d:Connection failed note
-//l:popup_note_window/opt2
-//r:1.0
-//
-#define qtn_iupnp_err_con_failed                "Connection failed"
-
-//d:Used to describe media rendering fails due to unknown error 
-//l:popup_note_window
-//r:2.1
-//
-#define qtn_iupnp_err_rendering_failed_unknown  "Playback failed on the remote device for unknown error. Try again"
-
-//d:Used to describe when an UPnP operation failed on the remote device
-//l:popup_note_window/opt2
-//r:2.1
-//
-#define qtn_iupnp_err_general_failure           "Selected device refused the operation"
-
-//d:Used to describe when the connection is lost 
-//d:while the user is copying files
-//l:popup_note_window/opt2
-//r:2.1
-//
-#define qtn_iupnp_err_conn_lost_copy            "Connection lost, some files may not be copied"
-
-//d:Used to describe when the connection is lost 
-//d:while the user is moving files
-//l:popup_note_window/opt2
-//r:2.1
-//
-#define qtn_iupnp_err_conn_lost                 "Connection lost, some files may not be moved"
-
-// End of File
+/*
+* Copyright (c) 2008 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:  Localization strings for upnpframework subsystem.
+*
+*/
+
+
+// --------------------------------------------------------------------------
+// 
+// LOCALISATION STRINGS OF SERVICES PROVIDED FOR EXTERNAL APPLICATIONS
+// (UPnPAiwEngine, UPnPAiwProvider, UPnPCommand) 
+//
+// --------------------------------------------------------------------------
+
+//d:Application interworking (AIW) menu command.
+//d:Enables usage of external UPnP Media Rendering device.
+//l:list_single_pane_t1_cp2
+//r:1.0
+//
+#define qtn_iupnp_aiw_enable_external_string             "Show via home net."
+
+//d:Application interworking (AIW) menu command.
+//d:Disables usage of external UPnP Media Rendering device.
+//l:list_single_pane_t1_cp2
+//r:1.0
+//
+#define qtn_iupnp_aiw_disable_external_string            "Stop showing"
+
+//d:Application interworking (AIW) menu command.
+//d:Copies the selected files to an external UPnP Media Server device.
+//l:list_single_popup_submenu_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_aiw_copy_to_external_string            "Copy to home network"
+
+//d:Application interworking (AIW) menu command.
+//d:Moves the selected files to an external UPnP Media Server device.
+//l:list_single_popup_submenu_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_aiw_move_to_external_string            "Move to home network"
+
+//d:Connecting wait note.
+//d:Shown while waiting for connection to get established. 
+//l:popup_note_wait_window
+//r:wk49/2008
+//
+#define qtn_iupnp_command_connecting            "Connecting"
+
+//d:Preparing playback wait note.
+//d:Shown while waiting playback on remote device to start.
+//l:popup_note_wait_window
+//r:wk49/2008
+//
+#define qtn_iupnp_command_prep_playback         "Preparing playback"
+
+//d:Note shown when one file has been copied to 
+//d:remote server device.
+//l:popup_note_window/opt2
+//r:wk49/2008
+//
+#define qtn_iupnp_info_copy_ext_one             "1 file copied to %U"
+
+//d:Note shown when multiple files have been copied to 
+//d:remote server device. Shown also when no files have been
+//d:copied to remote server device. Happens when all files 
+//d:are drm protected.
+//l:popup_note_window/opt2
+//r:wk49/2008
+//
+#define qtn_iupnp_info_copy_ext_many            "%N files copied to %U"
+
+//d:Note shown when one file has been moved to 
+//d:remote server device. 
+//l:popup_note_window/opt2
+//r:wk49/2008
+//
+#define qtn_iupnp_info_move_ext_one             "1 file moved to %U"
+
+//d:Note shown when multiple files have been copied to 
+//d:remote server device. Shown also when no files have been
+//d:moved to remote server device. Happens when all files 
+//d:are drm protected.
+//l:popup_note_window/opt2
+//r:wk49/2008
+//
+#define qtn_iupnp_info_move_ext_many            "%N files moved to %U"
+
+
+// --------------------------------------------------------------------------
+// 
+// LOCALISATION STRINGS FOR SEARCHING SERVICES
+// (UPnPAdvFind, UPnPBrowseSearchUI)
+//
+// --------------------------------------------------------------------------
+
+//d:Media type selection title
+//l:list_setting_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_media_type               "Media type"
+
+//d:Media type selection list title
+//l:main_pane_set_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_media_type_title         "Media type"
+
+//d:media type selection item
+//d:when selected, images, video clips and music files are searched
+//l:list_set_graphic_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_mt_all                   "All"
+
+//d:media type selection item
+//d:when selected only images are searched
+//l:list_set_graphic_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_mt_image                 "Images"
+
+//d:media type selection item
+//d:when selected only videos are searched
+//l:list_set_graphic_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_mt_video                 "Video clips"
+
+//d:media type selection item
+//d:when selected only music files are searched
+//l:list_set_graphic_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_mt_music                 "Music files"
+
+//d:file name editor title
+//l:list_setting_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_find_file                "Title"
+
+//d:artist editor item title
+//l:list_setting_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_find_artist              "Artist"
+
+//d:album editor item title
+//l:list_setting_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_find_album               "Album name"
+
+//d:genre editor item title
+//l:list_setting_pane_t1
+//r:wk49/2008
+// 
+#define qtn_iupnp_find_genre               "Genre"
+
+//d:date from editor item title
+//l:list_setting_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_find_date_from           "Date from"
+
+//d:date until editor item title
+//l:list_setting_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_find_date_until          "Date until"
+
+//d:find results window title
+//l:title_pane_t2/opt9
+//r:wk49/2008
+//
+#define qtn_iupnp_search_results           "Find results"
+
+//d:wait note text when search is ongoing
+//l:popup_note_wait_window
+//r:wk49/2008
+//
+#define qtn_iupnp_finding_results_note     "Finding results"
+
+//d:text for navi pane. tells the user how many files were found
+//l:navi_text_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_nof_files                 "%N files"
+
+//d:text for navi pane. tells the user how many files were found
+//l:navi_text_pane_t1
+//r:wk49/2008
+//
+#define qtn_iupnp_nof_file                  "1 file"
+
+//d:result window error note text
+//d:error note is shown when too many result files are found
+//l:popup_note_window/opt1
+//r:wk49/2008
+//
+#define qtn_iupnp_too_big_cache_note_text   "Too many items, showing only %N"
+
+//d:Copy file error note
+//l:popup_note_window/opt2
+//r:wk08/2009
+//
+#define qtn_iupnp_copy_failed               "Copy failed. Some files may not be copied."
+
+//d:Used to describe when there is no memory while the user is copying files
+//l:popup_note_window/opt2
+//r:wk08/2009
+#define qtn_iupnp_running_out_of_memory     "Running out of memory. Some files might not be copied."
+
+//d:progress info when data is being found from a media server
+//l:navi_text_pane_t1
+//r:wk08/2009
+#define qtn_iupnp_finding                   "Finding %N%"
+
+// --------------------------------------------------------------------------
+// 
+// LOCALISATION STRINGS FOR BROWSING AND RENDERING SERVICES
+// (UPnPCommonUI) 
+//
+// --------------------------------------------------------------------------
+
+//d:Command in options list in short term memories.
+//d:Show image or video on external device.
+//l:list_single_pane_t1_cp2/opt3
+//r:1.0
+//
+#define qtn_iupnp_show_ext_main                "Show"
+
+//d:Command in options list in short term memories.
+//d:Play music file on external device.
+//l:list_single_pane_t1_cp2/opt3
+//r:1.0
+//
+#define qtn_iupnp_play_ext_main                "Play"
+
+//d:Shows or plays an item on the handset
+//d:Item in qtn_iupnp_show_ext_main or qtn_iupnp_play_ext_main
+//l:list_single_popup_submenu_pane_t1
+//r:2.1
+//
+#define qtn_iupnp_on_device                    "On device"
+
+//d:Shows or plays an item via network - on a remote device
+//d:Item in qtn_iupnp_show_ext_main or qtn_iupnp_play_ext_main
+//l:list_single_popup_submenu_pane_t1
+//r:2.1
+//
+#define qtn_iupnp_via_homenet                  "Via home net"
+
+//d:External server dialog navi pane text when searching media servers
+//l:navi_text_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_server_search_main           "Searching" 
+
+//d:External server dialog text if folder is empty
+//l:main_list_empty_pane
+//r:1.0
+//
+#define qtn_iupnp_main_empty                   "(empty)"
+
+//d:Find dialog / container view text if folder is empty
+//l:main_list_empty_pane
+//r:1.0
+//
+#define qtn_iupnp_no_files_found               "No files found"
+
+//d:Time format on navigation pane when playing video on remote device
+//l:navi_text_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_sep_slash                     "%0U/%1U"
+
+//d:Softkey command
+//d:Continue video display
+//l:control_pane_t1/opt7
+//r:1.0
+//
+#define qtn_iupnp_sk_continue                  "Continue"
+
+//d:Softkey command
+//d:Replay video display
+//l:control_pane_t1/opt7
+//r:1.0
+//
+#define qtn_iupnp_sk_replay                    "Replay"
+
+//d:Information note header for UPnP media renderer selection
+//l:heading_pane_t1/opt2
+//r:1.0
+//
+#define qtn_iupnp_select_player                "Select player:"
+
+//d:Information note header for UPnP device selection
+//l:heading_pane_t1/opt2
+//r:1.0
+//
+#define qtn_iupnp_select_device                "Select device:"
+
+//d:Title pane text
+//l:title_pane_t2/opt9
+//r:2.1
+//
+#define qtn_iupnp_title_ext_media_2            "Home Media"   
+
+//d:submenu title when copying file from external device to handset
+//l:list_single_pane_t1_cp2
+//r:2.1
+//
+#define qtn_iupnp_copy_main                     "Copy" 
+
+//d:Dialog title when image showing on a remote renderer is active
+//l:title_pane_t2/opt9
+//r:2.1
+//
+#define qtn_iupnp_title_showing                 "Showing"
+
+//d:Used to describe the result of copying one file
+//l:popup_note_window/opt2
+//r:2.1
+//
+#define qtn_iupnp_info_copy_one                 "1 file copied"
+
+//d:Used to describe the result when no files copied
+//l:popup_note_window/opt2
+//r:2.1
+//
+#define qtn_iupnp_info_copy_none                "No files were copied"
+
+//d:Used to describe the result of copying multiple files
+//l:popup_note_window/opt2
+//r:2.1
+//
+#define qtn_iupnp_info_copy_many                "%N files copied"
+
+//d:Used to describe when UPnP device does not support the operation 
+//d:or is not compatible with given media 
+//l:popup_note_window/opt2
+//r:2.1
+//
+#define qtn_iupnp_err_not_supported             "Selected device does not support this operation"
+
+//d:Wait note shown while content list is updating
+//l:popup_note_wait_window
+//r:wk50/2008
+//
+#define qtn_iupnp_wait_list_update              "Updating list"
+
+//d:Wait note running until the playback starts
+//l:popup_note_wait_window
+//r:2.1
+//
+#define qtn_iupnp_prog_prep_playback            "Preparing playback"
+
+//d:Used when user tries to copy an empty folder 
+//l:popup_note_window/opt2
+//r:2.1
+//
+#define qtn_iupnp_no_items_to_play_text         "Container does not contain any supported items"
+
+//d:Wait note shown while opening a server for browsing
+//l:popup_note_wait_window
+//r:wk08/2009
+//
+#define qtn_iupnp_wait_opening_server           "Opening"
+
+//d:progress info when data is being retrieved from a media server
+//l:navi_text_pane_t1
+//r:wk10/2009
+#define qtn_iupnp_updating                      "Updating %N%"
+
+//d:Information note header for music playback device selection
+//l:heading_pane_t1
+//r:wk10/2009
+//
+#define qtn_iupnp_popup_play                    "Play:"
+
+//d:Information note header for image/video playback device selection
+//l:heading_pane_t1
+//r:wk10/2009
+//
+#define qtn_iupnp_popup_show                    "Show:"
+
+//d:Show or play an item on the handset
+//l:list_single_pane_t1_cp2
+//r:wk10/2009
+//
+#define qtn_iupnp_popup_on_device               "On device"
+
+//d:Show or play an item via network - on a remote device
+//l:list_single_pane_t1_cp2
+//r:wk10/2009
+//
+#define qtn_iupnp_popup_via_home_net            "Via Home net"
+
+// --------------------------------------------------------------------------
+// 
+// COMMON LOCALISATION STRINGS
+// Strings are used by multiple components.
+//
+// --------------------------------------------------------------------------
+
+//d:Skipping DRM files note.
+//d:Indicates that DRM protected files will be skipped
+//d:during processing of files (show, play, copy, move).
+//l:popup_note_window/opt2
+//r:1.0
+//
+#define qtn_iupnp_drm_file_text                 "Skipping DRM protected files."
+
+//d:Connection failed note
+//l:popup_note_window/opt2
+//r:1.0
+//
+#define qtn_iupnp_err_con_failed                "Connection failed"
+
+//d:Used to describe media rendering fails due to unknown error 
+//l:popup_note_window
+//r:2.1
+//
+#define qtn_iupnp_err_rendering_failed_unknown  "Playback failed on the remote device for unknown error. Try again"
+
+//d:Used to describe when an UPnP operation failed on the remote device
+//l:popup_note_window/opt2
+//r:2.1
+//
+#define qtn_iupnp_err_general_failure           "Selected device refused the operation"
+
+//d:Used to describe when the connection is lost 
+//d:while the user is copying files
+//l:popup_note_window/opt2
+//r:2.1
+//
+#define qtn_iupnp_err_conn_lost_copy            "Connection lost, some files may not be copied"
+
+//d:Used to describe when the connection is lost 
+//d:while the user is moving files
+//l:popup_note_window/opt2
+//r:2.1
+//
+#define qtn_iupnp_err_conn_lost                 "Connection lost, some files may not be moved"
+
+//d:Used to describe when rendering is failed
+//d:while some other controlpoint is using rendere
+//l:popup_note_window/opt2
+//r:2.1
+//
+#define qtn_iupnp_renderer_in_use               "%U is already in use. Please try again later."
+
+// End of File
--- a/upnpframework/upnpcommand/data/upnpcommandresources.rss	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/data/upnpcommandresources.rss	Mon Nov 01 12:37:49 2010 +0200
@@ -1,154 +1,163 @@
-/*
-* Copyright (c) 2007 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:  Resource definitions for project UpnpCommand
-*
-*/
-
-
-NAME UPCR
-
-// INCLUDES
-#include <avkon.rh>
-#include <avkon.rsg>
-#include <avkon.mbg>
-#include <eikon.rh>
-#include <upnpframework.loc>
-#include "upnpcommand.rh"
-
-// RESOURCE IDENTIFIERS
-
-RESOURCE RSS_SIGNATURE { }
-RESOURCE TBUF { buf=""; }
-
-// --------------------------------------------------------------------------
-// r_command_drm_file_text
-// "Skipping DRM protected files." - note
-// Used to indicate that DRM protected files will be skipped.
-// --------------------------------------------------------------------------
-RESOURCE TBUF r_command_drm_file_text
-    { 
-    buf = qtn_iupnp_drm_file_text;
-    }
-
-// --------------------------------------------------------------------------
-// r_command_err_rendering_failed_unknown_text
-// "Playback failed on the remote device for unknown error. Try again" - note
-// General error when playing from local to remote
-// --------------------------------------------------------------------------
-RESOURCE TBUF r_command_err_rendering_failed_unknown_text
-    { 
-    buf = qtn_iupnp_err_rendering_failed_unknown;
-    }
-
-// --------------------------------------------------------------------------
-// r_command_connecting_wait_note
-// A wait note shown when preparing media to be shown on home network
-// --------------------------------------------------------------------------
-RESOURCE DIALOG r_command_connecting_wait_note
-    {
-    flags = EAknWaitNoteFlags | EEikDialogFlagWait;
-    buttons = R_AVKON_SOFTKEYS_CANCEL;
-    items =
-        {
-        DLG_LINE
-            {
-            type = EAknCtNote;
-            id = EUPnPBrowseDialogProgressNote;
-            control = AVKON_NOTE
-                {
-                layout         = EWaitLayout;
-                singular_label = qtn_iupnp_command_connecting;
-                imageid        = EMbmAvkonQgn_note_progress;
-                imagemask      = EMbmAvkonQgn_note_progress_mask;
-                animation      = R_QGN_GRAF_WAIT_BAR_ANIM;
-                };
-            }
-        };
-    }
-
-// --------------------------------------------------------------------------
-// r_command_info_copy_ext_one_text
-// --------------------------------------------------------------------------
-//
-RESOURCE TBUF r_command_info_copy_ext_one_text
-    {
-    buf = qtn_iupnp_info_copy_ext_one;
-    }
-
-
-// --------------------------------------------------------------------------
-// r_command_info_copy_ext_many_text
-// --------------------------------------------------------------------------
-//
-RESOURCE TBUF r_command_info_copy_ext_many_text
-    {
-    buf = qtn_iupnp_info_copy_ext_many;
-    }
-
-// --------------------------------------------------------------------------
-// r_command_info_move_ext_one_text
-// --------------------------------------------------------------------------
-//
-RESOURCE TBUF r_command_info_move_ext_one_text
-    {
-    buf = qtn_iupnp_info_move_ext_one;
-    }
-
-
-// --------------------------------------------------------------------------
-// r_command_info_move_ext_many_text
-// --------------------------------------------------------------------------
-//
-RESOURCE TBUF r_command_info_move_ext_many_text
-    {
-    buf = qtn_iupnp_info_move_ext_many;
-    }
-
-// --------------------------------------------------------------------------
-// r_command_err_general_failure_text
-// --------------------------------------------------------------------------
-//
-RESOURCE TBUF r_command_err_general_failure_text
-    {
-    buf = qtn_iupnp_err_general_failure;
-    }
-
-// --------------------------------------------------------------------------
-// r_command_err_conn_lost_copy_text
-// --------------------------------------------------------------------------
-//
-RESOURCE TBUF r_command_err_conn_lost_copy_text
-    {
-    buf = qtn_iupnp_err_conn_lost_copy;
-    }
-
-// --------------------------------------------------------------------------
-// r_command_err_conn_lost_move_text
-// --------------------------------------------------------------------------
-//
-RESOURCE TBUF r_command_err_conn_lost_move_text
-    {
-    buf = qtn_iupnp_err_conn_lost;
-    }
-
-// --------------------------------------------------------------------------
-// r_command_err_con_failed_text
-// --------------------------------------------------------------------------
-//
-RESOURCE TBUF r_command_err_con_failed_text
-    {
-    buf = qtn_iupnp_err_con_failed;
-    }
-
-// End of file
+/*
+* Copyright (c) 2007 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:  Resource definitions for project UpnpCommand
+*
+*/
+
+
+NAME UPCR
+
+// INCLUDES
+#include <avkon.rh>
+#include <avkon.rsg>
+#include <avkon.mbg>
+#include <eikon.rh>
+#include <upnpframework.loc>
+#include "upnpcommand.rh"
+
+// RESOURCE IDENTIFIERS
+
+RESOURCE RSS_SIGNATURE { }
+RESOURCE TBUF { buf=""; }
+
+// --------------------------------------------------------------------------
+// r_command_drm_file_text
+// "Skipping DRM protected files." - note
+// Used to indicate that DRM protected files will be skipped.
+// --------------------------------------------------------------------------
+RESOURCE TBUF r_command_drm_file_text
+    { 
+    buf = qtn_iupnp_drm_file_text;
+    }
+
+// --------------------------------------------------------------------------
+// r_command_err_rendering_failed_unknown_text
+// "Playback failed on the remote device for unknown error. Try again" - note
+// General error when playing from local to remote
+// --------------------------------------------------------------------------
+RESOURCE TBUF r_command_err_rendering_failed_unknown_text
+    { 
+    buf = qtn_iupnp_err_rendering_failed_unknown;
+    }
+
+// --------------------------------------------------------------------------
+// r_command_connecting_wait_note
+// A wait note shown when preparing media to be shown on home network
+// --------------------------------------------------------------------------
+RESOURCE DIALOG r_command_connecting_wait_note
+    {
+    flags = EAknWaitNoteFlags | EEikDialogFlagWait;
+    buttons = R_AVKON_SOFTKEYS_CANCEL;
+    items =
+        {
+        DLG_LINE
+            {
+            type = EAknCtNote;
+            id = EUPnPBrowseDialogProgressNote;
+            control = AVKON_NOTE
+                {
+                layout         = EWaitLayout;
+                singular_label = qtn_iupnp_command_connecting;
+                imageid        = EMbmAvkonQgn_note_progress;
+                imagemask      = EMbmAvkonQgn_note_progress_mask;
+                animation      = R_QGN_GRAF_WAIT_BAR_ANIM;
+                };
+            }
+        };
+    }
+
+// --------------------------------------------------------------------------
+// r_command_info_copy_ext_one_text
+// --------------------------------------------------------------------------
+//
+RESOURCE TBUF r_command_info_copy_ext_one_text
+    {
+    buf = qtn_iupnp_info_copy_ext_one;
+    }
+
+
+// --------------------------------------------------------------------------
+// r_command_info_copy_ext_many_text
+// --------------------------------------------------------------------------
+//
+RESOURCE TBUF r_command_info_copy_ext_many_text
+    {
+    buf = qtn_iupnp_info_copy_ext_many;
+    }
+
+// --------------------------------------------------------------------------
+// r_command_info_move_ext_one_text
+// --------------------------------------------------------------------------
+//
+RESOURCE TBUF r_command_info_move_ext_one_text
+    {
+    buf = qtn_iupnp_info_move_ext_one;
+    }
+
+
+// --------------------------------------------------------------------------
+// r_command_info_move_ext_many_text
+// --------------------------------------------------------------------------
+//
+RESOURCE TBUF r_command_info_move_ext_many_text
+    {
+    buf = qtn_iupnp_info_move_ext_many;
+    }
+
+// --------------------------------------------------------------------------
+// r_command_err_general_failure_text
+// --------------------------------------------------------------------------
+//
+RESOURCE TBUF r_command_err_general_failure_text
+    {
+    buf = qtn_iupnp_err_general_failure;
+    }
+
+// --------------------------------------------------------------------------
+// r_command_err_conn_lost_copy_text
+// --------------------------------------------------------------------------
+//
+RESOURCE TBUF r_command_err_conn_lost_copy_text
+    {
+    buf = qtn_iupnp_err_conn_lost_copy;
+    }
+
+// --------------------------------------------------------------------------
+// r_command_err_conn_lost_move_text
+// --------------------------------------------------------------------------
+//
+RESOURCE TBUF r_command_err_conn_lost_move_text
+    {
+    buf = qtn_iupnp_err_conn_lost;
+    }
+
+// --------------------------------------------------------------------------
+// r_command_err_con_failed_text
+// --------------------------------------------------------------------------
+//
+RESOURCE TBUF r_command_err_con_failed_text
+    {
+    buf = qtn_iupnp_err_con_failed;
+    }
+
+// --------------------------------------------------------------------------
+// r_command_renderer_in_use_text
+// --------------------------------------------------------------------------
+//
+RESOURCE TBUF r_command_renderer_in_use_text
+    {
+    buf = qtn_iupnp_renderer_in_use;
+    }
+
+// End of file
--- a/upnpframework/upnpcommand/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,32 +1,30 @@
-/*
-* Copyright (c) 2007 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:  Build information file for project UpnpCommand component
-*
-*/
-
-
-PRJ_PLATFORMS
-DEFAULT
-
-PRJ_EXPORTS
-
-PRJ_MMPFILES
-
-    // both the command interface and the interface implementation
-    #ifdef FF_UPNP_FRAMEWORK_2_0  // UPnP feature flag
-    upnpcommandplugin.mmp
-    #endif // FF_UPNP_FRAMEWORK_2_0
-    upnpcommand.mmp
-
-// End of file
+/*
+* Copyright (c) 2007 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:  Build information file for project UpnpCommand component
+*
+*/
+
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+PRJ_MMPFILES
+
+    // both the command interface and the interface implementation
+    //upnpcommandplugin.mmp
+    upnpcommand.mmp
+
+// End of file
--- a/upnpframework/upnpcommand/group/upnpcommandplugin.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/group/upnpcommandplugin.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,110 +1,114 @@
-/*
-* Copyright (c) 2007 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:  Project definition file for project UpnpCommand component
-*
-*/
-
-
-// For compatibility with S60 3.2 and IAD branch
-#include "../../../group/upnpplatformvar.hrh"
-#include <data_caging_paths.hrh>
-#include "../inc/upnpcommanduids.hrh"
-
-
-// Build target
-TARGET          upnpcommandplugin.dll
-CAPABILITY      CAP_ECOM_PLUGIN
-TARGETTYPE      PLUGIN
-UID             0x10009D8D KUpnpCommandPluginDllUid
-VENDORID        VID_DEFAULT
-
-// SIS installation + IAD support
-VERSION 10.1
-paged
-
-// Build UI resources
-SOURCEPATH      ../data
-START RESOURCE  upnpcommandresources.rss
-HEADER
-TARGET          upnpcommandresources.rsc
-TARGETPATH      RESOURCE_FILES_DIR
-LANGUAGE_IDS
-END
-
-// Build ECom plugin resources
-START RESOURCE  ../data/200075DB.rss
-TARGET          upnpcommandplugin.rsc
-TARGETPATH      resource/plugins
-END
-
-// Source files
-SOURCEPATH      ../src
-SOURCE          upnpcommandproxy.cpp
-SOURCE          upnpfilepipe.cpp
-SOURCE          upnpnotehandler.cpp
-SOURCE          upnpcommandparameters.cpp
-SOURCE          upnpcommandimplementation.cpp
-SOURCE          upnptask.cpp
-SOURCE          upnpshowtask.cpp
-SOURCE          upnpcopytask.cpp
-SOURCE          upnpmovetask.cpp
-SOURCE          upnpbrowsetask.cpp
-SOURCE          upnprunsetuptask.cpp
-SOURCE          upnpfiletransferbasetask.cpp
-SOURCE          upnptaskresourceallocator.cpp
-SOURCE          upnpimagerenderingengine.cpp
-
-// Include directories
-USERINCLUDE     ../data
-USERINCLUDE     ../inc
-USERINCLUDE     ../../inc
-USERINCLUDE     ../../../inc
-USERINCLUDE     ../../upnputilities/inc
-
-MW_LAYER_SYSTEMINCLUDE
-UPNP_LOC_INCLUDE_PATH_COMPONENT
-
-// Core
-LIBRARY         euser.lib
-LIBRARY         bafl.lib            // BaflUtils
-LIBRARY         cone.lib            // CCoeEnv
-LIBRARY         centralrepository.lib // CRepository
-
-// Dialogs
-LIBRARY         avkon.lib
-
-// StringLoader
-LIBRARY         CommonEngine.lib
-
-// ECom
-LIBRARY         ecom.lib
-
-// Logging
-DEBUGLIBRARY    flogger.lib
-
-// Char conversion
-LIBRARY         charconv.lib
-
-// Upnp Framework
-LIBRARY         upnputilities.lib
-LIBRARY         upnpavobjects.lib
-LIBRARY         upnpavcontrollerclient.lib
-LIBRARY         upnpavcontrollerhelper.lib
-LIBRARY         upnpcommonui.lib
-LIBRARY         upnpfiletransferengine.lib
-LIBRARY         upnpappwizard.lib
-LIBRARY         upnpapplicationengine.lib
-LIBRARY         upnpsettingsengine.lib
-
-// End of file
+/*
+* Copyright (c) 2007 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:  Project definition file for project UpnpCommand component
+*
+*/
+
+
+// For compatibility with S60 3.2 and IAD branch
+#include "../../../group/upnpplatformvar.hrh"
+#include <data_caging_paths.hrh>
+#include "../inc/upnpcommanduids.hrh"
+
+
+// Build target
+TARGET          upnpcommandplugin.dll
+CAPABILITY      CAP_ECOM_PLUGIN
+TARGETTYPE      PLUGIN
+UID             0x10009D8D KUpnpCommandPluginDllUid
+VENDORID        VID_DEFAULT
+
+// SIS installation + IAD support
+VERSION 10.1
+paged
+
+// Build UI resources
+SOURCEPATH      ../data
+START RESOURCE  upnpcommandresources.rss
+HEADER
+TARGET          upnpcommandresources.rsc
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+// Build ECom plugin resources
+START RESOURCE  ../data/200075DB.rss
+TARGET          upnpcommandplugin.rsc
+TARGETPATH      resource/plugins
+END
+
+// Source files
+SOURCEPATH      ../src
+SOURCE          upnpcommandproxy.cpp
+SOURCE          upnpfilepipe.cpp
+SOURCE          upnpnotehandler.cpp
+SOURCE          upnpcommandparameters.cpp
+SOURCE          upnpcommandimplementation.cpp
+SOURCE          upnptask.cpp
+SOURCE          upnpshowtask.cpp
+SOURCE          upnpcopytask.cpp
+SOURCE          upnpmovetask.cpp
+SOURCE          upnpbrowsetask.cpp
+SOURCE          upnprunsetuptask.cpp
+SOURCE          upnpfiletransferbasetask.cpp
+SOURCE          upnptaskresourceallocator.cpp
+SOURCE          upnpimagerenderingengine.cpp
+
+// Include directories
+USERINCLUDE     ../data
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+USERINCLUDE     ../../../inc
+USERINCLUDE     ../../upnputilities/inc
+
+MW_LAYER_SYSTEMINCLUDE
+UPNP_LOC_INCLUDE_PATH_COMPONENT
+
+// Core
+LIBRARY         euser.lib
+LIBRARY         bafl.lib            // BaflUtils
+LIBRARY         cone.lib            // CCoeEnv
+LIBRARY         centralrepository.lib // CRepository
+
+// Dialogs
+LIBRARY         avkon.lib
+
+// StringLoader
+LIBRARY         commonengine.lib
+
+// ECom
+LIBRARY         ecom.lib
+
+// Logging
+DEBUGLIBRARY    flogger.lib
+
+// Char conversion
+LIBRARY         charconv.lib
+
+// dlnasrv
+LIBRARY         upnputilities.lib
+LIBRARY         upnpavobjects.lib
+LIBRARY         upnpavcontrollerclient.lib
+LIBRARY         upnpavcontrollerhelper.lib
+LIBRARY         upnpcommonui.lib
+LIBRARY         upnpfiletransferengine.lib
+LIBRARY         upnpappwizard.lib
+LIBRARY         upnpapplicationengine.lib
+LIBRARY         upnpsettingsengine.lib
+LIBRARY         upnprenderingstatemachine.lib
+
+// Upnp Stack
+LIBRARY         upnpipserversutils.lib
+
+// End of file
--- a/upnpframework/upnpcommand/inc/upnpcommand.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/inc/upnpcommand.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,189 +1,190 @@
-/*
-* Copyright (c) 2008 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:  UpnpCommand plugin interface
-*
-*/
-
-
-#ifndef UPNP_COMMAND_H
-#define UPNP_COMMAND_H
-
-// INCLUDES
-#include <ecom/ecom.h>                       // REComSession
-#include <e32std.h>                     // RLibrary
-#include "upnpcommandcons.h"
-
-// FORWARD DECLARATION
-class MUpnpCommandCallback;
-
-// CONSTANTS
-
-
-// CLASS DEFINITION
-
-/**
-* UpnpCommand ECom plugin interface definition.
-*/
-class CUpnpCommand : public CBase
-    {
-    public: // constructing / destructing
-
-        /**
-         * the DtorKey offset
-         * to pass in REComSession::CreateImplementationL
-         */
-        static inline TInt32 DtorKeyOffset()
-            {
-            return _FOFF( CUpnpCommand, iDtor_ID_Key );
-            }
-
-        /**
-         * Sets the command identity.
-         *
-         * @param aCommandId (UpnpCommand::TUpnpCommandId) the command ID
-         */
-        virtual void SetCommandIdL(
-            UpnpCommand::TUpnpCommandId aCommandId ) = 0;
-
-        /**
-         * Sets the observer.
-         *
-         * @param aCallback The callback interface
-         */
-        virtual void SetObserver( MUpnpCommandCallback* aCallback ) = 0;
-
-        /**
-         * Destructor.
-         */
-        virtual ~CUpnpCommand();
-
-    public: // Method for querying the availablity
-
-        /**
-         * Checks if this command is available for execution.
-         *
-         * @return ETrue if command is available and can be executed
-         */
-        virtual TBool IsAvailableL() = 0;
-
-        /**
-         * Checks if given command is available for execution.
-         *
-         * @param aCommandId (UpnpCommand::TUpnpCommandId) the command ID
-         * @return ETrue if command is available and can be executed
-         */
-        virtual TBool IsAvailableL( UpnpCommand::TUpnpCommandId aCommandId ) = 0;
-
-    public: // Business logic methods
-
-        /**
-         * Allocates the Upnp Framework resources.
-         */
-        virtual void AllocateResourcesL() = 0;
-
-        /**
-         * Releases the Upnp Framework resources. Stops command execution if
-         * it is ongoing.
-         */
-        virtual void ReleaseResources() = 0;
-
-        /**
-         * Executes the command. If Upnp Framework resources are not yet
-         * allocated, they are allocated.
-         */
-        virtual void ExecuteL() = 0;
-
-        /**
-         * Sets a parameter.
-         *
-         * Leaves if the given param type or value is not valid.
-         *
-         * @param aParamType parameter category
-         * @param aParamValue (const TDesC&) parameter value
-         */
-        virtual void SetParameterL(
-                                UpnpCommand::TUpnpParameterType aParamType,
-                                const TDesC& aParamValue ) = 0;
-
-        /**
-         * Returns a parameter, either set by client or returned
-         * as an out parameter after command execution
-         *
-         * @param aParamType (UpnpCommand::TUpnpParameterType)
-         * @return value of the parameter
-         */
-        virtual const TDesC& Parameter(
-            UpnpCommand::TUpnpParameterType aParamType ) = 0;
-
-        /**
-         * Resets all parameter values
-         */
-        virtual void ResetParameters() = 0;
-
-        /**
-         * Pushes one file into the file pipe.
-         *
-         * @param aParamvalue (const TDesC&) parameter value
-         */
-        virtual void PushFileL( const TDesC& aParam ) = 0;
-
-        /**
-         * number of files in the file pipe
-         *
-         * @return number of files in the pipe
-         */
-        virtual TInt FileCount() = 0;
-
-        /**
-         * Returns a file in the file pipe
-         *
-         * @param aIndex index of the file in pipe
-         * @return the file reference
-         */
-        virtual const TDesC& File( TInt aIndex ) = 0;
-
-        /**
-         * Resets files in the file pipe
-         */
-        virtual void ResetFiles() = 0;
-
-        /**
-         * Returns the state of the command
-         *
-         * @return UpnpCommand::TUpnpCommandState the state
-         */
-        virtual UpnpCommand::TUpnpCommandState State() = 0;
-
-    private: // Private data members
-
-        /**
-         * ECom instance identifier key.
-         */
-        TUid iDtor_ID_Key;
-
-    };
-
-
-// --------------------------------------------------------------------------
-// Destructor.
-// --------------------------------------------------------------------------
-//
-inline CUpnpCommand::~CUpnpCommand()
-    {
-    REComSession::DestroyedImplementation( iDtor_ID_Key );
-    }
-
-#endif // UPNP_COMMAND_H
-
-// End of File
+/*
+* Copyright (c) 2008 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:  UpnpCommand plugin interface
+*
+*/
+
+
+#ifndef UPNP_COMMAND_H
+#define UPNP_COMMAND_H
+
+// INCLUDES
+#include <ecom/ecom.h>                       // REComSession
+#include <e32std.h>                     // RLibrary
+#include "upnpcommandcons.h"
+
+// FORWARD DECLARATION
+class MUpnpCommandCallback;
+
+// CONSTANTS
+
+
+// CLASS DEFINITION
+
+/**
+* UpnpCommand ECom plugin interface definition.
+*/
+class CUpnpCommand : public CBase
+    {
+    public: // constructing / destructing
+
+        /**
+         * the DtorKey offset
+         * to pass in REComSession::CreateImplementationL
+         */
+        static inline TInt32 DtorKeyOffset()
+            {
+            return _FOFF( CUpnpCommand, iDtor_ID_Key );
+            }
+
+        /**
+         * Sets the command identity.
+         *
+         * @param aCommandId (UpnpCommand::TUpnpCommandId) the command ID
+         */
+        virtual void SetCommandIdL(
+            UpnpCommand::TUpnpCommandId aCommandId ) = 0;
+
+        /**
+         * Sets the observer.
+         *
+         * @param aCallback The callback interface
+         */
+        virtual void SetObserver( MUpnpCommandCallback* aCallback ) = 0;
+
+        /**
+         * Destructor.
+         */
+        virtual ~CUpnpCommand();
+
+    public: // Method for querying the availablity
+
+        /**
+         * Checks if this command is available for execution.
+         *
+         * @return ETrue if command is available and can be executed
+         */
+        virtual TBool IsAvailableL() = 0;
+
+        /**
+         * Checks if given command is available for execution.
+         *
+         * @param aCommandId (UpnpCommand::TUpnpCommandId) the command ID
+         * @return ETrue if command is available and can be executed
+         */
+        virtual TBool IsAvailableL( 
+                        UpnpCommand::TUpnpCommandId aCommandId ) = 0;
+
+    public: // Business logic methods
+
+        /**
+         * Allocates the Upnp Framework resources.
+         */
+        virtual void AllocateResourcesL() = 0;
+
+        /**
+         * Releases the Upnp Framework resources. Stops command execution if
+         * it is ongoing.
+         */
+        virtual void ReleaseResources() = 0;
+
+        /**
+         * Executes the command. If Upnp Framework resources are not yet
+         * allocated, they are allocated.
+         */
+        virtual void ExecuteL() = 0;
+
+        /**
+         * Sets a parameter.
+         *
+         * Leaves if the given param type or value is not valid.
+         *
+         * @param aParamType parameter category
+         * @param aParamValue (const TDesC&) parameter value
+         */
+        virtual void SetParameterL(
+                                UpnpCommand::TUpnpParameterType aParamType,
+                                const TDesC& aParamValue ) = 0;
+
+        /**
+         * Returns a parameter, either set by client or returned
+         * as an out parameter after command execution
+         *
+         * @param aParamType (UpnpCommand::TUpnpParameterType)
+         * @return value of the parameter
+         */
+        virtual const TDesC& Parameter(
+            UpnpCommand::TUpnpParameterType aParamType ) = 0;
+
+        /**
+         * Resets all parameter values
+         */
+        virtual void ResetParameters() = 0;
+
+        /**
+         * Pushes one file into the file pipe.
+         *
+         * @param aParamvalue (const TDesC&) parameter value
+         */
+        virtual void PushFileL( const TDesC& aParam ) = 0;
+
+        /**
+         * number of files in the file pipe
+         *
+         * @return number of files in the pipe
+         */
+        virtual TInt FileCount() = 0;
+
+        /**
+         * Returns a file in the file pipe
+         *
+         * @param aIndex index of the file in pipe
+         * @return the file reference
+         */
+        virtual const TDesC& File( TInt aIndex ) = 0;
+
+        /**
+         * Resets files in the file pipe
+         */
+        virtual void ResetFiles() = 0;
+
+        /**
+         * Returns the state of the command
+         *
+         * @return UpnpCommand::TUpnpCommandState the state
+         */
+        virtual UpnpCommand::TUpnpCommandState State() = 0;
+
+    private: // Private data members
+
+        /**
+         * ECom instance identifier key.
+         */
+        TUid iDtor_ID_Key;
+
+    };
+
+
+// --------------------------------------------------------------------------
+// Destructor.
+// --------------------------------------------------------------------------
+//
+inline CUpnpCommand::~CUpnpCommand()
+    {
+    REComSession::DestroyedImplementation( iDtor_ID_Key );
+    }
+
+#endif // UPNP_COMMAND_H
+
+// End of File
--- a/upnpframework/upnpcommand/inc/upnpimagerenderingengine.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/inc/upnpimagerenderingengine.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,254 +1,309 @@
-/*
-* Copyright (c) 2007 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:  Engine for rendering images remotely
-*
-*/
-
-
-#ifndef UPNP_IMAGERENDERINGENGINE_H
-#define UPNP_IMAGERENDERINGENGINE_H
-
-// INCLUDES
-#include <e32base.h>
-#include "upnpavrenderingsessionobserver.h" // base class
-#include "upnpitemresolverobserver.h" // base class
-
-// FORWARD DECLARATIONS
-class MUPnPAVController;
-class MUPnPAVRenderingSession;
-class MUpnpImageRenderingEngineObserver;
-class MUPnPItemResolver;
-class CUPnPPeriodic;
-
-/**
-* This class defines the UpnpShowTask used in UpnpCommand component.
-*
-* @since S60 3.2
-*/
-class CUpnpImageRenderingEngine
-    : public CBase
-    , public MUPnPItemResolverObserver
-    , public MUPnPAVRenderingSessionObserver
-    {
-
-    public: // construction
-
-        /**
-         * static constructor
-         * @param aAVController avcontroller resource
-         * @param aSession the rendering session to work with
-         * @param aObserver the client for this engine
-         */
-        static CUpnpImageRenderingEngine* NewL(
-            MUPnPAVController& aAVController,
-            MUPnPAVRenderingSession& aSession,
-            MUpnpImageRenderingEngineObserver& aObserver);
-
-        /**
-         * destructor
-         */
-        virtual ~CUpnpImageRenderingEngine();
-
-    private: // private part of construction
-
-        /**
-         * constructor
-         */
-        CUpnpImageRenderingEngine(
-            MUPnPAVController& aAVController,
-            MUPnPAVRenderingSession& aSession,
-            MUpnpImageRenderingEngineObserver& aObserver);
-        
-     
-        /**
-         * Second phase constructor
-         */
-        void ConstructL();
-        
-        
-        /**
-         * Cleans up used resources
-         */
-        void Cleanup();
-
-    public: // the interface
-
-        /**
-         * Requests to start rendering. This will cause the engine to query
-         * the media to render using the callback interface.
-         * This method can be called in all states and all conditions
-         * and subsequently very fast. The engine will keep track of
-         * states and indicate errors etc.
-         */
-        void PlayL();
-
-        /**
-         * Requests to stop rendering. This method can be called in all states.
-         */
-        void StopL();
-
-
-    protected: // Call back methods of MUPnPAVRenderingSessionObserver
-
-        /**
-         * UPnP AV Controller calls this method to return the result for the
-         * 'set uri' request.
-         *
-         * @since Series 60 3.1
-         * @param aError error code
-         * @return None
-         */
-        void SetURIResult( TInt aError );
-
-        /**
-         * UPnP AV Controller calls this method to indicate that the requested
-         * interaction operation (play, stop, etc.) is complete. In other
-         * words, the target rendering device has changed it's state 
-         * accordingly.
-         *
-         * @since Series 60 3.1
-         * @param aError (TInt) error code
-         * @param aOperation (TAVInteractOperation) operation Id
-         */
-        void InteractOperationComplete( TInt aError,
-            TUPnPAVInteractOperation aOperation );
-
-        /**
-         * Notifies that the Media Renderer we have a session with has
-         * disappeared. Session is now unusable and must be closed. 
-         *
-         * @since Series 60 3.1
-         * @param aReason (TUPnPDeviceDisconnectedReason) reason code
-         */
-        void MediaRendererDisappeared(
-            TUPnPDeviceDisconnectedReason aReason );
-
-        // Methods that are not used
-        void VolumeResult(
-                        TInt /*aError*/,
-                        TInt /*aVolumeLevel*/,
-                        TBool /*aActionResponse*/) {}
-        void MuteResult(
-                        TInt /*aError*/,
-                        TBool /*aMute*/,
-                        TBool /*aActionResponse*/ ) {}
-        void PositionInfoResult(
-                        TInt /*aError*/,
-                        const TDesC8& /*aTrackPosition*/,
-                        const TDesC8& /*aTrackLength*/ ) {}
-        void SetNextURIResult(
-                        TInt /*aError*/ ) {}
-            
-        void ReserveLocalMSServicesCompleted( TInt /*aError*/ ) {}
-
-    protected: // Methods from MUPnPItemResolverObserver
-
-        /**
-         * See UpnpAvControllerHelper API for more info.
-         */
-        void ResolveComplete(
-            const MUPnPItemResolver& aResolver, TInt aError );
-
-    public: // methods for the timer
-
-        /**
-         * the timeout callback
-         */
-        static TInt Timer( TAny* aArg );
-
-        /**
-         * handles the timeout internally
-         */
-        void RunTimerL();
-
-        /**
-         * handles errors in the timeout callback body
-         */
-        TInt RunError( TInt );
-        
-         /**
-         * checks if wlan is active
-         */       
-        TBool IsWlanActive();
-        
-    private: // Private methods
-
-        /**
-         * Handles the initiation of rendering (SetUri or video player 
-         * launching).
-         *
-         * @since S60 3.2
-         */
-        void InitiateShowingL();
-
-        /**
-         * Handles the start up of the item resolving.
-         *
-         * @since S60 3.2
-         */
-        void StartResolvingL();
-        
-        
-        /**
-         * Sends an acknowledgement
-		 */
-		void SendRenderAck( TInt aError );
-
-    private: // Data members
-
-        // avcontroller
-        MUPnPAVController&          iAVController;
-    
-        // the rendering session
-        MUPnPAVRenderingSession&    iRenderingSession;
-
-        // The observer interface
-        MUpnpImageRenderingEngineObserver&  iObserver;
-
-        // internal states
-        enum TRenderingState
-            {
-            EIdle = 100,            // doing nothing
-            EResolvingItem,         // resolving (preparing the item to be played)
-            EResolveComplete,       // resolve done succesfully. Starting to play
-            EStopping,              // calling Stop (for previoysly playing item)
-            ESettingUri,            // calling SetAVTransportURI
-            EStartingPlay,          // calling Play
-            EPlaying,               // play OK, just displaying the image :-)
-            EShuttingDown
-            };
-
-        // internal state
-        TRenderingState             iState;
-
-        // current resolver. owned.
-        MUPnPItemResolver*          iCurrentResolver;
-
-        // Buffered next resolver. Owned.
-        MUPnPItemResolver*          iBufferedResolver;
-
-        // flag that indicates a new image is in buffer
-        TBool                       iBufferingNewImage;
-
-		// timer support
-		CUPnPPeriodic*              iTimer;
-		
-		TBool                       iWlanActive;
-
-	};
-
-
-#endif // UPNP_IMAGERENDERINGENGINE_H
-
-// End of File
+/*
+* Copyright (c) 2009 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:  Engine for rendering images remotely
+*
+*/
+
+
+#ifndef UPNP_IMAGERENDERINGENGINE_H
+#define UPNP_IMAGERENDERINGENGINE_H
+
+// INCLUDES
+#include <e32base.h>
+#include "upnpavrenderingsessionobserver.h" // base class
+#include "upnpitemresolverobserver.h" // base class
+#include "upnprenderingstatemachineobserver.h" // base class
+
+// FORWARD DECLARATIONS
+class MUPnPAVController;
+class MUPnPAVRenderingSession;
+class MUpnpImageRenderingEngineObserver;
+class MUPnPItemResolver;
+class CUpnpRenderingStateMachine;
+class CUPnPPeriodic;
+
+/**
+* This class defines the UpnpShowTask used in UpnpCommand component.
+*
+* @since S60 3.2
+*/
+class CUpnpImageRenderingEngine
+    : public CBase
+    , public MUPnPItemResolverObserver
+    , public MUPnPAVRenderingSessionObserver
+    , public MUpnpRenderingStateMachineObserver
+    {
+    
+
+    public: // construction
+
+        /**
+         * static constructor
+         * @param aAVController avcontroller resource
+         * @param aSession the rendering session to work with
+         * @param aObserver the client for this engine
+         */
+        static CUpnpImageRenderingEngine* NewL(
+            MUPnPAVController& aAVController,
+            MUPnPAVRenderingSession& aSession,
+            MUpnpImageRenderingEngineObserver& aObserver);
+
+        /**
+         * destructor
+         */
+        virtual ~CUpnpImageRenderingEngine();
+
+    private: // private part of construction
+
+        /**
+         * constructor
+         */
+        CUpnpImageRenderingEngine(
+            MUPnPAVController& aAVController,
+            MUPnPAVRenderingSession& aSession,
+            MUpnpImageRenderingEngineObserver& aObserver);
+        
+     
+        /**
+         * Second phase constructor
+         */
+        void ConstructL();
+
+    public: // the interface
+
+        /**
+         * Requests to start rendering. This will cause the engine to query
+         * the media to render using the callback interface.
+         * This method can be called in all states and all conditions
+         * and subsequently very fast. The engine will keep track of
+         * states and indicate errors etc.
+         */
+        void PlayL();
+
+        /**
+         * Requests to stop rendering.
+         */
+        void StopL();
+
+
+    protected: // Call back methods of MUPnPAVRenderingSessionObserver
+
+        /**
+         * UPnP AV Controller calls this method to return the result for the
+         * 'set uri' request.
+         *
+         * @since Series 60 3.1
+         * @param aError error code
+         * @return None
+         */
+        void SetURIResult( TInt aError );
+
+        /**
+         * UPnP AV Controller calls this method to indicate that the requested
+         * interaction operation (play, stop, etc.) is complete. In other
+         * words, the target rendering device has changed it's state 
+         * accordingly.
+         *
+         * @since Series 60 3.1
+         * @param aError (TInt) error code
+         * @param aOperation (TAVInteractOperation) operation Id
+         */
+        void InteractOperationComplete( TInt aError,
+            TUPnPAVInteractOperation aOperation );
+
+        /**
+         * Notifies that the Media Renderer we have a session with has
+         * disappeared. Session is now unusable and must be closed. 
+         *
+         * @since Series 60 3.1
+         * @param aReason (TUPnPDeviceDisconnectedReason) reason code
+         */
+        void MediaRendererDisappeared(
+            TUPnPDeviceDisconnectedReason aReason );
+
+        // Methods that are not used
+        void VolumeResult(
+                        TInt /*aError*/,
+                        TInt /*aVolumeLevel*/,
+                        TBool /*aActionResponse*/) {}
+        void MuteResult(
+                        TInt /*aError*/,
+                        TBool /*aMute*/,
+                        TBool /*aActionResponse*/ ) {}
+        void PositionInfoResult(
+                        TInt /*aError*/,
+                        const TDesC8& /*aTrackPosition*/,
+                        const TDesC8& /*aTrackLength*/ ) {}
+        void SetNextURIResult(
+                        TInt /*aError*/ ) {}
+            
+        void ReserveLocalMSServicesCompleted( TInt /*aError*/ ) {}
+
+    protected: // Methods from MUPnPItemResolverObserver
+
+        /**
+         * See UpnpAvControllerHelper API for more info.
+         */
+        void ResolveComplete(
+            const MUPnPItemResolver& aResolver, TInt aError );
+    
+    protected: // from MUpnpRenderingStateMachineObserver
+        
+         /**
+          * Indicates state machine has been synchronised with the renderer
+          *
+          * @since Series 60 3.2
+          * @param aError error that occurred during sync
+          */
+        void RendererSyncReady( TInt aError,
+                            Upnp::TState aState );
+        
+        /**
+         * Indicates renderer state has changed either by request 
+         * or spontanelously.
+         *
+         * @since Series 60 3.2
+         * @param aError the error code
+         * @param aState the new state
+         * @param aUserOriented ETrue if this responds to a request
+         * @param aStateParam extra info depending on the state change
+         */
+        void RenderingStateChanged(
+                            TInt aError,
+                            Upnp::TState aState,
+                            TBool aUserOriented,
+                            TInt aStateParam );
+        /**
+         * Synchronises UI with media duration and current position
+         * this callback can be either automatic or explicitly requested
+         *
+         * @since Series 60 3.2
+         * @param aError error that occurred during position sync
+         * @param aMode mode in which the track is progressing
+         * @param aDuration media duration in milliseconds
+         * @param aPosition current position in milliseconds
+         */
+        void PositionSync( TInt aError,
+                            Upnp::TPositionMode aMode,
+                            TInt aDuration, TInt aPosition );
+            
+    public: // methods for the timer
+
+        /**
+         * the timeout callback
+         */
+        static TInt Timer( TAny* aArg );
+
+        /**
+         * handles the timeout internally
+         */
+        void RunTimerL();
+
+        /**
+         * handles errors in the timeout callback body
+         */
+        TInt RunError( TInt aError );
+        
+         /**
+          * checks if wlan is active
+          */
+        TBool IsWlanActive();
+        
+    private: // Private methods
+
+        /**
+         * Handles the start up of the item resolving.
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void StartResolvingL();
+        
+        
+        /**
+         * Sends an acknowledgement
+         *
+         * @since S60 3.2
+         * @param aError error code
+         * @return none
+        */
+        void SendRenderAck( TInt aError );
+        
+        /**
+         * Cycles next item by checking resolver status
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void Cycle();
+        
+        /**
+         * Cleans up used resources
+         *
+         * @since S60 3.2
+         * @param none
+         * @return none
+         */
+        void Cleanup();
+        
+    private: // Data members
+
+        // avcontroller
+        MUPnPAVController&                  iAVController;
+    
+        // the rendering session
+        MUPnPAVRenderingSession&            iRenderingSession;
+
+        // The observer interface
+        MUpnpImageRenderingEngineObserver&  iObserver;
+
+        // internal states
+        enum TRenderingState
+            {
+            EIdle = 100,     // doing nothing
+            EResolvingItem,  // resolving (preparing the item to be played)
+            EResolveComplete,// resolve done succesfully. Starting to play
+            ERendering,      // Check accurate state from statemachine
+            EShuttingDown
+            };
+
+        // internal state
+        TRenderingState                     iState;
+        // current resolver. owned.
+        MUPnPItemResolver*                  iCurrentResolver;
+
+        // Buffered next resolver. Owned.
+        MUPnPItemResolver*                  iBufferedResolver;
+
+        // flag that indicates a new image is in buffer
+        TBool                               iBufferingNewImage;
+
+        // timer support
+        CUPnPPeriodic*                      iTimer;
+
+        // Flag if WLan active or not
+        TBool                               iWlanActive;
+        
+
+        // the rendering state machine
+        CUpnpRenderingStateMachine*         iRenderingStateMachine;
+
+    };
+
+
+#endif // UPNP_IMAGERENDERINGENGINE_H
+
+// End of File
--- a/upnpframework/upnpcommand/inc/upnpimagerenderingengineobserver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/inc/upnpimagerenderingengineobserver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,82 +1,82 @@
-/*
-* Copyright (c) 2007 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:  observer for CUpnpImageRenderingEngine
-*
-*/
-
-
-#ifndef UPNP_IMAGERENDERINGENGINEOBSERVER_H
-#define UPNP_IMAGERENDERINGENGINEOBSERVER_H
-
-// INCLUDES
-#include <e32base.h>
-#include "upnpavrenderingsessionobserver.h" // base class
-#include "upnpitemresolverobserver.h" // base class
-
-// FORWARD DECLARATIONS
-class CUpnpAVDevice;
-class MUPnPAVController;
-class MUPnPAVRenderingSession;
-class MUPnPAVSessionBase;
-class MUPnPItemResolver;
-class CUPnPCommonUI;
-
-/**
-* Observer interface for image rendering engine.
-*
-* @since S60 3.2
-*/
-class MUpnpImageRenderingEngineObserver
-    {
-    public:
-
-        /**
-         * Requests for media to be rendered.
-         * this method is called soon after calling PlayL().
-         * the client is expected to provide an item resolver prepared with
-         * the media to be played back (but not resolved yet)
-         * ownership is transferred in this transaction.
-         * if client returns NULL playback will fail to KErrCancelled
-         * 
-         * @return the resolver representing media to be played
-         */
-        virtual MUPnPItemResolver* GetMedia() = 0;
-
-        /**
-         * Acknowledge for render request
-         * @param aError any errors that occurred
-         * @param aItem the actual item that is playing, trying to play, or
-         *        NULL if such is not available for some error condition
-		 * @return response error code
-		 *         KErrNone if the engine should carry on working
-		 *         KErrDisconnected if engine should disconnect
-         */
-        virtual TInt RenderAck(
-            TInt aError,
-            const CUpnpItem* aItem ) = 0; 
-
-        /**
-         * Notifies that rendering engine will shut down due to
-         * communication failure.
-         * @param aError the error code (some kind of reason)
-         */
-        virtual void EngineShutdown(
-            TInt aError ) = 0;
-            
-    };
-
-
-#endif // UPNP_IMAGERENDERINGENGINEOBSERVER_H
-
-// End of File
+/*
+* Copyright (c) 2007 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:  observer for CUpnpImageRenderingEngine
+*
+*/
+
+
+#ifndef UPNP_IMAGERENDERINGENGINEOBSERVER_H
+#define UPNP_IMAGERENDERINGENGINEOBSERVER_H
+
+// INCLUDES
+#include <e32base.h>
+#include "upnpavrenderingsessionobserver.h" // base class
+#include "upnpitemresolverobserver.h" // base class
+
+// FORWARD DECLARATIONS
+class CUpnpAVDevice;
+class MUPnPAVController;
+class MUPnPAVRenderingSession;
+class MUPnPAVSessionBase;
+class MUPnPItemResolver;
+class CUPnPCommonUI;
+
+/**
+* Observer interface for image rendering engine.
+*
+* @since S60 3.2
+*/
+class MUpnpImageRenderingEngineObserver
+    {
+    public:
+
+        /**
+         * Requests for media to be rendered.
+         * this method is called soon after calling PlayL().
+         * the client is expected to provide an item resolver prepared with
+         * the media to be played back (but not resolved yet)
+         * ownership is transferred in this transaction.
+         * if client returns NULL playback will fail to KErrCancelled
+         * 
+         * @return the resolver representing media to be played
+         */
+        virtual MUPnPItemResolver* GetMedia() = 0;
+
+        /**
+         * Acknowledge for render request
+         * @param aError any errors that occurred
+         * @param aItem the actual item that is playing, trying to play, or
+         *        NULL if such is not available for some error condition
+        * @return response error code
+        *         KErrNone if the engine should carry on working
+        *         KErrDisconnected if engine should disconnect
+         */
+        virtual TInt RenderAck(
+            TInt aError,
+            const CUpnpItem* aItem ) = 0; 
+
+        /**
+         * Notifies that rendering engine will shut down due to
+         * communication failure.
+         * @param aError the error code (some kind of reason)
+         */
+        virtual void EngineShutdown(
+            TInt aError ) = 0;
+            
+    };
+
+
+#endif // UPNP_IMAGERENDERINGENGINEOBSERVER_H
+
+// End of File
--- a/upnpframework/upnpcommand/inc/upnpnotehandler.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/inc/upnpnotehandler.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,207 +1,212 @@
-/*
-* Copyright (c) 2007 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:  Header file for the CUpnpNoteHandler class.
-*
-*/
-
-
-#ifndef UPNP_COMMAND_NOTE_HANDLER_TASK_H
-#define UPNP_COMMAND_NOTE_HANDLER_TASK_H
-
-// INCLUDES
-#include <e32base.h>
-
-// FORWARD DECLARATIONS
-class CAknWaitDialog;
-
-/**
-* This class does all UI note handling of UpnpCommand component.
-*
-* @since S60 3.2
-*/
-class CUpnpNoteHandler : public CBase
-    {
-    public: // Construction methods
-
-        /**
-         * Creates a new CUpnpNoteHandler instance.
-         *
-         * @since S60 3.2
-         * @return a new instance of CUpnpNoteHandler
-         */
-        static CUpnpNoteHandler* NewL();
-
-    public: // Business logic methods
-
-        /**
-         * Run the "Connecting" wait note.
-         *
-         * @since Series 60 3.2
-         * @return TInt return value
-         */
-        TInt RunConnectingWaitNote();
-
-        /**
-         * Closes the currently displaying wait note.
-         *
-         * @since Series 60 3.2
-         */
-        void CloseWaitNote();
-
-        /**
-         * Show "DRM protected files not supported." info note.
-         *
-         * @since Series 60 3.2
-         */
-        void ShowDrmNoteL();
-
-        /**
-         * Show "Connection lost." info note.
-         *
-         * @since Series 60 3.2
-         */
-        void ShowConnectionLostNoteL();
-        
-        /**
-         * Show info note when local MS fails to start
-         * 
-         * @since Series 60 3.2
-         */
-        void ShowLocalMSStartErrorNoteL();
-        
-        /**
-         * Show "N File copied." info note.
-         *
-         * @since Series 60 3.2
-         */
-        void ShowCopyInfoNoteL( TInt aCount, const TDesC& aServerName );
-        
-        /**
-         * Show "N Files moved." info note.
-         *
-         * @since Series 60 3.2
-         */
-        void ShowMoveInfoNoteL( TInt aCount, const TDesC& aServerName );
-        
-        /**
-         * Show "Copy failed." info note.
-         *
-         * @since Series 60 3.2
-         */
-        void ShowCopyErrorNoteL();
-        
-        /**
-         * Show "Move failed" info note.
-         *
-         * @since Series 60 3.2
-         */
-        void ShowMoveErrorNoteL();
-
-        /**
-         * Show "Connection lost" info note.
-         *
-         * @since Series 60 3.2
-         */
-        void ShowCopyDisconnectionErrorNoteL();
-        
-        /**
-         * Show "Connection lost" info note.
-         *
-         * @since Series 60 3.2
-         */
-        void ShowMoveDisconnectionErrorNoteL();
-
-        /**
-         * Show "Playback failed" info note.
-         *
-         * @since Series 60 3.2
-         */
-        void ShowPlaybackFailedNoteL();
-
-        /**
-         * Reset iDrmNoteShown
-         *
-         * @since Series 60 3.2
-         */
-        void ResetDrmNoteCount();
-
-    public: // Public destructor
-
-        /**
-         * Destructor.
-         */
-        virtual ~CUpnpNoteHandler();
-        
-    private: // Businnes l
-    
-        /**
-         * Runs general wait note.
-         *
-         * @since Series 60 3.2
-         * @return TInt return value
-         */
-        TInt RunWaitNote( TInt aResource );
-        
-        /**
-         * Show error note
-         *
-         * @since Series 60 3.2
-         */
-        void ShowErrorNoteL( TInt aResource );
-
-        /**
-         * Show info note
-         *
-         * @since Series 60 3.2
-         */
-        void ShowInfoNoteL( const TDesC& aText );
-
-    private: // Private construct/destruct methods
-
-        /**
-         * Perform the first phase of two phase construction.
-         *
-         * @since S60 3.2
-         */
-        CUpnpNoteHandler();
-
-        /**
-         * Perform the second phase of two phase construction. Reserves the
-         * Upnp Fw resources (they are released when the task is destroyed).
-         */
-        void ConstructL();
-        
-    private: // Data members
-    
-        /**
-         * Currently showing wait note. Owned.
-         */
-        CAknWaitDialog* iWaitNote;
-
-        /**
-         * The resource file offset.
-         */
-        TInt iResFileOffset;
-        
-        /**
-         * A boolean value indicating the state of the DRM note showing.
-         * The note is shown only once per session.
-         */
-        TBool iDrmNoteShown;
-
-    };
-
-#endif // UPNP_COMMAND_NOTE_HANDLER_TASK_H
-
+/*
+* Copyright (c) 2007 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:  Header file for the CUpnpNoteHandler class.
+*
+*/
+
+
+#ifndef UPNP_COMMAND_NOTE_HANDLER_TASK_H
+#define UPNP_COMMAND_NOTE_HANDLER_TASK_H
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CAknWaitDialog;
+
+/**
+* This class does all UI note handling of UpnpCommand component.
+*
+* @since S60 3.2
+*/
+class CUpnpNoteHandler : public CBase
+    {
+    public: // Construction methods
+
+        /**
+         * Creates a new CUpnpNoteHandler instance.
+         *
+         * @since S60 3.2
+         * @return a new instance of CUpnpNoteHandler
+         */
+        static CUpnpNoteHandler* NewL();
+
+    public: // Business logic methods
+
+        /**
+         * Run the "Connecting" wait note.
+         *
+         * @since Series 60 3.2
+         * @return TInt return value
+         */
+        TInt RunConnectingWaitNote();
+
+        /**
+         * Closes the currently displaying wait note.
+         *
+         * @since Series 60 3.2
+         */
+        void CloseWaitNote();
+
+        /**
+         * Show "DRM protected files not supported." info note.
+         *
+         * @since Series 60 3.2
+         */
+        void ShowDrmNoteL();
+
+        /**
+         * Show "Connection lost." info note.
+         *
+         * @since Series 60 3.2
+         */
+        void ShowConnectionLostNoteL();
+        
+        /**
+         * Show info note when local MS fails to start
+         * 
+         * @since Series 60 3.2
+         */
+        void ShowLocalMSStartErrorNoteL();
+        
+        /**
+         * Show "N File copied." info note.
+         *
+         * @since Series 60 3.2
+         */
+        void ShowCopyInfoNoteL( TInt aCount, const TDesC& aServerName );
+        
+        /**
+         * Show "N Files moved." info note.
+         *
+         * @since Series 60 3.2
+         */
+        void ShowMoveInfoNoteL( TInt aCount, const TDesC& aServerName );
+        
+        /**
+         * Show "Copy failed." info note.
+         *
+         * @since Series 60 3.2
+         */
+        void ShowCopyErrorNoteL();
+        
+        /**
+         * Show "Move failed" info note.
+         *
+         * @since Series 60 3.2
+         */
+        void ShowMoveErrorNoteL();
+
+        /**
+         * Show "Connection lost" info note.
+         *
+         * @since Series 60 3.2
+         */
+        void ShowCopyDisconnectionErrorNoteL();
+        
+        /**
+         * Show "Connection lost" info note.
+         *
+         * @since Series 60 3.2
+         */
+        void ShowMoveDisconnectionErrorNoteL();
+
+        /**
+         * Show "Playback failed" info note.
+         *
+         * @since Series 60 3.2
+         */
+        void ShowPlaybackFailedNoteL();
+        
+        /**
+         * Show "%U is already in use. Please try again later." error note.
+         */
+        void ShowRendererInUseNoteL( const TDesC& aDeviceName );
+
+        /**
+         * Reset iDrmNoteShown
+         *
+         * @since Series 60 3.2
+         */
+        void ResetDrmNoteCount();
+
+    public: // Public destructor
+
+        /**
+         * Destructor.
+         */
+        virtual ~CUpnpNoteHandler();
+        
+    private: // Businnes l
+    
+        /**
+         * Runs general wait note.
+         *
+         * @since Series 60 3.2
+         * @return TInt return value
+         */
+        TInt RunWaitNote( TInt aResource );
+        
+        /**
+         * Show error note
+         *
+         * @since Series 60 3.2
+         */
+        void ShowErrorNoteL( TInt aResource );
+
+        /**
+         * Show info note
+         *
+         * @since Series 60 3.2
+         */
+        void ShowInfoNoteL( const TDesC& aText );
+
+    private: // Private construct/destruct methods
+
+        /**
+         * Perform the first phase of two phase construction.
+         *
+         * @since S60 3.2
+         */
+        CUpnpNoteHandler();
+
+        /**
+         * Perform the second phase of two phase construction. Reserves the
+         * Upnp Fw resources (they are released when the task is destroyed).
+         */
+        void ConstructL();
+        
+    private: // Data members
+    
+        /**
+         * Currently showing wait note. Owned.
+         */
+        CAknWaitDialog* iWaitNote;
+
+        /**
+         * The resource file offset.
+         */
+        TInt iResFileOffset;
+        
+        /**
+         * A boolean value indicating the state of the DRM note showing.
+         * The note is shown only once per session.
+         */
+        TBool iDrmNoteShown;
+
+    };
+
+#endif // UPNP_COMMAND_NOTE_HANDLER_TASK_H
+
 // End of File
\ No newline at end of file
--- a/upnpframework/upnpcommand/inc/upnpshowtask.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/inc/upnpshowtask.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,145 +1,145 @@
-/*
-* Copyright (c) 2007 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:  Header file for the CUpnpShowTask class.
-*
-*/
-
-
-#ifndef UPNP_SHOW_TASK_H
-#define UPNP_SHOW_TASK_H
-
-// INCLUDES
-#include <e32base.h>
-#include "upnpresourceselector.h" // a member located here
-#include "upnptask.h" // base class
-#include "upnpimagerenderingengineobserver.h" // base class
-
-// FORWARD DECLARATIONS
-class MUPnPAVRenderingSession;
-class CUPnPCommonUI;
-class CUpnpTaskResourceAllocator;
-class CUpnpImageRenderingEngine;
-
-
-/**
-* This class defines the UpnpShowTask used in UpnpCommand component.
-*
-* @since S60 3.2
-*/
-class CUpnpShowTask : public CUpnpTask,
-                      public MUpnpImageRenderingEngineObserver
-    {
-    public: // Methods from CUpnpTask
-
-        /**
-         * Creates a new UpnpShowTask object. Allocates Upnp Fw resources.
-         * Resources will be released when the task is destroyed.
-         *
-         * @since S60 3.2
-         * @return a new instance of CUpnpShowTask, casted to type CUpnpTask
-         */
-        static CUpnpTask* NewL();
-
-        /**
-         * Destructor.
-         */
-        virtual ~CUpnpShowTask();
-
-        /**
-         * Allocates the Upnp Fw resources.
-         *
-         * @since S60 3.2
-         */
-        void AllocateResourcesL();
-
-        /**
-         * Executes the task.
-         *
-         * @since S60 3.2
-         */
-        void ExecuteL();
-
-
-    private: // Private construct/destruct methods
-
-        /**
-         * constructor
-         */
-        CUpnpShowTask();
-
-        /**
-         * Perform the second phase of two phase construction. Reserves the
-         * Upnp Fw resources (they are released when the task is destroyed).
-         */
-        void ConstructL();
-        
-        /**
-         * Cleans up used resources
-         */
-        void Cleanup();
-
-    protected: // methods from MUpnpImageRenderingEngineObserver
-
-        MUPnPItemResolver* GetMedia();
-
-        TInt RenderAck(
-            TInt aError,
-            const CUpnpItem* aItem ); 
-
-        void EngineShutdown(
-            TInt aError );
-
-
-    private: // Private methods
-
-        /**
-         * Launches the video player dialog for playing a video file on remote
-         * @param aItem the item to play
-         * @return an error code
-         */
-        TInt PlayVideo( const CUpnpItem& aItem );
-
-
-    private: // Data members
-
-        // Pointer to the UpnpAvController's rendering session.
-        MUPnPAVRenderingSession*            iRenderingSession;
-        
-        // Pointer to the UpnpAvController's rendering session.
-        MUPnPAVRenderingSession*            iVideoRenderingSession;
-
-        // flag for video playing
-        TBool                               iPlayingVideo;
-
-        // Pointer to the UPnPCommonUI;
-        CUPnPCommonUI*                      iCommonUI;
-
-        // Default resource selector. Owned.
-        TUPnPSelectDefaultResource          iSelector;
-
-        // The resource allocator
-        CUpnpTaskResourceAllocator*         iResourceAllocator;
-
-        // the image rendering engine
-        CUpnpImageRenderingEngine*          iRenderingEngine;
-        
-        // flag to show note when image showing failed
-        TBool                               iShowPlaybackFailedNote;
-        
-        };
-
-
-#endif // UPNP_SHOW_TASK_H
-
-// End of File
+/*
+* Copyright (c) 2007-2009 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:  Header file for the CUpnpShowTask class.
+*
+*/
+
+
+#ifndef UPNPSHOW_TASK_H
+#define UPNPSHOW_TASK_H
+
+// INCLUDES
+#include <e32base.h>
+#include "upnpresourceselector.h" // a member located here
+#include "upnptask.h" // base class
+#include "upnpimagerenderingengineobserver.h" // base class
+
+// FORWARD DECLARATIONS
+class MUPnPAVRenderingSession;
+class CUPnPCommonUI;
+class CUpnpTaskResourceAllocator;
+class CUpnpImageRenderingEngine;
+
+
+/**
+* This class defines the UpnpShowTask used in UpnpCommand component.
+*
+* @since S60 3.2
+*/
+class CUpnpShowTask : public CUpnpTask,
+                      public MUpnpImageRenderingEngineObserver
+    {
+    public: // Methods from CUpnpTask
+
+        /**
+         * Creates a new UpnpShowTask object. Allocates Upnp Fw resources.
+         * Resources will be released when the task is destroyed.
+         *
+         * @since S60 3.2
+         * @return a new instance of CUpnpShowTask, casted to type CUpnpTask
+         */
+        static CUpnpTask* NewL();
+
+        /**
+         * Destructor.
+         */
+        virtual ~CUpnpShowTask();
+
+        /**
+         * Allocates the Upnp Fw resources.
+         *
+         * @since S60 3.2
+         */
+        void AllocateResourcesL();
+
+        /**
+         * Executes the task.
+         *
+         * @since S60 3.2
+         */
+        void ExecuteL();
+
+
+    private: // Private construct/destruct methods
+
+        /**
+         * constructor
+         */
+        CUpnpShowTask();
+
+        /**
+         * Perform the second phase of two phase construction. Reserves the
+         * Upnp Fw resources (they are released when the task is destroyed).
+         */
+        void ConstructL();
+        
+        /**
+         * Cleans up used resources
+         */
+        void Cleanup();
+
+    private: // methods from MUpnpImageRenderingEngineObserver
+
+        MUPnPItemResolver* GetMedia();
+
+        TInt RenderAck(
+            TInt aError,
+            const CUpnpItem* aItem ); 
+
+        void EngineShutdown(
+            TInt aError );
+
+
+    private: // Private methods
+
+        /**
+         * Launches the video player dialog for playing a video file on remote
+         * @param aItem the item to play
+         * @return an error code
+         */
+        TInt PlayVideo( const CUpnpItem& aItem );
+
+
+    private: // Data members
+
+        // Pointer to the UpnpAvController's rendering session.
+        MUPnPAVRenderingSession*            iRenderingSession;
+        
+        // Pointer to the UpnpAvController's rendering session.
+        MUPnPAVRenderingSession*            iVideoRenderingSession;
+
+        // flag for video playing
+        TBool                               iPlayingVideo;
+
+        // Pointer to the UPnPCommonUI;
+        CUPnPCommonUI*                      iCommonUI;
+
+        // Default resource selector. Owned.
+        TUPnPSelectDefaultResource          iSelector;
+
+        // The resource allocator
+        CUpnpTaskResourceAllocator*         iResourceAllocator;
+
+        // the image rendering engine
+        CUpnpImageRenderingEngine*          iRenderingEngine;
+        
+        // flag to show note when image showing failed
+        TBool                               iShowPlaybackFailedNote;
+        
+        };
+
+
+#endif // UPNP_SHOW_TASK_H
+
+// End of File
--- a/upnpframework/upnpcommand/inc/upnptaskresourceallocator.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/inc/upnptaskresourceallocator.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,262 +1,214 @@
-/*
-* Copyright (c) 2007 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:  A class that allocates resources for a task
-*
-*/
-
-
-#ifndef UPNP_TASKRESOURCEALLOCATOR_H
-#define UPNP_TASKRESOURCEALLOCATOR_H
-
-// INCLUDES
-// System
-#include <e32base.h>
-
-// upnpframework / avcontroller api
-#include "upnpavdeviceobserver.h" // base class
-#include "upnpavbrowsingsessionobserver.h" // base class
-
-// FORWARD DECLARATIONS
-class CUPnPCommonUI;
-class CUpnpNoteHandler;
-class MUPnPAVController;
-class CUpnpAVDevice;
-class MUPnPAVBrowsingSession;
-class CUpnpNoteHandler;
-
-/**
- * A helper class that makes a method async.
- */
-class CUpnpTaskResourceAllocator
-    : public CAsyncOneShot
-    , public MUPnPAVDeviceObserver
-    , public MUPnPAVBrowsingSessionObserver
-    {
-    public:
-
-        /**
-         * List of upnp resource types available.
-         * These types can be combined by masking.
-         */
-        enum TUpnpResourceTypes
-            {
-            // open AV controller resource
-            EResourceAvController            = 0x0001,
-            // start local mediaserver
-            EResourceLocalMediaServer        = 0x0002,
-            // select an image-capable renderer
-            EResourceSelectImageRenderer     = 0x0100,
-            // select a copy-capable server
-            EResourceSelectCopyServer        = 0x0200,
-            // select a copy-capable server (display move title)
-            EResourceSelectMoveServer        = 0x0400,
-            // a mask, USED ONLY INTERNALLY !!!
-            EResourceSelectDevice            = 0xFF00,
-            };
-
-        /**
-         * static constructor
-         * @param aCommonUI common UI reference to use
-         * @param aNoteHandler note handler reference to use
-         * @param aMode which resources are needed
-         */
-        static CUpnpTaskResourceAllocator* NewL(
-            CUPnPCommonUI& aCommonUI,
-            TInt aMode );
-
-        /**
-         * destructor
-         */
-        virtual ~CUpnpTaskResourceAllocator();
-         
-    private:
-
-        /**
-         * constructor
-         */
-        CUpnpTaskResourceAllocator(
-            CUPnPCommonUI& aCommonUI,
-            TInt aMode );
-
-    public: // the interface
-        
-        /**
-         * Allocates the resources, returns when complete.
-         * A wait note will be displayed during the process.
-         * displays any necessary errors that occur during the process
-         */
-        void AllocateL();
-
-        /**
-         * returns the AVController resource after allocation.
-         * Note: This method panics if EResourceAvController was not set.
-         */
-        MUPnPAVController& AVController();
-
-        /**
-         * returns the selected device
-         * Note: the method panics if neither EResourceSelectRenderer nor
-         * EResourceSelectServer was set.
-         */
-        const CUpnpAVDevice& SelectedDevice();
-        
-        
-         /**
-         * Sets the pointer to the note handler. The ownership of the pointer
-         * is not transfered.
-         *
-         * Leaves with KErrArgument, if the provided pointer is invalid.
-         *
-         * @since S60 3.2
-         * @param aNoteHandler (CUpnpNoteHandler*) the pointer to the note
-         *        handler
-         */
-        void SetNoteHandlerL( CUpnpNoteHandler* aNoteHandler );
-        
-         
-    public: // from CAsyncOneShot
-        
-        /**
-         * Asynchronous execution
-         */
-        void RunL();
-
-        /**
-         * Execution of the error branch
-         */
-        TInt RunError( TInt aError );
-
-    private: // own methods
-
-        /**
-         * cleans up all resources
-         */
-        void Cleanup();
-
-        /**
-         * creates the AVController resource
-         */
-        void StartAvControllerL();
-
-        /**
-         * Starts the local mediaserver
-         */
-        void StartLocalMediaServerL();
-
-
-        /**
-         * shows a device selection popup
-         */
-        void SelectDeviceL();
-
-        /**
-         * sets an asynchronous error code
-         */
-        void SetErrorCode( TInt aError );
-
-    public: // Call back methods of MUPnPAVDeviceObserver
-
-        void UPnPDeviceDiscovered( const CUpnpAVDevice& aDevice );
-
-        void UPnPDeviceDisappeared( const CUpnpAVDevice& aDevice );
-
-        void WLANConnectionLost();
-       
-        
-    public: // Call back methods of MUPnPAVBrowsingSessionObserver
-
-        void BrowseResponse(
-            const TDesC8& aBrowseResponse,
-            TInt aError,
-            TInt aMatches,
-            TInt aTotalCount,
-            const TDesC8& aUpdateId
-            );
-
-        void SearchResponse( 
-            const TDesC8& aSearchResponse,
-            TInt aError,
-            TInt aMatches,
-            TInt aTotalCount,
-            const TDesC8& aUpdateId
-            );
-
-        void SearchCapabilitiesResponse( 
-            TInt aError,
-            const TDesC8& aSearchCapabilities 
-            );
-
-        void CreateContainerResponse( TInt aError, 
-            const TDesC8& aObjectId );
-
-        void DeleteObjectResponse( TInt aError );
-
-        void MediaServerDisappeared(
-            TUPnPDeviceDisconnectedReason aReason );
-
-        void ReserveLocalMSServicesCompleted( TInt aError );
-
-    protected:
-
-        /**
-         * states of the allocator
-         */
-        enum TAllocatorState
-            {
-            EStateIdle = 0, // class constructed, allocation not started yet
-            EStateAllocating, // allocation in progress
-            EStateWaitingForLMS, // rest done,waiting for local media server
-            EStateReady, // allocation succesful
-            EStateError  // allocation failed
-            };
-
-    private:
-
-        // internal state
-        TAllocatorState               iState;
-    
-        // the common UI resource
-        CUPnPCommonUI&                iCommonUI;
-
-        // the note handler
-        CUpnpNoteHandler*             iNoteHandler;
-
-        // resource allocation mode
-        TInt                          iMode;
-
-        // avcontroller resource
-        MUPnPAVController*            iAVController;
-
-        // selected device
-        CUpnpAVDevice*                iSelectedDevice;
-
-        // the mediaserver keepalive browsing session
-        MUPnPAVBrowsingSession*       iMediaServerSession;
-
-        // error occurred in some asynchronous operation
-        TInt                          iErrorCode;
-
-        // flag for local mediaserver start state
-        TBool                         iLocalMSStarted;
-
-        // flag for local mediaserver callback
-        TBool                         iLocalMSSCompleted;
-
-        
-    };
-
-
-#endif // UPNP_TASKRESOURCEALLOCATOR_H
-
-// End of File
+/*
+* Copyright (c) 2007-2009 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:  A class that allocates resources for a task
+*
+*/
+
+
+#ifndef UPNP_TASKRESOURCEALLOCATOR_H
+#define UPNP_TASKRESOURCEALLOCATOR_H
+
+// INCLUDES
+// System
+#include <e32base.h>
+
+// upnpframework / avcontroller api
+#include "upnpavdeviceobserver.h" // base class
+
+
+// FORWARD DECLARATIONS
+class CUPnPCommonUI;
+class CUpnpNoteHandler;
+class MUPnPAVController;
+class CUpnpAVDevice;
+class CUpnpNoteHandler;
+
+/**
+ * A helper class that makes a method async.
+ */
+class CUpnpTaskResourceAllocator
+    : public CAsyncOneShot
+    , public MUPnPAVDeviceObserver
+    {
+    public:
+
+        /**
+         * List of upnp resource types available.
+         * These types can be combined by masking.
+         */
+        enum TUpnpResourceTypes
+            {
+            // open AV controller resource
+            EResourceAvController            = 0x0001,
+            // select an image-capable renderer
+            EResourceSelectImageRenderer     = 0x0100,
+            // select a copy-capable server
+            EResourceSelectCopyServer        = 0x0200,
+            // select a copy-capable server (display move title)
+            EResourceSelectMoveServer        = 0x0400,
+            // a mask, USED ONLY INTERNALLY !!!
+            EResourceSelectDevice            = 0xFF00,
+            };
+
+        /**
+         * static constructor
+         * @param aCommonUI common UI reference to use
+         * @param aNoteHandler note handler reference to use
+         * @param aMode which resources are needed
+         */
+        static CUpnpTaskResourceAllocator* NewL(
+            CUPnPCommonUI& aCommonUI,
+            TInt aMode );
+
+        /**
+         * destructor
+         */
+        virtual ~CUpnpTaskResourceAllocator();
+         
+    private:
+
+        /**
+         * constructor
+         */
+        CUpnpTaskResourceAllocator(
+            CUPnPCommonUI& aCommonUI,
+            TInt aMode );
+
+    public: // the interface
+        
+        /**
+         * Allocates the resources, returns when complete.
+         * A wait note will be displayed during the process.
+         * displays any necessary errors that occur during the process
+         */
+        void AllocateL();
+
+        /**
+         * returns the AVController resource after allocation.
+         * Note: This method panics if EResourceAvController was not set.
+         */
+        MUPnPAVController& AVController();
+
+        /**
+         * returns the selected device
+         * Note: the method panics if neither EResourceSelectRenderer nor
+         * EResourceSelectServer was set.
+         */
+        const CUpnpAVDevice& SelectedDevice();
+        
+        
+         /**
+         * Sets the pointer to the note handler. The ownership of the pointer
+         * is not transfered.
+         *
+         * Leaves with KErrArgument, if the provided pointer is invalid.
+         *
+         * @since S60 3.2
+         * @param aNoteHandler (CUpnpNoteHandler*) the pointer to the note
+         *        handler
+         */
+        void SetNoteHandlerL( CUpnpNoteHandler* aNoteHandler );
+        
+         
+    public: // from CAsyncOneShot
+        
+        /**
+         * Asynchronous execution
+         */
+        void RunL();
+
+        /**
+         * Execution of the error branch
+         */
+        TInt RunError( TInt aError );
+
+    private: // own methods
+
+        /**
+         * cleans up all resources
+         */
+        void Cleanup();
+
+        /**
+         * creates the AVController resource
+         */
+        void StartAvControllerL();
+
+        /**
+         * Starts the local mediaserver
+         */
+        void StartLocalMediaServerL();
+
+
+        /**
+         * shows a device selection popup
+         */
+        void SelectDeviceL();
+
+        /**
+         * sets an asynchronous error code
+         */
+        void SetErrorCode( TInt aError );
+
+    public: // Call back methods of MUPnPAVDeviceObserver
+
+        void UPnPDeviceDiscovered( const CUpnpAVDevice& aDevice );
+
+        void UPnPDeviceDisappeared( const CUpnpAVDevice& aDevice );
+
+        void WLANConnectionLost();
+       
+
+    protected:
+
+        /**
+         * states of the allocator
+         */
+        enum TAllocatorState
+            {
+            EStateIdle = 0, // class constructed, allocation not started yet
+            EStateAllocating, // allocation in progress
+            EStateReady, // allocation succesful
+            EStateError  // allocation failed
+            };
+
+    private:
+
+        // internal state
+        TAllocatorState               iState;
+    
+        // the common UI resource
+        CUPnPCommonUI&                iCommonUI;
+
+        // the note handler
+        CUpnpNoteHandler*             iNoteHandler;
+
+        // resource allocation mode
+        TInt                          iMode;
+
+        // avcontroller resource
+        MUPnPAVController*            iAVController;
+
+        // selected device
+        CUpnpAVDevice*                iSelectedDevice;
+
+        // error occurred in some asynchronous operation
+        TInt                          iErrorCode;
+        
+    };
+
+
+#endif // UPNP_TASKRESOURCEALLOCATOR_H
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpbrowsecommand.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpbrowsecommand.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,114 +1,115 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpBrowseCommand class.
-*
-*/
-
-
-// INCLUDE FILES
-#include <upnpbrowsecommand.h>          // CUpnpBrowseCommand
-#include "upnpcommand.h"                // CUpnpCommand
-#include "upnpcommandmain.h"            // UpnpCommandMain::LoadL
-
-// --------------------------------------------------------------------------
-// CUpnpBrowseCommand::NewL
-// Creates a new UpnpCommand for Upnp home network browsing purposes.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpBrowseCommand* CUpnpBrowseCommand::NewL()
-    {
-    // Create new CUpnpBrowseCommand instance
-    CUpnpBrowseCommand* self = new (ELeave) CUpnpBrowseCommand();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpBrowseCommand::CUpnpBrowseCommand
-// Constructor
-// --------------------------------------------------------------------------
-//
-CUpnpBrowseCommand::CUpnpBrowseCommand()
-    {
-    // No implementation
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpBrowseCommand::~CUpnpBrowseCommand
-// Destructor
-// --------------------------------------------------------------------------
-//
-CUpnpBrowseCommand::~CUpnpBrowseCommand()
-    {
-    delete iCommand;
-    iCommand = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpBrowseCommand::ConstructL
-// Second phase constructor
-// --------------------------------------------------------------------------
-//
-void CUpnpBrowseCommand::ConstructL()
-    {
-    iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandBrowse );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpBrowseCommand::BrowseHomeNetworkL
-// Allocates Upnp Framework resources, and initiates Upnp home network
-// browsing.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpBrowseCommand::BrowseHomeNetworkL()
-    {
-    // Allocate Upnp Framework resources
-    iCommand->AllocateResourcesL();
-
-    // Execute the command (Synchronous. Will not return until the user
-    // stops browsing)
-    TRAPD( executeError, iCommand->ExecuteL() );
-
-    // Release Upnp Framework resources
-    iCommand->ReleaseResources(); 
-
-    // Leave if operation failed
-    if( executeError != KErrNone )
-        {
-        User::Leave( executeError );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpBrowseCommand::IsAvailableL
-// Returns the availability information of the command.
-// --------------------------------------------------------------------------
-//
-EXPORT_C TBool CUpnpBrowseCommand::IsAvailableL()
-    {
-    // create a temporary plugin instance
-    // then query command availability.
-    TBool available = EFalse;
-    TRAP_IGNORE(
-        CUpnpCommand* temp = UpnpCommandMain::LoadL( UpnpCommand::ECommandBrowse );
-        CleanupStack::PushL( temp );
-        available = temp->IsAvailableL();
-        CleanupStack::PopAndDestroy( temp );
-        );
-    return available;
-    }
-
-// End of File
+/*
+* Copyright (c) 2007 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:  Source file for CUpnpBrowseCommand class.
+*
+*/
+
+
+// INCLUDE FILES
+#include <upnpbrowsecommand.h>          // CUpnpBrowseCommand
+#include "upnpcommand.h"                // CUpnpCommand
+#include "upnpcommandmain.h"            // UpnpCommandMain::LoadL
+
+// --------------------------------------------------------------------------
+// CUpnpBrowseCommand::NewL
+// Creates a new UpnpCommand for Upnp home network browsing purposes.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpBrowseCommand* CUpnpBrowseCommand::NewL()
+    {
+    // Create new CUpnpBrowseCommand instance
+    CUpnpBrowseCommand* self = new (ELeave) CUpnpBrowseCommand();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpBrowseCommand::CUpnpBrowseCommand
+// Constructor
+// --------------------------------------------------------------------------
+//
+CUpnpBrowseCommand::CUpnpBrowseCommand()
+    {
+    // No implementation
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpBrowseCommand::~CUpnpBrowseCommand
+// Destructor
+// --------------------------------------------------------------------------
+//
+CUpnpBrowseCommand::~CUpnpBrowseCommand()
+    {
+    delete iCommand;
+    iCommand = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpBrowseCommand::ConstructL
+// Second phase constructor
+// --------------------------------------------------------------------------
+//
+void CUpnpBrowseCommand::ConstructL()
+    {
+    iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandBrowse );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpBrowseCommand::BrowseHomeNetworkL
+// Allocates Upnp Framework resources, and initiates Upnp home network
+// browsing.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpBrowseCommand::BrowseHomeNetworkL()
+    {
+    // Allocate Upnp Framework resources
+    iCommand->AllocateResourcesL();
+
+    // Execute the command (Synchronous. Will not return until the user
+    // stops browsing)
+    TRAPD( executeError, iCommand->ExecuteL() );
+
+    // Release Upnp Framework resources
+    iCommand->ReleaseResources(); 
+
+    // Leave if operation failed
+    if( executeError != KErrNone )
+        {
+        User::Leave( executeError );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpBrowseCommand::IsAvailableL
+// Returns the availability information of the command.
+// --------------------------------------------------------------------------
+//
+EXPORT_C TBool CUpnpBrowseCommand::IsAvailableL()
+    {
+    // create a temporary plugin instance
+    // then query command availability.
+    TBool available = EFalse;
+    TRAP_IGNORE(
+        CUpnpCommand* temp = UpnpCommandMain::LoadL( 
+                                        UpnpCommand::ECommandBrowse );
+        CleanupStack::PushL( temp );
+        available = temp->IsAvailableL();
+        CleanupStack::PopAndDestroy( temp );
+        );
+    return available;
+    }
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpcommandcallbackadapter.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpcommandcallbackadapter.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,74 +1,75 @@
-/*
-* Copyright (c) 2008 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:  Helper for upnp SHOW command
-*
-*/
-
-
-// INCLUDE FILES
-#include <upnpcommandobserver.h>
-#include "upnpcommandcallbackadapter.h"
-
-// --------------------------------------------------------------------------
-// CUpnpCommandCallbackAdapter::CUpnpCommandCallbackAdapter
-// Constructor
-// --------------------------------------------------------------------------
-//
-CUpnpCommandCallbackAdapter::CUpnpCommandCallbackAdapter(
-    MUpnpCommandObserver* aObserver )
-    {
-    iObserver = aObserver;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandCallbackAdapter::~CUpnpCommandCallbackAdapter
-// Destructor
-// --------------------------------------------------------------------------
-//
-CUpnpCommandCallbackAdapter::~CUpnpCommandCallbackAdapter()
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandCallbackAdapter::CommandEvent
-// Indicates that the command has been completed.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandCallbackAdapter::CommandEvent(
-    UpnpCommand::TUpnpCommandEvent aEventType,
-    TInt aStatusCode )
-    {
-    // If there is an observer, forward the callback
-    if ( iObserver )
-        {
-        if ( aEventType == UpnpCommand::EEventComplete )
-            {
-            iObserver->CommandComplete( aStatusCode );
-            }
-        else if ( aEventType == UpnpCommand::EEventProgress && aStatusCode > 0 )
-            {
-            // Convert progress events to CommandComplete methods of the observer
-            // ONLY if the progress code is a positive value. Therefore it does not
-            // get mixed up with real CommandComplete notifications with either
-            // KErrNone or an error value.
-            iObserver->CommandComplete( aStatusCode );
-            }
-        else
-            {
-            // eat the event
-            }
-        }
-    }
-
-// End of File
+/*
+* Copyright (c) 2008 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:  Helper for upnp SHOW command
+*
+*/
+
+
+// INCLUDE FILES
+#include <upnpcommandobserver.h>
+#include "upnpcommandcallbackadapter.h"
+
+// --------------------------------------------------------------------------
+// CUpnpCommandCallbackAdapter::CUpnpCommandCallbackAdapter
+// Constructor
+// --------------------------------------------------------------------------
+//
+CUpnpCommandCallbackAdapter::CUpnpCommandCallbackAdapter(
+    MUpnpCommandObserver* aObserver )
+    {
+    iObserver = aObserver;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandCallbackAdapter::~CUpnpCommandCallbackAdapter
+// Destructor
+// --------------------------------------------------------------------------
+//
+CUpnpCommandCallbackAdapter::~CUpnpCommandCallbackAdapter()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandCallbackAdapter::CommandEvent
+// Indicates that the command has been completed.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandCallbackAdapter::CommandEvent(
+    UpnpCommand::TUpnpCommandEvent aEventType,
+    TInt aStatusCode )
+    {
+    // If there is an observer, forward the callback
+    if ( iObserver )
+        {
+        if ( aEventType == UpnpCommand::EEventComplete )
+            {
+            iObserver->CommandComplete( aStatusCode );
+            }
+        else if ( aEventType == UpnpCommand::EEventProgress 
+                                                        && aStatusCode > 0 )
+            {
+            // Convert progress events to CommandComplete methods of the observer
+            // ONLY if the progress code is a positive value. Therefore it does not
+            // get mixed up with real CommandComplete notifications with either
+            // KErrNone or an error value.
+            iObserver->CommandComplete( aStatusCode );
+            }
+        else
+            {
+            // eat the event
+            }
+        }
+    }
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpcommandimplementation.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpcommandimplementation.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,474 +1,480 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpCommandImplementation class.
-*
-*/
-
-
-// INCLUDE FILES
-// system
-#include <centralrepository.h>
-
-// upnpframework / avcontroller helper api
-#include "upnpfileutility.h"                    // IsFileProtectedL()
-
-// upnpframework / command api
-#include "upnpcommand.h"                        // CUpnpCommand
-#include "upnpcommandcallback.h"                // MUpnpCommandCallback
-
-// command internal
-#include "upnpcommandimplementation.h"
-#include "upnpfilepipe.h"
-#include "upnpcommandparameters.h"
-#include "upnpnotehandler.h"
-#include "upnpshowtask.h"
-#include "upnpcopytask.h"
-#include "upnpmovetask.h"
-#include "upnpbrowsetask.h"
-#include "upnprunsetuptask.h"
-
-_LIT( KComponentLogfile, "upnpcommand.log");
-#include "upnplog.h"
-
-// CONSTANTS
-const TUid KCRUidUPnPApplication = {0x20009cae};
-const TUint32 KUPnPAppAccessPointSetting = 0x00000001;
-
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::NewL
-// Creates an instance of the implementation.
-// --------------------------------------------------------------------------
-//
-CUpnpCommandImplementation* CUpnpCommandImplementation::NewL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::NewL" );
-    
-    CUpnpCommandImplementation* self = NULL;
-    self = new (ELeave) CUpnpCommandImplementation();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::CUpnpCommandImplementation
-// First phase construction.
-// --------------------------------------------------------------------------
-//
-CUpnpCommandImplementation::CUpnpCommandImplementation()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::Constructor" );
-
-    // Set command ID to unknown by default. Client is forced to set this
-    // (inline code in the NewL method of CUpnpCommand interface class).
-    iCommandId = UpnpCommand::ECommandUndefined;
-
-    // By default there is no task
-    iTask = NULL;
-
-    // By default the state is IDLE (resources not allocated nor executing)
-    iState = UpnpCommand::EStateIdle;
-
-    // DRM note will be shown only once
-    iDrmNoteShown = EFalse;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::ConstructL
-// Second phase construction.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::ConstructL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ConstructL" );
-
-    iFilePipe = CUpnpFilePipe::NewL();
-    iParameters = CUpnpCommandParameters::NewL();
-    iNoteHandler = CUpnpNoteHandler::NewL();
-    }
-
-// --------------------------------------------------------------------------
-// Destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpCommandImplementation::~CUpnpCommandImplementation()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::Destructor" );
-
-    delete iTask;
-    iTask = NULL;
-    delete iFilePipe;
-    iFilePipe = NULL;
-    delete iParameters;
-    iParameters = NULL;
-    delete iNoteHandler;
-    iNoteHandler = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::SetCommandIdL
-// Sets the command ID.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::SetCommandIdL(
-    UpnpCommand::TUpnpCommandId aCommandId )
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpCommandImplementation::SetCommandIdL %d",
-        TInt( aCommandId ) );
-
-    // command ID can only be set ONCE !
-    __ASSERTD( iCommandId == UpnpCommand::ECommandUndefined,
-        __FILE__, __LINE__ );
-    if( iCommandId != UpnpCommand::ECommandUndefined )
-        {
-        User::Leave( KErrServerBusy );
-        }
-
-    iCommandId = aCommandId;
-
-    // If the command is to Show images & video, re-create the file pipe.
-    // In this case we are using a file pipe of a limited size (1)
-    if( iCommandId == UpnpCommand::ECommandShow )
-        {
-        delete iFilePipe;
-        iFilePipe = NULL; // In case the following method leaves
-        iFilePipe = CUpnpFilePipe::NewL( 1 );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::SetObserver
-// Sets the callback interface
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::SetObserver(
-    MUpnpCommandCallback* aCallback )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::SetObserver" );
-
-    // Set the observer
-    iParameters->SetObserver( aCallback );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::IsAvailableL
-// Checks if a command is available for execution
-// --------------------------------------------------------------------------
-//
-TBool CUpnpCommandImplementation::IsAvailableL()
-    {
-    return IsAvailableL( iCommandId );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::IsAvailableL
-// Checks if a command is available for execution
-// --------------------------------------------------------------------------
-//
-TBool CUpnpCommandImplementation::IsAvailableL(
-    UpnpCommand::TUpnpCommandId aCommandId )
-    {
-    switch( aCommandId )
-        {
-        case UpnpCommand::ECommandShow: // flow through
-        case UpnpCommand::ECommandCopy: // flow through
-        case UpnpCommand::ECommandMove: // flow through
-        case UpnpCommand::ECommandBrowse:
-            {
-            // available if upnp is configured
-            return IsUpnpConfiguredL();
-            }
-        case UpnpCommand::ECommandSetup:
-            {
-            // setup is always available
-            return ETrue;
-            }
-        default:
-            __PANICD( __FILE__, __LINE__ );
-        }
-
-    return EFalse;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::AllocateResourcesL
-// Allocates the Upnp Framework resources.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::AllocateResourcesL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::AllocateResourcesL" );
-
-    // Leave if a task is already going (resources allocated)
-    if( iTask )
-        {
-        User::Leave( KErrAlreadyExists );
-        }
-
-    // Instantiate a task according to the command ID
-    if( iCommandId == UpnpCommand::ECommandShow )
-        {
-        iTask = CUpnpShowTask::NewL();
-        }
-    else if( iCommandId == UpnpCommand::ECommandCopy )
-        {
-        iTask = CUpnpCopyTask::NewL();
-        }
-    else if( iCommandId == UpnpCommand::ECommandMove )
-        {
-        iTask = CUpnpMoveTask::NewL();
-        }
-    else if( iCommandId == UpnpCommand::ECommandBrowse )
-        {
-        iTask = CUpnpBrowseTask::NewL();
-        }
-    else if( iCommandId == UpnpCommand::ECommandSetup )
-        {
-        iTask = CUpnpRunSetupTask::NewL();
-        }
-    else
-        {
-        __PANICD( __FILE__, __LINE__ );
-        User::Leave( KErrNotSupported );
-        }
-
-    // Set the pointers for the task (using base class CUpnpTask methods)
-    iTask->SetTaskHandlerL( this );
-    iTask->SetCommandParametersL( iParameters );
-    iTask->SetFilePipeL( iFilePipe );
-    iTask->SetNoteHandlerL( iNoteHandler );
-
-    // Allocate the resources
-    TRAPD( allocateError, iTask->AllocateResourcesL() );
-    
-    // If allocating resources failed, delete the task and forward the
-    // leave code.
-    if( allocateError != KErrNone )
-        {
-        __LOG1( "[UpnpCommand]\t CUpnpCommandImplementation::AllocateResourcesL \
-failed %d", allocateError );
-        // show note only if operation was not cancelled by user
-        if( allocateError != KErrCancel )
-            {
-            TRAP_IGNORE( iNoteHandler->ShowConnectionLostNoteL() );
-            }
-            
-        delete iTask;
-        iTask = NULL;
-        iState = UpnpCommand::EStateIdle;
-        User::Leave( allocateError );
-        }
-
-    // Update the state
-    iState = UpnpCommand::EStateAllocated;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::ReleaseResources
-// Releases the Upnp Framework resources.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::ReleaseResources()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ReleaseResources" );
-
-    // Destroy the task
-    if( iTask )
-        {
-        delete iTask;
-        iTask = NULL;
-        }
-
-    // Update the state
-    iState = UpnpCommand::EStateIdle;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::ExecuteL
-// Executes the command.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::ExecuteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ExecuteL" );
-
-    // Allocates Upnp Fw resources if not yet allocated
-    if( !iTask )
-        {
-	    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ExecuteL task deleted, leave" );
-        User::Leave( KErrNotReady );
-        }
-
-    // Update the state
-    iState = UpnpCommand::EStateExecuting;
-
-    // Execute the task
-    TInt status = KErrNone;
-    TRAP( status, iTask->ExecuteL() );
-
-    // Update the state
-    iState = UpnpCommand::EStateAllocated;
-
-    // If operation failed, leave
-    if( status != KErrNone )
-        {
-        User::Leave( status );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::SetParameterL
-// Set a parameter.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::SetParameterL(
-    UpnpCommand::TUpnpParameterType aParamType,
-    const TDesC& aParamValue )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::SetParameterL" );
-    __ASSERTD( iParameters!=0, __FILE__, __LINE__ );
-
-    iParameters->SetL( aParamType, aParamValue );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::Parameter
-// --------------------------------------------------------------------------
-//
-const TDesC& CUpnpCommandImplementation::Parameter(
-    UpnpCommand::TUpnpParameterType aParamType )
-    {
-    __ASSERTD( iParameters!=0, __FILE__, __LINE__ );
-    return iParameters->Get( aParamType );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::ResetParameters
-// Resets parameteres.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::ResetParameters()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ResetParameters" );
-
-    // Reset parameters
-    iParameters->Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::PushFileL
-// Pushes one file into the file pipe.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::PushFileL( const TDesC& aFilename )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::PushFileL" );
-        
-    // Push it in the file pipe
-    iFilePipe->PushL( aFilename );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::CountFiles
-// --------------------------------------------------------------------------
-//
-TInt CUpnpCommandImplementation::FileCount()
-    {
-    return iFilePipe->Count();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::File
-// Pops oldest file from the file pipe.
-// --------------------------------------------------------------------------
-//
-const TDesC& CUpnpCommandImplementation::File( TInt aIndex )
-    {
-    return iFilePipe->FileAt( aIndex );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::ResetFiles
-// Resets files.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::ResetFiles()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ResetFiles" );
-
-    // Reset files
-    iFilePipe->Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::State
-// Returns the state of the command.
-// --------------------------------------------------------------------------
-//
-UpnpCommand::TUpnpCommandState CUpnpCommandImplementation::State()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::State" );
-
-    return iState;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::DestroyTask
-// Destroys the ongoing task.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandImplementation::DestroyTask()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::DestroyTask" );
-
-    // Release resources (delete the ongoing UpnpTask).
-    ReleaseResources();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandImplementation::IsUpnpConfigured
-// --------------------------------------------------------------------------
-//
-TBool CUpnpCommandImplementation::IsUpnpConfiguredL()
-    {
-    TBool returnValue = EFalse;
-    // Access the Upnp Fw central repository key
-    CRepository* repository = NULL;
-    TRAPD( error, repository = CRepository::NewL( KCRUidUPnPApplication ) );
-
-    if ( error == KErrNone )
-        {
-        // Read the IAP setting
-        TInt iapDefined = KErrNotFound;
-        TInt getError = repository->Get( KUPnPAppAccessPointSetting,
-                                         iapDefined );
-    
-        delete repository;
-    
-        // Define the return value (min. valid IAP Id value is 1,
-        // 0=None selected)
-        if( getError == KErrNone &&
-            iapDefined > 0 )
-            {
-            returnValue = ETrue;
-            }
-        }
-    
-    return returnValue;
-    }
-
-// End of File
+/*
+* Copyright (c) 2007 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:  Source file for CUpnpCommandImplementation class.
+*
+*/
+
+
+// INCLUDE FILES
+// system
+#include <centralrepository.h>
+
+// upnpframework / avcontroller helper api
+#include "upnpfileutility.h"                    // IsFileProtectedL()
+
+// upnpframework / command api
+#include "upnpcommand.h"                        // CUpnpCommand
+#include "upnpcommandcallback.h"                // MUpnpCommandCallback
+
+// command internal
+#include "upnpcommandimplementation.h"
+#include "upnpfilepipe.h"
+#include "upnpcommandparameters.h"
+#include "upnpnotehandler.h"
+#include "upnpshowtask.h"
+#include "upnpcopytask.h"
+#include "upnpmovetask.h"
+#include "upnpbrowsetask.h"
+#include "upnprunsetuptask.h"
+
+_LIT( KComponentLogfile, "upnpcommand.log");
+#include "upnplog.h"
+
+// CONSTANTS
+const TUid KCRUidUPnPApplication = {0x20009cae};
+const TUint32 KUPnPAppAccessPointSetting = 0x00000001;
+
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::NewL
+// Creates an instance of the implementation.
+// --------------------------------------------------------------------------
+//
+CUpnpCommandImplementation* CUpnpCommandImplementation::NewL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::NewL" );
+    
+    CUpnpCommandImplementation* self = NULL;
+    self = new (ELeave) CUpnpCommandImplementation();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::CUpnpCommandImplementation
+// First phase construction.
+// --------------------------------------------------------------------------
+//
+CUpnpCommandImplementation::CUpnpCommandImplementation()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::Constructor" );
+
+    // Set command ID to unknown by default. Client is forced to set this
+    // (inline code in the NewL method of CUpnpCommand interface class).
+    iCommandId = UpnpCommand::ECommandUndefined;
+
+    // By default there is no task
+    iTask = NULL;
+
+    // By default the state is IDLE (resources not allocated nor executing)
+    iState = UpnpCommand::EStateIdle;
+
+    // DRM note will be shown only once
+    iDrmNoteShown = EFalse;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::ConstructL
+// Second phase construction.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::ConstructL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ConstructL" );
+
+    iFilePipe = CUpnpFilePipe::NewL();
+    iParameters = CUpnpCommandParameters::NewL();
+    iNoteHandler = CUpnpNoteHandler::NewL();
+    }
+
+// --------------------------------------------------------------------------
+// Destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpCommandImplementation::~CUpnpCommandImplementation()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::Destructor" );
+
+    delete iTask;
+    iTask = NULL;
+    delete iFilePipe;
+    iFilePipe = NULL;
+    delete iParameters;
+    iParameters = NULL;
+    delete iNoteHandler;
+    iNoteHandler = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::SetCommandIdL
+// Sets the command ID.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::SetCommandIdL(
+    UpnpCommand::TUpnpCommandId aCommandId )
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpCommandImplementation::SetCommandIdL %d",
+        TInt( aCommandId ) );
+
+    // command ID can only be set ONCE !
+    __ASSERTD( iCommandId == UpnpCommand::ECommandUndefined,
+        __FILE__, __LINE__ );
+    if( iCommandId != UpnpCommand::ECommandUndefined )
+        {
+        User::Leave( KErrServerBusy );
+        }
+
+    iCommandId = aCommandId;
+
+    // If the command is to Show images & video, re-create the file pipe.
+    // In this case we are using a file pipe of a limited size (1)
+    if( iCommandId == UpnpCommand::ECommandShow )
+        {
+        delete iFilePipe;
+        iFilePipe = NULL; // In case the following method leaves
+        iFilePipe = CUpnpFilePipe::NewL( 1 );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::SetObserver
+// Sets the callback interface
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::SetObserver(
+    MUpnpCommandCallback* aCallback )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::SetObserver" );
+
+    // Set the observer
+    iParameters->SetObserver( aCallback );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::IsAvailableL
+// Checks if a command is available for execution
+// --------------------------------------------------------------------------
+//
+TBool CUpnpCommandImplementation::IsAvailableL()
+    {
+    return IsAvailableL( iCommandId );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::IsAvailableL
+// Checks if a command is available for execution
+// --------------------------------------------------------------------------
+//
+TBool CUpnpCommandImplementation::IsAvailableL(
+    UpnpCommand::TUpnpCommandId aCommandId )
+    {
+    TBool available( EFalse );
+    switch( aCommandId )
+        {
+        case UpnpCommand::ECommandShow: // flow through
+        case UpnpCommand::ECommandCopy: // flow through
+        case UpnpCommand::ECommandMove: // flow through
+        case UpnpCommand::ECommandBrowse:
+            {
+            // available if upnp is configured
+            available = IsUpnpConfiguredL();
+            }
+            break;
+        case UpnpCommand::ECommandSetup:
+            {
+            // setup is always available
+            available = ETrue;
+            }
+            break;
+        default:
+            {
+            __PANIC( __FILE__, __LINE__ );
+            }
+            break;
+        }
+
+    return available;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::AllocateResourcesL
+// Allocates the Upnp Framework resources.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::AllocateResourcesL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::AllocateResourcesL" );
+
+    // Leave if a task is already going (resources allocated)
+    if( iTask )
+        {
+        User::Leave( KErrAlreadyExists );
+        }
+
+    // Instantiate a task according to the command ID
+    if( iCommandId == UpnpCommand::ECommandShow )
+        {
+        iTask = CUpnpShowTask::NewL();
+        }
+    else if( iCommandId == UpnpCommand::ECommandCopy )
+        {
+        iTask = CUpnpCopyTask::NewL();
+        }
+    else if( iCommandId == UpnpCommand::ECommandMove )
+        {
+        iTask = CUpnpMoveTask::NewL();
+        }
+    else if( iCommandId == UpnpCommand::ECommandBrowse )
+        {
+        iTask = CUpnpBrowseTask::NewL();
+        }
+    else if( iCommandId == UpnpCommand::ECommandSetup )
+        {
+        iTask = CUpnpRunSetupTask::NewL();
+        }
+    else
+        {
+        __PANICD( __FILE__, __LINE__ );
+        User::Leave( KErrNotSupported );
+        }
+
+    // Set the pointers for the task (using base class CUpnpTask methods)
+    iTask->SetTaskHandlerL( this );
+    iTask->SetCommandParametersL( iParameters );
+    iTask->SetFilePipeL( iFilePipe );
+    iTask->SetNoteHandlerL( iNoteHandler );
+
+    // Allocate the resources
+    TRAPD( allocateError, iTask->AllocateResourcesL() );
+    
+    // If allocating resources failed, delete the task and forward the
+    // leave code.
+    if( allocateError != KErrNone )
+        {
+        __LOG1( "[UpnpCommand]\t AllocateResourcesL \
+failed %d", allocateError );
+        // show note only if operation was not cancelled by user
+        if( allocateError != KErrCancel )
+            {
+            TRAP_IGNORE( iNoteHandler->ShowConnectionLostNoteL() );
+            }
+            
+        delete iTask;
+        iTask = NULL;
+        iState = UpnpCommand::EStateIdle;
+        User::Leave( allocateError );
+        }
+
+    // Update the state
+    iState = UpnpCommand::EStateAllocated;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::ReleaseResources
+// Releases the Upnp Framework resources.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::ReleaseResources()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ReleaseResources" );
+
+    // Destroy the task
+    if( iTask )
+        {
+        delete iTask;
+        iTask = NULL;
+        }
+
+    // Update the state
+    iState = UpnpCommand::EStateIdle;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::ExecuteL
+// Executes the command.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::ExecuteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ExecuteL" );
+
+    // Allocates Upnp Fw resources if not yet allocated
+    if( !iTask )
+        {
+        __LOG( "[UpnpCommand]\t ExecuteL task deleted, leave" );
+        User::Leave( KErrNotReady );
+        }
+
+    // Update the state
+    iState = UpnpCommand::EStateExecuting;
+
+    // Execute the task
+    TInt status = KErrNone;
+    TRAP( status, iTask->ExecuteL() );
+
+    // Update the state
+    iState = UpnpCommand::EStateAllocated;
+
+    // If operation failed, leave
+    if( status != KErrNone )
+        {
+        User::Leave( status );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::SetParameterL
+// Set a parameter.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::SetParameterL(
+    UpnpCommand::TUpnpParameterType aParamType,
+    const TDesC& aParamValue )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::SetParameterL" );
+    __ASSERTD( iParameters!=0, __FILE__, __LINE__ );
+
+    iParameters->SetL( aParamType, aParamValue );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::Parameter
+// --------------------------------------------------------------------------
+//
+const TDesC& CUpnpCommandImplementation::Parameter(
+    UpnpCommand::TUpnpParameterType aParamType )
+    {
+    __ASSERTD( iParameters!=0, __FILE__, __LINE__ );
+    return iParameters->Get( aParamType );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::ResetParameters
+// Resets parameteres.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::ResetParameters()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ResetParameters" );
+
+    // Reset parameters
+    iParameters->Reset();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::PushFileL
+// Pushes one file into the file pipe.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::PushFileL( const TDesC& aFilename )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::PushFileL" );
+        
+    // Push it in the file pipe
+    iFilePipe->PushL( aFilename );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::CountFiles
+// --------------------------------------------------------------------------
+//
+TInt CUpnpCommandImplementation::FileCount()
+    {
+    return iFilePipe->Count();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::File
+// Pops oldest file from the file pipe.
+// --------------------------------------------------------------------------
+//
+const TDesC& CUpnpCommandImplementation::File( TInt aIndex )
+    {
+    return iFilePipe->FileAt( aIndex );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::ResetFiles
+// Resets files.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::ResetFiles()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::ResetFiles" );
+
+    // Reset files
+    iFilePipe->Reset();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::State
+// Returns the state of the command.
+// --------------------------------------------------------------------------
+//
+UpnpCommand::TUpnpCommandState CUpnpCommandImplementation::State()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::State" );
+
+    return iState;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::DestroyTask
+// Destroys the ongoing task.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandImplementation::DestroyTask()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandImplementation::DestroyTask" );
+
+    // Release resources (delete the ongoing UpnpTask).
+    ReleaseResources();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandImplementation::IsUpnpConfigured
+// --------------------------------------------------------------------------
+//
+TBool CUpnpCommandImplementation::IsUpnpConfiguredL()
+    {
+    TBool returnValue = EFalse;
+    // Access the Upnp Fw central repository key
+    CRepository* repository = NULL;
+    TRAPD( error, repository = CRepository::NewL( KCRUidUPnPApplication ) );
+
+    if ( error == KErrNone )
+        {
+        // Read the IAP setting
+        TInt iapDefined = KErrNotFound;
+        TInt getError = repository->Get( KUPnPAppAccessPointSetting,
+                                         iapDefined );
+    
+        delete repository;
+    
+        // Define the return value (min. valid IAP Id value is 1,
+        // 0=None selected)
+        if( getError == KErrNone &&
+            iapDefined > 0 )
+            {
+            returnValue = ETrue;
+            }
+        }
+    
+    return returnValue;
+    }
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpcommandparameters.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpcommandparameters.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,175 +1,178 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpCommandParameters class.
-*
-*/
-
-
-// INCLUDE FILES
-// upnpframework / command api
-#include "upnpcommandcallback.h"        // MUpnpCommandCallback
-
-// command internal
-#include "upnpcommandparameters.h"
-
-_LIT( KComponentLogfile, "upnpcommand.log");
-#include "upnplog.h"
-
-// --------------------------------------------------------------------------
-// CUpnpCommandParameters::NewL
-// Creates an instance of the implementation.
-// --------------------------------------------------------------------------
-//
-CUpnpCommandParameters* CUpnpCommandParameters::NewL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::NewL" );
-
-    return new (ELeave) CUpnpCommandParameters;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandParameters::CUpnpCommandParameters
-// First phase construction.
-// --------------------------------------------------------------------------
-//
-CUpnpCommandParameters::CUpnpCommandParameters()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Constructor" );
-
-    iCollectionName = NULL;
-    iCallback = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// Destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpCommandParameters::~CUpnpCommandParameters()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Destructor" );
-
-    // Reset the parameters
-    Reset();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandParameters::SetObserver
-// Sets the observer.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandParameters::SetObserver( MUpnpCommandCallback* aCallback )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::SetObserver" );
-
-    // Parameter check
-    __ASSERTD( aCallback!=0, __FILE__, __LINE__ );
-
-    // Set the variable
-    iCallback = aCallback;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandParameters::Observer
-// Gets the observer.
-// --------------------------------------------------------------------------
-//
-MUpnpCommandCallback* CUpnpCommandParameters::Observer()
-    {
-    return iCallback;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandParameters::SetL
-// Sets a parameter
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandParameters::SetL(
-    UpnpCommand::TUpnpParameterType aParamType,
-    const TDesC& aParamValue )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::SetL" );
-
-    switch( aParamType )
-        {
-        case UpnpCommand::EParamCollectionName:
-            {
-            // Parameter check
-            if( aParamValue == KNullDesC )
-                {
-                User::Leave( KErrArgument );
-                }
-            // allocation
-            HBufC* newCollectionName = aParamValue.AllocL();
-            delete iCollectionName;
-            iCollectionName = newCollectionName;
-            newCollectionName = NULL;
-            }
-            break;
-        case UpnpCommand::EParamMediaType: // flow through
-        case UpnpCommand::EParamDeviceUuid: // flow through
-        case UpnpCommand::EParamDeviceName:
-            // do nothing
-            break;
-        default:
-            __PANICD( __FILE__, __LINE__ );
-        }
-
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandParameters::Get
-// Returns a parameter by given type
-// --------------------------------------------------------------------------
-//
-const TDesC& CUpnpCommandParameters::Get(
-    UpnpCommand::TUpnpParameterType aParamType )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Get" );
-
-    switch( aParamType )
-        {
-        case UpnpCommand::EParamCollectionName:
-            {
-            if( iCollectionName )
-                {
-                return *iCollectionName;
-                }
-            }
-            break;
-        case UpnpCommand::EParamMediaType: // flow through
-        case UpnpCommand::EParamDeviceUuid: // flow through
-        case UpnpCommand::EParamDeviceName:
-            return KNullDesC;
-        default:
-            __PANICD( __FILE__, __LINE__ );
-        }
-
-    return KNullDesC;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCommandParameters::Reset
-// Resets variables.
-// --------------------------------------------------------------------------
-//
-void CUpnpCommandParameters::Reset()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Reset" );
-
-    // Delete/reset the variables
-    delete iCollectionName;
-    iCollectionName = NULL;
-    }
-
-// End of File
+/*
+* Copyright (c) 2007 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:  Source file for CUpnpCommandParameters class.
+*
+*/
+
+
+// INCLUDE FILES
+// upnpframework / command api
+#include "upnpcommandcallback.h"        // MUpnpCommandCallback
+
+// command internal
+#include "upnpcommandparameters.h"
+
+_LIT( KComponentLogfile, "upnpcommand.log");
+#include "upnplog.h"
+
+// --------------------------------------------------------------------------
+// CUpnpCommandParameters::NewL
+// Creates an instance of the implementation.
+// --------------------------------------------------------------------------
+//
+CUpnpCommandParameters* CUpnpCommandParameters::NewL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::NewL" );
+
+    return new (ELeave) CUpnpCommandParameters;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandParameters::CUpnpCommandParameters
+// First phase construction.
+// --------------------------------------------------------------------------
+//
+CUpnpCommandParameters::CUpnpCommandParameters()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Constructor" );
+
+    iCollectionName = NULL;
+    iCallback = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// Destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpCommandParameters::~CUpnpCommandParameters()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Destructor" );
+
+    // Reset the parameters
+    Reset();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandParameters::SetObserver
+// Sets the observer.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandParameters::SetObserver( MUpnpCommandCallback* aCallback )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::SetObserver" );
+
+    // Parameter check
+    __ASSERTD( aCallback!=0, __FILE__, __LINE__ );
+
+    // Set the variable
+    iCallback = aCallback;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandParameters::Observer
+// Gets the observer.
+// --------------------------------------------------------------------------
+//
+MUpnpCommandCallback* CUpnpCommandParameters::Observer()
+    {
+    return iCallback;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandParameters::SetL
+// Sets a parameter
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandParameters::SetL(
+    UpnpCommand::TUpnpParameterType aParamType,
+    const TDesC& aParamValue )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::SetL" );
+
+    switch( aParamType )
+        {
+        case UpnpCommand::EParamCollectionName:
+            {
+            // Parameter check
+            if( aParamValue == KNullDesC )
+                {
+                User::Leave( KErrArgument );
+                }
+            // allocation
+            HBufC* newCollectionName = aParamValue.AllocL();
+            delete iCollectionName;
+            iCollectionName = newCollectionName;
+            newCollectionName = NULL;
+            }
+            break;
+        case UpnpCommand::EParamMediaType: // flow through
+        case UpnpCommand::EParamDeviceUuid: // flow through
+        case UpnpCommand::EParamDeviceName:
+            // do nothing
+            break;
+        default:
+            {
+            __PANICD( __FILE__, __LINE__ );
+            }
+            break;
+        }
+
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandParameters::Get
+// Returns a parameter by given type
+// --------------------------------------------------------------------------
+//
+const TDesC& CUpnpCommandParameters::Get(
+    UpnpCommand::TUpnpParameterType aParamType )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Get" );
+
+    switch( aParamType )
+        {
+        case UpnpCommand::EParamCollectionName:
+            {
+            if( iCollectionName )
+                {
+                return *iCollectionName;
+                }
+            }
+            break;
+        case UpnpCommand::EParamMediaType: // flow through
+        case UpnpCommand::EParamDeviceUuid: // flow through
+        case UpnpCommand::EParamDeviceName:
+            return KNullDesC;
+        default:
+            __PANICD( __FILE__, __LINE__ );
+        }
+
+    return KNullDesC;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCommandParameters::Reset
+// Resets variables.
+// --------------------------------------------------------------------------
+//
+void CUpnpCommandParameters::Reset()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCommandParameters::Reset" );
+
+    // Delete/reset the variables
+    delete iCollectionName;
+    iCollectionName = NULL;
+    }
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpcopycommand.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpcopycommand.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,173 +1,174 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpCopyCommand class.
-*
-*/
-
-
-// INCLUDE FILES
-#include <upnpcopycommand.h>            // CUpnpCopyCommand
-#include "upnpcommand.h"                // CUpnpCommand
-#include "upnpcommandmain.h"            // UpnpCommandMain::LoadL
-
-// --------------------------------------------------------------------------
-// CUpnpCopyCommand::NewL
-// Creates a new UpnpCommand for file copying purposes.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpCopyCommand* CUpnpCopyCommand::NewL()
-    {
-    // Create new CUpnpCopyCommand instance
-    CUpnpCopyCommand* self = new (ELeave) CUpnpCopyCommand();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCopyCommand::CUpnpCopyCommand
-// Constructor
-// --------------------------------------------------------------------------
-//
-CUpnpCopyCommand::CUpnpCopyCommand()
-    {
-    // No implementation
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCopyCommand::~CUpnpCopyCommand
-// Destructor
-// --------------------------------------------------------------------------
-//
-CUpnpCopyCommand::~CUpnpCopyCommand()
-    {
-    delete iCommand;
-    iCommand = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCopyCommand::ConstructL
-// Second phase constructor
-// --------------------------------------------------------------------------
-//
-void CUpnpCopyCommand::ConstructL()
-    {
-    iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandCopy );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCopyCommand::CopyFilesL
-// Copies the given list of files to a remote Upnp Media Server.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpCopyCommand::CopyFilesL( CDesCArrayFlat* aFiles )
-    {
-    TInt status = KErrNone;
-
-    // Check param
-    if( !aFiles ||
-        aFiles->Count() <= 0 )
-        {
-        User::Leave( KErrArgument );
-        }
-
-    // Push the filenames into the file pipe
-    for( TInt index=0; index<aFiles->Count(); index++ )
-        {
-        if( status == KErrNone )
-            {
-            TRAP( status,
-                  iCommand->PushFileL( aFiles->MdcaPoint( index ) ) );
-            }
-        }
-
-    // If all files were pushed ok
-    if( status == KErrNone )
-        {
-        // Allocate Upnp Fw only for the duration of the command execution
-        TRAP( status, iCommand->AllocateResourcesL() );
-        if( status == KErrNone )
-            {
-            // Execute the command
-            TRAP( status, iCommand->ExecuteL() );
-
-            // Move the failed files back to client file array
-            aFiles->Reset();
-            for ( TInt i=0; i<iCommand->FileCount(); ++i )
-                {
-                TRAP_IGNORE( aFiles->AppendL( iCommand->File( i ) ) );
-                }
-
-            // Release Upnp Fw
-            iCommand->ReleaseResources();
-            }
-        }
-
-    // Reset the file pipe
-    iCommand->ResetFiles();
-
-    // Reset parameters
-    iCommand->ResetParameters();
-
-    // Leave if operation failed
-    if( status != KErrNone )
-        {
-        User::Leave( status );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCopyCommand::CopyPlaylistL
-// Copies the given playlist (playlist name + filenames) to a remote Upnp
-// Media Server.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpCopyCommand::CopyPlaylistL( const TDesC& aPlaylistName,
-                                               CDesCArrayFlat* aFiles )
-    {
-    // Check playlist name parameter, aFiles will be checked later
-    if( aPlaylistName == KNullDesC )
-        {
-        User::Leave( KErrArgument );
-        }
-
-    // Set the playlist parameter
-    iCommand->SetParameterL(
-        UpnpCommand::EParamCollectionName, aPlaylistName );
-
-    // Use CopyFilesL to do the copy (and to handle cleanup)
-    CopyFilesL( aFiles );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCopyCommand::IsAvailable
-// Inline implementation of the IsAvailable method.
-// --------------------------------------------------------------------------
-//
-EXPORT_C TBool CUpnpCopyCommand::IsAvailableL()
-    {
-    // create a temporary plugin instance
-    // then query command availability.
-    TBool available = EFalse;
-    TRAP_IGNORE(
-        CUpnpCommand* temp = UpnpCommandMain::LoadL( UpnpCommand::ECommandCopy );
-        CleanupStack::PushL( temp );
-        available = temp->IsAvailableL();
-        CleanupStack::PopAndDestroy( temp );
-        );
-    return available;
-    }
-
-// End of File
+/*
+* Copyright (c) 2007 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:  Source file for CUpnpCopyCommand class.
+*
+*/
+
+
+// INCLUDE FILES
+#include <upnpcopycommand.h>            // CUpnpCopyCommand
+#include "upnpcommand.h"                // CUpnpCommand
+#include "upnpcommandmain.h"            // UpnpCommandMain::LoadL
+
+// --------------------------------------------------------------------------
+// CUpnpCopyCommand::NewL
+// Creates a new UpnpCommand for file copying purposes.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpCopyCommand* CUpnpCopyCommand::NewL()
+    {
+    // Create new CUpnpCopyCommand instance
+    CUpnpCopyCommand* self = new (ELeave) CUpnpCopyCommand();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCopyCommand::CUpnpCopyCommand
+// Constructor
+// --------------------------------------------------------------------------
+//
+CUpnpCopyCommand::CUpnpCopyCommand()
+    {
+    // No implementation
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCopyCommand::~CUpnpCopyCommand
+// Destructor
+// --------------------------------------------------------------------------
+//
+CUpnpCopyCommand::~CUpnpCopyCommand()
+    {
+    delete iCommand;
+    iCommand = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCopyCommand::ConstructL
+// Second phase constructor
+// --------------------------------------------------------------------------
+//
+void CUpnpCopyCommand::ConstructL()
+    {
+    iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandCopy );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCopyCommand::CopyFilesL
+// Copies the given list of files to a remote Upnp Media Server.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpCopyCommand::CopyFilesL( CDesCArrayFlat* aFiles )
+    {
+    TInt status = KErrNone;
+
+    // Check param
+    if( !aFiles ||
+        aFiles->Count() <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Push the filenames into the file pipe
+    for( TInt index=0; index<aFiles->Count(); index++ )
+        {
+        if( status == KErrNone )
+            {
+            TRAP( status,
+                  iCommand->PushFileL( aFiles->MdcaPoint( index ) ) );
+            }
+        }
+
+    // If all files were pushed ok
+    if( status == KErrNone )
+        {
+        // Allocate Upnp Fw only for the duration of the command execution
+        TRAP( status, iCommand->AllocateResourcesL() );
+        if( status == KErrNone )
+            {
+            // Execute the command
+            TRAP( status, iCommand->ExecuteL() );
+
+            // Move the failed files back to client file array
+            aFiles->Reset();
+            for ( TInt i=0; i<iCommand->FileCount(); ++i )
+                {
+                TRAP_IGNORE( aFiles->AppendL( iCommand->File( i ) ) );
+                }
+
+            // Release Upnp Fw
+            iCommand->ReleaseResources();
+            }
+        }
+
+    // Reset the file pipe
+    iCommand->ResetFiles();
+
+    // Reset parameters
+    iCommand->ResetParameters();
+
+    // Leave if operation failed
+    if( status != KErrNone )
+        {
+        User::Leave( status );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCopyCommand::CopyPlaylistL
+// Copies the given playlist (playlist name + filenames) to a remote Upnp
+// Media Server.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpCopyCommand::CopyPlaylistL( const TDesC& aPlaylistName,
+                                               CDesCArrayFlat* aFiles )
+    {
+    // Check playlist name parameter, aFiles will be checked later
+    if( aPlaylistName == KNullDesC )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Set the playlist parameter
+    iCommand->SetParameterL(
+        UpnpCommand::EParamCollectionName, aPlaylistName );
+
+    // Use CopyFilesL to do the copy (and to handle cleanup)
+    CopyFilesL( aFiles );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCopyCommand::IsAvailable
+// Inline implementation of the IsAvailable method.
+// --------------------------------------------------------------------------
+//
+EXPORT_C TBool CUpnpCopyCommand::IsAvailableL()
+    {
+    // create a temporary plugin instance
+    // then query command availability.
+    TBool available = EFalse;
+    TRAP_IGNORE(
+        CUpnpCommand* temp = UpnpCommandMain::LoadL( 
+                                        UpnpCommand::ECommandCopy );
+        CleanupStack::PushL( temp );
+        available = temp->IsAvailableL();
+        CleanupStack::PopAndDestroy( temp );
+        );
+    return available;
+    }
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpcopytask.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpcopytask.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,171 +1,171 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpCopyTask class.
-*
-*/
-
-
-// INCLUDE FILES
-// System
-#include <utf.h>                        // ConvertToUnicodeFromUtf8L
-
-// upnp stack api
-#include <upnpitem.h>                   // CUpnpItem
-#include <upnpobject.h>                 // CUpnpObject (cast)
-
-// upnp framework / avcontroller api
-#include "upnpavcontroller.h"           // MUPnPAVController
-#include "upnpavcontrollerfactory.h"    // UPnPAVControllerFactory
-#include "upnpavbrowsingsession.h"      // MUPnPAVBrowsingSession
-#include "upnpavsessionbase.h"          // ReserveLocalMSServicesCompleted()
-#include "upnpavdevice.h"               // CUpnpAVDevice
-
-// upnp framework / commonutils api
-#include "upnpcommonutils.h"            // TUPnPItemType
-#include "upnpmetadatafetcher.h"        // UPnPMetadataFetcher
-
-// upnp framework / filetransferengine api
-#include "upnpfiletransferengine.h"     // CUpnpFileTransferEngine
-
-// upnp framework / command internal
-#include "upnpfilepipe.h"               // CUpnpFilePipe
-#include "upnpcommandparameters.h"      // CUpnpCommandParameters
-#include "upnptaskhandler.h"            // MUpnpTaskHandler
-#include "upnpnotehandler.h"            // CUpnpNoteHandler
-#include "upnpcopytask.h"
-#include "upnpcommand.h"
-#include "upnptaskresourceallocator.h"  // CUpnpTaskResourceAllocator
-
-_LIT( KComponentLogfile, "upnpcommand.log");
-#include "upnplog.h"
-
-// --------------------------------------------------------------------------
-// CUpnpCopyTask::NewL
-// Creates an instance of the implementation.
-// --------------------------------------------------------------------------
-//
-CUpnpTask* CUpnpCopyTask::NewL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCopyTask::NewL" );
-
-    // Create instance
-    CUpnpCopyTask* self = new (ELeave) CUpnpCopyTask();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCopyTask::CUpnpCopyTask
-// First phase construction.
-// --------------------------------------------------------------------------
-//
-CUpnpCopyTask::CUpnpCopyTask()
-    : CUpnpFileTransferBaseTask()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCopyTask::Constructor" );
-    }
-
-// --------------------------------------------------------------------------
-// Destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpCopyTask::~CUpnpCopyTask()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCopyTask::Destructor" );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCopyTask::ConstructL
-// Perform the second phase of two phase construction. Reserves the Upnp Fw
-// resources (they are released when the task is destroyed).
-// --------------------------------------------------------------------------
-//
-void CUpnpCopyTask::ConstructL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCopyTask::ConstructL" );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCopyTask::AllocateResourcesL
-// Allocates the Upnp Fw resources.
-// --------------------------------------------------------------------------
-//
-void CUpnpCopyTask::AllocateResourcesL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCopyTask::AllocateResourcesL" );
-
-    AllocateFileTransferResourcesL(
-        CUpnpTaskResourceAllocator::EResourceAvController |
-        CUpnpTaskResourceAllocator::EResourceSelectCopyServer );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCopyTask::ExecuteL
-// Executes the task.
-// --------------------------------------------------------------------------
-//
-void CUpnpCopyTask::ExecuteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpCopyTask::ExecuteL" );
-
-    if( !ResourceAllocator() )
-        {
-        __LOG( "[UpnpCommand]\t CUpnpCopyTask::ExecuteL \
-resources not allocated, leave" );
-        User::Leave( KErrNotReady );
-        }
-
-    TInt transferredFiles = 0;
-
-    TRAPD( status, ExecuteFileTransferL
-        ( EFalse, transferredFiles ) );
-    __LOG1( "[UpnpCommand]\t CUpnpCopyTask::ExecuteL done status %d", status );
-
-    // inform user
-    if( status == KErrNone )
-        {
-        HBufC* deviceString = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
-            ResourceAllocator()->SelectedDevice().FriendlyName() );
-        CleanupStack::PushL( deviceString );
-        NoteHandler()->ShowCopyInfoNoteL( 
-            transferredFiles,  *deviceString );
-        CleanupStack::PopAndDestroy( deviceString );
-        }
-    else if( status == KErrDisconnected || status == KErrSessionClosed 
-            || status == KErrCouldNotConnect )
-        {
-        // check if wlan is active
-        // note shown only in device disappeared cases
-        if( IsWlanActive() )
-            {
-            NoteHandler()->ShowCopyDisconnectionErrorNoteL();
-            }
-        }                 
-    else if( status != KErrCancel )
-        {
-        // some other generic error EXCEPT cancel
-        NoteHandler()->ShowCopyErrorNoteL();
-        }
-
-    // If there was an error, leave
-    if( status != KErrNone )
-        {
-        User::Leave( status );
-        }
-    }
-
-
-// End of File
+/*
+* Copyright (c) 2007 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:  Source file for CUpnpCopyTask class.
+*
+*/
+
+
+// INCLUDE FILES
+// System
+#include <utf.h>                        // ConvertToUnicodeFromUtf8L
+
+// upnp stack api
+#include <upnpitem.h>                   // CUpnpItem
+#include <upnpobject.h>                 // CUpnpObject (cast)
+
+// upnp framework / avcontroller api
+#include "upnpavcontroller.h"           // MUPnPAVController
+#include "upnpavcontrollerfactory.h"    // UPnPAVControllerFactory
+#include "upnpavbrowsingsession.h"      // MUPnPAVBrowsingSession
+#include "upnpavsessionbase.h"          // ReserveLocalMSServicesCompleted()
+#include "upnpavdevice.h"               // CUpnpAVDevice
+
+// upnp framework / commonutils api
+#include "upnpcommonutils.h"            // TUPnPItemType
+#include "upnpmetadatafetcher.h"        // UPnPMetadataFetcher
+
+// upnp framework / filetransferengine api
+#include "upnpfiletransferengine.h"     // CUpnpFileTransferEngine
+
+// upnp framework / command internal
+#include "upnpfilepipe.h"               // CUpnpFilePipe
+#include "upnpcommandparameters.h"      // CUpnpCommandParameters
+#include "upnptaskhandler.h"            // MUpnpTaskHandler
+#include "upnpnotehandler.h"            // CUpnpNoteHandler
+#include "upnpcopytask.h"
+#include "upnpcommand.h"
+#include "upnptaskresourceallocator.h"  // CUpnpTaskResourceAllocator
+
+_LIT( KComponentLogfile, "upnpcommand.log");
+#include "upnplog.h"
+
+// --------------------------------------------------------------------------
+// CUpnpCopyTask::NewL
+// Creates an instance of the implementation.
+// --------------------------------------------------------------------------
+//
+CUpnpTask* CUpnpCopyTask::NewL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCopyTask::NewL" );
+
+    // Create instance
+    CUpnpCopyTask* self = new (ELeave) CUpnpCopyTask();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCopyTask::CUpnpCopyTask
+// First phase construction.
+// --------------------------------------------------------------------------
+//
+CUpnpCopyTask::CUpnpCopyTask()
+    : CUpnpFileTransferBaseTask()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCopyTask::Constructor" );
+    }
+
+// --------------------------------------------------------------------------
+// Destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpCopyTask::~CUpnpCopyTask()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCopyTask::Destructor" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCopyTask::ConstructL
+// Perform the second phase of two phase construction. Reserves the Upnp Fw
+// resources (they are released when the task is destroyed).
+// --------------------------------------------------------------------------
+//
+void CUpnpCopyTask::ConstructL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCopyTask::ConstructL" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCopyTask::AllocateResourcesL
+// Allocates the Upnp Fw resources.
+// --------------------------------------------------------------------------
+//
+void CUpnpCopyTask::AllocateResourcesL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCopyTask::AllocateResourcesL" );
+
+    AllocateFileTransferResourcesL(
+        CUpnpTaskResourceAllocator::EResourceAvController |
+        CUpnpTaskResourceAllocator::EResourceSelectCopyServer );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCopyTask::ExecuteL
+// Executes the task.
+// --------------------------------------------------------------------------
+//
+void CUpnpCopyTask::ExecuteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpCopyTask::ExecuteL" );
+
+    if( !ResourceAllocator() )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpCopyTask::ExecuteL \
+resources not allocated, leave" );
+        User::Leave( KErrNotReady );
+        }
+
+    TInt transferredFiles = 0;
+
+    TRAPD( status, ExecuteFileTransferL
+        ( EFalse, transferredFiles ) );
+    __LOG1( "[UpnpCommand]\t ExecuteL done status %d", status );
+
+    // inform user
+    if( status == KErrNone )
+        {
+        HBufC* deviceString = CnvUtfConverter::ConvertToUnicodeFromUtf8L(
+            ResourceAllocator()->SelectedDevice().FriendlyName() );
+        CleanupStack::PushL( deviceString );
+        NoteHandler()->ShowCopyInfoNoteL( 
+            transferredFiles,  *deviceString );
+        CleanupStack::PopAndDestroy( deviceString );
+        }
+    else if( status == KErrDisconnected || status == KErrSessionClosed 
+            || status == KErrCouldNotConnect )
+        {
+        // check if wlan is active
+        // note shown only in device disappeared cases
+        if( IsWlanActive() )
+            {
+            NoteHandler()->ShowCopyDisconnectionErrorNoteL();
+            }
+        }                 
+    else if( status != KErrCancel )
+        {
+        // some other generic error EXCEPT cancel
+        NoteHandler()->ShowCopyErrorNoteL();
+        }
+
+    // If there was an error, leave
+    if( status != KErrNone )
+        {
+        User::Leave( status );
+        }
+    }
+
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpfiletransferbasetask.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpfiletransferbasetask.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,257 +1,257 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpFileTransferBaseTask class.
-*
-*/
-
-
-// INCLUDE FILES
-// system
-#include <utf.h>                        // ConvertToUnicodeFromUtf8L
-
-// upnp stack api
-#include <upnpitem.h>                   // CUpnpItem
-#include <upnpobject.h>                 // CUpnpObject (cast)
-
-// upnp framework / avcontroller api
-#include "upnpavcontrollerfactory.h"    // UPnPAVControllerFactory
-#include "upnpavcontroller.h"           // MUPnPAVController
-#include "upnpavbrowsingsession.h"      // MUPnPAVBrowsingSession
-#include "upnpavsessionobserverbase.h"  // MUPnPAVSessionObserverBase
-#include "upnpavdevice.h"               // CUpnpAVDevice
-
-// upnp framework / common utils api
-#include "upnpcommonutils.h"            // TUPnPItemType
-#include "upnpmetadatafetcher.h"        // UPnPMetadataFetcher
-
-// upnp framework / fte
-#include "upnpfiletransferengine.h"     // CUpnpFileTransferEngine
-// upnp framework / common ui
-#include "upnpcommonui.h"               // CUpnpCommonUI
-
-// upnpcommand internal
-#include "upnpfilepipe.h"               // CUpnpFilePipe
-#include "upnpcommandparameters.h"      // CUpnpCommandParameters
-#include "upnptaskhandler.h"            // MUpnpTaskHandler
-#include "upnpnotehandler.h"            // CUpnpNoteHandler
-#include "upnpcommand.h"                // CUpnpCommand
-#include "upnptaskresourceallocator.h"  // CUpnpTaskResourceAllocator
-#include "upnpfiletransferbasetask.h"   // CUpnpFileTransferBaseTask
-
-
-_LIT( KComponentLogfile, "upnpcommand.log");
-#include "upnplog.h"
-
-
-// --------------------------------------------------------------------------
-// CUpnpFileTransferBaseTask::CUpnpFileTransferBaseTask
-// First phase construction.
-// --------------------------------------------------------------------------
-//
-CUpnpFileTransferBaseTask::CUpnpFileTransferBaseTask()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::Constructor" );
-    }
-
-// --------------------------------------------------------------------------
-// Destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpFileTransferBaseTask::~CUpnpFileTransferBaseTask()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::Destructor" );
-
-    // delete the resource allocator
-    // Local mediaserver and AVController resources will be freed.
-    delete iResourceAllocator;
-    delete iCommonUI;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpFileTransferBaseTask::AllocateFileTransferResourcesL
-// Allocates the Upnp Fw resources.
-// --------------------------------------------------------------------------
-//
-void CUpnpFileTransferBaseTask::AllocateFileTransferResourcesL( TInt aMode)
-    {
-    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::AllocateResourcesL" );
-    
-    // create common UI
-    iCommonUI = CUPnPCommonUI::NewL();
-    
-    // create the resource allocator
-    iResourceAllocator = CUpnpTaskResourceAllocator::NewL(
-        *iCommonUI, aMode);
-        
-    iState = EStateConnected; 
-    
-    iResourceAllocator->SetNoteHandlerL( NoteHandler() );
-    
-    // now allocate!
-    iResourceAllocator->AllocateL();
-
-     // start a browsing session
-    iBrowsingSession =
-        &iResourceAllocator->AVController().StartBrowsingSessionL(
-            iResourceAllocator->SelectedDevice() );
-            
-    iBrowsingSession->SetObserver( *this );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpFileTransferBaseTask::ResourceAllocator
-// Executes the task.
-// --------------------------------------------------------------------------
-//
-CUpnpTaskResourceAllocator* CUpnpFileTransferBaseTask::ResourceAllocator()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::ResourceAllocator" );
- 
-    return iResourceAllocator;
-    }
-
-    
-// --------------------------------------------------------------------------
-// CUpnpFileTransferBaseTask::ExecuteFileTransferL
-// Executes the task.
-// --------------------------------------------------------------------------
-//
-void CUpnpFileTransferBaseTask::ExecuteFileTransferL( TBool aRemoveFiles, 
-    TInt& aTransferredFiles)
-    {
-    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::ExecuteL" );
-
-
-    // Leave if command has not been allocated yet
-    if( !FilePipe() ||
-        !CommandParameters() ||
-        !NoteHandler() ||
-        !iBrowsingSession ||
-        !iResourceAllocator )
-        {
-        __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::\
-ExecuteFileTransferL resources not allocated, leave" );
-        User::Leave( KErrNotReady );
-        }
-
-    // reset drm-note calculator ( note is shown once per operation )
-    NoteHandler()->ResetDrmNoteCount();
-    
-    TInt status = KErrNone;
-    TInt origFileCount = FilePipe()->Count();;    
-    TInt failedFileCount = 0;   
-
-    // Initialise and execute the UpnpFileTransferEngine
-    CUpnpFileTransferEngine* ftEngine = NULL;
-    ftEngine = CUpnpFileTransferEngine::NewL( iBrowsingSession );
-    if( status == KErrNone &&
-        ftEngine )
-        {
-        CleanupStack::PushL( ftEngine );
-        
-        // move operation
-        if( aRemoveFiles )
-            {
-            __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask, move files" );
-            ftEngine->MoveLocalFilesToRemoteServerL(
-                 &FilePipe()->AsArray() );
-            }
-        // copy operation
-        else
-            {  
-            // Read the collection name (if any)
-            const TDesC& collectionName =
-                CommandParameters()->Get( UpnpCommand::EParamCollectionName );
-
-            // If collection name is not set, the operation is file copy
-            if( collectionName != KNullDesC )
-                {
-                __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask,\
- copy playlist" );
-                ftEngine->CopyLocalPlaylistToRemoteServerL(
-                              collectionName, &FilePipe()->AsArray() );
-                }
-            // If collection name is set, the operation is playlist copy
-            else
-                {
-                __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask,\
- copy files" );
-                ftEngine->CopyLocalFilesToRemoteServerL(
-                              &FilePipe()->AsArray() );
-                }
-            }
-
-        // Clean up
-        CleanupStack::PopAndDestroy( ftEngine );
-        ftEngine = NULL;
-        }
-
-    // calculate number of transferred files based on original file count and
-    // items remaining in filepipe (those were NOT transferred)
-    failedFileCount = FilePipe()->Count();
-    aTransferredFiles = origFileCount - failedFileCount;
-
-    // check if connection was lost during transfer
-    if( iState != EStateConnected )
-        {
-        status = KErrDisconnected;
-        }
-
-    __LOG1( "[UpnpCommand]\t CUpnpFileTransferBaseTask::\
-ExecuteL done status %d", status );
-    
-    // If there was an error, leave
-    if( status != KErrNone )
-        {
-        User::Leave( status );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpFileTransferBaseTask::MediaServerDisappeared
-// Notifies that the Media Renderer we have a session with has disappeared.
-// --------------------------------------------------------------------------
-//
-void CUpnpFileTransferBaseTask::MediaServerDisappeared( 
-    TUPnPDeviceDisconnectedReason aReason )
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpFileTransferBaseTask::\
-MediaServerDisappeared aReason %d", aReason );
-
-    // need to know if wlan or server was lost
-    if( aReason == MUPnPAVSessionObserverBase::EWLANLost )
-        {
-        iState = EStateWLANLost;
-        }
-    else
-        {
-        iState = EStateMSLost;
-        }
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpFileTransferBaseTask::IsWlanActive
-// Returns connection state
-// --------------------------------------------------------------------------
-//
-TBool CUpnpFileTransferBaseTask::IsWlanActive()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::IsWlanActive" );
-
-    return (iState != EStateWLANLost);
-    }
-
-// End of File
+/*
+* Copyright (c) 2009 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:  Source file for CUpnpFileTransferBaseTask class.
+*
+*/
+
+
+// INCLUDE FILES
+// system
+#include <utf.h>                        // ConvertToUnicodeFromUtf8L
+
+// upnp stack api
+#include <upnpitem.h>                   // CUpnpItem
+#include <upnpobject.h>                 // CUpnpObject (cast)
+
+// upnp framework / avcontroller api
+#include "upnpavcontrollerfactory.h"    // UPnPAVControllerFactory
+#include "upnpavcontroller.h"           // MUPnPAVController
+#include "upnpavbrowsingsession.h"      // MUPnPAVBrowsingSession
+#include "upnpavsessionobserverbase.h"  // MUPnPAVSessionObserverBase
+#include "upnpavdevice.h"               // CUpnpAVDevice
+
+// upnp framework / common utils api
+#include "upnpcommonutils.h"            // TUPnPItemType
+#include "upnpmetadatafetcher.h"        // UPnPMetadataFetcher
+
+// upnp framework / fte
+#include "upnpfiletransferengine.h"     // CUpnpFileTransferEngine
+// upnp framework / common ui
+#include "upnpcommonui.h"               // CUpnpCommonUI
+
+// upnpcommand internal
+#include "upnpfilepipe.h"               // CUpnpFilePipe
+#include "upnpcommandparameters.h"      // CUpnpCommandParameters
+#include "upnptaskhandler.h"            // MUpnpTaskHandler
+#include "upnpnotehandler.h"            // CUpnpNoteHandler
+#include "upnpcommand.h"                // CUpnpCommand
+#include "upnptaskresourceallocator.h"  // CUpnpTaskResourceAllocator
+#include "upnpfiletransferbasetask.h"   // CUpnpFileTransferBaseTask
+
+
+_LIT( KComponentLogfile, "upnpcommand.log");
+#include "upnplog.h"
+
+
+// --------------------------------------------------------------------------
+// CUpnpFileTransferBaseTask::CUpnpFileTransferBaseTask
+// First phase construction.
+// --------------------------------------------------------------------------
+//
+CUpnpFileTransferBaseTask::CUpnpFileTransferBaseTask()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::Constructor" );
+    }
+
+// --------------------------------------------------------------------------
+// Destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpFileTransferBaseTask::~CUpnpFileTransferBaseTask()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::Destructor" );
+
+    // delete the resource allocator
+    // Local mediaserver and AVController resources will be freed.
+    delete iResourceAllocator;
+    delete iCommonUI;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpFileTransferBaseTask::AllocateFileTransferResourcesL
+// Allocates the Upnp Fw resources.
+// --------------------------------------------------------------------------
+//
+void CUpnpFileTransferBaseTask::AllocateFileTransferResourcesL( TInt aMode)
+    {
+    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::AllocateResourcesL" );
+    
+    // create common UI
+    iCommonUI = CUPnPCommonUI::NewL();
+    
+    // create the resource allocator
+    iResourceAllocator = CUpnpTaskResourceAllocator::NewL(
+        *iCommonUI, aMode);
+        
+    iState = EStateConnected; 
+    
+    iResourceAllocator->SetNoteHandlerL( NoteHandler() );
+    
+    // now allocate!
+    iResourceAllocator->AllocateL();
+
+     // start a browsing session
+    iBrowsingSession =
+        &iResourceAllocator->AVController().StartBrowsingSessionL(
+            iResourceAllocator->SelectedDevice() );
+            
+    iBrowsingSession->SetObserver( *this );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpFileTransferBaseTask::ResourceAllocator
+// Executes the task.
+// --------------------------------------------------------------------------
+//
+CUpnpTaskResourceAllocator* CUpnpFileTransferBaseTask::ResourceAllocator()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::ResourceAllocator" );
+ 
+    return iResourceAllocator;
+    }
+
+    
+// --------------------------------------------------------------------------
+// CUpnpFileTransferBaseTask::ExecuteFileTransferL
+// Executes the task.
+// --------------------------------------------------------------------------
+//
+void CUpnpFileTransferBaseTask::ExecuteFileTransferL( TBool aRemoveFiles, 
+    TInt& aTransferredFiles)
+    {
+    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::ExecuteL" );
+
+
+    // Leave if command has not been allocated yet
+    if( !FilePipe() ||
+        !CommandParameters() ||
+        !NoteHandler() ||
+        !iBrowsingSession ||
+        !iResourceAllocator )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::\
+ExecuteFileTransferL resources not allocated, leave" );
+        User::Leave( KErrNotReady );
+        }
+
+    // reset drm-note calculator ( note is shown once per operation )
+    NoteHandler()->ResetDrmNoteCount();
+    
+    TInt status = KErrNone;
+    TInt origFileCount = FilePipe()->Count();
+    TInt failedFileCount = 0;
+
+    // Initialise and execute the UpnpFileTransferEngine
+    CUpnpFileTransferEngine* ftEngine = NULL;
+    ftEngine = CUpnpFileTransferEngine::NewL( iBrowsingSession );
+    if( status == KErrNone &&
+        ftEngine )
+        {
+        CleanupStack::PushL( ftEngine );
+        
+        // move operation
+        if( aRemoveFiles )
+            {
+            __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask, move files" );
+            ftEngine->MoveLocalFilesToRemoteServerL(
+                 &FilePipe()->AsArray() );
+            }
+        // copy operation
+        else
+            {  
+            // Read the collection name (if any)
+            const TDesC& collectionName =
+                CommandParameters()->Get( UpnpCommand::EParamCollectionName );
+
+            // If collection name is not set, the operation is file copy
+            if( collectionName != KNullDesC )
+                {
+                __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask,\
+ copy playlist" );
+                ftEngine->CopyLocalPlaylistToRemoteServerL(
+                              collectionName, &FilePipe()->AsArray() );
+                }
+            // If collection name is set, the operation is playlist copy
+            else
+                {
+                __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask,\
+ copy files" );
+                ftEngine->CopyLocalFilesToRemoteServerL(
+                              &FilePipe()->AsArray() );
+                }
+            }
+
+        // Clean up
+        CleanupStack::PopAndDestroy( ftEngine );
+        ftEngine = NULL;
+        }
+
+    // calculate number of transferred files based on original file count and
+    // items remaining in filepipe (those were NOT transferred)
+    failedFileCount = FilePipe()->Count();
+    aTransferredFiles = origFileCount - failedFileCount;
+
+    // check if connection was lost during transfer
+    if( iState != EStateConnected )
+        {
+        status = KErrDisconnected;
+        }
+
+    __LOG1( "[UpnpCommand]\t CUpnpFileTransferBaseTask::\
+ExecuteL done status %d", status );
+    
+    // If there was an error, leave
+    if( status != KErrNone )
+        {
+        User::Leave( status );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpFileTransferBaseTask::MediaServerDisappeared
+// Notifies that the Media Renderer we have a session with has disappeared.
+// --------------------------------------------------------------------------
+//
+void CUpnpFileTransferBaseTask::MediaServerDisappeared( 
+    TUPnPDeviceDisconnectedReason aReason )
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpFileTransferBaseTask::\
+MediaServerDisappeared aReason %d", aReason );
+
+    // need to know if wlan or server was lost
+    if( aReason == MUPnPAVSessionObserverBase::EWLANLost )
+        {
+        iState = EStateWLANLost;
+        }
+    else
+        {
+        iState = EStateMSLost;
+        }
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpFileTransferBaseTask::IsWlanActive
+// Returns connection state
+// --------------------------------------------------------------------------
+//
+TBool CUpnpFileTransferBaseTask::IsWlanActive()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpFileTransferBaseTask::IsWlanActive" );
+
+    return (iState != EStateWLANLost);
+    }
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpimagerenderingengine.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpimagerenderingengine.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,683 +1,693 @@
-/*
-* Copyright (c) 2007 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:  Engine for rendering images remotely
-*
-*/
-
-
-// INCLUDE FILES
-// upnp stack api
-#include <upnpitem.h>                   // CUpnpItem
-#include <upnpobject.h>                 // CUpnpObject (cast)
-
-// upnpframework / avcontroller api
-#include "upnpavrenderingsession.h"     // MUPnPAVRenderingSession
-#include "upnpavsessionobserverbase.h" 
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h"           // KFilterCommon
-#include "upnpitemresolver.h"           // MUPnPItemResolver
-#include "upnpitemresolverobserver.h"   // MUPnPItemResolverObserver
-#include "upnpitemresolverfactory.h"    // UPnPItemResolverFactory
-#include "upnpitemutility.h"            // UPnPItemUtility::BelongsToClass
-
-// upnpframework / commonui
-#include "upnpcommonui.h"               // common UI for upnp video player dlg
-
-// command internal
-#include "upnpimagerenderingengineobserver.h"   // the observer interface
-#include "upnpimagerenderingengine.h"   // myself
-#include "upnpperiodic.h"
-
-_LIT( KComponentLogfile, "upnpcommand.log");
-#include "upnplog.h"
-
-// CONSTANT DEFINITIONS
-const TInt KReactionTimerMicrosec = 100000; // 100 millisec.
-
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::NewL
-// --------------------------------------------------------------------------
-//
-CUpnpImageRenderingEngine* CUpnpImageRenderingEngine::NewL(
-            MUPnPAVController& aAVController,
-            MUPnPAVRenderingSession& aSession,
-            MUpnpImageRenderingEngineObserver& aObserver )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::NewL" );
-
-    // Create instance
-    CUpnpImageRenderingEngine* self = NULL;
-    self = new (ELeave) CUpnpImageRenderingEngine(
-            aAVController, aSession, aObserver );
-    CleanupStack::PushL( self );
-    self->ConstructL( );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::CUpnpImageRenderingEngine
-// --------------------------------------------------------------------------
-//
-CUpnpImageRenderingEngine::CUpnpImageRenderingEngine(
-            MUPnPAVController& aAVController,
-            MUPnPAVRenderingSession& aSession,
-            MUpnpImageRenderingEngineObserver& aObserver )
-    : iAVController( aAVController )
-    , iRenderingSession( aSession )
-    , iObserver( aObserver )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine: Constructor" );
-
-    // Initialise member variables
-    iState = EIdle;
-    iCurrentResolver = 0;
-    iBufferedResolver = 0;
-
-    // set observer
-    iRenderingSession.SetObserver( *this );
-    }
-
-// --------------------------------------------------------------------------
-// Second phase constructor.
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::ConstructL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::ConstructL" );
-    iTimer = CUPnPPeriodic::NewL( CActive::EPriorityStandard );
-    
-    iWlanActive = ETrue;
-    }
-    
-// --------------------------------------------------------------------------
-// Destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpImageRenderingEngine::~CUpnpImageRenderingEngine()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine: Destructor" );
-
-    Cleanup();
-
-    // Stop observing the rendering session
-    iRenderingSession.RemoveObserver();
-
-    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::~CUpnpImageRenderingEngine delete iCurrentResolver" );
-    MUPnPItemResolver* tempCurrentResolver = iCurrentResolver;
-    iCurrentResolver = NULL;
-    delete tempCurrentResolver;
-    
-       if( iTimer )
-        {    
-        iTimer->Cancel();
-        delete iTimer;
-        iTimer = 0;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::Cleanup
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::Cleanup()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::Cleanup" );
-
-    // reset state
-    if ( iState != EShuttingDown )
-        {
-        iState = EIdle;
-        }
-
-    if( iTimer )
-        {    
-        iTimer->Cancel();
-        }
-
-    iBufferingNewImage = EFalse;
-
-    // Delete resolvers
-    // Delete for resolvers is done using temporary variables so that we can
-    // first nullify the members and then delete the actual objects.
-    // This is because local resolver deletion uses active scheduler loops
-    // and therefore other asynchronous events may orrur. So we may end
-    // up here in Cleanup again, during the resolver is being deleted.
-    // if deletion is done the conventional way, the objects get deleted
-    // twice, which is not what we want. :-)
-    
-    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::Cleanup delete iBufferedResolver" );
-    MUPnPItemResolver* tempBufferedResolver = iBufferedResolver;
-    iBufferedResolver = NULL;
-    delete tempBufferedResolver;
-
-    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::Cleanup end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::PlayL
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::PlayL()
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::PlayL in state %d",
-        iState);
-
-    if ( iState != EShuttingDown )
-        {
-        if( iTimer->IsActive() )
-            {
-            __LOG( "[UpnpCommand]\t timer already active" );
-            }
-        else
-            {
-            TTimeIntervalMicroSeconds32 delay( KReactionTimerMicrosec );
-            iTimer->Start( delay, delay, TCallBack( Timer, this ) );
-            }
-        }
-    else
-        {
-        __LOG( "[UpnpCommand]\t not doing play in shutting down state" );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::StopL
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::StopL()
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::StopL in state %d",
-        iState);
-
-    // cancel any timers that are going on
-    iTimer->Cancel();
-
-    // remove buffered images
-    iBufferingNewImage = EFalse;
-    delete iBufferedResolver;
-    iBufferedResolver = 0;
-
-    switch( iState )
-        {
-        case EIdle:
-        case EResolvingItem:
-        case EResolveComplete:
-        case ESettingUri: // fall through
-            {
-            // just cancel the sequence and do nothing
-            iState = EIdle;
-            break;
-            }
-        case EStartingPlay:
-            {
-            // wait for PLAY complete, then do STOP
-            // then wait for STOP complete
-            iState = EStopping;
-            break;
-            }
-        case EPlaying:
-            {
-            // Send stop action.
-            iRenderingSession.StopL();
-            iState = EStopping;
-            break;
-            }
-        case EStopping:
-            {
-            // already stopping - do nothing
-            break;
-            }
-        case EShuttingDown:
-            {
-            // command not allowed in this state
-            break;
-            }
-        default:
-            {
-            __PANICD( __FILE__, __LINE__ );
-            break;
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::Timer
-// timer callback
-// --------------------------------------------------------------------------
-//
-TInt CUpnpImageRenderingEngine::Timer( TAny* aArg )
-    {    
-    CUpnpImageRenderingEngine* self =
-        static_cast<CUpnpImageRenderingEngine*>( aArg );
-    TRAPD( error, self->RunTimerL() )
-    if ( error != KErrNone )
-        self->RunError( error );
-    return 0; // do not call again
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::RunTimerL
-// Timer has triggered, start rendering media.
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::RunTimerL()
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::RunTimerL, state %d",
-        iState );
-        
-    iTimer->Cancel();
-
-    delete iBufferedResolver;
-    iBufferedResolver = iObserver.GetMedia();
-    if ( iBufferedResolver == 0 )
-        {
-        __LOG( "[UpnpCommand]\t resolver returned zero" );
-        User::Leave( KErrCancel );
-        }
-
-    switch( iState )
-        {
-        case EIdle: // fall through
-            {
-            StartResolvingL();
-            break;
-            }
-        case EResolvingItem: // fall through
-        case EResolveComplete:
-        case ESettingUri: // fall through
-        case EStartingPlay:
-            {
-            // indicate that new image is being buffered. It will be popped
-            // from buffer in next callback.
-            iBufferingNewImage = ETrue;
-            break;
-            }
-        case EPlaying:
-            {
-            // indicate that new image is being buffered. Send stop signal.
-            // new item will be handled after stop completed.
-            iBufferingNewImage = ETrue;
-            iRenderingSession.StopL();
-            iState = EStopping;
-            break;
-            }
-        case EStopping:
-            {
-            // indicate that new image is being buffered. It will be popped
-            // from buffer in next callback.
-            iBufferingNewImage = ETrue;
-            break;
-            }
-        case EShuttingDown:
-            {
-            // command not allowed in this state
-            break;
-            }
-        default:
-            {
-            __PANICD( __FILE__, __LINE__ );
-            break;
-            }
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::StartResolvingL
-// Handles the start up of the item resolving.
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::StartResolvingL()
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::StartResolvingL\
- in state %d",
-        iState );
-
-    __ASSERTD( iBufferedResolver, __FILE__, __LINE__ );
-    if ( !iBufferedResolver )
-        {
-        // something is very wrong
-        User::Leave( KErrDisconnected );
-        }
-    
-    // delete old resolver
-    // destruction takes time due to unsharing, so set to null first
-    // so that this wont be used else where
-    MUPnPItemResolver* tempCurrentResolver = iCurrentResolver;
-    iCurrentResolver = NULL;
-    delete tempCurrentResolver;
-    
-    // take queued resolver in use
-    iCurrentResolver = iBufferedResolver;
-    iBufferedResolver = NULL;
-    iBufferingNewImage = EFalse;
-
-    // Update the state
-    iState = EResolvingItem;
-
-    // Start resolving the item
-    iCurrentResolver->ResolveL( *this );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::ResolveComplete
-// Indicates that resolving of an item is complete.
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::ResolveComplete(
-    const MUPnPItemResolver& aResolver,
-    TInt aError )
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::ResolveComplete\
- in state %d", iState );
-
-    // if engine is shutting down, no need to check these
-    if ( iState == EResolvingItem )
-        {
-        __ASSERTD( &aResolver == iCurrentResolver, __FILE__, __LINE__ );
-        if( iBufferingNewImage )
-            {
-            TRAP( aError, StartResolvingL() );
-            }
-        else if( aError == KErrNone )
-            {
-            iState = EResolveComplete;
-            
-            // Now that we have the full metadata of the item available, we
-            // can start the rendering
-            TRAP( aError, InitiateShowingL() );
-            }
-        // error handling
-        if( aError != KErrNone && iState != EShuttingDown )
-            {
-            SendRenderAck( aError );
-            }
-        }
-    else if( iState == EShuttingDown )
-        {
-        // do nothing.
-        iState = EIdle;
-        }
-    else
-        {
-        __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine: state error." );
-        __PANICD( __FILE__, __LINE__ );
-        iState = EIdle;
-        }
-
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::InitiateShowingL
-// Handles the initiation of rendering (SetUri or video player launching).
-// --------------------------------------------------------------------------
-void CUpnpImageRenderingEngine::InitiateShowingL()
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::InitiateShowingL\
- in state %d",
-        iState );
-    __ASSERTD( iCurrentResolver, __FILE__, __LINE__ );
-
-    if ( UPnPItemUtility::BelongsToClass(
-        iCurrentResolver->Item(), KClassImage ) )
-        {
-         // Send the setUri action
-        iRenderingSession.SetURIL(
-            iCurrentResolver->Resource().Value(),
-            iCurrentResolver->Item() );
-        // update the state
-        iState = ESettingUri;
-        }
-    else
-        {
-        User::Leave( KErrNotSupported );
-        }
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::SetURIResult
-// UPnP AV Controller calls this method as a result for the 'set uri' request.
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::SetURIResult( TInt aError )
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::SetURIResult\
- in state %d",
-        iState );
-
-    if ( iState == ESettingUri )
-        {
-        //need check the aError in case of SetURIL cause a error.
-        if( aError != KErrNone )
-            {
-            Cleanup();
-            return;         
-            }
-        __ASSERTD( iCurrentResolver, __FILE__, __LINE__ );
-        if( iBufferingNewImage )
-            {
-            TRAP( aError, StartResolvingL() );
-            }
-        else if( aError == KErrNone )
-            {
-            TRAP( aError, iRenderingSession.PlayL() );
-            if( aError == KErrNone )
-                {
-                // Update the state
-                iState = EStartingPlay;
-                }
-            }
-        // error handling
-        if( aError != KErrNone )
-            {
-            SendRenderAck( aError );
-            }
-        }
-    else if ( iState == EShuttingDown )
-        {
-        // do nothing
-        }
-    else
-        {
-        __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine: state error." );
-        __PANICD( __FILE__, __LINE__ );
-        iState = EIdle;
-        }
-
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::InteractOperationComplete
-// Called by UpnpAvController to indicate that play is complete.
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::InteractOperationComplete(
-    TInt aError,
-    TUPnPAVInteractOperation aOperation )
-    {
-    __LOG2( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
-InteractOperationComplete (%d) in state %d", aOperation, iState );
-
-    if ( iState == EStartingPlay )
-        {
-        __ASSERTD( iCurrentResolver, __FILE__, __LINE__ );
-        if( aOperation == EUPnPAVPlay && iBufferingNewImage )
-            {
-            // New image in buffer! call stop, then play new item.
-            TRAP( aError, iRenderingSession.StopL() );
-            if ( aError == KErrNone )
-                {
-                iState = EStopping;
-                }
-            }
-        else if ( aOperation == EUPnPAVPlay && aError == KErrNone )
-            {
-            // update status
-            iState = EPlaying;
-            // response for play request
-            SendRenderAck( KErrNone );
-            }
-        // error handling
-        if ( aError != KErrNone )
-            {
-            SendRenderAck( aError );
-            }
-        }
-    else if ( iState == EPlaying )
-        {
-        if( aOperation == EUPnPAVPlayUser )
-            {
-            // state change event notification
-            // no need to do anything here
-            }
-        else if( aOperation == EUPnPAVStopUser )
-            {
-            // user stop notification
-            // state to idle, so that no stop event will be sent
-            // if starting to process new item
-            iState = EIdle;
-            }
-        }
-    else if ( iState == EStopping )
-        {
-        __ASSERTD( iCurrentResolver, __FILE__, __LINE__ );
-        if( aOperation == EUPnPAVStop && iBufferingNewImage )
-            {
-            TRAP( aError, StartResolvingL() );
-            }
-        else if ( aOperation == EUPnPAVStop && aError == KErrNone )
-            {
-            // succesful stop - go IDLE
-            iState = EIdle;
-            }
-        // error handling
-        if ( aError != KErrNone )
-            {
-            SendRenderAck( aError );
-            }
-        }
-    else if ( iState == EShuttingDown )
-        {
-        if ( aOperation == EUPnPAVStop || aOperation == EUPnPAVPlay )
-            {
-            iState = EIdle;
-            }
-        }
-
-    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::InteractOperationComplete end " );
-    }
-
-
-
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::MediaRendererDisappeared
-// Notifies that the Media Renderer we have a session with has disappeared.
-// Session is now unusable and must be closed. 
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::MediaRendererDisappeared(
-    TUPnPDeviceDisconnectedReason aReason )
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
-MediaRendererDisappeared in state %d", iState );
-
-    if( iState == EShuttingDown )
-        {
-        __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
-        MediaRendererDisappeared engine already shutting down, do nothing" );
-        }
-    else
-        {
-        if( aReason == MUPnPAVSessionObserverBase::EWLANLost )
-            {
-            iWlanActive = EFalse;
-            }
-        iState = EShuttingDown; // avoid all callbacks
-        iObserver.EngineShutdown( KErrDisconnected );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::RunError
-// Exception occurred in the timer body
-// --------------------------------------------------------------------------
-//
-TInt CUpnpImageRenderingEngine::RunError( TInt aError )
-    {
-    __LOG2( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
-RunError in state %d aError %d", iState, aError );
-    Cleanup();
-    SendRenderAck( aError );
-    return KErrNone;
-    }
-
-
-
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::SendRenderAck
-// Exception occurred in the timer body
-// --------------------------------------------------------------------------
-//
-void CUpnpImageRenderingEngine::SendRenderAck( TInt aError )
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
-SendRenderAck(%d)", aError );
-
-    // take a stack copy of some members
-    MUpnpImageRenderingEngineObserver& observer = iObserver;
-    const CUpnpItem* item = NULL;
-    if ( iCurrentResolver  && 
-        !( iState == EIdle || iState == EResolvingItem ) )
-        {
-        item = &iCurrentResolver->Item();
-        }
-
-    // cleanup if this was an error
-    if ( aError != KErrNone )
-        {
-        __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
-SendRenderAck aError=%d -> Cleanup", aError );
-        Cleanup();
-        }
-
-    // call the observer
-    TInt resp = observer.RenderAck( aError, item );
-
-    // in case of disconnected error, do engine shutdown
-    if ( resp == KErrDisconnected )
-        {
-        __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
-SendRenderAck resp=%d -> EngineShutdown", resp );
-        iState = EShuttingDown;
-        observer.EngineShutdown( resp );
-        }
-
-    }
-    
-    
-// --------------------------------------------------------------------------
-// CUpnpImageRenderingEngine::IsWlanActive
-// If connection to renderer is lost, checks if wlan is still active
-// --------------------------------------------------------------------------
-//
-TBool CUpnpImageRenderingEngine::IsWlanActive()
-    {        
-    return iWlanActive;
-    }
-    
-// End of File
+/*
+* Copyright (c) 2007 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:  Engine for rendering images remotely
+*
+*/
+
+
+// INCLUDE FILES
+// upnp stack api
+#include <upnpitem.h>                   // CUpnpItem
+#include <upnpobject.h>                 // CUpnpObject (cast)
+
+// upnpframework / avcontroller api
+#include "upnpavrenderingsession.h"     // MUPnPAVRenderingSession
+#include "upnpavsessionobserverbase.h" 
+
+// upnpframework / avcontroller helper api
+#include "upnpconstantdefs.h"           // KFilterCommon
+#include "upnpitemresolver.h"           // MUPnPItemResolver
+#include "upnpitemresolverobserver.h"   // MUPnPItemResolverObserver
+#include "upnpitemresolverfactory.h"    // UPnPItemResolverFactory
+#include "upnpitemutility.h"            // UPnPItemUtility::BelongsToClass
+
+// upnpframework / commonui
+#include "upnpcommonui.h"               // common UI for upnp video player dlg
+#include "upnprenderingstatemachine.h"  // rendering state machine
+
+// command internal
+#include "upnpimagerenderingengineobserver.h"   // the observer interface
+#include "upnpimagerenderingengine.h"   // self
+#include "upnpperiodic.h"
+
+_LIT( KComponentLogfile, "upnpcommand.log");
+#include "upnplog.h"
+
+// CONSTANT DEFINITIONS
+const TInt KReactionTimerMicrosec = 100000; // 100 millisec.
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::NewL
+// --------------------------------------------------------------------------
+//
+CUpnpImageRenderingEngine* CUpnpImageRenderingEngine::NewL(
+            MUPnPAVController& aAVController,
+            MUPnPAVRenderingSession& aSession,
+            MUpnpImageRenderingEngineObserver& aObserver )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::NewL" );
+
+    // Create instance
+    CUpnpImageRenderingEngine* self = NULL;
+    self = new (ELeave) CUpnpImageRenderingEngine(
+            aAVController, aSession, aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL( );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::CUpnpImageRenderingEngine
+// --------------------------------------------------------------------------
+//
+CUpnpImageRenderingEngine::CUpnpImageRenderingEngine(
+            MUPnPAVController& aAVController,
+            MUPnPAVRenderingSession& aSession,
+            MUpnpImageRenderingEngineObserver& aObserver )
+    : iAVController( aAVController )
+    , iRenderingSession( aSession )
+    , iObserver( aObserver )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine: Constructor" );
+
+    // Initialise member variables
+    iState = EIdle;
+    iCurrentResolver = 0;
+    iBufferedResolver = 0;
+    iRenderingStateMachine = NULL;
+    iWlanActive = ETrue;
+    // set observer
+    iRenderingSession.SetObserver( *this );
+    }
+
+// --------------------------------------------------------------------------
+// Second phase constructor.
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::ConstructL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::ConstructL" );
+    iTimer = CUPnPPeriodic::NewL( CActive::EPriorityStandard );
+    iRenderingStateMachine = 
+                  CUpnpRenderingStateMachine::NewL( iRenderingSession );
+    iRenderingStateMachine->SetObserver( *this );
+    iRenderingStateMachine->SyncL();
+    }
+    
+// --------------------------------------------------------------------------
+// Destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpImageRenderingEngine::~CUpnpImageRenderingEngine()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine:\
+        Destructor" );
+    Cleanup();
+    
+    // Stop observing the rendering session
+    iRenderingSession.RemoveObserver();
+
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+~CUpnpImageRenderingEngine delete iCurrentResolver" );
+    MUPnPItemResolver* tempCurrentResolver = iCurrentResolver;
+    iCurrentResolver = NULL;
+    delete tempCurrentResolver;
+    
+    if ( iRenderingStateMachine )
+        {
+        iRenderingStateMachine->RemoveObserver();
+        delete iRenderingStateMachine;
+        iRenderingStateMachine = NULL;
+        }
+
+    if( iTimer )
+        {    
+        iTimer->Cancel();
+        delete iTimer;
+        iTimer = 0;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::Cleanup
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::Cleanup()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::Cleanup" );
+
+    // reset state
+    if ( iState != EShuttingDown )
+        {
+        iState = EIdle;
+        }
+
+    if( iTimer )
+        {    
+        iTimer->Cancel();
+        }
+
+    iBufferingNewImage = EFalse;
+    // Delete resolvers
+    // Delete for resolvers is done using temporary variables so that we can
+    // first nullify the members and then delete the actual objects.
+    // This is because local resolver deletion uses active scheduler loops
+    // and therefore other asynchronous events may orrur. So we may end
+    // up here in Cleanup again, during the resolver is being deleted.
+    // if deletion is done the conventional way, the objects get deleted
+    // twice, which is not what we want. :-)
+    
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+Cleanup delete iBufferedResolver" );
+    MUPnPItemResolver* tempBufferedResolver = iBufferedResolver;
+    iBufferedResolver = NULL;
+    delete tempBufferedResolver;
+
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::Cleanup end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::PlayL
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::PlayL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::PlayL" );
+
+    if ( iState != EShuttingDown )
+        {
+        if( iTimer->IsActive() )
+            {
+            __LOG( "[UpnpCommand]\t timer already active" );
+            }
+        else
+            {
+            TTimeIntervalMicroSeconds32 delay( KReactionTimerMicrosec );
+            iTimer->Start( delay, delay, TCallBack( Timer, this ) );
+            }
+        }
+    else
+        {
+        __LOG( "[UpnpCommand]\t not doing play in shutting down state" );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::StopL
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::StopL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::StopL" );
+
+    // cancel any timers that are going on
+    iTimer->Cancel();
+
+    // remove buffered images
+    iBufferingNewImage = EFalse;
+    delete iBufferedResolver;
+    iBufferedResolver = 0;
+
+    switch( iState )
+        {
+        case EIdle:
+        case EResolvingItem:
+        case EResolveComplete:
+            {
+            // just cancel the sequence and do nothing
+            iState = EIdle;
+            break;
+            }
+        case ERendering: 
+            {
+            // Send stop action.
+            iRenderingStateMachine->CommandL( Upnp::EStop, 0, NULL );
+            break;
+            }
+        case EShuttingDown:
+            {
+            // command not allowed in this state
+            break;
+            }
+        default:
+            {
+            __PANIC( __FILE__, __LINE__ );
+            break;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::Timer
+// timer callback
+// --------------------------------------------------------------------------
+//
+TInt CUpnpImageRenderingEngine::Timer( TAny* aArg )
+    {    
+    CUpnpImageRenderingEngine* self =
+        static_cast<CUpnpImageRenderingEngine*>( aArg );
+    TRAPD( error, self->RunTimerL() )
+    if ( error != KErrNone )
+        {
+        self->RunError( error );
+        }
+    return 0; // do not call again
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::RunTimerL
+// Timer has triggered, start rendering media.
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::RunTimerL()
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::RunTimerL, state %d",
+        iState );
+        
+    iTimer->Cancel();
+
+    delete iBufferedResolver;
+    iBufferedResolver = iObserver.GetMedia();
+    if ( iBufferedResolver == 0 )
+        {
+        __LOG( "[UpnpCommand]\t resolver returned zero" );
+        User::Leave( KErrCancel );
+        }
+
+    switch( iState )
+        {
+        case EIdle: 
+            {
+            StartResolvingL();
+            break;
+            }
+        case EResolvingItem: // fall through
+        case EResolveComplete: // fall through
+            {
+            // indicate that new image is being buffered. It will be popped
+            // from buffer in next callback.
+            iBufferingNewImage = ETrue;
+            break;
+            }
+        case ERendering:
+            {
+            // indicate that new image is being buffered. Send stop signal.
+            // new item will be handled after stop completed.
+            if( !iBufferingNewImage )
+                {
+                iBufferingNewImage = ETrue;
+                iRenderingStateMachine->CommandL( Upnp::EStop, 0, NULL );
+                }
+            else
+                {
+                // stop already sent, wait for response and do nothing
+                __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::RunTimerL,\
+wait for stop" );
+                }
+            break;
+            }
+        case EShuttingDown:
+            {
+            // command not allowed in this state
+            break;
+            }
+        default:
+            {
+            __PANIC( __FILE__, __LINE__ );
+            break;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::RunError
+// Exception occurred in the timer body
+// --------------------------------------------------------------------------
+//
+TInt CUpnpImageRenderingEngine::RunError( TInt aError )
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+RunError aError %d", aError );
+    Cleanup();
+    SendRenderAck( aError );
+    return KErrNone;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::StartResolvingL
+// Handles the start up of the item resolving.
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::StartResolvingL()
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::StartResolvingL\
+ in state %d",
+        iState );
+
+    __ASSERTD( iBufferedResolver, __FILE__, __LINE__ );
+    if ( !iBufferedResolver )
+        {
+        // something is very wrong
+        User::Leave( KErrDisconnected );
+        }
+    
+    // delete old resolver
+    // destruction takes time due to unsharing, so set to null first
+    // so that this wont be used else where
+    MUPnPItemResolver* tempCurrentResolver = iCurrentResolver;
+    iCurrentResolver = NULL;
+    delete tempCurrentResolver;
+    
+    // take queued resolver in use
+    iCurrentResolver = iBufferedResolver;
+    iBufferedResolver = NULL;
+    iBufferingNewImage = EFalse;
+
+    // Update the state
+    iState = EResolvingItem;
+
+    // Start resolving the item
+    iCurrentResolver->ResolveL( *this );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::ResolveComplete
+// Indicates that resolving of an item is complete.
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::ResolveComplete(
+                                    const MUPnPItemResolver& aResolver,
+                                    TInt aError )
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::ResolveComplete\
+ aError %d", aError );
+    
+    // if engine is shutting down, no need to check these
+    if ( iState == EResolvingItem )
+        {
+        __ASSERT( &aResolver == iCurrentResolver, __FILE__, __LINE__ );
+        
+        if( iBufferingNewImage )
+            {
+            TRAP( aError, StartResolvingL() );
+            }
+        else if( aError == KErrNone )
+            {
+            iState = ERendering;
+            const CUpnpItem& item = iCurrentResolver->Item();
+
+            if ( UPnPItemUtility::BelongsToClass( item, KClassImage ) )
+                {
+                __LOG1( "[UpnpCommand]\t play image item of resolver 0x%d", 
+                                                    TInt(iCurrentResolver) );
+                Cycle();
+                }
+            else if ( UPnPItemUtility::BelongsToClass( item, KClassVideo ) )
+                {
+                __LOG( "[UpnpCommand]\t video, inform observer to play it" );
+                aError = iObserver.RenderAck( KErrNotSupported, &item );
+                }
+            }
+            
+        // error handling
+        if( aError != KErrNone && iState != EShuttingDown )
+            {
+            SendRenderAck( aError );
+            }
+        }
+    else if( iState == EShuttingDown )
+        {
+        // do nothing.
+        iState = EIdle;
+        }
+    else
+        {
+        __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine: state error." );
+        __PANICD( __FILE__, __LINE__ );
+        iState = EIdle;
+        }
+
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::SetURIResult
+// UPnP AV Controller calls this method as a result for the 'set uri' request.
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::SetURIResult( TInt aError )
+    {    
+    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::SetURIResult\
+ in aError %d", aError );
+ 
+    if ( iState == ERendering )
+        {
+        if( iBufferingNewImage && aError == KErrNone)
+            {
+            __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+SetURIResult - pass cancel to rendering state machine" );
+            iRenderingStateMachine->SetURIResult( KErrCancel );
+            }
+        else if( aError == KErrNone )
+            {
+            __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+SetURIResult - pass uri result to rendering state machine" );
+            iRenderingStateMachine->SetURIResult( aError );
+            }
+        }
+    else if ( iState == EShuttingDown )
+        {
+        // do nothing
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::InteractOperationComplete
+// Called by UpnpAvController to indicate that play is complete.
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::InteractOperationComplete(
+    TInt aError,
+    TUPnPAVInteractOperation aOperation )
+    {
+    __LOG2( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+InteractOperationComplete aOperation %d aError %d", aOperation, aError );
+    if ( iState != EShuttingDown )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+InteractOperationComplete - pass operation to rendering state machine" );
+        iRenderingStateMachine->InteractOperationComplete( 
+            aError, aOperation );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::MediaRendererDisappeared
+// Notifies that the Media Renderer we have a session with has disappeared.
+// Session is now unusable and must be closed. 
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::MediaRendererDisappeared(
+    TUPnPDeviceDisconnectedReason aReason )
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+MediaRendererDisappeared in state %d", iState );
+
+    if( iState == EShuttingDown )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+        MediaRendererDisappeared engine already shutting down, do nothing" );
+        }
+    else
+        {
+        if( aReason == MUPnPAVSessionObserverBase::EWLANLost )
+            {
+            iWlanActive = EFalse;
+            }
+        iState = EShuttingDown; // avoid all callbacks
+        iObserver.EngineShutdown( KErrDisconnected );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::SendRenderAck
+// Exception occurred in the timer body
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::SendRenderAck( TInt aError )
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+SendRenderAck(%d)", aError );
+
+    // take a stack copy of some members
+    MUpnpImageRenderingEngineObserver& observer = iObserver;
+    const CUpnpItem* item = NULL;
+    if ( iCurrentResolver  && 
+        !( iState == EIdle || iState == EResolvingItem ) )
+        {
+        item = &iCurrentResolver->Item();
+        }
+
+    // cleanup if this was an error
+    if ( aError != KErrNone )
+        {
+        __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+SendRenderAck aError=%d -> Cleanup", aError );
+        Cleanup();
+        }
+
+    // call the observer
+    TInt resp = observer.RenderAck( aError, item );
+
+    // in case of disconnected error, do engine shutdown
+    if ( resp == KErrDisconnected )
+        {
+        __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+SendRenderAck resp=%d -> EngineShutdown", resp );
+        iState = EShuttingDown;
+        observer.EngineShutdown( resp );
+        }
+
+    }
+    
+    
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::IsWlanActive
+// If connection to renderer is lost, checks if wlan is still active
+// --------------------------------------------------------------------------
+//
+TBool CUpnpImageRenderingEngine::IsWlanActive()
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+IsWlanActive iWlanActive=%d ", iWlanActive );
+    return iWlanActive;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::Cycle
+// Cycles next item by checking resolver status. 
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::Cycle()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::Cycle" );
+    
+    TRAPD( err, iRenderingStateMachine->CommandL( 
+            Upnp::EPlay, 0, &iCurrentResolver->Item() ) );
+            
+    if ( KErrNone != err )
+        {
+        SendRenderAck( err );
+        }
+    }
+    
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::RendererSyncReady
+// Callback from rendering state machine when sync is ready.
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::RendererSyncReady( TInt aError,
+    Upnp::TState aState )
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+RendererSyncReady aError=%d ", aError );
+
+    if( aState != Upnp::EStopped )
+        {
+        // Renderer is used by another controlpoint. Cannot continue.
+        iState = EShuttingDown; // avoid all callbacks
+        iObserver.EngineShutdown( KErrInUse );
+        }
+    else if ( KErrNone != aError )
+        {
+        // notify observer if error. currently there will not
+        // any error from rendering state machine but may be
+        // in future. 
+        SendRenderAck( aError );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::RenderingStateChanged
+// Callback from rendering state machine when rendering state changes.
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::RenderingStateChanged( TInt aError, 
+    Upnp::TState aState , TBool aActionResponse, TInt /*aStateParam*/ )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+RenderingStateChanged" );
+
+    __LOG3( "[UpnpCommand]\t aError=%d aState=0x%x aActionResponse=%d",
+                                        aError, aState, aActionResponse );
+
+    if ( Upnp::EStopped == aState )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+RenderingStateChanged - image play stopped" );
+        
+        iState = EIdle;
+        
+        // new image waiting -> start resolving
+        if( iBufferingNewImage )
+            {
+            __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+RenderingStateChanged - start resolving new image");
+            TRAP( aError, StartResolvingL() );
+            }
+        }
+    else if ( Upnp::EPlaying == aState )
+        {
+        // new image waiting -> wait for stop
+        // stop has already been sent
+        if( iBufferingNewImage )
+            {
+            __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+RenderingStateChanged to play - new image -> wait for stop");
+            }
+            
+        // image playing -> inform observer  
+        else if( aActionResponse &&  KErrNone == aError )
+            {
+            __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+RenderingStateChanged - image play started ");
+            SendRenderAck( aError );
+            }
+        }    
+            
+    // Error handling       
+    if ( KErrNone != aError )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+RenderingStateChanged - Error situation" );
+        SendRenderAck( aError );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpImageRenderingEngine::RendererSyncReady
+// Callback from rendering state machine when rendering position is sync.
+// --------------------------------------------------------------------------
+//
+void CUpnpImageRenderingEngine::PositionSync( TInt /*aError*/, 
+        Upnp::TPositionMode /*aMode*/,
+        TInt /*aDuration*/,
+        TInt /*aPosition*/ )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpImageRenderingEngine::\
+PositionSync" );
+    }
+    
+// End of File
--- a/upnpframework/upnpcommand/src/upnpmovecommand.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpmovecommand.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,150 +1,151 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpCopyCommand class.
-*
-*/
-
-
-// INCLUDE FILES
-#include <upnpmovecommand.h>            // CUpnpMoveCommand
-#include "upnpcommand.h"                // CUpnpCommand
-#include "upnpcommandmain.h"            // UpnpCommandMain::LoadL
-
-// --------------------------------------------------------------------------
-// CUpnpMoveCommand::NewL
-// Creates a new UpnpCommand for file moving purposes.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpMoveCommand* CUpnpMoveCommand::NewL()
-    {
-    // Create new CUpnpMoveCommand instance
-    CUpnpMoveCommand* self = new (ELeave) CUpnpMoveCommand();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpMoveCommand::CUpnpMoveCommand
-// Constructor
-// --------------------------------------------------------------------------
-//
-CUpnpMoveCommand::CUpnpMoveCommand()
-    {
-    // No implementation
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpMoveCommand::~CUpnpMoveCommand
-// Destructor
-// --------------------------------------------------------------------------
-//
-CUpnpMoveCommand::~CUpnpMoveCommand()
-    {
-    delete iCommand;
-    iCommand = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpMoveCommand::ConstructL
-// Second phase constructor
-// --------------------------------------------------------------------------
-//
-void CUpnpMoveCommand::ConstructL()
-    {
-    iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandMove );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpMoveCommand::MoveFilesL
-// Moves the given list of files to a remote Upnp Media Server.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpMoveCommand::MoveFilesL( CDesCArrayFlat* aFiles )
-    {
-    TInt status = KErrNone;
-
-    // Check params
-    if( !aFiles ||
-        aFiles->Count() <= 0 )
-        {
-        User::Leave( KErrArgument );
-        }
-
-    // Push the filenames into the file pipe
-    for( TInt index=0; index<aFiles->Count(); index++ )
-        {
-        if( status == KErrNone )
-            {
-            TRAP( status,
-                  iCommand->PushFileL( aFiles->MdcaPoint( index ) ) );
-            }
-        }
-
-    // If all files were pushed ok
-    if( status == KErrNone )
-        {
-        // Allocate Upnp Fw only for the duration of the command execution
-        TRAP( status, iCommand->AllocateResourcesL() );
-        if( status == KErrNone )
-            {
-            // Execute the command
-            TRAP( status, iCommand->ExecuteL() );
-
-            // Move the failed files back to client file array
-            aFiles->Reset();
-            for ( TInt i=0; i<iCommand->FileCount(); ++i )
-                {
-                TRAP_IGNORE( aFiles->AppendL( iCommand->File( i ) ) );
-                }
-
-            // Release Upnp Fw
-            iCommand->ReleaseResources();
-            }
-        }
-
-    // Reset the file pipe
-    iCommand->ResetFiles();
-
-    // Reset parameters
-    iCommand->ResetParameters();
-
-    // Leave if operation failed
-    if( status != KErrNone )
-        {
-        User::Leave( status );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpMoveCommand::IsAvailableL
-// Inline implementation of the IsAvailable method.
-// --------------------------------------------------------------------------
-//
-EXPORT_C TBool CUpnpMoveCommand::IsAvailableL()
-    {
-    // create a temporary plugin instance
-    // then query command availability.
-    TBool available = EFalse;
-    TRAP_IGNORE(
-        CUpnpCommand* temp = UpnpCommandMain::LoadL( UpnpCommand::ECommandMove );
-        CleanupStack::PushL( temp );
-        available = temp->IsAvailableL();
-        CleanupStack::PopAndDestroy( temp );
-        );
-    return available;
-    }
-
-// End of File
+/*
+* Copyright (c) 2007 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:  Source file for CUpnpCopyCommand class.
+*
+*/
+
+
+// INCLUDE FILES
+#include <upnpmovecommand.h>            // CUpnpMoveCommand
+#include "upnpcommand.h"                // CUpnpCommand
+#include "upnpcommandmain.h"            // UpnpCommandMain::LoadL
+
+// --------------------------------------------------------------------------
+// CUpnpMoveCommand::NewL
+// Creates a new UpnpCommand for file moving purposes.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpMoveCommand* CUpnpMoveCommand::NewL()
+    {
+    // Create new CUpnpMoveCommand instance
+    CUpnpMoveCommand* self = new (ELeave) CUpnpMoveCommand();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpMoveCommand::CUpnpMoveCommand
+// Constructor
+// --------------------------------------------------------------------------
+//
+CUpnpMoveCommand::CUpnpMoveCommand()
+    {
+    // No implementation
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpMoveCommand::~CUpnpMoveCommand
+// Destructor
+// --------------------------------------------------------------------------
+//
+CUpnpMoveCommand::~CUpnpMoveCommand()
+    {
+    delete iCommand;
+    iCommand = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpMoveCommand::ConstructL
+// Second phase constructor
+// --------------------------------------------------------------------------
+//
+void CUpnpMoveCommand::ConstructL()
+    {
+    iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandMove );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpMoveCommand::MoveFilesL
+// Moves the given list of files to a remote Upnp Media Server.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpMoveCommand::MoveFilesL( CDesCArrayFlat* aFiles )
+    {
+    TInt status = KErrNone;
+
+    // Check params
+    if( !aFiles ||
+        aFiles->Count() <= 0 )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // Push the filenames into the file pipe
+    for( TInt index=0; index<aFiles->Count(); index++ )
+        {
+        if( status == KErrNone )
+            {
+            TRAP( status,
+                  iCommand->PushFileL( aFiles->MdcaPoint( index ) ) );
+            }
+        }
+
+    // If all files were pushed ok
+    if( status == KErrNone )
+        {
+        // Allocate Upnp Fw only for the duration of the command execution
+        TRAP( status, iCommand->AllocateResourcesL() );
+        if( status == KErrNone )
+            {
+            // Execute the command
+            TRAP( status, iCommand->ExecuteL() );
+
+            // Move the failed files back to client file array
+            aFiles->Reset();
+            for ( TInt i=0; i<iCommand->FileCount(); ++i )
+                {
+                TRAP_IGNORE( aFiles->AppendL( iCommand->File( i ) ) );
+                }
+
+            // Release Upnp Fw
+            iCommand->ReleaseResources();
+            }
+        }
+
+    // Reset the file pipe
+    iCommand->ResetFiles();
+
+    // Reset parameters
+    iCommand->ResetParameters();
+
+    // Leave if operation failed
+    if( status != KErrNone )
+        {
+        User::Leave( status );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpMoveCommand::IsAvailableL
+// Inline implementation of the IsAvailable method.
+// --------------------------------------------------------------------------
+//
+EXPORT_C TBool CUpnpMoveCommand::IsAvailableL()
+    {
+    // create a temporary plugin instance
+    // then query command availability.
+    TBool available = EFalse;
+    TRAP_IGNORE(
+        CUpnpCommand* temp = UpnpCommandMain::LoadL( 
+                                        UpnpCommand::ECommandMove );
+        CleanupStack::PushL( temp );
+        available = temp->IsAvailableL();
+        CleanupStack::PopAndDestroy( temp );
+        );
+    return available;
+    }
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpmovetask.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpmovetask.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,172 +1,172 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpMoveTask class.
-*
-*/
-
-
-// INCLUDE FILES
-// System
-#include <utf.h>                        // ConvertToUnicodeFromUtf8L
-
-// upnp stack api
-#include <upnpitem.h>                   // CUpnpItem
-#include <upnpobject.h>                 // CUpnpObject (cast)
-
-// upnp framework / avcontroller api
-#include "upnpavcontroller.h"           // MUPnPAVController
-#include "upnpavcontrollerfactory.h"    // UPnPAVControllerFactory
-#include "upnpavbrowsingsession.h"      // MUPnPAVBrowsingSession
-#include "upnpavsessionbase.h"          // ReserveLocalMSServicesCompleted()
-#include "upnpavdevice.h"               // CUpnpAVDevice
-
-// upnp framework / internal api's
-#include "upnpcommonutils.h"            // TUPnPItemType
-#include "upnpmetadatafetcher.h"        // UPnPMetadataFetcher
-#include "upnpfiletransferengine.h"     // CUpnpFileTransferEngine
-
-// upnp framework / command internal
-#include "upnpfilepipe.h"               // CUpnpFilePipe
-#include "upnpcommandparameters.h"      // CUpnpCommandParameters
-#include "upnptaskhandler.h"            // MUpnpTaskHandler
-#include "upnpnotehandler.h"            // CUpnpNoteHandler
-#include "upnpmovetask.h"
-#include "upnpcommand.h"
-#include "upnptaskresourceallocator.h"  // CUpnpTaskResourceAllocator
-
-_LIT( KComponentLogfile, "upnpcommand.log");
-#include "upnplog.h"
-
-// --------------------------------------------------------------------------
-// CUpnpMoveTask::NewL
-// Creates an instance of the implementation.
-// --------------------------------------------------------------------------
-//
-CUpnpTask* CUpnpMoveTask::NewL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpMoveTask::NewL" );
-
-    // Create instance
-    CUpnpMoveTask* self = new (ELeave) CUpnpMoveTask();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpMoveTask::CUpnpMoveTask
-// First phase construction.
-// --------------------------------------------------------------------------
-//
-CUpnpMoveTask::CUpnpMoveTask()
-    : CUpnpFileTransferBaseTask()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpMoveTask::Constructor" );
-    }
-
-// --------------------------------------------------------------------------
-// Destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpMoveTask::~CUpnpMoveTask()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpMoveTask::Destructor" );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpMoveTask::ConstructL
-// Perform the second phase of two phase construction. Reserves the Upnp Fw
-// resources (they are released when the task is destroyed).
-// --------------------------------------------------------------------------
-//
-void CUpnpMoveTask::ConstructL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpMoveTask::ConstructL" );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpMoveTask::AllocateResourcesL
-// Allocates the Upnp Fw resources.
-// --------------------------------------------------------------------------
-//
-void CUpnpMoveTask::AllocateResourcesL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpMoveTask::AllocateResourcesL" );
-
-    AllocateFileTransferResourcesL(
-        CUpnpTaskResourceAllocator::EResourceAvController |
-        CUpnpTaskResourceAllocator::EResourceSelectMoveServer );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpMoveTask::ExecuteL
-// Executes the task.
-// --------------------------------------------------------------------------
-//
-void CUpnpMoveTask::ExecuteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpMoveTask::ExecuteL" );
-
-    if( !ResourceAllocator() )
-        {
-        __LOG( "[UpnpCommand]\t CUpnpCopyTask::ExecuteL \
-resources not allocated, leave" );
-        User::Leave( KErrNotReady );
-        }
-
-    TInt transferredFiles = 0;
-        
-    TRAPD( status, ExecuteFileTransferL
-        ( ETrue, transferredFiles ) );
-    __LOG1( "[UpnpCommand]\t CUpnpMoveTask::ExecuteL done status %d", status );
-
-    // inform user
-    if( status == KErrNone )
-        {
-        HBufC* deviceString = CnvUtfConverter::ConvertToUnicodeFromUtf8L( 
-            ResourceAllocator()->SelectedDevice().FriendlyName() );
-        CleanupStack::PushL( deviceString );
-        NoteHandler()->ShowMoveInfoNoteL( 
-            transferredFiles,  *deviceString );
-        CleanupStack::PopAndDestroy( deviceString );
-        }
-    else if( status == KErrNotSupported )
-        {
-        NoteHandler()->ShowDrmNoteL();
-        }
-    else if( status == KErrDisconnected || status == KErrSessionClosed )
-        {
-        // check from if wlan is active
-        // note shown only in device disappeared cases
-        if( IsWlanActive() )
-            {
-            NoteHandler()->ShowMoveDisconnectionErrorNoteL();
-            }
-        }                   
-    else if( status != KErrCancel )
-        {
-        // some other generic error EXCEPT cancel
-        NoteHandler()->ShowMoveErrorNoteL();
-        }
-
-    // If there was an error, leave
-    if( status != KErrNone )
-        {
-        User::Leave( status );
-        }
-    }
-
-
-// End of File
+/*
+* Copyright (c) 2007 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:  Source file for CUpnpMoveTask class.
+*
+*/
+
+
+// INCLUDE FILES
+// System
+#include <utf.h>                        // ConvertToUnicodeFromUtf8L
+
+// upnp stack api
+#include <upnpitem.h>                   // CUpnpItem
+#include <upnpobject.h>                 // CUpnpObject (cast)
+
+// upnp framework / avcontroller api
+#include "upnpavcontroller.h"           // MUPnPAVController
+#include "upnpavcontrollerfactory.h"    // UPnPAVControllerFactory
+#include "upnpavbrowsingsession.h"      // MUPnPAVBrowsingSession
+#include "upnpavsessionbase.h"          // ReserveLocalMSServicesCompleted()
+#include "upnpavdevice.h"               // CUpnpAVDevice
+
+// upnp framework / internal api's
+#include "upnpcommonutils.h"            // TUPnPItemType
+#include "upnpmetadatafetcher.h"        // UPnPMetadataFetcher
+#include "upnpfiletransferengine.h"     // CUpnpFileTransferEngine
+
+// upnp framework / command internal
+#include "upnpfilepipe.h"               // CUpnpFilePipe
+#include "upnpcommandparameters.h"      // CUpnpCommandParameters
+#include "upnptaskhandler.h"            // MUpnpTaskHandler
+#include "upnpnotehandler.h"            // CUpnpNoteHandler
+#include "upnpmovetask.h"
+#include "upnpcommand.h"
+#include "upnptaskresourceallocator.h"  // CUpnpTaskResourceAllocator
+
+_LIT( KComponentLogfile, "upnpcommand.log");
+#include "upnplog.h"
+
+// --------------------------------------------------------------------------
+// CUpnpMoveTask::NewL
+// Creates an instance of the implementation.
+// --------------------------------------------------------------------------
+//
+CUpnpTask* CUpnpMoveTask::NewL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpMoveTask::NewL" );
+
+    // Create instance
+    CUpnpMoveTask* self = new (ELeave) CUpnpMoveTask();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpMoveTask::CUpnpMoveTask
+// First phase construction.
+// --------------------------------------------------------------------------
+//
+CUpnpMoveTask::CUpnpMoveTask()
+    : CUpnpFileTransferBaseTask()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpMoveTask::Constructor" );
+    }
+
+// --------------------------------------------------------------------------
+// Destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpMoveTask::~CUpnpMoveTask()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpMoveTask::Destructor" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpMoveTask::ConstructL
+// Perform the second phase of two phase construction. Reserves the Upnp Fw
+// resources (they are released when the task is destroyed).
+// --------------------------------------------------------------------------
+//
+void CUpnpMoveTask::ConstructL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpMoveTask::ConstructL" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpMoveTask::AllocateResourcesL
+// Allocates the Upnp Fw resources.
+// --------------------------------------------------------------------------
+//
+void CUpnpMoveTask::AllocateResourcesL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpMoveTask::AllocateResourcesL" );
+
+    AllocateFileTransferResourcesL(
+        CUpnpTaskResourceAllocator::EResourceAvController |
+        CUpnpTaskResourceAllocator::EResourceSelectMoveServer );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpMoveTask::ExecuteL
+// Executes the task.
+// --------------------------------------------------------------------------
+//
+void CUpnpMoveTask::ExecuteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpMoveTask::ExecuteL" );
+
+    if( !ResourceAllocator() )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpCopyTask::ExecuteL \
+resources not allocated, leave" );
+        User::Leave( KErrNotReady );
+        }
+
+    TInt transferredFiles = 0;
+        
+    TRAPD( status, ExecuteFileTransferL
+        ( ETrue, transferredFiles ) );
+    __LOG1( "[UpnpCommand]\t ExecuteL done status %d", status );
+
+    // inform user
+    if( status == KErrNone )
+        {
+        HBufC* deviceString = CnvUtfConverter::ConvertToUnicodeFromUtf8L( 
+            ResourceAllocator()->SelectedDevice().FriendlyName() );
+        CleanupStack::PushL( deviceString );
+        NoteHandler()->ShowMoveInfoNoteL( 
+            transferredFiles,  *deviceString );
+        CleanupStack::PopAndDestroy( deviceString );
+        }
+    else if( status == KErrNotSupported )
+        {
+        NoteHandler()->ShowDrmNoteL();
+        }
+    else if( status == KErrDisconnected || status == KErrSessionClosed )
+        {
+        // check from if wlan is active
+        // note shown only in device disappeared cases
+        if( IsWlanActive() )
+            {
+            NoteHandler()->ShowMoveDisconnectionErrorNoteL();
+            }
+        }                   
+    else if( status != KErrCancel )
+        {
+        // some other generic error EXCEPT cancel
+        NoteHandler()->ShowMoveErrorNoteL();
+        }
+
+    // If there was an error, leave
+    if( status != KErrNone )
+        {
+        User::Leave( status );
+        }
+    }
+
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpnotehandler.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpnotehandler.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,432 +1,462 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpNoteHandler class.
-*
-*/
-
-
-// INCLUDE FILES
-// system
-#include <bautils.h>                            // BaflUtils
-#include <eikenv.h>                             // CEikonEnv
-#include <AknWaitDialog.h>                      // CAknWaitDialog
-#include <StringLoader.h>                       // StringLoader
-#include <aknnotewrappers.h>                    // CAknErrorNote
-// upnpframework / common ui
-#include "upnpcommonui.h"                       // CUPnPCommonUI
-// command internal
-#include <upnpcommandresources.rsg>             // UpnpCommand resource file
-#include "upnpnotehandler.h"
-
-_LIT( KComponentLogfile, "upnpcommand.log");
-#include "upnplog.h"
-
-
-// CONSTANTS
-_LIT( KResFileName,     "\\resource\\upnpcommandresources.rsc" );
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::NewL
-// Creates an instance of the implementation.
-// --------------------------------------------------------------------------
-//
-CUpnpNoteHandler* CUpnpNoteHandler::NewL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::NewL" );
-
-    // Create instance
-    CUpnpNoteHandler* self = NULL;
-    self = new (ELeave) CUpnpNoteHandler();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::CUpnpNoteHandler
-// First phase construction.
-// --------------------------------------------------------------------------
-//
-CUpnpNoteHandler::CUpnpNoteHandler()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::Constructor" );
-
-    iWaitNote = NULL;
-    
-    // DRM note will be shown only once
-    iDrmNoteShown = EFalse;
-    }
-
-// --------------------------------------------------------------------------
-// Destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpNoteHandler::~CUpnpNoteHandler()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::Destructor" );
-
-    // If wait note is running, finish it
-    if( iWaitNote )
-        {
-        TRAP_IGNORE( iWaitNote->ProcessFinishedL() );
-        }
-
-    // Un-load resource file
-    if ( iResFileOffset )
-        {
-        CEikonEnv::Static()->DeleteResourceFile( iResFileOffset );
-        iResFileOffset = 0;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ConstructL
-// Perform the second phase of two phase construction. Reserves the Upnp Fw
-// resources (they are released when the task is destroyed).
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ConstructL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ConstructL" );
-
-    // Get the pointer to coe env (owned by Eikon env)
-    CEikonEnv* coeEnv = CEikonEnv::Static();
-    if( !coeEnv )
-        {
-        User::Leave( KErrNotSupported );
-        }
-
-    // Get the filesession reference from coe env
-    RFs& fileSession = coeEnv->FsSession();
-
-    // Load resource file
-    TFileName rscFileName( KResFileName );
-    TFileName dllName;
-    Dll::FileName( dllName );
-    TBuf<2> drive = dllName.Left( 2 ); // Drive letter followed by ':' 
-    rscFileName.Insert( 0, drive );
-
-    // Get the exact filename of the resource file
-    BaflUtils::NearestLanguageFile( fileSession, rscFileName );
-
-    // Check if the resource file exists or not
-    if ( !BaflUtils::FileExists( fileSession, rscFileName ) )
-        {
-        __LOG( "[UpnpCommand]\t Resource file does not exist!" );
-        User::Leave( KErrNotFound );
-        }
-
-    // Read the resource file offset
-    iResFileOffset = coeEnv->AddResourceFileL( rscFileName );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::RunConnectingWaitNote
-// Launches the "Connecting" wait note.
-// --------------------------------------------------------------------------
-//
-TInt CUpnpNoteHandler::RunConnectingWaitNote()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::\
-RunConnectingWaitNote" );
-
-    TInt status = KErrNone;
-    status = RunWaitNote( R_COMMAND_CONNECTING_WAIT_NOTE );
-    return status;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowDrmNoteL
-// Show "DRM protected files not supported." info note.
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ShowDrmNoteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowDrmNoteL" );
-
-    if( !iDrmNoteShown )
-        {
-        iDrmNoteShown = ETrue;
-        ShowErrorNoteL( R_COMMAND_DRM_FILE_TEXT );
-        }
-    else
-        {
-        __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowDrmNoteL, skipped" );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowConnectionLostNoteL
-// Show "Connection failed." info note.
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ShowConnectionLostNoteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowConnectionLostNoteL" );
-
-    ShowErrorNoteL( R_COMMAND_ERR_CON_FAILED_TEXT );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowLocalMSStartErrorNoteL
-// Show "Connection failed." info note.
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ShowLocalMSStartErrorNoteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowLocalMSStartErrorNoteL" );
-
-    // local mediaserver refuses to start.
-    // use "connection failed" - this describes the error best.
-    ShowErrorNoteL( R_COMMAND_ERR_CON_FAILED_TEXT );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowCopyInfoNoteL
-// Show "%N files copied to %U" info note.
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ShowCopyInfoNoteL( TInt aCount, 
-        const TDesC& aServerName )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowCopyInfoNoteL" );
-
-    HBufC* infoText = NULL;
-    
-    if( aCount == 1 )
-        {                               
-        infoText = StringLoader::LoadLC( 
-                R_COMMAND_INFO_COPY_EXT_ONE_TEXT,
-                aServerName );
-        }
-    else
-        {
-        infoText = StringLoader::LoadLC( 
-                R_COMMAND_INFO_COPY_EXT_MANY_TEXT,
-                aServerName,
-                aCount );
-        }
-
-    ShowInfoNoteL( *infoText );
-    
-    CleanupStack::PopAndDestroy( infoText );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowMoveInfoNoteL
-// Show "1 file moved to %U" info note.
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ShowMoveInfoNoteL( TInt aCount, 
-        const TDesC& aServerName )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowMoveInfoNoteL" );
-    // NOTE: defect in UI spec. Missing loc text. Using
-    // "N files copied" localisation instead.
-
-    HBufC* infoText = NULL;
-
-    if( aCount == 1 )
-        {                                       
-        infoText = StringLoader::LoadLC( 
-                R_COMMAND_INFO_MOVE_EXT_ONE_TEXT,
-                aServerName );
-        }
-    else
-        {
-        infoText = StringLoader::LoadLC( 
-                R_COMMAND_INFO_MOVE_EXT_MANY_TEXT,
-                aServerName,
-                aCount );
-        }
-
-    ShowInfoNoteL( *infoText );
-    
-    CleanupStack::PopAndDestroy( infoText );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowCopyErrorNoteL
-// Show "Selected device does not support this operation" error note
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ShowCopyErrorNoteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowCopyErrorNoteL" );
-  
-    ShowErrorNoteL( R_COMMAND_ERR_GENERAL_FAILURE_TEXT );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowMoveErrorNoteL
-// Show "Selected device does not support this operation" error note
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ShowMoveErrorNoteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowMoveErrorNoteL" );
-
-    ShowErrorNoteL( R_COMMAND_ERR_GENERAL_FAILURE_TEXT );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowCopyDisconnectionErrorNoteL
-// Show "Connection lost, some files may not be copied" error note
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ShowCopyDisconnectionErrorNoteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::\
-ShowCopyDisconnectionErrorNoteL" );
- 
-    ShowErrorNoteL( R_COMMAND_ERR_CONN_LOST_COPY_TEXT );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowMoveDisconnectionErrorNoteL
-// Show "Connection lost. Some files might not be moved" error note
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ShowMoveDisconnectionErrorNoteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::\
-ShowMoveDisconnectionErrorNoteL" );
-
-    ShowErrorNoteL( R_COMMAND_ERR_CONN_LOST_MOVE_TEXT);
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowPlaybackFailedNoteL
-// Show "Playback failed on the remote device for unknown error. 
-// Try again" info note.
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::ShowPlaybackFailedNoteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowPlaybackFailedNoteL" );
-    
-    ShowErrorNoteL( R_COMMAND_ERR_RENDERING_FAILED_UNKNOWN_TEXT );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::RunWaitNote
-// Launches the wait note.
-// --------------------------------------------------------------------------
-//
-TInt CUpnpNoteHandler::RunWaitNote( TInt aResource )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::RunWaitNote" );
-
-    TInt status = KErrNone;
-    
-    
-    // If the note is already showing
-    if( iWaitNote )
-        {
-        status = KErrInUse;
-        }
-    else
-        {
-        // Create the wait note
-        iWaitNote = new CAknWaitDialog(
-            ( REINTERPRET_CAST( CEikDialog**, &iWaitNote ) ), ETrue );
-        if( iWaitNote )
-            {
-            // Execute the wait note
-            TBool noteResult = EFalse;
-            TRAP( status, noteResult =
-                iWaitNote->ExecuteLD(
-                aResource ) );
-            if( !noteResult )
-                {
-                status = KErrCancel;
-                }
-
-            // Clean up
-            iWaitNote = NULL;
-            }
-        else
-            {
-            // If we failed to allocate memory for the note
-            status = KErrNoMemory;
-            }
-
-        }
-
-    return status;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::CloseWaitNote
-// Closes the "Activating sharing" wait note.
-// --------------------------------------------------------------------------
-//
-void CUpnpNoteHandler::CloseWaitNote()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::CloseWaitNote" );
-
-    // If wait note is running, finish it
-    if( iWaitNote )
-        {
-        TRAP_IGNORE( iWaitNote->ProcessFinishedL() );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowInfoNoteL
-// Show info note
-// --------------------------------------------------------------------------
-//    
-void CUpnpNoteHandler::ShowInfoNoteL( const TDesC& aText )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowInfoNoteL" );
-    
-    CAknInformationNote* infoNote = 
-        new ( ELeave ) CAknInformationNote( ETrue );
-    infoNote->ExecuteLD( aText );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ShowErrorNoteL
-// Show error note
-// --------------------------------------------------------------------------
-//    
-void CUpnpNoteHandler::ShowErrorNoteL( TInt aResource )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowInfoNoteL" );
-
-    // Load the string, and show the note
-    HBufC* errorText = StringLoader::LoadLC( aResource );
-    CAknInformationNote* errorNote = 
-        new ( ELeave ) CAknInformationNote( ETrue );
-    errorNote->ExecuteLD( *errorText );
-    CleanupStack::PopAndDestroy( errorText );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpNoteHandler::ResetDrmNoteCount
-// Drm note can shoud be shown only one in operation
-// this reset calculator so that note can be shown again
-// --------------------------------------------------------------------------
-//     
-void CUpnpNoteHandler::ResetDrmNoteCount()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ResetDrmNoteCount" );
-    iDrmNoteShown = EFalse;
-    }
-
-// End of File
+/*
+* Copyright (c) 2007 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:  Source file for CUpnpNoteHandler class.
+*
+*/
+
+
+// INCLUDE FILES
+// system
+#include <bautils.h>                            // BaflUtils
+#include <eikenv.h>                             // CEikonEnv
+#include <AknWaitDialog.h>                      // CAknWaitDialog
+#include <StringLoader.h>                       // StringLoader
+#include <aknnotewrappers.h>                    // CAknErrorNote
+// upnpframework / common ui
+#include "upnpcommonui.h"                       // CUPnPCommonUI
+// command internal
+#include <upnpcommandresources.rsg>             // UpnpCommand resource file
+#include "upnpnotehandler.h"
+
+_LIT( KComponentLogfile, "upnpcommand.log");
+#include "upnplog.h"
+
+
+// CONSTANTS
+_LIT( KResFileName,     "\\resource\\upnpcommandresources.rsc" );
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::NewL
+// Creates an instance of the implementation.
+// --------------------------------------------------------------------------
+//
+CUpnpNoteHandler* CUpnpNoteHandler::NewL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::NewL" );
+
+    // Create instance
+    CUpnpNoteHandler* self = NULL;
+    self = new (ELeave) CUpnpNoteHandler();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::CUpnpNoteHandler
+// First phase construction.
+// --------------------------------------------------------------------------
+//
+CUpnpNoteHandler::CUpnpNoteHandler()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::Constructor" );
+
+    iWaitNote = NULL;
+    
+    // DRM note will be shown only once
+    iDrmNoteShown = EFalse;
+    }
+
+// --------------------------------------------------------------------------
+// Destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpNoteHandler::~CUpnpNoteHandler()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::Destructor" );
+
+    // If wait note is running, finish it
+    if( iWaitNote )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpNoteHandler::Destructor\
+        iWaitNote->ProcessFinishedL " );
+        TRAP_IGNORE( iWaitNote->ProcessFinishedL() );
+        }
+
+    // Un-load resource file
+    if ( iResFileOffset )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpNoteHandler::Destructor\
+        Un-load resource file " );
+        CEikonEnv::Static()->DeleteResourceFile( iResFileOffset );
+        iResFileOffset = 0;
+        }
+        
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::Destructor - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ConstructL
+// Perform the second phase of two phase construction. Reserves the Upnp Fw
+// resources (they are released when the task is destroyed).
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ConstructL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ConstructL" );
+
+    // Get the pointer to coe env (owned by Eikon env)
+    CEikonEnv* coeEnv = CEikonEnv::Static();
+    if( !coeEnv )
+        {
+        User::Leave( KErrNotSupported );
+        }
+
+    // Get the filesession reference from coe env
+    RFs& fileSession = coeEnv->FsSession();
+
+    // Load resource file
+    TFileName rscFileName( KResFileName );
+    TFileName dllName;
+    Dll::FileName( dllName );
+    TBuf<2> drive = dllName.Left( 2 ); // Drive letter followed by ':' 
+    rscFileName.Insert( 0, drive );
+
+    // Get the exact filename of the resource file
+    BaflUtils::NearestLanguageFile( fileSession, rscFileName );
+
+    // Check if the resource file exists or not
+    if ( !BaflUtils::FileExists( fileSession, rscFileName ) )
+        {
+        __LOG( "[UpnpCommand]\t Resource file does not exist!" );
+        User::Leave( KErrNotFound );
+        }
+
+    // Read the resource file offset
+    iResFileOffset = coeEnv->AddResourceFileL( rscFileName );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::RunConnectingWaitNote
+// Launches the "Connecting" wait note.
+// --------------------------------------------------------------------------
+//
+TInt CUpnpNoteHandler::RunConnectingWaitNote()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::\
+RunConnectingWaitNote" );
+
+    TInt status = KErrNone;
+    status = RunWaitNote( R_COMMAND_CONNECTING_WAIT_NOTE );
+    return status;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowDrmNoteL
+// Show "DRM protected files not supported." info note.
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowDrmNoteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowDrmNoteL" );
+
+    if( !iDrmNoteShown )
+        {
+        iDrmNoteShown = ETrue;
+        ShowErrorNoteL( R_COMMAND_DRM_FILE_TEXT );
+        }
+    else
+        {
+        __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowDrmNoteL, skipped" );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowConnectionLostNoteL
+// Show "Connection failed." info note.
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowConnectionLostNoteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowConnectionLostNoteL" );
+
+    ShowErrorNoteL( R_COMMAND_ERR_CON_FAILED_TEXT );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowLocalMSStartErrorNoteL
+// Show "Connection failed." info note.
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowLocalMSStartErrorNoteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowLocalMSStartErrorNoteL" );
+
+    // local mediaserver refuses to start.
+    // use "connection failed" - this describes the error best.
+    ShowErrorNoteL( R_COMMAND_ERR_CON_FAILED_TEXT );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowCopyInfoNoteL
+// Show "%N files copied to %U" info note.
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowCopyInfoNoteL( TInt aCount, 
+        const TDesC& aServerName )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowCopyInfoNoteL" );
+
+    HBufC* infoText = NULL;
+    
+    if( aCount == 1 )
+        {                               
+        infoText = StringLoader::LoadLC( 
+                R_COMMAND_INFO_COPY_EXT_ONE_TEXT,
+                aServerName );
+        }
+    else
+        {
+        infoText = StringLoader::LoadLC( 
+                R_COMMAND_INFO_COPY_EXT_MANY_TEXT,
+                aServerName,
+                aCount );
+        }
+
+    ShowInfoNoteL( *infoText );
+    
+    CleanupStack::PopAndDestroy( infoText );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowMoveInfoNoteL
+// Show "1 file moved to %U" info note.
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowMoveInfoNoteL( TInt aCount, 
+        const TDesC& aServerName )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowMoveInfoNoteL" );
+    // NOTE: defect in UI spec. Missing loc text. Using
+    // "N files copied" localisation instead.
+
+    HBufC* infoText = NULL;
+
+    if( aCount == 1 )
+        {                                       
+        infoText = StringLoader::LoadLC( 
+                R_COMMAND_INFO_MOVE_EXT_ONE_TEXT,
+                aServerName );
+        }
+    else
+        {
+        infoText = StringLoader::LoadLC( 
+                R_COMMAND_INFO_MOVE_EXT_MANY_TEXT,
+                aServerName,
+                aCount );
+        }
+
+    ShowInfoNoteL( *infoText );
+    
+    CleanupStack::PopAndDestroy( infoText );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowCopyErrorNoteL
+// Show "Selected device does not support this operation" error note
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowCopyErrorNoteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowCopyErrorNoteL" );
+  
+    ShowErrorNoteL( R_COMMAND_ERR_GENERAL_FAILURE_TEXT );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowMoveErrorNoteL
+// Show "Selected device does not support this operation" error note
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowMoveErrorNoteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowMoveErrorNoteL" );
+
+    ShowErrorNoteL( R_COMMAND_ERR_GENERAL_FAILURE_TEXT );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowCopyDisconnectionErrorNoteL
+// Show "Connection lost, some files may not be copied" error note
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowCopyDisconnectionErrorNoteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::\
+ShowCopyDisconnectionErrorNoteL" );
+ 
+    ShowErrorNoteL( R_COMMAND_ERR_CONN_LOST_COPY_TEXT );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowMoveDisconnectionErrorNoteL
+// Show "Connection lost. Some files might not be moved" error note
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowMoveDisconnectionErrorNoteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::\
+ShowMoveDisconnectionErrorNoteL" );
+
+    ShowErrorNoteL( R_COMMAND_ERR_CONN_LOST_MOVE_TEXT);
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowPlaybackFailedNoteL
+// Show "Playback failed on the remote device for unknown error. 
+// Try again" info note.
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowPlaybackFailedNoteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowPlaybackFailedNoteL" );
+    
+    ShowErrorNoteL( R_COMMAND_ERR_RENDERING_FAILED_UNKNOWN_TEXT );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowRendererInUseNoteL
+// Show "%U is already in use. Please try again later." - note.
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::ShowRendererInUseNoteL( const TDesC& aDeviceName )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowRendererInUseNoteL" );
+
+    // Load note text
+    HBufC* textFormat = StringLoader::LoadLC( 
+                                      R_COMMAND_RENDERER_IN_USE_TEXT );
+    HBufC* noteText = HBufC::NewLC( textFormat->Length() 
+                                  + aDeviceName.Length() );
+    noteText->Des().Format( textFormat->Des() , &aDeviceName );
+    // Create and launch the error note
+    CAknErrorNote* errorNote = new( ELeave ) CAknErrorNote;
+    errorNote->ExecuteLD( *noteText );
+    CleanupStack::PopAndDestroy( noteText );
+    CleanupStack::PopAndDestroy( textFormat );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::RunWaitNote
+// Launches the wait note.
+// --------------------------------------------------------------------------
+//
+TInt CUpnpNoteHandler::RunWaitNote( TInt aResource )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::RunWaitNote" );
+
+    TInt status = KErrNone;
+    
+    
+    // If the note is already showing
+    if( iWaitNote )
+        {
+        status = KErrInUse;
+        }
+    else
+        {
+        // Create the wait note
+        iWaitNote = new CAknWaitDialog(
+            ( REINTERPRET_CAST( CEikDialog**, &iWaitNote ) ), ETrue );
+        if( iWaitNote )
+            {
+            // Execute the wait note
+            TBool noteResult = EFalse;
+            TRAP( status, noteResult =
+                iWaitNote->ExecuteLD(
+                aResource ) );
+            if( !noteResult )
+                {
+                status = KErrCancel;
+                }
+
+            // Clean up
+            iWaitNote = NULL;
+            }
+        else
+            {
+            // If we failed to allocate memory for the note
+            status = KErrNoMemory;
+            }
+
+        }
+
+    return status;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::CloseWaitNote
+// Closes the "Activating sharing" wait note.
+// --------------------------------------------------------------------------
+//
+void CUpnpNoteHandler::CloseWaitNote()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::CloseWaitNote" );
+
+    // If wait note is running, finish it
+    if( iWaitNote )
+        {
+        TRAP_IGNORE( iWaitNote->ProcessFinishedL() );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowInfoNoteL
+// Show info note
+// --------------------------------------------------------------------------
+//    
+void CUpnpNoteHandler::ShowInfoNoteL( const TDesC& aText )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowInfoNoteL" );
+    
+    CAknInformationNote* infoNote = 
+        new ( ELeave ) CAknInformationNote( ETrue );
+    infoNote->ExecuteLD( aText );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ShowErrorNoteL
+// Show error note
+// --------------------------------------------------------------------------
+//    
+void CUpnpNoteHandler::ShowErrorNoteL( TInt aResource )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ShowInfoNoteL" );
+
+    // Load the string, and show the note
+    HBufC* errorText = StringLoader::LoadLC( aResource );
+    CAknInformationNote* errorNote = 
+        new ( ELeave ) CAknInformationNote( ETrue );
+    errorNote->ExecuteLD( *errorText );
+    CleanupStack::PopAndDestroy( errorText );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpNoteHandler::ResetDrmNoteCount
+// Drm note can shoud be shown only one in operation
+// this reset calculator so that note can be shown again
+// --------------------------------------------------------------------------
+//     
+void CUpnpNoteHandler::ResetDrmNoteCount()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpNoteHandler::ResetDrmNoteCount" );
+    iDrmNoteShown = EFalse;
+    }
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnprunsetupcommand.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnprunsetupcommand.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,113 +1,114 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpRunSetupCommand class.
-*
-*/
-
-
-// INCLUDE FILES
-#include <upnprunsetupcommand.h>        // CUpnpRunSetupCommand
-#include "upnpcommand.h"                // CUpnpCommand
-#include "upnpcommandmain.h"            // UpnpCommandMain::LoadL
-
-// --------------------------------------------------------------------------
-// CUpnpRunSetupCommand::NewL
-// Creates a new UpnpCommand for running the Upnp Fw's setup wizard.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpRunSetupCommand* CUpnpRunSetupCommand::NewL()
-    {
-    // Create new CUpnpRunSetupCommand instance
-    CUpnpRunSetupCommand* self = new (ELeave) CUpnpRunSetupCommand();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpRunSetupCommand::CUpnpRunSetupCommand
-// Constructor
-// --------------------------------------------------------------------------
-//
-CUpnpRunSetupCommand::CUpnpRunSetupCommand()
-    {
-    // No implementation
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpRunSetupCommand::~CUpnpRunSetupCommand
-// Destructor
-// --------------------------------------------------------------------------
-//
-CUpnpRunSetupCommand::~CUpnpRunSetupCommand()
-    {
-    delete iCommand;
-    iCommand = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpRunSetupCommand::ConstructL
-// Second phase constructor
-// --------------------------------------------------------------------------
-//
-void CUpnpRunSetupCommand::ConstructL()
-    {
-    iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandSetup );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpRunSetupCommand::BrowseHomeNetworkL
-// Allocates Upnp Framework resources, and starts up the Upnp Fw's setup
-// wizard.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpRunSetupCommand::RunSetupL()
-    {
-    // Allocate Upnp Framework resources
-    iCommand->AllocateResourcesL();
-
-    // Execute the command
-    TRAPD( executeError, iCommand->ExecuteL() );
-
-    // Release Upnp Framework resources
-    iCommand->ReleaseResources(); 
-
-    // Leave if operation failed
-    if( executeError != KErrNone )
-        {
-        User::Leave( executeError );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpRunSetupCommand::IsAvailableL
-// Returns the availability information of the command.
-// --------------------------------------------------------------------------
-//
-EXPORT_C TBool CUpnpRunSetupCommand::IsAvailableL()
-    {
-    // create a temporary plugin instance
-    // then query command availability.
-    TBool available = EFalse;
-    TRAP_IGNORE(
-        CUpnpCommand* temp = UpnpCommandMain::LoadL( UpnpCommand::ECommandSetup );
-        CleanupStack::PushL( temp );
-        available = temp->IsAvailableL();
-        CleanupStack::PopAndDestroy( temp );
-        );
-    return available;
-    }
-
-// End of File
+/*
+* Copyright (c) 2007 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:  Source file for CUpnpRunSetupCommand class.
+*
+*/
+
+
+// INCLUDE FILES
+#include <upnprunsetupcommand.h>        // CUpnpRunSetupCommand
+#include "upnpcommand.h"                // CUpnpCommand
+#include "upnpcommandmain.h"            // UpnpCommandMain::LoadL
+
+// --------------------------------------------------------------------------
+// CUpnpRunSetupCommand::NewL
+// Creates a new UpnpCommand for running the Upnp Fw's setup wizard.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpRunSetupCommand* CUpnpRunSetupCommand::NewL()
+    {
+    // Create new CUpnpRunSetupCommand instance
+    CUpnpRunSetupCommand* self = new (ELeave) CUpnpRunSetupCommand();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpRunSetupCommand::CUpnpRunSetupCommand
+// Constructor
+// --------------------------------------------------------------------------
+//
+CUpnpRunSetupCommand::CUpnpRunSetupCommand()
+    {
+    // No implementation
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpRunSetupCommand::~CUpnpRunSetupCommand
+// Destructor
+// --------------------------------------------------------------------------
+//
+CUpnpRunSetupCommand::~CUpnpRunSetupCommand()
+    {
+    delete iCommand;
+    iCommand = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpRunSetupCommand::ConstructL
+// Second phase constructor
+// --------------------------------------------------------------------------
+//
+void CUpnpRunSetupCommand::ConstructL()
+    {
+    iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandSetup );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpRunSetupCommand::BrowseHomeNetworkL
+// Allocates Upnp Framework resources, and starts up the Upnp Fw's setup
+// wizard.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpRunSetupCommand::RunSetupL()
+    {
+    // Allocate Upnp Framework resources
+    iCommand->AllocateResourcesL();
+
+    // Execute the command
+    TRAPD( executeError, iCommand->ExecuteL() );
+
+    // Release Upnp Framework resources
+    iCommand->ReleaseResources(); 
+
+    // Leave if operation failed
+    if( executeError != KErrNone )
+        {
+        User::Leave( executeError );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpRunSetupCommand::IsAvailableL
+// Returns the availability information of the command.
+// --------------------------------------------------------------------------
+//
+EXPORT_C TBool CUpnpRunSetupCommand::IsAvailableL()
+    {
+    // create a temporary plugin instance
+    // then query command availability.
+    TBool available = EFalse;
+    TRAP_IGNORE(
+        CUpnpCommand* temp = UpnpCommandMain::LoadL( 
+                                        UpnpCommand::ECommandSetup );
+        CleanupStack::PushL( temp );
+        available = temp->IsAvailableL();
+        CleanupStack::PopAndDestroy( temp );
+        );
+    return available;
+    }
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpshowcommand.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpshowcommand.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,193 +1,199 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpShowCommand class.
-*
-*/
-
-
-// INCLUDE FILES
-#include <upnpshowcommand.h>            // CUpnpShowCommand
-#include <upnpcommandobserver.h>        // CUpnpCommandObserver
-#include "upnpcommand.h"                // CUpnpCommand
-#include "upnpcommandmain.h"            // UpnpCommandMain::LoadL
-#include "upnpcommandcallbackadapter.h" // CUpnpCommandCallbackAdapter
-
-// --------------------------------------------------------------------------
-// CUpnpShowCommand::NewL
-// Creates a new UpnpCommand for image and video showing purposes.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpShowCommand* CUpnpShowCommand::NewL()
-    {
-    // Create new CUpnpShowCommand instance
-    CUpnpShowCommand* self = new (ELeave) CUpnpShowCommand( NULL );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowCommand::NewL
-// Creates a new UpnpCommand for image and video showing purposes.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpShowCommand* CUpnpShowCommand::NewL(
-                                        MUpnpCommandObserver* aObserver )
-    {
-    // Check the availability
-    if( !IsAvailableL() )
-        {
-        User::Leave( KErrNotReady );
-        }
-
-    // Create new CUpnpShowCommand instance
-    CUpnpShowCommand* self = new (ELeave) CUpnpShowCommand( aObserver );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowCommand::CUpnpShowCommand
-// Constructor
-// --------------------------------------------------------------------------
-//
-CUpnpShowCommand::CUpnpShowCommand( MUpnpCommandObserver* aObserver)
-    {
-    iObserver = NULL;
-    if( aObserver )
-        {
-        iObserver = aObserver;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowCommand::~CUpnpShowCommand
-// Destructor
-// --------------------------------------------------------------------------
-//
-CUpnpShowCommand::~CUpnpShowCommand()
-    {
-    delete iCommand;
-    iCommand = NULL;
-    delete iAdapter;
-    iAdapter = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowCommand::ConstructL
-// Second phase constructor
-// --------------------------------------------------------------------------
-//
-void CUpnpShowCommand::ConstructL()
-    {
-    iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandShow );
-
-    // Register to observer
-    if( iObserver )
-        {
-        iAdapter = new (ELeave) CUpnpCommandCallbackAdapter( iObserver );
-        iCommand->SetObserver( iAdapter );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowCommand::StartShowingL
-// Starts showing. Allocates Upnp Framework resources.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpShowCommand::StartShowingL()
-    {
-    // Allocate Upnp Fw resources
-    iCommand->AllocateResourcesL();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowCommand::StopShowingL
-// Stops showing. Releases all Upnp Framework resources.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpShowCommand::StopShowingL()
-    {
-    // Release Upnp Fw resources
-    iCommand->ReleaseResources();
-
-    // Reset the file pipe
-    iCommand->ResetFiles(); 
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowCommand::ShowImageL
-// Shows the given images on a remote Upnp Media Rendering device.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpShowCommand::ShowImageL( const TDesC& aFilename )
-    {
-    // Check param
-    if( aFilename == KNullDesC )
-        {
-        User::Leave( KErrArgument );
-        }
-
-
-    // Push the filename into the parameter pipe
-    iCommand->PushFileL( aFilename ); 
-
-    // Execute the command
-    iCommand->ExecuteL();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowCommand::ShowVideoL
-// Shows the given video on a remote Upnp Media Rendering device.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpShowCommand::ShowVideoL( const TDesC& aFilename )
-    {
-    // Check param
-    if( aFilename == KNullDesC )
-        {
-        User::Leave( KErrArgument );
-        }
-
-
-    // Push the filename into the file pipe
-    iCommand->PushFileL( aFilename ); 
-
-    // Execute the command
-    iCommand->ExecuteL(); 
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowCommand::IsAvailableL
-// Returns the availability information of the command.
-// --------------------------------------------------------------------------
-//
-EXPORT_C TBool CUpnpShowCommand::IsAvailableL()
-    {
-    // create a temporary plugin instance
-    // then query command availability.
-    TBool available = EFalse;
-    TRAP_IGNORE(
-        CUpnpCommand* temp = UpnpCommandMain::LoadL( UpnpCommand::ECommandShow );
-        CleanupStack::PushL( temp );
-        available = temp->IsAvailableL();
-        CleanupStack::PopAndDestroy( temp );
-        );
-    return available;
-    }
-
-// End of File
+/*
+* Copyright (c) 2007 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:  Source file for CUpnpShowCommand class.
+*
+*/
+
+
+// INCLUDE FILES
+#include <upnpshowcommand.h>            // CUpnpShowCommand
+#include <upnpcommandobserver.h>        // CUpnpCommandObserver
+#include "upnpcommand.h"                // CUpnpCommand
+#include "upnpcommandmain.h"            // UpnpCommandMain::LoadL
+#include "upnpcommandcallbackadapter.h" // CUpnpCommandCallbackAdapter
+
+// --------------------------------------------------------------------------
+// CUpnpShowCommand::NewL
+// Creates a new UpnpCommand for image and video showing purposes.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpShowCommand* CUpnpShowCommand::NewL()
+    {
+    // Create new CUpnpShowCommand instance
+    CUpnpShowCommand* self = new (ELeave) CUpnpShowCommand( NULL );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowCommand::NewL
+// Creates a new UpnpCommand for image and video showing purposes.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpShowCommand* CUpnpShowCommand::NewL(
+                                        MUpnpCommandObserver* aObserver )
+    {
+    // Check the availability
+    if( !IsAvailableL() )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    // Create new CUpnpShowCommand instance
+    CUpnpShowCommand* self = new (ELeave) CUpnpShowCommand( aObserver );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowCommand::CUpnpShowCommand
+// Constructor
+// --------------------------------------------------------------------------
+//
+CUpnpShowCommand::CUpnpShowCommand( MUpnpCommandObserver* aObserver)
+    {
+    iObserver = NULL;
+    if( aObserver )
+        {
+        iObserver = aObserver;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowCommand::~CUpnpShowCommand
+// Destructor
+// --------------------------------------------------------------------------
+//
+CUpnpShowCommand::~CUpnpShowCommand()
+    {
+    delete iCommand;
+    iCommand = NULL;
+    delete iAdapter;
+    iAdapter = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowCommand::ConstructL
+// Second phase constructor
+// --------------------------------------------------------------------------
+//
+void CUpnpShowCommand::ConstructL()
+    {
+
+    iCommand = UpnpCommandMain::LoadL( UpnpCommand::ECommandShow );
+
+    // Register to observer
+    if( iObserver )
+        {
+        iAdapter = new (ELeave) CUpnpCommandCallbackAdapter( iObserver );
+        iCommand->SetObserver( iAdapter );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowCommand::StartShowingL
+// Starts showing. Allocates Upnp Framework resources.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpShowCommand::StartShowingL()
+    {
+
+    // Allocate Upnp Fw resources
+    iCommand->AllocateResourcesL();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowCommand::StopShowingL
+// Stops showing. Releases all Upnp Framework resources.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpShowCommand::StopShowingL()
+    {
+    
+    // Release Upnp Fw resources
+    iCommand->ReleaseResources();
+
+    // Reset the file pipe
+    iCommand->ResetFiles(); 
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowCommand::ShowImageL
+// Shows the given images on a remote Upnp Media Rendering device.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpShowCommand::ShowImageL( const TDesC& aFilename )
+    {
+    
+    // Check param
+    if( aFilename == KNullDesC )
+        {
+        User::Leave( KErrArgument );
+        }
+
+
+    // Push the filename into the parameter pipe
+    iCommand->PushFileL( aFilename ); 
+
+    // Execute the command
+    iCommand->ExecuteL();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowCommand::ShowVideoL
+// Shows the given video on a remote Upnp Media Rendering device.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpShowCommand::ShowVideoL( const TDesC& aFilename )
+    {
+    
+    // Check param
+    if( aFilename == KNullDesC )
+        {
+        User::Leave( KErrArgument );
+        }
+
+
+    // Push the filename into the file pipe
+    iCommand->PushFileL( aFilename ); 
+
+    // Execute the command
+    iCommand->ExecuteL(); 
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowCommand::IsAvailableL
+// Returns the availability information of the command.
+// --------------------------------------------------------------------------
+//
+EXPORT_C TBool CUpnpShowCommand::IsAvailableL()
+    {
+    // create a temporary plugin instance
+    // then query command availability.
+    TBool available = EFalse;
+    TRAP_IGNORE(
+        CUpnpCommand* temp = UpnpCommandMain::LoadL( 
+                                        UpnpCommand::ECommandShow );
+        CleanupStack::PushL( temp );
+        available = temp->IsAvailableL();
+        CleanupStack::PopAndDestroy( temp );
+        );
+    return available;
+    }
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnpshowtask.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnpshowtask.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,381 +1,394 @@
-/*
-* Copyright (c) 2007 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:  Source file for CUpnpShowTask class.
-*
-*/
-
-
-// INCLUDE FILES
-// upnp stack api
-#include <upnpitem.h>                   // CUpnpItem
-#include <upnpobject.h>                 // CUpnpObject (cast)
-
-// upnpframework / avcontroller api
-#include "upnpavcontroller.h"           // MUPnPAVController
-#include "upnpavrenderingsession.h"     // MUPnPAVRenderingSession
-#include "upnpavsessionobserverbase.h"
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h"           // KFilterCommon, KClassVideo
-#include "upnpitemresolver.h"           // MUPnPItemResolver
-#include "upnpitemresolverobserver.h"   // MUPnPItemResolverObserver
-#include "upnpitemresolverfactory.h"    // UPnPItemResolverFactory
-#include "upnpitemutility.h"            // UPnPItemUtility::BelongsToClass
-
-// upnpframework / commonui
-#include "upnpcommonui.h"
-
-// command internal
-#include "upnpfilepipe.h"               // CUpnpFilePipe
-#include "upnptaskhandler.h"            // MUpnpTaskHandler
-#include "upnptaskresourceallocator.h"  // CUpnpTaskResourceAllocator
-#include "upnpimagerenderingengine.h"   // CUpnpImageRenderingEngine
-#include "upnpshowtask.h"
-#include "upnpcommand.h"
-#include "upnpnotehandler.h"            // CUpnpNoteHandler
-
-_LIT( KComponentLogfile, "upnpcommand.log");
-#include "upnplog.h"
-
-
-// --------------------------------------------------------------------------
-// CUpnpShowTask::NewL
-// Creates an instance of the implementation.
-// --------------------------------------------------------------------------
-//
-CUpnpTask* CUpnpShowTask::NewL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::NewL" );
-
-    // Create instance
-    CUpnpShowTask* self = new (ELeave) CUpnpShowTask();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowTask::CUpnpShowTask
-// First phase construction.
-// --------------------------------------------------------------------------
-//
-CUpnpShowTask::CUpnpShowTask()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::Constructor" );
-
-    // Initialise member variables
-    iCommonUI = NULL;
-    iPlayingVideo = EFalse;
-    iRenderingSession = NULL;
-    iVideoRenderingSession = NULL;
-    iResourceAllocator = NULL;
-    iRenderingEngine = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// Destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpShowTask::~CUpnpShowTask()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::Destructor" );
-
-    Cleanup();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowTask::Cleanup
-// --------------------------------------------------------------------------
-//
-void CUpnpShowTask::Cleanup()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::Cleanup" );
-
-    if ( iRenderingEngine )
-        {
-        delete iRenderingEngine;
-        iRenderingEngine = NULL;
-        }       
-        
-    // delete the resource allocator
-    // Local mediaserver and AVController resources will be freed.
-    delete iResourceAllocator;
-    iResourceAllocator = NULL;
-
-    iRenderingSession = NULL;
-    iVideoRenderingSession = NULL;
-
-    delete iCommonUI;
-    iCommonUI = NULL;
-
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::Cleanup - end" );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowTask::ConstructL
-// Perform the second phase of two phase construction. Reserves the Upnp Fw
-// resources (they are released when the task is destroyed).
-// --------------------------------------------------------------------------
-//
-void CUpnpShowTask::ConstructL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::ConstructL" );
-
-    // create common UI
-    iCommonUI = CUPnPCommonUI::NewL();
-
-    // create the resource allocator
-    iResourceAllocator = CUpnpTaskResourceAllocator::NewL(
-        *iCommonUI,
-        CUpnpTaskResourceAllocator::EResourceAvController |
-        CUpnpTaskResourceAllocator::EResourceLocalMediaServer |
-        CUpnpTaskResourceAllocator::EResourceSelectImageRenderer );
-        
-    iShowPlaybackFailedNote = ETrue;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowTask::AllocateResourcesL
-// Allocates the Upnp Fw resources.
-// --------------------------------------------------------------------------
-//
-void CUpnpShowTask::AllocateResourcesL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::AllocateResourcesL" );
-
-    iResourceAllocator->SetNoteHandlerL( NoteHandler() );
-    
-    NoteHandler()->ResetDrmNoteCount();
-    
-    // now allocate!
-    iResourceAllocator->AllocateL();
-
-    // start a rendering session
-    iRenderingSession =
-        &iResourceAllocator->AVController().StartRenderingSessionL(
-            iResourceAllocator->SelectedDevice() );
-
-    // create image rendering engine
-    iRenderingEngine = CUpnpImageRenderingEngine::NewL(
-        iResourceAllocator->AVController(),
-        *iRenderingSession,
-        *this );
-    }
-
-
-
-// --------------------------------------------------------------------------
-// CUpnpShowTask::ExecuteL
-// Executes the task.
-// --------------------------------------------------------------------------
-//
-void CUpnpShowTask::ExecuteL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::ExecuteL" );
-    // assert that required resources exist
-    __ASSERTD( iRenderingEngine, __FILE__, __LINE__ );
-
-
-    if( iPlayingVideo )
-        {
-        // if videoplayerdlg is active, we cannot start rendering new file
-        // before user closes the dialog
-        __LOG( "[UpnpCommand]\t CUpnpShowTask::ExecuteL\
-            video already playing, do nothing" );
-        }
-    else
-        {
-        // start rendering process on the engine
-        iRenderingEngine->PlayL();
-        }
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpShowTask::GetMedia
-// provide media to be played back
-// --------------------------------------------------------------------------
-MUPnPItemResolver* CUpnpShowTask::GetMedia()
-    {
-    __ASSERTD( FilePipe(), __FILE__, __LINE__ );
-
-    MUPnPItemResolver* resolver = 0;
-
-    if ( FilePipe()->Count() > 0 )
-        {
-        const TDesC& filename = FilePipe()->FileAt( 0 );
-        __LOG1( "[UpnpCommand]\t CUpnpShowTask::GetMedia: %S", &filename );
-        TRAP_IGNORE (
-            resolver =
-                UPnPItemResolverFactory::NewLocalItemResolverL(
-                    filename,
-                    iResourceAllocator->AVController(),
-                    iSelector,
-                    UPnPItemResolverFactory::EOmitLocalMSStart );
-            );
-        }
-
-    return resolver;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowTask::RenderAck
-// Callback from image rendering engine.
-// --------------------------------------------------------------------------
-TInt CUpnpShowTask::RenderAck(
-    TInt aError,
-    const CUpnpItem* aItem )
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpShowTask::RenderAck aError %D", aError );
-    if ( aError == KErrNotSupported && aItem &&
-        UPnPItemUtility::BelongsToClass( *aItem, KClassVideo ) )
-        {
-        // NOTE!
-        // This is a special case. For video playback we use the image
-        // rendering engine for resolving, and then it fails with
-        // KErrNotSupported, because it is not an image. Now we catch the
-        // error here and play the resolved item. Why that complicated ?
-        // - to keep image rendering engine for image rendering ONLY
-        //   and not to mix video UI stuff in there
-        // - to enable image rendering engine reuse in the future
-        // - so that we do not have to rewrite the resolving code in
-        //   another place, it already exists in image rendering engine.
-        aError = PlayVideo( *aItem );
-        }
-
-    if ( aError != KErrDisconnected )
-        {
-        // disconnect message is handled in EngineShutdown
-        // other errors are handled here
-        if ( aError == KErrNotSupported || aError == KErrPermissionDenied )
-            {
-            TRAP_IGNORE( NoteHandler()->ShowDrmNoteL() );
-            }
-        else if( aError != KErrNone && iShowPlaybackFailedNote )
-            {
-            // note is shown only once per session
-            TRAP_IGNORE( NoteHandler()->ShowPlaybackFailedNoteL() );
-            iShowPlaybackFailedNote = EFalse;
-            }
-            
-        // inform observer
-        CommandEvent( UpnpCommand::EEventComplete, aError );
-        }
-        __LOG1( "[UpnpCommand]\t CUpnpShowTask::RenderAck end, resp=%d", aError );
-    return aError;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpShowTask::EngineShutdown
-// Callback from image rendering engine.
-// --------------------------------------------------------------------------
-void CUpnpShowTask::EngineShutdown(
-    TInt aError )
-    {
-    __ASSERTD( iRenderingEngine, __FILE__, __LINE__ );
-    
-    if ( iPlayingVideo )
-        {
-        __LOG1( "[UpnpCommand]\t CUpnpShowTask::EngineShutdown(%d)\
-while video playing",
-            aError );
-        TRAP_IGNORE( iCommonUI->DismissDialogL( aError ) );
-        }
-    else
-        {
-        __LOG1( "[UpnpCommand]\t CUpnpShowTask::EngineShutdown(%d)",
-            aError );
-            
-        if( aError == KErrDisconnected )
-            {
-            // check from rendering engine if wlan is active
-            // note shown only in device disappeared cases
-            if( iRenderingEngine->IsWlanActive() )
-                {
-                TRAP_IGNORE( NoteHandler()->ShowConnectionLostNoteL() );
-                }
-            }
-            
-            
-        // Inform the observer
-        __ASSERTD( TaskHandler(), __FILE__, __LINE__ );
-
-        CommandEvent( UpnpCommand::EEventComplete, aError);
-        }
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::EngineShutdown END" );
-    }
-
-
-    
-// --------------------------------------------------------------------------
-// CUpnpShowTask::PlayVideo
-// Launches the video player dialog for playing a video file on remote
-// --------------------------------------------------------------------------
-TInt CUpnpShowTask::PlayVideo( const CUpnpItem& aItem )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::CUpnpShowTask::PlayVideo start" );
-    
-    TInt videoPlayerError = KErrNone;
-    TInt videoStatus = KErrNone;
-
-    // Update the state
-    iPlayingVideo = ETrue;
-            
-            
-    // Launch the video player dialog to render the item.
-    TRAP( videoPlayerError,
-    
-        // start a rendering session ( used only for video playing )
-        if( !iVideoRenderingSession )
-            {
-            iVideoRenderingSession =
-                &iResourceAllocator->AVController().StartRenderingSessionL(
-                    iResourceAllocator->SelectedDevice() );
-            }
-        
-        // inform observer that we are launching dialog
-        __LOG( "[UpnpCommand]\t CUpnpShowTask::CUpnpShowTask::PlayVideo \
-launching videoplayerdialog" );
-        CommandEvent( UpnpCommand::EEventProgress,
-            UpnpCommand::KUpnpCommandStatusStartPlayVideo, EFalse );
-
-        // plays video     
-        videoStatus = iCommonUI->ExecuteVideoPlayerL(
-             *iVideoRenderingSession, aItem );
-        )
-
-    // Update the state
-    iPlayingVideo = EFalse;
-
-    // Fix UpnpCommonUi's return value
-    if( videoStatus > 0 )
-        {
-        videoStatus = KErrNone;
-        }
-
-    if( videoPlayerError != KErrNone &&
-        videoStatus == KErrNone )
-        {
-        videoStatus = videoPlayerError;
-        }
-
-    __LOG( "[UpnpCommand]\t CUpnpShowTask::CUpnpShowTask::PlayVideo end" );
-
-    // Inform the observer, no matter if the playing succeeded or failed.
-    return videoStatus;
-    }
-    
-
-// End of File
+/*
+* Copyright (c) 2007-2009 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:  Source file for CUpnpShowTask class.
+*
+*/
+
+
+// INCLUDE FILES
+// upnp stack api
+#include <upnpitem.h>                   // CUpnpItem
+#include <upnpobject.h>                 // CUpnpObject (cast)
+
+// upnpframework / avcontroller api
+#include "upnpavcontroller.h"           // MUPnPAVController
+#include "upnpavrenderingsession.h"     // MUPnPAVRenderingSession
+#include "upnpavsessionobserverbase.h"
+
+// upnpframework / avcontroller helper api
+#include "upnpconstantdefs.h"           // KFilterCommon, KClassVideo
+#include "upnpitemresolver.h"           // MUPnPItemResolver
+#include "upnpitemresolverobserver.h"   // MUPnPItemResolverObserver
+#include "upnpitemresolverfactory.h"    // UPnPItemResolverFactory
+#include "upnpitemutility.h"            // UPnPItemUtility::BelongsToClass
+#include <upnpstring.h>                 // UpnpString::ToUnicodeL
+
+// upnpframework / commonui
+#include "upnpcommonui.h"
+
+// command internal
+#include "upnpfilepipe.h"               // CUpnpFilePipe
+#include "upnptaskhandler.h"            // MUpnpTaskHandler
+#include "upnptaskresourceallocator.h"  // CUpnpTaskResourceAllocator
+#include "upnpimagerenderingengine.h"   // CUpnpImageRenderingEngine
+#include "upnpshowtask.h"
+#include "upnpcommand.h"
+#include "upnpnotehandler.h"            // CUpnpNoteHandler
+#include "upnpavdevice.h"
+
+_LIT( KComponentLogfile, "upnpcommand.log");
+#include "upnplog.h"
+
+
+// --------------------------------------------------------------------------
+// CUpnpShowTask::NewL
+// Creates an instance of the implementation.
+// --------------------------------------------------------------------------
+//
+CUpnpTask* CUpnpShowTask::NewL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::NewL" );
+
+    // Create instance
+    CUpnpShowTask* self = new (ELeave) CUpnpShowTask();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowTask::CUpnpShowTask
+// First phase construction.
+// --------------------------------------------------------------------------
+//
+CUpnpShowTask::CUpnpShowTask()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::Constructor" );
+
+    }
+
+// --------------------------------------------------------------------------
+// Destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpShowTask::~CUpnpShowTask()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::Destructor" );
+
+    Cleanup();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowTask::Cleanup
+// --------------------------------------------------------------------------
+//
+void CUpnpShowTask::Cleanup()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::Cleanup" );
+
+	delete iRenderingEngine;
+	iRenderingEngine = NULL;
+        
+    // delete the resource allocator
+    // Local mediaserver and AVController resources will be freed.
+    delete iResourceAllocator;
+    iResourceAllocator = NULL;
+
+    iRenderingSession = NULL;
+    iVideoRenderingSession = NULL;
+
+    delete iCommonUI;
+    iCommonUI = NULL;
+
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::Cleanup - end" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowTask::ConstructL
+// Perform the second phase of two phase construction. Reserves the Upnp Fw
+// resources (they are released when the task is destroyed).
+// --------------------------------------------------------------------------
+//
+void CUpnpShowTask::ConstructL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::ConstructL" );
+
+    // create common UI
+    iCommonUI = CUPnPCommonUI::NewL();
+
+    // create the resource allocator
+    iResourceAllocator = CUpnpTaskResourceAllocator::NewL(
+        *iCommonUI,
+        CUpnpTaskResourceAllocator::EResourceAvController |
+        /*CUpnpTaskResourceAllocator::EResourceLocalMediaServer |*/
+        CUpnpTaskResourceAllocator::EResourceSelectImageRenderer );
+        
+    iShowPlaybackFailedNote = ETrue;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowTask::AllocateResourcesL
+// Allocates the Upnp Fw resources.
+// --------------------------------------------------------------------------
+//
+void CUpnpShowTask::AllocateResourcesL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::AllocateResourcesL" );
+
+    iResourceAllocator->SetNoteHandlerL( NoteHandler() );
+    
+    NoteHandler()->ResetDrmNoteCount();
+    
+    // now allocate!
+    iResourceAllocator->AllocateL();
+
+    // start a rendering session
+    iRenderingSession =
+        &iResourceAllocator->AVController().StartRenderingSessionL(
+            iResourceAllocator->SelectedDevice() );
+
+    // create image rendering engine
+    iRenderingEngine = CUpnpImageRenderingEngine::NewL(
+        iResourceAllocator->AVController(),
+        *iRenderingSession,
+        *this );
+    }
+
+
+
+// --------------------------------------------------------------------------
+// CUpnpShowTask::ExecuteL
+// Executes the task.
+// --------------------------------------------------------------------------
+//
+void CUpnpShowTask::ExecuteL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::ExecuteL" );
+    // assert that required resources exist
+    __ASSERT( iRenderingEngine, __FILE__, __LINE__ );
+
+
+    if( iPlayingVideo )
+        {
+        // if videoplayerdlg is active, we cannot start rendering new file
+        // before user closes the dialog
+        __LOG( "[UpnpCommand]\t CUpnpShowTask::ExecuteL\
+            video already playing, do nothing" );
+        }
+    else
+        {
+        // start rendering process on the engine
+        iRenderingEngine->PlayL();
+        }
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpShowTask::GetMedia
+// provide media to be played back
+// --------------------------------------------------------------------------
+MUPnPItemResolver* CUpnpShowTask::GetMedia()
+    {
+    __ASSERT( FilePipe(), __FILE__, __LINE__ );
+
+    __LOG1( "[UpnpCommand]\t CUpnpShowTask::GetMedia cnt %d", 
+        FilePipe()->Count() );
+
+    MUPnPItemResolver* resolver = 0;
+
+    if ( FilePipe()->Count() > 0 )
+        {
+        const TDesC& filename = FilePipe()->FileAt( 0 );
+        __LOG1( "[UpnpCommand]\t CUpnpShowTask::GetMedia: %S", &filename );
+        TRAP_IGNORE (
+            resolver =
+                UPnPItemResolverFactory::NewLocalItemResolverL(
+                    filename,
+                    iResourceAllocator->AVController(),
+                    iSelector,
+                    UPnPItemResolverFactory::EOmitLocalMSStart );
+            );
+        }
+
+    return resolver;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowTask::RenderAck
+// Callback from image rendering engine.
+// --------------------------------------------------------------------------
+TInt CUpnpShowTask::RenderAck(
+    TInt aError,
+    const CUpnpItem* aItem )
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpShowTask::RenderAck aError %D", aError );
+    if ( aError == KErrNotSupported && aItem &&
+        UPnPItemUtility::BelongsToClass( *aItem, KClassVideo ) )
+        {
+        // NOTE!
+        // This is a special case. For video playback we use the image
+        // rendering engine for resolving, and then it fails with
+        // KErrNotSupported, because it is not an image. Now we catch the
+        // error here and play the resolved item. Why that complicated ?
+        // - to keep image rendering engine for image rendering ONLY
+        //   and not to mix video UI stuff in there
+        // - to enable image rendering engine reuse in the future
+        // - so that we do not have to rewrite the resolving code in
+        //   another place, it already exists in image rendering engine.
+        aError = PlayVideo( *aItem );
+        }
+
+    // disconnect and renderer busy messages are handled in EngineShutdown
+    // other errors are handled here
+    if ( aError != KErrDisconnected )
+        {
+        if ( aError == KErrNotSupported || aError == KErrPermissionDenied )
+            {
+            // protected file
+            TRAP_IGNORE( NoteHandler()->ShowDrmNoteL() );
+            }
+        else if( aError != KErrNone && iShowPlaybackFailedNote )
+            {
+            // unknown error -> show general note
+            // note is shown only once per session
+            TRAP_IGNORE( NoteHandler()->ShowPlaybackFailedNoteL() );
+            iShowPlaybackFailedNote = EFalse;
+            }
+            
+        // inform observer
+        CommandEvent( UpnpCommand::EEventComplete, aError );
+        }
+    
+    __LOG1( "[UpnpCommand]\t RenderAck end, resp=%d", aError );
+
+    return aError;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpShowTask::EngineShutdown
+// Callback from image rendering engine.
+// --------------------------------------------------------------------------
+void CUpnpShowTask::EngineShutdown(
+    TInt aError )
+    {
+    if ( iPlayingVideo )
+        {
+        __LOG1( "[UpnpCommand]\t CUpnpShowTask::EngineShutdown(%d)\
+while video playing",
+            aError );
+        TRAP_IGNORE( iCommonUI->DismissDialogL( aError ) );
+        }
+    else
+        {
+        __LOG1( "[UpnpCommand]\t CUpnpShowTask::EngineShutdown(%d)",
+            aError );
+            
+        if( aError == KErrDisconnected )
+            {
+            __ASSERTD( iRenderingEngine, __FILE__, __LINE__ );
+            
+            // check from rendering engine if wlan is active
+            // note shown only in device disappeared cases
+            if( iRenderingEngine->IsWlanActive() )
+                {
+                TRAP_IGNORE( NoteHandler()->ShowConnectionLostNoteL() );
+                }
+            }
+        else if( aError == KErrInUse )
+            {
+            // renderer is used by another controlpoint¨
+            if ( iRenderingSession )
+                {
+                TRAP_IGNORE( HBufC* rendererName = UpnpString::ToUnicodeL( 
+                                iRenderingSession->Device().FriendlyName() );
+                    CleanupStack::PushL( rendererName );
+                    iRenderingSession->Device().FriendlyName();
+                    NoteHandler()->ShowRendererInUseNoteL(*rendererName);
+                    CleanupStack::PopAndDestroy( rendererName );
+                    );
+                }
+            }  
+            
+            
+        // Inform the observer
+        __ASSERT( TaskHandler(), __FILE__, __LINE__ );
+
+        CommandEvent( UpnpCommand::EEventComplete, aError, ETrue );
+        }
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::EngineShutdown END" );
+    }
+
+
+    
+// --------------------------------------------------------------------------
+// CUpnpShowTask::PlayVideo
+// Launches the video player dialog for playing a video file on remote
+// --------------------------------------------------------------------------
+TInt CUpnpShowTask::PlayVideo( const CUpnpItem& aItem )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::CUpnpShowTask::PlayVideo start" );
+    
+    TInt videoPlayerError = KErrNone;
+    TInt videoStatus = KErrNone;
+
+    // Update the state
+    iPlayingVideo = ETrue;
+            
+            
+    // Launch the video player dialog to render the item.
+    TRAP( videoPlayerError,
+    
+        // start a rendering session ( used only for video playing )
+        if( !iVideoRenderingSession )
+            {
+            iVideoRenderingSession =
+                &iResourceAllocator->AVController().StartRenderingSessionL(
+                    iResourceAllocator->SelectedDevice() );
+            }
+        
+        // inform observer that we are launching dialog
+        __LOG( "[UpnpCommand]\t CUpnpShowTask::CUpnpShowTask::PlayVideo \
+launching videoplayerdialog" );
+        CommandEvent( UpnpCommand::EEventProgress,
+            UpnpCommand::KUpnpCommandStatusStartPlayVideo, EFalse );
+
+        // plays video     
+        videoStatus = iCommonUI->ExecuteVideoPlayerL(
+             *iVideoRenderingSession, aItem );
+        )
+
+    // Update the state
+    iPlayingVideo = EFalse;
+
+    // Fix UpnpCommonUi's return value
+    if( videoStatus > 0 )
+        {
+        videoStatus = KErrNone;
+        }
+
+    if( videoPlayerError != KErrNone &&
+        videoStatus == KErrNone )
+        {
+        videoStatus = videoPlayerError;
+        }
+
+    __LOG( "[UpnpCommand]\t CUpnpShowTask::CUpnpShowTask::PlayVideo end" );
+
+    // Inform the observer, no matter if the playing succeeded or failed.
+    return videoStatus;
+    }
+    
+
+// End of File
--- a/upnpframework/upnpcommand/src/upnptaskresourceallocator.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpcommand/src/upnptaskresourceallocator.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,541 +1,387 @@
-/*
-* Copyright (c) 2007 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:  A class that allocates resources for a task
-*
-*/
-
-
-// INCLUDE FILES
-// upnpframework / avcontroller api
-#include "upnpavcontrollerfactory.h"    // UPnPAVControllerFactory
-#include "upnpavcontroller.h"           // MUPnPAVController
-#include "upnpavdevice.h"               // CUpnpAVDevice
-#include "upnpavbrowsingsession.h"      // MUPnPAVBrowsingSession
-
-// upnpframework / common ui
-#include "upnpcommonui.h"               // CUPnPCommonUI
-
-// command internal
-#include "upnpnotehandler.h"            // CUpnpNoteHandler
-#include "upnptaskresourceallocator.h"  // myself
-
-_LIT( KComponentLogfile, "upnpcommand.log");
-#include "upnplog.h"
-
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::NewL
-// --------------------------------------------------------------------------
-CUpnpTaskResourceAllocator* CUpnpTaskResourceAllocator::NewL(
-    CUPnPCommonUI& aCommonUI,
-    TInt aMode )
-    {
-    CUpnpTaskResourceAllocator* self = new (ELeave)
-        CUpnpTaskResourceAllocator( aCommonUI, aMode );
-
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::CUpnpTaskResourceAllocator
-// --------------------------------------------------------------------------
-CUpnpTaskResourceAllocator::CUpnpTaskResourceAllocator(
-    CUPnPCommonUI& aCommonUI,
-    TInt aMode )
-    : CAsyncOneShot( EPriorityStandard )
-    , iCommonUI( aCommonUI )
-    {
-    __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator: constructor" );
-
-    iState = EStateIdle;
-    iErrorCode = KErrNone;
-    iMode = aMode;
-    iLocalMSSCompleted = EFalse;
-
-    if ( iMode & EResourceLocalMediaServer ||
-         iMode & EResourceSelectDevice )
-        {
-        // if any of these flags are set, AVCONTROLLER flag is mandatory.
-        // assert that.
-        __ASSERTD( iMode & EResourceAvController, __FILE__, __LINE__ );
-        }
-
-    if ( iMode & EResourceLocalMediaServer )
-        {
-        // if this flag is set, one of the device selection flags is mandatory.
-        __ASSERTD( iMode & EResourceSelectDevice, __FILE__, __LINE__ );
-        }
-
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::~CUpnpTaskResourceAllocator
-// --------------------------------------------------------------------------
-CUpnpTaskResourceAllocator::~CUpnpTaskResourceAllocator()
-    {
-    if ( iState == EStateAllocating )
-        {
-        __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
-        
-        SetErrorCode( KErrCancel );
-        if ( iNoteHandler )
-            {
-            iNoteHandler->CloseWaitNote();
-            }
-        }
-
-    Cleanup();
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::Cleanup
-// --------------------------------------------------------------------------
-void CUpnpTaskResourceAllocator::Cleanup()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::Cleanup" );
-
-    delete iSelectedDevice;
-    iSelectedDevice = 0;
-    
-    if ( iMediaServerSession )
-        {
-        // Stop local file sharing (release)
-        TRAPD( error, iMediaServerSession->ReleaseLocalMSServicesL() );
-        if( error != KErrNone )
-            {
-            __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\
-ReleaseLocalMSService failed %d", error );
-            }
-        
-        // Stop observing the rendering session
-        iMediaServerSession->RemoveObserver();
-
-        // Stop session
-        iAVController->StopBrowsingSession( *iMediaServerSession );
-        iMediaServerSession = NULL;
-        }
-
-    if( iAVController )
-        {
-        iAVController->RemoveDeviceObserver();
-        iAVController->Release(); // Fixes ESLX-7BMJBN
-        iAVController = NULL;
-        }
-
-    }
-
-
-
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::AllocateL
-// --------------------------------------------------------------------------
-void CUpnpTaskResourceAllocator::AllocateL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::AllocateL" );
-
-    __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
-    
-    // make CAsyncOneShot to do its trick in parallel
-    Call();
-
-    // show progress note in sync.
-    iState = EStateAllocating;
-    TInt status = iNoteHandler->RunConnectingWaitNote();
-    SetErrorCode( status );
-    iState = EStateReady;
-
-    // progress note has exited. Monitor errors from the progress note
-
-    // in error situation clean up resources and leave
-    if ( iErrorCode != KErrNone )
-        {
-        iState = EStateError;
-        Cleanup();
-        User::Leave( iErrorCode );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::AVController
-// --------------------------------------------------------------------------
-MUPnPAVController& CUpnpTaskResourceAllocator::AVController()
-    {
-    __ASSERT( iState == EStateReady, __FILE__, __LINE__ );
-    __ASSERT( iMode & EResourceAvController, __FILE__, __LINE__ );
-
-    return *iAVController;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::SelectedDevice
-// --------------------------------------------------------------------------
-const CUpnpAVDevice& CUpnpTaskResourceAllocator::SelectedDevice()
-    {
-    __ASSERT( iState == EStateReady, __FILE__, __LINE__ );
-    __ASSERT( iMode & EResourceSelectDevice, __FILE__, __LINE__ );
-    __ASSERT( iSelectedDevice, __FILE__, __LINE__ );
-
-    return *iSelectedDevice;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::RunL
-// --------------------------------------------------------------------------
-void CUpnpTaskResourceAllocator::RunL()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL" );
-
-    // make sure we are still on the go
-    if ( iState == EStateAllocating )
-        {
-        // starting of AVController
-        StartAvControllerL();
-        }
-    else
-        {
-        __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \
-    StartAvControllerL not done in state %d", iState );
-        }
-    // make sure we are still on the go
-    if ( iState == EStateAllocating )
-        {
-        // select device
-        SelectDeviceL();
-        }
-    else
-        {
-        __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \
-    SelectDeviceL not done in state %d", iState );
-        }
-    // make sure we are still on the go
-    if ( iState == EStateAllocating )
-        {
-        // start the local mediaserver
-        StartLocalMediaServerL();
-        }
-    else
-        {
-        __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \
-    StartLocalMediaServerL not done in state %d", iState );
-        }        
-    // make sure we are still on the go
-    if ( iState == EStateAllocating )
-        {
-        // if local media server was started but not yet completed,
-        // wait for callback
-        if ( iMode & EResourceLocalMediaServer
-            && !iLocalMSSCompleted )
-            {
-            __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \
-    waiting for ReserveLocalMSServicesCompleted" );
-            iState = EStateWaitingForLMS;
-            }
-        // otherwise we are done now
-        else
-            {
-            // close the wait note
-            __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
-            iNoteHandler->CloseWaitNote();
-            }
-        }
-    else
-        {
-        __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \
-    CloseWaitNote not done in state %d", iState );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::RunError
-// --------------------------------------------------------------------------
-TInt CUpnpTaskResourceAllocator::RunError( TInt aError )
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunError: %d",
-        aError );
-
-    __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
-    
-    // asynchronous operation leaves. store the error code and make the
-    // wait note exit.
-    SetErrorCode( aError );
-    iNoteHandler->CloseWaitNote();
-        
-    return KErrNone;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::StartAvControllerL
-// --------------------------------------------------------------------------
-void CUpnpTaskResourceAllocator::StartAvControllerL()
-    {
-    if ( iMode & EResourceAvController )
-        {
-        __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\
-StartAvControllerL" );
-
-        // Create new UpnpAvController client instance
-        iAVController = UPnPAVControllerFactory::NewUPnPAVControllerL();
-
-        // Register as an observer (for WLAN lost notification) 
-        iAVController->SetDeviceObserver( *this );
-        }
-    else
-        {
-        __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\
-    AvController not started" );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::StartLocalMediaServerL
-// --------------------------------------------------------------------------
-void CUpnpTaskResourceAllocator::StartLocalMediaServerL()
-    {
-    if ( iMode & EResourceLocalMediaServer )
-        {
-        __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\
-StartLocalMediaServerL" );
-
-        // create a dummy device
-        CUpnpAVDevice* dummyDevice = CUpnpAVDevice::NewLC();
-        dummyDevice->SetUuidL( KNullDesC8 );
-        dummyDevice->SetDeviceType(CUpnpAVDevice::EMediaServer);    
-        // create a session for mediaserver resources keepalive
-        iMediaServerSession =
-            &iAVController->StartBrowsingSessionL( *dummyDevice );
-        iMediaServerSession->SetObserver( *this );
-        CleanupStack::PopAndDestroy( dummyDevice );
-        // now reserve
-        iMediaServerSession->ReserveLocalMSServicesL();
-        }
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::SelectDeviceL
-// --------------------------------------------------------------------------
-//
-void CUpnpTaskResourceAllocator::SelectDeviceL()
-    {
-    if ( iMode & EResourceSelectDevice )
-        {
-        __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::SelectDeviceL" );
-
-        TInt status = KErrNone;
-        
-        // decide device filters and popup title
-        TUPnPDeviceTypesToSearch deviceFilter =
-            EUPnPSearchAllDevices;
-        TUPnPDialogTitle popupTitle = EUPnPSelectDeviceTitle;
-
-        if ( iMode & EResourceSelectImageRenderer )
-            {
-            deviceFilter = EUPnPSearchRenderingDevicesWithImageCapability;
-            }
-        else if ( iMode & EResourceSelectCopyServer )
-            {
-            deviceFilter = EUPnPSearchServerDevicesWithCopyCapability;
-            popupTitle = EUPnPCopyToTitle;
-            }
-        else if ( iMode & EResourceSelectMoveServer )
-            {
-            deviceFilter = EUPnPSearchServerDevicesWithCopyCapability;
-            popupTitle = EUPnPMoveToTitle;
-            }
-        
-        // Launch the device selection dialog
-        CUpnpAVDevice* tempDevice = CUpnpAVDevice::NewL();
-        CleanupStack::PushL( tempDevice );
-        status = iCommonUI.SelectDeviceL(
-                  *iAVController,
-                  *tempDevice,
-                  deviceFilter,
-                  popupTitle );
-
-        // Fix UpnpCommonUi return value
-        if( status > 0 )
-            {
-            status = KErrNone;
-            }
-
-        if( status != KErrNone )
-            {
-            // failed
-            User::Leave( status );
-            }
-
-        CleanupStack::Pop( tempDevice );
-        iSelectedDevice = tempDevice;
-
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::SetErrorCode
-// --------------------------------------------------------------------------
-void CUpnpTaskResourceAllocator::SetErrorCode( TInt aErrorCode )
-    {
-    __LOG2( "[UpnpCommand]\t CUpnpTaskResourceAllocator::SetErrorCode \
-%d -> %d", iErrorCode, aErrorCode );
-
-    if ( iErrorCode == KErrNone )
-        {
-        __LOG( "error code changed");
-        iErrorCode = aErrorCode;
-        } 
-    // if user cancelled operation, we don't need other error codes
-    // so it's ok to reset old error code
-    else if ( aErrorCode == KErrCancel )
-        {
-        __LOG( "error code reseted");
-        iErrorCode = aErrorCode;
-        }
-    }
-
-// ==========================================================================
-// Methods for AVController device observer
-// ==========================================================================
-    
-    
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::WLANConnectionLost
-// --------------------------------------------------------------------------
-void CUpnpTaskResourceAllocator::WLANConnectionLost()
-    {
-    __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::WLANConnectionLost" );
-
-    if ( iState == EStateAllocating || iState == EStateWaitingForLMS )
-        {
-        __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
-        SetErrorCode( KErrDisconnected );
-        iNoteHandler->CloseWaitNote();
-        iState = EStateError;
-        }
-    }
-
-void CUpnpTaskResourceAllocator::UPnPDeviceDiscovered(
-    const CUpnpAVDevice& /*aDevice*/ )
-    {
-    }
-
-void CUpnpTaskResourceAllocator::UPnPDeviceDisappeared(
-    const CUpnpAVDevice& aDevice )
-    {
-    __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
-    if ( ( iState == EStateAllocating || iState == EStateWaitingForLMS )
-         && iSelectedDevice != 0 )
-        {
-        if ( aDevice.Uuid() == iSelectedDevice->Uuid() )
-            {
-            __LOG( "[UpnpCommand]\t selected device lost !" );
-            SetErrorCode( KErrDisconnected );
-            iNoteHandler->CloseWaitNote();
-            iState = EStateError;
-            }
-        }
-    }
-    
-    
-// ==========================================================================
-// Methods for AVController browsing session observer
-// ==========================================================================
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::ReserveLocalMSServicesCompleted
-// --------------------------------------------------------------------------
-void CUpnpTaskResourceAllocator::ReserveLocalMSServicesCompleted( TInt aError )
-    {
-    __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\
-ReserveLocalMSServicesCompleted: %d", aError );
-
-    if ( iState == EStateAllocating 
-        || iState == EStateWaitingForLMS )
-        {
-        iLocalMSSCompleted = ETrue;
-        SetErrorCode( aError );
-        if ( aError == KErrNone )
-            {
-            iLocalMSStarted = ETrue;
-            iMediaServerSession->RemoveObserver();
-            }
-        // allocation done, just waiting for this callback
-        // close note and we are done
-        if( iState == EStateWaitingForLMS )
-            {
-            iNoteHandler->CloseWaitNote();
-            }
-        }
-    }
-
-
-void CUpnpTaskResourceAllocator::BrowseResponse(
-    const TDesC8& /*aBrowseResponse*/,
-    TInt /*aError*/,
-    TInt /*aMatches*/,
-    TInt /*aTotalCount*/,
-    const TDesC8& /*aUpdateId*/ )
-    {
-    }
-
-void CUpnpTaskResourceAllocator::SearchResponse( 
-    const TDesC8& /*aSearchResponse*/,
-    TInt /*aError*/,
-    TInt /*aMatches*/,
-    TInt /*aTotalCount*/,
-    const TDesC8& /*aUpdateId*/ )
-    {
-    }
-
-void CUpnpTaskResourceAllocator::SearchCapabilitiesResponse( 
-    TInt /*aError*/,
-    const TDesC8& /*aSearchCapabilities*/ )
-    {
-    }
-
-void CUpnpTaskResourceAllocator::CreateContainerResponse(
-    TInt /*aError*/, 
-    const TDesC8& /*aObjectId*/ )
-    {
-    }
-
-void CUpnpTaskResourceAllocator::DeleteObjectResponse(
-    TInt /*aError*/ )
-    {
-    }
- 
-void CUpnpTaskResourceAllocator::MediaServerDisappeared(
-    TUPnPDeviceDisconnectedReason /*aReason*/ )
-    {
-    }
-
-
-
-// --------------------------------------------------------------------------
-// CUpnpTaskResourceAllocator::SetNoteHandlerL
-// Sets the pointer to the note handler.
-// --------------------------------------------------------------------------
-void CUpnpTaskResourceAllocator::SetNoteHandlerL( 
-                                        CUpnpNoteHandler* aNoteHandler )
-    {
-    // Check parameter
-    if( !aNoteHandler )
-        {
-        User::Leave( KErrArgument );
-        }
-
-    iNoteHandler = aNoteHandler;
-    }
+/*
+* Copyright (c) 2007-2009 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:  A class that allocates resources for a task
+*
+*/
+
+
+// INCLUDE FILES
+// upnpframework / avcontroller api
+#include "upnpavcontrollerfactory.h"    // UPnPAVControllerFactory
+#include "upnpavcontroller.h"           // MUPnPAVController
+#include "upnpavdevice.h"               // CUpnpAVDevice
+#include "upnpavbrowsingsession.h"      // MUPnPAVBrowsingSession
+
+// upnpframework / common ui
+#include "upnpcommonui.h"               // CUPnPCommonUI
+
+// command internal
+#include "upnpnotehandler.h"            // CUpnpNoteHandler
+#include "upnptaskresourceallocator.h"  // myself
+
+_LIT( KComponentLogfile, "upnpcommand.log");
+#include "upnplog.h"
+
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::NewL
+// --------------------------------------------------------------------------
+CUpnpTaskResourceAllocator* CUpnpTaskResourceAllocator::NewL(
+    CUPnPCommonUI& aCommonUI,
+    TInt aMode )
+    {
+    CUpnpTaskResourceAllocator* self = new (ELeave)
+        CUpnpTaskResourceAllocator( aCommonUI, aMode );
+
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::CUpnpTaskResourceAllocator
+// --------------------------------------------------------------------------
+CUpnpTaskResourceAllocator::CUpnpTaskResourceAllocator(
+    CUPnPCommonUI& aCommonUI,
+    TInt aMode )
+    : CAsyncOneShot( EPriorityStandard )
+    , iCommonUI( aCommonUI )
+    {
+    __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator: constructor" );
+
+    iState = EStateIdle;
+    iErrorCode = KErrNone;
+    iMode = aMode;
+
+    if ( iMode & EResourceSelectDevice )
+        {
+        // AVCONTROLLER flag is mandatory.
+        // assert that.
+        __ASSERTD( iMode & EResourceAvController, __FILE__, __LINE__ );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::~CUpnpTaskResourceAllocator
+// --------------------------------------------------------------------------
+CUpnpTaskResourceAllocator::~CUpnpTaskResourceAllocator()
+    {
+    if ( iState == EStateAllocating )
+        {
+        __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
+        
+        SetErrorCode( KErrCancel );
+        if ( iNoteHandler )
+            {
+            iNoteHandler->CloseWaitNote();
+            }
+        }
+
+    Cleanup();
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::Cleanup
+// --------------------------------------------------------------------------
+void CUpnpTaskResourceAllocator::Cleanup()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::Cleanup" );
+
+    delete iSelectedDevice;
+    iSelectedDevice = 0;
+            
+    if( iAVController )
+        {
+        iAVController->RemoveDeviceObserver();
+        iAVController->Release(); // Fixes ESLX-7BMJBN
+        iAVController = NULL;
+        }
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::AllocateL
+// --------------------------------------------------------------------------
+void CUpnpTaskResourceAllocator::AllocateL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::AllocateL" );
+
+    __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
+    
+    // make CAsyncOneShot to do its trick in parallel
+    Call();
+
+    // show progress note in sync.
+    iState = EStateAllocating;
+    TInt status = iNoteHandler->RunConnectingWaitNote();
+    SetErrorCode( status );
+    iState = EStateReady;
+
+    // progress note has exited. Monitor errors from the progress note
+
+    // in error situation clean up resources and leave
+    if ( iErrorCode != KErrNone )
+        {
+        iState = EStateError;
+        Cleanup();
+        User::Leave( iErrorCode );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::AVController
+// --------------------------------------------------------------------------
+MUPnPAVController& CUpnpTaskResourceAllocator::AVController()
+    {
+    __ASSERT( iState == EStateReady, __FILE__, __LINE__ );
+    __ASSERT( iMode & EResourceAvController, __FILE__, __LINE__ );
+
+    return *iAVController;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::SelectedDevice
+// --------------------------------------------------------------------------
+const CUpnpAVDevice& CUpnpTaskResourceAllocator::SelectedDevice()
+    {
+    __ASSERT( iState == EStateReady, __FILE__, __LINE__ );
+    __ASSERT( iMode & EResourceSelectDevice, __FILE__, __LINE__ );
+    __ASSERT( iSelectedDevice, __FILE__, __LINE__ );
+
+    return *iSelectedDevice;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::RunL
+// --------------------------------------------------------------------------
+void CUpnpTaskResourceAllocator::RunL()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL" );
+
+    // make sure we are still on the go
+    if ( iState == EStateAllocating )
+        {
+        // starting of AVController
+        StartAvControllerL();
+        }
+    else
+        {
+        __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \
+    StartAvControllerL not done in state %d", iState );
+        }
+    // make sure we are still on the go
+    if ( iState == EStateAllocating )
+        {
+        // select device
+        SelectDeviceL();
+        }
+    else
+        {
+        __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \
+    SelectDeviceL not done in state %d", iState );
+        }
+    // make sure we are still on the go
+    if ( iState == EStateAllocating )
+        {
+        // close the wait note
+        __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
+        iNoteHandler->CloseWaitNote();
+        }
+    else
+        {
+        __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunL \
+    CloseWaitNote not done in state %d", iState );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::RunError
+// --------------------------------------------------------------------------
+TInt CUpnpTaskResourceAllocator::RunError( TInt aError )
+    {
+    __LOG1( "[UpnpCommand]\t CUpnpTaskResourceAllocator::RunError: %d",
+        aError );
+
+    __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
+    
+    // asynchronous operation leaves. store the error code and make the
+    // wait note exit.
+    SetErrorCode( aError );
+    iNoteHandler->CloseWaitNote();
+        
+    return KErrNone;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::StartAvControllerL
+// --------------------------------------------------------------------------
+void CUpnpTaskResourceAllocator::StartAvControllerL()
+    {
+    if ( iMode & EResourceAvController )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\
+StartAvControllerL" );
+
+        // Create new UpnpAvController client instance
+        iAVController = UPnPAVControllerFactory::NewUPnPAVControllerL();
+
+        // Register as an observer (for WLAN lost notification) 
+        iAVController->SetDeviceObserver( *this );
+        }
+    else
+        {
+        __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::\
+    AvController not started" );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::SelectDeviceL
+// --------------------------------------------------------------------------
+//
+void CUpnpTaskResourceAllocator::SelectDeviceL()
+    {
+    if ( iMode & EResourceSelectDevice )
+        {
+        __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::SelectDeviceL" );
+
+        TInt status = KErrNone;
+        
+        // decide device filters and popup title
+        TUPnPDeviceTypesToSearch deviceFilter =
+            EUPnPSearchAllDevices;
+        TUPnPDialogTitle popupTitle = EUPnPSelectDeviceTitle;
+
+        if ( iMode & EResourceSelectImageRenderer )
+            {
+            deviceFilter = EUPnPSearchRenderingDevicesWithImageCapability;
+            }
+        else if ( iMode & EResourceSelectCopyServer )
+            {
+            deviceFilter = EUPnPSearchServerDevicesWithCopyCapability;
+            popupTitle = EUPnPCopyToTitle;
+            }
+        else if ( iMode & EResourceSelectMoveServer )
+            {
+            deviceFilter = EUPnPSearchServerDevicesWithCopyCapability;
+            popupTitle = EUPnPMoveToTitle;
+            }
+        
+        // Launch the device selection dialog
+        CUpnpAVDevice* tempDevice = CUpnpAVDevice::NewL();
+        CleanupStack::PushL( tempDevice );
+        status = iCommonUI.SelectDeviceL(
+                  *iAVController,
+                  *tempDevice,
+                  deviceFilter,
+                  popupTitle );
+
+        // Fix UpnpCommonUi return value
+        if( status > 0 )
+            {
+            status = KErrNone;
+            }
+
+        if( status != KErrNone )
+            {
+            // failed
+            User::Leave( status );
+            }
+
+        CleanupStack::Pop( tempDevice );
+        iSelectedDevice = tempDevice;
+
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::SetErrorCode
+// --------------------------------------------------------------------------
+void CUpnpTaskResourceAllocator::SetErrorCode( TInt aErrorCode )
+    {
+    __LOG2( "[UpnpCommand]\t CUpnpTaskResourceAllocator::SetErrorCode \
+%d -> %d", iErrorCode, aErrorCode );
+
+    if ( iErrorCode == KErrNone )
+        {
+        __LOG( "error code changed");
+        iErrorCode = aErrorCode;
+        } 
+    // if user cancelled operation, we don't need other error codes
+    // so it's ok to reset old error code
+    else if ( aErrorCode == KErrCancel )
+        {
+        __LOG( "error code reseted");
+        iErrorCode = aErrorCode;
+        }
+    }
+
+// ==========================================================================
+// Methods for AVController device observer
+// ==========================================================================
+    
+    
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::WLANConnectionLost
+// --------------------------------------------------------------------------
+void CUpnpTaskResourceAllocator::WLANConnectionLost()
+    {
+    __LOG( "[UpnpCommand]\t CUpnpTaskResourceAllocator::WLANConnectionLost" );
+
+    if ( iState == EStateAllocating )
+        {
+        __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
+        SetErrorCode( KErrDisconnected );
+        iNoteHandler->CloseWaitNote();
+        iState = EStateError;
+        }
+    }
+
+void CUpnpTaskResourceAllocator::UPnPDeviceDiscovered(
+    const CUpnpAVDevice& /*aDevice*/ )
+    {
+    }
+
+void CUpnpTaskResourceAllocator::UPnPDeviceDisappeared(
+    const CUpnpAVDevice& aDevice )
+    {
+    __ASSERTD( iNoteHandler, __FILE__, __LINE__ );
+    if ( ( iState == EStateAllocating )
+         && iSelectedDevice != 0 )
+        {
+        if ( aDevice.Uuid() == iSelectedDevice->Uuid() )
+            {
+            __LOG( "[UpnpCommand]\t selected device lost !" );
+            SetErrorCode( KErrDisconnected );
+            iNoteHandler->CloseWaitNote();
+            iState = EStateError;
+            }
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpTaskResourceAllocator::SetNoteHandlerL
+// Sets the pointer to the note handler.
+// --------------------------------------------------------------------------
+void CUpnpTaskResourceAllocator::SetNoteHandlerL( 
+                                        CUpnpNoteHandler* aNoteHandler )
+    {
+    // Check parameter
+    if( !aNoteHandler )
+        {
+        User::Leave( KErrArgument );
+        }
+
+    iNoteHandler = aNoteHandler;
+    }
--- a/upnpframework/upnpfiletransferengine/group/upnpfiletransferengine.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpfiletransferengine/group/upnpfiletransferengine.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,88 +1,88 @@
-/*
-* Copyright (c) 2006-2007 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:  Project definition file for project UpnpFileTransferEngine
-*
-*/
-
-
-// For compatibility with S60 3.2 and IAD branch
-#include "../../../group/upnpplatformvar.hrh"
-#include "../inc/upnpfiletransferengineuids.hrh"
-
-#include <data_caging_paths.hrh>
-
-// Build target
-TARGET          upnpfiletransferengine.dll
-CAPABILITY      CAP_GENERAL_DLL
-TARGETTYPE      DLL
-UID             0x10009D8D KUpnpFileTransferEngineDllUid
-VENDORID        VID_DEFAULT
-
-// SIS installation + IAD support
-VERSION 10.1
-paged
-
-SOURCEPATH      ../data
-START RESOURCE  upnpfiletransferengineresources.rss
-HEADER
-TARGET          upnpfiletransferengineresources.rsc
-TARGETPATH      RESOURCE_FILES_DIR
-LANGUAGE_IDS
-END
-
-USERINCLUDE     ../inc
-USERINCLUDE     ../../inc
-USERINCLUDE     ../../../inc
-USERINCLUDE     ../data
-USERINCLUDE     ../../upnputilities/inc
-USERINCLUDE     ../../upnpcommand/inc
-USERINCLUDE     ../../upnpaiwengine/inc
-
-MW_LAYER_SYSTEMINCLUDE
-UPNP_LOC_INCLUDE_PATH_COMPONENT
-
-SOURCEPATH      ../src
-SOURCE          upnpplaylisthandler.cpp
-SOURCE          upnpfiletransferhandler.cpp
-SOURCE          upnpfiletransferengine.cpp
-SOURCE          upnpnotehandler.cpp
-SOURCE          upnpdownloadhandler.cpp
-SOURCE          upnpuploadhandler.cpp
-
-// Core platform + Ui
-LIBRARY         euser.lib
-LIBRARY         bafl.lib
-LIBRARY         cone.lib
-LIBRARY         efsrv.lib 
-LIBRARY         PlatformEnv.lib
-LIBRARY         avkon.lib
-LIBRARY         eikctl.lib
-LIBRARY         CommonEngine.lib 
-
-// S60 Upnp Stack
-LIBRARY         upnpipserversutils.lib
-LIBRARY         upnpavobjects.lib
-
-// Upnp Framework
-LIBRARY         upnpavcontrollerclient.lib
-LIBRARY         upnpavcontrollerhelper.lib
-LIBRARY         upnputilities.lib
-LIBRARY         upnpmusicadapter.lib
-LIBRARY         upnpsettingsengine.lib 
-LIBRARY         upnpxmlparser.lib
-
-// Debugging
-DEBUGLIBRARY    flogger.lib
-
-// End of file
+/*
+* Copyright (c) 2006-2007 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:  Project definition file for project UpnpFileTransferEngine
+*
+*/
+
+
+// For compatibility with S60 3.2 and IAD branch
+#include "../../../group/upnpplatformvar.hrh"
+#include "../inc/upnpfiletransferengineuids.hrh"
+
+#include <data_caging_paths.hrh>
+
+// Build target
+TARGET          upnpfiletransferengine.dll
+CAPABILITY      CAP_GENERAL_DLL
+TARGETTYPE      DLL
+UID             0x10009D8D KUpnpFileTransferEngineDllUid
+VENDORID        VID_DEFAULT
+
+// SIS installation + IAD support
+VERSION 10.1
+paged
+
+SOURCEPATH      ../data
+START RESOURCE  upnpfiletransferengineresources.rss
+HEADER
+TARGET          upnpfiletransferengineresources.rsc
+TARGETPATH      RESOURCE_FILES_DIR
+LANGUAGE_IDS
+END
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+USERINCLUDE     ../../../inc
+USERINCLUDE     ../data
+USERINCLUDE     ../../upnputilities/inc
+USERINCLUDE     ../../upnpcommand/inc
+USERINCLUDE     ../../upnpaiwengine/inc
+
+MW_LAYER_SYSTEMINCLUDE
+UPNP_LOC_INCLUDE_PATH_COMPONENT
+
+SOURCEPATH      ../src
+SOURCE          upnpplaylisthandler.cpp
+SOURCE          upnpfiletransferhandler.cpp
+SOURCE          upnpfiletransferengine.cpp
+SOURCE          upnpnotehandler.cpp
+SOURCE          upnpdownloadhandler.cpp
+SOURCE          upnpuploadhandler.cpp
+
+// Core platform + Ui
+LIBRARY         euser.lib
+LIBRARY         bafl.lib
+LIBRARY         cone.lib
+LIBRARY         efsrv.lib 
+LIBRARY         platformenv.lib
+LIBRARY         avkon.lib
+LIBRARY         eikctl.lib
+LIBRARY         commonengine.lib 
+
+// S60 Upnp Stack
+LIBRARY         upnpipserversutils.lib
+LIBRARY         upnpavobjects.lib
+
+// Upnp Framework
+LIBRARY         upnpavcontrollerclient.lib
+LIBRARY         upnpavcontrollerhelper.lib
+LIBRARY         upnputilities.lib
+LIBRARY         upnpmusicadapter.lib
+LIBRARY         upnpsettingsengine.lib 
+LIBRARY         upnpxmlparser.lib
+
+// Debugging
+DEBUGLIBRARY    flogger.lib
+
+// End of file
--- a/upnpframework/upnpmusicadapter/src/upnpalbumservices.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnpmusicadapter/src/upnpalbumservices.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,628 +1,628 @@
-/*
-* Copyright (c) 2006-2007 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:  provides album handling services for UPnP framework
-*
-*/
-
-#include "upnpapplicationcrkeys.h" // KCRUidUPnPApplication
-#include <mpxcollectionutility.h>
-#include <mpxcollectionframeworkdefs.h> // main attribute keys
-#include <mpxmessagegeneraldefs.h>
-#include <mpxmediageneraldefs.h> // commonly used attribute keys
-#include <mpxmediacontainerdefs.h> // container-specific attribute keys
-#include <mpxcollectionpath.h>
-#include <mpxcollectionmessage.h>
-#include <mpxmediadrmdefs.h>
-
-#include <mpxmedia.h>
-#include <mpxmediaarray.h>
-
-#include "upnpalbumservices.h" // ourselves
-
-// debug
-_LIT16( KComponentLogfile, "musicadapter.txt" );
-#include "upnplog.h"
-
-// Constant definitions
-#define KAlbumsCollectionUid 0x20007197 // album plugin uid
-
-// ======== MEMBER FUNCTIONS ========
-
-// ---------------------------------------------------------------------------
-// CUPnPAlbumServices::NewL
-// 1st phase constructor.
-// ---------------------------------------------------------------------------
-//
-EXPORT_C CUPnPAlbumServices* CUPnPAlbumServices::NewL()
-    {
-    __LOG( "CUPnPAlbumServices::NewL" );
-
-    CUPnPAlbumServices* self = new(ELeave) CUPnPAlbumServices();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::CUPnPAlbumServices
-// Default constructor.
-// --------------------------------------------------------------------------
-//    
-CUPnPAlbumServices::CUPnPAlbumServices() : iStatus( KErrNone )
-    {
-    // None.
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::ConstructL
-// 2nd phase constructor
-// --------------------------------------------------------------------------
-//    
-void CUPnPAlbumServices::ConstructL()
-    {
-    __LOG( "CUPnPAlbumServices::ConstructL" );
-    iAlbumNames = new (ELeave) CDesCArrayFlat(5);
-    iAlbumIds = new (ELeave) CDesCArrayFlat(5);
-
-    iCollectionUtility = MMPXCollectionUtility::NewL(
-        (MMPXCollectionObserver*)this, KMcModePlaylist );
-
-    // Open album collection plugin. Callback to HandleCollectionMessage.
-    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
-    CleanupStack::PushL( path );
-    path->AppendL( KAlbumsCollectionUid );
-    iCollectionUtility->Collection().OpenL( *path );
- 	CleanupStack::PopAndDestroy( path ); 
-
-    // Wait until signalled to proceed
-    iWait = new (ELeave) CActiveSchedulerWait();    
-    iWait->Start();     
-
-    __LOG1( "CUPnPAlbumServices::ConstructL - End %d", iStatus );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::ListAlbumsL
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUPnPAlbumServices::ListAlbumsL(
-    CDesCArray& aAlbumIds,
-    CDesCArray& aAlbumNames )
-    {
-    __LOG( "CUPnPAlbumServices::ListAlbumsL" );
-    
-    // Check if already listed
-    
-    if( iStatus != KErrNone)
-        {
-        __LOG1( "CUPnPAlbumServices::ListAlbumsL iStatus %d return", iStatus );
-        return;
-        }
-    
-    if( iAlbumNames->Count() > 0 && iAlbumIds->Count() > 0 )
-        {
-        __LOG( "CUPnPAlbumServices::ListAlbumsL: Already fetched." );
-        // Copy from member
-        TInt count = iAlbumNames->Count();
-        __LOG1( "Album count=%d", count );
-        for( TInt i = 0; i < count; i++ )
-            {
-            aAlbumNames.AppendL( iAlbumNames->MdcaPoint(i) );
-            aAlbumIds.AppendL( iAlbumIds->MdcaPoint(i) );
-            }
-        __LOG( "CUPnPAlbumServices::ListAlbumsL: Return." );
-        return;
-        }
-
-    CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
-    CleanupStack::PushL( path );
-    path->SelectAllL();
-
-    RArray<TMPXAttribute> attrs;
-    CleanupClosePushL( attrs );
-    attrs.AppendL( KMPXMediaGeneralId );
-    attrs.AppendL( KMPXMediaGeneralTitle );
-
-    // Get album list from collection. Callback to HandleCollectionMediaL
-    iCollectionUtility->Collection().MediaL( *path, attrs.Array() );
-    CleanupStack::PopAndDestroy( &attrs );
-    CleanupStack::PopAndDestroy( path );
-
-    // Wait until signalled to proceed
-    iWait->Start();
-
-    if( iStatus != KErrNone )
-        {
-        if( iStatus == KErrNotFound )
-            {
-            // No albums available.
-            __LOG( "ListAlbumsL: No albums available!" );
-            return;
-            }
-        else // Some other problem
-            {
-            User::Leave( iStatus );
-            }
-        }
-
-    if ( iMedia != 0 )
-        {
-        TMPXAttribute mediaArrayAttr( KMPXMediaIdContainer,
-            EMPXMediaArrayContents );
-                
-        if( iMedia->IsSupported( mediaArrayAttr ) )
-            {
-            __LOG("getting album array");
-            CMPXMediaArray* medias = iMedia->ValueCObjectL<CMPXMediaArray>(
-                mediaArrayAttr );
-
-            if( medias )
-                {
-                CleanupStack::PushL( medias );
-                // Album count
-                TInt count = medias->Count();        
-                __LOG1( "Album count=%d", count );
-
-                for( TInt i = 0; i < count; ++i )
-                    {
-                    const CMPXMedia* entry = (*medias)[i];
-                    const TDesC& title = entry->ValueText(
-                        KMPXMediaGeneralTitle );
-                    __LOG3( "Title: %d/%d [%S]",i, count, &title );
-                    TMPXItemId id = *entry->Value<TMPXItemId>(
-                        KMPXMediaGeneralId );
-                    aAlbumNames.AppendL( title );
-                    iAlbumNames->AppendL( title ); // for later usage
-                    aAlbumIds.AppendL( Id2Desc( id ) );
-                    iAlbumIds->AppendL( Id2Desc( id ) ); // for later usage
-                    }
-                CleanupStack::PopAndDestroy( medias );
-                }
-            }
-        else
-            {
-            __LOG( "getting single item" );
-            const TDesC& title = iMedia->ValueText(
-                KMPXMediaGeneralTitle );
-            __LOG1( "Title: %S", &title );
-            TMPXItemId id = *iMedia->Value<TMPXItemId>(
-                KMPXMediaGeneralId );
-            aAlbumNames.AppendL( title );
-            iAlbumNames->AppendL( title ); // for later usage
-            aAlbumIds.AppendL( Id2Desc( id ) );
-            iAlbumIds->AppendL( Id2Desc( id ) ); // for later usage
-            }
-        delete iMedia;
-        iMedia = 0;
-        }
-
-    __LOG( "CUPnPAlbumServices::ListAlbumsL -End" );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::OpenAlbumL
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUPnPAlbumServices::OpenAlbumL(
-    const TDesC& aAlbumId,
-    CDesCArray& aContentMedia )
-
-    {
-    
-
-    __LOG1( "CUPnPAlbumServices::OpenAlbumL(%S)", &aAlbumId );
-    
-  
-    if( iStatus != KErrNone)
-        {
-        __LOG1( "CUPnPAlbumServices::OpenAlbumL iStatus %d return", iStatus );
-        return;
-        }
-        
-    CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
-    CleanupStack::PushL( path );   
-    path->AppendL( Desc2Id( aAlbumId ) );
-
-    iCollectionUtility->Collection().OpenL( *path );
- 	CleanupStack::PopAndDestroy( path );
-
- 	// Wait until signalled to proceed
-    iWait->Start();
-
- 	if( iStatus != KErrNone )
-        {
-        // Open album failed.
-        User::Leave( iStatus );
-        }
-
-    CMPXCollectionPath* mediaPath = iCollectionUtility->Collection().PathL();
-    CleanupStack::PushL( mediaPath );
-    mediaPath->SelectAllL();
-    
-    RArray<TMPXAttribute> attrs;
-    CleanupClosePushL( attrs );
-    attrs.Append( KMPXMediaGeneralUri );
-
-    // Get metadata of given album. Callback to HandleCollectionMediaL
-    iCollectionUtility->Collection().MediaL( *mediaPath, attrs.Array() );
-    CleanupStack::PopAndDestroy( &attrs );
-    CleanupStack::PopAndDestroy( mediaPath );
-
-    // Wait until signalled to proceed
-    iWait->Start();
-
-    if( iStatus != KErrNone )
-        {
-        if( iStatus == KErrNotFound )
-            {
-            // Album is empty
-            __LOG( "ListAlbumsL: Album is empty" );
-            return;
-            }
-        else // Some other problem
-            {
-            User::Leave( iStatus );
-            }
-        }
-
-    if ( iMedia != 0 )
-        {
-        __LOG( "CUPnPAlbumServices::iMedia exist! ");
-        TMPXAttribute mediaArrayAttr( KMPXMediaIdContainer,
-            EMPXMediaArrayContents );
-
-        // Check if there is more than one item in album
-        if( iMedia->IsSupported( mediaArrayAttr ) )
-            {
-            __LOG("getting album array");
-            CMPXMediaArray* medias = iMedia->ValueCObjectL<CMPXMediaArray>(
-                mediaArrayAttr );
-
-            if( medias )
-                {
-                __LOG( "CUPnPAlbumServices::album array exist! ");
-                CleanupStack::PushL( medias );
-                // Album count
-                TInt count = medias->Count();        
-                __LOG1( "Album count=%d", count );
-
-                for( TInt i = 0; i < count; ++i )
-                    {
-                    __LOG2( "accessing album: item %d of %d",i, count );
-                    const CMPXMedia* entry = (*medias)[i];
-                    const TDesC& uri = entry->ValueText(
-                        KMPXMediaGeneralUri );
-                    __LOG1( "Item uri:[%S]", &uri );
-                    aContentMedia.AppendL( entry->ValueText(
-                        KMPXMediaGeneralUri ) );
-                    }
-                 CleanupStack::PopAndDestroy( medias );
-                 }
-            }
-         else // Handle single item
-            {
-            __LOG("getting single item");
-            const TDesC& uri = iMedia->ValueText( KMPXMediaGeneralUri );
-            __LOG1( "Item uri:[%S]", &uri );
-            aContentMedia.AppendL( iMedia->ValueText( KMPXMediaGeneralUri ) );
-            }
-            
-        delete iMedia;
-        iMedia = 0;
-        }
-    __LOG( "CUPnPAlbumServices::OpenAlbumL - End ");
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::IsValidAlbumL
-// --------------------------------------------------------------------------
-//
-EXPORT_C TBool CUPnPAlbumServices::IsValidAlbumL(
-    const TDesC& aAlbumName )
-    {
-    TBool found = EFalse;
-
-    __LOG1( "IsValidAlbumL(%S)", &aAlbumName );
-    
-    if( iStatus != KErrNone)
-        {
-        __LOG1( "CUPnPAlbumServices::IsValidAlbumL iStatus %d return", iStatus );
-        return EFalse;
-        }
-        
-    // Check if already listed
-    if( iAlbumNames->Count() > 0 )
-        {
-        __LOG( "CUPnPAlbumServices::IsValidAlbumL: Already fetched." );
-        TInt count = iAlbumNames->Count();
-        __LOG1( "Album count=%d", count );
-        for( TInt i = 0; i < count; i++ )
-            {
-            if( aAlbumName.Compare( iAlbumNames->MdcaPoint(i) ) == 0 )
-                {
-                __LOG( "IsValidAlbum -> True ");
-                i = count;
-                found = ETrue;
-                }
-            }
-        __LOG( "CUPnPAlbumServices::IsValidAlbumL: Return." );
-        return found;
-        }
-
-    // List albums
-    CMPXCollectionPath* mediaPath = iCollectionUtility->Collection().PathL();
-    CleanupStack::PushL( mediaPath );
-    mediaPath->SelectAllL();
-
-    RArray<TMPXAttribute> attrs;
-    CleanupClosePushL( attrs );
-    attrs.AppendL( KMPXMediaGeneralId );
-    attrs.AppendL( KMPXMediaGeneralTitle );
-
-    // Get album data. Callback to HandleCollectionMediaL
-    iCollectionUtility->Collection().MediaL( *mediaPath, attrs.Array() );
-    CleanupStack::PopAndDestroy( &attrs );
-    CleanupStack::PopAndDestroy( mediaPath );
-
-    // Wait until signalled to proceed
-    iWait->Start();
-
-    if( iStatus != KErrNone )
-        {
-        if( iStatus == KErrNotFound )
-            {
-            // No albums available
-            __LOG( "ListAlbumsL: No albums available" );
-            return EFalse;
-            }
-        else // Some other problem
-            {
-            User::Leave( iStatus );
-            }
-        }
-
-    if ( iMedia != 0 )
-        {
-        __LOG( "CUPnPAlbumServices::iMedia exist! ");
-        TMPXAttribute mediaArrayAttr( KMPXMediaIdContainer,
-            EMPXMediaArrayContents );
-                
-        if( iMedia->IsSupported( mediaArrayAttr ) )
-            {
-            __LOG("getting album array");
-            CMPXMediaArray* medias = iMedia->ValueCObjectL<CMPXMediaArray>(
-                mediaArrayAttr );
-
-            if( medias )
-                {
-                __LOG( "CUPnPAlbumServices::album array exist! ");
-                CleanupStack::PushL( medias );
-                // Album count
-                TInt count = medias->Count();        
-                __LOG1( "Album count=%d", count );
-
-                for( TInt i = 0; i < count; ++i )
-                    {
-                    const CMPXMedia* entry = (*medias)[i];
-                    if( aAlbumName.Compare( 
-                        entry->ValueText( KMPXMediaGeneralTitle ) ) == 0 )
-                        {
-                        __LOG( "IsValidAlbum -> True ");
-                        found = ETrue;
-                        break;
-                        }
-                    }
-                CleanupStack::PopAndDestroy( medias );
-                }
-            }
-        else
-            {
-            __LOG( "iMedia->IsSupported = False!" );
-            }
-        delete iMedia;
-        iMedia = 0;
-        }
-
-    __LOG( "CUPnPAlbumServices::IsValidAlbumL - End ");
-    return found;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::~CUPnPAlbumServices
-// Destructor.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUPnPAlbumServices::~CUPnPAlbumServices()
-    {
-    __LOG( "CUPnPAlbumServices::~CUPnPAlbumServices" );
-    iAlbumNames->Reset();
-    delete iAlbumNames;
-    iAlbumNames = 0;
-    iAlbumIds->Reset();
-    delete iAlbumIds;
-    iAlbumIds = 0;
-    
-    if ( iCollectionUtility )
-        {
-        iCollectionUtility->Close();
-        iCollectionUtility = 0;
-        }
-
-    delete iWait;
-    iWait = 0;
-
-    if( iMedia )
-        {
-        delete iMedia;
-        iMedia = 0;
-        }
-    }
-
-
-// Methods from MMPXCollectionObserver:
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::HandleCollectionMessage
-// Callback for Collection->OpenL()
-// --------------------------------------------------------------------------
-// 
-void CUPnPAlbumServices::HandleCollectionMessage( CMPXMessage* aMsg,
-    TInt aErr )
-
-    {
-    __LOG1( "HandleCollectionMessage: err=%d", aErr );
-	if( aErr == KErrNone)
-	    {
-	    TRAPD( error, DoHandleCollectionMessageL( aMsg ) );
-        if ( error != KErrNone )
-            {
-            __LOG1( "DoHandleCollectionMessageL: leave with %d", error );
-            iStatus = error;
-            iWait->AsyncStop();
-            }
-	    }
-	 else
-	    {
-	    iStatus = aErr;
-	    iWait->AsyncStop();
-	    }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::HandleCollectionMediaL
-// --------------------------------------------------------------------------
-//
-
-void CUPnPAlbumServices::HandleCollectionMediaL( const CMPXMedia& aMedia,
-    TInt aError )
-
-    {
-    __LOG1( "CUPnPAlbumServices::HandleCollectionMediaL: err=%d", aError );
-    if( aError == KErrNone )
-        {                    
-        // delete if already exist
-        if( iMedia )
-            {
-            delete iMedia;
-            iMedia = 0;
-            }
-        iMedia = CMPXMedia::NewL( aMedia );
-        }
-
-    iStatus = aError;
-    iWait->AsyncStop();
-
-    __LOG("CUPnPAlbumServices::HandleCollectionMediaL - End");
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::HandleOpenL
-// Callback for Collection->OpenL(path, attrs)
-// --------------------------------------------------------------------------
-// 
-void CUPnPAlbumServices::HandleOpenL( const CMPXMedia& /*aEntries*/,
-    TInt /*aIndex*/, TBool /*aComplete*/, TInt aError )
-    {
-    __LOG1( "CUPnPAlbumServices::HandleOpenL %d", aError);
-    
-    if( aError != KErrNone)
-        {
-        iStatus = aError;
-        iWait->AsyncStop();
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::HandleOpenL
-// --------------------------------------------------------------------------
-// 
-void CUPnPAlbumServices::HandleOpenL( 
-    const CMPXCollectionPlaylist& /*aPlaylist*/, TInt aError )
-    {
-    __LOG1( "CUPnPAlbumServices::HandleOpenL %d", aError);
-    
-    if( aError != KErrNone)
-        {
-        iStatus = aError;
-        iWait->AsyncStop();
-        }
-    }
-
-// --------------------------------------------------------------------------
-// Converts an ID from TMPXItemId form to descriptor form.
-// --------------------------------------------------------------------------
-//
-const TDesC& CUPnPAlbumServices::Id2Desc( const TMPXItemId& aId )
-    {  
-    iTempBuffer.Num( aId );
-    return iTempBuffer;
-    }
-
-// --------------------------------------------------------------------------
-// Converts an ID from descriptor form to TMPXItemId form.
-// --------------------------------------------------------------------------
-//
-TMPXItemId CUPnPAlbumServices::Desc2Id( const TDesC& aDesc )
-    {
-    TLex convert( aDesc );
-    TUint temp;
-    convert.Val( temp, EDecimal );
-    TMPXItemId id(temp);
-    return id;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPAlbumServices::DoHandleCollectionMessageL
-// --------------------------------------------------------------------------
-//
-void CUPnPAlbumServices::DoHandleCollectionMessageL( CMPXMessage* aMsg )
-    {
-    __LOG( "CUPnPAlbumServices::DoHandleCollectionMessageL" );
-
-    if( aMsg && aMsg->IsSupported(KMPXMessageGeneralEvent ) &&
-			aMsg->IsSupported(KMPXMessageGeneralType ) )
-        {
-	    TInt event( *aMsg->Value<TInt>( KMPXMessageGeneralEvent ) );
-	    TInt type( *aMsg->Value<TInt>( KMPXMessageGeneralType ) );
-	    TInt data( *aMsg->Value<TInt>( KMPXMessageGeneralData ) );
-	    
-	    __LOG1("Event: %d", event );
-	    __LOG1("Type: %d", type );
-	    __LOG1("Data: %d", data );
-	     	        
-	    switch ( event )
-            {
-            case TMPXCollectionMessage::EPathChanged:
-                {
-                __LOG( "TMPXCollectionMessage::EPathChanged" );
-                if( type == EMcPathChangedByOpen )
-                    {
-                    __LOG( " Type: EMcPathChangedByOpen " );
-                    // Album collection is ready for use
-                    iStatus = KErrNone;
-                    iWait->AsyncStop();
-                    }
-                }    
-            break;
-            default:
-                {
-                // do nothing
-                } 
-                break;
-            }
-	   }
-    }
-
-
+/*
+* Copyright (c) 2006-2007 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:  provides album handling services for UPnP framework
+*
+*/
+
+#include "upnpapplicationcrkeys.h" // KCRUidUPnPApplication
+#include <mpxcollectionutility.h>
+#include <mpxcollectionframeworkdefs.h> // main attribute keys
+#include <mpxmessagegeneraldefs.h>
+#include <mpxmediageneraldefs.h> // commonly used attribute keys
+#include <mpxmediacontainerdefs.h> // container-specific attribute keys
+#include <mpxcollectionpath.h>
+#include <mpxcollectionmessage.h>
+#include <mpxmediadrmdefs.h>
+
+#include <mpxmedia.h>
+#include <mpxmediaarray.h>
+
+#include "upnpalbumservices.h" // ourselves
+
+// debug
+_LIT16( KComponentLogfile, "musicadapter.txt" );
+#include "upnplog.h"
+
+// Constant definitions
+#define KAlbumsCollectionUid 0x20007197 // album plugin uid
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CUPnPAlbumServices::NewL
+// 1st phase constructor.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CUPnPAlbumServices* CUPnPAlbumServices::NewL()
+    {
+    __LOG( "CUPnPAlbumServices::NewL" );
+
+    CUPnPAlbumServices* self = new(ELeave) CUPnPAlbumServices();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::CUPnPAlbumServices
+// Default constructor.
+// --------------------------------------------------------------------------
+//    
+CUPnPAlbumServices::CUPnPAlbumServices() : iStatus( KErrNone )
+    {
+    // None.
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::ConstructL
+// 2nd phase constructor
+// --------------------------------------------------------------------------
+//    
+void CUPnPAlbumServices::ConstructL()
+    {
+    __LOG( "CUPnPAlbumServices::ConstructL" );
+    iAlbumNames = new (ELeave) CDesCArrayFlat(5);
+    iAlbumIds = new (ELeave) CDesCArrayFlat(5);
+
+    iCollectionUtility = MMPXCollectionUtility::NewL(
+        (MMPXCollectionObserver*)this, KMcModePlaylist );
+
+    // Open album collection plugin. Callback to HandleCollectionMessage.
+    CMPXCollectionPath* path = CMPXCollectionPath::NewL();
+    CleanupStack::PushL( path );
+    path->AppendL( KAlbumsCollectionUid );
+    iCollectionUtility->Collection().OpenL( *path );
+ 	CleanupStack::PopAndDestroy( path ); 
+
+    // Wait until signalled to proceed
+    iWait = new (ELeave) CActiveSchedulerWait();    
+    iWait->Start();     
+
+    __LOG1( "CUPnPAlbumServices::ConstructL - End %d", iStatus );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::ListAlbumsL
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUPnPAlbumServices::ListAlbumsL(
+    CDesCArray& aAlbumIds,
+    CDesCArray& aAlbumNames )
+    {
+    __LOG( "CUPnPAlbumServices::ListAlbumsL" );
+    
+    // Check if already listed
+    
+    if( iStatus != KErrNone)
+        {
+        __LOG1( "CUPnPAlbumServices::ListAlbumsL iStatus %d return", iStatus );
+        return;
+        }
+    
+    if( iAlbumNames->Count() > 0 && iAlbumIds->Count() > 0 )
+        {
+        __LOG( "CUPnPAlbumServices::ListAlbumsL: Already fetched." );
+        // Copy from member
+        TInt count = iAlbumNames->Count();
+        __LOG1( "Album count=%d", count );
+        for( TInt i = 0; i < count; i++ )
+            {
+            aAlbumNames.AppendL( iAlbumNames->MdcaPoint(i) );
+            aAlbumIds.AppendL( iAlbumIds->MdcaPoint(i) );
+            }
+        __LOG( "CUPnPAlbumServices::ListAlbumsL: Return." );
+        return;
+        }
+
+    CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
+    CleanupStack::PushL( path );
+    path->SelectAllL();
+
+    RArray<TMPXAttribute> attrs;
+    CleanupClosePushL( attrs );
+    attrs.Append( KMPXMediaGeneralId );
+    attrs.Append( KMPXMediaGeneralTitle );
+
+    // Get album list from collection. Callback to HandleCollectionMediaL
+    iCollectionUtility->Collection().MediaL( *path, attrs.Array() );
+    CleanupStack::PopAndDestroy( &attrs );
+    CleanupStack::PopAndDestroy( path );
+
+    // Wait until signalled to proceed
+    iWait->Start();
+
+    if( iStatus != KErrNone )
+        {
+        if( iStatus == KErrNotFound )
+            {
+            // No albums available.
+            __LOG( "ListAlbumsL: No albums available!" );
+            return;
+            }
+        else // Some other problem
+            {
+            User::Leave( iStatus );
+            }
+        }
+
+    if ( iMedia != 0 )
+        {
+        TMPXAttribute mediaArrayAttr( KMPXMediaIdContainer,
+            EMPXMediaArrayContents );
+                
+        if( iMedia->IsSupported( mediaArrayAttr ) )
+            {
+            __LOG("getting album array");
+            CMPXMediaArray* medias = iMedia->ValueCObjectL<CMPXMediaArray>(
+                mediaArrayAttr );
+
+            if( medias )
+                {
+                CleanupStack::PushL( medias );
+                // Album count
+                TInt count = medias->Count();        
+                __LOG1( "Album count=%d", count );
+
+                for( TInt i = 0; i < count; ++i )
+                    {
+                    const CMPXMedia* entry = (*medias)[i];
+                    const TDesC& title = entry->ValueText(
+                        KMPXMediaGeneralTitle );
+                    __LOG3( "Title: %d/%d [%S]",i, count, &title );
+                    TMPXItemId id = *entry->Value<TMPXItemId>(
+                        KMPXMediaGeneralId );
+                    aAlbumNames.AppendL( title );
+                    iAlbumNames->AppendL( title ); // for later usage
+                    aAlbumIds.AppendL( Id2Desc( id ) );
+                    iAlbumIds->AppendL( Id2Desc( id ) ); // for later usage
+                    }
+                CleanupStack::PopAndDestroy( medias );
+                }
+            }
+        else
+            {
+            __LOG( "getting single item" );
+            const TDesC& title = iMedia->ValueText(
+                KMPXMediaGeneralTitle );
+            __LOG1( "Title: %S", &title );
+            TMPXItemId id = *iMedia->Value<TMPXItemId>(
+                KMPXMediaGeneralId );
+            aAlbumNames.AppendL( title );
+            iAlbumNames->AppendL( title ); // for later usage
+            aAlbumIds.AppendL( Id2Desc( id ) );
+            iAlbumIds->AppendL( Id2Desc( id ) ); // for later usage
+            }
+        delete iMedia;
+        iMedia = 0;
+        }
+
+    __LOG( "CUPnPAlbumServices::ListAlbumsL -End" );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::OpenAlbumL
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUPnPAlbumServices::OpenAlbumL(
+    const TDesC& aAlbumId,
+    CDesCArray& aContentMedia )
+
+    {
+    
+
+    __LOG1( "CUPnPAlbumServices::OpenAlbumL(%S)", &aAlbumId );
+    
+  
+    if( iStatus != KErrNone)
+        {
+        __LOG1( "CUPnPAlbumServices::OpenAlbumL iStatus %d return", iStatus );
+        return;
+        }
+        
+    CMPXCollectionPath* path = iCollectionUtility->Collection().PathL();
+    CleanupStack::PushL( path );   
+    path->AppendL( Desc2Id( aAlbumId ) );
+
+    iCollectionUtility->Collection().OpenL( *path );
+ 	CleanupStack::PopAndDestroy( path );
+
+ 	// Wait until signalled to proceed
+    iWait->Start();
+
+ 	if( iStatus != KErrNone )
+        {
+        // Open album failed.
+        User::Leave( iStatus );
+        }
+
+    CMPXCollectionPath* mediaPath = iCollectionUtility->Collection().PathL();
+    CleanupStack::PushL( mediaPath );
+    mediaPath->SelectAllL();
+    
+    RArray<TMPXAttribute> attrs;
+    CleanupClosePushL( attrs );
+    attrs.Append( KMPXMediaGeneralUri );
+
+    // Get metadata of given album. Callback to HandleCollectionMediaL
+    iCollectionUtility->Collection().MediaL( *mediaPath, attrs.Array() );
+    CleanupStack::PopAndDestroy( &attrs );
+    CleanupStack::PopAndDestroy( mediaPath );
+
+    // Wait until signalled to proceed
+    iWait->Start();
+
+    if( iStatus != KErrNone )
+        {
+        if( iStatus == KErrNotFound )
+            {
+            // Album is empty
+            __LOG( "ListAlbumsL: Album is empty" );
+            return;
+            }
+        else // Some other problem
+            {
+            User::Leave( iStatus );
+            }
+        }
+
+    if ( iMedia != 0 )
+        {
+        __LOG( "CUPnPAlbumServices::iMedia exist! ");
+        TMPXAttribute mediaArrayAttr( KMPXMediaIdContainer,
+            EMPXMediaArrayContents );
+
+        // Check if there is more than one item in album
+        if( iMedia->IsSupported( mediaArrayAttr ) )
+            {
+            __LOG("getting album array");
+            CMPXMediaArray* medias = iMedia->ValueCObjectL<CMPXMediaArray>(
+                mediaArrayAttr );
+
+            if( medias )
+                {
+                __LOG( "CUPnPAlbumServices::album array exist! ");
+                CleanupStack::PushL( medias );
+                // Album count
+                TInt count = medias->Count();        
+                __LOG1( "Album count=%d", count );
+
+                for( TInt i = 0; i < count; ++i )
+                    {
+                    __LOG2( "accessing album: item %d of %d",i, count );
+                    const CMPXMedia* entry = (*medias)[i];
+                    const TDesC& uri = entry->ValueText(
+                        KMPXMediaGeneralUri );
+                    __LOG1( "Item uri:[%S]", &uri );
+                    aContentMedia.AppendL( entry->ValueText(
+                        KMPXMediaGeneralUri ) );
+                    }
+                 CleanupStack::PopAndDestroy( medias );
+                 }
+            }
+         else // Handle single item
+            {
+            __LOG("getting single item");
+            const TDesC& uri = iMedia->ValueText( KMPXMediaGeneralUri );
+            __LOG1( "Item uri:[%S]", &uri );
+            aContentMedia.AppendL( iMedia->ValueText( KMPXMediaGeneralUri ) );
+            }
+            
+        delete iMedia;
+        iMedia = 0;
+        }
+    __LOG( "CUPnPAlbumServices::OpenAlbumL - End ");
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::IsValidAlbumL
+// --------------------------------------------------------------------------
+//
+EXPORT_C TBool CUPnPAlbumServices::IsValidAlbumL(
+    const TDesC& aAlbumName )
+    {
+    TBool found = EFalse;
+
+    __LOG1( "IsValidAlbumL(%S)", &aAlbumName );
+    
+    if( iStatus != KErrNone)
+        {
+        __LOG1( "CUPnPAlbumServices::IsValidAlbumL iStatus %d return", iStatus );
+        return EFalse;
+        }
+        
+    // Check if already listed
+    if( iAlbumNames->Count() > 0 )
+        {
+        __LOG( "CUPnPAlbumServices::IsValidAlbumL: Already fetched." );
+        TInt count = iAlbumNames->Count();
+        __LOG1( "Album count=%d", count );
+        for( TInt i = 0; i < count; i++ )
+            {
+            if( aAlbumName.Compare( iAlbumNames->MdcaPoint(i) ) == 0 )
+                {
+                __LOG( "IsValidAlbum -> True ");
+                i = count;
+                found = ETrue;
+                }
+            }
+        __LOG( "CUPnPAlbumServices::IsValidAlbumL: Return." );
+        return found;
+        }
+
+    // List albums
+    CMPXCollectionPath* mediaPath = iCollectionUtility->Collection().PathL();
+    CleanupStack::PushL( mediaPath );
+    mediaPath->SelectAllL();
+
+    RArray<TMPXAttribute> attrs;
+    CleanupClosePushL( attrs );
+    attrs.Append( KMPXMediaGeneralId );
+    attrs.Append( KMPXMediaGeneralTitle );
+
+    // Get album data. Callback to HandleCollectionMediaL
+    iCollectionUtility->Collection().MediaL( *mediaPath, attrs.Array() );
+    CleanupStack::PopAndDestroy( &attrs );
+    CleanupStack::PopAndDestroy( mediaPath );
+
+    // Wait until signalled to proceed
+    iWait->Start();
+
+    if( iStatus != KErrNone )
+        {
+        if( iStatus == KErrNotFound )
+            {
+            // No albums available
+            __LOG( "ListAlbumsL: No albums available" );
+            return EFalse;
+            }
+        else // Some other problem
+            {
+            User::Leave( iStatus );
+            }
+        }
+
+    if ( iMedia != 0 )
+        {
+        __LOG( "CUPnPAlbumServices::iMedia exist! ");
+        TMPXAttribute mediaArrayAttr( KMPXMediaIdContainer,
+            EMPXMediaArrayContents );
+                
+        if( iMedia->IsSupported( mediaArrayAttr ) )
+            {
+            __LOG("getting album array");
+            CMPXMediaArray* medias = iMedia->ValueCObjectL<CMPXMediaArray>(
+                mediaArrayAttr );
+
+            if( medias )
+                {
+                __LOG( "CUPnPAlbumServices::album array exist! ");
+                CleanupStack::PushL( medias );
+                // Album count
+                TInt count = medias->Count();        
+                __LOG1( "Album count=%d", count );
+
+                for( TInt i = 0; i < count; ++i )
+                    {
+                    const CMPXMedia* entry = (*medias)[i];
+                    if( aAlbumName.Compare( 
+                        entry->ValueText( KMPXMediaGeneralTitle ) ) == 0 )
+                        {
+                        __LOG( "IsValidAlbum -> True ");
+                        found = ETrue;
+                        break;
+                        }
+                    }
+                CleanupStack::PopAndDestroy( medias );
+                }
+            }
+        else
+            {
+            __LOG( "iMedia->IsSupported = False!" );
+            }
+        delete iMedia;
+        iMedia = 0;
+        }
+
+    __LOG( "CUPnPAlbumServices::IsValidAlbumL - End ");
+    return found;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::~CUPnPAlbumServices
+// Destructor.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUPnPAlbumServices::~CUPnPAlbumServices()
+    {
+    __LOG( "CUPnPAlbumServices::~CUPnPAlbumServices" );
+    iAlbumNames->Reset();
+    delete iAlbumNames;
+    iAlbumNames = 0;
+    iAlbumIds->Reset();
+    delete iAlbumIds;
+    iAlbumIds = 0;
+    
+    if ( iCollectionUtility )
+        {
+        iCollectionUtility->Close();
+        iCollectionUtility = 0;
+        }
+
+    delete iWait;
+    iWait = 0;
+
+    if( iMedia )
+        {
+        delete iMedia;
+        iMedia = 0;
+        }
+    }
+
+
+// Methods from MMPXCollectionObserver:
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::HandleCollectionMessage
+// Callback for Collection->OpenL()
+// --------------------------------------------------------------------------
+// 
+void CUPnPAlbumServices::HandleCollectionMessage( CMPXMessage* aMsg,
+    TInt aErr )
+
+    {
+    __LOG1( "HandleCollectionMessage: err=%d", aErr );
+	if( aErr == KErrNone)
+	    {
+	    TRAPD( error, DoHandleCollectionMessageL( aMsg ) );
+        if ( error != KErrNone )
+            {
+            __LOG1( "DoHandleCollectionMessageL: leave with %d", error );
+            iStatus = error;
+            iWait->AsyncStop();
+            }
+	    }
+	 else
+	    {
+	    iStatus = aErr;
+	    iWait->AsyncStop();
+	    }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::HandleCollectionMediaL
+// --------------------------------------------------------------------------
+//
+
+void CUPnPAlbumServices::HandleCollectionMediaL( const CMPXMedia& aMedia,
+    TInt aError )
+
+    {
+    __LOG1( "CUPnPAlbumServices::HandleCollectionMediaL: err=%d", aError );
+    if( aError == KErrNone )
+        {                    
+        // delete if already exist
+        if( iMedia )
+            {
+            delete iMedia;
+            iMedia = 0;
+            }
+        iMedia = CMPXMedia::NewL( aMedia );
+        }
+
+    iStatus = aError;
+    iWait->AsyncStop();
+
+    __LOG("CUPnPAlbumServices::HandleCollectionMediaL - End");
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::HandleOpenL
+// Callback for Collection->OpenL(path, attrs)
+// --------------------------------------------------------------------------
+// 
+void CUPnPAlbumServices::HandleOpenL( const CMPXMedia& /*aEntries*/,
+    TInt /*aIndex*/, TBool /*aComplete*/, TInt aError )
+    {
+    __LOG1( "CUPnPAlbumServices::HandleOpenL %d", aError);
+    
+    if( aError != KErrNone)
+        {
+        iStatus = aError;
+        iWait->AsyncStop();
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::HandleOpenL
+// --------------------------------------------------------------------------
+// 
+void CUPnPAlbumServices::HandleOpenL( 
+    const CMPXCollectionPlaylist& /*aPlaylist*/, TInt aError )
+    {
+    __LOG1( "CUPnPAlbumServices::HandleOpenL %d", aError);
+    
+    if( aError != KErrNone)
+        {
+        iStatus = aError;
+        iWait->AsyncStop();
+        }
+    }
+
+// --------------------------------------------------------------------------
+// Converts an ID from TMPXItemId form to descriptor form.
+// --------------------------------------------------------------------------
+//
+const TDesC& CUPnPAlbumServices::Id2Desc( const TMPXItemId& aId )
+    {  
+    iTempBuffer.Num( aId );
+    return iTempBuffer;
+    }
+
+// --------------------------------------------------------------------------
+// Converts an ID from descriptor form to TMPXItemId form.
+// --------------------------------------------------------------------------
+//
+TMPXItemId CUPnPAlbumServices::Desc2Id( const TDesC& aDesc )
+    {
+    TLex convert( aDesc );
+    TUint temp;
+    convert.Val( temp, EDecimal );
+    TMPXItemId id(temp);
+    return id;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPAlbumServices::DoHandleCollectionMessageL
+// --------------------------------------------------------------------------
+//
+void CUPnPAlbumServices::DoHandleCollectionMessageL( CMPXMessage* aMsg )
+    {
+    __LOG( "CUPnPAlbumServices::DoHandleCollectionMessageL" );
+
+    if( aMsg && aMsg->IsSupported(KMPXMessageGeneralEvent ) &&
+			aMsg->IsSupported(KMPXMessageGeneralType ) )
+        {
+	    TInt event( *aMsg->Value<TInt>( KMPXMessageGeneralEvent ) );
+	    TInt type( *aMsg->Value<TInt>( KMPXMessageGeneralType ) );
+	    TInt data( *aMsg->Value<TInt>( KMPXMessageGeneralData ) );
+	    
+	    __LOG1("Event: %d", event );
+	    __LOG1("Type: %d", type );
+	    __LOG1("Data: %d", data );
+	     	        
+	    switch ( event )
+            {
+            case TMPXCollectionMessage::EPathChanged:
+                {
+                __LOG( "TMPXCollectionMessage::EPathChanged" );
+                if( type == EMcPathChangedByOpen )
+                    {
+                    __LOG( " Type: EMcPathChangedByOpen " );
+                    // Album collection is ready for use
+                    iStatus = KErrNone;
+                    iWait->AsyncStop();
+                    }
+                }    
+            break;
+            default:
+                {
+                // do nothing
+                } 
+                break;
+            }
+	   }
+    }
+
+
--- a/upnpframework/upnputilities/BWINS/upnputilitiesU.DEF	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/BWINS/upnputilitiesU.DEF	Mon Nov 01 12:37:49 2010 +0200
@@ -1,40 +1,50 @@
-EXPORTS
-	??1CUPnPMetaDataUtility@@UAE@XZ @ 1 NONAME ; CUPnPMetaDataUtility::~CUPnPMetaDataUtility(void)
-	?AddResElementL@UpnpCdsResElementUtility@@SAXAAVCUpnpItem@@ABVTDesC16@@@Z @ 2 NONAME ; void UpnpCdsResElementUtility::AddResElementL(class CUpnpItem &, class TDesC16 const &)
-	?Album@CUPnPMetaDataUtility@@QBEABVTDesC16@@XZ @ 3 NONAME ; class TDesC16 const & CUPnPMetaDataUtility::Album(void) const
-	?Artist@CUPnPMetaDataUtility@@QBEABVTDesC16@@XZ @ 4 NONAME ; class TDesC16 const & CUPnPMetaDataUtility::Artist(void) const
-	?CreateItemFromFileL@UPnPMetadataFetcher@@SAPAVCUpnpItem@@ABVTDesC16@@@Z @ 5 NONAME ; class CUpnpItem * UPnPMetadataFetcher::CreateItemFromFileL(class TDesC16 const &)
-	?CreateItemFromFileLC@UPnPMetadataFetcher@@SAPAVCUpnpItem@@ABVTDesC16@@@Z @ 6 NONAME ; class CUpnpItem * UPnPMetadataFetcher::CreateItemFromFileLC(class TDesC16 const &)
-	?Date@CUPnPMetaDataUtility@@QBEABVTDesC16@@XZ @ 7 NONAME ; class TDesC16 const & CUPnPMetaDataUtility::Date(void) const
-	?DeleteTempFilesL@UPnPCommonUtils@@SAXXZ @ 8 NONAME ; void UPnPCommonUtils::DeleteTempFilesL(void)
-	?DesC8ToInt@UPnPCommonUtils@@SAHABVTDesC8@@@Z @ 9 NONAME ; int UPnPCommonUtils::DesC8ToInt(class TDesC8 const &)
-	?FetchMetadataL@UPnPMetadataFetcher@@SAXAAVCUpnpObject@@ABVTDesC16@@@Z @ 10 NONAME ; void UPnPMetadataFetcher::FetchMetadataL(class CUpnpObject &, class TDesC16 const &)
-	?FetchMetadataL@UPnPMetadataFetcher@@SAXAAVCUpnpObject@@ABVTDesC16@@ABVTDesC8@@@Z @ 11 NONAME ; void UPnPMetadataFetcher::FetchMetadataL(class CUpnpObject &, class TDesC16 const &, class TDesC8 const &)
-	?FindContainerByTitle@UPnPCommonUtils@@SAPAVCUpnpContainer@@ABVCUpnpContainerList@@ABVTDesC8@@@Z @ 12 NONAME ; class CUpnpContainer * UPnPCommonUtils::FindContainerByTitle(class CUpnpContainerList const &, class TDesC8 const &)
-	?Genre@CUPnPMetaDataUtility@@QBEABVTDesC16@@XZ @ 13 NONAME ; class TDesC16 const & CUPnPMetaDataUtility::Genre(void) const
-	?GetMimeTypeByExtensionL@UPnPCommonUtils@@SAPAVHBufC8@@ABVTDesC16@@@Z @ 14 NONAME ; class HBufC8 * UPnPCommonUtils::GetMimeTypeByExtensionL(class TDesC16 const &)
-	?IntToDesC8LC@UPnPCommonUtils@@SAPAVHBufC8@@ABH@Z @ 15 NONAME ; class HBufC8 * UPnPCommonUtils::IntToDesC8LC(int const &)
-	?IsPlaylistContainerL@UPnPCommonUtils@@SAHABVCUpnpObject@@@Z @ 16 NONAME ; int UPnPCommonUtils::IsPlaylistContainerL(class CUpnpObject const &)
-	?IsUriAbsolute@UpnpCdsResElementUtility@@SAHABVTDesC8@@@Z @ 17 NONAME ; int UpnpCdsResElementUtility::IsUriAbsolute(class TDesC8 const &)
-	?LoadMetaDataL@CUPnPMetaDataUtility@@QAEXABVTDesC16@@@Z @ 18 NONAME ; void CUPnPMetaDataUtility::LoadMetaDataL(class TDesC16 const &)
-	?MemoryCardStateL@UPnPCommonUtils@@SAHXZ @ 19 NONAME ; int UPnPCommonUtils::MemoryCardStateL(void)
-	?NewL@CUPnPConnectionMonitor@@SAPAV1@AAVMUPnPConnectionMonitorObserver@@H@Z @ 20 NONAME ; class CUPnPConnectionMonitor * CUPnPConnectionMonitor::NewL(class MUPnPConnectionMonitorObserver &, int)
-	?NewL@CUPnPMetaDataUtility@@SAPAV1@XZ @ 21 NONAME ; class CUPnPMetaDataUtility * CUPnPMetaDataUtility::NewL(void)
-	?RenameFileL@UPnPCommonUtils@@SAPAVHBufC16@@ABVTDesC16@@@Z @ 22 NONAME ; class HBufC16 * UPnPCommonUtils::RenameFileL(class TDesC16 const &)
-	?ReplaceIllegalFilenameCharactersL@UPnPCommonUtils@@SAPAVHBufC16@@ABVTDesC16@@@Z @ 23 NONAME ; class HBufC16 * UPnPCommonUtils::ReplaceIllegalFilenameCharactersL(class TDesC16 const &)
-	?ReplaceIllegalFilenameCharactersL@UPnPCommonUtils@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 24 NONAME ; class HBufC8 * UPnPCommonUtils::ReplaceIllegalFilenameCharactersL(class TDesC8 const &)
-	?ReplacePlaceHolderInURIL@UPnPCommonUtils@@SAXAAVCUpnpItem@@ABVTInetAddr@@@Z @ 25 NONAME ; void UPnPCommonUtils::ReplacePlaceHolderInURIL(class CUpnpItem &, class TInetAddr const &)
-	?ResolveFileTypeL@UPnPCommonUtils@@SA?AW4TUPnPItemType@@ABVTDesC16@@@Z @ 26 NONAME ; enum TUPnPItemType UPnPCommonUtils::ResolveFileTypeL(class TDesC16 const &)
-	?ResolveMimeTypeL@UPnPCommonUtils@@SAPAVHBufC8@@ABVTDesC16@@@Z @ 27 NONAME ; class HBufC8 * UPnPCommonUtils::ResolveMimeTypeL(class TDesC16 const &)
-	?TTimeToUPnPDateL@UPnPCommonUtils@@SAPAVHBufC16@@VTTime@@@Z @ 28 NONAME ; class HBufC16 * UPnPCommonUtils::TTimeToUPnPDateL(class TTime)
-	?Title@CUPnPMetaDataUtility@@QBEABVTDesC16@@XZ @ 29 NONAME ; class TDesC16 const & CUPnPMetaDataUtility::Title(void) const
-	?IsAudioSupported@UPnPCommonUtils@@SAHABVTDesC8@@@Z @ 30 NONAME ; int UPnPCommonUtils::IsAudioSupported(class TDesC8 const &)
-	?IsImageSupported@UPnPCommonUtils@@SAHABVTDesC8@@@Z @ 31 NONAME ; int UPnPCommonUtils::IsImageSupported(class TDesC8 const &)
-	?IsVideoSupported@UPnPCommonUtils@@SAHABVTDesC8@@@Z @ 32 NONAME ; int UPnPCommonUtils::IsVideoSupported(class TDesC8 const &)
-	?FileExtensionByMimeTypeL@UPnPCommonUtils@@SAPAVHBufC16@@ABVTDesC8@@@Z @ 33 NONAME ; class HBufC16 * UPnPCommonUtils::FileExtensionByMimeTypeL(class TDesC8 const &)
-	?NotifyMediaGalleryL@UpnpGalleryNotifier@@SAXXZ @ 34 NONAME ; void UpnpGalleryNotifier::NotifyMediaGalleryL(void)
-	?DebugSimulateConnectionLostL@CUPnPConnectionMonitor@@SAXXZ @ 35 NONAME ; void CUPnPConnectionMonitor::DebugSimulateConnectionLostL(void)
-	?LoadTitleL@CUPnPMetaDataUtility@@QAEXABVTDesC16@@@Z @ 36 NONAME ; void CUPnPMetaDataUtility::LoadTitleL(class TDesC16 const &)
-	?FixListboxItemTextL@UPnPCommonUtils@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 37 NONAME ; class HBufC8 * UPnPCommonUtils::FixListboxItemTextL(class TDesC8 const &)
-	?NewL@CUPnPPeriodic@@SAPAV1@H@Z @ 38 NONAME ; class CUPnPPeriodic * CUPnPPeriodic::NewL(int)
-
+EXPORTS
+	??1CUPnPMetaDataUtility@@UAE@XZ @ 1 NONAME ; CUPnPMetaDataUtility::~CUPnPMetaDataUtility(void)
+	??1CUPnPPathUtility@@UAE@XZ @ 2 NONAME ; CUPnPPathUtility::~CUPnPPathUtility(void)
+	?AddResElementL@UpnpCdsResElementUtility@@SAXAAVCUpnpItem@@ABVTDesC16@@@Z @ 3 NONAME ; void UpnpCdsResElementUtility::AddResElementL(class CUpnpItem &, class TDesC16 const &)
+	?Album@CUPnPMetaDataUtility@@QBEABVTDesC16@@XZ @ 4 NONAME ; class TDesC16 const & CUPnPMetaDataUtility::Album(void) const
+	?Artist@CUPnPMetaDataUtility@@QBEABVTDesC16@@XZ @ 5 NONAME ; class TDesC16 const & CUPnPMetaDataUtility::Artist(void) const
+	?CreateCopyPathL@CUPnPPathUtility@@QBEPAVHBufC16@@ABVCUpnpItem@@ABVCUpnpElement@@H@Z @ 6 NONAME ; class HBufC16 * CUPnPPathUtility::CreateCopyPathL(class CUpnpItem const &, class CUpnpElement const &, int) const
+	?CreateCopyPathL@CUPnPPathUtility@@QBEPAVHBufC16@@ABVCUpnpItem@@ABVCUpnpElement@@HW4TDriveNumber@@@Z @ 7 NONAME ; class HBufC16 * CUPnPPathUtility::CreateCopyPathL(class CUpnpItem const &, class CUpnpElement const &, int, enum TDriveNumber) const
+	?CreateItemFromFileL@UPnPMetadataFetcher@@SAPAVCUpnpItem@@ABVTDesC16@@@Z @ 8 NONAME ; class CUpnpItem * UPnPMetadataFetcher::CreateItemFromFileL(class TDesC16 const &)
+	?CreateItemFromFileLC@UPnPMetadataFetcher@@SAPAVCUpnpItem@@ABVTDesC16@@@Z @ 9 NONAME ; class CUpnpItem * UPnPMetadataFetcher::CreateItemFromFileLC(class TDesC16 const &)
+	?Date@CUPnPMetaDataUtility@@QBEABVTDesC16@@XZ @ 10 NONAME ; class TDesC16 const & CUPnPMetaDataUtility::Date(void) const
+	?DeleteTempFilesL@UPnPCommonUtils@@SAXXZ @ 11 NONAME ; void UPnPCommonUtils::DeleteTempFilesL(void)
+	?DesC8ToInt@UPnPCommonUtils@@SAHABVTDesC8@@@Z @ 12 NONAME ; int UPnPCommonUtils::DesC8ToInt(class TDesC8 const &)
+	?FetchMetadataL@UPnPMetadataFetcher@@SAXAAVCUpnpObject@@ABVTDesC16@@@Z @ 13 NONAME ; void UPnPMetadataFetcher::FetchMetadataL(class CUpnpObject &, class TDesC16 const &)
+	?FetchMetadataL@UPnPMetadataFetcher@@SAXAAVCUpnpObject@@ABVTDesC16@@ABVTDesC8@@@Z @ 14 NONAME ; void UPnPMetadataFetcher::FetchMetadataL(class CUpnpObject &, class TDesC16 const &, class TDesC8 const &)
+	?FileExtensionByMimeTypeL@UPnPCommonUtils@@SAPAVHBufC16@@ABVTDesC8@@@Z @ 15 NONAME ; class HBufC16 * UPnPCommonUtils::FileExtensionByMimeTypeL(class TDesC8 const &)
+	?FileTypeByMimeTypeL@UPnPCommonUtils@@SA?AW4TUPnPItemType@@ABVTDesC8@@@Z @ 16 NONAME ; enum TUPnPItemType UPnPCommonUtils::FileTypeByMimeTypeL(class TDesC8 const &)
+	?FindContainerByTitle@UPnPCommonUtils@@SAPAVCUpnpContainer@@ABVCUpnpContainerList@@ABVTDesC8@@@Z @ 17 NONAME ; class CUpnpContainer * UPnPCommonUtils::FindContainerByTitle(class CUpnpContainerList const &, class TDesC8 const &)
+	?FixListboxItemTextL@UPnPCommonUtils@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 18 NONAME ; class HBufC8 * UPnPCommonUtils::FixListboxItemTextL(class TDesC8 const &)
+	?Genre@CUPnPMetaDataUtility@@QBEABVTDesC16@@XZ @ 19 NONAME ; class TDesC16 const & CUPnPMetaDataUtility::Genre(void) const
+	?GetCopyPathDriveL@CUPnPPathUtility@@QBEXAAW4TDriveNumber@@@Z @ 20 NONAME ; void CUPnPPathUtility::GetCopyPathDriveL(enum TDriveNumber &) const
+	?GetCopyPathL@CUPnPPathUtility@@QBEPAVHBufC16@@ABVCUpnpItem@@ABVCUpnpElement@@H@Z @ 21 NONAME ; class HBufC16 * CUPnPPathUtility::GetCopyPathL(class CUpnpItem const &, class CUpnpElement const &, int) const
+	?GetCopyPathL@CUPnPPathUtility@@QBEPAVHBufC16@@ABVCUpnpItem@@ABVCUpnpElement@@HW4TDriveNumber@@@Z @ 22 NONAME ; class HBufC16 * CUPnPPathUtility::GetCopyPathL(class CUpnpItem const &, class CUpnpElement const &, int, enum TDriveNumber) const
+	?GetMimeTypeByExtensionL@UPnPCommonUtils@@SAPAVHBufC8@@ABVTDesC16@@@Z @ 23 NONAME ; class HBufC8 * UPnPCommonUtils::GetMimeTypeByExtensionL(class TDesC16 const &)
+	?IntToDesC8LC@UPnPCommonUtils@@SAPAVHBufC8@@ABH@Z @ 24 NONAME ; class HBufC8 * UPnPCommonUtils::IntToDesC8LC(int const &)
+	?IsAudioSupported@UPnPCommonUtils@@SAHABVTDesC8@@@Z @ 25 NONAME ; int UPnPCommonUtils::IsAudioSupported(class TDesC8 const &)
+	?IsImageSupported@UPnPCommonUtils@@SAHABVTDesC8@@@Z @ 26 NONAME ; int UPnPCommonUtils::IsImageSupported(class TDesC8 const &)
+	?IsPlaylistContainerL@UPnPCommonUtils@@SAHABVCUpnpObject@@@Z @ 27 NONAME ; int UPnPCommonUtils::IsPlaylistContainerL(class CUpnpObject const &)
+	?IsUriAbsolute@UpnpCdsResElementUtility@@SAHABVTDesC8@@@Z @ 28 NONAME ; int UpnpCdsResElementUtility::IsUriAbsolute(class TDesC8 const &)
+	?IsVideoSupported@UPnPCommonUtils@@SAHABVTDesC8@@@Z @ 29 NONAME ; int UPnPCommonUtils::IsVideoSupported(class TDesC8 const &)
+	?LoadMetaDataL@CUPnPMetaDataUtility@@QAEXABVTDesC16@@@Z @ 30 NONAME ; void CUPnPMetaDataUtility::LoadMetaDataL(class TDesC16 const &)
+	?LoadTitleL@CUPnPMetaDataUtility@@QAEXABVTDesC16@@@Z @ 31 NONAME ; void CUPnPMetaDataUtility::LoadTitleL(class TDesC16 const &)
+	?MemoryCardStateL@UPnPCommonUtils@@SAHXZ @ 32 NONAME ; int UPnPCommonUtils::MemoryCardStateL(void)
+	?NewL@CUPnPMetaDataUtility@@SAPAV1@XZ @ 33 NONAME ; class CUPnPMetaDataUtility * CUPnPMetaDataUtility::NewL(void)
+	?NewL@CUPnPPathUtility@@SAPAV1@XZ @ 34 NONAME ; class CUPnPPathUtility * CUPnPPathUtility::NewL(void)
+	?NewL@CUPnPPeriodic@@SAPAV1@H@Z @ 35 NONAME ; class CUPnPPeriodic * CUPnPPeriodic::NewL(int)
+	?NewLC@CUPnPPathUtility@@SAPAV1@XZ @ 36 NONAME ; class CUPnPPathUtility * CUPnPPathUtility::NewLC(void)
+	?NotifyMediaGalleryL@UpnpGalleryNotifier@@SAXXZ @ 37 NONAME ; void UpnpGalleryNotifier::NotifyMediaGalleryL(void)
+	?RemoveEmptyFoldersFromCopyPathL@CUPnPPathUtility@@SAXABVTDesC16@@@Z @ 38 NONAME ; void CUPnPPathUtility::RemoveEmptyFoldersFromCopyPathL(class TDesC16 const &)
+	?RenameFileL@UPnPCommonUtils@@SAPAVHBufC16@@ABVTDesC16@@@Z @ 39 NONAME ; class HBufC16 * UPnPCommonUtils::RenameFileL(class TDesC16 const &)
+	?ReplaceIllegalDirNameCharactersL@UPnPCommonUtils@@SAPAVHBufC16@@ABVTDesC16@@@Z @ 40 NONAME ; class HBufC16 * UPnPCommonUtils::ReplaceIllegalDirNameCharactersL(class TDesC16 const &)
+	?ReplaceIllegalDirNameCharactersL@UPnPCommonUtils@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 41 NONAME ; class HBufC8 * UPnPCommonUtils::ReplaceIllegalDirNameCharactersL(class TDesC8 const &)
+	?ReplaceIllegalFilenameCharactersL@UPnPCommonUtils@@SAPAVHBufC16@@ABVTDesC16@@@Z @ 42 NONAME ; class HBufC16 * UPnPCommonUtils::ReplaceIllegalFilenameCharactersL(class TDesC16 const &)
+	?ReplaceIllegalFilenameCharactersL@UPnPCommonUtils@@SAPAVHBufC8@@ABVTDesC8@@@Z @ 43 NONAME ; class HBufC8 * UPnPCommonUtils::ReplaceIllegalFilenameCharactersL(class TDesC8 const &)
+	?ReplacePlaceHolderInURIL@UPnPCommonUtils@@SAXAAVCUpnpItem@@ABVTInetAddr@@@Z @ 44 NONAME ; void UPnPCommonUtils::ReplacePlaceHolderInURIL(class CUpnpItem &, class TInetAddr const &)
+	?ResolveFileTypeL@UPnPCommonUtils@@SA?AW4TUPnPItemType@@ABVTDesC16@@@Z @ 45 NONAME ; enum TUPnPItemType UPnPCommonUtils::ResolveFileTypeL(class TDesC16 const &)
+	?ResolveMimeTypeL@UPnPCommonUtils@@SAPAVHBufC8@@ABVTDesC16@@@Z @ 46 NONAME ; class HBufC8 * UPnPCommonUtils::ResolveMimeTypeL(class TDesC16 const &)
+	?TTimeToUPnPDateL@UPnPCommonUtils@@SAPAVHBufC16@@VTTime@@@Z @ 47 NONAME ; class HBufC16 * UPnPCommonUtils::TTimeToUPnPDateL(class TTime)
+	?Title@CUPnPMetaDataUtility@@QBEABVTDesC16@@XZ @ 48 NONAME ; class TDesC16 const & CUPnPMetaDataUtility::Title(void) const
+
--- a/upnpframework/upnputilities/EABI/upnputilitiesU.DEF	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/EABI/upnputilitiesU.DEF	Mon Nov 01 12:37:49 2010 +0200
@@ -1,48 +1,58 @@
-EXPORTS
-	_ZN15UPnPCommonUtils10DesC8ToIntERK6TDesC8 @ 1 NONAME
-	_ZN15UPnPCommonUtils11RenameFileLERK7TDesC16 @ 2 NONAME
-	_ZN15UPnPCommonUtils12IntToDesC8LCERKi @ 3 NONAME
-	_ZN15UPnPCommonUtils16DeleteTempFilesLEv @ 4 NONAME
-	_ZN15UPnPCommonUtils16MemoryCardStateLEv @ 5 NONAME
-	_ZN15UPnPCommonUtils16ResolveFileTypeLERK7TDesC16 @ 6 NONAME
-	_ZN15UPnPCommonUtils16ResolveMimeTypeLERK7TDesC16 @ 7 NONAME
-	_ZN15UPnPCommonUtils16TTimeToUPnPDateLE5TTime @ 8 NONAME
-	_ZN15UPnPCommonUtils20FindContainerByTitleERK18CUpnpContainerListRK6TDesC8 @ 9 NONAME
-	_ZN15UPnPCommonUtils20IsPlaylistContainerLERK11CUpnpObject @ 10 NONAME
-	_ZN15UPnPCommonUtils23GetMimeTypeByExtensionLERK7TDesC16 @ 11 NONAME
-	_ZN15UPnPCommonUtils24ReplacePlaceHolderInURILER9CUpnpItemRK9TInetAddr @ 12 NONAME
-	_ZN15UPnPCommonUtils33ReplaceIllegalFilenameCharactersLERK6TDesC8 @ 13 NONAME
-	_ZN15UPnPCommonUtils33ReplaceIllegalFilenameCharactersLERK7TDesC16 @ 14 NONAME
-	_ZN19UPnPMetadataFetcher14FetchMetadataLER11CUpnpObjectRK7TDesC16 @ 15 NONAME
-	_ZN19UPnPMetadataFetcher14FetchMetadataLER11CUpnpObjectRK7TDesC16RK6TDesC8 @ 16 NONAME
-	_ZN19UPnPMetadataFetcher19CreateItemFromFileLERK7TDesC16 @ 17 NONAME
-	_ZN19UPnPMetadataFetcher20CreateItemFromFileLCERK7TDesC16 @ 18 NONAME
-	_ZN20CUPnPMetaDataUtility13LoadMetaDataLERK7TDesC16 @ 19 NONAME
-	_ZN20CUPnPMetaDataUtility4NewLEv @ 20 NONAME
-	_ZN20CUPnPMetaDataUtilityD0Ev @ 21 NONAME
-	_ZN20CUPnPMetaDataUtilityD1Ev @ 22 NONAME
-	_ZN20CUPnPMetaDataUtilityD2Ev @ 23 NONAME
-	_ZN22CUPnPConnectionMonitor4NewLER30MUPnPConnectionMonitorObserveri @ 24 NONAME
-	_ZN24UpnpCdsResElementUtility13IsUriAbsoluteERK6TDesC8 @ 25 NONAME
-	_ZN24UpnpCdsResElementUtility14AddResElementLER9CUpnpItemRK7TDesC16 @ 26 NONAME
-	_ZNK20CUPnPMetaDataUtility4DateEv @ 27 NONAME
-	_ZNK20CUPnPMetaDataUtility5AlbumEv @ 28 NONAME
-	_ZNK20CUPnPMetaDataUtility5GenreEv @ 29 NONAME
-	_ZNK20CUPnPMetaDataUtility5TitleEv @ 30 NONAME
-	_ZNK20CUPnPMetaDataUtility6ArtistEv @ 31 NONAME
-	_ZTI20CUPnPMetaDataUtility @ 32 NONAME ; #<TI>#
-	_ZTI22CUPnPConnectionMonitor @ 33 NONAME ; #<TI>#
-	_ZTV20CUPnPMetaDataUtility @ 34 NONAME ; #<VT>#
-	_ZTV22CUPnPConnectionMonitor @ 35 NONAME ; #<VT>#
-	_ZN15UPnPCommonUtils16IsAudioSupportedERK6TDesC8 @ 36 NONAME
-	_ZN15UPnPCommonUtils16IsImageSupportedERK6TDesC8 @ 37 NONAME
-	_ZN15UPnPCommonUtils16IsVideoSupportedERK6TDesC8 @ 38 NONAME
-	_ZN15UPnPCommonUtils24FileExtensionByMimeTypeLERK6TDesC8 @ 39 NONAME
-	_ZN19UpnpGalleryNotifier19NotifyMediaGalleryLEv @ 40 NONAME
-	_ZN22CUPnPConnectionMonitor28DebugSimulateConnectionLostLEv @ 41 NONAME
-	_ZN20CUPnPMetaDataUtility10LoadTitleLERK7TDesC16 @ 42 NONAME
-	_ZN15UPnPCommonUtils19FixListboxItemTextLERK6TDesC8 @ 43 NONAME
-	_ZN13CUPnPPeriodic4NewLEi @ 44 NONAME
-	_ZTI13CUPnPPeriodic @ 45 NONAME ; #<TI>#
-	_ZTV13CUPnPPeriodic @ 46 NONAME ; #<VT>#
-
+EXPORTS
+	_ZN13CUPnPPeriodic4NewLEi @ 1 NONAME
+	_ZN15UPnPCommonUtils10DesC8ToIntERK6TDesC8 @ 2 NONAME
+	_ZN15UPnPCommonUtils11RenameFileLERK7TDesC16 @ 3 NONAME
+	_ZN15UPnPCommonUtils12IntToDesC8LCERKi @ 4 NONAME
+	_ZN15UPnPCommonUtils16DeleteTempFilesLEv @ 5 NONAME
+	_ZN15UPnPCommonUtils16IsAudioSupportedERK6TDesC8 @ 6 NONAME
+	_ZN15UPnPCommonUtils16IsImageSupportedERK6TDesC8 @ 7 NONAME
+	_ZN15UPnPCommonUtils16IsVideoSupportedERK6TDesC8 @ 8 NONAME
+	_ZN15UPnPCommonUtils16MemoryCardStateLEv @ 9 NONAME
+	_ZN15UPnPCommonUtils16ResolveFileTypeLERK7TDesC16 @ 10 NONAME
+	_ZN15UPnPCommonUtils16ResolveMimeTypeLERK7TDesC16 @ 11 NONAME
+	_ZN15UPnPCommonUtils16TTimeToUPnPDateLE5TTime @ 12 NONAME
+	_ZN15UPnPCommonUtils19FileTypeByMimeTypeLERK6TDesC8 @ 13 NONAME
+	_ZN15UPnPCommonUtils19FixListboxItemTextLERK6TDesC8 @ 14 NONAME
+	_ZN15UPnPCommonUtils20FindContainerByTitleERK18CUpnpContainerListRK6TDesC8 @ 15 NONAME
+	_ZN15UPnPCommonUtils20IsPlaylistContainerLERK11CUpnpObject @ 16 NONAME
+	_ZN15UPnPCommonUtils23GetMimeTypeByExtensionLERK7TDesC16 @ 17 NONAME
+	_ZN15UPnPCommonUtils24FileExtensionByMimeTypeLERK6TDesC8 @ 18 NONAME
+	_ZN15UPnPCommonUtils24ReplacePlaceHolderInURILER9CUpnpItemRK9TInetAddr @ 19 NONAME
+	_ZN15UPnPCommonUtils32ReplaceIllegalDirNameCharactersLERK6TDesC8 @ 20 NONAME
+	_ZN15UPnPCommonUtils32ReplaceIllegalDirNameCharactersLERK7TDesC16 @ 21 NONAME
+	_ZN15UPnPCommonUtils33ReplaceIllegalFilenameCharactersLERK6TDesC8 @ 22 NONAME
+	_ZN15UPnPCommonUtils33ReplaceIllegalFilenameCharactersLERK7TDesC16 @ 23 NONAME
+	_ZN16CUPnPPathUtility31RemoveEmptyFoldersFromCopyPathLERK7TDesC16 @ 24 NONAME
+	_ZN16CUPnPPathUtility4NewLEv @ 25 NONAME
+	_ZN16CUPnPPathUtility5NewLCEv @ 26 NONAME
+	_ZN16CUPnPPathUtilityD0Ev @ 27 NONAME
+	_ZN16CUPnPPathUtilityD1Ev @ 28 NONAME
+	_ZN16CUPnPPathUtilityD2Ev @ 29 NONAME
+	_ZN19UPnPMetadataFetcher14FetchMetadataLER11CUpnpObjectRK7TDesC16 @ 30 NONAME
+	_ZN19UPnPMetadataFetcher14FetchMetadataLER11CUpnpObjectRK7TDesC16RK6TDesC8 @ 31 NONAME
+	_ZN19UPnPMetadataFetcher19CreateItemFromFileLERK7TDesC16 @ 32 NONAME
+	_ZN19UPnPMetadataFetcher20CreateItemFromFileLCERK7TDesC16 @ 33 NONAME
+	_ZN19UpnpGalleryNotifier19NotifyMediaGalleryLEv @ 34 NONAME
+	_ZN20CUPnPMetaDataUtility10LoadTitleLERK7TDesC16 @ 35 NONAME
+	_ZN20CUPnPMetaDataUtility13LoadMetaDataLERK7TDesC16 @ 36 NONAME
+	_ZN20CUPnPMetaDataUtility4NewLEv @ 37 NONAME
+	_ZN20CUPnPMetaDataUtilityD0Ev @ 38 NONAME
+	_ZN20CUPnPMetaDataUtilityD1Ev @ 39 NONAME
+	_ZN20CUPnPMetaDataUtilityD2Ev @ 40 NONAME
+	_ZN24UpnpCdsResElementUtility13IsUriAbsoluteERK6TDesC8 @ 41 NONAME
+	_ZN24UpnpCdsResElementUtility14AddResElementLER9CUpnpItemRK7TDesC16 @ 42 NONAME
+	_ZNK16CUPnPPathUtility12GetCopyPathLERK9CUpnpItemRK12CUpnpElementi @ 43 NONAME
+	_ZNK16CUPnPPathUtility12GetCopyPathLERK9CUpnpItemRK12CUpnpElementi12TDriveNumber @ 44 NONAME
+	_ZNK16CUPnPPathUtility15CreateCopyPathLERK9CUpnpItemRK12CUpnpElementi @ 45 NONAME
+	_ZNK16CUPnPPathUtility15CreateCopyPathLERK9CUpnpItemRK12CUpnpElementi12TDriveNumber @ 46 NONAME
+	_ZNK16CUPnPPathUtility17GetCopyPathDriveLER12TDriveNumber @ 47 NONAME
+	_ZNK20CUPnPMetaDataUtility4DateEv @ 48 NONAME
+	_ZNK20CUPnPMetaDataUtility5AlbumEv @ 49 NONAME
+	_ZNK20CUPnPMetaDataUtility5GenreEv @ 50 NONAME
+	_ZNK20CUPnPMetaDataUtility5TitleEv @ 51 NONAME
+	_ZNK20CUPnPMetaDataUtility6ArtistEv @ 52 NONAME
+	_ZTI13CUPnPPeriodic @ 53 NONAME
+	_ZTI20CUPnPMetaDataUtility @ 54 NONAME
+	_ZTV13CUPnPPeriodic @ 55 NONAME
+	_ZTV20CUPnPMetaDataUtility @ 56 NONAME
+
--- a/upnpframework/upnputilities/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,44 +1,45 @@
-/*
-* Copyright (c) 2006-2007 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:  Build info file for upnp utilities
-*
-*/
-
-
-PRJ_PLATFORMS
-// No requirements
-
-PRJ_EXPORTS
-//internal domain API
-../inc/upnpconnectionmonitor.h                    |../../../inc/upnpconnectionmonitor.h
-../inc/upnpconnectionmonitorobserver.h            |../../../inc/upnpconnectionmonitorobserver.h
-../inc/upnpcdsreselementutility.h                 |../../../inc/upnpcdsreselementutility.h
-../inc/upnpmetadatafetcher.h                      |../../../inc/upnpmetadatafetcher.h
-../inc/upnpcommonutils.h            		  |../../../inc/upnpcommonutils.h
-../inc/upnpmetadatautility.h          		  |../../../inc/upnpmetadatautility.h
-../inc/upnpfileutilitytypes.h        		  |../../../inc/upnpfileutilitytypes.h
-../inc/upnpperiodic.h        		          |../../../inc/upnpperiodic.h
-
-
-PRJ_MMPFILES
-upnputilities.mmp
-
-PRJ_TESTMMPFILES
-// None
-
-PRJ_TESTEXPORTS
-// None
-
-
-
+/*
+* Copyright (c) 2006-2007 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:  Build info file for upnp utilities
+*
+*/
+
+
+PRJ_PLATFORMS
+// No requirements
+
+PRJ_EXPORTS
+//internal domain API
+../inc/upnpconnectionmonitor.h                    |../../../inc/upnpconnectionmonitor.h
+../inc/upnpconnectionmonitorobserver.h            |../../../inc/upnpconnectionmonitorobserver.h
+../inc/upnpcdsreselementutility.h                 |../../../inc/upnpcdsreselementutility.h
+../inc/upnpmetadatafetcher.h                      |../../../inc/upnpmetadatafetcher.h
+../inc/upnpcommonutils.h            		  |../../../inc/upnpcommonutils.h
+../inc/upnpmetadatautility.h          		  |../../../inc/upnpmetadatautility.h
+../inc/upnpfileutilitytypes.h        		  |../../../inc/upnpfileutilitytypes.h
+../inc/upnpperiodic.h        		          |../../../inc/upnpperiodic.h
+../inc/upnppathutility.h            		  |../../../inc/upnppathutility.h
+
+PRJ_MMPFILES
+upnputilities.mmp
+upnpconnmon.mmp
+
+PRJ_TESTMMPFILES
+// None
+
+PRJ_TESTEXPORTS
+// None
+
+
+
--- a/upnpframework/upnputilities/group/upnputilities.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/group/upnputilities.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,89 +1,91 @@
-/*
-* Copyright (c) 2006-2007 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:  UPnP utilities project definition file
-*
-*/
-
-
-#include "../../../group/upnpplatformvar.hrh"
-#include "../../../inc/upnpframeworkfeatures_mmp.hrh"
-
-
-// Build target
-TARGET          upnputilities.dll
-TARGETTYPE      DLL
-UID             0x1000008D 0x10208A13
-
-// Platform security
-CAPABILITY      CAP_GENERAL_DLL
-VENDORID        VID_DEFAULT
-
-// SIS installation + IAD support
-VERSION 10.1
-paged
-
-// Include paths
-USERINCLUDE     ../../inc
-USERINCLUDE     ../inc
-
-MW_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE   ../../../inc
-
-// Sources
-SOURCEPATH      ../src
-SOURCE          upnpcommonutils.cpp
-SOURCE          upnpmetadatautility.cpp
-SOURCE          upnpmetadatafetcher.cpp
-SOURCE          upnpcdsreselementutility.cpp
-SOURCE          upnpconnectionmonitor.cpp
-SOURCE          upnpgallerynotifier.cpp
-SOURCE          upnpperiodic.cpp
-
-// Core platform
-LIBRARY         euser.lib
-LIBRARY         estor.lib
-LIBRARY         efsrv.lib
-LIBRARY         bafl.lib
-LIBRARY         charconv.lib
-LIBRARY         esock.lib
-LIBRARY         insock.lib
-LIBRARY         commdb.lib
-LIBRARY         PlatformEnv.lib
-LIBRARY         connmon.lib
-
-// Meta data
-LIBRARY         MetaDataUtility.lib
-
-// MIME 
-LIBRARY         apmime.lib
-LIBRARY         apgrfx.lib
-
-// CAF (WM-DRM)
-LIBRARY         caf.lib
-LIBRARY         cafutils.lib
-
-// CLF
-LIBRARY         ContentListingFramework.lib
-
-// S60 Upnp Stack
-LIBRARY         upnpavobjects.lib
-LIBRARY         upnpipserversutils.lib
-
-// Upnp FW
-LIBRARY         dlnaprofiler.lib
-
-// debug logging facilities
-DEBUGLIBRARY    flogger.lib
-
-// End of file
+/*
+* Copyright (c) 2006-2007 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:  UPnP utilities project definition file
+*
+*/
+
+
+#include "../../../group/upnpplatformvar.hrh"
+#include "../../../inc/upnpframeworkfeatures_mmp.hrh"
+
+
+// Build target
+TARGET          upnputilities.dll
+TARGETTYPE      DLL
+UID             0x1000008D 0x10208A13
+
+// Platform security
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+// SIS installation + IAD support
+VERSION 10.1
+paged
+
+// Include paths
+USERINCLUDE     ../../inc
+USERINCLUDE     ../inc
+
+MW_LAYER_SYSTEMINCLUDE
+SYSTEMINCLUDE   ../../../inc
+
+// Sources
+SOURCEPATH      ../src
+SOURCE          upnpcommonutils.cpp
+SOURCE          upnpmetadatautility.cpp
+SOURCE          upnpmetadatafetcher.cpp
+SOURCE          upnpcdsreselementutility.cpp
+SOURCE          upnpgallerynotifier.cpp
+SOURCE          upnpperiodic.cpp
+SOURCE          upnppathutility.cpp
+
+// Core platform
+LIBRARY         euser.lib
+LIBRARY         estor.lib
+LIBRARY         efsrv.lib
+LIBRARY         bafl.lib
+LIBRARY         charconv.lib
+LIBRARY         esock.lib
+LIBRARY         insock.lib
+LIBRARY         commdb.lib
+LIBRARY         PlatformEnv.lib
+
+// Settings Engine
+LIBRARY         upnpsettingsengine.lib
+
+// Meta data
+LIBRARY         MetaDataUtility.lib
+
+// MIME 
+LIBRARY         apmime.lib
+LIBRARY         apgrfx.lib
+
+// CAF (WM-DRM)
+LIBRARY         caf.lib
+LIBRARY         cafutils.lib
+
+// CLF
+LIBRARY         ContentListingFramework.lib
+
+// S60 Upnp Stack
+LIBRARY         upnpipserversutils.lib
+
+// dlnasrv
+LIBRARY         upnpavobjects.lib
+LIBRARY         dlnaprofiler.lib
+
+// debug logging facilities
+DEBUGLIBRARY    flogger.lib
+
+// End of file
--- a/upnpframework/upnputilities/inc/upnpcommonutils.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/inc/upnpcommonutils.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,265 +1,314 @@
-/*
-* Copyright (c) 2005-2008 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:  UPnP framework's common utility functions
-*
-*/
-
-
-#ifndef UPNPCOMMONUTILS_H
-#define UPNPCOMMONUTILS_H
-
-//  INCLUDES
-#include <e32base.h>
-#include <upnpobject.h>
-#include <f32file.h>
-
-// DATA TYPES
-enum TUPnPItemType
-    {
-    ETypeAudio = 0,
-    ETypeVideo,
-    ETypeImage,
-    ETypePlaylist,
-    ETypeOther
-    };
-
-// FORWARD DECLARATIONS
-class CUpnpItem;
-class CUpnpContainer;
-class CUpnpContainerList;
-class CUpnpAttribute;
-class TInetAddr;
-
-// CONSTANTS
-// upload directory
-_LIT( KUpnpUploadDirectory, "Download\\Media\\" );
-
-// CLASS DECLARATION
-
-/**
-* UPnP Framework's common utility functions
-*
-* @lib upnputilities.lib
-* @since S60 3.0
-*/
-class UPnPCommonUtils
-    {
-
-public: // Business logic methods
-
-    /**
-     * Returns status whether memory card is inserted or not.
-     *
-     * @since S60 3.0
-     * @return TBool indicating the status of memory card
-     */
-    IMPORT_C static TBool MemoryCardStateL();
-
-    /**
-     * Resolves the MIME type of a file by it's content, using the 
-     * platform MIME recognizer. Leaves in error cases.
-     *
-     * @since S60 3.0
-     * @param TDesC8& file name (with full path info)
-     * @return HBufC8* mime type
-     */
-    IMPORT_C static HBufC8* ResolveMimeTypeL(
-                                const TDesC& aFileName );
-
-    /**
-     * Resolves the MIME type of a file by it's extension. Leaves in error
-     * cases.
-     *
-     * @since S60 3.0
-     * @param TDesC& const, file name (with full path info)
-     * @return HBufC8* mime type
-     */
-    IMPORT_C static HBufC8* GetMimeTypeByExtensionL( 
-                                const TDesC& aFileName );
-
-    /**
-     * Resolves the type of a file. Leaves in error cases.
-     *
-     * @since S60 3.0
-     * @param TDesC8& file name (with full path info)
-     * @return TUPnPItemType file type
-     */
-    IMPORT_C static TUPnPItemType ResolveFileTypeL( 
-                                const TDesC& aFileName );
-
-    /**
-     * Replaces IP address and port number placeholders of the RES
-     * element's URI string of the given item.
-     *
-     * @since S60 3.1
-     * @param aItem (CUpnpItem&) the item which RES element's URI is to be
-     *        updated
-     * @param aAddress (const TInetAddr&) the address and port number of
-     *        the updated URI
-     */
-    IMPORT_C static void ReplacePlaceHolderInURIL( 
-                                CUpnpItem& aItem,
-                                const TInetAddr& aAddress );
-
-    /**
-     * Replaces the illegal filename characters of the given filename
-     * string and returns a new fixed filename string. The following
-     * characters are replaced with an underscore: >, <, ", \, /, *, |, 
-     * : and ?. 8bit version.
-     *
-     * @since S60 3.1
-     * @param aFileName (const TDesC8&) filename to be checked
-     * @return HBufC8* fixed filename string
-     **/
-    IMPORT_C static HBufC8* ReplaceIllegalFilenameCharactersL( 
-                                const TDesC8& aFileName );
-                    
-    /**
-     * Replaces the illegal filename characters of the given filename
-     * string and returns a new fixed filename string. The following
-     * characters are replaced with an underscore: >, <, ", \, /, *, |, 
-     * : and ?. 16bit version.
-     *
-     * @since S60 3.1
-     * @param aFileName (const TDesC&) filename to be checked
-     * @return HBufC* fixed filename string
-     **/
-    IMPORT_C static HBufC* ReplaceIllegalFilenameCharactersL( 
-                                const TDesC& aFileName );
-
-    /**
-     * Checks if the given CUpnpObject is a playlist container. Leaves if
-     * the given object is not correctly formed. 
-     *
-     * @since S60 3.1
-     * @param aContainer (const CUpnpObject&) filename to be checked
-     * @return TBool
-     **/
-    IMPORT_C static TBool IsPlaylistContainerL( 
-                                const CUpnpObject& aContainer );
-
-    /** 
-     * Return container with given title from list of containers
-     *
-     * @since S60 3.1
-     * @param aList List containig containers to search
-     * @param aTitle Title to search for
-     * @return CUpnpContainer* The pointer to container, NULL if
-     * not found
-     **/
-    IMPORT_C static CUpnpContainer* FindContainerByTitle(
-        const CUpnpContainerList& aList, const TDesC8& aTitle );
-
-    /**
-     * Convert TInt to TDesC8
-     * @since S60 3.1
-     * @param aObject TInt to convert
-     */
-    IMPORT_C static HBufC8* IntToDesC8LC( const TInt& aObject );
-
-    /**
-     * Convert TDesC8 to TInt
-     * @since S60 3.1
-     * @param aObject Descriptor to convert
-     */
-    IMPORT_C static TInt DesC8ToInt( const TDesC8& aObject );
-    
-    /**
-     * Converts TTime to UPnP date string
-     *
-     * @since S60 3.1
-     * @param aTime time
-     * @return UPnP date as a heap descriptor
-     */
-    IMPORT_C static HBufC* TTimeToUPnPDateL( TTime aTime );
-
-    
-    /**
-     * Rename the downloaded file to %s_upnpfwtemp(%s is original filename)
-     * used in play remote item on local device
-     * @since S60 3.1
-     *
-     * @param aFilePath original file path
-     * @return HBufC pointer to the new filepath
-     */
-    IMPORT_C static HBufC* UPnPCommonUtils::RenameFileL( const TDesC& aFilePath );
-    
-    /**
-     * Delete upnp genereated temporary files from download locations
-     * both from phone memory and memory card
-     * Leave in case of fatal errors
-     * @since S60 3.1
-     *
-     */
-    IMPORT_C static void DeleteTempFilesL();
-
-
-     /**
-     * Checks if device supports images 
-     *
-     * @since S60 3.1
-     * @param TDesC8& protocolinfo
-     * @return TBool
-     */
-    IMPORT_C static TBool IsImageSupported(
-                                const TDesC8& aProtocolInfo );
-                                
-                                
-     /**
-     * Checks if device supports audio 
-     *
-     * @since S60 3.1
-     * @param TDesC8& protocolinfo
-     * @return TBool
-     */
-    IMPORT_C static TBool IsAudioSupported(
-                                const TDesC8& aProtocolInfo );
-                                
-                                
-     /**
-     * Checks if device supports video 
-     *
-     * @since S60 3.1
-     * @param TDesC8& protocolinfo
-     * @return TBool
-     */
-    IMPORT_C static TBool IsVideoSupported(
-                                const TDesC8& aProtocolInfo );
-                                
-     /**
-     * Return the file extension according a mime type
-     *
-     * @since S60 3.2
-     * @param const TDesC8& mime type
-     * @return file extension
-     */
-    IMPORT_C static HBufC* FileExtensionByMimeTypeL(
-        const TDesC8& aMimeType );
-    
-    /**
-     * Removes the tab character of the given text
-     * string and returns a new fixed file title string.
-     *
-     * @since S60 3.2.3
-     * @param aText (const TDesC8&) listboxe item text to be checked
-     * @return HBufC8* fixed text string
-     **/
-    IMPORT_C static HBufC8* FixListboxItemTextL( 
-                                const TDesC8& aText );    
-    };
-
-
-#endif  // UPNPCOMMONUTILS_H
-
-// End of File
+/*
+* Copyright (c) 2005-2008 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:  UPnP framework's common utility functions
+*
+*/
+
+
+#ifndef UPNPCOMMONUTILS_H
+#define UPNPCOMMONUTILS_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <upnpobject.h>
+#include <f32file.h>
+
+// DATA TYPES
+enum TUPnPItemType
+    {
+    ETypeAudio = 0,
+    ETypeVideo,
+    ETypeImage,
+    ETypePlaylist,
+    ETypeOther
+    };
+
+// FORWARD DECLARATIONS
+class CUpnpItem;
+class CUpnpContainer;
+class CUpnpContainerList;
+class CUpnpAttribute;
+class TInetAddr;
+
+// CONSTANTS
+// upload directory
+_LIT( KUpnpUploadDirectory, "Download\\Media\\" );
+
+// CLASS DECLARATION
+
+/**
+* UPnP Framework's common utility functions
+*
+* @lib upnputilities.lib
+* @since S60 3.0
+*/
+class UPnPCommonUtils
+    {
+
+public: // Business logic methods
+
+    /**
+     * Returns status whether memory card is inserted or not.
+     *
+     * @since S60 3.0
+     * @return TBool indicating the status of memory card
+     */
+    IMPORT_C static TBool MemoryCardStateL();
+
+    /**
+     * Resolves the MIME type of a file by it's content, using the 
+     * platform MIME recognizer. Leaves in error cases.
+     *
+     * @since S60 3.0
+     * @param TDesC8& file name (with full path info)
+     * @return HBufC8* mime type
+     */
+    IMPORT_C static HBufC8* ResolveMimeTypeL(
+                                const TDesC& aFileName );
+
+    /**
+     * Resolves the MIME type of a file by it's extension. Leaves in error
+     * cases.
+     *
+     * @since S60 3.0
+     * @param TDesC& const, file name (with full path info)
+     * @return HBufC8* mime type
+     */
+    IMPORT_C static HBufC8* GetMimeTypeByExtensionL( 
+                                const TDesC& aFileName );
+
+    /**
+     * Resolves the type of a file. Leaves in error cases.
+     *
+     * @since S60 3.0
+     * @param TDesC8& file name (with full path info)
+     * @return TUPnPItemType file type
+     */
+    IMPORT_C static TUPnPItemType ResolveFileTypeL( 
+                                const TDesC& aFileName );
+
+    /**
+     * Replaces IP address and port number placeholders of the RES
+     * element's URI string of the given item.
+     *
+     * @since S60 3.1
+     * @param aItem (CUpnpItem&) the item which RES element's URI is to be
+     *        updated
+     * @param aAddress (const TInetAddr&) the address and port number of
+     *        the updated URI
+     */
+    IMPORT_C static void ReplacePlaceHolderInURIL( 
+                                CUpnpItem& aItem,
+                                const TInetAddr& aAddress );
+
+    /**
+     * Replaces the illegal filename characters of the given filename
+     * string and returns a new fixed filename string. The following
+     * characters are replaced with an underscore: >, <, ", \, /, *, |, 
+     * : and ?. 8bit version.
+     *
+     * @since S60 3.1
+     * @param aFileName (const TDesC8&) filename to be checked
+     * @return HBufC8* fixed filename string
+     **/
+    IMPORT_C static HBufC8* ReplaceIllegalFilenameCharactersL( 
+                                const TDesC8& aFileName );
+                    
+    /**
+     * Replaces the illegal filename characters of the given filename
+     * string and returns a new fixed filename string. The following
+     * characters are replaced with an underscore: >, <, ", \, /, *, |, 
+     * : and ?. 16bit version.
+     *
+     * @since S60 3.1
+     * @param aFileName (const TDesC&) filename to be checked
+     * @return HBufC* fixed filename string
+     **/
+    IMPORT_C static HBufC* ReplaceIllegalFilenameCharactersL( 
+                                const TDesC& aFileName );
+
+    /**
+     * Checks if the given CUpnpObject is a playlist container. Leaves if
+     * the given object is not correctly formed. 
+     *
+     * @since S60 3.1
+     * @param aContainer (const CUpnpObject&) filename to be checked
+     * @return TBool
+     **/
+    IMPORT_C static TBool IsPlaylistContainerL( 
+                                const CUpnpObject& aContainer );
+
+    /** 
+     * Return container with given title from list of containers
+     *
+     * @since S60 3.1
+     * @param aList List containig containers to search
+     * @param aTitle Title to search for
+     * @return CUpnpContainer* The pointer to container, NULL if
+     * not found
+     **/
+    IMPORT_C static CUpnpContainer* FindContainerByTitle(
+        const CUpnpContainerList& aList, const TDesC8& aTitle );
+
+    /**
+     * Convert TInt to TDesC8
+     * @since S60 3.1
+     * @param aObject TInt to convert
+     */
+    IMPORT_C static HBufC8* IntToDesC8LC( const TInt& aObject );
+
+    /**
+     * Convert TDesC8 to TInt
+     * @since S60 3.1
+     * @param aObject Descriptor to convert
+     */
+    IMPORT_C static TInt DesC8ToInt( const TDesC8& aObject );
+    
+    /**
+     * Converts TTime to UPnP date string
+     *
+     * @since S60 3.1
+     * @param aTime time
+     * @return UPnP date as a heap descriptor
+     */
+    IMPORT_C static HBufC* TTimeToUPnPDateL( TTime aTime );
+
+    
+    /**
+     * Rename the downloaded file to %s_upnpfwtemp(%s is original filename)
+     * used in play remote item on local device
+     * @since S60 3.1
+     *
+     * @param aFilePath original file path
+     * @return HBufC pointer to the new filepath
+     */
+    IMPORT_C static HBufC* UPnPCommonUtils::RenameFileL( const TDesC& aFilePath );
+    
+    /**
+     * Delete upnp genereated temporary files from download locations
+     * both from phone memory and memory card
+     * Leave in case of fatal errors
+     * @since S60 3.1
+     *
+     */
+    IMPORT_C static void DeleteTempFilesL();
+
+
+     /**
+     * Checks if device supports images 
+     *
+     * @since S60 3.1
+     * @param TDesC8& protocolinfo
+     * @return TBool
+     */
+    IMPORT_C static TBool IsImageSupported(
+                                const TDesC8& aProtocolInfo );
+                                
+                                
+     /**
+     * Checks if device supports audio 
+     *
+     * @since S60 3.1
+     * @param TDesC8& protocolinfo
+     * @return TBool
+     */
+    IMPORT_C static TBool IsAudioSupported(
+                                const TDesC8& aProtocolInfo );
+                                
+                                
+     /**
+     * Checks if device supports video 
+     *
+     * @since S60 3.1
+     * @param TDesC8& protocolinfo
+     * @return TBool
+     */
+    IMPORT_C static TBool IsVideoSupported(
+                                const TDesC8& aProtocolInfo );
+                                
+     /**
+     * Return the file extension according a mime type
+     *
+     * @since S60 3.2
+     * @param const TDesC8& mime type
+     * @return file extension
+     */
+    IMPORT_C static HBufC* FileExtensionByMimeTypeL(
+        const TDesC8& aMimeType );
+    
+    /**
+     * Removes the tab character of the given text
+     * string and returns a new fixed file title string.
+     *
+     * @since S60 3.2.3
+     * @param aText (const TDesC8&) listboxe item text to be checked
+     * @return HBufC8* fixed text string
+     **/
+    IMPORT_C static HBufC8* FixListboxItemTextL( 
+                                const TDesC8& aText );
+    
+    /**
+    * Returns the file type according a mime type
+    *
+    * @param const TDesC8& mime type
+    * @return TUPnPItemType file type
+    */
+   IMPORT_C static TUPnPItemType FileTypeByMimeTypeL(
+       const TDesC8& aMimeType );
+   
+   /**
+    * Same as ReplaceIllegalFilenameCharactersL(), but also replaces the last
+    * character by underscore if it's a dot ('.'). 8bit version.
+    * 
+    * @param aDirName (const TDesC8&) directory name to be checked
+    * @return HBufC8* fixed directory name string
+    */
+   IMPORT_C static HBufC8* ReplaceIllegalDirNameCharactersL( 
+       const TDesC8& aDirName );
+      
+   /**
+    * Same as ReplaceIllegalFilenameCharactersL(), but also replaces the last
+    * character by underscore if it's a dot ('.'). 16bit version.
+    * 
+    * @param aDirName (const TDesC&) directory name to be checked
+    * @return HBufC* fixed directory name string
+    */   
+   IMPORT_C static HBufC* ReplaceIllegalDirNameCharactersL( 
+       const TDesC& aDirName );
+   
+   
+private:
+    
+    static void GetMimeTypeforImageExtensionsL( const TDesC& aExt ,HBufC8** aMimeType);
+    
+    static void GetMimeTypeforAudioVideoExtensionsL(  const TDesC& aExt ,HBufC8** aMimeType);
+    
+    static void GetMimeTypeforExtensionsL(  const TDesC& aExt ,HBufC8** aMimeType);
+    
+    static void GetFileExtensionForMimeTypesL(const TDesC8& aMimeType,HBufC** aFileExt);
+    
+    static void GetFileExtensionForImageMimeTypesL(const TDesC8& aMimeType,HBufC** aFileExt);
+    
+    static void GetFileExtensionForBMPandMP3MimeTypesL(const TDesC8& aMimeType,HBufC** aFileExt);
+    
+    static void GetFileExtensionForAudioMimeTypesL(const TDesC8& aMimeType,HBufC** aFileExt);
+    
+    static void GetFileExtensionForVideoMimeTypesL(const TDesC8& aMimeType,HBufC** aFileExt);
+   
+};
+
+
+#endif  // UPNPCOMMONUTILS_H
+
+// End of File
--- a/upnpframework/upnputilities/inc/upnpconnectionmonitor.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/inc/upnpconnectionmonitor.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,141 +1,168 @@
-/*
-* Copyright (c) 2008 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:  Monitors for WLAN connection
-*
-*/
-
-#ifndef C_UPNPCONNECTIONMMONITOR_H
-#define C_UPNPCONNECTIONMMONITOR_H
-
-
-// INCLUDES
-#include <e32base.h>
-#include <rconnmon.h>
-
-#include <f32file.h> 
-
-#include "upnpconnectionmonitorobserver.h"
-
-// CONSTANTS
-// none
-
-// MACROS
-// none
-
-// DATA TYPES
-// none
-
-// FUNCTION PROTOTYPES
-// none
-
-// FORWARD DECLARATIONS
-// none
-
-// CLASS DECLARATION
-
-/**
-* CUPnPConnectionMonitor class provides a WLAN connection monitor
-* for UPnP applications.
-*
-* @lib upnputilities.lib
-* @since S60 3.0
-*/
-class CUPnPConnectionMonitor :  public CActive,
-                                public MConnectionMonitorObserver
-    {
-    
-public:  // Constructors and destructor
-    
-    /**
-     * Two-phased constructor.
-     */
-    IMPORT_C static CUPnPConnectionMonitor* NewL(
-        MUPnPConnectionMonitorObserver& aObserver, TInt aAccessPoint );
-    
-    /**
-     * Destructor.
-     */
-    virtual ~CUPnPConnectionMonitor();
-
-    /**
-     * Simulate connection lost case. Calling this method will cause all
-     * instances of the CUPnPConnectionMonitor to call back "ConnectionLost"
-     * via the observer API.
-     *
-     * This method is for module test use only.
-     */
-    IMPORT_C static void DebugSimulateConnectionLostL();
-    
-    /**
-     * Checks current connection ids what is wlan id
-     * and stores it to iConnectionId
-     */
-    void  ParseCurrentConnections();
-    
-protected: // From CActive
-
-    void DoCancel();
-    
-    void RunL();
-
-protected: // From MConnectionMonitorObserver
-
-    /**
-     * Catches the Connection monitor events 
-     * @since Series 60 3.0
-     * @param aConnMonEvent event
-     * @return none
-     */
-    void EventL( const CConnMonEventBase& aConnMonEvent ) ;
-        
-private:
-
-    /**
-     * C++ default constructor.
-     */
-    CUPnPConnectionMonitor( MUPnPConnectionMonitorObserver& aObserver,
-        TInt aAccessPoint );
-
-    /**
-     * By default Symbian 2nd phase constructor is private.
-     */
-    void ConstructL();
-    
-    /**
-     * Checks connection type
-     */
-    TBool IsWlanConnection( TInt aConnectionId);
-
-
-private:    // Data
-
-    // file server (used only in debugging services)
-    RFs iFs;
-
-    // Connection monitor server
-    RConnectionMonitor              iConnectionMonitor;
-
-    // Connection id
-    TInt                            iConnectionId;
-
-    // Callback pointer, not owned
-    MUPnPConnectionMonitorObserver& iObserver;
-
-    // Accesspoint to be observed
-    TInt                            iAccessPoint;
-    };
-
-#endif // C_UPNPCONNECTIONMMONITOR_H
-            
-// End of File
+/*
+* Copyright (c) 2008 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:  Monitors for WLAN connection
+*
+*/
+
+#ifndef C_UPNPCONNECTIONMMONITOR_H
+#define C_UPNPCONNECTIONMMONITOR_H
+
+
+// INCLUDES
+#include <e32base.h>
+#include <rconnmon.h>
+
+#include "upnpconnectionmonitorobserver.h"
+
+/**
+* CUPnPConnectionMonitor class provides a WLAN connection monitor
+* for UPnP applications.
+*
+* @lib upnputilities.lib
+* @since S60 3.0
+*/
+class CUPnPConnectionMonitor :  public CActive,
+                                public MConnectionMonitorObserver
+    {
+    
+public:  // Constructors and destructor
+    
+    /**
+     * Two-phased constructor.
+     */
+    IMPORT_C static CUPnPConnectionMonitor* NewL( TInt aAccessPoint );
+    
+    /**
+     * Destructor.
+     */
+    virtual ~CUPnPConnectionMonitor();
+
+    /**
+     * Sets connection observer. Can be used if observer changes 
+     * after creation of connection monitor.
+     * @param aObserver Observer.
+     */
+    IMPORT_C void SetObserver( MUPnPConnectionMonitorObserver& aObserver );
+    
+    /**
+     * Requests a notification when requested access point is available.
+     * To avoid high power consumption, access point is observed some
+     * minutes. If access point is available earlier, IapAvailable is 
+     * called and monitoring stopped. Observation of access point can 
+     * be canceled with NotifyIapCancel at any point.
+     * @param aAccessPoint Access point from which notification is requested.
+     */
+    IMPORT_C void NotifyIap( TInt aAccessPoint );
+    
+    /**
+     * Stops scanning of access point started with NotifyIap.
+     */
+    IMPORT_C void NotifyIapCancel();
+    
+protected: // From CActive
+
+    void DoCancel();
+    
+    void RunL();
+
+protected: // From MConnectionMonitorObserver
+
+    /**
+     * Catches the Connection monitor events 
+     * @since Series 60 3.0
+     * @param aConnMonEvent event
+     * @return none
+     */
+    void EventL( const CConnMonEventBase& aConnMonEvent ) ;
+        
+private:
+
+    /**
+     * C++ default constructor.
+     */
+    CUPnPConnectionMonitor( TInt aAccessPoint );
+
+    /**
+     * By default Symbian 2nd phase constructor is private.
+     */
+    void ConstructL();
+    
+    /**
+     * Checks connection type
+     */
+    TBool IsWlanConnection( TInt aConnectionId);
+
+    /**
+     * Checks current connection ids what is wlan id
+     * and stores it to iConnectionId
+     */
+    void  ParseCurrentConnections();
+    
+    /**
+     * Callback for iap observation stop timer.
+     */
+    static TInt TimeoutCallback( TAny* aSelf );
+
+    /**
+     * Implementation of timeout handling.
+     */
+    void StopIapObservation();
+    
+    /**
+     * Cancels and deletes timeout timer.
+     */
+    void DeleteTimeoutTimer();
+
+private:
+    
+    enum EMonitorState
+        {
+        EMonitorStateWait,
+        EMonitorStateIap
+        };
+
+private:    // Data
+
+    // Connection monitor server
+    RConnectionMonitor              iConnectionMonitor;
+
+    // Connection id on connection creation
+    TInt                            iConnectionIdOnCreate;
+
+    // Connection id on connection deletion
+    TInt                            iConnectionId;
+
+    // Callback pointer, not owned
+    MUPnPConnectionMonitorObserver* iObserver;
+
+    // Accesspoint to be observed
+    TInt                            iAccessPoint;
+    
+    // Indication of scan request
+    TBool                           iMonitorState;
+    
+    // Buffer for iap information
+    TConnMonIapInfoBuf              iIapBuf;
+    
+    // Timer used when scanning iap at intervals
+    RTimer                          iTimer;
+    
+    // Timer used to avoid scanning of access point
+    // forever if client does not stop scanning.
+    CPeriodic*                      iTimeout;
+    };
+
+#endif // C_UPNPCONNECTIONMMONITOR_H
+            
+// End of File
--- a/upnpframework/upnputilities/inc/upnpconnectionmonitorobserver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/inc/upnpconnectionmonitorobserver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,45 +1,56 @@
-/*
-* Copyright (c) 2002-2007 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:  UPnP Connection monitor observer interface class declaration.
-*
-*/
-
-
-#ifndef M_UPNPCONNECTIONMONITOROBSERVER_H
-#define M_UPNPCONNECTIONMONITOROBSERVER_H
-
-//  INCLUDES
-#include <e32std.h>
-
-/**
- * MUPnPConnectionMonitorObserver is an interface for Connection Monitor.
- *
- * @lib upnputilities.lib
- * @since S60 3.0
- */
-class MUPnPConnectionMonitorObserver
-    {
-public:
-    
-    /**
-     * This function will be called when WLan connection is lost for UPnP 
-     *
-     * @since S60 3.1
-     */    
-    virtual void ConnectionLost() = 0;
-    };
-
-#endif // M_UPNPCONNECTIONMONITOROBSERVER_H
-     
-// End of File
+/*
+* Copyright (c) 2002-2007 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:  UPnP Connection monitor observer interface class declaration.
+*
+*/
+
+
+#ifndef M_UPNPCONNECTIONMONITOROBSERVER_H
+#define M_UPNPCONNECTIONMONITOROBSERVER_H
+
+//  INCLUDES
+#include <e32std.h>
+
+/**
+ * MUPnPConnectionMonitorObserver is an interface for Connection Monitor.
+ *
+ * @lib upnputilities.lib
+ * @since S60 3.0
+ */
+class MUPnPConnectionMonitorObserver
+    {
+public:
+    
+    /**
+     * This function will be called when WLan connection is lost for UPnP 
+     *
+     * @since S60 3.1
+     */    
+    virtual void ConnectionLost( TBool aUserOriented ) = 0;
+    /**
+     * This function will be called when Wlan connection is created
+     * @param aConnectionId Id of created connection.
+     */    
+    virtual void ConnectionCreated( TInt /*aConnectionId*/ ){}
+    /**
+     * This function will be called when access point requested 
+     * in NotifyIap function call is available.
+     * @param aIapId Id of access point.
+     */    
+    virtual void IapAvailable( TInt /*aIapId*/ ){}
+    };
+
+#endif // M_UPNPCONNECTIONMONITOROBSERVER_H
+     
+// End of File
--- a/upnpframework/upnputilities/inc/upnpfileutilitytypes.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/inc/upnpfileutilitytypes.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,171 +1,169 @@
-/*
-* Copyright (c) 2006-2007 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:  UPnP Object-related constant definitions
-*
-*/
-
-
-// System includes
-#include <e32base.h>
-
-// mime types <-> files ext
-
-// XHTML
-_LIT8( KXHtmlMime,  "application/xhtml+xml" );
-_LIT( KXHtmlExt,    ".xhtml" ); 
-
-// HTML
-_LIT8( KHtmlMime,   "text/html" );
-_LIT( KHtmlExt,     ".html" );
-
-// XML
-_LIT8( KXmlMime1,   "text/xml" );       
-_LIT8( KXmlMime2,   "application/xml" );
-_LIT8( KXmlMime3,	"application/x-xml");
-_LIT( KXmlExt,      ".xml" );
-
-// TXT
-_LIT8( KTxtMime,    "text/plain" );
-_LIT8( KTxtMime2,	"application/txt" );
-_LIT8( KTxtMime3,	"browser/internal" );
-_LIT8( KTxtMime4,	"text/anytext" );
-_LIT8( KTxtMime5,	"widetext/plain" );
-_LIT8( KTxtMime6,	"widetext/paragraph" );
-_LIT( KTxtExt,      ".txt" );
-
-// JPEG
-_LIT8( KJpegMime,   "image/jpeg" );
-_LIT( KJpegExt,     ".jpeg" );
-
-// JPG
-_LIT8( KJpegMime2,  "image/jpg" );
-_LIT8( KJpegMime3,  "image/jpe_" );
-_LIT8( KJpegMime4,  "image/pjpeg" );
-_LIT8( KJpegMime5,   "image/vnd.swiftview-jpeg" );
-_LIT( KJpgExt,      ".jpg" );
-
-// GIF
-_LIT8( KGifMime,    "image/gif" );             
-_LIT8( KGifMime2,	"image/x-xbitmap" );
-_LIT8( KGifMime3,	"image/gi_" );
-_LIT( KGifExt,      ".gif" );
-
-// PNG
-_LIT8( KPngMime,    "image/png" );             
-_LIT8( KPngMime2,	"application/png" );
-_LIT8( KPngMime3,	"application/x-png" );
-_LIT( KPngExt,      ".png" );
-
-// MPG
-_LIT8( KMpgMime1,   "video/mpeg");
-_LIT8( KMpgMime2,   "video/mpg");
-_LIT8( KMpgMime3,   "video/x-mpg");
-_LIT8( KMpgMime4,   "video/mpeg2" );
-_LIT8( KMpgMime5,   "application/x-pn-mpg" );
-_LIT8( KMpgMime6,	"video/x-mpeg" );
-_LIT8( KMpgMime7,	"video/x-mpeg2a");
-_LIT8( KMpgMime10,  "image/mpg" );
-_LIT( KMpgExt1,     ".mpg" );
-
-// MPEG4
-_LIT8( KMpeg4Mime,  "video/mpeg4" );
-_LIT( KMpeg4Ext,    ".mpeg4" );
-
-// MP4
-_LIT8( KMp4Mime,    "video/mp4" );
-_LIT8( KMp4Mime2,   "video/mp4v-es" );
-_LIT8( KMp4Mime3,   "audio/mp4" );
-_LIT( KMp4Ext,      ".mp4" );
-
-// AVI
-_LIT8( KAviMime1,   "video/avi" );
-_LIT8( KAviMime2,   "video/msvideo" );
-_LIT8( KAviMime3,   "video/x-msvideo" );
-_LIT8( KAviMime4,   "image/avi" );
-_LIT8( KAviMime5,   "video/xmpg2" );
-_LIT8( KAviMime6,	"application/x-troff-msvideo" );
-_LIT8( KAviMime7, 	"audio/aiff" );
-_LIT8( KAviMime8, 	"audio/avi" );
-_LIT8( KAviMime9,   "video/x-ms-avi" );
-_LIT( KAviExt,      ".avi" );
-
-// MP3
-_LIT8( KMp3Mime1,   "audio/x-mpeg-3");
-_LIT8( KMp3Mime2,   "audio/mpeg3" );           
-_LIT8( KMp3Mime3,   "audio/mpeg" );
-_LIT8( KMp3Mime4,   "audio/x-mpeg" );
-_LIT8( KMp3Mime5,   "audio/mp3" );
-_LIT8( KMp3Mime6,   "audio/x-mp3" );
-_LIT8( KMp3Mime7,   "audio/x-mpeg3" );
-_LIT8( KMp3Mime8,   "audio/mpg" );
-_LIT8( KMp3Mime9,   "audio/x-mpg" );
-_LIT8( KMp3Mime10,  "audio/x-mpegaudio" );
-_LIT( KMp3Ext,      ".mp3" );
-
-//M4A
-_LIT8( KM4aMime,    "audio/x-m4a" );
-_LIT( KM4aExt,      ".m4a" );
-// AAC
-_LIT8( KAacMime,    "audio/aac" );
-_LIT8( KAacMime2,   "audio/vnd.dlna.adts" );
-_LIT8( KAacMime3,   "audio/adts" );
-_LIT8( KAacMime4,   "audio/x-aac" );
-_LIT( KAacExt,      ".aac" );
-
-// WMA             
-_LIT8( KWmaMime,    "audio/x-ms-wma" );        
-_LIT8( KWmaMime2,   "video/x-ms-asf" );
-_LIT( KWmaExt,      ".wma" );
-
-// WMV
-_LIT8( KWmvMime,    "video/x-ms-wmv" );
-_LIT( KWmvExt,      ".wmv" );
-
-// BMP
-_LIT8( KBmpMime,    "image/bmp" );             
-_LIT8( KBmpMime2,   "image/x-bmp" );
-_LIT8( KBmpMime3,   "image/x-bitmap" );
-_LIT8( KBmpMime4,   "image/x-xbitmap" );
-_LIT8( KBmpMime5,   "image/x-ms-bmp" );
-_LIT8( KBmpMime6,   "application/bmp" );
-_LIT8( KBmpMime7,   "application/x-bmp" );
-_LIT8( KBmpMime8,   "application/x-win-bitmap" );
-_LIT8( KBmpMime9,   "application/preview" );
-_LIT( KBmpExt,      ".bmp" );
-
-// WAV
-_LIT8( KAudioXWav,   "audio/x-wav" );
-_LIT8( KAudioWav,   "audio/wav" );
-_LIT8( KAudioL16,   "audio/L16" );
-_LIT( KWavExt,      ".wav" );
-
-// 3GP
-_LIT8( KAudio3gpp,  "audio/3gpp" );
-_LIT8( KVideo3gpp,  "video/3gpp" );
-_LIT( K3gpExt,      ".3gp" );
-
-// AMR
-_LIT8( KAudioAMR,   "audio/AMR" );
-_LIT( KAmrExt,      ".amr" );
-
-// Real audio
-_LIT8( KRAMime8,   "audio/x-pn-realaudio" );
-_LIT( KRAExt,      ".ra" );
-
-// DLNA
-_LIT8( KVideoTts,   "video/vnd.dlna.mpeg-tts" );
-_LIT( KTtsExt,       ".tts" );
-
-
-
+/*
+* Copyright (c) 2006-2007 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:  UPnP Object-related constant definitions
+*
+*/
+
+
+// System includes
+#include <e32base.h>
+
+// mime types <-> files ext
+
+// XHTML
+_LIT8( KXHtmlMime,  "application/xhtml+xml" );
+_LIT( KXHtmlExt,    ".xhtml" ); 
+
+// HTML
+_LIT8( KHtmlMime,   "text/html" );
+_LIT( KHtmlExt,     ".html" );
+
+// XML
+_LIT8( KXmlMime1,   "text/xml" );       
+_LIT8( KXmlMime2,   "application/xml" );
+_LIT8( KXmlMime3,	"application/x-xml");
+_LIT( KXmlExt,      ".xml" );
+
+// TXT
+_LIT8( KTxtMime,    "text/plain" );
+_LIT8( KTxtMime2,	"application/txt" );
+_LIT8( KTxtMime3,	"browser/internal" );
+_LIT8( KTxtMime4,	"text/anytext" );
+_LIT8( KTxtMime5,	"widetext/plain" );
+_LIT8( KTxtMime6,	"widetext/paragraph" );
+_LIT( KTxtExt,      ".txt" );
+
+// JPEG
+_LIT8( KJpegMime,   "image/jpeg" );
+_LIT( KJpegExt,     ".jpeg" );
+
+// JPG
+_LIT8( KJpegMime2,  "image/jpg" );
+_LIT8( KJpegMime3,  "image/jpe_" );
+_LIT8( KJpegMime4,  "image/pjpeg" );
+_LIT8( KJpegMime5,   "image/vnd.swiftview-jpeg" );
+_LIT( KJpgExt,      ".jpg" );
+
+// GIF
+_LIT8( KGifMime,    "image/gif" );             
+_LIT8( KGifMime2,	"image/x-xbitmap" );
+_LIT8( KGifMime3,	"image/gi_" );
+_LIT( KGifExt,      ".gif" );
+
+// PNG
+_LIT8( KPngMime,    "image/png" );             
+_LIT8( KPngMime2,	"application/png" );
+_LIT8( KPngMime3,	"application/x-png" );
+_LIT( KPngExt,      ".png" );
+
+// MPG
+_LIT8( KMpgMime1,   "video/mpeg");
+_LIT8( KMpgMime2,   "video/mpg");
+_LIT8( KMpgMime3,   "video/x-mpg");
+_LIT8( KMpgMime4,   "video/mpeg2" );
+_LIT8( KMpgMime5,   "application/x-pn-mpg" );
+_LIT8( KMpgMime6,	"video/x-mpeg" );
+_LIT8( KMpgMime7,	"video/x-mpeg2a");
+_LIT8( KMpgMime10,  "image/mpg" );
+_LIT( KMpgExt1,     ".mpg" );
+
+// MPEG4
+_LIT8( KMpeg4Mime,  "video/mpeg4" );
+_LIT( KMpeg4Ext,    ".mpeg4" );
+
+// MP4
+_LIT8( KMp4Mime,    "video/mp4" );
+_LIT8( KMp4Mime2,   "video/mp4v-es" );
+_LIT8( KMp4Mime3,   "audio/mp4" );
+_LIT( KMp4Ext,      ".mp4" );
+
+// AVI
+_LIT8( KAviMime1,   "video/avi" );
+_LIT8( KAviMime2,   "video/msvideo" );
+_LIT8( KAviMime3,   "video/x-msvideo" );
+_LIT8( KAviMime4,   "image/avi" );
+_LIT8( KAviMime5,   "video/xmpg2" );
+_LIT8( KAviMime6,	"application/x-troff-msvideo" );
+_LIT8( KAviMime7, 	"audio/aiff" );
+_LIT8( KAviMime8, 	"audio/avi" );
+_LIT8( KAviMime9,   "video/x-ms-avi" );
+_LIT( KAviExt,      ".avi" );
+
+// MP3
+_LIT8( KMp3Mime1,   "audio/x-mpeg-3");
+_LIT8( KMp3Mime2,   "audio/mpeg3" );           
+_LIT8( KMp3Mime3,   "audio/mpeg" );
+_LIT8( KMp3Mime4,   "audio/x-mpeg" );
+_LIT8( KMp3Mime5,   "audio/mp3" );
+_LIT8( KMp3Mime6,   "audio/x-mp3" );
+_LIT8( KMp3Mime7,   "audio/x-mpeg3" );
+_LIT8( KMp3Mime8,   "audio/mpg" );
+_LIT8( KMp3Mime9,   "audio/x-mpg" );
+_LIT8( KMp3Mime10,  "audio/x-mpegaudio" );
+_LIT( KMp3Ext,      ".mp3" );
+
+//M4A
+_LIT8( KM4aMime,    "audio/x-m4a" );
+_LIT( KM4aExt,      ".m4a" );
+// AAC
+_LIT8( KAacMime,    "audio/aac" );
+_LIT8( KAacMime2,   "audio/vnd.dlna.adts" );
+_LIT8( KAacMime3,   "audio/adts" );
+_LIT8( KAacMime4,   "audio/x-aac" );
+_LIT( KAacExt,      ".aac" );
+
+// WMA             
+_LIT8( KWmaMime,    "audio/x-ms-wma" );        
+_LIT8( KWmaMime2,   "video/x-ms-asf" );
+_LIT( KWmaExt,      ".wma" );
+
+// WMV
+_LIT8( KWmvMime,    "video/x-ms-wmv" );
+_LIT( KWmvExt,      ".wmv" );
+
+// BMP
+_LIT8( KBmpMime,    "image/bmp" );             
+_LIT8( KBmpMime2,   "image/x-bmp" );
+_LIT8( KBmpMime3,   "image/x-bitmap" );
+_LIT8( KBmpMime4,   "image/x-xbitmap" );
+_LIT8( KBmpMime5,   "image/x-ms-bmp" );
+_LIT8( KBmpMime6,   "application/bmp" );
+_LIT8( KBmpMime7,   "application/x-bmp" );
+_LIT8( KBmpMime8,   "application/x-win-bitmap" );
+_LIT8( KBmpMime9,   "application/preview" );
+_LIT( KBmpExt,      ".bmp" );
+
+// WAV
+_LIT8( KAudioXWav,   "audio/x-wav" );
+_LIT8( KAudioWav,   "audio/wav" );
+_LIT8( KAudioL16,   "audio/L16" );
+_LIT( KWavExt,      ".wav" );
+
+// 3GP
+_LIT8( KAudio3gpp,  "audio/3gpp" );
+_LIT8( KVideo3gpp,  "video/3gpp" );
+_LIT( K3gpExt,      ".3gp" );
+
+// AMR
+_LIT8( KAudioAMR,   "audio/AMR" );
+_LIT( KAmrExt,      ".amr" );
+
+// Real audio
+_LIT8( KRAMime8,   "audio/x-pn-realaudio" );
+_LIT( KRAExt,      ".ra" );
+
+// DLNA
+_LIT8( KVideoTts,   "video/vnd.dlna.mpeg-tts" );
+_LIT( KTtsExt,       ".tts" );
+
--- a/upnpframework/upnputilities/inc/upnpmetadatafetcher.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/inc/upnpmetadatafetcher.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,95 +1,101 @@
-/*
-* Copyright (c) 2005-2007 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:  Meta data fetching utilities
-*
-*/
-
-
-#ifndef UPNPMETADATAFETCHER_H
-#define UPNPMETADATAFETCHER_H
-
-// INCLUDES
-#include <e32base.h>
-
-// FORWARD DECLARATIONS
-class CUpnpObject;
-
-// CLASS DECLARATION
-    
-/**
-* Static meta data fetching utilities.
-*
-* @lib upnputilities.lib
-* @since S60 3.1
-*/
-class UPnPMetadataFetcher
-    {
-
-public:
-
-    /**
-     * Resolves the metadata and fills in the CUpnpObject's metadata 
-     * fields accordingly.
-     * 
-     * @since Series 60 3.1
-     * @param aObject (CUpnpObject&) the target CUpnpObject
-     * @param aFilePath (const TDesC&) the filepath of the file
-     * @param aMimeType (const TDesC8&) the mime type of the file
-     */
-    IMPORT_C static void FetchMetadataL( CUpnpObject& aObject, 
-                                         const TDesC& aFilePath, 
-                                         const TDesC8& aMimeType );
-
-    /**
-     * Resolves the metadata and fills in the CUpnpObject's metadata 
-     * fields accordingly.
-     * 
-     * @since Series 60 3.1
-     * @param aObject (CUpnpObject&) the target CUpnpObject
-     * @param aFilePath (const TDesC&) the filepath of the file
-     */
-    IMPORT_C static void FetchMetadataL( CUpnpObject& aObject, 
-                                         const TDesC& aFilePath );
-
-    /**
-     * Creates a new CUpnpItem from a local file. Resolves the metadata and 
-     * fills in the new CUpnpItem's metadata fields accordingly.
-     * 
-     * @since Series 60 3.1
-     * @param aFilePath (const TDesC&) the filepath of the file
-     * @return (CUpnpItem*) pointer to the newly created CUpnpItem,
-     *         or NULL if the creation of the item or metadata resolving
-     *         fails. Pushes the object into the CleanupStack.
-     */
-    IMPORT_C static CUpnpItem* CreateItemFromFileLC( 
-                                            const TDesC& aFilePath );
-
-    /**
-     * Creates a new CUpnpItem from a local file. Resolves the metadata and 
-     * fills in the new CUpnpItem's metadata fields accordingly.
-     * 
-     * @since Series 60 3.1
-     * @param aFilePath (const TDesC&) the filepath of the file
-     * @return (CUpnpItem*) pointer to the newly created CUpnpItem,
-     *         or NULL if the creation of the item or metadata resolving
-     *         fails.
-     */
-    IMPORT_C static CUpnpItem* CreateItemFromFileL(
-                                            const TDesC& aFilePath );
-
-    };
-
-#endif // UPNPMETADATAFETCHER_H
-
-// End of File
+/*
+* Copyright (c) 2005-2007 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:  Meta data fetching utilities
+*
+*/
+
+
+#ifndef UPNPMETADATAFETCHER_H
+#define UPNPMETADATAFETCHER_H
+
+// INCLUDES
+#include <e32base.h>
+
+// FORWARD DECLARATIONS
+class CUpnpObject;
+
+// CLASS DECLARATION
+    
+/**
+* Static meta data fetching utilities.
+*
+* @lib upnputilities.lib
+* @since S60 3.1
+*/
+class UPnPMetadataFetcher
+    {
+
+public:
+
+    /**
+     * Resolves the metadata and fills in the CUpnpObject's metadata 
+     * fields accordingly.
+     * 
+     * @since Series 60 3.1
+     * @param aObject (CUpnpObject&) the target CUpnpObject
+     * @param aFilePath (const TDesC&) the filepath of the file
+     * @param aMimeType (const TDesC8&) the mime type of the file
+     */
+    IMPORT_C static void FetchMetadataL( CUpnpObject& aObject, 
+                                         const TDesC& aFilePath, 
+                                         const TDesC8& aMimeType );
+
+    /**
+     * Resolves the metadata and fills in the CUpnpObject's metadata 
+     * fields accordingly.
+     * 
+     * @since Series 60 3.1
+     * @param aObject (CUpnpObject&) the target CUpnpObject
+     * @param aFilePath (const TDesC&) the filepath of the file
+     */
+    IMPORT_C static void FetchMetadataL( CUpnpObject& aObject, 
+                                         const TDesC& aFilePath );
+
+    /**
+     * Creates a new CUpnpItem from a local file. Resolves the metadata and 
+     * fills in the new CUpnpItem's metadata fields accordingly.
+     * 
+     * @since Series 60 3.1
+     * @param aFilePath (const TDesC&) the filepath of the file
+     * @return (CUpnpItem*) pointer to the newly created CUpnpItem,
+     *         or NULL if the creation of the item or metadata resolving
+     *         fails. Pushes the object into the CleanupStack.
+     */
+    IMPORT_C static CUpnpItem* CreateItemFromFileLC( 
+                                            const TDesC& aFilePath );
+
+    /**
+     * Creates a new CUpnpItem from a local file. Resolves the metadata and 
+     * fills in the new CUpnpItem's metadata fields accordingly.
+     * 
+     * @since Series 60 3.1
+     * @param aFilePath (const TDesC&) the filepath of the file
+     * @return (CUpnpItem*) pointer to the newly created CUpnpItem,
+     *         or NULL if the creation of the item or metadata resolving
+     *         fails.
+     */
+    IMPORT_C static CUpnpItem* CreateItemFromFileL(
+                                            const TDesC& aFilePath );
+    
+private:
+    
+    static void AddElementToObjectL(CUpnpObject& aObject,
+                                         const TDesC& aMetaDataUtilityName, 
+                                         const TDesC8& aElementName );
+
+    };
+
+#endif // UPNPMETADATAFETCHER_H
+
+// End of File
--- a/upnpframework/upnputilities/src/upnpcdsreselementutility.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/src/upnpcdsreselementutility.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,218 +1,225 @@
-/*
-* Copyright (c) 2006-2007 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:  Utility class for meta data gathering for audio files
-*
-*/
-
-
-// INCLUDE FILES
-// System
-#include <e32std.h>
-#include <e32base.h>
-
-// upnp stack api
-#include <upnpitem.h> // CUpnpItem
-#include <upnpstring.h>
-#include <upnpelement.h>
-#include <upnpdlnaprotocolinfo.h>
-#include <upnpprotocolinfo.h>
-
-// upnpframework / avcontroller helper api
-#include <upnpconstantdefs.h> // for upnp class defs
-
-// upnpframework internal api's
-#include "upnpresresolver.h" // CUpnpResResolver
-#include "upnpresparameters.h"
-
-// utilities internal
-#include "upnpcommonutils.h"
-#include "upnpcdsreselementutility.h"
-
-_LIT( KHttp, "http://" );
-const TInt KColon = 58;
-const TInt KIpAddLen = 25;
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// --------------------------------------------------------------------------
-// CUpnpCdsResElementUtility::AddResElementL
-// 
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-EXPORT_C void UpnpCdsResElementUtility::AddResElementL( 
-                                                CUpnpItem& aItem, 
-                                                const TDesC& aFilename )
-    {
-
-    // Create CUpnpElement for res
-    CUpnpElement* elRes = CUpnpElement::NewL( KElementRes() );
-    CleanupStack::PushL( elRes );
-    elRes->SetFilePathL( aFilename );
- 
-    // Create res resolver component and put it to CleanupStack
-    CUpnpResResolver* resolver = CUpnpResResolver::NewLC();
-    
-    // Obtain res element parameters using res resolver component.
-    CUpnpResParameters* resParameters = NULL;
-	TRAPD(err, resParameters = resolver->GetResParametersL( aFilename ) );
-
-   if (err == KErrGeneral)	
-    {
-	// File not recognized, handling it manually by adding
-	// following res-item:  'http-get:*:MIMETYPE:*'
-
-   		_LIT8( KProtInfo1, "http-get:");
-    	_LIT8( KStar8, "*");
-    	_LIT8( KColon8, ":");
-    	HBufC8* mimetype = UPnPCommonUtils::ResolveMimeTypeL(aFilename);
-    	mimetype->Des().Trim();		// needs to be trimmed
-
-        TInt resultLen = KProtInfo1().Length() + KStar8().Length() + 
-    	KColon8().Length() + mimetype->Des().Length() + KColon8().Length() +
-        KStar8().Length();
-    	HBufC8* resValue = HBufC8::NewLC( resultLen );
-
-    // construct final value
-	    resValue->Des().Append( KProtInfo1 );
-	    resValue->Des().Append( KStar8 );
-	    resValue->Des().Append( KColon8 );
-	    resValue->Des().Append( *mimetype );
-	    resValue->Des().Append( KColon8 );
-	    resValue->Des().Append( KStar8 );
-
-		CUpnpProtocolInfo* pInfo = CUpnpProtocolInfo::NewL(*resValue);
-		CUpnpAttribute* attribute = CUpnpAttribute::NewLC( KAttributeProtocolInfo() );
-		attribute->SetValueL( pInfo->ProtocolInfoL() );
-		elRes->AddAttributeL( attribute );    
-    	aItem.AddElementL(elRes);
-
-		CleanupStack::Pop( attribute );
-		CleanupStack::PopAndDestroy( resValue );
-		CleanupStack::PopAndDestroy( resolver );
-    	CleanupStack::Pop( elRes );
-  		resValue = NULL;
-    	mimetype = NULL;
-    	
-    	return;
-    }
-    // Fixes ESLX-7B7HBL
-    else if( err )
-        {
-        User::Leave( err );
-        }
-
-    CleanupStack::PushL( resParameters );
-
-    // Add protocolInfo parameter to res element.
-    if ( resParameters->ProtocolInfo().Length() > 0 ) 
-        {
-        CUpnpAttribute* prInfo = CUpnpAttribute::NewLC( KAttributeProtocolInfo() );
-        prInfo->SetValueL( resParameters->ProtocolInfo() );   
-        elRes->AddAttributeL( prInfo ); //transfer ownership
-        CleanupStack::Pop( prInfo );       
-        }
-
-    // Add size parameter to res element.
-
-    HBufC8* sizeString = resParameters->FileSizeL();
-    if ( sizeString ) 
-        {
-        CleanupStack::PushL( sizeString );
-        CUpnpAttribute* size =
-            CUpnpAttribute::NewLC( KAttributeSize() );
-        size->SetValueL( *sizeString );
-
-        elRes->AddAttributeL( size ); //transfer ownership
-        CleanupStack::Pop( size );        
-        CleanupStack::PopAndDestroy( sizeString );
-        sizeString = NULL;
-        }
-
-    if ( resParameters->IsImageFile() ) 
-        {
-        // In image case, add resolution parameter to res element.
-        HBufC8* resolutionString = resParameters->ResolutionL();
-        if ( resolutionString ) 
-            {
-            CleanupStack::PushL( resolutionString );
-            CUpnpAttribute* resolution = 
-                CUpnpAttribute::NewLC( KAttributeResolution() );
-            resolution->SetValueL( *resolutionString );
-            elRes->AddAttributeL( resolution ); //transfer ownership
-            CleanupStack::Pop( resolution );            
-            CleanupStack::PopAndDestroy( resolutionString );
-            resolutionString = NULL;
-            }
-        }
-    else if ( resParameters->IsAudioOrVideoFile() )
-        {
-        // In music or video case, add duration parameter to res element.
-        HBufC8* durationString = resParameters->DurationL();
-        if ( durationString ) 
-            {
-            CleanupStack::PushL( durationString );
-            CUpnpAttribute* duration =
-                CUpnpAttribute::NewLC( KAttributeDuration() );
-            duration->SetValueL( *durationString );
-            elRes->AddAttributeL( duration ); //transfer ownership
-            CleanupStack::Pop( duration );
-            CleanupStack::PopAndDestroy( durationString );
-            durationString = NULL;
-            }
-        }
-
-    CleanupStack::PopAndDestroy( resParameters );
-    CleanupStack::PopAndDestroy( resolver );
-
-    // Attach res element to aItem.
-    aItem.AddElementL( elRes ); //transfer ownership
-    CleanupStack::Pop( elRes );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpCdsResElementUtility::IsUriAbsolute
-// 
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-EXPORT_C TBool UpnpCdsResElementUtility::IsUriAbsolute( const TDesC8& aUri )
-    {
-    TInetAddr addr;
-    TBool retVal = EFalse;
-    TBuf<KIpAddLen> ipAddrBuf;
-    // if aUri.Length is less than KHttp().Length(),aUri is invalid
-    if ( aUri.Length() >= KHttp().Length() )
-		{
-		TPtrC8 right = aUri.Right( aUri.Length() - KHttp().Length() );
-
-		TInt posit = right.Locate( TChar( KColon ) );
-		if( posit != KErrNotFound )
-			{
-			TPtrC8 ipAddr = right.Left( posit );
-			if( ipAddr.Length() <= KIpAddLen )
-				{
-				ipAddrBuf.Copy( ipAddr );
-				}
-			}
-
-		if( addr.Input( ipAddrBuf ) == KErrNone )
-			{
-			retVal = ETrue;
-			}
-		}
-
-	return retVal;    
-    }
-
-//  End of File  
+/*
+* Copyright (c) 2006-2007 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:  Utility class for meta data gathering for audio files
+*
+*/
+
+
+// INCLUDE FILES
+// System
+#include <e32std.h>
+#include <e32base.h>
+
+// upnp stack api
+#include <upnpitem.h> // CUpnpItem
+#include <upnpstring.h>
+#include <upnpelement.h>
+#include <upnpdlnaprotocolinfo.h>
+#include <upnpprotocolinfo.h>
+
+// upnpframework / avcontroller helper api
+#include "upnpconstantdefs.h" // for upnp class defs
+
+// upnpframework internal api's
+#include "upnpresresolver.h" // CUpnpResResolver
+#include "upnpresparameters.h"
+
+// utilities internal
+#include "upnpcommonutils.h"
+#include "upnpcdsreselementutility.h"
+
+_LIT( KHttp, "http://" );
+const TInt KColon = 58;
+const TInt KIpAddLen = 25;
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// --------------------------------------------------------------------------
+// CUpnpCdsResElementUtility::AddResElementL
+// 
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+EXPORT_C void UpnpCdsResElementUtility::AddResElementL( 
+                                                CUpnpItem& aItem, 
+                                                const TDesC& aFilename )
+    {
+
+    // Create CUpnpElement for res
+    CUpnpElement* elRes = CUpnpElement::NewL( KElementRes() );
+    CleanupStack::PushL( elRes );
+    elRes->SetFilePathL( aFilename );
+ 
+    // Create res resolver component and put it to CleanupStack
+    CUpnpResResolver* resolver = CUpnpResResolver::NewLC();
+    
+    // Obtain res element parameters using res resolver component.
+    CUpnpResParameters* resParameters = NULL;
+	TRAPD(err, resParameters = resolver->GetResParametersL( aFilename ) );
+
+   if (err == KErrGeneral)	
+    {
+	// File not recognized, handling it manually by adding
+	// following res-item:  'http-get:*:MIMETYPE:*'
+
+   		_LIT8( KProtInfo1, "http-get:");
+    	_LIT8( KStar8, "*");
+    	_LIT8( KColon8, ":");
+    	HBufC8* mimetype = UPnPCommonUtils::ResolveMimeTypeL(aFilename);
+    	CleanupStack::PushL( mimetype );
+    	mimetype->Des().Trim();		// needs to be trimmed
+
+        TInt resultLen = KProtInfo1().Length() + KStar8().Length() + 
+    	KColon8().Length() + mimetype->Des().Length() + KColon8().Length() +
+        KStar8().Length();
+    	HBufC8* resValue = HBufC8::NewLC( resultLen );
+        CleanupStack::Pop( resValue ); // temporarily pop so that mimetype can be destroyed
+        
+    // construct final value
+	    resValue->Des().Append( KProtInfo1 );
+	    resValue->Des().Append( KStar8 );
+	    resValue->Des().Append( KColon8 );
+	    resValue->Des().Append( *mimetype );
+	    resValue->Des().Append( KColon8 );
+	    resValue->Des().Append( KStar8 );
+        
+        CleanupStack::PopAndDestroy( mimetype );
+        mimetype = NULL;
+        CleanupStack::PushL( resValue );
+        
+		CUpnpProtocolInfo* pInfo = CUpnpProtocolInfo::NewL(*resValue);
+		CleanupStack::PushL( pInfo );
+		CUpnpAttribute* attribute = CUpnpAttribute::NewLC( KAttributeProtocolInfo() );
+		attribute->SetValueL( pInfo->ProtocolInfoL() );
+		elRes->AddAttributeL( attribute );    
+    	aItem.AddElementL(elRes);
+
+		CleanupStack::Pop( attribute );
+		CleanupStack::PopAndDestroy( pInfo );
+		CleanupStack::PopAndDestroy( resValue );
+		CleanupStack::PopAndDestroy( resolver );
+    	CleanupStack::Pop( elRes );
+  		resValue = NULL;
+    	
+    	return;
+    }
+    // Fixes ESLX-7B7HBL
+    else if( err )
+        {
+        User::Leave( err );
+        }
+
+    CleanupStack::PushL( resParameters );
+
+    // Add protocolInfo parameter to res element.
+    if ( resParameters->ProtocolInfo().Length() > 0 ) 
+        {
+        CUpnpAttribute* prInfo = CUpnpAttribute::NewLC( KAttributeProtocolInfo() );
+        prInfo->SetValueL( resParameters->ProtocolInfo() );   
+        elRes->AddAttributeL( prInfo ); //transfer ownership
+        CleanupStack::Pop( prInfo );       
+        }
+
+    // Add size parameter to res element.
+
+    HBufC8* sizeString = resParameters->FileSizeL();
+    if ( sizeString ) 
+        {
+        CleanupStack::PushL( sizeString );
+        CUpnpAttribute* size =
+            CUpnpAttribute::NewLC( KAttributeSize() );
+        size->SetValueL( *sizeString );
+
+        elRes->AddAttributeL( size ); //transfer ownership
+        CleanupStack::Pop( size );        
+        CleanupStack::PopAndDestroy( sizeString );
+        sizeString = NULL;
+        }
+
+    if ( resParameters->IsImageFile() ) 
+        {
+        // In image case, add resolution parameter to res element.
+        HBufC8* resolutionString = resParameters->ResolutionL();
+        if ( resolutionString ) 
+            {
+            CleanupStack::PushL( resolutionString );
+            CUpnpAttribute* resolution = 
+                CUpnpAttribute::NewLC( KAttributeResolution() );
+            resolution->SetValueL( *resolutionString );
+            elRes->AddAttributeL( resolution ); //transfer ownership
+            CleanupStack::Pop( resolution );            
+            CleanupStack::PopAndDestroy( resolutionString );
+            resolutionString = NULL;
+            }
+        }
+    else if ( resParameters->IsAudioOrVideoFile() )
+        {
+        // In music or video case, add duration parameter to res element.
+        HBufC8* durationString = resParameters->DurationL();
+        if ( durationString ) 
+            {
+            CleanupStack::PushL( durationString );
+            CUpnpAttribute* duration =
+                CUpnpAttribute::NewLC( KAttributeDuration() );
+            duration->SetValueL( *durationString );
+            elRes->AddAttributeL( duration ); //transfer ownership
+            CleanupStack::Pop( duration );
+            CleanupStack::PopAndDestroy( durationString );
+            durationString = NULL;
+            }
+        }
+
+    CleanupStack::PopAndDestroy( resParameters );
+    CleanupStack::PopAndDestroy( resolver );
+
+    // Attach res element to aItem.
+    aItem.AddElementL( elRes ); //transfer ownership
+    CleanupStack::Pop( elRes );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpCdsResElementUtility::IsUriAbsolute
+// 
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+EXPORT_C TBool UpnpCdsResElementUtility::IsUriAbsolute( const TDesC8& aUri )
+    {
+    TInetAddr addr;
+    TBool retVal = EFalse;
+    TBuf<KIpAddLen> ipAddrBuf;
+    // if aUri.Length is less than KHttp().Length(),aUri is invalid
+    if ( aUri.Length() >= KHttp().Length() )
+		{
+		TPtrC8 right = aUri.Right( aUri.Length() - KHttp().Length() );
+
+		TInt posit = right.Locate( TChar( KColon ) );
+		if( posit != KErrNotFound )
+			{
+			TPtrC8 ipAddr = right.Left( posit );
+			if( ipAddr.Length() <= KIpAddLen )
+				{
+				ipAddrBuf.Copy( ipAddr );
+				}
+			}
+
+		if( addr.Input( ipAddrBuf ) == KErrNone )
+			{
+			retVal = ETrue;
+			}
+		}
+
+	return retVal;    
+    }
+
+//  End of File  
--- a/upnpframework/upnputilities/src/upnpcommonutils.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/src/upnpcommonutils.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1124 +1,1316 @@
-/*
-* Copyright (c) 2005-2008 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:  Upnp framework's common utility functions
-*
-*/
-
-
-// INCLUDE FILES
-// System
-#include <e32std.h>
-#include <upnpstring.h>
-#include <apmrec.h>
-#include <apgcli.h>
-#include <WlanCdbCols.h>            // WLAN_SERVICE
-#include <caf/content.h>                // CAF (WM-DRM check)
-#include <caf/agent.h>                  // CAF (WM-DRM check)
-#include <commdb.h>
-#include <in_sock.h> 
-#include <pathinfo.h>
-
-// upnp stack api
-#include <upnpcontainerlist.h>
-#include <upnpcontainer.h>
-#include <upnpitem.h>
-#include <upnpdevice.h>
-
-// upnpframework / avcontroller helper api
-#include <upnpconstantdefs.h>
-
-// utilities internal
-#include "upnpfileutilitytypes.h"
-#include "upnpcommonutils.h"
-
-_LIT( KComponentLogfile, "upnputilities.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-_LIT8( KMimeAudio,          "audio" );
-_LIT8( KMimeVideo,          "video" );
-_LIT8( KMimeImage,          "image" );
-_LIT8( KMimePlaylist,       "audio/mpegurl" );
-
-_LIT16( KXHtml16,           ".XHTML" );
-_LIT16( KHtml16,            ".HTML" );
-_LIT16( KXml16,             ".XML" );
-_LIT16( KTxt16,             ".TXT" );
-_LIT16( KJpeg16,            ".JPEG" );
-_LIT16( KJpg16,             ".JPG" );
-_LIT16( KGif16,             ".GIF" );
-_LIT16( KPng16,             ".PNG" );
-_LIT16( KMpeg16,            ".MPEG" );
-_LIT16( KMpg16,             ".MPG" );
-_LIT16( KMpeg416,           ".MPEG4" );
-_LIT16( KAvi16,             ".AVI" );
-_LIT16( KMp316,             ".MP3" );
-_LIT16( KAac16,             ".AAC" );
-_LIT16( KWma16,             ".WMA" );
-_LIT8( KXHtml,              "application/vnd.pwg-xhtml-print" );
-_LIT8( KHtml,               "text/html" );
-_LIT8( KXml,                "text/xml" );
-_LIT8( KTxt,                "text/plain" );
-_LIT8( KJpg,                "image/jpeg" );
-_LIT8( KGif,                "image/gif" );
-_LIT8( KPng,                "image/png" );
-_LIT8( KMpeg,               "video/mpeg" );
-_LIT8( KMpeg4,              "video/mpeg4" );
-_LIT8( KMp3,                "audio/mpeg" );
-_LIT8( KAac,                "audio/aac" );
-_LIT8( KWma,                "audio/x-ms-wma" );
-_LIT8( KAvi,                "video/x-msvideo" );
-
-
-_LIT(  KLineFeed,           "\r\n");
-_LIT8( KHttpDes,            "http://" );
-_LIT( KTemp,                "upnpfwtemp");
-
-_LIT8( KUnderScore,         "_" );
-_LIT8( KStar,               "*" );
-_LIT8( KColon,              ":");
-_LIT8( KKorp,               "<" );
-_LIT8( KProk,               ">" );
-_LIT8( KQuotation,          "\"" );
-_LIT8( KDoubleBackSlash,    "\\" );
-_LIT8( KSlash,              "/" );
-_LIT8( KQuestionMark,       "?" );
-_LIT8( KPipe,               "|" );
-_LIT8( KTab,                "\t" );
-_LIT8( KSpace,              " " );
-
-const TInt KPlaceHolderLength       = 28;
-const TInt KBufferLength            = 256;
-const TInt KBufferLengthSmall       = 10;
-const TInt KCodeSemicolon           = 58;
-const TInt KMask                    = 0xFF;
-const TInt KCodeDot                 = 46;
-
-
-_LIT( KUpnpDateString,"%F%Y-%M-%D");
-const TInt KMaxDateStringLength = 30;
-
-
-
-_LIT8( KAudioSupport,        "audio/" );
-_LIT8( KImageSupport,        "image/" );
-_LIT8( KVideoSupport,        "video/" );
-
-_LIT8( KImageJpeg,         	"=JPEG_" );
-_LIT8( KImagePng,          	"=PNG_" );
-
-_LIT8( KAudioAc3,         	"=AC3" );
-_LIT8( KAudioAmr,         	"=AMR_" );
-_LIT8( KAudioAtra,         	"=ATRAC3plus" );
-_LIT8( KAudioLpcm,         	"=LPCM" );
-_LIT8( KAudioMp3,         	"=MP3" );
-_LIT8( KAudioAac,         	"=AAC_" );
-_LIT8( KAudioHeaac,        	"=HEAAC_" );
-_LIT8( KAudioBsac,         	"=BSAC_" );
-_LIT8( KAudioWmab,         	"=WMABASE" );
-_LIT8( KAudioWmaf,         	"=WMAFULL" );
-
-_LIT8( KAudioWmap,         	"=WMAPRO" );
-_LIT8( KVideoMpeg,          "=MPEG" );
-_LIT8( KVideoAvc,          	"=AVC_" );
-_LIT8( KVideoWmvm,         	"=WMVMED_" );
-_LIT8( KVideoVmvh,          "=WMVHIGH_" );
-_LIT8( KVideoWmvh,          "=WMVHM_" );
-_LIT8( KVideoWmvspll,       "=WMVSPLL_" );
-_LIT8( KVideoWmvspml,       "=WMVSPML_" );
-// ============================ LOCAL FUNCTIONS =============================
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::MemoryCardStateL
-//---------------------------------------------------------------------------
-//
-EXPORT_C TBool UPnPCommonUtils::MemoryCardStateL()
-    {
-    TDriveInfo driveInfo;
-
-    TBool status = EFalse;
-    RFs fileServer;
-    User::LeaveIfError( fileServer.Connect() );
-    CleanupClosePushL( fileServer );
-    TInt error = fileServer.Drive( driveInfo, EDriveE );
-    CleanupStack::PopAndDestroy( &fileServer );
-
-    //check if memory card is present
-    if ( error == KErrNone && driveInfo.iType == EMediaHardDisk )
-        {
-        status = ETrue;
-        }
-
-    return status;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::ResolveMimeTypeL
-// Resolves the MIME type of a file. Leaves in error cases.
-// --------------------------------------------------------------------------
-EXPORT_C HBufC8* UPnPCommonUtils::ResolveMimeTypeL( const TDesC& aFileName )
-    {
-    HBufC8* mimetype = NULL;
-
-    mimetype = GetMimeTypeByExtensionL( aFileName );
-
-    // If the mime type was not recognized by the extension, try the 
-    // platform mime type recognizer
-    if( !mimetype )
-        {           
-        // finding server
-        RApaLsSession sess; 
-        TInt error = sess.Connect();
-    
-        // We have FS, File and RApaLs open
-        if ( error == KErrNone )
-            {
-            CleanupClosePushL( sess );
-    
-            TUid id = TUid::Uid( 0 );
-            TDataType type;
-    
-            error = sess.AppForDocument( aFileName, id, type );
-    
-            if( error == KErrNone )
-                {
-                mimetype = HBufC8::NewL( type.Des8().Length() + 
-                                         KLineFeed().Length() );
-                mimetype->Des().Append( type.Des8() );
-                mimetype->Des().Append( KLineFeed() );
-                }
-                
-            // Clean up
-            CleanupStack::PopAndDestroy( &sess );
-            }
-        }
-
-    return mimetype;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::GetMimeTypeByExtensionL
-// Resolves the type of a file. Leaves in error cases.
-// --------------------------------------------------------------------------
-EXPORT_C HBufC8* UPnPCommonUtils::GetMimeTypeByExtensionL(
-    const TDesC& aFileName )
-    {
-    HBufC8* mimetype = NULL;
-    HBufC* tempFilename = aFileName.AllocL();
-    CleanupStack::PushL( tempFilename );
-
-    // Convert letters to upper case
-    tempFilename->Des().UpperCase();
-
-    TParse parse;
-    parse.Set( tempFilename->Des(), NULL, NULL );
-    TBufC<KMaxName> ext( parse.Ext() );
-
-    CleanupStack::PopAndDestroy( tempFilename );
-    tempFilename = NULL;
-
-    // FindC and length calculation is used,
-    // because compareC does not work for undefined reason  
-
-    if ( ext.FindC( KHtml16 ) == 0 && 
-         ext.Length() == KHtml16().Length() )
-        {
-        mimetype = HBufC8::NewLC( KHtml().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KHtml() );
-        }
-    else if ( ext.FindC( KXml16 ) == 0 && 
-              ext.Length() == KXml16().Length() )
-        {
-        mimetype = HBufC8::NewLC( KXml().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KXml() );
-        }
-    else if ( ext.FindC( KTxt16 ) == 0 && 
-              ext.Length() == KTxt16().Length() )
-        {
-        mimetype = HBufC8::NewLC( KTxt().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KTxt() );
-        }
-    else if ( ( ext.FindC( KJpg16 ) == 0 && 
-                ext.Length() == KJpg16().Length() ) ||
-                ( ext.FindC( KJpeg16 ) == 0 && 
-                  ext.Length() == KJpeg16().Length() ) )
-        {
-        mimetype = HBufC8::NewLC( KJpg().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KJpg() );
-        }       
-    else if ( ext.FindC( KGif16 ) == 0 && 
-              ext.Length() == KGif16().Length() )
-        {
-        mimetype = HBufC8::NewLC( KGif().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KGif() );
-        }   
-    else if ( ext.FindC( KPng16 ) == 0 && 
-              ext.Length() == KPng16().Length() )
-        {
-        mimetype = HBufC8::NewLC( KPng().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KPng() );
-        }
-    else if ( ( ext.FindC( KMpg16 ) == 0 &&
-                ext.Length() == KMpg16().Length() ) ||
-                ( ext.FindC( KMpeg16 ) == 0 &&
-                  ext.Length() == KMpeg16().Length() ) )
-        {
-        mimetype = HBufC8::NewLC( KMpeg().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KMpeg() );
-        }
-    else if ( ( ext.FindC( KMpeg416 ) == 0 && 
-                ext.Length() == KMpeg416().Length() ) )
-        {
-        mimetype = HBufC8::NewLC( KMpeg4().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KMpeg4() );
-        }
-    else if ( ext.FindC( KAvi16 ) == 0 && 
-              ext.Length() == KAvi16().Length() )
-        {
-        mimetype = HBufC8::NewLC( KAvi().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KAvi() );
-        }
-    else if ( ext.FindC( KMp316 ) == 0 && 
-              ext.Length() == KMp316().Length() )
-        {
-        mimetype = HBufC8::NewLC( KMp3().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KMp3() );
-        }
-    else if ( ext.FindC( KXHtml16 ) == 0 && 
-              ext.Length() == KXHtml16().Length() )
-        {
-        mimetype = HBufC8::NewLC( KXHtml().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KXHtml() );
-        }
-    else if ( ext.FindC( KAac16 ) == 0 && 
-              ext.Length() == KAac16().Length() )
-        {
-        mimetype = HBufC8::NewLC( KAac().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KAac() );
-        }
-    else if ( ext.FindC( KWma16 ) == 0 && 
-              ext.Length() == KWma16().Length() )
-        {
-        mimetype = HBufC8::NewLC( KWma().Length() );
-        mimetype->Des().Zero();
-        mimetype->Des().Append( KWma() );
-        }
-    else
-        {
-        // Mime type not recognized. Return NULL.        
-        }
-
-    if( mimetype )
-        {
-        CleanupStack::Pop( mimetype );
-        }
-
-    return mimetype;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::ResolveFileTypeL
-// Resolves the MIME type of a file. Leaves in error cases.
-// --------------------------------------------------------------------------
-EXPORT_C TUPnPItemType UPnPCommonUtils::ResolveFileTypeL(
-                                                    const TDesC& aFileName )
-    {
-    TUPnPItemType returnValue = ETypeOther;
-
-    if( aFileName != KNullDesC )
-        {
-
-        HBufC8* mimetype = NULL;
-        mimetype = ResolveMimeTypeL( aFileName );
-        if( mimetype )
-            {
-            CleanupStack::PushL( mimetype );
-
-            if( mimetype->Des().Find( KMimeImage() ) >= 0 )
-                {
-                returnValue = ETypeImage;
-                }
-            else if( mimetype->Des().Find( KMimePlaylist() ) >= 0 )
-                {
-                returnValue = ETypePlaylist;
-                }
-            else if( mimetype->Des().Find( KMimeAudio() ) >= 0 )
-                {
-                returnValue = ETypeAudio;
-                }
-            else if( mimetype->Des().Find( KMimeVideo() ) >= 0 )
-                {
-                returnValue = ETypeVideo;
-                }
-            else
-                {
-                returnValue = ETypeOther;
-                }
-    
-            // Clean up
-            CleanupStack::PopAndDestroy( mimetype );
-            mimetype = NULL;
-            }
-        else
-            {
-            returnValue = ETypeOther;
-            }
-        }
-    else
-        {
-        User::Leave( KErrArgument );
-        }
-
-    return returnValue;
-    }
-
-//---------------------------------------------------------------------------
-// UPnPCommonUtils::ReplacePlaceHolderInURIL
-// Replaces IP address and port number placeholders of the RES element's URI
-// string of the given item.
-//---------------------------------------------------------------------------
-//
-EXPORT_C void UPnPCommonUtils::ReplacePlaceHolderInURIL( 
-                                            CUpnpItem& aItem,
-                                            const TInetAddr& aAddress )
-    {
-    __LOG( "UPnPCommonUtils::ReplacePlaceHolderInURIL" );
-    
-    const RUPnPElementsArray& elms = aItem.GetElements();
-    
-    TInt count = elms.Count();
-    TInt i = 0;
-    for( ; i < count; i++)
-        {
-        if( elms[ i ]->Name() == KElementRes )
-            {
-            TPtrC8 ptrC( elms[ i ]->Value() );
-
-            HBufC8* addrBuf = HBufC8::NewLC( KBufferLength );
-            addrBuf->Des().Append( KHttpDes );
-            TBuf8<KBufferLengthSmall> buf;
-            TChar separator( KCodeSemicolon );
-            TChar dot( KCodeDot );
-            TUint32 addr = aAddress.Address();
-            buf.Num( addr >> 24 ); // First part of the ip address
-            addrBuf->Des().Append( buf );
-            addrBuf->Des().Append( dot );
-            buf.Num( ( addr >> 16 ) & KMask ); // Second part of ip address
-            addrBuf->Des().Append( buf );
-            addrBuf->Des().Append( dot );
-            buf.Num( ( addr >> 8 ) & KMask ); // Third part of the ip address
-            addrBuf->Des().Append( buf );
-            addrBuf->Des().Append( dot );
-            buf.Num( addr & KMask ); // last part of the ip address
-            addrBuf->Des().Append( buf );
-            addrBuf->Des().Append( separator );
-
-            buf.Num( aAddress.Port() ); // port number
-            addrBuf->Des().Append( buf );
-            
-            // Append rest of the uri
-            addrBuf->Des().Append( ptrC.Mid( KPlaceHolderLength ) );
-            
-            __LOG8( *addrBuf );
-            
-            elms[ i ]->SetValueL( *addrBuf );
-                        
-            CleanupStack::PopAndDestroy( addrBuf );
-            i = count;
-            }
-        }    
-    }
-    
-//---------------------------------------------------------------------------
-// UPnPCommonUtils::ReplaceIllegalFilenameCharactersL
-// Replaces the illegal filename characters from the given filename string
-// and returns a new fixed filename string. 8bit version.
-//---------------------------------------------------------------------------
-//
-EXPORT_C HBufC8* UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
-                                        const TDesC8& aFileName )
-    {
-    // Note that this implementation is a bit slow since it goes through the 
-    // descriptor many times. Only one iteration would be optimal solution.
-    HBufC8* buf = HBufC8::NewLC( aFileName.Length() );
-    TPtr8 ptr = buf->Des();
-    ptr.Copy( aFileName );
-    
-    UpnpString::StringReplaceInPlaceL( ptr, 
-                                       KProk(),
-                                       KUnderScore() );
-    UpnpString::StringReplaceInPlaceL( ptr,
-                                       KKorp(),
-                                       KUnderScore() );        
-    UpnpString::StringReplaceInPlaceL( ptr,
-                                       KQuotation(),
-                                       KUnderScore() );
-    UpnpString::StringReplaceInPlaceL( ptr,
-                                       KDoubleBackSlash(),
-                                       KUnderScore() );
-    UpnpString::StringReplaceInPlaceL( ptr, 
-                                       KSlash(),
-                                       KUnderScore() );
-    UpnpString::StringReplaceInPlaceL( ptr,
-                                       KStar(),
-                                       KUnderScore() );
-    UpnpString::StringReplaceInPlaceL( ptr,
-                                       KPipe(),
-                                       KUnderScore() );
-    UpnpString::StringReplaceInPlaceL( ptr,
-                                       KColon(),
-                                       KUnderScore() );
-    UpnpString::StringReplaceInPlaceL( ptr,
-                                       KQuestionMark(),
-                                       KUnderScore() );
-    UpnpString::StringReplaceInPlaceL( ptr,
-                                       KTab(),
-                                       KUnderScore() );
-    CleanupStack::Pop(); // Can't pop by name, name invalid now
-    return buf;
-    }    
-
-//---------------------------------------------------------------------------
-// UPnPCommonUtils::ReplaceIllegalFilenameCharactersL
-// Replaces the illegal filename characters from the given filename string
-// and returns a new fixed filename string. 16bit version.
-//---------------------------------------------------------------------------
-//
-EXPORT_C HBufC* UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
-                                        const TDesC& aFilename )
-    {
-    HBufC8* convertedParam = NULL;
-    convertedParam = UpnpString::FromUnicodeL( aFilename );
-    CleanupStack::PushL( convertedParam );
-    
-    HBufC8* replacedFilename8 = NULL;
-    replacedFilename8 = ReplaceIllegalFilenameCharactersL( *convertedParam );
-    CleanupStack::PushL( replacedFilename8 );
-
-    HBufC* replacedFilename16 = NULL;
-    replacedFilename16 = UpnpString::ToUnicodeL( *replacedFilename8 );
-    
-    // Clean up
-    CleanupStack::PopAndDestroy( replacedFilename8 );
-    CleanupStack::PopAndDestroy( convertedParam );
-                                            
-    return replacedFilename16;
-    }    
-
-//---------------------------------------------------------------------------
-// UPnPCommonUtils::IsPlaylistContainerL
-// Checks if the given CUpnpObject is a playlist container.
-//---------------------------------------------------------------------------
-//
-EXPORT_C TBool UPnPCommonUtils::IsPlaylistContainerL( 
-                                        const CUpnpObject& aContainer )
-    {
-    TBool returnValue = EFalse;
-    if( aContainer.ObjectType() != EUPnPContainer ||
-        aContainer.ObjectClass() == KNullDesC8 )
-        {
-        User::Leave( KErrArgument );
-        }
-    else
-        {
-        if( aContainer.ObjectClass().CompareF( KClassPlaylist() ) == 0 )
-            {
-            returnValue = ETrue;
-            }        
-        }
-    return returnValue;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::FindContainerByTitle
-// Finds container from CUpnpContainerList by title field
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpContainer* UPnPCommonUtils::FindContainerByTitle(
-    const CUpnpContainerList& aList, const TDesC8& aTitle )
-    {
-    TBool notFound( ETrue );
-    TInt index( 0 );
-    CUpnpContainer* tmp( NULL );
-
-    while ( index < aList.ObjectCount() && notFound )
-        {
-        tmp = static_cast< CUpnpContainer* >
-            ( aList[ index ] );
-        if ( tmp->Title().Compare( aTitle ) == 0 )
-            {
-            notFound = EFalse;
-            }
-        else
-            {
-            tmp = NULL;
-            }
-        index++;
-        }
-    return tmp;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::IntToDesC8LC
-// Returns IntValue for aObject
-// --------------------------------------------------------------------------
-//
-EXPORT_C HBufC8* UPnPCommonUtils::IntToDesC8LC( 
-    const TInt& aObject )
-    {
-    HBufC8* buf = HBufC8::NewLC(12);
-    TPtr8 ptrBuf = buf->Des();
-
-    ptrBuf.Num(aObject);
-
-    return buf;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::DesC8ToInt
-// Returns IntValue for aObject
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt UPnPCommonUtils::DesC8ToInt( 
-    const TDesC8& aObject )
-    {
-    TLex8 lex( aObject );
-
-    TInt lValue( KErrArgument );
-
-    lex.Val( lValue );
-    return lValue;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::TTimeToUPnPDateL
-// see upnpcommonutils.h
-// --------------------------------------------------------------------------
-EXPORT_C HBufC* UPnPCommonUtils::TTimeToUPnPDateL( TTime aTime )
-    {
-    TBuf<KMaxDateStringLength> date;        
-    aTime.FormatL( date, KUpnpDateString );
-
-    return date.AllocL();
-    }
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::RenameFileL
-// see upnpcommonutils.h
-// --------------------------------------------------------------------------
-EXPORT_C HBufC* UPnPCommonUtils::RenameFileL( const TDesC& aFilePath )
-    {
-    
-    //get the file extension include '.',e.g .jpg
-    TInt dot = aFilePath.LocateReverse( KCodeDot );
-    HBufC* extension = NULL;
-    if( dot > 0 ) //if there is extension
-        {
-        extension = aFilePath.Right( aFilePath.Length() - dot ).AllocL();
-        CleanupStack::PushL( extension );
-        }
-    else //if there is no extension
-        {
-        dot = aFilePath.Length();
-        }
-    // get the file path without extension: http://1.2.3//test
-    HBufC* leftString = aFilePath.Left( dot ).AllocL(); 
-    CleanupStack::PushL( leftString );
-    
-    //rename it: http:://1.2.3//test_upnptemp.jpg
-    HBufC* name_upnpfwtemp = NULL;
-    if( extension )
-        {
-        name_upnpfwtemp = HBufC::NewL( leftString->Length() + 
-                                          KTemp().Length() + 
-                                          extension->Length() );    
-        }
-    else
-        {
-        name_upnpfwtemp = HBufC::NewL( leftString->Length() + 
-                                       KTemp().Length() );
-        }
-                            
-    name_upnpfwtemp->Des().Append( *leftString );
-    name_upnpfwtemp->Des().Append( KTemp() );
-    
-    if( extension )
-        {
-        name_upnpfwtemp->Des().Append( *extension );
-        }
-    
-    
-    CleanupStack::PopAndDestroy( leftString );
-    
-    if( extension )
-        {
-        CleanupStack::PopAndDestroy( extension );
-        }
-    
-    
-    CleanupStack::PushL( name_upnpfwtemp );
-    
-    // try to rename the file
-    RFs fsSession;
-    User::LeaveIfError( fsSession.Connect() ); // connect session
-    CleanupClosePushL( fsSession );
-
-    TInt error = fsSession.Rename( aFilePath, *name_upnpfwtemp );
-
-    CleanupStack::PopAndDestroy( &fsSession );
-    CleanupStack::Pop( name_upnpfwtemp ); 
-    
-    if( KErrNone == error )
-        {
-        return name_upnpfwtemp; //transfer ownership
-        }
-    else
-        {
-        delete name_upnpfwtemp;
-        return NULL;
-        }
-    
-    }
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::DeleteTempFilesL
-// see upnpcommonutils.h
-// --------------------------------------------------------------------------
-EXPORT_C void UPnPCommonUtils::DeleteTempFilesL()
-    {
-    __LOG("UPnPCommonUtils::\
-DeleteTempFilesL begin");
-
-    RFs fs;
-    User::LeaveIfError( fs.Connect() ); // connect session
-    CleanupClosePushL( fs );
-
-    CFileMan* fileMan = CFileMan::NewL( fs );
-    CleanupStack::PushL( fileMan );
-    _LIT( KAnyChar, "*");
-    _LIT( KAnyExtension, "*.*");
-    _LIT( KUpnpUploadTempDirectory, "Download\\Media\\temp\\" );
-
-    // clean phone memory
-    HBufC* path = HBufC::NewLC( KMaxFileName );
-    TPtrC mcDrive( PathInfo::MemoryCardRootPath() );
-    path->Des().Append( mcDrive );
-    path->Des().Append( KUpnpUploadDirectory );
-    path->Des().Append( KAnyChar );
-    path->Des().Append( KTemp );
-    path->Des().Append( KAnyExtension );
-    fileMan->Delete( *path );
-    
-    path->Des().Zero();
-    path->Des().Append( mcDrive );
-    path->Des().Append( KUpnpUploadTempDirectory );
-    path->Des().Append( KAnyExtension );
-    fileMan->Delete( *path );
-    CleanupStack::PopAndDestroy( path );
-
-    // clean memory card
-    path = HBufC::NewLC( KMaxFileName );
-    TPtrC phoneDrive( PathInfo::PhoneMemoryRootPath() );
-    path->Des().Append( phoneDrive );
-    path->Des().Append( KUpnpUploadDirectory );
-    path->Des().Append( KAnyChar );
-    path->Des().Append( KTemp );
-    path->Des().Append( KAnyExtension );
-    fileMan->Delete( *path );
-    
-    path->Des().Zero();
-    path->Des().Append( phoneDrive );
-    path->Des().Append( KUpnpUploadTempDirectory );
-    path->Des().Append( KAnyExtension );
-    fileMan->Delete( *path );
-    CleanupStack::PopAndDestroy( path );
-
-    CleanupStack::PopAndDestroy( fileMan );
-    CleanupStack::PopAndDestroy( &fs );
-
-    __LOG("UPnPCommonUtils::\
-DeleteTempFilesL end");
-    }
-
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::IsImageSupported
-// see upnpcommonutils.h
-// --------------------------------------------------------------------------    
- EXPORT_C TBool UPnPCommonUtils::IsImageSupported( const TDesC8& aProtocolInfo )
-	{
-	// simple check
-	if( aProtocolInfo.Find( KImageSupport ) >= 0 )
-		{
-		return ETrue;
-		}
-		
-		
-	// check mime types	
-	if( aProtocolInfo.FindC( KImageJpeg ) > 0 )
-		{
-		return ETrue;
-		}
-		
-	if( aProtocolInfo.FindC( KImagePng ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	return EFalse;
-	}
-	
-	
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::IsAudioSupported
-// see upnpcommonutils.h
-// --------------------------------------------------------------------------
-EXPORT_C TBool UPnPCommonUtils::IsAudioSupported( const TDesC8& aProtocolInfo )
-	{
-	// simple check
-	if( aProtocolInfo.Find( KAudioSupport ) >= 0 )
-		{
-		return ETrue;
-		}
-		
-	
-	// check mime types	
-	if( aProtocolInfo.FindC( KAudioAc3 ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KAudioAmr ) > 0 )
-		{
-		return ETrue;
-		}
-
-	if( aProtocolInfo.FindC( KAudioAtra ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KAudioLpcm ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KAudioMp3 ) > 0 )
-		{
-		return ETrue;
-		}
-
-	if( aProtocolInfo.FindC( KAudioAac ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KAudioHeaac ) > 0 )
-		{
-		return ETrue;
-		}
-
-	if( aProtocolInfo.FindC( KAudioBsac ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KAudioWmab ) > 0 )
-		{
-		return ETrue;
-		}
-			
-	if( aProtocolInfo.FindC( KAudioWmaf ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KAudioWmap ) > 0 )
-		{
-		return ETrue;
-		}
-	
-
-	return EFalse;
-	}
-	
-	
-
-	
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::IsVideoSupported
-// see upnpcommonutils.h
-// --------------------------------------------------------------------------
-EXPORT_C TBool UPnPCommonUtils::IsVideoSupported( const TDesC8& aProtocolInfo )
-	{
-	// simple check
-	if( aProtocolInfo.Find( KVideoSupport ) >= 0 )
-		{
-		return ETrue;
-		}
-		
-		
-	// check mime types		
-	if( aProtocolInfo.FindC( KVideoMpeg ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KVideoAvc ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KVideoWmvm ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KVideoVmvh ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KVideoWmvh ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KVideoWmvspll ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	if( aProtocolInfo.FindC( KVideoWmvspml ) > 0 )
-		{
-		return ETrue;
-		}
-	
-	return EFalse;
-	}
-	
-// --------------------------------------------------------------------------
-// UPnPCommonUtils::FileExtensionByMimeTypeL
-// See upnpfileutility.h
-//---------------------------------------------------------------------------
-//
-EXPORT_C HBufC* UPnPCommonUtils::FileExtensionByMimeTypeL(
-    const TDesC8& aMimeType )
-    {
-    HBufC* fileExt = NULL;
-
-    // XHTML
-    if( aMimeType.CompareC( KXHtmlMime ) == 0 )
-        {
-        fileExt = KXHtmlExt().AllocL();
-        }
-    // HTML
-    else if( aMimeType.CompareC( KHtmlMime ) == 0 )
-        {
-        fileExt = KHtmlExt().AllocL();
-        }
-    // XML
-    else if( aMimeType.CompareC( KXmlMime1 ) == 0 ||
-             aMimeType.CompareC( KXmlMime2 ) == 0 ||
-             aMimeType.CompareC( KXmlMime3 ) == 0  )
-        {
-        fileExt = KXmlExt().AllocL();
-        }
-    // TXT    
-    else if( aMimeType.CompareC( KTxtMime )  == 0 ||
-             aMimeType.CompareC( KTxtMime2 ) == 0 ||
-             aMimeType.CompareC( KTxtMime3 ) == 0 ||
-             aMimeType.CompareC( KTxtMime4 ) == 0 ||
-             aMimeType.CompareC( KTxtMime5 ) == 0 ||
-             aMimeType.CompareC( KTxtMime6 ) == 0  )
-        {
-        fileExt = KTxtExt().AllocL();
-        }
-    // JPEG
-    else if( aMimeType.CompareC( KJpegMime ) == 0 )
-        {
-        fileExt = KJpegExt().AllocL();
-        }
-    // JPG
-    else if( aMimeType.CompareC( KJpegMime2 ) == 0 ||
-             aMimeType.CompareC( KJpegMime3 ) == 0 ||
-             aMimeType.CompareC( KJpegMime4 ) == 0 ||
-             aMimeType.CompareC( KJpegMime5 ) == 0  )
-        {
-        fileExt = KJpgExt().AllocL();
-        }
-    // GIF    
-    else if( aMimeType.CompareC( KGifMime )  == 0 ||
-             aMimeType.CompareC( KGifMime2 ) == 0 ||
-             aMimeType.CompareC( KGifMime3 ) == 0  )
-        {
-        fileExt = KGifExt().AllocL();
-        }
-    // PNG    
-    else if( aMimeType.CompareC( KPngMime )  == 0 ||
-             aMimeType.CompareC( KPngMime2 ) == 0 ||
-             aMimeType.CompareC( KPngMime3 ) == 0  )
-        {
-        fileExt = KPngExt().AllocL();
-        }
-    // MPG    
-    else if( aMimeType.CompareC( KMpgMime1 )  == 0 ||
-             aMimeType.CompareC( KMpgMime2 )  == 0 ||
-             aMimeType.CompareC( KMpgMime3 )  == 0 ||
-             aMimeType.CompareC( KMpgMime4 )  == 0 ||
-             aMimeType.CompareC( KMpgMime5 )  == 0 ||
-             aMimeType.CompareC( KMpgMime6 )  == 0 ||
-             aMimeType.CompareC( KMpgMime7 )  == 0 ||
-             aMimeType.CompareC( KMpgMime10 ) == 0  )
-        {
-        fileExt = KMpgExt1().AllocL();
-        }
-    // MPEG4    
-    else if( aMimeType.CompareC( KMpeg4Mime )  == 0 )
-        {
-        fileExt = KMpeg4Ext().AllocL();
-        }
-    // MP4        
-    else if( aMimeType.CompareC( KMp4Mime )  == 0 ||
-             aMimeType.CompareC( KMp4Mime2 ) == 0 ||
-             aMimeType.CompareC( KMp4Mime3 ) == 0  )
-        {
-        fileExt = KMp4Ext().AllocL();
-        }
-    // AVI
-    else if( aMimeType.CompareC( KAviMime1 ) == 0 ||
-             aMimeType.CompareC( KAviMime2 ) == 0 ||
-             aMimeType.CompareC( KAviMime3 ) == 0 ||
-             aMimeType.CompareC( KAviMime4 ) == 0 ||
-             aMimeType.CompareC( KAviMime5 ) == 0 ||
-             aMimeType.CompareC( KAviMime6 ) == 0 ||
-             aMimeType.CompareC( KAviMime7 ) == 0 ||
-             aMimeType.CompareC( KAviMime8 ) == 0 ||
-             aMimeType.CompareC( KAviMime9 ) == 0 )
-        {
-        fileExt = KAviExt().AllocL();
-        }
-    // MP3
-    else if( aMimeType.CompareC( KMp3Mime1 )  == 0 ||
-             aMimeType.CompareC( KMp3Mime2 )  == 0 ||
-             aMimeType.CompareC( KMp3Mime3 )  == 0 ||
-             aMimeType.CompareC( KMp3Mime4 )  == 0 ||
-             aMimeType.CompareC( KMp3Mime5 )  == 0 ||
-             aMimeType.CompareC( KMp3Mime6 )  == 0 ||
-             aMimeType.CompareC( KMp3Mime7 )  == 0 ||
-             aMimeType.CompareC( KMp3Mime8 )  == 0 ||
-             aMimeType.CompareC( KMp3Mime9 )  == 0 ||
-             aMimeType.CompareC( KMp3Mime10 ) == 0 )
-        {
-        fileExt = KMp3Ext().AllocL();
-        }
-    // AAC    
-    else if( aMimeType.CompareC( KAacMime )   == 0 ||
-             aMimeType.CompareC( KAacMime2 )  == 0 ||
-             aMimeType.CompareC( KAacMime3 )  == 0 ||
-             aMimeType.CompareC( KAacMime4 )  == 0 )
-        {
-        fileExt = KAacExt().AllocL();
-        }
-    //M4a
-    else if( aMimeType.CompareC( KM4aMime )   == 0 )
-       {
-       fileExt = KM4aExt().AllocL();
-       }
-    // WMA    
-    else if( aMimeType.CompareC( KWmaMime )   == 0 ||
-             aMimeType.CompareC( KWmaMime2 )  == 0 )
-        {
-        fileExt = KWmaExt().AllocL();
-        }
-    // BMP
-    else if( aMimeType.CompareC( KBmpMime )  == 0 ||
-             aMimeType.CompareC( KBmpMime2 ) == 0 ||
-             aMimeType.CompareC( KBmpMime3 ) == 0 ||
-             aMimeType.CompareC( KBmpMime4 ) == 0 ||
-             aMimeType.CompareC( KBmpMime5 ) == 0 ||
-             aMimeType.CompareC( KBmpMime6 ) == 0 ||
-             aMimeType.CompareC( KBmpMime7 ) == 0 ||
-             aMimeType.CompareC( KBmpMime8 ) == 0 ||
-             aMimeType.CompareC( KBmpMime9 ) == 0  )
-        {
-        fileExt = KBmpExt().AllocL();
-        }
-    // 3GP
-    else if( aMimeType.CompareC( KAudio3gpp ) == 0 ||
-             aMimeType.CompareC( KVideo3gpp ) == 0 ) 
-        {
-        fileExt = K3gpExt().AllocL();
-        }
-    // AMR
-    else if( aMimeType.CompareC( KAudioAMR )  == 0 )
-        {
-        fileExt = KAmrExt().AllocL();
-        }
-    // WAV
-    else if( aMimeType.CompareC( KAudioWav ) == 0 ||
-             aMimeType.CompareC( KAudioXWav ) == 0 ||
-             aMimeType.FindC( KAudioL16 ) != KErrNotFound )
-        {
-        fileExt = KWavExt().AllocL();
-        }
-    // Real audio    
-    else if ( aMimeType.CompareC( KRAMime8 )  == 0 )
-        {
-        fileExt = KRAExt().AllocL();
-        }
-    // TTS    
-    else if( aMimeType.CompareC( KVideoTts )  == 0 )
-        {
-        fileExt = KTtsExt().AllocL();
-        }
-    // WMV    
-    else if( aMimeType.CompareC( KWmvMime )  == 0 )
-        {
-        fileExt = KWmvExt().AllocL();        
-        }
-    return fileExt;
-    }
-
-//---------------------------------------------------------------------------
-// UPnPCommonUtils::FixListboxItemTextL
-// Removes the tab character of the given text
-// and returns a new fixed text string. 8bit version.
-//---------------------------------------------------------------------------
-//
-EXPORT_C HBufC8* UPnPCommonUtils::FixListboxItemTextL( const TDesC8& aText )
-    {
-    HBufC8* fixedText = HBufC8::NewLC( aText.Length() );
-    TPtr8 ptr = fixedText->Des();
-    ptr.Copy( aText );
-    
-    UpnpString::StringReplaceInPlaceL( ptr, 
-                                       KTab(),
-                                       KSpace() );   
-    CleanupStack::Pop(); // Can't pop by name, name invalid now
-    return fixedText;
-    }
-
-//  End of File
+/*
+* Copyright (c) 2005-2008 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:  Upnp framework's common utility functions
+*
+*/
+
+
+// INCLUDE FILES
+// System
+#include <e32std.h>
+#include <upnpstring.h>
+#include <apmrec.h>
+#include <apgcli.h>
+#include <WlanCdbCols.h>            // WLAN_SERVICE
+#include <caf/content.h>                // CAF (WM-DRM check)
+#include <caf/agent.h>                  // CAF (WM-DRM check)
+#include <commdb.h>
+#include <in_sock.h> 
+#include <pathinfo.h>
+
+// upnp stack api
+#include <upnpcontainerlist.h>
+#include <upnpcontainer.h>
+#include <upnpitem.h>
+#include <upnpdevice.h>
+
+// upnpframework / avcontroller helper api
+#include "upnpconstantdefs.h"
+
+// utilities internal
+#include "upnpfileutilitytypes.h"
+#include "upnpcommonutils.h"
+
+_LIT( KComponentLogfile, "upnputilities.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+_LIT8( KMimeAudio,          "audio" );
+_LIT8( KMimeVideo,          "video" );
+_LIT8( KMimeImage,          "image" );
+_LIT8( KMimePlaylist,       "audio/mpegurl" );
+
+_LIT16( KXHtml16,           ".XHTML" );
+_LIT16( KHtml16,            ".HTML" );
+_LIT16( KXml16,             ".XML" );
+_LIT16( KTxt16,             ".TXT" );
+_LIT16( KJpeg16,            ".JPEG" );
+_LIT16( KJpg16,             ".JPG" );
+_LIT16( KGif16,             ".GIF" );
+_LIT16( KPng16,             ".PNG" );
+_LIT16( KMpeg16,            ".MPEG" );
+_LIT16( KMpg16,             ".MPG" );
+_LIT16( KMpeg416,           ".MPEG4" );
+_LIT16( KAvi16,             ".AVI" );
+_LIT16( KMp316,             ".MP3" );
+_LIT16( KMp416,             ".MP4" );
+_LIT16( KAac16,             ".AAC" );
+_LIT16( KWma16,             ".WMA" );
+_LIT16( KTs16,              ".TS" );
+_LIT16( KMts16,             ".MTS" );
+_LIT16( KM2ts16,            ".M2TS" );
+_LIT8( KXHtml,              "application/vnd.pwg-xhtml-print" );
+_LIT8( KHtml,               "text/html" );
+_LIT8( KXml,                "text/xml" );
+_LIT8( KTxt,                "text/plain" );
+_LIT8( KJpg,                "image/jpeg" );
+_LIT8( KGif,                "image/gif" );
+_LIT8( KPng,                "image/png" );
+_LIT8( KMpeg,               "video/mpeg" );
+_LIT8( KMpeg4,              "video/mpeg4" );
+_LIT8( KMp3,                "audio/mpeg" );
+_LIT8( KMp4,                "video/mp4" );
+_LIT8( KAac,                "audio/aac" );
+_LIT8( KWma,                "audio/x-ms-wma" );
+_LIT8( KAvi,                "video/x-msvideo" );
+_LIT8( KTs,                 "video/mpeg" );
+_LIT8( KM2ts,               "video/vnd.dlna.mpeg-tts" );
+
+_LIT(  KLineFeed,           "\r\n");
+_LIT8( KHttpDes,            "http://" );
+_LIT( KTemp,                "upnpfwtemp");
+
+_LIT8( KUnderScore,         "_" );
+_LIT8( KStar,               "*" );
+_LIT8( KColon,              ":");
+_LIT8( KKorp,               "<" );
+_LIT8( KProk,               ">" );
+_LIT8( KQuotation,          "\"" );
+_LIT8( KDoubleBackSlash,    "\\" );
+_LIT8( KSlash,              "/" );
+_LIT8( KQuestionMark,       "?" );
+_LIT8( KPipe,               "|" );
+_LIT8( KTab,                "\t" );
+_LIT8( KSpace,              " " );
+
+const TInt KPlaceHolderLength       = 28;
+const TInt KBufferLength            = 256;
+const TInt KBufferLengthSmall       = 10;
+const TInt KCodeSemicolon           = 58;
+const TInt KMask                    = 0xFF;
+const TInt KCodeDot                 = 46;
+
+
+_LIT( KUpnpDateString,"%F%Y-%M-%D");
+const TInt KMaxDateStringLength = 30;
+
+
+
+_LIT8( KAudioSupport,        "audio/" );
+_LIT8( KImageSupport,        "image/" );
+_LIT8( KVideoSupport,        "video/" );
+
+_LIT8( KImageJpeg,         	"=JPEG_" );
+_LIT8( KImagePng,          	"=PNG_" );
+
+_LIT8( KAudioAc3,         	"=AC3" );
+_LIT8( KAudioAmr,         	"=AMR_" );
+_LIT8( KAudioAtra,         	"=ATRAC3plus" );
+_LIT8( KAudioLpcm,         	"=LPCM" );
+_LIT8( KAudioMp3,         	"=MP3" );
+_LIT8( KAudioAac,         	"=AAC_" );
+_LIT8( KAudioHeaac,        	"=HEAAC_" );
+_LIT8( KAudioBsac,         	"=BSAC_" );
+_LIT8( KAudioWmab,         	"=WMABASE" );
+_LIT8( KAudioWmaf,         	"=WMAFULL" );
+
+_LIT8( KAudioWmap,         	"=WMAPRO" );
+_LIT8( KVideoMpeg,          "=MPEG" );
+_LIT8( KVideoAvc,          	"=AVC_" );
+_LIT8( KVideoWmvm,         	"=WMVMED_" );
+_LIT8( KVideoVmvh,          "=WMVHIGH_" );
+_LIT8( KVideoWmvh,          "=WMVHM_" );
+_LIT8( KVideoWmvspll,       "=WMVSPLL_" );
+_LIT8( KVideoWmvspml,       "=WMVSPML_" );
+
+
+
+// ============================ LOCAL FUNCTIONS =============================
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::MemoryCardStateL
+//---------------------------------------------------------------------------
+//
+EXPORT_C TBool UPnPCommonUtils::MemoryCardStateL()
+    {
+    TDriveInfo driveInfo;
+
+    TBool status = EFalse;
+    RFs fileServer;
+    User::LeaveIfError( fileServer.Connect() );
+    CleanupClosePushL( fileServer );
+    TInt error = fileServer.Drive( driveInfo, EDriveE );
+    CleanupStack::PopAndDestroy( &fileServer );
+
+    //check if memory card is present
+    if ( error == KErrNone && driveInfo.iType == EMediaHardDisk )
+        {
+        status = ETrue;
+        }
+
+    return status;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::ResolveMimeTypeL
+// Resolves the MIME type of a file. Leaves in error cases.
+// --------------------------------------------------------------------------
+EXPORT_C HBufC8* UPnPCommonUtils::ResolveMimeTypeL( const TDesC& aFileName )
+    {
+    HBufC8* mimetype = NULL;
+
+    mimetype = GetMimeTypeByExtensionL( aFileName );
+
+    // If the mime type was not recognized by the extension, try the 
+    // platform mime type recognizer
+    if( !mimetype )
+        {           
+        // finding server
+        RApaLsSession sess; 
+        TInt error = sess.Connect();
+    
+        // We have FS, File and RApaLs open
+        if ( error == KErrNone )
+            {
+            CleanupClosePushL( sess );
+    
+            TUid id = TUid::Uid( 0 );
+            TDataType type;
+    
+            error = sess.AppForDocument( aFileName, id, type );
+    
+            if( error == KErrNone )
+                {
+                mimetype = HBufC8::NewL( type.Des8().Length() + 
+                                         KLineFeed().Length() );
+                mimetype->Des().Append( type.Des8() );
+                mimetype->Des().Append( KLineFeed() );
+                }
+                
+            // Clean up
+            CleanupStack::PopAndDestroy( &sess );
+            }
+        }
+
+    return mimetype;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::GetMimeTypeByExtensionL
+// Resolves the type of a file. Leaves in error cases.
+// --------------------------------------------------------------------------
+EXPORT_C HBufC8* UPnPCommonUtils::GetMimeTypeByExtensionL(
+    const TDesC& aFileName )
+    {
+    HBufC8* mimetype = NULL;
+    HBufC* tempFilename = aFileName.AllocL();
+    CleanupStack::PushL( tempFilename );
+
+    // Convert letters to upper case
+    tempFilename->Des().UpperCase();
+
+    TParse parse;
+    parse.Set( tempFilename->Des(), NULL, NULL );
+    TBufC<KMaxName> ext( parse.Ext() );
+
+    CleanupStack::PopAndDestroy( tempFilename );
+    tempFilename = NULL;
+
+    // FindC and length calculation is used,
+    // because compareC does not work for undefined reason  
+
+    GetMimeTypeforImageExtensionsL( ext,&mimetype );
+    GetMimeTypeforAudioVideoExtensionsL( ext,&mimetype );
+    GetMimeTypeforExtensionsL( ext,&mimetype );
+
+    return mimetype;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::ResolveFileTypeL
+// Resolves the MIME type of a file. Leaves in error cases.
+// --------------------------------------------------------------------------
+EXPORT_C TUPnPItemType UPnPCommonUtils::ResolveFileTypeL(
+                                                    const TDesC& aFileName )
+    {
+    TUPnPItemType returnValue = ETypeOther;
+
+    if( aFileName != KNullDesC )
+        {
+
+        HBufC8* mimetype = NULL;
+        mimetype = ResolveMimeTypeL( aFileName );
+        if( mimetype )
+            {
+            CleanupStack::PushL( mimetype );
+
+            if( mimetype->Des().Find( KMimeImage() ) >= 0 )
+                {
+                returnValue = ETypeImage;
+                }
+            else if( mimetype->Des().Find( KMimePlaylist() ) >= 0 )
+                {
+                returnValue = ETypePlaylist;
+                }
+            else if( mimetype->Des().Find( KMimeAudio() ) >= 0 )
+                {
+                returnValue = ETypeAudio;
+                }
+            else if( mimetype->Des().Find( KMimeVideo() ) >= 0 )
+                {
+                returnValue = ETypeVideo;
+                }
+            else
+                {
+                returnValue = ETypeOther;
+                }
+    
+            // Clean up
+            CleanupStack::PopAndDestroy( mimetype );
+            mimetype = NULL;
+            }
+        else
+            {
+            returnValue = ETypeOther;
+            }
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    return returnValue;
+    }
+
+//---------------------------------------------------------------------------
+// UPnPCommonUtils::ReplacePlaceHolderInURIL
+// Replaces IP address and port number placeholders of the RES element's URI
+// string of the given item.
+//---------------------------------------------------------------------------
+//
+EXPORT_C void UPnPCommonUtils::ReplacePlaceHolderInURIL( 
+                                            CUpnpItem& aItem,
+                                            const TInetAddr& aAddress )
+    {
+    __LOG( "UPnPCommonUtils::ReplacePlaceHolderInURIL" );
+    
+    const RUPnPElementsArray& elms = aItem.GetElements();
+    
+    TInt count = elms.Count();
+    TInt i = 0;
+    for( ; i < count; i++)
+        {
+        if( elms[ i ]->Name() == KElementRes )
+            {
+            TPtrC8 ptrC( elms[ i ]->Value() );
+
+            HBufC8* addrBuf = HBufC8::NewLC( KBufferLength );
+            addrBuf->Des().Append( KHttpDes );
+            TBuf8<KBufferLengthSmall> buf;
+            TChar separator( KCodeSemicolon );
+            TChar dot( KCodeDot );
+            TUint32 addr = aAddress.Address();
+            buf.Num( addr >> 24 ); // First part of the ip address
+            addrBuf->Des().Append( buf );
+            addrBuf->Des().Append( dot );
+            buf.Num( ( addr >> 16 ) & KMask ); // Second part of ip address
+            addrBuf->Des().Append( buf );
+            addrBuf->Des().Append( dot );
+            buf.Num( ( addr >> 8 ) & KMask ); // Third part of the ip address
+            addrBuf->Des().Append( buf );
+            addrBuf->Des().Append( dot );
+            buf.Num( addr & KMask ); // last part of the ip address
+            addrBuf->Des().Append( buf );
+            addrBuf->Des().Append( separator );
+
+            buf.Num( aAddress.Port() ); // port number
+            addrBuf->Des().Append( buf );
+            
+            // Append rest of the uri
+            addrBuf->Des().Append( ptrC.Mid( KPlaceHolderLength ) );
+            
+            __LOG8( *addrBuf );
+            
+            elms[ i ]->SetValueL( *addrBuf );
+                        
+            CleanupStack::PopAndDestroy( addrBuf );
+            i = count;
+            }
+        }    
+    }
+    
+//---------------------------------------------------------------------------
+// UPnPCommonUtils::ReplaceIllegalFilenameCharactersL
+// Replaces the illegal filename characters from the given filename string
+// and returns a new fixed filename string. 8bit version.
+//---------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
+                                        const TDesC8& aFileName )
+    {
+    // Note that this implementation is a bit slow since it goes through the 
+    // descriptor many times. Only one iteration would be optimal solution.
+    HBufC8* buf = HBufC8::NewLC( aFileName.Length() );
+    TPtr8 ptr = buf->Des();
+    ptr.Copy( aFileName );
+    
+    UpnpString::StringReplaceInPlaceL( ptr, 
+                                       KProk(),
+                                       KUnderScore() );
+    UpnpString::StringReplaceInPlaceL( ptr,
+                                       KKorp(),
+                                       KUnderScore() );        
+    UpnpString::StringReplaceInPlaceL( ptr,
+                                       KQuotation(),
+                                       KUnderScore() );
+    UpnpString::StringReplaceInPlaceL( ptr,
+                                       KDoubleBackSlash(),
+                                       KUnderScore() );
+    UpnpString::StringReplaceInPlaceL( ptr, 
+                                       KSlash(),
+                                       KUnderScore() );
+    UpnpString::StringReplaceInPlaceL( ptr,
+                                       KStar(),
+                                       KUnderScore() );
+    UpnpString::StringReplaceInPlaceL( ptr,
+                                       KPipe(),
+                                       KUnderScore() );
+    UpnpString::StringReplaceInPlaceL( ptr,
+                                       KColon(),
+                                       KUnderScore() );
+    UpnpString::StringReplaceInPlaceL( ptr,
+                                       KQuestionMark(),
+                                       KUnderScore() );
+    UpnpString::StringReplaceInPlaceL( ptr,
+                                       KTab(),
+                                       KUnderScore() );
+    CleanupStack::Pop(); // Can't pop by name, name invalid now
+    return buf;
+    }    
+
+//---------------------------------------------------------------------------
+// UPnPCommonUtils::ReplaceIllegalFilenameCharactersL
+// Replaces the illegal filename characters from the given filename string
+// and returns a new fixed filename string. 16bit version.
+//---------------------------------------------------------------------------
+//
+EXPORT_C HBufC* UPnPCommonUtils::ReplaceIllegalFilenameCharactersL( 
+                                        const TDesC& aFilename )
+    {
+    HBufC8* convertedParam = NULL;
+    convertedParam = UpnpString::FromUnicodeL( aFilename );
+    CleanupStack::PushL( convertedParam );
+    
+    HBufC8* replacedFilename8 = NULL;
+    replacedFilename8 = ReplaceIllegalFilenameCharactersL( *convertedParam );
+    CleanupStack::PushL( replacedFilename8 );
+
+    HBufC* replacedFilename16 = NULL;
+    replacedFilename16 = UpnpString::ToUnicodeL( *replacedFilename8 );
+    
+    // Clean up
+    CleanupStack::PopAndDestroy( replacedFilename8 );
+    CleanupStack::PopAndDestroy( convertedParam );
+                                            
+    return replacedFilename16;
+    }    
+
+//---------------------------------------------------------------------------
+// UPnPCommonUtils::IsPlaylistContainerL
+// Checks if the given CUpnpObject is a playlist container.
+//---------------------------------------------------------------------------
+//
+EXPORT_C TBool UPnPCommonUtils::IsPlaylistContainerL( 
+                                        const CUpnpObject& aContainer )
+    {
+    TBool returnValue = EFalse;
+    if( aContainer.ObjectType() != EUPnPContainer ||
+        aContainer.ObjectClass() == KNullDesC8 )
+        {
+        User::Leave( KErrArgument );
+        }
+    else
+        {
+        if( aContainer.ObjectClass().CompareF( KClassPlaylist() ) == 0 )
+            {
+            returnValue = ETrue;
+            }        
+        }
+    return returnValue;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::FindContainerByTitle
+// Finds container from CUpnpContainerList by title field
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpContainer* UPnPCommonUtils::FindContainerByTitle(
+    const CUpnpContainerList& aList, const TDesC8& aTitle )
+    {
+    TBool notFound( ETrue );
+    TInt index( 0 );
+    CUpnpContainer* tmp( NULL );
+
+    while ( index < aList.ObjectCount() && notFound )
+        {
+        tmp = static_cast< CUpnpContainer* >
+            ( aList[ index ] );
+        if ( tmp->Title().Compare( aTitle ) == 0 )
+            {
+            notFound = EFalse;
+            }
+        else
+            {
+            tmp = NULL;
+            }
+        index++;
+        }
+    return tmp;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::IntToDesC8LC
+// Returns IntValue for aObject
+// --------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* UPnPCommonUtils::IntToDesC8LC( 
+    const TInt& aObject )
+    {
+    HBufC8* buf = HBufC8::NewLC(12);
+    TPtr8 ptrBuf = buf->Des();
+
+    ptrBuf.Num(aObject);
+
+    return buf;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::DesC8ToInt
+// Returns IntValue for aObject
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt UPnPCommonUtils::DesC8ToInt( 
+    const TDesC8& aObject )
+    {
+    TLex8 lex( aObject );
+
+    TInt lValue( KErrArgument );
+
+    lex.Val( lValue );
+    return lValue;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::TTimeToUPnPDateL
+// see upnpcommonutils.h
+// --------------------------------------------------------------------------
+EXPORT_C HBufC* UPnPCommonUtils::TTimeToUPnPDateL( TTime aTime )
+    {
+    TBuf<KMaxDateStringLength> date;        
+    aTime.FormatL( date, KUpnpDateString );
+
+    return date.AllocL();
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::RenameFileL
+// see upnpcommonutils.h
+// --------------------------------------------------------------------------
+EXPORT_C HBufC* UPnPCommonUtils::RenameFileL( const TDesC& aFilePath )
+    {
+    
+    //get the file extension include '.',e.g .jpg
+    TInt dot = aFilePath.LocateReverse( KCodeDot );
+    HBufC* extension = NULL;
+    if( dot > 0 ) //if there is extension
+        {
+        extension = aFilePath.Right( aFilePath.Length() - dot ).AllocL();
+        CleanupStack::PushL( extension );
+        }
+    else //if there is no extension
+        {
+        dot = aFilePath.Length();
+        }
+    // get the file path without extension: http://1.2.3//test
+    HBufC* leftString = aFilePath.Left( dot ).AllocL(); 
+    CleanupStack::PushL( leftString );
+    
+    //rename it: http:://1.2.3//test_upnptemp.jpg
+    HBufC* name_upnpfwtemp = NULL;
+    if( extension )
+        {
+        name_upnpfwtemp = HBufC::NewL( leftString->Length() + 
+                                          KTemp().Length() + 
+                                          extension->Length() );    
+        }
+    else
+        {
+        name_upnpfwtemp = HBufC::NewL( leftString->Length() + 
+                                       KTemp().Length() );
+        }
+                            
+    name_upnpfwtemp->Des().Append( *leftString );
+    name_upnpfwtemp->Des().Append( KTemp() );
+    
+    if( extension )
+        {
+        name_upnpfwtemp->Des().Append( *extension );
+        }
+    
+    
+    CleanupStack::PopAndDestroy( leftString );
+    
+    if( extension )
+        {
+        CleanupStack::PopAndDestroy( extension );
+        }
+    
+    
+    CleanupStack::PushL( name_upnpfwtemp );
+    
+    // try to rename the file
+    RFs fsSession;
+    User::LeaveIfError( fsSession.Connect() ); // connect session
+    CleanupClosePushL( fsSession );
+
+    TInt error = fsSession.Rename( aFilePath, *name_upnpfwtemp );
+
+    CleanupStack::PopAndDestroy( &fsSession );
+    CleanupStack::Pop( name_upnpfwtemp ); 
+    
+    if( KErrNone == error )
+        {
+        return name_upnpfwtemp; //transfer ownership
+        }
+    else
+        {
+        delete name_upnpfwtemp;
+        return NULL;
+        }
+    
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::DeleteTempFilesL
+// see upnpcommonutils.h
+// --------------------------------------------------------------------------
+EXPORT_C void UPnPCommonUtils::DeleteTempFilesL()
+    {
+    __LOG("UPnPCommonUtils::\
+DeleteTempFilesL begin");
+
+    RFs fs;
+    User::LeaveIfError( fs.Connect() ); // connect session
+    CleanupClosePushL( fs );
+
+    CFileMan* fileMan = CFileMan::NewL( fs );
+    CleanupStack::PushL( fileMan );
+    _LIT( KAnyChar, "*");
+    _LIT( KAnyExtension, "*.*");
+    _LIT( KUpnpUploadTempDirectory, "Download\\Media\\temp\\" );
+
+    // clean phone memory
+    HBufC* path = HBufC::NewLC( KMaxFileName );
+    TPtrC mcDrive( PathInfo::MemoryCardRootPath() );
+    path->Des().Append( mcDrive );
+    path->Des().Append( KUpnpUploadDirectory );
+    path->Des().Append( KAnyChar );
+    path->Des().Append( KTemp );
+    path->Des().Append( KAnyExtension );
+    fileMan->Delete( *path );
+    
+    path->Des().Zero();
+    path->Des().Append( mcDrive );
+    path->Des().Append( KUpnpUploadTempDirectory );
+    path->Des().Append( KAnyExtension );
+    fileMan->Delete( *path );
+    CleanupStack::PopAndDestroy( path );
+
+    // clean memory card
+    path = HBufC::NewLC( KMaxFileName );
+    TPtrC phoneDrive( PathInfo::PhoneMemoryRootPath() );
+    path->Des().Append( phoneDrive );
+    path->Des().Append( KUpnpUploadDirectory );
+    path->Des().Append( KAnyChar );
+    path->Des().Append( KTemp );
+    path->Des().Append( KAnyExtension );
+    fileMan->Delete( *path );
+    
+    path->Des().Zero();
+    path->Des().Append( phoneDrive );
+    path->Des().Append( KUpnpUploadTempDirectory );
+    path->Des().Append( KAnyExtension );
+    fileMan->Delete( *path );
+    CleanupStack::PopAndDestroy( path );
+
+    CleanupStack::PopAndDestroy( fileMan );
+    CleanupStack::PopAndDestroy( &fs );
+
+    __LOG("UPnPCommonUtils::\
+DeleteTempFilesL end");
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::IsImageSupported
+// see upnpcommonutils.h
+// --------------------------------------------------------------------------    
+ EXPORT_C TBool UPnPCommonUtils::IsImageSupported( const TDesC8& aProtocolInfo )
+	{
+	// simple check
+	if( aProtocolInfo.Find( KImageSupport ) >= 0 )
+		{
+		return ETrue;
+		}
+		
+		
+	// check mime types	
+	if( aProtocolInfo.FindC( KImageJpeg ) > 0 )
+		{
+		return ETrue;
+		}
+		
+	if( aProtocolInfo.FindC( KImagePng ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	return EFalse;
+	}
+	
+	
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::IsAudioSupported
+// see upnpcommonutils.h
+// --------------------------------------------------------------------------
+EXPORT_C TBool UPnPCommonUtils::IsAudioSupported( const TDesC8& aProtocolInfo )
+	{
+	// simple check
+	if( aProtocolInfo.Find( KAudioSupport ) >= 0 )
+		{
+		return ETrue;
+		}
+		
+	
+	// check mime types	
+	if( aProtocolInfo.FindC( KAudioAc3 ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KAudioAmr ) > 0 )
+		{
+		return ETrue;
+		}
+
+	if( aProtocolInfo.FindC( KAudioAtra ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KAudioLpcm ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KAudioMp3 ) > 0 )
+		{
+		return ETrue;
+		}
+
+	if( aProtocolInfo.FindC( KAudioAac ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KAudioHeaac ) > 0 )
+		{
+		return ETrue;
+		}
+
+	if( aProtocolInfo.FindC( KAudioBsac ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KAudioWmab ) > 0 )
+		{
+		return ETrue;
+		}
+			
+	if( aProtocolInfo.FindC( KAudioWmaf ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KAudioWmap ) > 0 )
+		{
+		return ETrue;
+		}
+	
+
+	return EFalse;
+	}
+	
+	
+
+	
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::IsVideoSupported
+// see upnpcommonutils.h
+// --------------------------------------------------------------------------
+EXPORT_C TBool UPnPCommonUtils::IsVideoSupported( const TDesC8& aProtocolInfo )
+	{
+	// simple check
+	if( aProtocolInfo.Find( KVideoSupport ) >= 0 )
+		{
+		return ETrue;
+		}
+		
+		
+	// check mime types		
+	if( aProtocolInfo.FindC( KVideoMpeg ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KVideoAvc ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KVideoWmvm ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KVideoVmvh ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KVideoWmvh ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KVideoWmvspll ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	if( aProtocolInfo.FindC( KVideoWmvspml ) > 0 )
+		{
+		return ETrue;
+		}
+	
+	return EFalse;
+	}
+	
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::FileExtensionByMimeTypeL
+// See upnpfileutility.h
+//---------------------------------------------------------------------------
+//
+EXPORT_C HBufC* UPnPCommonUtils::FileExtensionByMimeTypeL(
+    const TDesC8& aMimeType )
+    {
+    HBufC* fileExt = NULL;
+    
+    GetFileExtensionForImageMimeTypesL( aMimeType,&fileExt );
+    
+    if(!fileExt)
+        {
+        GetFileExtensionForAudioMimeTypesL( aMimeType,&fileExt );
+        }
+    if(!fileExt)
+        {
+        GetFileExtensionForVideoMimeTypesL( aMimeType,&fileExt );
+        }
+    if(!fileExt)
+        {
+        GetFileExtensionForMimeTypesL( aMimeType,&fileExt );
+        }
+    if(!fileExt)
+        {
+        // AMR
+         if( aMimeType.CompareC( KAudioAMR )  == 0 )
+            {
+            fileExt = KAmrExt().AllocL();
+            }
+        // Real audio    
+        else if ( aMimeType.CompareC( KRAMime8 )  == 0 )
+            {
+            fileExt = KRAExt().AllocL();
+            }
+        }
+    
+    return fileExt;
+    }
+
+//---------------------------------------------------------------------------
+// UPnPCommonUtils::FixListboxItemTextL
+// Removes the tab character of the given text
+// and returns a new fixed text string. 8bit version.
+//---------------------------------------------------------------------------
+//
+EXPORT_C HBufC8* UPnPCommonUtils::FixListboxItemTextL( const TDesC8& aText )
+    {
+    HBufC8* fixedText = HBufC8::NewLC( aText.Length() );
+    TPtr8 ptr = fixedText->Des();
+    ptr.Copy( aText );
+    
+    UpnpString::StringReplaceInPlaceL( ptr, 
+                                       KTab(),
+                                       KSpace() );   
+    CleanupStack::Pop(); // Can't pop by name, name invalid now
+    return fixedText;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPCommonUtils::FileTypeByMimeTypeL
+// Get the file type based on MIME type of the file. Leaves in error cases.
+// --------------------------------------------------------------------------
+EXPORT_C TUPnPItemType UPnPCommonUtils::FileTypeByMimeTypeL(
+        const TDesC8& aMimeType )
+    {
+    TUPnPItemType returnValue = ETypeOther;
+
+    if( aMimeType != KNullDesC8 )
+        {
+        if( aMimeType.Find( KMimeImage() ) >= 0 )
+            {
+            returnValue = ETypeImage;
+            }
+        else if( aMimeType.Find( KMimePlaylist() ) >= 0 )
+            {
+            returnValue = ETypePlaylist;
+            }
+        else if( aMimeType.Find( KMimeAudio() ) >= 0 )
+            {
+            returnValue = ETypeAudio;
+            }
+        else if( aMimeType.Find( KMimeVideo() ) >= 0 )
+            {
+            returnValue = ETypeVideo;
+            }
+        else
+            {
+            returnValue = ETypeOther;
+            }
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    return returnValue;
+    }
+
+void UPnPCommonUtils::GetMimeTypeforImageExtensionsL( const TDesC& aExt , HBufC8** aMimeType)
+    {
+    if(*aMimeType != NULL)
+         return;
+    // FindC and length calculation is used,
+    // because compareC does not work for undefined reason
+    if ( ( aExt.FindC( KJpg16 ) == 0 && 
+            aExt.Length() == KJpg16().Length() ) ||
+                    ( aExt.FindC( KJpeg16 ) == 0 && 
+                            aExt.Length() == KJpeg16().Length() ) )
+            {
+            *aMimeType = HBufC8::NewLC( KJpg().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KJpg() );
+            }       
+        else if ( aExt.FindC( KGif16 ) == 0 && 
+                aExt.Length() == KGif16().Length() )
+            {
+            *aMimeType = HBufC8::NewLC( KGif().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KGif() );
+            }   
+        else if ( aExt.FindC( KPng16 ) == 0 && 
+                aExt.Length() == KPng16().Length() )
+            {
+            *aMimeType = HBufC8::NewLC( KPng().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KPng() );
+            }
+    if( *aMimeType )
+        {
+        CleanupStack::Pop( *aMimeType );
+        }
+    
+    }
+    
+void UPnPCommonUtils::GetMimeTypeforAudioVideoExtensionsL( const TDesC& aExt , HBufC8** aMimeType)
+    {
+    if(*aMimeType != NULL)
+         return;
+    
+    // FindC and length calculation is used,
+    // because compareC does not work for undefined reason
+    if ( ( aExt.FindC( KMpg16 ) == 0 &&
+                aExt.Length() == KMpg16().Length() ) ||
+                ( aExt.FindC( KMpeg16 ) == 0 &&
+                  aExt.Length() == KMpeg16().Length() ) )
+            {
+            *aMimeType = HBufC8::NewLC( KMpeg().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KMpeg() );
+            }
+        else if ( ( aExt.FindC( KMpeg416 ) == 0 && 
+                    aExt.Length() == KMpeg416().Length() ) )
+            {
+            *aMimeType = HBufC8::NewLC( KMpeg4().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KMpeg4() );
+            }
+        else if ( aExt.FindC( KAvi16 ) == 0 && 
+                  aExt.Length() == KAvi16().Length() )
+            {
+            *aMimeType = HBufC8::NewLC( KAvi().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KAvi() );
+            }
+        else if ( aExt.FindC( KMp316 ) == 0 && 
+                  aExt.Length() == KMp316().Length() )
+            {
+            *aMimeType = HBufC8::NewLC( KMp3().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KMp3() );
+            }
+        else if ( aExt.FindC( KMp416 ) == 0 && 
+                  aExt.Length() == KMp416().Length() )
+            {
+            *aMimeType = HBufC8::NewLC( KMp4().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KMp4() );
+            }
+        else if ( aExt.FindC( KAac16 ) == 0 && 
+                  aExt.Length() == KAac16().Length() )
+            {
+            *aMimeType = HBufC8::NewLC( KAac().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KAac() );
+            }
+        else if ( aExt.FindC( KWma16 ) == 0 && 
+                  aExt.Length() == KWma16().Length() )
+            {
+            *aMimeType = HBufC8::NewLC( KWma().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KWma() );
+            }
+        else if ( aExt.FindC( KTs16 ) == 0 &&
+                  aExt.Length() == KTs16().Length() )
+            {
+            *aMimeType = HBufC8::NewLC( KTs().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KTs() );            
+            }
+        else if ( ( aExt.FindC( KMts16 ) == 0 &&
+                    aExt.Length() == KMts16().Length() ) ||
+                  ( aExt.FindC( KM2ts16 ) == 0 &&
+                    aExt.Length() == KM2ts16().Length() ) )
+            {
+            *aMimeType = HBufC8::NewLC( KM2ts().Length() );
+            (*aMimeType)->Des().Zero();
+            (*aMimeType)->Des().Append( KM2ts() );            
+            }
+    if( *aMimeType )
+        {
+        CleanupStack::Pop( *aMimeType );
+        }
+    }
+    
+void UPnPCommonUtils::GetMimeTypeforExtensionsL( const TDesC& aExt , HBufC8** aMimeType)
+    {
+    if(*aMimeType != NULL)
+        return;
+    
+    // FindC and length calculation is used,
+    // because compareC does not work for undefined reason
+    if ( aExt.FindC( KHtml16 ) == 0 && 
+            aExt.Length() == KHtml16().Length() )
+        {
+        *aMimeType = HBufC8::NewLC( KHtml().Length() );
+        (*aMimeType)->Des().Zero();
+        (*aMimeType)->Des().Append( KHtml() );
+        }
+    else if ( aExt.FindC( KXml16 ) == 0 && 
+            aExt.Length() == KXml16().Length() )
+        {
+        *aMimeType = HBufC8::NewLC( KXml().Length() );
+        (*aMimeType)->Des().Zero();
+        (*aMimeType)->Des().Append( KXml() );
+        }
+    else if ( aExt.FindC( KTxt16 ) == 0 && 
+            aExt.Length() == KTxt16().Length() )
+        {
+        *aMimeType = HBufC8::NewLC( KTxt().Length() );
+        (*aMimeType)->Des().Zero();
+        (*aMimeType)->Des().Append( KTxt() );
+        }
+    else if ( aExt.FindC( KXHtml16 ) == 0 && 
+                      aExt.Length() == KXHtml16().Length() )
+        {
+        *aMimeType = HBufC8::NewLC( KXHtml().Length() );
+        (*aMimeType)->Des().Zero();
+        (*aMimeType)->Des().Append( KXHtml() );
+        }
+    
+    if( *aMimeType )
+        {
+        CleanupStack::Pop( *aMimeType );
+        }
+    }
+
+void UPnPCommonUtils::GetFileExtensionForMimeTypesL(const TDesC8& aMimeType,HBufC** aFileExt)
+    {
+    if(*aFileExt != NULL)
+          return;
+    // XHTML
+    if( aMimeType.CompareC( KXHtmlMime ) == 0 )
+        {
+        *aFileExt = KXHtmlExt().AllocL();
+        }
+    // HTML
+    else if( aMimeType.CompareC( KHtmlMime ) == 0 )
+        {
+        *aFileExt = KHtmlExt().AllocL();
+        }
+    // XML
+    else if( aMimeType.CompareC( KXmlMime1 ) == 0 ||
+             aMimeType.CompareC( KXmlMime2 ) == 0 ||
+             aMimeType.CompareC( KXmlMime3 ) == 0  )
+        {
+        *aFileExt = KXmlExt().AllocL();
+        }
+    // TXT    
+    else if( aMimeType.CompareC( KTxtMime )  == 0 ||
+             aMimeType.CompareC( KTxtMime2 ) == 0 ||
+             aMimeType.CompareC( KTxtMime3 ) == 0 ||
+             aMimeType.CompareC( KTxtMime4 ) == 0 ||
+             aMimeType.CompareC( KTxtMime5 ) == 0 ||
+             aMimeType.CompareC( KTxtMime6 ) == 0  )
+        {
+        *aFileExt = KTxtExt().AllocL();
+        }
+    }
+   
+void UPnPCommonUtils::GetFileExtensionForImageMimeTypesL(const TDesC8& aMimeType,HBufC** aFileExt)
+    {
+    // JPEG
+    if( aMimeType.CompareC( KJpegMime ) == 0 )
+        {
+        *aFileExt = KJpegExt().AllocL();
+        }
+    // JPG
+    else if( aMimeType.CompareC( KJpegMime2 ) == 0 ||
+             aMimeType.CompareC( KJpegMime3 ) == 0 ||
+             aMimeType.CompareC( KJpegMime4 ) == 0 ||
+             aMimeType.CompareC( KJpegMime5 ) == 0  )
+        {
+        *aFileExt = KJpgExt().AllocL();
+        }
+    // GIF    
+    else if( aMimeType.CompareC( KGifMime )  == 0 ||
+             aMimeType.CompareC( KGifMime2 ) == 0 ||
+             aMimeType.CompareC( KGifMime3 ) == 0  )
+        {
+        *aFileExt = KGifExt().AllocL();
+        }
+    // PNG    
+    else if( aMimeType.CompareC( KPngMime )  == 0 ||
+             aMimeType.CompareC( KPngMime2 ) == 0 ||
+             aMimeType.CompareC( KPngMime3 ) == 0  )
+        {
+        *aFileExt = KPngExt().AllocL();
+        }
+    else
+        {
+        GetFileExtensionForBMPandMP3MimeTypesL( aMimeType,aFileExt );
+        }
+    
+    }
+
+void UPnPCommonUtils::GetFileExtensionForBMPandMP3MimeTypesL(const TDesC8& aMimeType,HBufC** aFileExt)
+    {
+    if( aMimeType.CompareC( KBmpMime )  == 0 ||
+             aMimeType.CompareC( KBmpMime2 ) == 0 ||
+             aMimeType.CompareC( KBmpMime3 ) == 0 ||
+             aMimeType.CompareC( KBmpMime4 ) == 0 ||
+             aMimeType.CompareC( KBmpMime5 ) == 0 ||
+             aMimeType.CompareC( KBmpMime6 ) == 0 ||
+             aMimeType.CompareC( KBmpMime7 ) == 0 ||
+             aMimeType.CompareC( KBmpMime8 ) == 0 ||
+             aMimeType.CompareC( KBmpMime9 ) == 0  )
+        {
+        *aFileExt = KBmpExt().AllocL();
+        }
+    // MP3
+    else if( aMimeType.CompareC( KMp3Mime1 )  == 0 ||
+             aMimeType.CompareC( KMp3Mime2 )  == 0 ||
+             aMimeType.CompareC( KMp3Mime3 )  == 0 ||
+             aMimeType.CompareC( KMp3Mime4 )  == 0 ||
+             aMimeType.CompareC( KMp3Mime5 )  == 0 ||
+             aMimeType.CompareC( KMp3Mime6 )  == 0 ||
+             aMimeType.CompareC( KMp3Mime7 )  == 0 ||
+             aMimeType.CompareC( KMp3Mime8 )  == 0 ||
+             aMimeType.CompareC( KMp3Mime9 )  == 0 ||
+             aMimeType.CompareC( KMp3Mime10 ) == 0 )
+        {
+        *aFileExt = KMp3Ext().AllocL();
+        }
+    
+    }
+
+   
+void UPnPCommonUtils::GetFileExtensionForAudioMimeTypesL(const TDesC8& aMimeType,HBufC** aFileExt)
+    {
+    // MPG
+    if( aMimeType.CompareC( KMpgMime1 )  == 0 ||
+             aMimeType.CompareC( KMpgMime2 )  == 0 ||
+             aMimeType.CompareC( KMpgMime3 )  == 0 ||
+             aMimeType.CompareC( KMpgMime4 )  == 0 ||
+             aMimeType.CompareC( KMpgMime5 )  == 0 ||
+             aMimeType.CompareC( KMpgMime6 )  == 0 ||
+             aMimeType.CompareC( KMpgMime7 )  == 0 ||
+             aMimeType.CompareC( KMpgMime10 ) == 0  )
+        {
+        *aFileExt = KMpgExt1().AllocL();
+        }
+    // AAC    
+    else if( aMimeType.CompareC( KAacMime )   == 0 ||
+             aMimeType.CompareC( KAacMime2 )  == 0 ||
+             aMimeType.CompareC( KAacMime3 )  == 0 ||
+             aMimeType.CompareC( KAacMime4 )  == 0 )
+        {
+        *aFileExt = KAacExt().AllocL();
+        }
+    //M4a
+    else if( aMimeType.CompareC( KM4aMime )   == 0 )
+       {
+       *aFileExt = KM4aExt().AllocL();
+       }
+    // WAV
+    else if( aMimeType.CompareC( KAudioWav ) == 0 ||
+             aMimeType.CompareC( KAudioXWav ) == 0 ||
+             aMimeType.FindC( KAudioL16 ) != KErrNotFound )
+        {
+        *aFileExt = KWavExt().AllocL();
+        }
+    // WMA    
+    else if( aMimeType.CompareC( KWmaMime )   == 0 ||
+             aMimeType.CompareC( KWmaMime2 )  == 0 )
+        {
+        *aFileExt = KWmaExt().AllocL();
+        }
+    
+    }
+
+void UPnPCommonUtils::GetFileExtensionForVideoMimeTypesL(const TDesC8& aMimeType,HBufC** aFileExt)
+    {
+    // MPEG4    
+    if( aMimeType.CompareC( KMpeg4Mime )  == 0 )
+        {
+        *aFileExt = KMpeg4Ext().AllocL();
+        }
+    // MP4        
+    else if( aMimeType.CompareC( KMp4Mime )  == 0 ||
+             aMimeType.CompareC( KMp4Mime2 ) == 0 ||
+             aMimeType.CompareC( KMp4Mime3 ) == 0  )
+        {
+        *aFileExt = KMp4Ext().AllocL();
+        }
+    // AVI
+    else if( aMimeType.CompareC( KAviMime1 ) == 0 ||
+             aMimeType.CompareC( KAviMime2 ) == 0 ||
+             aMimeType.CompareC( KAviMime3 ) == 0 ||
+             aMimeType.CompareC( KAviMime4 ) == 0 ||
+             aMimeType.CompareC( KAviMime5 ) == 0 ||
+             aMimeType.CompareC( KAviMime6 ) == 0 ||
+             aMimeType.CompareC( KAviMime7 ) == 0 ||
+             aMimeType.CompareC( KAviMime8 ) == 0 ||
+             aMimeType.CompareC( KAviMime9 ) == 0 )
+        {
+        *aFileExt = KAviExt().AllocL();
+        }
+    // 3GP
+    else if( aMimeType.CompareC( KAudio3gpp ) == 0 ||
+             aMimeType.CompareC( KVideo3gpp ) == 0 ) 
+        {
+        *aFileExt = K3gpExt().AllocL();
+        }
+    // TTS    
+    else if( aMimeType.CompareC( KVideoTts )  == 0 )
+        {
+        *aFileExt = KTtsExt().AllocL();
+        }
+    // WMV    
+    else if( aMimeType.CompareC( KWmvMime )  == 0 )
+        {
+        *aFileExt = KWmvExt().AllocL();        
+        }
+    }
+
+EXPORT_C HBufC8* UPnPCommonUtils::ReplaceIllegalDirNameCharactersL( 
+                                        const TDesC8& aDirName )
+    {
+    HBufC8* replacedDirName = ReplaceIllegalFilenameCharactersL( aDirName );
+    TPtr8 ptr( replacedDirName->Des() );
+            
+    // In case of a dir name, if the last char is a dot, it must be
+    // replaced
+    TInt length( aDirName.Length() );
+    TChar dot( KCodeDot );
+    if( length > 0 && ptr.LocateReverse( dot ) == length - 1 )        
+        {
+        ptr.Replace( length - 1, 1, KUnderScore() );
+        }
+    
+    return replacedDirName;
+    }
+
+EXPORT_C HBufC* UPnPCommonUtils::ReplaceIllegalDirNameCharactersL( 
+                                        const TDesC& aDirName )
+    {
+    HBufC8* convertedParam = NULL;
+    convertedParam = UpnpString::FromUnicodeL( aDirName );
+    CleanupStack::PushL( convertedParam );
+    
+    HBufC8* replacedDirName8 = NULL;
+    replacedDirName8 = ReplaceIllegalDirNameCharactersL( *convertedParam );
+    CleanupStack::PushL( replacedDirName8 );
+
+    HBufC* replacedDirName16 = NULL;
+    replacedDirName16 = UpnpString::ToUnicodeL( *replacedDirName8 );
+    
+    // Clean up
+    CleanupStack::PopAndDestroy( replacedDirName8 );
+    CleanupStack::PopAndDestroy( convertedParam );
+                                            
+    return replacedDirName16; 
+    }
+
+//  End of File
--- a/upnpframework/upnputilities/src/upnpconnectionmonitor.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/src/upnpconnectionmonitor.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,305 +1,389 @@
-/*
-* Copyright (c) 2008 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:  UPnP Connection Monitor class implementation.
-*
-*/
-
-
-// INCLUDE FILES
-#include <nifvar.h>
-
-#include "upnpconnectionmonitor.h"
-
-// logging
-_LIT( KComponentLogfile, "upnputilities.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-#ifdef __UPNP_CONSOLE_MT__
-_LIT( KConnectionBreakdownSimulationFile, "C:\\Data\\Wlan" );
-#endif // __UPNP_CONSOLE_MT__
-
-
-
-// ========================== MEMBER FUNCTIONS ===============================
-
-
-// ---------------------------------------------------------------------------
-// CUPnPConnectionMonitor::CUPnPConnectionMonitor
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// ---------------------------------------------------------------------------
-//
-CUPnPConnectionMonitor::CUPnPConnectionMonitor(
-    MUPnPConnectionMonitorObserver& aObserver, TInt aAccessPoint ) :
-    CActive( EPriorityStandard ),
-    iObserver( aObserver ),
-    iAccessPoint( aAccessPoint )
-    {
-    }
-
-
-// ---------------------------------------------------------------------------
-// CUPnPConnectionMonitor::NewL
-// Two-phased constructor.
-// ---------------------------------------------------------------------------
-//
-EXPORT_C CUPnPConnectionMonitor* CUPnPConnectionMonitor::NewL(
-    MUPnPConnectionMonitorObserver& aObserver, TInt aAccessPoint )
-    {
-    CUPnPConnectionMonitor* self = new(ELeave) CUPnPConnectionMonitor(
-        aObserver, aAccessPoint );
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(self);
-    return self;    
-    }
-
-
-// ---------------------------------------------------------------------------
-// CUPnPConnectionMonitor::ConstructL
-// Symbian 2nd phase constructor can leave.
-// ---------------------------------------------------------------------------
-//
-void CUPnPConnectionMonitor::ConstructL()
-    {
-    __LOG( "CUPnPConnectionMonitor::ConstructL" );
-
-#ifdef __UPNP_CONSOLE_MT__
-
-    // monitor filesystem for connection breakdown simulation
-    CActiveScheduler::Add( this );
-    User::LeaveIfError( iFs.Connect() );
-    iFs.NotifyChange( ENotifyFile, iStatus,
-        KConnectionBreakdownSimulationFile );
-    SetActive();
-
-#endif // __UPNP_CONSOLE_MT__
-
-    iConnectionMonitor.ConnectL();
-    iConnectionMonitor.NotifyEventL( *this );
-
-    ParseCurrentConnections();
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPConnectionMonitor::ParseCurrentConnections()
-// ---------------------------------------------------------------------------
-//
-void CUPnPConnectionMonitor::ParseCurrentConnections()
-    {    
-    // Get the count of connections
-    TRequestStatus status = KRequestPending;
-    TUint connectionCount = 0;
-    iConnectionMonitor.GetConnectionCount(connectionCount, status);
-    User::WaitForRequest( status ); 
-    // Go through available connections and check to see
-    // WLAN connection is already running
-    if( !status.Int() )
-        {
-        for( TUint i=1; i < connectionCount+1;  i++ )
-            {
-            TUint connectionId;
-            TUint subConnectionCount;
-
-            iConnectionMonitor.GetConnectionInfo( 
-                                            i,
-                                            connectionId, 
-                                            subConnectionCount);
-
-            if( IsWlanConnection( connectionId ) )
-                {
-                __LOG( "CUPnPConnectionMonitor - Found WLAN connection" );
-                iConnectionId = connectionId;
-                }
-            }   
-        }  
-    __LOG2( "CUPnPConnectionMonitor::ParseCurrentConnections() \
-    wlanId = %d connectionCount = %d ", iConnectionId , connectionCount );
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPConnectionMonitor::~CUPnPConnectionMonitor()
-// Destructor
-// ---------------------------------------------------------------------------
-//
-CUPnPConnectionMonitor::~CUPnPConnectionMonitor()
-    {
-#ifdef __UPNP_CONSOLE_MT__
-
-    // stop monitoring filesystem
-    Cancel();
-    iFs.Close();
-
-#endif // __UPNP_CONSOLE_MT__
-
-    // Disconnect from CM server
-    iConnectionMonitor.CancelNotifications();
-    iConnectionMonitor.Close();
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPConnectionMonitor::EventL()
-// Receives event from connection monitor
-// ---------------------------------------------------------------------------
-//
-void CUPnPConnectionMonitor::EventL( const CConnMonEventBase& aConnMonEvent )
-    {
-    __LOG1( "CUPnPConnectionMonitor::EventL type %d", aConnMonEvent.EventType() );
-    TUint connectionId = 0;
-
-    switch ( aConnMonEvent.EventType() )
-        {
-        case EConnMonCreateConnection:
-            {
-            const CConnMonCreateConnection* eventCreate; 
-            eventCreate = (const CConnMonCreateConnection*)&aConnMonEvent;
-            connectionId = eventCreate->ConnectionId();
-
-            // Save connectionId if type is WLAN
-            if( IsWlanConnection( connectionId ))
-                {
-                __LOG( "CUPnPConnectionMonitor::EventL EConnMonCreateConnection \
-WLAN connection found" );
-                iConnectionId = connectionId;
-                }
-
-            break;
-            }
-
-        // Connection is deleted
-        case EConnMonDeleteConnection:
-            {
-            const CConnMonDeleteConnection* eventDelete; 
-            eventDelete = 
-                    ( const CConnMonDeleteConnection* ) &aConnMonEvent;
-            connectionId = eventDelete->ConnectionId();
-            
-            // If there is new id for wlan we will pass if statement
-            // because then the current is invalid then
-            ParseCurrentConnections();
-            if( connectionId == iConnectionId )
-                {
-                __LOG( "CUPnPConnectionMonitor::EventL EConnMonDeleteConnection \
-WLAN connection found" );
-                iObserver.ConnectionLost();
-                }
-            break;
-            }
-         default:
-            {
-            break;
-            }
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPConnectionMonitor::IsWlanConnection()
-// Checks if connection type is WLAN
-// ---------------------------------------------------------------------------
-//
-TBool CUPnPConnectionMonitor::IsWlanConnection( TInt aConnectionId)
-    {
-    __LOG( "CUPnPConnectionMonitor::IsWlanConnection" );
-    TBool ret = EFalse;
-    TInt bearer = 0;
-    TInt bearerinfo = 0;
-    
-    TRequestStatus status = KRequestPending;
-    iConnectionMonitor.GetIntAttribute( 
-                                    aConnectionId, 
-                                    0, 
-                                    KBearer, 
-                                    (TInt &) bearer,
-                                    status );
-    User::WaitForRequest( status ); 
-    
-    TRequestStatus status2 = KRequestPending;
-    iConnectionMonitor.GetIntAttribute( 
-                                    aConnectionId, 
-                                    0, 
-                                    KBearerInfo, 
-                                    (TInt &) bearerinfo,
-                                    status2 );
-    User::WaitForRequest( status2 ); 
-    
-    if( bearer == EBearerWLAN && bearerinfo == EBearerWLAN )
-        {
-        ret = ETrue;
-        }
-        
-    return ret;
-    }
-    
-// ---------------------------------------------------------------------------
-// CUPnPConnectionMonitor::RunL()
-// Active object run loop
-// ---------------------------------------------------------------------------
-//
-void CUPnPConnectionMonitor::RunL()
-    {
-#ifdef __UPNP_CONSOLE_MT__
-    // simulated connection break has been activated
-    iObserver.ConnectionLost();
-    iFs.Delete( KConnectionBreakdownSimulationFile );
-#endif // __UPNP_CONSOLE_MT__
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPConnectionMonitor::DoCancel()
-// Active object cancel implementation
-// ---------------------------------------------------------------------------
-//
-void CUPnPConnectionMonitor::DoCancel()
-    {
-#ifdef __UPNP_CONSOLE_MT__
-    // cancel notifications from FS
-    iFs.NotifyChangeCancel();
-#endif // __UPNP_CONSOLE_MT__    
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPConnectionMonitor::DebugSimulateConnectionLostL()
-// Simulate connection lost case.
-// ---------------------------------------------------------------------------
-//
-EXPORT_C void CUPnPConnectionMonitor::DebugSimulateConnectionLostL()
-    {
-#ifdef __UPNP_CONSOLE_MT__
-    // signal connection breakdown via filesystem
-    RFs fs;
-    CleanupClosePushL( fs );
-    User::LeaveIfError( fs.Connect() );
-    TInt err = fs.Delete( KConnectionBreakdownSimulationFile );
-    if ( err != KErrNone &&
-         err != KErrNotFound )
-        {
-        User::Leave( err );
-        }
-    
-    RFile file;
-    CleanupClosePushL( file );
-    User::LeaveIfError( file.Create( fs,
-        KConnectionBreakdownSimulationFile, EFileWrite ) );
-    
-    CleanupStack::PopAndDestroy( &file );
-    CleanupStack::PopAndDestroy( &fs );
-    
-#else // __UPNP_CONSOLE_MT__
-    // connection simulation method called, but feature is not active !
-    __PANICD( __FILE__, __LINE__ );
-#endif // __UPNP_CONSOLE_MT__
-    }
-
-// end of file
+/*
+* Copyright (c) 2008 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:  UPnP Connection Monitor class implementation.
+*
+*/
+
+
+// INCLUDE FILES
+#include <nifvar.h>
+
+#include "upnpconnectionmonitor.h"
+
+// logging
+_LIT( KComponentLogfile, "upnputilities.txt");
+#include "upnplog.h"
+
+const TInt KWaitIapInterval = 10000000; // 10 seconds
+const TInt KWaitIapMaximum = 180000000; // 3 minutes
+
+// ========================== MEMBER FUNCTIONS ===============================
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CUPnPConnectionMonitor* CUPnPConnectionMonitor::NewL( TInt aAccessPoint )
+    {
+    CUPnPConnectionMonitor* self = new(ELeave) CUPnPConnectionMonitor( aAccessPoint );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    return self;    
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::~CUPnPConnectionMonitor()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUPnPConnectionMonitor::~CUPnPConnectionMonitor()
+    {
+    Cancel();
+
+    // Disconnect from CM server
+    iConnectionMonitor.CancelNotifications();
+    iConnectionMonitor.Close();
+    iTimer.Close();
+    DeleteTimeoutTimer();
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::SetObserver
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CUPnPConnectionMonitor::SetObserver(
+    MUPnPConnectionMonitorObserver& aObserver )
+    {
+    iObserver = &aObserver;
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::NotifyIap
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CUPnPConnectionMonitor::NotifyIap( TInt aAccessPoint )
+    {
+    __LOG1( "CUPnPConnectionMonitor::NotifyIap, aAccessPoint %d", aAccessPoint );
+    iAccessPoint = aAccessPoint;
+    if( IsActive() )
+        {
+        Cancel();
+        }
+    DeleteTimeoutTimer();
+    // Create a timer for switching off Iap observation.
+    iTimeout = CPeriodic::NewL( CActive::EPriorityStandard );
+    iTimeout->Start( KWaitIapMaximum, KWaitIapMaximum, TCallBack( TimeoutCallback, this ) );
+    // EConnMonIapAvailabilityChange event is generated only is there is
+    // background scanning active. That is why iap is checked actively here.
+    iMonitorState = EMonitorStateWait;
+    iTimer.After( iStatus, KWaitIapInterval );
+    SetActive();
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::NotifyIapCancel
+// ---------------------------------------------------------------------------
+//
+EXPORT_C void CUPnPConnectionMonitor::NotifyIapCancel()
+    {
+    __LOG( "CUPnPConnectionMonitor::NotifyIapCancel" );
+    DeleteTimeoutTimer();
+    Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::DoCancel()
+// Active object cancel implementation
+// ---------------------------------------------------------------------------
+//
+void CUPnPConnectionMonitor::DoCancel()
+    {
+    __LOG( "CUPnPConnectionMonitor::DoCancel" );
+    iTimer.Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::RunL()
+// Active object run loop
+// ---------------------------------------------------------------------------
+//
+void CUPnPConnectionMonitor::RunL()
+    {
+    __LOG2( "CUPnPConnectionMonitor::RunL, state %d, iStatus %d", 
+        iMonitorState, iStatus.Int() );
+    
+    switch( iMonitorState )
+        {
+        case EMonitorStateWait:
+            {
+            iMonitorState = EMonitorStateIap;
+            iConnectionMonitor.GetPckgAttribute(
+                    EBearerIdWLAN,
+                    0,
+                    KIapAvailability,
+                    iIapBuf,
+                    iStatus );
+            SetActive();
+            break;
+            }
+        case EMonitorStateIap:
+            {
+            TBool found( EFalse );
+            TConnMonIapInfo iaps = iIapBuf();
+            TInt count( iaps.Count() );
+            __LOG2( "CUPnPConnectionMonitor::RunL, iapCount %d, iAccessPoint %d", 
+                count, iAccessPoint );
+            for( TInt i = 0; i < count; i++ )
+                {
+                __LOG1( "CUPnPConnectionMonitor::RunL, iap %d", iaps.iIap[i].iIapId );
+                if( iaps.iIap[i].iIapId == iAccessPoint )
+                    {
+                    found = ETrue;
+                    DeleteTimeoutTimer();
+                    if( iObserver )
+                        {
+                        iObserver->IapAvailable( iAccessPoint );
+                        }
+                    break;
+                    }
+                }
+            if( !found )
+                {
+                iMonitorState = EMonitorStateWait;
+                iTimer.After( iStatus, KWaitIapInterval );
+                SetActive();
+                }
+            break;
+            }
+        default:
+            break;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::EventL()
+// Receives event from connection monitor
+// ---------------------------------------------------------------------------
+//
+void CUPnPConnectionMonitor::EventL( const CConnMonEventBase& aConnMonEvent )
+    {
+    __LOG1( "CUPnPConnectionMonitor::EventL type %d", aConnMonEvent.EventType() );
+    TUint connectionId = 0;
+
+    switch ( aConnMonEvent.EventType() )
+        {
+        case EConnMonCreateConnection:
+            {
+            const CConnMonCreateConnection* eventCreate; 
+            eventCreate = (const CConnMonCreateConnection*)&aConnMonEvent;
+            connectionId = eventCreate->ConnectionId();
+
+            // Save connectionId if type is WLAN
+            if( IsWlanConnection( connectionId ))
+                {
+                __LOG1( "CUPnPConnectionMonitor::EventL EConnMonCreateConnection \
+WLAN connection found, connectionId %d", connectionId );
+                if( iObserver )
+                    {
+                    iObserver->ConnectionCreated( connectionId );
+                    }
+                iConnectionIdOnCreate = connectionId;
+                }
+
+            break;
+            }
+
+        // Connection is deleted
+        case EConnMonDeleteConnection:
+            {
+            const CConnMonDeleteConnection* eventDelete; 
+            eventDelete = 
+                    ( const CConnMonDeleteConnection* ) &aConnMonEvent;
+            connectionId = eventDelete->ConnectionId();
+            __LOG3( "CUPnPConnectionMonitor::EventL EConnMonDeleteConnection \
+WLAN connection lost, connectionId %d (%d, %d)", 
+                connectionId, iConnectionId, iConnectionIdOnCreate );
+            
+            // If there is new id for wlan we will pass if statement
+            // because then the current is invalid then
+            ParseCurrentConnections();
+            if( connectionId == iConnectionId || 
+                connectionId == iConnectionIdOnCreate )
+                {
+                TBool authoritativeDelete = eventDelete->AuthoritativeDelete();
+                __LOG1( "CUPnPConnectionMonitor::EventL EConnMonDeleteConnection \
+authoritativeDelete %d", authoritativeDelete );
+                if( iObserver )
+                    {
+                    iObserver->ConnectionLost( authoritativeDelete );
+                    }
+                }
+            break;
+            }
+         default:
+            {
+            break;
+            }
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::CUPnPConnectionMonitor
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------------------------
+//
+CUPnPConnectionMonitor::CUPnPConnectionMonitor( TInt aAccessPoint ) :
+    CActive( EPriorityStandard ),
+    iAccessPoint( aAccessPoint )
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::ConstructL
+// Symbian 2nd phase constructor can leave.
+// ---------------------------------------------------------------------------
+//
+void CUPnPConnectionMonitor::ConstructL()
+    {
+    __LOG( "CUPnPConnectionMonitor::ConstructL" );
+
+    CActiveScheduler::Add( this );
+
+    iConnectionMonitor.ConnectL();
+    iConnectionMonitor.NotifyEventL( *this );
+
+    ParseCurrentConnections();
+    User::LeaveIfError(iTimer.CreateLocal());
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::IsWlanConnection()
+// Checks if connection type is WLAN
+// ---------------------------------------------------------------------------
+//
+TBool CUPnPConnectionMonitor::IsWlanConnection( TInt aConnectionId)
+    {
+    __LOG( "CUPnPConnectionMonitor::IsWlanConnection" );
+    TBool ret = EFalse;
+    TInt bearer = 0;
+    TInt bearerinfo = 0;
+    
+    TRequestStatus status = KRequestPending;
+    iConnectionMonitor.GetIntAttribute( 
+                                    aConnectionId, 
+                                    0, 
+                                    KBearer, 
+                                    (TInt &) bearer,
+                                    status );
+    User::WaitForRequest( status ); 
+    
+    TRequestStatus status2 = KRequestPending;
+    iConnectionMonitor.GetIntAttribute( 
+                                    aConnectionId, 
+                                    0, 
+                                    KBearerInfo, 
+                                    (TInt &) bearerinfo,
+                                    status2 );
+    User::WaitForRequest( status2 ); 
+    
+    if( bearer == EBearerWLAN && bearerinfo == EBearerWLAN )
+        {
+        ret = ETrue;
+        }
+        
+    return ret;
+    }
+    
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::ParseCurrentConnections()
+// ---------------------------------------------------------------------------
+//
+void CUPnPConnectionMonitor::ParseCurrentConnections()
+    {    
+    // Get the count of connections
+    TRequestStatus status = KRequestPending;
+    TUint connectionCount = 0;
+    iConnectionMonitor.GetConnectionCount(connectionCount, status);
+    User::WaitForRequest( status ); 
+    // Go through available connections and check to see
+    // WLAN connection is already running
+    if( !status.Int() )
+        {
+        for( TUint i=1; i < connectionCount+1;  i++ )
+            {
+            TUint connectionId;
+            TUint subConnectionCount;
+
+            iConnectionMonitor.GetConnectionInfo( 
+                                            i,
+                                            connectionId, 
+                                            subConnectionCount);
+
+            if( IsWlanConnection( connectionId ) )
+                {
+                __LOG( "CUPnPConnectionMonitor - Found WLAN connection" );
+                iConnectionId = connectionId;
+                }
+            }   
+        }  
+    __LOG2( "CUPnPConnectionMonitor::ParseCurrentConnections() \
+    wlanId = %d connectionCount = %d ", iConnectionId , connectionCount );
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::TimeoutCallback
+// ---------------------------------------------------------------------------
+//
+TInt CUPnPConnectionMonitor::TimeoutCallback( TAny* aSelf )
+    {
+    __LOG( "CUPnPConnectionMonitor::TimeoutCallback" );
+
+    if( aSelf )
+        {
+        CUPnPConnectionMonitor* self = static_cast<CUPnPConnectionMonitor*>( aSelf );
+        self->StopIapObservation();
+        }
+    return KErrNone;
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::StopIapObservation
+// ---------------------------------------------------------------------------
+//
+void CUPnPConnectionMonitor::StopIapObservation()
+    {
+    __LOG( "CUPnPConnectionMonitor::StopIapObservation" );
+    DeleteTimeoutTimer();
+    Cancel();
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPConnectionMonitor::DeleteTimeoutTimer
+// ---------------------------------------------------------------------------
+//
+void CUPnPConnectionMonitor::DeleteTimeoutTimer()
+    {
+    __LOG( "CUPnPConnectionMonitor::DeleteTimeoutTimer" );
+    if( iTimeout )
+        {
+        iTimeout->Cancel();
+        delete iTimeout;
+        iTimeout = 0;
+        }
+    }
+
+// end of file
--- a/upnpframework/upnputilities/src/upnpmetadatafetcher.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/src/upnpmetadatafetcher.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,318 +1,268 @@
-/*
-* Copyright (c) 2006-2007 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:  UPnP metadata fetching utilities.
-*
-*/
-
-
-// INCLUDE FILES
-// System
-#include <e32std.h>
-#include <e32base.h>
-
-// upnp stack api
-#include <upnpdevice.h>
-#include <upnpcontainer.h>
-#include <upnpitem.h>
-#include <upnpelement.h>
-#include <upnpstring.h>
-
-// upnpframework / avcontroller helper api
-#include <upnpconstantdefs.h>
-
-// utilities internal
-#include "upnpmetadatautility.h"
-#include "upnpcommonutils.h" 
-#include "upnpmetadatafetcher.h"
-#include "upnpcdsreselementutility.h"
-
-
-// CONSTANTS
-_LIT8( KMimeAudio,  "audio" );
-_LIT8( KMimeVideo,  "video" );
-_LIT8( KMimeImage,  "image" );
-_LIT8( KMimeApplication,    "application" );
-
-_LIT8( KItemCreator,    "None" );
-_LIT8( KRealMediaVideo,     "application/x-pn-realmedia" );
-
-// --------------------------------------------------------------------------
-// UPnPMetadataFetcher::FetchMetadataL
-// Resolves the metadata and fills in the CUpnpObject's metadata fields 
-// accordingly.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void UPnPMetadataFetcher::FetchMetadataL( CUpnpObject& aObject, 
-                                                   const TDesC& aFilePath, 
-                                                   const TDesC8& aMimeType )
-    {
-    CUPnPMetaDataUtility* utility = CUPnPMetaDataUtility::NewL();
-    CleanupStack::PushL( utility );
-
-    // APa: Continue even if the loading of meta data fails
-    // (in S60 3.2 this leaves)
-    TRAP_IGNORE( utility->LoadMetaDataL( aFilePath ) );
-
-    // Get the title from metadata is available, if not, use the filename
-    HBufC8* tempBuf = NULL;
-    if( utility->Title().Length() > 0 )
-        {
-        tempBuf = UpnpString::FromUnicodeL( utility->Title() );
-        CleanupStack::PushL( tempBuf );
-        aObject.SetTitleL( *tempBuf );
-        CleanupStack::PopAndDestroy( tempBuf ); tempBuf = NULL;
-        }
-    else
-        {
-        // Remove the path and file extension from the filename
-        TInt lastDot = 0;
-        TInt lastSlash = 0;
-        TInt length = 0;
-        lastDot = aFilePath.LocateReverseF('.');
-        if( KErrNotFound == lastDot ) //if file extension is not found
-            {
-            lastDot = aFilePath.Length();
-            }
-        lastSlash = aFilePath.LocateReverseF('\\');
-        length = lastDot - lastSlash;
-        HBufC* strippedFilename = NULL;
-        strippedFilename = aFilePath.Mid((lastSlash+1), (length-1)).AllocL();
-        CleanupStack::PushL( strippedFilename );
-
-        // Convert to 8bit, and set the UpnpObject's title value
-        tempBuf = UpnpString::FromUnicodeL( *strippedFilename );
-        CleanupStack::PushL( tempBuf );
-        aObject.SetTitleL( *tempBuf );
-
-        // Clean up
-        CleanupStack::PopAndDestroy( tempBuf ); 
-        tempBuf = NULL;
-        CleanupStack::PopAndDestroy( strippedFilename );
-        strippedFilename = NULL;
-        }
-
-    const RUPnPElementsArray& elms = aObject.GetElements();
-    TInt count = elms.Count();
-    TInt i;
-    TBool found;
-    
-    if( aMimeType.Find( KMimeAudio ) >= 0 )
-        {
-        // Set object class
-        aObject.SetObjectClassL( KClassAudioMusicTrack );
-        
-        // Artist
-        // Try to find the artist element and update it if found
-        tempBuf = UpnpString::FromUnicodeL( utility->Artist() );
-        if( tempBuf )
-            {
-            CleanupStack::PushL( tempBuf );
-            found = EFalse;
-            for( i = 0; i < count; i++)
-                {
-                if( elms[ i ]->Name() == KElementArtist )
-                    {
-                    elms[ i ]->SetValueL( *tempBuf );
-                    found = ETrue;
-                    i = count;
-                    }
-                }
-            if( !found )
-                {
-                // Not found, create a new artist element and add it to the 
-                // item
-                CUpnpElement* element = CUpnpElement::NewLC( KElementArtist );
-                element->SetValueL( *tempBuf );
-                aObject.AddElementL( element );
-                CleanupStack::Pop( element );
-                }
-            CleanupStack::PopAndDestroy( tempBuf ); tempBuf = NULL;    
-                
-            }
-        
-        // Genre
-        // Try to find the genre element and update it if found
-        tempBuf = UpnpString::FromUnicodeL( utility->Genre() );
-        if( tempBuf )
-            {
-            CleanupStack::PushL( tempBuf );
-            found = EFalse;
-            for( i = 0; i < count; i++)
-                {
-                if( elms[ i ]->Name() == KElementGenre )
-                    {
-                    elms[ i ]->SetValueL( *tempBuf );
-                    found = ETrue;
-                    i = count;
-                    }
-                }
-            if( !found )
-                {
-                // Not found, create a new genre element and add it to the 
-                // item
-                CUpnpElement* element = CUpnpElement::NewLC( KElementGenre );
-                element->SetValueL( *tempBuf );
-                aObject.AddElementL( element );
-                CleanupStack::Pop( element );
-                }
-            CleanupStack::PopAndDestroy( tempBuf ); tempBuf = NULL;
-            }
-        
-        // Album
-        // Try to find the album element and update it if found
-        tempBuf = UpnpString::FromUnicodeL( utility->Album() );
-        if( tempBuf )
-            {
-            CleanupStack::PushL( tempBuf );
-            found = EFalse;
-            for( i = 0; i < count; i++)
-                {
-                if( elms[ i ]->Name() == KElementAlbum )
-                    {
-                    elms[ i ]->SetValueL( *tempBuf );
-                    found = ETrue;
-                    i = count;
-                    }
-                }
-            if( !found )
-                {
-                // Not found, create a new album element and add it to the 
-                // item
-                CUpnpElement* element = CUpnpElement::NewLC( KElementAlbum );
-                element->SetValueL( *tempBuf );
-                aObject.AddElementL( element );
-                CleanupStack::Pop( element );
-                }
-            CleanupStack::PopAndDestroy( tempBuf ); tempBuf = NULL;
-            }
-        }
-    else if( aMimeType.Find( KMimeVideo ) >= 0 )
-        {
-        // Set Object class
-        aObject.SetObjectClassL( KClassVideo );
-        }
-    else if( aMimeType.Find( KMimeImage ) >= 0 )
-        {
-        // Set Object class
-        aObject.SetObjectClassL( KClassImage );
-        }
-    else if( aMimeType.Find( KMimeApplication ) >= 0 )
-        {
-        // some special cases here
-        // Fixes EAHN-7ETBH7
-        if( aMimeType.Find( KRealMediaVideo ) >= 0 )
-            {
-            aObject.SetObjectClassL( KClassVideo );
-            }
-        }
-    else
-        {
-        // Do nothing
-        }
-
-    // Date
-    // Try to find the date element and update it if found
-    tempBuf = UpnpString::FromUnicodeL( utility->Date() );
-    if( tempBuf )
-        {
-        CleanupStack::PushL( tempBuf );
-        found = EFalse;
-        for( i = 0; i < count; i++)
-            {
-            if( elms[ i ]->Name() == KElementDate )
-                {
-                elms[ i ]->SetValueL( *tempBuf );
-                found = ETrue;
-                i = count;
-                }
-            }
-        if( !found )
-            {
-            // Not found, create a new date element and add it to the item
-            CUpnpElement* element = CUpnpElement::NewLC( KElementDate );
-            element->SetValueL( *tempBuf );
-            aObject.AddElementL( element );
-            CleanupStack::Pop( element );
-            }
-        CleanupStack::PopAndDestroy( tempBuf ); tempBuf = NULL;
-        }       
-                         
-    CUpnpElement* element = CUpnpElement::NewLC( KElementCreator );
-    element->SetValueL( KItemCreator );
-    aObject.AddElementL( element );
-    CleanupStack::Pop( element );  
-    // Clean up
-    CleanupStack::PopAndDestroy( utility );
-    utility = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPMetadataFetcher::FetchMetadataL
-// Resolves the metadata and fills in the CUpnpObject's metadata fields 
-// accordingly.
-// --------------------------------------------------------------------------
-//
-EXPORT_C void UPnPMetadataFetcher::FetchMetadataL( CUpnpObject& aObject, 
-                                                   const TDesC& aFilePath )
-    {
-    // Resolve the MIME type of the file
-    HBufC8* mimeType = NULL;
-    mimeType = UPnPCommonUtils::ResolveMimeTypeL( aFilePath );
-    if( mimeType )
-        {    
-        CleanupStack::PushL( mimeType );
-        // Fill in the metadata
-        FetchMetadataL( aObject, aFilePath, *mimeType );
-        // Clean up
-        CleanupStack::PopAndDestroy( mimeType );
-        mimeType = NULL;
-        }        
-    }
-
-// --------------------------------------------------------------------------
-// UPnPMetadataFetcher::CreateItemFromFileLC
-// Creates a new CUpnpItem from a local file. Resolves the metadata and fills
-// in the new CUpnpItem's metadata fields accordingly.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpItem* UPnPMetadataFetcher::CreateItemFromFileLC( 
-                                                    const TDesC& aFilePath )
-    {
-    CUpnpItem* item = NULL;
-    item = CUpnpItem::NewL();
-    CleanupStack::PushL( item );
-
-    // Add a res-element to the item
-    UpnpCdsResElementUtility::AddResElementL( *item, aFilePath );
-    // Resolve the metadata
-    FetchMetadataL( *item, aFilePath );
-    
-    return item;
-    }
-
-// --------------------------------------------------------------------------
-// UPnPMetadataFetcher::CreateItemFromFileL
-// Creates a new CUpnpItem from a local file. Resolves the metadata and fills
-// in the new CUpnpItem's metadata fields accordingly.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpItem* UPnPMetadataFetcher::CreateItemFromFileL(
-                                                    const TDesC& aFilePath )
-    {
-    CUpnpItem* item = CreateItemFromFileLC( aFilePath );
-    CleanupStack::Pop( item );
-    return item;
-    }
-
-// End of File
+/*
+* Copyright (c) 2006-2007 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:  UPnP metadata fetching utilities.
+*
+*/
+
+
+// INCLUDE FILES
+// System
+#include <e32std.h>
+#include <e32base.h>
+
+// upnp stack api
+#include <upnpdevice.h>
+#include <upnpcontainer.h>
+#include <upnpitem.h>
+#include <upnpelement.h>
+#include <upnpstring.h>
+
+// upnpframework / avcontroller helper api
+#include "upnpconstantdefs.h"
+
+// utilities internal
+#include "upnpmetadatautility.h"
+#include "upnpcommonutils.h" 
+#include "upnpmetadatafetcher.h"
+#include "upnpcdsreselementutility.h"
+
+
+// CONSTANTS
+_LIT8( KMimeAudio,  "audio" );
+_LIT8( KMimeVideo,  "video" );
+_LIT8( KMimeImage,  "image" );
+_LIT8( KMimeApplication,    "application" );
+
+_LIT8( KItemCreator,    "None" );
+_LIT8( KRealMediaVideo,     "application/x-pn-realmedia" );
+
+// --------------------------------------------------------------------------
+// UPnPMetadataFetcher::FetchMetadataL
+// Resolves the metadata and fills in the CUpnpObject's metadata fields 
+// accordingly.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void UPnPMetadataFetcher::FetchMetadataL( CUpnpObject& aObject, 
+                                                   const TDesC& aFilePath, 
+                                                   const TDesC8& aMimeType )
+    {
+    CUPnPMetaDataUtility* utility = CUPnPMetaDataUtility::NewL();
+    CleanupStack::PushL( utility );
+
+    // APa: Continue even if the loading of meta data fails
+    // (in S60 3.2 this leaves)
+    TRAP_IGNORE( utility->LoadMetaDataL( aFilePath ) );
+
+    // Get the title from metadata is available, if not, use the filename
+    HBufC8* tempBuf = NULL;
+    if( utility->Title().Length() > 0 )
+        {
+        tempBuf = UpnpString::FromUnicodeL( utility->Title() );
+        CleanupStack::PushL( tempBuf );
+        aObject.SetTitleL( *tempBuf );
+        CleanupStack::PopAndDestroy( tempBuf ); tempBuf = NULL;
+        }
+    else
+        {
+        // Remove the path and file extension from the filename
+        TInt lastDot = 0;
+        TInt lastSlash = 0;
+        TInt length = 0;
+        lastDot = aFilePath.LocateReverseF('.');
+        if( KErrNotFound == lastDot ) //if file extension is not found
+            {
+            lastDot = aFilePath.Length();
+            }
+        lastSlash = aFilePath.LocateReverseF('\\');
+        length = lastDot - lastSlash;
+        HBufC* strippedFilename = NULL;
+        strippedFilename = aFilePath.Mid((lastSlash+1), (length-1)).AllocL();
+        CleanupStack::PushL( strippedFilename );
+
+        // Convert to 8bit, and set the UpnpObject's title value
+        tempBuf = UpnpString::FromUnicodeL( *strippedFilename );
+        CleanupStack::PushL( tempBuf );
+        aObject.SetTitleL( *tempBuf );
+
+        // Clean up
+        CleanupStack::PopAndDestroy( tempBuf ); 
+        tempBuf = NULL;
+        CleanupStack::PopAndDestroy( strippedFilename );
+        strippedFilename = NULL;
+        }
+
+    if( aMimeType.Find( KMimeAudio ) >= 0 )
+        {
+        // Set object class
+        aObject.SetObjectClassL( KClassAudioMusicTrack );
+        
+        AddElementToObjectL(aObject,
+                        utility->Artist(), 
+                        KElementArtist() );
+        
+        
+        // Genre
+        // Try to find the genre element and update it if found
+        
+        AddElementToObjectL(aObject,
+                        utility->Genre(), 
+                        KElementGenre() );
+        
+        
+        // Album
+        // Try to find the album element and update it if found
+        
+        AddElementToObjectL(aObject,
+                        utility->Album(), 
+                        KElementAlbum() );
+        
+       
+        }
+    else if( aMimeType.Find( KMimeVideo ) >= 0 )
+        {
+        // Set Object class
+        aObject.SetObjectClassL( KClassVideo );
+        }
+    else if( aMimeType.Find( KMimeImage ) >= 0 )
+        {
+        // Set Object class
+        aObject.SetObjectClassL( KClassImage );
+        }
+    else if( aMimeType.Find( KMimeApplication ) >= 0 )
+        {
+        // some special cases here
+        // Fixes EAHN-7ETBH7
+        if( aMimeType.Find( KRealMediaVideo ) >= 0 )
+            {
+            aObject.SetObjectClassL( KClassVideo );
+            }
+        }
+    else
+        {
+        // Do nothing
+        }
+
+    // Date
+    // Try to find the date element and update it if found
+    
+    AddElementToObjectL(aObject,
+                    utility->Date(), 
+                    KElementDate() );
+    
+                         
+    CUpnpElement* element = CUpnpElement::NewLC( KElementCreator );
+    element->SetValueL( KItemCreator );
+    aObject.AddElementL( element );
+    CleanupStack::Pop( element );  
+    // Clean up
+    CleanupStack::PopAndDestroy( utility );
+    utility = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPMetadataFetcher::FetchMetadataL
+// Resolves the metadata and fills in the CUpnpObject's metadata fields 
+// accordingly.
+// --------------------------------------------------------------------------
+//
+EXPORT_C void UPnPMetadataFetcher::FetchMetadataL( CUpnpObject& aObject, 
+                                                   const TDesC& aFilePath )
+    {
+    // Resolve the MIME type of the file
+    HBufC8* mimeType = NULL;
+    mimeType = UPnPCommonUtils::ResolveMimeTypeL( aFilePath );
+    if( mimeType )
+        {    
+        CleanupStack::PushL( mimeType );
+        // Fill in the metadata
+        FetchMetadataL( aObject, aFilePath, *mimeType );
+        // Clean up
+        CleanupStack::PopAndDestroy( mimeType );
+        mimeType = NULL;
+        }        
+    }
+
+// --------------------------------------------------------------------------
+// UPnPMetadataFetcher::CreateItemFromFileLC
+// Creates a new CUpnpItem from a local file. Resolves the metadata and fills
+// in the new CUpnpItem's metadata fields accordingly.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpItem* UPnPMetadataFetcher::CreateItemFromFileLC( 
+                                                    const TDesC& aFilePath )
+    {
+    CUpnpItem* item = NULL;
+    item = CUpnpItem::NewL();
+    CleanupStack::PushL( item );
+
+    // Add a res-element to the item
+    UpnpCdsResElementUtility::AddResElementL( *item, aFilePath );
+    // Resolve the metadata
+    FetchMetadataL( *item, aFilePath );
+    
+    return item;
+    }
+
+// --------------------------------------------------------------------------
+// UPnPMetadataFetcher::CreateItemFromFileL
+// Creates a new CUpnpItem from a local file. Resolves the metadata and fills
+// in the new CUpnpItem's metadata fields accordingly.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpItem* UPnPMetadataFetcher::CreateItemFromFileL(
+                                                    const TDesC& aFilePath )
+    {
+    CUpnpItem* item = CreateItemFromFileLC( aFilePath );
+    CleanupStack::Pop( item );
+    return item;
+    }
+
+
+void UPnPMetadataFetcher::AddElementToObjectL(CUpnpObject& aObject,
+                                        const TDesC& aMetaDataUtilityName, 
+                                        const TDesC8& aElementName )
+    {
+    HBufC8* tempBuf = NULL;
+    const RUPnPElementsArray& elms = aObject.GetElements();
+    TInt count = elms.Count();
+    TInt i;
+    TBool found;
+    tempBuf = UpnpString::FromUnicodeL( aMetaDataUtilityName );
+        if( tempBuf )
+            {
+            CleanupStack::PushL( tempBuf );
+            found = EFalse;
+            for( i = 0; i < count; i++)
+                {
+                if( elms[ i ]->Name() == aElementName )
+                    {
+                    elms[ i ]->SetValueL( *tempBuf );
+                    found = ETrue;
+                    i = count;
+                    }
+                }
+            if( !found )
+                {
+                // Not found, create a new element and add it to the item
+                CUpnpElement* element = CUpnpElement::NewLC( aElementName );
+                element->SetValueL( *tempBuf );
+                aObject.AddElementL( element );
+                CleanupStack::Pop( element );
+                }
+            CleanupStack::PopAndDestroy( tempBuf ); tempBuf = NULL;
+            }
+    
+    }
+
+// End of File
--- a/upnpframework/upnputilities/src/upnpmetadatautility.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpframework/upnputilities/src/upnpmetadatautility.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,342 +1,342 @@
-/*
-* Copyright (c) 2002-2007 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:  Utility class for meta data gathering for audio files
-*
-*/
-
-
-// INCLUDE FILES
-#include <e32base.h>
-#include <MetaDataUtility.h>
-#include <MetaDataFieldContainer.h>
-
-#include "upnpmetadatautility.h"
-#include "upnpcommonutils.h"
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// ---------------------------------------------------------------------------
-// CUPnPMetaDataUtility::CUPnPMetaDataUtility
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// ---------------------------------------------------------------------------
-//
-CUPnPMetaDataUtility::CUPnPMetaDataUtility()
-    {
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPMetaDataUtility::NewL
-// Two-phased constructor.
-// ---------------------------------------------------------------------------
-//
-EXPORT_C CUPnPMetaDataUtility* CUPnPMetaDataUtility::NewL()
-    {
-    CUPnPMetaDataUtility* self = new( ELeave ) CUPnPMetaDataUtility;
-    
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop();
-
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPMetaDataUtility::ConstructL
-// Symbian 2nd phase constructor can leave.
-// ---------------------------------------------------------------------------
-//
-void CUPnPMetaDataUtility::ConstructL()
-    {
-    iMetaDataUtility = CMetaDataUtility::NewL();
-    }
-    
-// ---------------------------------------------------------------------------
-// CUPnPMetaDataUtility::~CUPnPMetaDataUtility()
-// Destructor
-// ---------------------------------------------------------------------------
-//
-EXPORT_C CUPnPMetaDataUtility::~CUPnPMetaDataUtility()
-    {
-    if ( iMetaDataUtility )
-        {
-        TRAP_IGNORE( iMetaDataUtility->ResetL() );
-        }
-        
-    delete iArtist;
-    delete iAlbum;
-    delete iGenre;
-    delete iTitle;
-    delete iDate;
-    delete iMetaDataUtility;        
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMetaDataUtility::LoadMetaDataL
-// Finds correct MMF controller according to give file name
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUPnPMetaDataUtility::LoadMetaDataL( const TDesC& aFileName )
-    {
-    // Cleanup existing information
-    Reset();
-    
-    RArray<TMetaDataFieldId> wantedFields;
-    CleanupClosePushL( wantedFields );
-    wantedFields.AppendL( EMetaDataSongTitle );
-    wantedFields.AppendL( EMetaDataArtist );
-    wantedFields.AppendL( EMetaDataAlbum );
-    wantedFields.AppendL( EMetaDataGenre );
-    wantedFields.AppendL( EMetaDataDate );
-    
-    // Reset to be sure that no allocations are left over
-    iMetaDataUtility->ResetL();
-    
-    // Open the file
-    iMetaDataUtility->OpenFileL( aFileName, wantedFields );
-    
-    // wantedFields is not needed anymore
-    CleanupStack::PopAndDestroy( &wantedFields );
-    
-    // Go through the meta data fields and pick the required ones
-    TInt count = iMetaDataUtility->MetaDataCount();
-    
-    if ( count > 0 )
-        {
-        const CMetaDataFieldContainer& container = 
-                                        iMetaDataUtility->MetaDataFieldsL();
-        TMetaDataFieldId fieldId;
-        for ( TInt index = 0; index < count; index++ )
-            {
-            TPtrC content = container.At( index, fieldId );
-            switch ( fieldId )
-                {
-                case EMetaDataSongTitle:
-                    {
-                    iTitle = content.AllocL();
-                    break;
-                    }
-                case EMetaDataArtist:
-                    {
-                    iArtist = content.AllocL();
-                    break;
-                    }
-                case EMetaDataAlbum:
-                    {
-                    iAlbum = content.AllocL();
-                    break;
-                    }
-                case EMetaDataGenre:
-                    {
-                    iGenre = content.AllocL();
-                    break;
-                    }
-                case EMetaDataDate:
-                    {
-                    iDate = content.AllocL();
-                    break;
-                    }
-                default:
-                    {
-                    // Nothing to do
-                    break;
-                    }
-                }
-            }
-        }
-        
-    if( !iDate )
-        {
-        // Date was not found from metadata, so get it from file properties
-        RFs fs;
-        User::LeaveIfError( fs.Connect() );
-        CleanupClosePushL( fs );
-        RFile file;
-        User::LeaveIfError( file.Open( fs,aFileName, EFileRead |
-            EFileShareReadersOrWriters ) );
-        CleanupClosePushL( file );
-        
-        TTime time;
-        User::LeaveIfError( file.Modified( time ) );
-        
-
-        iDate = UPnPCommonUtils::TTimeToUPnPDateL( time );
-                
-        CleanupStack::PopAndDestroy( &file );        
-        CleanupStack::PopAndDestroy( &fs );        
-
-        }
-    // Cleanup
-    iMetaDataUtility->ResetL();
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMetaDataUtility::Title
-// Returns title for the song
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-EXPORT_C const TDesC& CUPnPMetaDataUtility::Title() const
-    {
-    if ( iTitle )
-        {
-        return *iTitle;
-        }
-    else
-        {
-        return KNullDesC;
-        }
-    }   
-        
-// --------------------------------------------------------------------------
-// CUPnPMetaDataUtility::Artist
-// Returns artist for the song
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-EXPORT_C const TDesC& CUPnPMetaDataUtility::Artist() const
-    {
-    if ( iArtist )
-        {
-        return *iArtist;
-        }
-    else
-        {
-        return KNullDesC;
-        }
-    }       
-        
-// --------------------------------------------------------------------------
-// CUPnPMetaDataUtility::Album
-// Returns album for the song
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-EXPORT_C const TDesC& CUPnPMetaDataUtility::Album() const
-    {
-    if ( iAlbum )
-        {
-        return *iAlbum;
-        }
-    else
-        {
-        return KNullDesC;
-        }
-    }
-        
-// --------------------------------------------------------------------------
-// CUPnPMetaDataUtility::Genre
-// Returns genre for the song
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-EXPORT_C const TDesC& CUPnPMetaDataUtility::Genre() const
-    {
-    if ( iGenre )
-        {
-        return *iGenre;
-        }
-    else
-        {
-        return KNullDesC;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMetaDataUtility::Date
-// Returns date for the file
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-EXPORT_C const TDesC& CUPnPMetaDataUtility::Date() const
-    {
-    if ( iDate )
-        {
-        return *iDate;
-        }
-    else
-        {
-        return KNullDesC;
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMetaDataUtility::LoadTitleL
-// Finds the title(ID3 tag) of the file according to give file name
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUPnPMetaDataUtility::LoadTitleL( const TDesC& aFileName )
-    {
-    // Cleanup existing information
-    Reset();
-    
-    RArray<TMetaDataFieldId> wantedFields;
-    CleanupClosePushL( wantedFields );
-    wantedFields.Append( EMetaDataSongTitle );
-    
-    // Reset to be sure that no allocations are left over
-    iMetaDataUtility->ResetL();
-    
-    // Open the file
-    iMetaDataUtility->OpenFileL( aFileName, wantedFields );
-    
-    // wantedFields is not needed anymore
-    CleanupStack::PopAndDestroy( &wantedFields );
-    
-    // Go through the meta data fields and pick the required ones
-    TInt count = iMetaDataUtility->MetaDataCount();
-    
-    if ( count > 0 )
-        {
-        const CMetaDataFieldContainer& container = 
-                                        iMetaDataUtility->MetaDataFieldsL();
-        TMetaDataFieldId fieldId;
-        for ( TInt index = 0; index < count; index++ )
-            {
-            TPtrC content = container.At( index, fieldId );
-            if ( EMetaDataSongTitle == fieldId )
-                {
-                iTitle = content.AllocL();
-                break;
-                }
-            }
-        }
-    
-    // Cleanup
-    iMetaDataUtility->ResetL();
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPMetaDataUtility::Reset
-// Reset member variables
-// (other items were commented in a header).
-// ---------------------------------------------------------------------------
-//
-void CUPnPMetaDataUtility::Reset()
-    {
-    delete iTitle;
-    iTitle = NULL;
-    delete iArtist;
-    iArtist = NULL;
-    delete iAlbum;
-    iAlbum = NULL;
-    delete iGenre;
-    iGenre = NULL;
-    delete iDate;
-    iDate = NULL;
-    }
-
-//  End of File  
+/*
+* Copyright (c) 2002-2007 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:  Utility class for meta data gathering for audio files
+*
+*/
+
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <MetaDataUtility.h>
+#include <MetaDataFieldContainer.h>
+
+#include "upnpmetadatautility.h"
+#include "upnpcommonutils.h"
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// ---------------------------------------------------------------------------
+// CUPnPMetaDataUtility::CUPnPMetaDataUtility
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------------------------
+//
+CUPnPMetaDataUtility::CUPnPMetaDataUtility()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPMetaDataUtility::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CUPnPMetaDataUtility* CUPnPMetaDataUtility::NewL()
+    {
+    CUPnPMetaDataUtility* self = new( ELeave ) CUPnPMetaDataUtility;
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPMetaDataUtility::ConstructL
+// Symbian 2nd phase constructor can leave.
+// ---------------------------------------------------------------------------
+//
+void CUPnPMetaDataUtility::ConstructL()
+    {
+    iMetaDataUtility = CMetaDataUtility::NewL();
+    }
+    
+// ---------------------------------------------------------------------------
+// CUPnPMetaDataUtility::~CUPnPMetaDataUtility()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+EXPORT_C CUPnPMetaDataUtility::~CUPnPMetaDataUtility()
+    {
+    if ( iMetaDataUtility )
+        {
+        TRAP_IGNORE( iMetaDataUtility->ResetL() );
+        }
+        
+    delete iArtist;
+    delete iAlbum;
+    delete iGenre;
+    delete iTitle;
+    delete iDate;
+    delete iMetaDataUtility;        
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMetaDataUtility::LoadMetaDataL
+// Finds correct MMF controller according to give file name
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUPnPMetaDataUtility::LoadMetaDataL( const TDesC& aFileName )
+    {
+    // Cleanup existing information
+    Reset();
+    
+    RArray<TMetaDataFieldId> wantedFields;
+    CleanupClosePushL( wantedFields );
+    wantedFields.Append( EMetaDataSongTitle );
+    wantedFields.Append( EMetaDataArtist );
+    wantedFields.Append( EMetaDataAlbum );
+    wantedFields.Append( EMetaDataGenre );
+    wantedFields.Append( EMetaDataDate );
+    
+    // Reset to be sure that no allocations are left over
+    iMetaDataUtility->ResetL();
+    
+    // Open the file
+    iMetaDataUtility->OpenFileL( aFileName, wantedFields );
+    
+    // wantedFields is not needed anymore
+    CleanupStack::PopAndDestroy( &wantedFields );
+    
+    // Go through the meta data fields and pick the required ones
+    TInt count = iMetaDataUtility->MetaDataCount();
+    
+    if ( count > 0 )
+        {
+        const CMetaDataFieldContainer& container = 
+                                        iMetaDataUtility->MetaDataFieldsL();
+        TMetaDataFieldId fieldId;
+        for ( TInt index = 0; index < count; index++ )
+            {
+            TPtrC content = container.At( index, fieldId );
+            switch ( fieldId )
+                {
+                case EMetaDataSongTitle:
+                    {
+                    iTitle = content.AllocL();
+                    break;
+                    }
+                case EMetaDataArtist:
+                    {
+                    iArtist = content.AllocL();
+                    break;
+                    }
+                case EMetaDataAlbum:
+                    {
+                    iAlbum = content.AllocL();
+                    break;
+                    }
+                case EMetaDataGenre:
+                    {
+                    iGenre = content.AllocL();
+                    break;
+                    }
+                case EMetaDataDate:
+                    {
+                    iDate = content.AllocL();
+                    break;
+                    }
+                default:
+                    {
+                    // Nothing to do
+                    break;
+                    }
+                }
+            }
+        }
+        
+    if( !iDate )
+        {
+        // Date was not found from metadata, so get it from file properties
+        RFs fs;
+        User::LeaveIfError( fs.Connect() );
+        CleanupClosePushL( fs );
+        RFile file;
+        User::LeaveIfError( file.Open( fs,aFileName, EFileRead |
+            EFileShareReadersOrWriters ) );
+        CleanupClosePushL( file );
+        
+        TTime time;
+        User::LeaveIfError( file.Modified( time ) );
+        
+
+        iDate = UPnPCommonUtils::TTimeToUPnPDateL( time );
+                
+        CleanupStack::PopAndDestroy( &file );        
+        CleanupStack::PopAndDestroy( &fs );        
+
+        }
+    // Cleanup
+    iMetaDataUtility->ResetL();
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMetaDataUtility::Title
+// Returns title for the song
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+EXPORT_C const TDesC& CUPnPMetaDataUtility::Title() const
+    {
+    if ( iTitle )
+        {
+        return *iTitle;
+        }
+    else
+        {
+        return KNullDesC;
+        }
+    }   
+        
+// --------------------------------------------------------------------------
+// CUPnPMetaDataUtility::Artist
+// Returns artist for the song
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+EXPORT_C const TDesC& CUPnPMetaDataUtility::Artist() const
+    {
+    if ( iArtist )
+        {
+        return *iArtist;
+        }
+    else
+        {
+        return KNullDesC;
+        }
+    }       
+        
+// --------------------------------------------------------------------------
+// CUPnPMetaDataUtility::Album
+// Returns album for the song
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+EXPORT_C const TDesC& CUPnPMetaDataUtility::Album() const
+    {
+    if ( iAlbum )
+        {
+        return *iAlbum;
+        }
+    else
+        {
+        return KNullDesC;
+        }
+    }
+        
+// --------------------------------------------------------------------------
+// CUPnPMetaDataUtility::Genre
+// Returns genre for the song
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+EXPORT_C const TDesC& CUPnPMetaDataUtility::Genre() const
+    {
+    if ( iGenre )
+        {
+        return *iGenre;
+        }
+    else
+        {
+        return KNullDesC;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMetaDataUtility::Date
+// Returns date for the file
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+EXPORT_C const TDesC& CUPnPMetaDataUtility::Date() const
+    {
+    if ( iDate )
+        {
+        return *iDate;
+        }
+    else
+        {
+        return KNullDesC;
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMetaDataUtility::LoadTitleL
+// Finds the title(ID3 tag) of the file according to give file name
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUPnPMetaDataUtility::LoadTitleL( const TDesC& aFileName )
+    {
+    // Cleanup existing information
+    Reset();
+    
+    RArray<TMetaDataFieldId> wantedFields;
+    CleanupClosePushL( wantedFields );
+    wantedFields.Append( EMetaDataSongTitle );
+    
+    // Reset to be sure that no allocations are left over
+    iMetaDataUtility->ResetL();
+    
+    // Open the file
+    iMetaDataUtility->OpenFileL( aFileName, wantedFields );
+    
+    // wantedFields is not needed anymore
+    CleanupStack::PopAndDestroy( &wantedFields );
+    
+    // Go through the meta data fields and pick the required ones
+    TInt count = iMetaDataUtility->MetaDataCount();
+    
+    if ( count > 0 )
+        {
+        const CMetaDataFieldContainer& container = 
+                                        iMetaDataUtility->MetaDataFieldsL();
+        TMetaDataFieldId fieldId;
+        for ( TInt index = 0; index < count; index++ )
+            {
+            TPtrC content = container.At( index, fieldId );
+            if ( EMetaDataSongTitle == fieldId )
+                {
+                iTitle = content.AllocL();
+                break;
+                }
+            }
+        }
+    
+    // Cleanup
+    iMetaDataUtility->ResetL();
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPMetaDataUtility::Reset
+// Reset member variables
+// (other items were commented in a header).
+// ---------------------------------------------------------------------------
+//
+void CUPnPMetaDataUtility::Reset()
+    {
+    delete iTitle;
+    iTitle = NULL;
+    delete iArtist;
+    iArtist = NULL;
+    delete iAlbum;
+    iAlbum = NULL;
+    delete iGenre;
+    iGenre = NULL;
+    delete iDate;
+    iDate = NULL;
+    }
+
+//  End of File  
--- a/upnpmediaserver/avobjects/src/upnpdlnaprotocolinfo.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/avobjects/src/upnpdlnaprotocolinfo.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,865 +1,866 @@
-/** @file
-* Copyright (c) 2005-2008 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:  ProtocolInfo DLNA functionality class 
-*
-*/
-
-
-#include "upnpdlnaprotocolinfo.h"
-#include "upnpdlnaprotocolinfocons.h"
-#include "upnpprotocolinfolocal.h"
-
-#include <e32base.h>
-#include <e32cons.h>
-
-using namespace UpnpDlnaProtocolInfo;
-
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::CProtocolInfoDlna()
-//  Constructor of the class
-//-----------------------------------------------------------------
-CUpnpDlnaProtocolInfo::CUpnpDlnaProtocolInfo(): CUpnpProtocolInfo(),
-                                            iDlnaCi( KErrNotFound ) 
-    {    
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::~CProtocolInfoDlna()
-//  Destructor of the class
-//-----------------------------------------------------------------
-CUpnpDlnaProtocolInfo::~CUpnpDlnaProtocolInfo()
-    {    
-    delete iDlnaPn; 
-    delete iDlnaPs; 
-    delete iOtherParams;
-    delete iFlagsParam;
-    delete iOpParam;
-    }
-
-
-//-----------------------------------------------------------------
-// CProtocolInfoDlna::NewL
-// Factory method for creating instance of class. aInputString must contain protocolInfo string.
-//-----------------------------------------------------------------
-EXPORT_C CUpnpDlnaProtocolInfo* CUpnpDlnaProtocolInfo::NewL()
-    {
-    CUpnpDlnaProtocolInfo* newElement = new (ELeave) CUpnpDlnaProtocolInfo();
-    CleanupStack::PushL( newElement );
-    CleanupStack::Pop( newElement );
-    return newElement; 
-    }
-
-    
-//-----------------------------------------------------------------
-// CProtocolInfoDlna::NewL
-// Factory method for creating instance of class. aInputString must contain protocolInfo string.
-//-----------------------------------------------------------------
-EXPORT_C CUpnpDlnaProtocolInfo* CUpnpDlnaProtocolInfo::NewL(const TDesC8& aInputString)
-    {
-    CUpnpDlnaProtocolInfo* newElement = new (ELeave) CUpnpDlnaProtocolInfo();
-    CleanupStack::PushL( newElement );
-    newElement->BaseConstructL( aInputString );     
-    CleanupStack::Pop( newElement );
-    return newElement; 
-    }
-    
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::ConstructL(TDesC8& aInputString)
-//  Method for creating instance of class. aInputString must contain protocolInfo string.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::ConstructL(const TDesC8& aInputString) 
-    {
-    BaseConstructL(aInputString);
-    
-    TInt result = ParseL( aInputString );
-    if ( result != KErrNone ) 
-        {
-        User::Leave( result );            
-        }
-    }
-
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetOpTimeParam(TBool aValue)
-//  Setter for DLNA.ORG_OP time seek parameter.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::SetOpTimeParam(TBool aValue)
-    {
-    SetDlnaParam( aValue, A_VAL );
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetOpRangeParam(TBool aValue)
-//  Setter for DLNA.ORG_OP range seek parameter.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::SetOpRangeParam(TBool aValue)
-    {
-    return SetDlnaParam( aValue, B_VAL );
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetDlnaFlag(TBool aValue, TInt aFlagIndex)
-//  Setter for DLNA_FLAGS
-//-----------------------------------------------------------------
-void  CUpnpDlnaProtocolInfo::SetDlnaFlag(TBool aValue, TUint8 aFlagIndex)
-    {
-    if ( aFlagIndex >= KDLNA_FLAGS_QUANTITY) return;
-    TInt index = aFlagIndex / K32BIT;
-    SetIntBit32((TUint32&) iDlnaFlags[ index ], aValue, aFlagIndex);
-    }    
-    
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::GetDlnaFlag(TInt aFlagIndex)
-//  Getter for DLNA_FLAGS
-//-----------------------------------------------------------------
-TBool CUpnpDlnaProtocolInfo::GetDlnaFlag(TInt aFlagIndex)
-    {
-    if ( aFlagIndex >= KDLNA_FLAGS_QUANTITY ) return EFalse;
-    TUint8 index = aFlagIndex / K32BIT;
-    TUint8 bit_index = aFlagIndex % K32BIT;
-    TUint32 bit = 1<<bit_index;    
-    if ( iDlnaFlags[ index ]  & bit )
-        {
-        return ETrue;
-        }
-    else 
-        {
-        return EFalse;
-        }
-    
-    }        
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::ParseL(TDesC8& aInputString)
-//  Parses aInputString into protocolInfo object.
-//-----------------------------------------------------------------
-TInt CUpnpDlnaProtocolInfo::ParseL(const TDesC8& aInputString)
-    {
-        TInt result = KErrNone;        
-        CUpnpProtocolInfo::ParseL(aInputString);
-        
-        result = ParseForthParameterL();
-        if ( iDlnaPn != NULL)
-            {
-            delete iFourthParameter; 
-            iFourthParameter = NULL;
-            }
-        return result;        
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::ParseForthParameterL()
-//  Parses the fourth field.
-//-----------------------------------------------------------------
-TInt CUpnpDlnaProtocolInfo::ParseForthParameterL()
-    {
-    HBufC8* forth = iFourthParameter;
-    if ( !forth )
-        {
-        return KErrArgument;
-        }
-
-    TLex8 input(*forth);
-    TBool end = EFalse;
-    while( (!input.Eos()) && (!end))
-        {
-        ParseAtomToDelimeter( input, KDlnaTokenizer);
-        TPtrC8 name(input.MarkedToken());
-        Skip(input,1);
-        end = ParseForthParameterInternalL( name, input);
-        }
-    return KErrNone;
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::ParseDlnaPsParamL(TLex8& aLexer)
-//  Parses DLNA.ORG_PS params.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::ParseDlnaPsParamL(TLex8& aLexer)
-    {
-    ParseAtomToDelimeter(aLexer, KDlnaDelimeter);
-    TPtrC8 value (aLexer.MarkedToken());
-    if ( aLexer.MarkedToken().Length() == 0 ) User::Leave( KErrArgument );
-    SetPsParameterL(value);
-    SkipAndMark(aLexer, 1);
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::ParseDlnaPnParamL(TLex8& aLexer)
-//  Parses DLNA.ORG_PN params.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::ParseDlnaPnParamL(TLex8& aLexer)
-    {
-    ParseAtomToDelimeter(aLexer, KDlnaDelimeter);
-    TPtrC8 value (aLexer.MarkedToken());
-    if ( aLexer.MarkedToken().Length() == 0 ) User::Leave( KErrArgument );
-    SetPnParameterL(value);
-    SkipAndMark(aLexer, 1);
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::ParseDlnaOpParamL(TLex8& aLexer)
-//  Parses DLNA.ORG_OP params.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::ParseDlnaOpParamL(TLex8& aLexer)
-    {
-    ParseAtomToDelimeter(aLexer, KDlnaDelimeter);
-    TPtrC8 value (aLexer.MarkedToken());
-    if (value.Length() != 2) User::Leave( KErrArgument );
-    TChar character = value[0]; 
-    User::LeaveIfError(CheckBooleanValue(character));
-    SetOpTimeParam(character == KDLNA_BOOLEAN_TRUE);    
-    character = value[1]; 
-    User::LeaveIfError(CheckBooleanValue(character));
-    SetOpRangeParam(character == KDLNA_BOOLEAN_TRUE);
-    //SetOpParameter
-    SkipAndMark(aLexer, 1);
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::ParseDlnaCiParamL(TLex8& aLexer)
-//  Parses DLNA.ORG_CI params.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::ParseDlnaCiParamL(TLex8& aLexer)
-    {
-    ParseAtomToDelimeter(aLexer, KDlnaDelimeter);
-    TPtrC8 value (aLexer.MarkedToken());
-    if (value.Length() != 1) User::Leave( KErrArgument );
-    TChar character = value[0]; 
-    User::LeaveIfError(CheckBooleanValue(character));    
-    SetCiParameter(character == KDLNA_BOOLEAN_TRUE);
-    //SetOpParameter
-    SkipAndMark(aLexer, 1);
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::ParseDlnaFlagsParamL(TLex8& aLexer)
-//  Parses DLNA.ORG_FLAGS params.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::ParseDlnaFlagsParamL(TLex8& aLexer)
-    {
-    ParseAtomToDelimeter(aLexer, KDlnaDelimeter);
-    
-    if ( aLexer.MarkedToken().Length() != 
-        KDLNA_FLAGS_NUMBER * KMAX_INT_LENGTH_STRING) 
-        User::Leave( KErrArgument );
-    
-    TLex8 plagLex(aLexer.MarkedToken());    
-    
-    for(int i = 0; i < KDLNA_FLAGS_NUMBER; i++)
-        {
-        plagLex.Mark();
-        plagLex.Inc( KMAX_INT_LENGTH_STRING );
-        TPtrC8 value (plagLex.MarkedToken());
-        // check if values are from HEX range
-        for (TInt j = 0; j < KMAX_INT_LENGTH_STRING;j++)
-            if (!((value[j] >='0' &&  value[j] <='9') ||
-                (value[j] >='a' &&  value[j] <='f') || 
-                (value[j] >='A' &&  value[j] <='F')))
-                User::Leave( KErrArgument );
-        
-        TLex8* ptr = new TLex8(value);
-        User::LeaveIfError(ptr->Val(iDlnaFlags[i], EHex)); 
-        delete ptr;
-        }
-    SkipAndMark(aLexer,1);
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::ParseOtherParamsL(TLex8& aLexer)
-//  Parses other params.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::ParseOtherParamsL(TLex8& /*aLexer*/)
-    {
-    if ( iDlnaPn != NULL )
-        {
-        
-        //    SetOtherParamL(aLexer.RemainderFromMark());
-        }
-    }
-    
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::ParseForthParameterInternalL( TDesC8& aName, TLex8& aLexer)
-//  Parses the fourth param.
-//-----------------------------------------------------------------
-TBool CUpnpDlnaProtocolInfo::ParseForthParameterInternalL( const TDesC8& aName, TLex8& aLexer)
-    {
-    TBool result = EFalse;
-    if ( aName.Compare(KDLNA_PN) == 0)
-        {
-        aLexer.Mark();
-        ParseDlnaPnParamL(aLexer);
-        }
-    else if ( aName.Compare(KDLNA_OP) == 0 )
-        {
-        aLexer.Mark();
-        ParseDlnaOpParamL(aLexer);
-        }
-    else if ( aName.Compare(KDLNA_PS) == 0 )
-        {
-        aLexer.Mark();
-        ParseDlnaPsParamL(aLexer);
-        }
-    else if ( aName.Compare(KDLNA_CI) == 0 )        
-        {
-        aLexer.Mark();
-        ParseDlnaCiParamL(aLexer);
-        }
-    else if ( aName.Compare(KDLNA_FLAGS) == 0 )                
-        {
-        aLexer.Mark();
-        ParseDlnaFlagsParamL(aLexer);
-        }
-    else 
-        {
-        ParseOtherParamsL(aLexer);
-        result = ETrue;
-        }
-    return result;
-    }
-        
-//-----------------------------------------------------------------
-//  CUpnpDlnaProtocolInfo::FourthField()
-//  
-//-----------------------------------------------------------------
-EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::FourthField()
-    {
-     TRAPD( error, FourthParameterInternalL() )
-     if ( error )
-         { 
-         return KNullDesC8();
-         }    
-    return iFourthParameter->Des();
-    }
-
-
-//-----------------------------------------------------------------
-//  CUpnpDlnaProtocolInfo::FourthParameterInternalL()
-//  
-//-----------------------------------------------------------------    
-void CUpnpDlnaProtocolInfo::FourthParameterInternalL()
-    {
-    TInt len = GetFourthParameterLength();
-    
-    HBufC8* buf = HBufC8::NewLC(len);
-    TPtr8 bufPtr(buf->Des());
-    GetFourthParameterInternalL(bufPtr);
-    
-    delete iFourthParameter;
-    iFourthParameter = buf;
-    
-    CleanupStack::Pop(buf);        
-    }
-    
-    
-        
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetIntBit(TInt& aParameter, TBool aValue, TInt aBitNumber)
-//  Setter for DLNA_FLAGS
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::SetIntBit8(TUint8& aParameter, TBool aValue, TUint8 aBitNumber)
-    {
-    if ( aBitNumber >= KMAX_INT_LENGTH_STRING ) return;
-    if ( ! (aValue == EFalse) )
-        {
-        aParameter |= (TUint8)1<<aBitNumber;
-        }
-    else
-        {
-        aParameter  &= ~((TUint8)1<<aBitNumber);
-        }
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetIntBit(TInt& aParameter, TBool aValue, TInt aBitNumber)
-//  Setter for DLNA_FLAGS
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::SetIntBit32(TUint32& aParameter, TBool aValue, TUint8 aBitNumber)
-    {
-    if ( aBitNumber >= K32BIT ) return;
-    if ( ! (aValue == EFalse) )
-        {
-        aParameter |= (TUint32)1<<aBitNumber;
-        }
-    else
-        {
-        aParameter  &= ~((TUint32)1<<aBitNumber);
-        }
-    }    
-    
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetDlnaParam(TBool aValue, TInt aParamIndex)
-//  Setter for a DLNA parameter.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::SetDlnaParam(TBool aValue, TUint8 aParamIndex)
-    {
-    SetIntBit8((TUint8&) iParams, aValue, aParamIndex);
-    }    
-            
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::GetDlnaParam(TInt aParamIndex)
-//  Getter for DLNA params.
-//-----------------------------------------------------------------
-TBool CUpnpDlnaProtocolInfo::GetDlnaParam(TInt aParamIndex)
-    {
-     return ( iParams  & ((TUint8)1<<aParamIndex));
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::IsDlnaFlagsSet()
-//  This function returns ETrue if at least one dlna flag is set
-//-----------------------------------------------------------------
-TBool CUpnpDlnaProtocolInfo::IsDlnaFlagsSet()
-    {
-    for( int i = 0; i < KDLNA_FLAGS_NUMBER  ; i++)
-        {
-        if (iDlnaFlags[i] != 0 )
-            return ETrue;     
-        }
-    //if not DLNA flags not set
-    return EFalse;        
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::GetForthParameterInternalL(TPtr8& aBuffer)
-//  This function produces a string containing all info taken from fourth ProtocolInfo field
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::GetFourthParameterInternalL(TDes8& aBuffer)
-    {
-    
-    //if ( FourthField() != KNullDesC8)
-    //    {
-    //    aBuffer.Append( *iFourthParameter );
-    //    return;
-    //    }    
-    
-    
-    if ( PnParameter() == KNullDesC8 )        
-        {
-        aBuffer.Append(KDlnaAllStar);
-        return;
-        }
-    aBuffer.Append( KDLNA_PN );
-    aBuffer.Append( KDlnaTokenizer ); 
-    aBuffer.Append( *iDlnaPn );
-    if ( GetDlnaOpRangeParam() || GetDlnaOpTimeParam() )
-        {
-        aBuffer.Append( KDlnaDelimeter ); 
-        aBuffer.Append( KDLNA_OP );
-        aBuffer.Append( KDlnaTokenizer ); 
-        aBuffer.Append( GetDlnaOpTimeParam() ? KDLNA_BOOLEAN_TRUE:KDLNA_BOOLEAN_FALSE); //Time value 0,1
-        aBuffer.Append( GetDlnaOpRangeParam() ? KDLNA_BOOLEAN_TRUE:KDLNA_BOOLEAN_FALSE); //Range value 0,1
-        }
-    if ( PsParameter() != KNullDesC8 )
-        {
-        aBuffer.Append( KDlnaDelimeter ); 
-        aBuffer.Append( KDLNA_PS );
-        aBuffer.Append( KDlnaTokenizer ); 
-        aBuffer.Append( *iDlnaPs );
-        }
-    if ( iDlnaCi != KErrNotFound )
-        {
-        aBuffer.Append( KDlnaDelimeter ); 
-        aBuffer.Append( KDLNA_CI );
-        aBuffer.Append( KDlnaTokenizer ); 
-        aBuffer.Append( iDlnaCi ? KOneChar() : KZeroChar() ); 
-        }
-    
-    TBool saveDlnaFlags = IsDlnaFlagsSet();
-    
-    if ( saveDlnaFlags )
-        {
-        aBuffer.Append( KDlnaDelimeter ); 
-        aBuffer.Append( KDLNA_FLAGS );
-        aBuffer.Append( KDlnaTokenizer ); 
-        SerializeDlnaFlagsL( aBuffer );
-        }
-    if ( GetOtherParams() != KNullDesC8) 
-        {
-        aBuffer.Append( KDlnaDelimeter ); 
-        aBuffer.Append( *iOtherParams );
-        }
-    }
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::GetForthParameterParameterLength
-//  This function returns length of the string containing all relevant information from fourth ProtocolInfo field. 
-//-----------------------------------------------------------------
-TInt CUpnpDlnaProtocolInfo::GetFourthParameterLength()
-    {
-    
-    //if ( FourthField() != KNullDesC8)
-    //    {
-    //    return iFourthParameter->Length();
-    //    }
-    
-    
-    if ( PnParameter() == KNullDesC8 )        
-        {
-        return 1; 
-        }
-    TInt result = 0; 
-    result += KDLNA_PN.operator()().Length();
-    result += 1 ; 
-    result += iDlnaPn->Length();
-    if ( GetDlnaOpRangeParam() || GetDlnaOpTimeParam() )
-        {
-        result += 1; // ; 
-        result += KDLNA_OP.operator()().Length();
-        result += 1; //= 
-        result += 1; //Time value 0,1
-        result += 1; //Range value 0,1
-        }
-    if ( PsParameter() != KNullDesC8 )
-        {
-        result += 1; // ; separator
-        result += KDLNA_PS.operator()().Length();
-        result += 1; // = 
-        result += iDlnaPs->Length();
-        }
-    if ( iDlnaCi != KErrNotFound )
-        {
-        result += 1; //; 
-        result += KDLNA_CI.operator()().Length();
-        result += 1; //= 
-        result += 1; // value 
-        }
-    
-    TBool saveDlnaFlags = IsDlnaFlagsSet();
-    
-    if ( saveDlnaFlags )
-        {
-        result += 1; //; 
-        result += KDLNA_FLAGS.operator()().Length();
-        result += 1; // = 
-        result += KDLNA_FLAGS_NUMBER * KMAX_INT_LENGTH_STRING; // Values length
-        }
-    if ( GetOtherParams() != KNullDesC8 ) 
-        {
-        result += 1; //; 
-        result += iOtherParams->Length();
-        }
-    return result;
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SerializeDlnaFlagsL(TPtr8& aBuffer)
-//  Serializes iDlnaFlags member variable into a string.
-//-----------------------------------------------------------------
-void CUpnpDlnaProtocolInfo::SerializeDlnaFlagsL(TDes8& aBuffer)
-    {
-    HBufC8* number = HBufC8::NewL(KMAX_INT_LENGTH_STRING);
-    TPtr8 ptrNumber( number->Des() );
-    for(int i = 0; i < KDLNA_FLAGS_NUMBER ; i++)    
-        {
-        ptrNumber.NumFixedWidth(iDlnaFlags[i], EHex, KMAX_INT_LENGTH_STRING);
-        ptrNumber.UpperCase();
-        aBuffer.Append( *number);
-        }
-    delete number;
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::GetDlnaOpTimeParam()
-//  Getter for DLNA.ORG_OP time seek parameter.
-//-----------------------------------------------------------------
-TBool CUpnpDlnaProtocolInfo::GetDlnaOpTimeParam()
-    {
-    return GetDlnaParam(A_VAL);
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::GetDlnaOpRangeParam()
-//  Getter for DLNA.ORG_OP range seek parameter.
-//-----------------------------------------------------------------
-TBool CUpnpDlnaProtocolInfo::GetDlnaOpRangeParam()
-    {
-    return GetDlnaParam(B_VAL);
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetOpParameterL(TPtrC8 aValue)
-//  Setter for DLNA.ORG_OP parameter.
-//-----------------------------------------------------------------
-EXPORT_C void CUpnpDlnaProtocolInfo::SetOpParameterL(const TDesC8& aValue)
-    {                   
-    TPtrC8 opParamName;
-    TPtrC8 opParamValue;
-        
-    //---- getting a proper value of DLNA.ORG_OP param --
-    if ( aValue.Locate(KDlnaTokenizer) > KErrNotFound )
-    {
-        TLex8 lexer(aValue);    
-        ParseAtomToDelimeter( lexer, KDlnaTokenizer);
-        opParamName.Set( lexer.MarkedToken() );
-        
-        if ( opParamName != KDLNA_OP)
-            {
-            User::Leave(KErrBadDescriptor);    
-            }
-        
-        Skip(lexer, 1);            
-        opParamValue.Set( lexer.Remainder() );         
-        }
-    else
-        {
-        opParamValue.Set(aValue);            
-        }
-                
-    //---- parsing DLNA.ORG_OP param value ---------------
-    if ( opParamValue.Length() == 2 && 
-        !CheckBooleanValue(((TChar)opParamValue[0])) && 
-        !CheckBooleanValue(((TChar)opParamValue[1])) 
-        )
-        {                        
-        TBool opTimeParam = ((TChar)opParamValue[0]).GetNumericValue();
-        TBool opRangeParam = ((TChar)opParamValue[1]).GetNumericValue();
-        
-        SetOpTimeParam(opTimeParam);
-        SetOpRangeParam(opRangeParam);        
-        }
-    else 
-        {        
-        User::Leave(KErrBadDescriptor);
-        }                                                                                        
-    } 
-    
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetOpParameterL(UpnpDlnaProtocolInfo::TDlnaParams param,TBool aValue)
-//  Setter for DLNA.ORG_OP parameter.
-//-----------------------------------------------------------------
-EXPORT_C void CUpnpDlnaProtocolInfo::SetOpParameterL(UpnpDlnaProtocolInfo::TDlnaParams param,TBool aValue)
-    {
-    SetDlnaParam( aValue, param );
-    }
-    
-//-----------------------------------------------------------------
-//  CUpnpDlnaProtocolInfo::OpParameterL()
-//  Getter for DLNA.ORG_OP parameter.
-//-----------------------------------------------------------------
-EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::OpParameterL()
-    {
-    TBool opTimeParam = GetDlnaOpTimeParam();
-    TBool opRangeParam = GetDlnaOpRangeParam();
-    HBufC8* opParameter = HBufC8::NewLC(2);    
-    opParameter->Des().AppendNum( opTimeParam ? 1:0 );
-    opParameter->Des().AppendNum( opRangeParam ? 1:0 );           
-       
-    CleanupStack::Pop(opParameter);
-       
-    delete iOpParam;
-    iOpParam = opParameter;
-    return iOpParam->Des();
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetOpParameterL(UpnpDlnaProtocolInfo::TDlnaParams param,TBool aValue)
-//  Setter for DLNA.ORG_OP parameter.
-//-----------------------------------------------------------------
-EXPORT_C TBool CUpnpDlnaProtocolInfo::OpParameter(UpnpDlnaProtocolInfo::TDlnaParams param)
-    {
-    return GetDlnaParam( param );
-    }
-    
-//-----------------------------------------------------------------
-//  CUpnpDlnaProtocolInfo::SetFlagsParameterL(const TDesC8& flags)
-//  Setter for DLNA.ORG_CI parameter.
-//-----------------------------------------------------------------
-EXPORT_C void CUpnpDlnaProtocolInfo::SetFlagsParameterL(const TDesC8& flags)
-    {                
-    TPtrC8 flagsParamName(KDLNA_FLAGS);        
-    TLex8 lexer(flags);
-    TInt len = flags.Length();
-                
-    //---- getting a proper value of DLNA.ORG_FLAGS ----
-    if ( flags.Locate(KDlnaTokenizer) > KErrNotFound )
-        {                    
-        ParseAtomToDelimeter( lexer, KDlnaTokenizer);
-        flagsParamName.Set( lexer.MarkedToken() );
-            
-        if ( flagsParamName != KDLNA_FLAGS )
-            {
-            User::Leave(KErrBadDescriptor);    
-            }
-            
-        Skip(lexer, 1);
-        TPtrC8 tmp = lexer.Remainder();
-                        
-        len = tmp.Length();
-        lexer = tmp;
-        }                                        
-        
-    //---- checking if DLNA.ORG_FLAGS has proper value --                
-    if (len != 32)
-        {
-        User::Leave( KErrBadDescriptor );
-        }
-        
-    while( !lexer.Eos() )
-        {
-        if ( !lexer.Get().IsHexDigit() )
-            {
-            User::Leave( KErrBadDescriptor );
-            }
-        }
-        
-    lexer.UnGetToMark();                                                
-    ParseForthParameterInternalL( flagsParamName, lexer );                       
-    }
-    
-//-----------------------------------------------------------------
-//  CUpnpDlnaProtocolInfo::FlagsParameterL()
-//  Getter for DLNA.ORG_CI parameter.
-//----------------------------------------------------------------
-EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::FlagsParameterL()
-    {
-    TInt len = KDLNA_FLAGS_NUMBER * KMAX_INT_LENGTH_STRING; // Values length
-    HBufC8* flagsParameter = HBufC8::NewLC(len);
-    TPtr8 ptr = flagsParameter->Des();
-    SerializeDlnaFlagsL(ptr);
-    CleanupStack::Pop(flagsParameter);    
-    delete iFlagsParam;
-    iFlagsParam = flagsParameter;            
-    return iFlagsParam->Des();
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetCiParameter(TBool aValue)
-//  Setter for DLNA.ORG_CI parameter.
-//-----------------------------------------------------------------
-EXPORT_C void CUpnpDlnaProtocolInfo::SetCiParameter(TBool aValue)
-    {
-    iDlnaCi = aValue;
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::CiParameter()
-//  Getter for DLNA.ORG_CI parameter.
-//-----------------------------------------------------------------
-EXPORT_C TBool CUpnpDlnaProtocolInfo::CiParameter()
-    {
-    return !(iDlnaCi <= 0);
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetOtherParamsL(TDesC8& aValue)
-//  Setter for other parameter value.
-//-----------------------------------------------------------------
-EXPORT_C void CUpnpDlnaProtocolInfo::SetOtherParamL(const TDesC8& aValue)
-     {
-     if ( iOtherParams)
-         {
-         delete iOtherParams;
-         iOtherParams = NULL;
-         }
-     iOtherParams = aValue.AllocL();
-     }    
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::GetOtherParams()
-//  Getter for other parameter value.
-//-----------------------------------------------------------------
-EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::GetOtherParams()
-     {
-     if ( iOtherParams )
-         {
-         return iOtherParams->Des();
-         }
-     else
-         {
-         return KNullDesC8();
-         }
-     }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetDlnaFlag(TBool aValue,TInt flag)
-//  Setter for a single flag.
-//-----------------------------------------------------------------
-EXPORT_C void CUpnpDlnaProtocolInfo::SetDlnaFlag(UpnpDlnaProtocolInfo::TDlnaFlags flag, TBool aValue)
-    {
-    SetDlnaFlag( aValue, flag);
-    }
-
-//-----------------------------------------------------------------
-//  ProtocolInfo::DlnaFlag()
-//  Getter for a single flag.
-//-----------------------------------------------------------------
-EXPORT_C TBool CUpnpDlnaProtocolInfo::DlnaFlag(UpnpDlnaProtocolInfo::TDlnaFlags flag)
-    {
-    return GetDlnaFlag(flag);
-    }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetDlnaPnParameterL(TDesC8& aValue)
-//  Setter for DLNA.ORG_PN.
-//-----------------------------------------------------------------
-EXPORT_C void CUpnpDlnaProtocolInfo::SetPnParameterL(const TDesC8& aValue)
-     {
-    if ( iDlnaPn )
-        {
-        delete iDlnaPn ; 
-        iDlnaPn = NULL;
-        }
-    iDlnaPn = aValue.AllocL();
-    }
- 
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::GetDlnaPnParameter()
-//  Getter for DLNA.ORG_PN.
-//-----------------------------------------------------------------
-EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::PnParameter()
-    {
-     if ( iDlnaPn )
-         {
-         return iDlnaPn->Des();
-         }
-     else 
-         {
-         return KNullDesC8();
-         }
-     }
-
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::SetDlnaPsParameterL(TDesC8& aValue)
-//  Setter for DLNA.ORG_PS.
-//-----------------------------------------------------------------
-EXPORT_C void CUpnpDlnaProtocolInfo::SetPsParameterL(const TDesC8& aValue)
-    {
-    if ( iDlnaPs )
-        {
-        delete iDlnaPs ; 
-        iDlnaPs = NULL;
-        }
-    iDlnaPs = aValue.AllocL();    
-    }
- 
-//-----------------------------------------------------------------
-//  CProtocolInfoDlna::GetDlnaPsParameter()
-//  Getter for DLNA.ORG_PS.
-//-----------------------------------------------------------------
-EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::PsParameter()
-     {
-     if ( iDlnaPs )
-         {
-         return iDlnaPs->Des();
-         }
-     else
-        {
-        return KNullDesC8();
-        }
-     }
-
-     
-//end of file
+/** @file
+* Copyright (c) 2005-2008 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:  ProtocolInfo DLNA functionality class 
+*
+*/
+
+
+#include "upnpdlnaprotocolinfo.h"
+#include "upnpdlnaprotocolinfocons.h"
+#include "upnpprotocolinfolocal.h"
+
+#include <e32base.h>
+#include <e32cons.h>
+
+using namespace UpnpDlnaProtocolInfo;
+
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::CProtocolInfoDlna()
+//  Constructor of the class
+//-----------------------------------------------------------------
+CUpnpDlnaProtocolInfo::CUpnpDlnaProtocolInfo(): CUpnpProtocolInfo(),
+                                            iDlnaCi( KErrNotFound ) 
+    {    
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::~CProtocolInfoDlna()
+//  Destructor of the class
+//-----------------------------------------------------------------
+CUpnpDlnaProtocolInfo::~CUpnpDlnaProtocolInfo()
+    {    
+    delete iDlnaPn; 
+    delete iDlnaPs; 
+    delete iOtherParams;
+    delete iFlagsParam;
+    delete iOpParam;
+    }
+
+
+//-----------------------------------------------------------------
+// CProtocolInfoDlna::NewL
+// Factory method for creating instance of class. aInputString must contain protocolInfo string.
+//-----------------------------------------------------------------
+EXPORT_C CUpnpDlnaProtocolInfo* CUpnpDlnaProtocolInfo::NewL()
+    {
+    CUpnpDlnaProtocolInfo* newElement = new (ELeave) CUpnpDlnaProtocolInfo();
+    CleanupStack::PushL( newElement );
+    CleanupStack::Pop( newElement );
+    return newElement; 
+    }
+
+    
+//-----------------------------------------------------------------
+// CProtocolInfoDlna::NewL
+// Factory method for creating instance of class. aInputString must contain protocolInfo string.
+//-----------------------------------------------------------------
+EXPORT_C CUpnpDlnaProtocolInfo* CUpnpDlnaProtocolInfo::NewL(const TDesC8& aInputString)
+    {
+    CUpnpDlnaProtocolInfo* newElement = new (ELeave) CUpnpDlnaProtocolInfo();
+    CleanupStack::PushL( newElement );
+    newElement->BaseConstructL( aInputString );     
+    CleanupStack::Pop( newElement );
+    return newElement; 
+    }
+    
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::ConstructL(TDesC8& aInputString)
+//  Method for creating instance of class. aInputString must contain protocolInfo string.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::ConstructL(const TDesC8& aInputString) 
+    {
+    BaseConstructL(aInputString);
+    
+    TInt result = ParseL( aInputString );
+    if ( result != KErrNone ) 
+        {
+        User::Leave( result );            
+        }
+    }
+
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetOpTimeParam(TBool aValue)
+//  Setter for DLNA.ORG_OP time seek parameter.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::SetOpTimeParam(TBool aValue)
+    {
+    SetDlnaParam( aValue, A_VAL );
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetOpRangeParam(TBool aValue)
+//  Setter for DLNA.ORG_OP range seek parameter.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::SetOpRangeParam(TBool aValue)
+    {
+    return SetDlnaParam( aValue, B_VAL );
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetDlnaFlag(TBool aValue, TInt aFlagIndex)
+//  Setter for DLNA_FLAGS
+//-----------------------------------------------------------------
+void  CUpnpDlnaProtocolInfo::SetDlnaFlag(TBool aValue, TUint8 aFlagIndex)
+    {
+    if ( aFlagIndex >= KDLNA_FLAGS_QUANTITY) return;
+    TInt index = aFlagIndex / K32BIT;
+    SetIntBit32((TUint32&) iDlnaFlags[ index ], aValue, aFlagIndex);
+    }    
+    
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::GetDlnaFlag(TInt aFlagIndex)
+//  Getter for DLNA_FLAGS
+//-----------------------------------------------------------------
+TBool CUpnpDlnaProtocolInfo::GetDlnaFlag(TInt aFlagIndex)
+    {
+    if ( aFlagIndex >= KDLNA_FLAGS_QUANTITY ) return EFalse;
+    TUint8 index = aFlagIndex / K32BIT;
+    TUint8 bit_index = aFlagIndex % K32BIT;
+    TUint32 bit = 1<<bit_index;    
+    if ( iDlnaFlags[ index ]  & bit )
+        {
+        return ETrue;
+        }
+    else 
+        {
+        return EFalse;
+        }
+    
+    }        
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::ParseL(TDesC8& aInputString)
+//  Parses aInputString into protocolInfo object.
+//-----------------------------------------------------------------
+TInt CUpnpDlnaProtocolInfo::ParseL(const TDesC8& aInputString)
+    {
+        TInt result = KErrNone;        
+        CUpnpProtocolInfo::ParseL(aInputString);
+        
+        result = ParseForthParameterL();
+        if ( iDlnaPn != NULL)
+            {
+            delete iFourthParameter; 
+            iFourthParameter = NULL;
+            }
+        return result;        
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::ParseForthParameterL()
+//  Parses the fourth field.
+//-----------------------------------------------------------------
+TInt CUpnpDlnaProtocolInfo::ParseForthParameterL()
+    {
+    HBufC8* forth = iFourthParameter;
+    if ( !forth )
+        {
+        return KErrArgument;
+        }
+
+    TLex8 input(*forth);
+    TBool end = EFalse;
+    while( (!input.Eos()) && (!end))
+        {
+        ParseAtomToDelimeter( input, KDlnaTokenizer);
+        TPtrC8 name(input.MarkedToken());
+        Skip(input,1);
+        end = ParseForthParameterInternalL( name, input);
+        }
+    return KErrNone;
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::ParseDlnaPsParamL(TLex8& aLexer)
+//  Parses DLNA.ORG_PS params.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::ParseDlnaPsParamL(TLex8& aLexer)
+    {
+    ParseAtomToDelimeter(aLexer, KDlnaDelimeter);
+    TPtrC8 value (aLexer.MarkedToken());
+    if ( aLexer.MarkedToken().Length() == 0 ) User::Leave( KErrArgument );
+    SetPsParameterL(value);
+    SkipAndMark(aLexer, 1);
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::ParseDlnaPnParamL(TLex8& aLexer)
+//  Parses DLNA.ORG_PN params.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::ParseDlnaPnParamL(TLex8& aLexer)
+    {
+    ParseAtomToDelimeter(aLexer, KDlnaDelimeter);
+    TPtrC8 value (aLexer.MarkedToken());
+    if ( aLexer.MarkedToken().Length() == 0 ) User::Leave( KErrArgument );
+    SetPnParameterL(value);
+    SkipAndMark(aLexer, 1);
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::ParseDlnaOpParamL(TLex8& aLexer)
+//  Parses DLNA.ORG_OP params.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::ParseDlnaOpParamL(TLex8& aLexer)
+    {
+    ParseAtomToDelimeter(aLexer, KDlnaDelimeter);
+    TPtrC8 value (aLexer.MarkedToken());
+    if (value.Length() != 2) User::Leave( KErrArgument );
+    TChar character = value[0]; 
+    User::LeaveIfError(CheckBooleanValue(character));
+    SetOpTimeParam(character == KDLNA_BOOLEAN_TRUE);    
+    character = value[1]; 
+    User::LeaveIfError(CheckBooleanValue(character));
+    SetOpRangeParam(character == KDLNA_BOOLEAN_TRUE);
+    //SetOpParameter
+    SkipAndMark(aLexer, 1);
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::ParseDlnaCiParamL(TLex8& aLexer)
+//  Parses DLNA.ORG_CI params.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::ParseDlnaCiParamL(TLex8& aLexer)
+    {
+    ParseAtomToDelimeter(aLexer, KDlnaDelimeter);
+    TPtrC8 value (aLexer.MarkedToken());
+    if (value.Length() != 1) User::Leave( KErrArgument );
+    TChar character = value[0]; 
+    User::LeaveIfError(CheckBooleanValue(character));    
+    SetCiParameter(character == KDLNA_BOOLEAN_TRUE);
+    //SetOpParameter
+    SkipAndMark(aLexer, 1);
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::ParseDlnaFlagsParamL(TLex8& aLexer)
+//  Parses DLNA.ORG_FLAGS params.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::ParseDlnaFlagsParamL(TLex8& aLexer)
+    {
+    ParseAtomToDelimeter(aLexer, KDlnaDelimeter);
+    
+    if ( aLexer.MarkedToken().Length() != 
+        KDLNA_FLAGS_NUMBER * KMAX_INT_LENGTH_STRING) 
+        User::Leave( KErrArgument );
+    
+    TLex8 plagLex(aLexer.MarkedToken());    
+    
+    for(int i = 0; i < KDLNA_FLAGS_NUMBER; i++)
+        {
+        plagLex.Mark();
+        plagLex.Inc( KMAX_INT_LENGTH_STRING );
+        TPtrC8 value (plagLex.MarkedToken());
+        // check if values are from HEX range
+        for (TInt j = 0; j < KMAX_INT_LENGTH_STRING;j++)
+            if (!((value[j] >='0' &&  value[j] <='9') ||
+                (value[j] >='a' &&  value[j] <='f') || 
+                (value[j] >='A' &&  value[j] <='F')))
+                User::Leave( KErrArgument );
+        
+        TLex8* ptr = new TLex8(value);
+        CleanupStack::PushL(ptr);
+        User::LeaveIfError(ptr->Val(iDlnaFlags[i], EHex)); 
+        CleanupStack::PopAndDestroy(ptr);
+        }
+    SkipAndMark(aLexer,1);
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::ParseOtherParamsL(TLex8& aLexer)
+//  Parses other params.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::ParseOtherParamsL(TLex8& /*aLexer*/)
+    {
+    if ( iDlnaPn != NULL )
+        {
+        
+        //    SetOtherParamL(aLexer.RemainderFromMark());
+        }
+    }
+    
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::ParseForthParameterInternalL( TDesC8& aName, TLex8& aLexer)
+//  Parses the fourth param.
+//-----------------------------------------------------------------
+TBool CUpnpDlnaProtocolInfo::ParseForthParameterInternalL( const TDesC8& aName, TLex8& aLexer)
+    {
+    TBool result = EFalse;
+    if ( aName.Compare(KDLNA_PN) == 0)
+        {
+        aLexer.Mark();
+        ParseDlnaPnParamL(aLexer);
+        }
+    else if ( aName.Compare(KDLNA_OP) == 0 )
+        {
+        aLexer.Mark();
+        ParseDlnaOpParamL(aLexer);
+        }
+    else if ( aName.Compare(KDLNA_PS) == 0 )
+        {
+        aLexer.Mark();
+        ParseDlnaPsParamL(aLexer);
+        }
+    else if ( aName.Compare(KDLNA_CI) == 0 )        
+        {
+        aLexer.Mark();
+        ParseDlnaCiParamL(aLexer);
+        }
+    else if ( aName.Compare(KDLNA_FLAGS) == 0 )                
+        {
+        aLexer.Mark();
+        ParseDlnaFlagsParamL(aLexer);
+        }
+    else 
+        {
+        ParseOtherParamsL(aLexer);
+        result = ETrue;
+        }
+    return result;
+    }
+        
+//-----------------------------------------------------------------
+//  CUpnpDlnaProtocolInfo::FourthField()
+//  
+//-----------------------------------------------------------------
+EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::FourthField()
+    {
+     TRAPD( error, FourthParameterInternalL() )
+     if ( error )
+         { 
+         return KNullDesC8();
+         }    
+    return iFourthParameter->Des();
+    }
+
+
+//-----------------------------------------------------------------
+//  CUpnpDlnaProtocolInfo::FourthParameterInternalL()
+//  
+//-----------------------------------------------------------------    
+void CUpnpDlnaProtocolInfo::FourthParameterInternalL()
+    {
+    TInt len = GetFourthParameterLength();
+    
+    HBufC8* buf = HBufC8::NewLC(len);
+    TPtr8 bufPtr(buf->Des());
+    GetFourthParameterInternalL(bufPtr);
+    
+    delete iFourthParameter;
+    iFourthParameter = buf;
+    
+    CleanupStack::Pop(buf);        
+    }
+    
+    
+        
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetIntBit(TInt& aParameter, TBool aValue, TInt aBitNumber)
+//  Setter for DLNA_FLAGS
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::SetIntBit8(TUint8& aParameter, TBool aValue, TUint8 aBitNumber)
+    {
+    if ( aBitNumber >= KMAX_INT_LENGTH_STRING ) return;
+    if ( ! (aValue == EFalse) )
+        {
+        aParameter |= (TUint8)1<<aBitNumber;
+        }
+    else
+        {
+        aParameter  &= ~((TUint8)1<<aBitNumber);
+        }
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetIntBit(TInt& aParameter, TBool aValue, TInt aBitNumber)
+//  Setter for DLNA_FLAGS
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::SetIntBit32(TUint32& aParameter, TBool aValue, TUint8 aBitNumber)
+    {
+    if ( aBitNumber >= K32BIT ) return;
+    if ( ! (aValue == EFalse) )
+        {
+        aParameter |= (TUint32)1<<aBitNumber;
+        }
+    else
+        {
+        aParameter  &= ~((TUint32)1<<aBitNumber);
+        }
+    }    
+    
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetDlnaParam(TBool aValue, TInt aParamIndex)
+//  Setter for a DLNA parameter.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::SetDlnaParam(TBool aValue, TUint8 aParamIndex)
+    {
+    SetIntBit8((TUint8&) iParams, aValue, aParamIndex);
+    }    
+            
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::GetDlnaParam(TInt aParamIndex)
+//  Getter for DLNA params.
+//-----------------------------------------------------------------
+TBool CUpnpDlnaProtocolInfo::GetDlnaParam(TInt aParamIndex)
+    {
+     return ( iParams  & ((TUint8)1<<aParamIndex));
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::IsDlnaFlagsSet()
+//  This function returns ETrue if at least one dlna flag is set
+//-----------------------------------------------------------------
+TBool CUpnpDlnaProtocolInfo::IsDlnaFlagsSet()
+    {
+    for( int i = 0; i < KDLNA_FLAGS_NUMBER  ; i++)
+        {
+        if (iDlnaFlags[i] != 0 )
+            return ETrue;     
+        }
+    //if not DLNA flags not set
+    return EFalse;        
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::GetForthParameterInternalL(TPtr8& aBuffer)
+//  This function produces a string containing all info taken from fourth ProtocolInfo field
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::GetFourthParameterInternalL(TDes8& aBuffer)
+    {
+    
+    //if ( FourthField() != KNullDesC8)
+    //    {
+    //    aBuffer.Append( *iFourthParameter );
+    //    return;
+    //    }    
+    
+    
+    if ( PnParameter() == KNullDesC8 )        
+        {
+        aBuffer.Append(KDlnaAllStar);
+        return;
+        }
+    aBuffer.Append( KDLNA_PN );
+    aBuffer.Append( KDlnaTokenizer ); 
+    aBuffer.Append( *iDlnaPn );
+    if ( GetDlnaOpRangeParam() || GetDlnaOpTimeParam() )
+        {
+        aBuffer.Append( KDlnaDelimeter ); 
+        aBuffer.Append( KDLNA_OP );
+        aBuffer.Append( KDlnaTokenizer ); 
+        aBuffer.Append( GetDlnaOpTimeParam() ? KDLNA_BOOLEAN_TRUE:KDLNA_BOOLEAN_FALSE); //Time value 0,1
+        aBuffer.Append( GetDlnaOpRangeParam() ? KDLNA_BOOLEAN_TRUE:KDLNA_BOOLEAN_FALSE); //Range value 0,1
+        }
+    if ( PsParameter() != KNullDesC8 )
+        {
+        aBuffer.Append( KDlnaDelimeter ); 
+        aBuffer.Append( KDLNA_PS );
+        aBuffer.Append( KDlnaTokenizer ); 
+        aBuffer.Append( *iDlnaPs );
+        }
+    if ( iDlnaCi != KErrNotFound )
+        {
+        aBuffer.Append( KDlnaDelimeter ); 
+        aBuffer.Append( KDLNA_CI );
+        aBuffer.Append( KDlnaTokenizer ); 
+        aBuffer.Append( iDlnaCi ? KOneChar() : KZeroChar() ); 
+        }
+    
+    TBool saveDlnaFlags = IsDlnaFlagsSet();
+    
+    if ( saveDlnaFlags )
+        {
+        aBuffer.Append( KDlnaDelimeter ); 
+        aBuffer.Append( KDLNA_FLAGS );
+        aBuffer.Append( KDlnaTokenizer ); 
+        SerializeDlnaFlagsL( aBuffer );
+        }
+    if ( GetOtherParams() != KNullDesC8) 
+        {
+        aBuffer.Append( KDlnaDelimeter ); 
+        aBuffer.Append( *iOtherParams );
+        }
+    }
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::GetForthParameterParameterLength
+//  This function returns length of the string containing all relevant information from fourth ProtocolInfo field. 
+//-----------------------------------------------------------------
+TInt CUpnpDlnaProtocolInfo::GetFourthParameterLength()
+    {
+    
+    //if ( FourthField() != KNullDesC8)
+    //    {
+    //    return iFourthParameter->Length();
+    //    }
+    
+    
+    if ( PnParameter() == KNullDesC8 )        
+        {
+        return 1; 
+        }
+    TInt result = 0; 
+    result += KDLNA_PN.operator()().Length();
+    result += 1 ; 
+    result += iDlnaPn->Length();
+    if ( GetDlnaOpRangeParam() || GetDlnaOpTimeParam() )
+        {
+        result += 1; // ; 
+        result += KDLNA_OP.operator()().Length();
+        result += 1; //= 
+        result += 1; //Time value 0,1
+        result += 1; //Range value 0,1
+        }
+    if ( PsParameter() != KNullDesC8 )
+        {
+        result += 1; // ; separator
+        result += KDLNA_PS.operator()().Length();
+        result += 1; // = 
+        result += iDlnaPs->Length();
+        }
+    if ( iDlnaCi != KErrNotFound )
+        {
+        result += 1; //; 
+        result += KDLNA_CI.operator()().Length();
+        result += 1; //= 
+        result += 1; // value 
+        }
+    
+    TBool saveDlnaFlags = IsDlnaFlagsSet();
+    
+    if ( saveDlnaFlags )
+        {
+        result += 1; //; 
+        result += KDLNA_FLAGS.operator()().Length();
+        result += 1; // = 
+        result += KDLNA_FLAGS_NUMBER * KMAX_INT_LENGTH_STRING; // Values length
+        }
+    if ( GetOtherParams() != KNullDesC8 ) 
+        {
+        result += 1; //; 
+        result += iOtherParams->Length();
+        }
+    return result;
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SerializeDlnaFlagsL(TPtr8& aBuffer)
+//  Serializes iDlnaFlags member variable into a string.
+//-----------------------------------------------------------------
+void CUpnpDlnaProtocolInfo::SerializeDlnaFlagsL(TDes8& aBuffer)
+    {
+    HBufC8* number = HBufC8::NewL(KMAX_INT_LENGTH_STRING);
+    TPtr8 ptrNumber( number->Des() );
+    for(int i = 0; i < KDLNA_FLAGS_NUMBER ; i++)    
+        {
+        ptrNumber.NumFixedWidth(iDlnaFlags[i], EHex, KMAX_INT_LENGTH_STRING);
+        ptrNumber.UpperCase();
+        aBuffer.Append( *number);
+        }
+    delete number;
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::GetDlnaOpTimeParam()
+//  Getter for DLNA.ORG_OP time seek parameter.
+//-----------------------------------------------------------------
+TBool CUpnpDlnaProtocolInfo::GetDlnaOpTimeParam()
+    {
+    return GetDlnaParam(A_VAL);
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::GetDlnaOpRangeParam()
+//  Getter for DLNA.ORG_OP range seek parameter.
+//-----------------------------------------------------------------
+TBool CUpnpDlnaProtocolInfo::GetDlnaOpRangeParam()
+    {
+    return GetDlnaParam(B_VAL);
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetOpParameterL(TPtrC8 aValue)
+//  Setter for DLNA.ORG_OP parameter.
+//-----------------------------------------------------------------
+EXPORT_C void CUpnpDlnaProtocolInfo::SetOpParameterL(const TDesC8& aValue)
+    {                   
+    TPtrC8 opParamName;
+    TPtrC8 opParamValue;
+        
+    //---- getting a proper value of DLNA.ORG_OP param --
+    if ( aValue.Locate(KDlnaTokenizer) > KErrNotFound )
+    {
+        TLex8 lexer(aValue);    
+        ParseAtomToDelimeter( lexer, KDlnaTokenizer);
+        opParamName.Set( lexer.MarkedToken() );
+        
+        if ( opParamName != KDLNA_OP)
+            {
+            User::Leave(KErrBadDescriptor);    
+            }
+        
+        Skip(lexer, 1);            
+        opParamValue.Set( lexer.Remainder() );         
+        }
+    else
+        {
+        opParamValue.Set(aValue);            
+        }
+                
+    //---- parsing DLNA.ORG_OP param value ---------------
+    if ( opParamValue.Length() == 2 && 
+        !CheckBooleanValue(((TChar)opParamValue[0])) && 
+        !CheckBooleanValue(((TChar)opParamValue[1])) 
+        )
+        {                        
+        TBool opTimeParam = ((TChar)opParamValue[0]).GetNumericValue();
+        TBool opRangeParam = ((TChar)opParamValue[1]).GetNumericValue();
+        
+        SetOpTimeParam(opTimeParam);
+        SetOpRangeParam(opRangeParam);        
+        }
+    else 
+        {        
+        User::Leave(KErrBadDescriptor);
+        }                                                                                        
+    } 
+    
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetOpParameterL(UpnpDlnaProtocolInfo::TDlnaParams param,TBool aValue)
+//  Setter for DLNA.ORG_OP parameter.
+//-----------------------------------------------------------------
+EXPORT_C void CUpnpDlnaProtocolInfo::SetOpParameterL(UpnpDlnaProtocolInfo::TDlnaParams param,TBool aValue)
+    {
+    SetDlnaParam( aValue, param );
+    }
+    
+//-----------------------------------------------------------------
+//  CUpnpDlnaProtocolInfo::OpParameterL()
+//  Getter for DLNA.ORG_OP parameter.
+//-----------------------------------------------------------------
+EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::OpParameterL()
+    {
+    TBool opTimeParam = GetDlnaOpTimeParam();
+    TBool opRangeParam = GetDlnaOpRangeParam();
+    HBufC8* opParameter = HBufC8::NewLC(2);    
+    opParameter->Des().AppendNum( opTimeParam ? 1:0 );
+    opParameter->Des().AppendNum( opRangeParam ? 1:0 );           
+       
+    CleanupStack::Pop(opParameter);
+       
+    delete iOpParam;
+    iOpParam = opParameter;
+    return iOpParam->Des();
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetOpParameterL(UpnpDlnaProtocolInfo::TDlnaParams param,TBool aValue)
+//  Setter for DLNA.ORG_OP parameter.
+//-----------------------------------------------------------------
+EXPORT_C TBool CUpnpDlnaProtocolInfo::OpParameter(UpnpDlnaProtocolInfo::TDlnaParams param)
+    {
+    return GetDlnaParam( param );
+    }
+    
+//-----------------------------------------------------------------
+//  CUpnpDlnaProtocolInfo::SetFlagsParameterL(const TDesC8& flags)
+//  Setter for DLNA.ORG_CI parameter.
+//-----------------------------------------------------------------
+EXPORT_C void CUpnpDlnaProtocolInfo::SetFlagsParameterL(const TDesC8& flags)
+    {                
+    TPtrC8 flagsParamName(KDLNA_FLAGS);        
+    TLex8 lexer(flags);
+    TInt len = flags.Length();
+                
+    //---- getting a proper value of DLNA.ORG_FLAGS ----
+    if ( flags.Locate(KDlnaTokenizer) > KErrNotFound )
+        {                    
+        ParseAtomToDelimeter( lexer, KDlnaTokenizer);
+        flagsParamName.Set( lexer.MarkedToken() );
+            
+        if ( flagsParamName != KDLNA_FLAGS )
+            {
+            User::Leave(KErrBadDescriptor);    
+            }
+            
+        Skip(lexer, 1);
+        TPtrC8 tmp = lexer.Remainder();
+                        
+        len = tmp.Length();
+        lexer = tmp;
+        }                                        
+        
+    //---- checking if DLNA.ORG_FLAGS has proper value --                
+    if (len != 32)
+        {
+        User::Leave( KErrBadDescriptor );
+        }
+        
+    while( !lexer.Eos() )
+        {
+        if ( !lexer.Get().IsHexDigit() )
+            {
+            User::Leave( KErrBadDescriptor );
+            }
+        }
+        
+    lexer.UnGetToMark();                                                
+    ParseForthParameterInternalL( flagsParamName, lexer );                       
+    }
+    
+//-----------------------------------------------------------------
+//  CUpnpDlnaProtocolInfo::FlagsParameterL()
+//  Getter for DLNA.ORG_CI parameter.
+//----------------------------------------------------------------
+EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::FlagsParameterL()
+    {
+    TInt len = KDLNA_FLAGS_NUMBER * KMAX_INT_LENGTH_STRING; // Values length
+    HBufC8* flagsParameter = HBufC8::NewLC(len);
+    TPtr8 ptr = flagsParameter->Des();
+    SerializeDlnaFlagsL(ptr);
+    CleanupStack::Pop(flagsParameter);    
+    delete iFlagsParam;
+    iFlagsParam = flagsParameter;            
+    return iFlagsParam->Des();
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetCiParameter(TBool aValue)
+//  Setter for DLNA.ORG_CI parameter.
+//-----------------------------------------------------------------
+EXPORT_C void CUpnpDlnaProtocolInfo::SetCiParameter(TBool aValue)
+    {
+    iDlnaCi = aValue;
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::CiParameter()
+//  Getter for DLNA.ORG_CI parameter.
+//-----------------------------------------------------------------
+EXPORT_C TBool CUpnpDlnaProtocolInfo::CiParameter()
+    {
+    return !(iDlnaCi <= 0);
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetOtherParamsL(TDesC8& aValue)
+//  Setter for other parameter value.
+//-----------------------------------------------------------------
+EXPORT_C void CUpnpDlnaProtocolInfo::SetOtherParamL(const TDesC8& aValue)
+     {
+     if ( iOtherParams)
+         {
+         delete iOtherParams;
+         iOtherParams = NULL;
+         }
+     iOtherParams = aValue.AllocL();
+     }    
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::GetOtherParams()
+//  Getter for other parameter value.
+//-----------------------------------------------------------------
+EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::GetOtherParams()
+     {
+     if ( iOtherParams )
+         {
+         return iOtherParams->Des();
+         }
+     else
+         {
+         return KNullDesC8();
+         }
+     }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetDlnaFlag(TBool aValue,TInt flag)
+//  Setter for a single flag.
+//-----------------------------------------------------------------
+EXPORT_C void CUpnpDlnaProtocolInfo::SetDlnaFlag(UpnpDlnaProtocolInfo::TDlnaFlags flag, TBool aValue)
+    {
+    SetDlnaFlag( aValue, flag);
+    }
+
+//-----------------------------------------------------------------
+//  ProtocolInfo::DlnaFlag()
+//  Getter for a single flag.
+//-----------------------------------------------------------------
+EXPORT_C TBool CUpnpDlnaProtocolInfo::DlnaFlag(UpnpDlnaProtocolInfo::TDlnaFlags flag)
+    {
+    return GetDlnaFlag(flag);
+    }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetDlnaPnParameterL(TDesC8& aValue)
+//  Setter for DLNA.ORG_PN.
+//-----------------------------------------------------------------
+EXPORT_C void CUpnpDlnaProtocolInfo::SetPnParameterL(const TDesC8& aValue)
+     {
+    if ( iDlnaPn )
+        {
+        delete iDlnaPn ; 
+        iDlnaPn = NULL;
+        }
+    iDlnaPn = aValue.AllocL();
+    }
+ 
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::GetDlnaPnParameter()
+//  Getter for DLNA.ORG_PN.
+//-----------------------------------------------------------------
+EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::PnParameter()
+    {
+     if ( iDlnaPn )
+         {
+         return iDlnaPn->Des();
+         }
+     else 
+         {
+         return KNullDesC8();
+         }
+     }
+
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::SetDlnaPsParameterL(TDesC8& aValue)
+//  Setter for DLNA.ORG_PS.
+//-----------------------------------------------------------------
+EXPORT_C void CUpnpDlnaProtocolInfo::SetPsParameterL(const TDesC8& aValue)
+    {
+    if ( iDlnaPs )
+        {
+        delete iDlnaPs ; 
+        iDlnaPs = NULL;
+        }
+    iDlnaPs = aValue.AllocL();    
+    }
+ 
+//-----------------------------------------------------------------
+//  CProtocolInfoDlna::GetDlnaPsParameter()
+//  Getter for DLNA.ORG_PS.
+//-----------------------------------------------------------------
+EXPORT_C TPtrC8 CUpnpDlnaProtocolInfo::PsParameter()
+     {
+     if ( iDlnaPs )
+         {
+         return iDlnaPs->Des();
+         }
+     else
+        {
+        return KNullDesC8();
+        }
+     }
+
+     
+//end of file
--- a/upnpmediaserver/avobjects/src/upnpitem.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/avobjects/src/upnpitem.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,132 +1,134 @@
-/** @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:  UPnP container class implementation
-*
-*/
-
-
-// INCLUDE FILES
-#include    <e32base.h>
-#include	"upnpobject.h"
-#include    "upnpitem.h"
-
-
-
-
-
-
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpItem::CUpnpItem
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CUpnpItem::CUpnpItem()
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpItem::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CUpnpItem::ConstructL(  )
-    {
-    iRefId = KNullDesC8().AllocL();
-    CUpnpObject::ConstructL(  );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpItem::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-EXPORT_C CUpnpItem* CUpnpItem::NewL( )
-    {
-    CUpnpItem* self = new( ELeave ) CUpnpItem;    
-	self->ConstructL();
-    return self;
-    }
-
-    
-// Destructor
-EXPORT_C CUpnpItem::~CUpnpItem()
-    {
-    delete iRefId;
-    }
-         
-// -----------------------------------------------------------------------------
-// CUpnpItem::SetRefIdL
-// Sets file name for the object.
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpItem::SetRefIdL( const TDesC8& aRefIdL )
-    {
-    HBufC8* tmp = aRefIdL.AllocL();
-    delete iRefId;
-    iRefId = tmp;    
-    }
-      
-// -----------------------------------------------------------------------------
-// CUpnpItem::FileName
-// Returns filename of the object. If null, returns KNullDesC
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-EXPORT_C const TDesC8& CUpnpItem::RefId() const
-    {
-    return *iRefId;
-    }    
-      
-// -----------------------------------------------------------------------------
-// CUpnpItem::ExternalizeL
-// Writes the content to stream.
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpItem::ExternalizeL( RWriteStream& aStream ) const
-    {
-    BaseExternalizeL( aStream );
-    aStream << RefId();
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpItem::InternalizeL
-// Fills item information from stream
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//	
-EXPORT_C void CUpnpItem::InternalizeL( RReadStream& aStream )
-    {
-    BaseInternalizeL( aStream );
-    delete iRefId;
-    iRefId = NULL;
-    iRefId = HBufC8::NewL( aStream, KMaxUpnpObjStringLen );    
-    }
-// -----------------------------------------------------------------------------
-// CUpnpItem::ObjectType
-// Returns item-type
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUPnPObjectType CUpnpItem::ObjectType() const
-    {
-    return EUPnPItem;
-    }
-  
-//  End of File
+/** @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:  UPnP container class implementation
+*
+*/
+
+
+// INCLUDE FILES
+#include    <e32base.h>
+#include	"upnpobject.h"
+#include    "upnpitem.h"
+
+
+
+
+
+
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpItem::CUpnpItem
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUpnpItem::CUpnpItem()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpItem::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUpnpItem::ConstructL(  )
+    {
+    iRefId = KNullDesC8().AllocL();
+    CUpnpObject::ConstructL(  );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpItem::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CUpnpItem* CUpnpItem::NewL( )
+    {
+    CUpnpItem* self = new( ELeave ) CUpnpItem;    
+    CleanupStack::PushL( self );
+	self->ConstructL();
+	CleanupStack::Pop( self );
+    return self;
+    }
+
+    
+// Destructor
+EXPORT_C CUpnpItem::~CUpnpItem()
+    {
+    delete iRefId;
+    }
+         
+// -----------------------------------------------------------------------------
+// CUpnpItem::SetRefIdL
+// Sets file name for the object.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpItem::SetRefIdL( const TDesC8& aRefIdL )
+    {
+    HBufC8* tmp = aRefIdL.AllocL();
+    delete iRefId;
+    iRefId = tmp;    
+    }
+      
+// -----------------------------------------------------------------------------
+// CUpnpItem::FileName
+// Returns filename of the object. If null, returns KNullDesC
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C const TDesC8& CUpnpItem::RefId() const
+    {
+    return *iRefId;
+    }    
+      
+// -----------------------------------------------------------------------------
+// CUpnpItem::ExternalizeL
+// Writes the content to stream.
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpItem::ExternalizeL( RWriteStream& aStream ) const
+    {
+    BaseExternalizeL( aStream );
+    aStream << RefId();
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpItem::InternalizeL
+// Fills item information from stream
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//	
+EXPORT_C void CUpnpItem::InternalizeL( RReadStream& aStream )
+    {
+    BaseInternalizeL( aStream );
+    delete iRefId;
+    iRefId = NULL;
+    iRefId = HBufC8::NewL( aStream, KMaxUpnpObjStringLen );    
+    }
+// -----------------------------------------------------------------------------
+// CUpnpItem::ObjectType
+// Returns item-type
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUPnPObjectType CUpnpItem::ObjectType() const
+    {
+    return EUPnPItem;
+    }
+  
+//  End of File
--- a/upnpmediaserver/contentdirectoryservice/BWINS/AVContentDirectoryU.DEF	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/BWINS/AVContentDirectoryU.DEF	Mon Nov 01 12:37:49 2010 +0200
@@ -1,28 +1,31 @@
-EXPORTS
-	?UnknownHttpEventReceivedL@CUpnpContentDirectory@@QAEXAAVCUpnpHttpMessage@@@Z @ 1 NONAME ; void CUpnpContentDirectory::UnknownHttpEventReceivedL(class CUpnpHttpMessage &)
-	?SendActionL@CUpnpContentDirectory@@QAEXPAVCUpnpAction@@W4TUpnpErrorCode@@@Z @ 2 NONAME ; void CUpnpContentDirectory::SendActionL(class CUpnpAction *, enum TUpnpErrorCode)
-	?NewL@CUpnpContentDirectoryService@@SAPAV1@XZ @ 3 NONAME ; class CUpnpContentDirectoryService * CUpnpContentDirectoryService::NewL(void)
-	?ShareReferenceListL@CUpnpContentDirectoryService@@QAEXPAVCUpnpItemList@@PAH@Z @ 4 NONAME ; void CUpnpContentDirectoryService::ShareReferenceListL(class CUpnpItemList *, int *)
-	?NewLC@CUpnpContentDirectoryService@@SAPAV1@UTUpnpCdSettings@@@Z @ 5 NONAME ; class CUpnpContentDirectoryService * CUpnpContentDirectoryService::NewLC(struct TUpnpCdSettings)
-	?GetSingleContainerL@CUpnpContentDirectoryService@@QAEPAVCUpnpContainer@@H@Z @ 6 NONAME ; class CUpnpContainer * CUpnpContentDirectoryService::GetSingleContainerL(int)
-	?AddressChangeL@CUpnpContentDirectoryService@@QAEXXZ @ 7 NONAME ; void CUpnpContentDirectoryService::AddressChangeL(void)
-	?UnshareItemL@CUpnpContentDirectoryService@@QAEXH@Z @ 8 NONAME ; void CUpnpContentDirectoryService::UnshareItemL(int)
-	?SendMessageL@CUpnpContentDirectory@@QAEXPAVCUpnpHttpMessage@@@Z @ 9 NONAME ; void CUpnpContentDirectory::SendMessageL(class CUpnpHttpMessage *)
-	?ShareReferenceL@CUpnpContentDirectoryService@@QAEXPAVCUpnpItem@@@Z @ 10 NONAME ; void CUpnpContentDirectoryService::ShareReferenceL(class CUpnpItem *)
-	?GetContentDirectory@CUpnpContentDirectoryService@@QAEPAVCUpnpContentDirectory@@XZ @ 11 NONAME ; class CUpnpContentDirectory * CUpnpContentDirectoryService::GetContentDirectory(void)
-	?UnshareItemListL@CUpnpContentDirectoryService@@QAEXAAV?$RArray@H@@PAH@Z @ 12 NONAME ; void CUpnpContentDirectoryService::UnshareItemListL(class RArray<int> &, int *)
-	?GetAddress@CUpnpContentDirectoryService@@QAE?AVTInetAddr@@XZ @ 13 NONAME ; class TInetAddr CUpnpContentDirectoryService::GetAddress(void)
-	?NewTransactionL@CUpnpContentDirectory@@UAEXABVTDesC8@@0ABVTInetAddr@@AAPAVCUpnpHttpServerTransaction@@@Z @ 14 NONAME ; void CUpnpContentDirectory::NewTransactionL(class TDesC8 const &, class TDesC8 const &, class TInetAddr const &, class CUpnpHttpServerTransaction * &)
-	?NewL@CUpnpContentDirectoryService@@SAPAV1@UTUpnpCdSettings@@@Z @ 15 NONAME ; class CUpnpContentDirectoryService * CUpnpContentDirectoryService::NewL(struct TUpnpCdSettings)
-	?SetDownloadDirectoryL@CUpnpContentDirectoryService@@QAEXABVTDesC16@@@Z @ 16 NONAME ; void CUpnpContentDirectoryService::SetDownloadDirectoryL(class TDesC16 const &)
-	?ShareItemListL@CUpnpContentDirectoryService@@QAEXPAVCUpnpItemList@@PAH@Z @ 17 NONAME ; void CUpnpContentDirectoryService::ShareItemListL(class CUpnpItemList *, int *)
-	?ShareObjectL@CUpnpContentDirectoryService@@QAEXPAVCUpnpObject@@@Z @ 18 NONAME ; void CUpnpContentDirectoryService::ShareObjectL(class CUpnpObject *)
-	?SetSender@CUpnpContentDirectory@@QAEXPAVMUpnpCdsSender@@@Z @ 19 NONAME ; void CUpnpContentDirectory::SetSender(class MUpnpCdsSender *)
-	?UnshareContainerL@CUpnpContentDirectoryService@@QAEXH@Z @ 20 NONAME ; void CUpnpContentDirectoryService::UnshareContainerL(int)
-	?GetItemListL@CUpnpContentDirectoryService@@QAEXHPAVCUpnpBrowseCriteria@@PAHPAVCUpnpItemList@@@Z @ 21 NONAME ; void CUpnpContentDirectoryService::GetItemListL(int, class CUpnpBrowseCriteria *, int *, class CUpnpItemList *)
-	?GetContainerListL@CUpnpContentDirectoryService@@QAEXHPAVCUpnpBrowseCriteria@@PAHPAVCUpnpContainerList@@@Z @ 22 NONAME ; void CUpnpContentDirectoryService::GetContainerListL(int, class CUpnpBrowseCriteria *, int *, class CUpnpContainerList *)
-	?HttpTransferEventReceivedL@CUpnpContentDirectory@@QAEXAAVCUpnpHttpMessage@@@Z @ 23 NONAME ; void CUpnpContentDirectory::HttpTransferEventReceivedL(class CUpnpHttpMessage &)
-	?NewLC@CUpnpContentDirectoryService@@SAPAV1@XZ @ 24 NONAME ; class CUpnpContentDirectoryService * CUpnpContentDirectoryService::NewLC(void)
-	?SetThumbnailDirectoryL@CUpnpContentDirectoryService@@QAEXABVTDesC16@@@Z @ 25 NONAME ; void CUpnpContentDirectoryService::SetThumbnailDirectoryL(class TDesC16 const &)
-	?GetSharedItemL@CUpnpContentDirectoryService@@QAEPAVCUpnpItem@@H@Z @ 26 NONAME ; class CUpnpItem * CUpnpContentDirectoryService::GetSharedItemL(int)
-
+EXPORTS
+	?UnknownHttpEventReceivedL@CUpnpContentDirectory@@QAEXAAVCUpnpHttpMessage@@@Z @ 1 NONAME ; void CUpnpContentDirectory::UnknownHttpEventReceivedL(class CUpnpHttpMessage &)
+	?SendActionL@CUpnpContentDirectory@@QAEXPAVCUpnpAction@@W4TUpnpErrorCode@@@Z @ 2 NONAME ; void CUpnpContentDirectory::SendActionL(class CUpnpAction *, enum TUpnpErrorCode)
+	?NewL@CUpnpContentDirectoryService@@SAPAV1@XZ @ 3 NONAME ; class CUpnpContentDirectoryService * CUpnpContentDirectoryService::NewL(void)
+	?ShareReferenceListL@CUpnpContentDirectoryService@@QAEXPAVCUpnpItemList@@PAH@Z @ 4 NONAME ; void CUpnpContentDirectoryService::ShareReferenceListL(class CUpnpItemList *, int *)
+	?NewLC@CUpnpContentDirectoryService@@SAPAV1@UTUpnpCdSettings@@@Z @ 5 NONAME ; class CUpnpContentDirectoryService * CUpnpContentDirectoryService::NewLC(struct TUpnpCdSettings)
+	?NewTransactionL@CUpnpDlnaFilter@@UAEXABVTDesC8@@0ABVTInetAddr@@AAPAVCUpnpHttpServerTransaction@@@Z @ 6 NONAME ; void CUpnpDlnaFilter::NewTransactionL(class TDesC8 const &, class TDesC8 const &, class TInetAddr const &, class CUpnpHttpServerTransaction * &)
+	?GetSingleContainerL@CUpnpContentDirectoryService@@QAEPAVCUpnpContainer@@H@Z @ 7 NONAME ; class CUpnpContainer * CUpnpContentDirectoryService::GetSingleContainerL(int)
+	?AddressChangeL@CUpnpContentDirectoryService@@QAEXXZ @ 8 NONAME ; void CUpnpContentDirectoryService::AddressChangeL(void)
+	?UnshareItemL@CUpnpContentDirectoryService@@QAEXH@Z @ 9 NONAME ; void CUpnpContentDirectoryService::UnshareItemL(int)
+	?SendMessageL@CUpnpContentDirectory@@QAEXPAVCUpnpHttpMessage@@@Z @ 10 NONAME ; void CUpnpContentDirectory::SendMessageL(class CUpnpHttpMessage *)
+	?ShareReferenceL@CUpnpContentDirectoryService@@QAEXPAVCUpnpItem@@@Z @ 11 NONAME ; void CUpnpContentDirectoryService::ShareReferenceL(class CUpnpItem *)
+	?GetContentDirectory@CUpnpContentDirectoryService@@QAEPAVCUpnpContentDirectory@@XZ @ 12 NONAME ; class CUpnpContentDirectory * CUpnpContentDirectoryService::GetContentDirectory(void)
+	?UnshareItemListL@CUpnpContentDirectoryService@@QAEXAAV?$RArray@H@@PAH@Z @ 13 NONAME ; void CUpnpContentDirectoryService::UnshareItemListL(class RArray<int> &, int *)
+	?GetAddress@CUpnpContentDirectoryService@@QAE?AVTInetAddr@@XZ @ 14 NONAME ; class TInetAddr CUpnpContentDirectoryService::GetAddress(void)
+	?NewL@CUpnpDlnaFilter@@SAPAV1@PAVMUpnpContentDirectoryDataFinder@@PAVCUpnpSecurityManager@@@Z @ 15 NONAME ; class CUpnpDlnaFilter * CUpnpDlnaFilter::NewL(class MUpnpContentDirectoryDataFinder *, class CUpnpSecurityManager *)
+	?NewTransactionL@CUpnpContentDirectory@@UAEXABVTDesC8@@0ABVTInetAddr@@AAPAVCUpnpHttpServerTransaction@@@Z @ 16 NONAME ; void CUpnpContentDirectory::NewTransactionL(class TDesC8 const &, class TDesC8 const &, class TInetAddr const &, class CUpnpHttpServerTransaction * &)
+	?NewL@CUpnpContentDirectoryService@@SAPAV1@UTUpnpCdSettings@@@Z @ 17 NONAME ; class CUpnpContentDirectoryService * CUpnpContentDirectoryService::NewL(struct TUpnpCdSettings)
+	?SetDownloadDirectoryL@CUpnpContentDirectoryService@@QAEXABVTDesC16@@@Z @ 18 NONAME ; void CUpnpContentDirectoryService::SetDownloadDirectoryL(class TDesC16 const &)
+	?ShareItemListL@CUpnpContentDirectoryService@@QAEXPAVCUpnpItemList@@PAH@Z @ 19 NONAME ; void CUpnpContentDirectoryService::ShareItemListL(class CUpnpItemList *, int *)
+	?ShareObjectL@CUpnpContentDirectoryService@@QAEXPAVCUpnpObject@@@Z @ 20 NONAME ; void CUpnpContentDirectoryService::ShareObjectL(class CUpnpObject *)
+	?SetSender@CUpnpContentDirectory@@QAEXPAVMUpnpCdsSender@@@Z @ 21 NONAME ; void CUpnpContentDirectory::SetSender(class MUpnpCdsSender *)
+	?UnshareContainerL@CUpnpContentDirectoryService@@QAEXH@Z @ 22 NONAME ; void CUpnpContentDirectoryService::UnshareContainerL(int)
+	?GetItemListL@CUpnpContentDirectoryService@@QAEXHPAVCUpnpBrowseCriteria@@PAHPAVCUpnpItemList@@@Z @ 23 NONAME ; void CUpnpContentDirectoryService::GetItemListL(int, class CUpnpBrowseCriteria *, int *, class CUpnpItemList *)
+	?GetContainerListL@CUpnpContentDirectoryService@@QAEXHPAVCUpnpBrowseCriteria@@PAHPAVCUpnpContainerList@@@Z @ 24 NONAME ; void CUpnpContentDirectoryService::GetContainerListL(int, class CUpnpBrowseCriteria *, int *, class CUpnpContainerList *)
+	?HttpTransferEventReceivedL@CUpnpContentDirectory@@QAEXAAVCUpnpHttpMessage@@@Z @ 25 NONAME ; void CUpnpContentDirectory::HttpTransferEventReceivedL(class CUpnpHttpMessage &)
+	?NewLC@CUpnpContentDirectoryService@@SAPAV1@XZ @ 26 NONAME ; class CUpnpContentDirectoryService * CUpnpContentDirectoryService::NewLC(void)
+	?SetThumbnailDirectoryL@CUpnpContentDirectoryService@@QAEXABVTDesC16@@@Z @ 27 NONAME ; void CUpnpContentDirectoryService::SetThumbnailDirectoryL(class TDesC16 const &)
+	?GetSharedItemL@CUpnpContentDirectoryService@@QAEPAVCUpnpItem@@H@Z @ 28 NONAME ; class CUpnpItem * CUpnpContentDirectoryService::GetSharedItemL(int)
+	?NewLC@CUpnpDlnaFilter@@SAPAV1@PAVMUpnpContentDirectoryDataFinder@@PAVCUpnpSecurityManager@@@Z @ 29 NONAME ; class CUpnpDlnaFilter * CUpnpDlnaFilter::NewLC(class MUpnpContentDirectoryDataFinder *, class CUpnpSecurityManager *)
+
--- a/upnpmediaserver/contentdirectoryservice/EABI/AVContentDirectoryU.DEF	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/EABI/AVContentDirectoryU.DEF	Mon Nov 01 12:37:49 2010 +0200
@@ -1,89 +1,93 @@
-EXPORTS
-	_ZN21CUpnpContentDirectory11SendActionLEP11CUpnpAction14TUpnpErrorCode @ 1 NONAME
-	_ZN21CUpnpContentDirectory12SendMessageLEP16CUpnpHttpMessage @ 2 NONAME
-	_ZN21CUpnpContentDirectory15NewTransactionLERK6TDesC8S2_RK9TInetAddrRP26CUpnpHttpServerTransaction @ 3 NONAME
-	_ZN21CUpnpContentDirectory25UnknownHttpEventReceivedLER16CUpnpHttpMessage @ 4 NONAME
-	_ZN21CUpnpContentDirectory26HttpTransferEventReceivedLER16CUpnpHttpMessage @ 5 NONAME
-	_ZN21CUpnpContentDirectory9SetSenderEP14MUpnpCdsSender @ 6 NONAME
-	_ZN28CUpnpContentDirectoryService10GetAddressEv @ 7 NONAME
-	_ZN28CUpnpContentDirectoryService12GetItemListLEiP19CUpnpBrowseCriteriaPiP13CUpnpItemList @ 8 NONAME
-	_ZN28CUpnpContentDirectoryService12ShareObjectLEP11CUpnpObject @ 9 NONAME
-	_ZN28CUpnpContentDirectoryService12UnshareItemLEi @ 10 NONAME
-	_ZN28CUpnpContentDirectoryService14AddressChangeLEv @ 11 NONAME
-	_ZN28CUpnpContentDirectoryService14GetSharedItemLEi @ 12 NONAME
-	_ZN28CUpnpContentDirectoryService14ShareItemListLEP13CUpnpItemListPi @ 13 NONAME
-	_ZN28CUpnpContentDirectoryService15ShareReferenceLEP9CUpnpItem @ 14 NONAME
-	_ZN28CUpnpContentDirectoryService16UnshareItemListLER6RArrayIiEPi @ 15 NONAME
-	_ZN28CUpnpContentDirectoryService17GetContainerListLEiP19CUpnpBrowseCriteriaPiP18CUpnpContainerList @ 16 NONAME
-	_ZN28CUpnpContentDirectoryService17UnshareContainerLEi @ 17 NONAME
-	_ZN28CUpnpContentDirectoryService19GetContentDirectoryEv @ 18 NONAME
-	_ZN28CUpnpContentDirectoryService19GetSingleContainerLEi @ 19 NONAME
-	_ZN28CUpnpContentDirectoryService19ShareReferenceListLEP13CUpnpItemListPi @ 20 NONAME
-	_ZN28CUpnpContentDirectoryService21SetDownloadDirectoryLERK7TDesC16 @ 21 NONAME
-	_ZN28CUpnpContentDirectoryService22SetThumbnailDirectoryLERK7TDesC16 @ 22 NONAME
-	_ZN28CUpnpContentDirectoryService4NewLE15TUpnpCdSettings @ 23 NONAME
-	_ZN28CUpnpContentDirectoryService4NewLEv @ 24 NONAME
-	_ZN28CUpnpContentDirectoryService5NewLCE15TUpnpCdSettings @ 25 NONAME
-	_ZN28CUpnpContentDirectoryService5NewLCEv @ 26 NONAME
-	_ZTI14CUpnpCdsSender @ 27 NONAME ; #<TI>#
-	_ZTI14CUpnpTableBean @ 28 NONAME ; #<TI>#
-	_ZTI15CUpnpMapElement @ 29 NONAME ; #<TI>#
-	_ZTI15CUpnpMimeMapper @ 30 NONAME ; #<TI>#
-	_ZTI15CUpnpObjectBean @ 31 NONAME ; #<TI>#
-	_ZTI16CUpnpCdDbFactory @ 32 NONAME ; #<TI>#
-	_ZTI16CUpnpElementBean @ 33 NONAME ; #<TI>#
-	_ZTI17CUpnpFileTransfer @ 34 NONAME ; #<TI>#
-	_ZTI17CUpnpLocalStorage @ 35 NONAME ; #<TI>#
-	_ZTI17CUpnpStateHandler @ 36 NONAME ; #<TI>#
-	_ZTI17CUpnpTransferBase @ 37 NONAME ; #<TI>#
-	_ZTI18CUpnpAttributeBean @ 38 NONAME ; #<TI>#
-	_ZTI18CUpnpFilterElement @ 39 NONAME ; #<TI>#
-	_ZTI18CUpnpResourcesBean @ 40 NONAME ; #<TI>#
-	_ZTI19CUpnpElementFactory @ 41 NONAME ; #<TI>#
-	_ZTI20CUpnpMetadataStorage @ 42 NONAME ; #<TI>#
-	_ZTI20CUpnpTransferHandler @ 43 NONAME ; #<TI>#
-	_ZTI21CUpnpContentDirectory @ 44 NONAME ; #<TI>#
-	_ZTI21CUpnpTransferUploader @ 45 NONAME ; #<TI>#
-	_ZTI21CUpnpXmlContentFilter @ 46 NONAME ; #<TI>#
-	_ZTI22CUpnpAutoDestroyObject @ 47 NONAME ; #<TI>#
-	_ZTI23CUpnpContentDirectoryDb @ 48 NONAME ; #<TI>#
-	_ZTI23CUpnpTransferController @ 49 NONAME ; #<TI>#
-	_ZTI23CUpnpTransferDownloader @ 50 NONAME ; #<TI>#
-	_ZTI26CUpnpAutoDestroyObjectList @ 51 NONAME ; #<TI>#
-	_ZTI28CUpnpContentDirectoryService @ 52 NONAME ; #<TI>#
-	_ZTI29CUpnpHttpFileServeTransaction @ 53 NONAME ; #<TI>#
-	_ZTI30CUpnpFileTransferTimerObserver @ 54 NONAME ; #<TI>#
-	_ZTI31CUpnpHttpFileReceiveTransaction @ 55 NONAME ; #<TI>#
-	_ZTI8CUpnpMapI7HBufC16E @ 56 NONAME ; #<TI>#
-	_ZTV14CUpnpCdsSender @ 57 NONAME ; #<VT>#
-	_ZTV14CUpnpTableBean @ 58 NONAME ; #<VT>#
-	_ZTV15CUpnpMapElement @ 59 NONAME ; #<VT>#
-	_ZTV15CUpnpMimeMapper @ 60 NONAME ; #<VT>#
-	_ZTV15CUpnpObjectBean @ 61 NONAME ; #<VT>#
-	_ZTV16CUpnpCdDbFactory @ 62 NONAME ; #<VT>#
-	_ZTV16CUpnpElementBean @ 63 NONAME ; #<VT>#
-	_ZTV17CUpnpFileTransfer @ 64 NONAME ; #<VT>#
-	_ZTV17CUpnpLocalStorage @ 65 NONAME ; #<VT>#
-	_ZTV17CUpnpStateHandler @ 66 NONAME ; #<VT>#
-	_ZTV17CUpnpTransferBase @ 67 NONAME ; #<VT>#
-	_ZTV18CUpnpAttributeBean @ 68 NONAME ; #<VT>#
-	_ZTV18CUpnpFilterElement @ 69 NONAME ; #<VT>#
-	_ZTV18CUpnpResourcesBean @ 70 NONAME ; #<VT>#
-	_ZTV19CUpnpElementFactory @ 71 NONAME ; #<VT>#
-	_ZTV20CUpnpMetadataStorage @ 72 NONAME ; #<VT>#
-	_ZTV20CUpnpTransferHandler @ 73 NONAME ; #<VT>#
-	_ZTV21CUpnpContentDirectory @ 74 NONAME ; #<VT>#
-	_ZTV21CUpnpTransferUploader @ 75 NONAME ; #<VT>#
-	_ZTV21CUpnpXmlContentFilter @ 76 NONAME ; #<VT>#
-	_ZTV22CUpnpAutoDestroyObject @ 77 NONAME ; #<VT>#
-	_ZTV23CUpnpContentDirectoryDb @ 78 NONAME ; #<VT>#
-	_ZTV23CUpnpTransferController @ 79 NONAME ; #<VT>#
-	_ZTV23CUpnpTransferDownloader @ 80 NONAME ; #<VT>#
-	_ZTV26CUpnpAutoDestroyObjectList @ 81 NONAME ; #<VT>#
-	_ZTV28CUpnpContentDirectoryService @ 82 NONAME ; #<VT>#
-	_ZTV29CUpnpHttpFileServeTransaction @ 83 NONAME ; #<VT>#
-	_ZTV30CUpnpFileTransferTimerObserver @ 84 NONAME ; #<VT>#
-	_ZTV31CUpnpHttpFileReceiveTransaction @ 85 NONAME ; #<VT>#
-	_ZTV8CUpnpMapI7HBufC16E @ 86 NONAME ; #<VT>#
-	_ZThn144_N21CUpnpContentDirectory15NewTransactionLERK6TDesC8S2_RK9TInetAddrRP26CUpnpHttpServerTransaction @ 87 NONAME ; #<thunk>#
-
+EXPORTS
+	_ZN15CUpnpDlnaFilter15NewTransactionLERK6TDesC8S2_RK9TInetAddrRP26CUpnpHttpServerTransaction @ 1 NONAME
+	_ZN15CUpnpDlnaFilter4NewLEP31MUpnpContentDirectoryDataFinderP20CUpnpSecurityManager @ 2 NONAME
+	_ZN15CUpnpDlnaFilter5NewLCEP31MUpnpContentDirectoryDataFinderP20CUpnpSecurityManager @ 3 NONAME
+	_ZN21CUpnpContentDirectory11SendActionLEP11CUpnpAction14TUpnpErrorCode @ 4 NONAME
+	_ZN21CUpnpContentDirectory12SendMessageLEP16CUpnpHttpMessage @ 5 NONAME
+	_ZN21CUpnpContentDirectory15NewTransactionLERK6TDesC8S2_RK9TInetAddrRP26CUpnpHttpServerTransaction @ 6 NONAME
+	_ZN21CUpnpContentDirectory25UnknownHttpEventReceivedLER16CUpnpHttpMessage @ 7 NONAME
+	_ZN21CUpnpContentDirectory26HttpTransferEventReceivedLER16CUpnpHttpMessage @ 8 NONAME
+	_ZN21CUpnpContentDirectory9SetSenderEP14MUpnpCdsSender @ 9 NONAME
+	_ZN28CUpnpContentDirectoryService10GetAddressEv @ 10 NONAME
+	_ZN28CUpnpContentDirectoryService12GetItemListLEiP19CUpnpBrowseCriteriaPiP13CUpnpItemList @ 11 NONAME
+	_ZN28CUpnpContentDirectoryService12ShareObjectLEP11CUpnpObject @ 12 NONAME
+	_ZN28CUpnpContentDirectoryService12UnshareItemLEi @ 13 NONAME
+	_ZN28CUpnpContentDirectoryService14AddressChangeLEv @ 14 NONAME
+	_ZN28CUpnpContentDirectoryService14GetSharedItemLEi @ 15 NONAME
+	_ZN28CUpnpContentDirectoryService14ShareItemListLEP13CUpnpItemListPi @ 16 NONAME
+	_ZN28CUpnpContentDirectoryService15ShareReferenceLEP9CUpnpItem @ 17 NONAME
+	_ZN28CUpnpContentDirectoryService16UnshareItemListLER6RArrayIiEPi @ 18 NONAME
+	_ZN28CUpnpContentDirectoryService17GetContainerListLEiP19CUpnpBrowseCriteriaPiP18CUpnpContainerList @ 19 NONAME
+	_ZN28CUpnpContentDirectoryService17UnshareContainerLEi @ 20 NONAME
+	_ZN28CUpnpContentDirectoryService19GetContentDirectoryEv @ 21 NONAME
+	_ZN28CUpnpContentDirectoryService19GetSingleContainerLEi @ 22 NONAME
+	_ZN28CUpnpContentDirectoryService19ShareReferenceListLEP13CUpnpItemListPi @ 23 NONAME
+	_ZN28CUpnpContentDirectoryService21SetDownloadDirectoryLERK7TDesC16 @ 24 NONAME
+	_ZN28CUpnpContentDirectoryService22SetThumbnailDirectoryLERK7TDesC16 @ 25 NONAME
+	_ZN28CUpnpContentDirectoryService4NewLE15TUpnpCdSettings @ 26 NONAME
+	_ZN28CUpnpContentDirectoryService4NewLEv @ 27 NONAME
+	_ZN28CUpnpContentDirectoryService5NewLCE15TUpnpCdSettings @ 28 NONAME
+	_ZN28CUpnpContentDirectoryService5NewLCEv @ 29 NONAME
+	_ZTI14CUpnpCdsSender @ 30 NONAME ; #<TI>#
+	_ZTI14CUpnpTableBean @ 31 NONAME ; #<TI>#
+	_ZTI15CUpnpMapElement @ 32 NONAME ; #<TI>#
+	_ZTI15CUpnpMimeMapper @ 33 NONAME ; #<TI>#
+	_ZTI15CUpnpObjectBean @ 34 NONAME ; #<TI>#
+	_ZTI16CUpnpCdDbFactory @ 35 NONAME ; #<TI>#
+	_ZTI16CUpnpElementBean @ 36 NONAME ; #<TI>#
+	_ZTI17CUpnpFileTransfer @ 37 NONAME ; #<TI>#
+	_ZTI17CUpnpLocalStorage @ 38 NONAME ; #<TI>#
+	_ZTI17CUpnpStateHandler @ 39 NONAME ; #<TI>#
+	_ZTI17CUpnpTransferBase @ 40 NONAME ; #<TI>#
+	_ZTI18CUpnpAttributeBean @ 41 NONAME ; #<TI>#
+	_ZTI18CUpnpFilterElement @ 42 NONAME ; #<TI>#
+	_ZTI18CUpnpResourcesBean @ 43 NONAME ; #<TI>#
+	_ZTI19CUpnpElementFactory @ 44 NONAME ; #<TI>#
+	_ZTI20CUpnpMetadataStorage @ 45 NONAME ; #<TI>#
+	_ZTI20CUpnpTransferHandler @ 46 NONAME ; #<TI>#
+	_ZTI21CUpnpContentDirectory @ 47 NONAME ; #<TI>#
+	_ZTI21CUpnpTransferUploader @ 48 NONAME ; #<TI>#
+	_ZTI21CUpnpXmlContentFilter @ 49 NONAME ; #<TI>#
+	_ZTI22CUpnpAutoDestroyObject @ 50 NONAME ; #<TI>#
+	_ZTI23CUpnpContentDirectoryDb @ 51 NONAME ; #<TI>#
+	_ZTI23CUpnpTransferController @ 52 NONAME ; #<TI>#
+	_ZTI23CUpnpTransferDownloader @ 53 NONAME ; #<TI>#
+	_ZTI26CUpnpAutoDestroyObjectList @ 54 NONAME ; #<TI>#
+	_ZTI28CUpnpContentDirectoryService @ 55 NONAME ; #<TI>#
+	_ZTI29CUpnpHttpDataServeTransaction @ 56 NONAME ; #<TI>#
+	_ZTI30CUpnpFileTransferTimerObserver @ 57 NONAME ; #<TI>#
+	_ZTI31CUpnpHttpFileReceiveTransaction @ 58 NONAME ; #<TI>#
+	_ZTI8CUpnpMapI7HBufC16E @ 59 NONAME ; #<TI>#
+	_ZTV14CUpnpCdsSender @ 60 NONAME ; #<VT>#
+	_ZTV14CUpnpTableBean @ 61 NONAME ; #<VT>#
+	_ZTV15CUpnpMapElement @ 62 NONAME ; #<VT>#
+	_ZTV15CUpnpMimeMapper @ 63 NONAME ; #<VT>#
+	_ZTV15CUpnpObjectBean @ 64 NONAME ; #<VT>#
+	_ZTV16CUpnpCdDbFactory @ 65 NONAME ; #<VT>#
+	_ZTV16CUpnpElementBean @ 66 NONAME ; #<VT>#
+	_ZTV17CUpnpFileTransfer @ 67 NONAME ; #<VT>#
+	_ZTV17CUpnpLocalStorage @ 68 NONAME ; #<VT>#
+	_ZTV17CUpnpStateHandler @ 69 NONAME ; #<VT>#
+	_ZTV17CUpnpTransferBase @ 70 NONAME ; #<VT>#
+	_ZTV18CUpnpAttributeBean @ 71 NONAME ; #<VT>#
+	_ZTV18CUpnpFilterElement @ 72 NONAME ; #<VT>#
+	_ZTV18CUpnpResourcesBean @ 73 NONAME ; #<VT>#
+	_ZTV19CUpnpElementFactory @ 74 NONAME ; #<VT>#
+	_ZTV20CUpnpMetadataStorage @ 75 NONAME ; #<VT>#
+	_ZTV20CUpnpTransferHandler @ 76 NONAME ; #<VT>#
+	_ZTV21CUpnpContentDirectory @ 77 NONAME ; #<VT>#
+	_ZTV21CUpnpTransferUploader @ 78 NONAME ; #<VT>#
+	_ZTV21CUpnpXmlContentFilter @ 79 NONAME ; #<VT>#
+	_ZTV22CUpnpAutoDestroyObject @ 80 NONAME ; #<VT>#
+	_ZTV23CUpnpContentDirectoryDb @ 81 NONAME ; #<VT>#
+	_ZTV23CUpnpTransferController @ 82 NONAME ; #<VT>#
+	_ZTV23CUpnpTransferDownloader @ 83 NONAME ; #<VT>#
+	_ZTV26CUpnpAutoDestroyObjectList @ 84 NONAME ; #<VT>#
+	_ZTV28CUpnpContentDirectoryService @ 85 NONAME ; #<VT>#
+	_ZTV29CUpnpHttpDataServeTransaction @ 86 NONAME ; #<VT>#
+	_ZTV30CUpnpFileTransferTimerObserver @ 87 NONAME ; #<VT>#
+	_ZTV31CUpnpHttpFileReceiveTransaction @ 88 NONAME ; #<VT>#
+	_ZTV8CUpnpMapI7HBufC16E @ 89 NONAME ; #<VT>#
+	_ZThn144_N21CUpnpContentDirectory15NewTransactionLERK6TDesC8S2_RK9TInetAddrRP26CUpnpHttpServerTransaction @ 90 NONAME ; #<thunk>#
+	_ZThn4_N15CUpnpDlnaFilter15NewTransactionLERK6TDesC8S2_RK9TInetAddrRP26CUpnpHttpServerTransaction @ 91 NONAME ; #<thunk>#
+
--- a/upnpmediaserver/contentdirectoryservice/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,29 +1,31 @@
-/** @file
-* Copyright (c) 2005 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:  Build info for the Content Directory Service component
-*
-*/
-
-
-PRJ_EXPORTS
-
-../inc/upnpcontentdirectoryservice.h |../../inc/upnpcontentdirectoryservice.h
-../inc/upnpcontentdirectoryeventobserver.h |../../inc/upnpcontentdirectoryeventobserver.h
-../inc/upnpcontentdirectoryglobals.h |../../inc/upnpcontentdirectoryglobals.h
-../inc/upnpcdsettings.h |../../inc/upnpcdsettings.h 
-
-PRJ_MMPFILES
-contentdirectoryservice.mmp
-
-//end of file
+/** @file
+* Copyright (c) 2005 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:  Build info for the Content Directory Service component
+*
+*/
+
+
+PRJ_EXPORTS
+
+../inc/upnpcontentdirectoryservice.h        |../../inc/upnpcontentdirectoryservice.h
+../inc/upnpcontentdirectoryeventobserver.h  |../../inc/upnpcontentdirectoryeventobserver.h
+../inc/upnpcontentdirectoryglobals.h        |../../inc/upnpcontentdirectoryglobals.h
+../inc/upnpcdsettings.h                     |../../inc/upnpcdsettings.h 
+../inc/dlna/upnpdlnafilter.h                |../../../inc/upnpdlnafilter.h
+../inc/upnpcontentdirectorydatafinder.h     |../../../inc/upnpcontentdirectorydatafinder.h		
+
+PRJ_MMPFILES
+contentdirectoryservice.mmp
+
+//end of file
--- a/upnpmediaserver/contentdirectoryservice/group/contentdirectoryservice.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/group/contentdirectoryservice.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,116 +1,116 @@
-/** @file
-* Copyright (c) 2002-2004 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: 
-*     This is the project specification file for Upnp.
-*
-*/
-
-#include <platform_paths.hrh>
-#include <data_caging_paths.hrh>
-
-TARGETTYPE      DLL
-
-TARGET          avcontentdirectory.dll
-UID             0x1000008d 0x10204159
-
-
-VERSION 10.1
-paged
-
-CAPABILITY      CAP_GENERAL_DLL
-VENDORID        VID_DEFAULT
-
-SOURCEPATH      ../src
-SOURCE          upnpcontentdirectory.cpp
-SOURCE          upnpelementfactory.cpp
-SOURCE          upnpcontainerupdateid.cpp
-SOURCE          upnpcontentdirectorydb.cpp
-SOURCE          upnpfiletransfer.cpp
-SOURCE          upnpelementbean.cpp
-SOURCE          upnpattributebean.cpp
-SOURCE          upnpobjectbean.cpp
-SOURCE          upnpfilterelement.cpp
-SOURCE          upnpthumbnailcreator.cpp
-SOURCE          upnptablebean.cpp
-SOURCE          upnperror.cpp
-SOURCE          upnpresourcesbean.cpp
-SOURCE          upnpcdutils.cpp
-SOURCE          upnpcddbfactory.cpp
-SOURCE          upnpcontentdirectoryservice.cpp
-SOURCE          upnpmetadatastorage.cpp
-SOURCE          upnplocalstorage.cpp
-SOURCE          upnpfiletransfertimerobserver.cpp
-SOURCE          upnpautodestroyobjectlist.cpp
-SOURCE          upnpautodestroyobject.cpp
-SOURCE          upnpsender.cpp
-SOURCE          upnpmapbase.cpp
-SOURCE          upnpmapelement.cpp
-SOURCE          upnpxmlcontentfilter.cpp
-SOURCE          upnpstatehandler.cpp
-SOURCE          upnpmimemapper.cpp
-SOURCE          upnpmspathutility.cpp
-
-SOURCE          upnptransferbase.cpp
-SOURCE          upnptransferdownloader.cpp
-SOURCE          upnptransferuploader.cpp
-
-SOURCE          upnptransfercontroller.cpp
-SOURCE          upnptransferhandler.cpp
-
-SOURCE          dlna/upnpdlnafilter.cpp 
-SOURCE          dlna/upnphttpfileservetransaction.cpp
-SOURCE          dlna/upnphttpfilereceivetransaction.cpp
-SOURCE          dlna/upnpdlnafilterheaders.cpp
-
-
-MW_LAYER_SYSTEMINCLUDE
-
-USERINCLUDE     ../inc
-USERINCLUDE     ../../inc
-USERINCLUDE     ../../../inc
-USERINCLUDE     ../inc/dlna
-
-//central repository
-LIBRARY         centralrepository.lib
-LIBRARY         upnpipserversutils.lib
-LIBRARY         upnpserviceframework.lib
-LIBRARY         upnpavobjects.lib
-LIBRARY         httptransfer.lib
-LIBRARY         dlnawebserver.lib
-LIBRARY         avmediaserverclient.lib
-LIBRARY         xmlenginedom.lib
-LIBRARY         xmlengineutils.lib
-LIBRARY         euser.lib
-LIBRARY         efsrv.lib
-LIBRARY         insock.lib 
-LIBRARY         esock.lib 
-LIBRARY         bafl.lib
-LIBRARY         estor.lib   
-LIBRARY         edbms.lib 
-LIBRARY         ecom.lib
-LIBRARY         sysutil.lib
-LIBRARY         PlatformEnv.lib
-LIBRARY         estlib.lib 
-LIBRARY         inetprotutil.lib
-LIBRARY         imageconversion.lib
-LIBRARY         bitmaptransforms.lib
-LIBRARY         fbscli.lib
-LIBRARY         charconv.lib
-LIBRARY         cafutils.lib
-LIBRARY         caf.lib
-
-DEBUGLIBRARY    flogger.lib
-DEFFILE         AVContentDirectory
-
-// End of file
+/** @file
+* Copyright (c) 2002-2004 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: 
+*     This is the project specification file for Upnp.
+*
+*/
+
+#include <platform_paths.hrh>
+#include <data_caging_paths.hrh>
+
+TARGETTYPE      DLL
+
+TARGET          avcontentdirectory.dll
+UID             0x1000008d 0x10204159
+
+
+VERSION 10.1
+paged
+
+CAPABILITY      CAP_GENERAL_DLL
+VENDORID        VID_DEFAULT
+
+SOURCEPATH      ../src
+SOURCE          upnpcontentdirectory.cpp
+SOURCE          upnpelementfactory.cpp
+SOURCE          upnpcontainerupdateid.cpp
+SOURCE          upnpcontentdirectorydb.cpp
+SOURCE          upnpfiletransfer.cpp
+SOURCE          upnpelementbean.cpp
+SOURCE          upnpattributebean.cpp
+SOURCE          upnpobjectbean.cpp
+SOURCE          upnpfilterelement.cpp
+SOURCE          upnpthumbnailcreator.cpp
+SOURCE          upnptablebean.cpp
+SOURCE          upnperror.cpp
+SOURCE          upnpresourcesbean.cpp
+SOURCE          upnpcdutils.cpp
+SOURCE          upnpcddbfactory.cpp
+SOURCE          upnpcontentdirectoryservice.cpp
+SOURCE          upnpmetadatastorage.cpp
+SOURCE          upnplocalstorage.cpp
+SOURCE          upnpfiletransfertimerobserver.cpp
+SOURCE          upnpautodestroyobjectlist.cpp
+SOURCE          upnpautodestroyobject.cpp
+SOURCE          upnpsender.cpp
+SOURCE          upnpmapbase.cpp
+SOURCE          upnpmapelement.cpp
+SOURCE          upnpxmlcontentfilter.cpp
+SOURCE          upnpstatehandler.cpp
+SOURCE          upnpmimemapper.cpp
+SOURCE          upnpmspathutility.cpp
+
+SOURCE          upnptransferbase.cpp
+SOURCE          upnptransferdownloader.cpp
+SOURCE          upnptransferuploader.cpp
+
+SOURCE          upnptransfercontroller.cpp
+SOURCE          upnptransferhandler.cpp
+
+SOURCE          dlna/upnpdlnafilter.cpp 
+SOURCE          dlna/upnphttpdataservetransaction.cpp
+SOURCE          dlna/upnphttpfilereceivetransaction.cpp
+SOURCE          dlna/upnpdlnafilterheaders.cpp
+
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE     ../inc
+USERINCLUDE     ../../inc
+USERINCLUDE     ../../../inc
+USERINCLUDE     ../inc/dlna
+
+//central repository
+LIBRARY         centralrepository.lib
+LIBRARY         upnpipserversutils.lib
+LIBRARY         upnpserviceframework.lib
+LIBRARY         upnpavobjects.lib
+LIBRARY         httptransfer.lib
+LIBRARY         dlnawebserver.lib
+LIBRARY         avmediaserverclient.lib
+LIBRARY         xmlenginedom.lib
+LIBRARY         xmlengineutils.lib
+LIBRARY         euser.lib
+LIBRARY         efsrv.lib
+LIBRARY         insock.lib 
+LIBRARY         esock.lib 
+LIBRARY         bafl.lib
+LIBRARY         estor.lib   
+LIBRARY         edbms.lib 
+LIBRARY         ecom.lib
+LIBRARY         sysutil.lib
+LIBRARY         PlatformEnv.lib
+LIBRARY         estlib.lib 
+LIBRARY         inetprotutil.lib
+LIBRARY         imageconversion.lib
+LIBRARY         bitmaptransforms.lib
+LIBRARY         fbscli.lib
+LIBRARY         charconv.lib
+LIBRARY         cafutils.lib
+LIBRARY         caf.lib
+
+DEBUGLIBRARY    flogger.lib
+DEFFILE         AVContentDirectory
+
+// End of file
--- a/upnpmediaserver/contentdirectoryservice/inc/dlna/upnpdlnafilter.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/inc/dlna/upnpdlnafilter.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,233 +1,325 @@
-/** @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:  CUpnpDlnaFilter declaration.
- *
- */
-
-#ifndef UPNPDLNAFILTER_H
-#define UPNPDLNAFILTER_H
-
-// INCLUDES
-#include <e32std.h>
-#include <e32base.h>
-#include <f32file.h> 
-#include "upnphttpservertransactioncreator.h"
-
-class MUpnpContentDirectoryDataFinder;
-class CUpnpHttpMessage;
-class CUpnpDlnaProtocolInfo;
-class CUpnpSecurityManager;
-class CUpnpHttpFileServeTransaction;
-class CUpnpHttpFileReceiveTransaction;
-class CUpnpDlnaFilterHeaders;
-class TUpnpDlnaCorelation;
-
-// CLASS DECLARATION
-
-/**
- *  CUpnpDlnaFilter
- * 
- */
-NONSHARABLE_CLASS( CUpnpDlnaFilter ) : public CBase,
-        public MUpnpHttpServerTransactionCreator
-    {
-public:
-    // Public Constructors and destructor
-
-    /**
-     * Destructor.
-     */
-    ~CUpnpDlnaFilter();
-
-    /**
-     * Two-phased constructor.
-     */
-    static CUpnpDlnaFilter* NewL( MUpnpContentDirectoryDataFinder* aFinder,
-        CUpnpSecurityManager* aSecurityManager );
-
-    /**
-     * Two-phased constructor.
-     */
-    static CUpnpDlnaFilter* NewLC( MUpnpContentDirectoryDataFinder* aFinder,
-        CUpnpSecurityManager* aSecurityManager );
-
-    //from MUpnpHttpServerTransactionCreator
-    virtual void NewTransactionL(
-        const TDesC8& aMethod, const TDesC8& aUri, 
-        const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans );
-
-    //from MUpnpHttpServerTransactionCreator
-
-    /**
-     * Checks correctness of path to, requested in HTTP message, file and 
-     *  changes its format to be compliant with Symbian's file system.
-     * @since Series60 2.6
-     * @param aMsg HTTP message containing file request.
-     * @param aPathWithNewMethod reference which is filled with formated path 
-     *  to requested file.
-     **/
-    void FormatPathL( CUpnpHttpFileServeTransaction *aTransaction, TDes &aPath );
-
-    /**
-     * Add appropriate directives to http header according to DLNA specification
-     * @param aTransaction http transaction
-     * @return KErrNone header prepared successfully, otherwise -EHttpNotFound
-     *         If DLNA correlations are wrong error from then it returns an error
-     */
-    TInt PrepareHeaderL( CUpnpHttpFileServeTransaction &aTransaction );
-
-    /**
-     * Method checks DLNA transferMode for POST messages.
-     * @since Series60 2.6
-     * @param aPostMessage - incoming POST message with upload to be saved in file.
-     * @return ETrue if POST can be accepted.
-     **/
-    TInt CheckDLNAPostCorrelationsL(CUpnpHttpFileReceiveTransaction& aTransaction);
-
-    /**
-     * Determines download path basing on incomming POST message and media path got
-     *  from server. Result is saved in iInFilename. 
-     *  If file should not be saved, flag iSaveToFile will be set to EFalse.
-     * @since Series60 2.6
-     * @param aPostMessage - incoming POST message with upload to be saved in file.
-     * @return download path or NULL in case of error
-     */
-    HBufC* DetermineDownloadPathL(CUpnpHttpFileReceiveTransaction& aTransaction);
-
-    //security manager getter
-    CUpnpSecurityManager* SecurityManager();
-    
-    //file server session getter        
-    RFs& FileSession();
-
-    /**
-     * Check if resource is accessible 
-     * @param aFileName data source file name
-     * @param aSender sender
-     * @return KErrNone if resource is accessible, otherwise -EHttpNotFound
-     */
-    TInt AuthorizeRequestL( const TDesC& aFileName, const TInetAddr& aSender );
-
-public:
-    // protected
-    // Private Constructors
-
-    /**
-     * Constructor for performing 1st stage construction
-     */
-    CUpnpDlnaFilter( MUpnpContentDirectoryDataFinder* aFinder,
-        CUpnpSecurityManager* aSecurityManager );
-
-    /**
-     * EPOC default constructor for performing 2nd stage construction
-     */
-    void ConstructL();
-
-private:
-
-    /**
-     * Find protocolInfo by contentUri (Not by importUri) and extract 3rd field,
-     * using ContentDirectory.
-     * @param aFullContentUri uri to be searched in database
-     *       (full value of resource with IP:port prefix).
-     * @return a3rdhField 3rdhField from protocolInfo (if it is DLNA compatible) which is
-     *       related to founded resource. Ownership is transfered to the caller.
-     */
-    HBufC8* CUpnpDlnaFilter::ThirdFieldFromCdL( const TDesC8& aContentUri );
-
-    /**
-     * Gets name of file with content for given object's id.
-     * @param aObjectId id of the ContentDirecotry object holding the content
-     * @param aFileName pointer to buffer in which the name of the file will be returned.
-     *       Buffer for aFileName has to allocated first.
-     */
-    void GetMediaFileNameL( TInt aObjectId, TPtr& aFileName );
-
-    /**
-     * Find a folder shared from DB (ContentDirectory).
-     * @param aUrlPath Name of URL path that needs to be found and converted
-     * to aFolderPath
-     * @param aFileName Name of shared file (can be null if just folder is looking for).
-     * @param aSystemPath Name of shared folder.
-     * @return KErrNone or another of the system error codes.
-     */
-    TInt FindSharedFolderDBL(const TDesC8& aUrlPath, const TDesC8& aFileName,
-            HBufC8*& aSystemPath);
-
-    /**
-     * Checks if specified URI exists in database and returns object id for
-     *  given URI or KErrNotFound if URI is no registered in database.
-     * @param aImportUri uri to be searched in databse.
-     * @return objId if successful or KErrnone if object wasn't found.
-     */
-    TInt CheckImportUriL( TDesC8& aImportUri );
-
-    /**
-     * Checks DLNA correlations for given message.
-     * @since Series60 2.6
-     * @param aMessage message for which correlations check will be performed 
-     *  exists for given message.
-     * @return KErrNone if no HTTPerror problem occurs	 
-     **/
-    TInt CheckDLNACorrelationsL( CUpnpHttpFileServeTransaction& aTransaction );
-
-
-    /**
-     * Method returns content type of a resource
-     * @since Series60 3.2
-     * @param aMessage, aMime, aFilename
-     * @return KErrNone if mime type retrieved with no errors
-     **/
-    TInt GetContentTypeL( CUpnpHttpFileServeTransaction &aTransaction, HBufC8*& aMime,
-        const TDesC16& aFilename );
- 
-
-    CUpnpDlnaProtocolInfo* ProtocolInfoL( const TDesC8& aContentUri );
-
-    void AddHeaderIfNotEmptyL( const TDesC8& aHeaderName, 
-        CUpnpHttpFileServeTransaction& aTransaction );
-    
-    
-    HBufC* MakeFileNameUniqueL( const TDesC& aFilename, RFs& aFs );
-
-    HBufC* PreparePostfixToMakeFileUniqueL( const TDesC& aFilename, RFs& aFs );
-    
-    HBufC* PrepareBaseFileNameL( const TDesC& aFilename, RFs& aFs );
-    
-    TInt CheckCorelationL( CUpnpHttpFileServeTransaction& aTransaction,
-                            TUpnpDlnaCorelation& aDlnaCorelation );
-                            
-    TInt CheckTransferModeL( CUpnpHttpFileServeTransaction& aTransaction,
-                             TUpnpDlnaCorelation& aDlnaCorelation );
-                             
-    TInt AppendCorelationHeadersL( CUpnpHttpFileServeTransaction& aTransaction,
-                             TUpnpDlnaCorelation& aDlnaCorelation, TDesC8& aTransferMode  );
-	
-protected:	
-	
-    // Pointer to ContentDirectoryDataFinder implementation.
-    // Not owned.
-    MUpnpContentDirectoryDataFinder* iCdDataFinder;
-    
-    CUpnpSecurityManager* iSecurityManager;
-    
-    // protocol info for dlna corelation
-    CUpnpDlnaProtocolInfo* iProtocolInfo;
-
-    RFs iFs;
-    
-    };
-
-#endif // UPNPDLNAFILTER_H
-// End Of File
+/** @file
+ * Copyright (c) 2005-2009 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:  CUpnpDlnaFilter declaration.
+ *
+ */
+
+#ifndef UPNPDLNAFILTER_H
+#define UPNPDLNAFILTER_H
+
+// INCLUDES
+#include <e32std.h>
+#include <e32base.h>
+#include <f32file.h> 
+#include "upnphttpservertransactioncreator.h"
+
+class MUpnpContentDirectoryDataFinder;
+class CUpnpDlnaProtocolInfo;
+class CUpnpSecurityManager;
+class CUpnpHttpDataServeTransaction;
+class CUpnpHttpFileReceiveTransaction;
+class TUpnpDlnaCorelation;
+
+// CLASS DECLARATION
+
+/**
+ *  CUpnpDlnaFilter
+ * 
+ */
+NONSHARABLE_CLASS( CUpnpDlnaFilter ) : public CBase,
+        public MUpnpHttpServerTransactionCreator
+    {
+public:
+    // Public Constructors and destructor
+
+	/**
+	 * static constructor.
+	 * 
+	 * @param aFinder, MUpnpContentDirectoryDataFinder
+	 * @param aSecurityManager, instance of CUpnpSecurityManager
+	 */
+	IMPORT_C  static CUpnpDlnaFilter* NewL( 
+		MUpnpContentDirectoryDataFinder* aFinder,
+		CUpnpSecurityManager* aSecurityManager );
+	
+	/**
+	 * see MUpnpHttpServerTransactionCreator.
+	 */
+	IMPORT_C void NewTransactionL(
+		const TDesC8& aMethod, const TDesC8& aUri, 
+		const TInetAddr& aSender, 
+		CUpnpHttpServerTransaction*& aResultTrans );
+	
+    /**
+     * static constructor.
+     */
+    IMPORT_C static CUpnpDlnaFilter* NewLC( 
+    	MUpnpContentDirectoryDataFinder* aFinder,
+        CUpnpSecurityManager* aSecurityManager );
+	    
+    /**
+     * Destructor.
+     */
+    ~CUpnpDlnaFilter();
+    
+
+    //from MUpnpHttpServerTransactionCreator
+
+    /**
+     * Checks correctness of path to, requested in HTTP message, file and 
+     *  changes its format to be compliant with Symbian's file system.
+     * @since Series60 2.6
+     * 
+     * @param aTransaction http transaction
+     * @param aPath reference which is filled with formated path 
+     *  to requested file.
+     **/
+    void FormatPathL( CUpnpHttpDataServeTransaction *aTransaction, 
+    		TDes &aPath );
+
+    /**
+     * Add appropriate directives to http header according to DLNA 
+     * specification
+     * 
+     * @param aTransaction http transaction
+     * @return KErrNone header prepared successfully,otherwise-EHttpNotFound
+     * If DLNA correlations are wrong error from then it returns an error
+     */
+    TInt PrepareHeaderL( CUpnpHttpDataServeTransaction &aTransaction );
+
+    /**
+     * Method checks DLNA transferMode for POST messages.
+     * @since Series60 2.6
+     * 
+     * @param aTransaction - incoming POST message with upload to be saved 
+     * in file.
+     * @return ETrue if POST can be accepted.
+     **/
+    TInt CheckDLNAPostCorrelationsL(
+    		CUpnpHttpFileReceiveTransaction& aTransaction);
+
+    /**
+     * Determines download path basing on incomming POST message and media 
+     * path got from server. Result is saved in iInFilename. 
+     *  If file should not be saved, flag iSaveToFile will be set to EFalse.
+     * @since Series60 2.6
+     * 
+     * @param aTransaction - incoming POST message with upload to be saved 
+     * in file.
+     * @return download path or NULL in case of error
+     */
+    HBufC* DetermineDownloadPathL(
+    		CUpnpHttpFileReceiveTransaction& aTransaction);
+
+    /**
+     * security manager getter
+     */
+    CUpnpSecurityManager* SecurityManager();
+    
+    /**
+     * file server session getter
+     */
+    RFs& FileSession();
+
+    /**
+     * Check if resource is accessible 
+     * 
+     * @param aFileName data source file name
+     * @param aSender sender
+     * @return KErrNone if resource is accessible, otherwise-EHttpNotFound
+     */
+    TInt AuthorizeRequestL( const TDesC& aFileName, 
+    		const TInetAddr& aSender );
+
+private:
+    // protected
+    // Private Constructors
+
+    /**
+     * Constructor for performing 1st stage construction
+     */
+	CUpnpDlnaFilter( MUpnpContentDirectoryDataFinder* aFinder,
+        CUpnpSecurityManager* aSecurityManager );
+
+    /**
+     * EPOC default constructor for performing 2nd stage construction
+     */
+    void ConstructL();
+
+private:
+
+    /**
+     * Find protocolInfo by contentUri (Not by importUri) and extract 3rd 
+     * field, using ContentDirectory.
+     * 
+     * @param aFullContentUri uri to be searched in database
+     *       (full value of resource with IP:port prefix).
+     * @return a3rdhField 3rdhField from protocolInfo (if it is DLNA 
+     * compatible) which is related to founded resource. 
+     * Ownership is transfered to the caller.
+     */
+    HBufC8* CUpnpDlnaFilter::ThirdFieldFromCdL( const TDesC8& aContentUri );
+
+    /**
+     * Gets name of file with content for given object's id.
+     * 
+     * @param aObjectId id of the ContentDirecotry object holding the content
+     * @param aFileName pointer to buffer in which the name of the file will 
+     * be returned. Buffer for aFileName has to allocated first.
+     */
+    void GetMediaFileNameL( TInt aObjectId, TPtr& aFileName );
+
+    /**
+     * Find a folder shared from DB (ContentDirectory).
+     * 
+     * @param aUrlPath Name of URL path that needs to be found and converted
+     * to aFolderPath
+     * @param aFileName Name of shared file (can be null if just folder is 
+     * looking for).
+     * @param aSystemPath Name of shared folder.
+     * @return KErrNone or another of the system error codes.
+     */
+    TInt FindSharedFolderDBL(const TDesC8& aUrlPath, const TDesC8& aFileName,
+            HBufC8*& aSystemPath);
+
+    /**
+     * Checks if specified URI exists in database and returns object id for
+     *  given URI or KErrNotFound if URI is no registered in database.
+     * @param aImportUri uri to be searched in databse.
+     * @return objId if successful or KErrnone if object wasn't found.
+     */
+    TInt CheckImportUriL( TDesC8& aImportUri );
+
+    /**
+     * Checks DLNA correlations for given message.
+     * 
+     * @@param aTransaction http transaction.
+     * @return KErrNone if no HTTPerror problem occurs	 
+     **/
+    TInt CheckDLNACorrelationsL( 
+    		CUpnpHttpDataServeTransaction& aTransaction );
+
+
+    /**
+     * Method returns content type of a resource
+     * 
+     * @param aTransaction http transaction
+     * @param aMime, content mimetype
+     * @param aFilename , file name
+     * @return KErrNone if mime type retrieved with no errors
+     **/
+    TInt GetContentTypeL( CUpnpHttpDataServeTransaction &aTransaction, 
+    	HBufC8*& aMime,
+        const TDesC16& aFilename );
+ 
+    /**
+      * Method returns content protocol info
+      * 
+      * @param aContentUri, content uri 
+      * @return upnpdlnaprotocolinfo of the content.
+      **/
+    CUpnpDlnaProtocolInfo* ProtocolInfoL( const TDesC8& aContentUri );
+
+    /**
+      * Method adds header
+      * 
+      * @param aHeaderName, header name
+      * @param aTransaction http transaction
+      **/
+    void AddHeaderIfNotEmptyL( const TDesC8& aHeaderName, 
+        CUpnpHttpDataServeTransaction& aTransaction );
+    
+    /**
+      * Method returns unique filename
+      * 
+      * @param aFilename , file name
+      * @param aFs , session to fileserver.
+      * @return unique filename.ownership transferred
+      **/    
+    HBufC* MakeFileNameUniqueL( const TDesC& aFilename, RFs& aFs );
+
+    /**
+      * Method returns postfix string to make filename unique
+      * 
+      * @param aFilename , file name
+      * @param aFs , session to fileserver.
+      * @returns postfix string.ownership transferred
+      **/
+    HBufC* PreparePostfixToMakeFileUniqueL( const TDesC& aFilename, 
+    		RFs& aFs );
+
+    /**
+      * Method returns filename
+      * 
+      * @param aFilename , file name
+      * @param aFs , session to fileserver.
+      * @returns filename string. ownership transferred
+      **/
+    HBufC* PrepareBaseFileNameL( const TDesC& aFilename, RFs& aFs );
+
+    /**
+      * Method verifies dlna correlation 
+      * 
+      * @param aTransaction http transaction
+      * @returns dlna specific error codes 
+      **/
+    TInt CheckCorelationL( CUpnpHttpDataServeTransaction& aTransaction,
+                            TUpnpDlnaCorelation& aDlnaCorelation );
+    
+    /**
+      * Method verifies transfer modes
+      * 
+      * @param aTransaction http transaction
+      * @returns dlna specific error codes
+      **/                            
+    TInt CheckTransferModeL( CUpnpHttpDataServeTransaction& aTransaction,
+                             TUpnpDlnaCorelation& aDlnaCorelation );
+                             
+    /**
+      * Method adds correlation headers
+      * 
+      * @param aTransaction http transaction
+      * @param aDlnaCorelation, dlna correlation structure
+      * @return KErrNone if successful
+      **/
+    TInt AppendCorelationHeadersL( 
+    		CUpnpHttpDataServeTransaction& aTransaction,
+            TUpnpDlnaCorelation& aDlnaCorelation, TDesC8& aTransferMode  );
+    
+    /**
+      * Method returns decode content uri.
+	  *
+      * @param contentURI, content uri
+      * @return decoded content uri string 
+      * ownership transferred.
+      **/
+    HBufC8* DecodeContentUriLC( const TPtrC8& contentURI);
+	
+protected:	
+	
+    // Pointer to ContentDirectoryDataFinder implementation.
+    // Not owned.
+    MUpnpContentDirectoryDataFinder* iCdDataFinder;
+    
+    CUpnpSecurityManager* iSecurityManager;
+    
+    // protocol info for dlna corelation
+    CUpnpDlnaProtocolInfo* iProtocolInfo;
+
+    RFs iFs;
+    
+    };
+
+#endif // UPNPDLNAFILTER_H
+// End Of File
--- a/upnpmediaserver/contentdirectoryservice/inc/upnpcdutils.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/inc/upnpcdutils.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,261 +1,265 @@
-/** @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:  ContentDirectory utils,
-*
-*/
-
-
-
-#ifndef CDUTILS_H
-#define CDUTILS_H
-
-//  INCLUDES
-#include <xml/dom/xmlengdom.h>
-#include <e32base.h>
-
-
-// CLASS DECLARATION
-
-/**
-*  Set of utils functions.
-*
-*  @lib AVContentDirectory.lib
-*  @since Series60 3.1
-*/
-class UpnpCdUtils
-{
- public:
- 
-    static void ValidateFilePath(TDes8& aPath);
-    static void ValidateFilePath(TDes& aPath);
-    static void ValidateSrcUriL(TDesC8& aPath,TDesC8& aIp);
-    /**
-    * Removes white spaces (and '\r \n \t and space') from the given descriptor 
-    * @since Series S60 3.0
-    * @param aString descriptor to be processed
-    */
-    static void RemoveWhiteSpacesL(TDes8& aString);
-
-    /**
-    * Checking if there are white spaces(and '\r \n \t and space' ) in the given descriptor
-    * @since Series S60 3.1
-    * @param aString 
-    * @return boolean
-    */
-    static TBool IsWhiteString(const TDesC8& aString);
-    
-    /**
-    * Gets element
-    * @since Series S60 3.1
-    * @param aFragment 
-    * @return TXmlEngElement
-    */      
-    static TXmlEngElement GetObjectElementL(RXmlEngDocument& aFragment);
-    
-    /**
-    * Checks if Ref id value exists
-    * @since Series S60 5.0 HN
-    * @param aFragment 
-    * @return TBool
-    */     
-    static TBool HasRefIdL( RXmlEngDocument& aFragment );
-    
-    /**
-    * Encodes Xml 
-    * @since Series S60 3.1
-    * @param aString
-    * @return descriptor pointer
-    */
-    static HBufC8* EncodeXmlStringL(const TDesC8& aString);
-    
-     
-   	static HBufC* Des8ToDesL(const TDesC8& aString);
-    
-    /**
-    * Conversion from TDes8 to TDes16
-    * @since Series S60 3.1
-    * @param aString
-    * @return descriptor pointer
-    */
-    static HBufC* Des8ToDesLC(const TDesC8& aString);
-    
-    /**
-    * Conversion from TDes16 to TDes8
-    * @since Series S60 3.1
-        * @param aString
-    * @return descrptor pointer
-    */
-    static HBufC8* DesToDes8LC(const TDesC& aString);
-       
-    /*
-    * Getter
-    * @since Series S60 3.1
-        * @param aUri
-    * @return TInt
-    */
-    static TInt64 ResIdFromUriL(const TDesC8& aUri);
-    
-    /*
-    * Getter
-    * @since Series S60 3.1
-    * @param aUri
-    * @return TPtrC8
-    */
-    static TPtrC8 ResIdFromUriDesL(const TDesC8& aUri);
-    
-    /*
-    * Sets Object Id
-    * @since Series S60 3.1
-    * @param aElement TXmlEngElement of the element
-    * @param aId Id
-    */
-
-    static void SetObjectIdL(TXmlEngElement aElement, TInt aId);
-    /*
-    * Sets refID
-    * @since Series S60 5.0 HN
-    * @param aElement TXmlEngElement of the element
-    * @param aRefId
-    */
-    static void SetObjectRefIdL(TXmlEngElement aElement, TInt aRefId);
-    
-    /*
-    * Sets parentID
-    * @since Series S60 5.0 HN
-    * @param aElement TXmlEngElement of the element
-    * @param aRefId
-    */
-    static void SetObjectParentIdL(TXmlEngElement aElement, TInt aParentId);
-        
-    /*
-     * Sets restricted field
-     * @since Series S60 5.0 HN
-     * @param aElement TXmlEngElement of the element
-     * @param aRestrictedFlag
-     */
-    static void SetRestrictedFieldL( TXmlEngElement aElement, TBool aRestrictedFlag );
-
-    /*
-    * Sets Container Id
-    * @since Series S60 3.1
-    * @param aElement TXmlEngElement of the element
-    * @param aParentId ParentId
-    */
-    static void SetContainerIdL(TXmlEngElement aElement, TInt aParentId);
-   	static HBufC8* BuildImportUriLC(TInt aResId);
-   	static HBufC8* BuildImportUriShorterLC(TInt64 aResId);
-	static HBufC8* BuildContentUriL(TInt aResId, const TDesC& aFileExten, TDesC8& aObjectId);
-    static HBufC8* UpnpCdUtils::RandomizeL(TInt aRange);
-    /**
-    * Checks whether the element is required and removes the attribute notifying it
-    * @since Series S60 3.0
-    * @param aElement TXmlEngElement of the element
-    * @param aObjId aCd pointer to the ContentDirectory object - it provides a function which deletes
-    *               a file from the private directory
-    * @param ETrue if the element is required, otherwise EFalse
-    */
-    static TBool IsElementRequiredL(TXmlEngElement aElement);
-        /**
-    * Replaces the the first occurrence of true/false sequence with 1/0 within given descriptor 
-    * @since Series S60 3.0
-    * @param aBuf descriptor pointer
-    */
-    static void ReplaceTrueFalse(HBufC8* aBuf);
-
-    /**
-    * Gets the full name with namespace of the given element.
-    * @since Series S60 3.0
-    * @param aElement an element to get the name of
-    * @return descriptor with the namespace:name of the element, 
-    *              the caller should delete it when it is no longer needed
-    */
-    static HBufC8* GetElmNameWithNsL(TXmlEngElement aElement);
-     
-    static HBufC* EscapeAposL(const TDesC&  aValue);
-    static TBool ValidateDateL(  TPtrC8 aValue );
-    
-    /**
-    * Converts TDesC8 to TUint
-    */
-    static TInt StringToTUint(const TDesC8& aStr, TUint* aInt);
-    
-    /**
-    * Checks whether input string contains a specific number of digits and whether whole number fit into specific range
-    * @since Series S60 3.0
-    * @param aInput input descriptor [a number]
-    * @param aNumber number of digits the descriptor should contain
-    * @param aExactDigitsNumber should the number have exact number of digits or not
-    * @param aRange the number mustn't exceed the specified range
-    * @return ETrue if condition is fulfilled
-    */
-    static TBool AreDigitsInSpecificRange(const TDesC8& aInput, TInt aNumber, TBool aExactDigitsNumber, TUint32 aRange); 
-    
-    /**
-    * Validates res@duration attribute
-    * @since Series S60 3.0
-    * @param aInput descriptor containing duration value to validate
-    * @return ETrue if res@duration has proper format
-    */
-    static TBool ValidateDurationValue(const TDesC8& aInput);  
-    
-    /**
-    * Split string into pieces with delimeter
-    * @since Series S60 3.0
-    * @param aLexeme a lexer to parse
-    * @param aDelimeter delimeter    
-    */
-    static void SplitStringByDelimeter(TLex8& aLexeme, TChar aDelimeter);
-    
-    /**
-    * Skip characters in lexer
-    * @since Series S60 3.0
-    * @param aLexer a lexer to parse
-    * @param aValue number of characters to skip
-    */
-    static void Skip(TLex8& aLexer, TInt aValue);
-        
-         /**
-    * Extracts integer value from descriptor
-    * @param aStr descriptor to be extracted
-    * @param aInt integer to be fill in
-    * @return error status
-    */
-    static TInt StringToInteger(const TDesC8& aStr, TInt* aInt);
-            
- private:
-     enum TPlaces
-        {
-        EYear = 4,
-        EMonth = 7,
-        EDay = 10,
-        EHour = 13,
-        EMinute = 16,
-        ESecond = 19,
-        EZone1 = 20,
-        EHourOffset1 = 22,
-        EMiliSecond = 23,
-        EZone2 = 24,
-        ETimeOffset1 = 25,
-        EHourOffset2 = 26,
-        ETimeOffset2 = 29
-        };
-    /*
-    * C++ default constructor.
-    */
-    UpnpCdUtils();
-};
-
-#endif      // CDUTILS_H   
-            
-// End of File
+/** @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:  ContentDirectory utils,
+*
+*/
+
+
+
+#ifndef CDUTILS_H
+#define CDUTILS_H
+
+//  INCLUDES
+#include <xmlengdom.h>
+#include <e32base.h>
+
+
+// CLASS DECLARATION
+
+/**
+*  Set of utils functions.
+*
+*  @lib AVContentDirectory.lib
+*  @since Series60 3.1
+*/
+class UpnpCdUtils
+{
+ public:
+ 
+    static void ValidateFilePath(TDes8& aPath);
+    static void ValidateFilePath(TDes& aPath);
+    static void ValidateSrcUriL(TDesC8& aPath,TDesC8& aIp);
+    /**
+    * Removes white spaces (and '\r \n \t and space') from the given descriptor 
+    * @since Series S60 3.0
+    * @param aString descriptor to be processed
+    */
+    static void RemoveWhiteSpacesL(TDes8& aString);
+
+    /**
+    * Checking if there are white spaces(and '\r \n \t and space' ) in the given descriptor
+    * @since Series S60 3.1
+    * @param aString 
+    * @return boolean
+    */
+    static TBool IsWhiteString(const TDesC8& aString);
+    
+    /**
+    * Gets element
+    * @since Series S60 3.1
+    * @param aFragment 
+    * @return TXmlEngElement
+    */      
+    static TXmlEngElement GetObjectElementL(RXmlEngDocument& aFragment);
+    
+    /**
+    * Checks if Ref id value exists
+    * @since Series S60 5.0 HN
+    * @param aFragment 
+    * @return TBool
+    */     
+    static TBool HasRefIdL( RXmlEngDocument& aFragment );
+    
+    /**
+    * Encodes Xml 
+    * @since Series S60 3.1
+    * @param aString
+    * @return descriptor pointer
+    */
+    static HBufC8* EncodeXmlStringL(const TDesC8& aString);
+    
+     
+   	static HBufC* Des8ToDesL(const TDesC8& aString);
+    
+    /**
+    * Conversion from TDes8 to TDes16
+    * @since Series S60 3.1
+    * @param aString
+    * @return descriptor pointer
+    */
+    static HBufC* Des8ToDesLC(const TDesC8& aString);
+    
+    /**
+    * Conversion from TDes16 to TDes8
+    * @since Series S60 3.1
+        * @param aString
+    * @return descrptor pointer
+    */
+    static HBufC8* DesToDes8LC(const TDesC& aString);
+       
+    /*
+    * Getter
+    * @since Series S60 3.1
+        * @param aUri
+    * @return TInt
+    */
+    static TInt64 ResIdFromUriL(const TDesC8& aUri);
+    
+    /*
+    * Getter
+    * @since Series S60 3.1
+    * @param aUri
+    * @return TPtrC8
+    */
+    static TPtrC8 ResIdFromUriDesL(const TDesC8& aUri);
+    
+    /*
+    * Sets Object Id
+    * @since Series S60 3.1
+    * @param aElement TXmlEngElement of the element
+    * @param aId Id
+    */
+
+    static void SetObjectIdL(TXmlEngElement aElement, TInt aId);
+    /*
+    * Sets refID
+    * @since Series S60 5.0 HN
+    * @param aElement TXmlEngElement of the element
+    * @param aRefId
+    */
+    static void SetObjectRefIdL(TXmlEngElement aElement, TInt aRefId);
+    
+    /*
+    * Sets parentID
+    * @since Series S60 5.0 HN
+    * @param aElement TXmlEngElement of the element
+    * @param aRefId
+    */
+    static void SetObjectParentIdL(TXmlEngElement aElement, TInt aParentId);
+        
+    /*
+     * Sets restricted field
+     * @since Series S60 5.0 HN
+     * @param aElement TXmlEngElement of the element
+     * @param aRestrictedFlag
+     */
+    static void SetRestrictedFieldL( TXmlEngElement aElement, TBool aRestrictedFlag );
+
+    /*
+    * Sets Container Id
+    * @since Series S60 3.1
+    * @param aElement TXmlEngElement of the element
+    * @param aParentId ParentId
+    */
+    static void SetContainerIdL(TXmlEngElement aElement, TInt aParentId);
+   	static HBufC8* BuildImportUriLC(TInt aResId);
+   	static HBufC8* BuildImportUriShorterLC(TInt64 aResId);
+	static HBufC8* BuildContentUriL(TInt aResId, const TDesC& aFileExten, TDesC8& aObjectId);
+    static HBufC8* UpnpCdUtils::RandomizeL(TInt aRange);
+    /**
+    * Checks whether the element is required and removes the attribute notifying it
+    * @since Series S60 3.0
+    * @param aElement TXmlEngElement of the element
+    * @param aObjId aCd pointer to the ContentDirectory object - it provides a function which deletes
+    *               a file from the private directory
+    * @param ETrue if the element is required, otherwise EFalse
+    */
+    static TBool IsElementRequiredL(TXmlEngElement aElement);
+        /**
+    * Replaces the the first occurrence of true/false sequence with 1/0 within given descriptor 
+    * @since Series S60 3.0
+    * @param aBuf descriptor pointer
+    */
+    static void ReplaceTrueFalse(HBufC8* aBuf);
+
+    /**
+    * Gets the full name with namespace of the given element.
+    * @since Series S60 3.0
+    * @param aElement an element to get the name of
+    * @return descriptor with the namespace:name of the element, 
+    *              the caller should delete it when it is no longer needed
+    */
+    static HBufC8* GetElmNameWithNsL(TXmlEngElement aElement);
+     
+    static HBufC* EscapeAposL(const TDesC&  aValue);
+    static TBool ValidateDateL(  TPtrC8 aValue );
+    
+    /**
+    * Converts TDesC8 to TUint
+    */
+    static TInt StringToTUint(const TDesC8& aStr, TUint* aInt);
+    
+    /**
+    * Checks whether input string contains a specific number of digits and whether whole number fit into specific range
+    * @since Series S60 3.0
+    * @param aInput input descriptor [a number]
+    * @param aNumber number of digits the descriptor should contain
+    * @param aExactDigitsNumber should the number have exact number of digits or not
+    * @param aRange the number mustn't exceed the specified range
+    * @return ETrue if condition is fulfilled
+    */
+    static TBool AreDigitsInSpecificRange(const TDesC8& aInput, TInt aNumber, TBool aExactDigitsNumber, TUint32 aRange); 
+    
+    /**
+    * Validates res@duration attribute
+    * @since Series S60 3.0
+    * @param aInput descriptor containing duration value to validate
+    * @return ETrue if res@duration has proper format
+    */
+    static TBool ValidateDurationValue(const TDesC8& aInput);  
+    
+    /**
+    * Split string into pieces with delimeter
+    * @since Series S60 3.0
+    * @param aLexeme a lexer to parse
+    * @param aDelimeter delimeter    
+    */
+    static void SplitStringByDelimeter(TLex8& aLexeme, TChar aDelimeter);
+    
+    /**
+    * Skip characters in lexer
+    * @since Series S60 3.0
+    * @param aLexer a lexer to parse
+    * @param aValue number of characters to skip
+    */
+    static void Skip(TLex8& aLexer, TInt aValue);
+        
+         /**
+    * Extracts integer value from descriptor
+    * @param aStr descriptor to be extracted
+    * @param aInt integer to be fill in
+    * @return error status
+    */
+    static TInt StringToInteger(const TDesC8& aStr, TInt* aInt);
+
+    
+private:
+    static TBool ValidateDateLength(TInt aDateLength);
+            
+ private:
+     enum TPlaces
+        {
+        EYear = 4,
+        EMonth = 7,
+        EDay = 10,
+        EHour = 13,
+        EMinute = 16,
+        ESecond = 19,
+        EZone1 = 20,
+        EHourOffset1 = 22,
+        EMiliSecond = 23,
+        EZone2 = 24,
+        ETimeOffset1 = 25,
+        EHourOffset2 = 26,
+        ETimeOffset2 = 29
+        };
+    /*
+    * C++ default constructor.
+    */
+    UpnpCdUtils();
+};
+
+#endif      // CDUTILS_H   
+            
+// End of File
--- a/upnpmediaserver/contentdirectoryservice/inc/upnpcontentdirectory.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/inc/upnpcontentdirectory.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,922 +1,923 @@
-/** @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:  Declares ContentDirectory class.
-*
-*/
-
-
-#ifndef C_CUPNPCONTENTDIRECTORY_H
-#define C_CUPNPCONTENTDIRECTORY_H
-
-
-// INCLUDES
-#include "upnpserviceimplementation.h"
-#include "upnpelementfactory.h"
-
-// new xml
-#include <xml/dom/xmlengdom.h>
-
-#include "upnpfiletransfer.h"
-#include "upnpcontentdirectorydatafinder.h"
-#include "upnpthumbnailcreator.h"
-#include "upnpcdsettings.h"
-#include "upnptransferobserver.h"
-#include "upnphttpservertransactioncreator.h"
-#include "upnphttpserverobserver.h"
-
-// FORWARD DECLARATIONS
-
-class CUpnpElementFactory;
-class TUpnpContainerUpdateId;
-class CUpnpFileTransferTimerObserver;
-class CUpnpObject;
-class CUpnpItem;
-class CUpnpContentDirectoryDb;
-class CProtocolInfo;
-class CUpnpMetadataStorage;
-class CUpnpAutoDestroyObjectList;
-class MUpnpContentDirectoryEventObserver;
-class CUpnpFileTransferEvent;
-class MUpnpCdsSender;
-class CUpnpStateHandler;
-class CUpnpTransferUploader;
-class CUpnpMimeMapper;
-class CUpnpTransferController;
-class MUpnpTransferInterface;
-class CUpnpDlnaFilter;
-class CUpnpHttpServerSession;
-class CUpnpSecurityManager;
-
-// CONSTANTS
-static const TInt KMaxImportExportTransfers = 3;
-_LIT8( KContentDirectoryType, "ContentDirectory:1" );
-
-// CLASS DECLARATION
-
-/**
-*  @brief Main Content Directory Service Class
-*
-*  @lib ServiceFramework.lib
-*  @since Series60 2.6
-*/
-class CUpnpContentDirectory :             
-                public CUpnpServiceImplementation, 
-                public MUpnpContentDirectoryDataFinder,
-                public MUpnpThumbnailCreatorObserver,
-                public MUpnpTransferObserver,
-                public MUpnpHttpServerTransactionCreator,
-                public MUpnpHttpServerObserver
-{
-public: // Constructors and destructors
-    
-    /**
-    * Two-phased constructor for creating Content Directory Service (CDS).
-    * @since Series60 2.6
-    * @param aService Parent service 
-    */
-    static CUpnpContentDirectory* NewL( TUpnpCdSettings aSettings, 
-                                        CUpnpMetadataStorage* aMetadataStorage,
-                                        MUpnpTransferInterface* aTransfer );
-
-    /**
-    * Destructor function; called automatically from the destructor of a 
-    * derived class
-    **/
-    virtual ~CUpnpContentDirectory();
-    IMPORT_C void SetSender(MUpnpCdsSender* aSender);
-            
-
-public: //from CUpnpServiceImplementation
-    
-    CUpnpStateHandler* CUpnpContentDirectory::StateHandler();
-    /**
-    * Handles auto destroy events.
-    * @since Series 60 2.6
-    * @param aObjIdn id of evented upnp object
-    */
-    void AutoDestroyEventL(TInt aObjId, TBool aDeleteObj);
-
-    /**
-    * This functions is a entry point for actions. See coments in base class
-    * @since Series 60 2.6
-    * @param aAction Action received by CDS.
-    */
-    void ActionReceivedLD( CUpnpAction* aAction );
-    
-    /**
-    * Hnadle unknown http event
-    * Export for interneal use only    
-    */
-    IMPORT_C void UnknownHttpEventReceivedL( CUpnpHttpMessage& aHttpMsg );
-    
-    /**
-    * Handles address change event    
-    */
-    void AddressChangeL();
-    
-    /**
-    * This function is for informing service from evented statevariables.
-    * @since Series 60 2.6
-    * @param aVariableName Name of the evented statevariable.
-    */
-    void StateVariableEvented(const TDesC8& aVariableName);
-      
-    /**
-    * Checks if specified importUri is in database still active.
-    * @param aImportUri uri to be searched in databse. 
-    * @return objId if successful
-    */
-    TInt CheckImportUriL(const TDesC8& aImportUri);
-
-    /**
-    * Inserts Ip and Port
-    * @since Series S60 3.1
-    * @param aString
-    */
-    void InsertRealIpAndPortL(TDes8& aString);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aString
-    * @return descriptor pointer
-    */  
-    HBufC8* InsertIpAndPortPlaceholderL(const TDesC8& aString);
-    
-    /**
-    * Find protocolInfo by importUri (Not by importUri).
-    * @param aImportUri uri to be searched in database (Value of resource).
-    * @return aProtocolInfo related to resorce which has been founded 
-    */  
-    CUpnpDlnaProtocolInfo* GetProtocolInfoByImportUriL(const TDesC8& aImportUri);
-    
-    /**
-    * Gets infomation about protocol
-    * @since Series S60 3.1
-    * @param aContentUri
-    * @parma aProtocolInfo
-    * @return
-    */
-    TInt GetProtocolInfoL(const TDesC8& aContentUri, CUpnpDlnaProtocolInfo*& aProtocolInfo);
-        
-    /**
-    * Gets title of the object with given id from ContentDirectory service. 
-    * @since Series60 2.6
-    * @param aObjectId id of the object.
-    * @param aValue pointer to buffer in which the tilte of the object will be returned.
-    *       Buffer for aValue has to allocated first.
-    **/
-    void GetTitleForUriL( TInt aObjectId, TPtr& aValue );
-        
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aUrlPath
-    * @param aFileName
-    * @param aSystemPath
-    */
-    TInt FindSharedFolderL( const TDesC& aUrlPath, const TDesC& aFileName, HBufC*& aSystemPath);
-        
-    /**
-    *
-    * @since Series S60 3.1
-    * @return TPtrC
-    */
-    const TPtrC MediaRealDir();
-        
-        
-    /**
-    * Sets download directory
-    * @since Series S60 3.1
-    * @param aDownloadDir this directory is going to be set as download directory
-    * @return TInt
-    */
-    void SetDownloadDirectoryL(const TDesC& aDownloadDir);
-        
-    /**
-    * Sets thumbnail directory
-    * @since Series S60 3.1
-    * @param aDownloadDir this directory is going to be set as thumbnail directory
-    * @return TInt
-    */
-    void SetThumbnailDirectoryL(const TDesC& aDownloadDir);    
-    
-    TInetAddr GetAddress();
-    IMPORT_C void SendActionL(CUpnpAction* aAction, TUpnpErrorCode aError);
-    IMPORT_C void SendMessageL( CUpnpHttpMessage* aMessage );
-    CUpnpAutoDestroyObjectList* GetAutoDestroyObjectList();
-    
-    // For internal use only
-    IMPORT_C void HttpTransferEventReceivedL(CUpnpHttpMessage& aHttpMsg);
-    
-    /**
-    * Sends transfer failed event to Media Server       
-    * @param aSessionId transaction identifier
-    * @param aStatusCode HTTP Status code
-    */
-    void NotifyTransferFailL(TInt aSessionId, TInt aStatusCode);
-    
-    /**
-    * Sends transfer stopped event to Media Server       
-    * @param aSessionId transaction identifier
-    * @param aType import/export
-    */
-    void NotifyTransferStoppedL( TInt aSessionId, CUpnpFileTransfer::TTransferType aType);
-
-     // new functions for httptransfer.dll intergration
-    void HttpGetStartedSoapNotifyL(TInt aSessionId);    
-    void HttpPostStartedL(TInt aSessionId);   
-              
-
-    // helper functions
-    TCurrentAction ExecutedAction();
-    void SetExecutedAction(TCurrentAction aAction);
-    
-    
-    /**
-    * This function is a entry point for http messages.
-    * received from Symbian HTTP Stack
-    * @since Series 60 3.2
-    * @param aSessionId identifier of the HTTP request.
-    * @param aHttpStatusCode HTTP error code.
-    */
-    void HttpResponseReceivedL( TInt aSessionId,
-                                TInt aStatusCode);   
-    
-    /**
-    * Getter
-    * @since Series 60 3.2
-    * @return Event Observer
-    */
-    MUpnpContentDirectoryEventObserver* EventObserver();
-    
-public://temporary public methods
-
-    void TransferCompleteL(TInt aResId, TInt aObjId);
-    
-    void TransferProgress( TInt aId, TInt aBytes, TInt aTotalBytes );
-    
-    void TransferStartL(const TDesC8& aImpUri);
-
-    /** 
-    * This fuction removes a TransferID from the TransferIDs Statevariable
-    * @since Series 60 2.6
-    * @param aTransferID a id of file transfer
-    **/
-    void RemoveFileTransferFromTransferIDsStateVariableL(TInt aTransferID);
-    
-    /** 
-    * This fuction adds a TransferID to the TransferIDs Statevariable
-    * @since Series 60 2.6
-    * @param aTransferID a id of file transfer
-    **/
-    void AddFileTransferToTransferIDsStateVariableL( TInt aTransferID );
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aFileName
-    * @return boolean whether given file is drmfile
-    */
-    TBool IsDrmFileL(const TDesC& aFileName);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aFileName
-    * @return boolean whether given file is drmfile
-    */
-    TBool IsDrmFileL(const TDesC8& aFileName);
-    
-
-     /** 
-    * This functions is used for generating correct res tags for finished downloads.
-    * @param aOnlyThumbnail  this method is used during two action - ImportResource and CreateObject. 
-    *                           In CreateObject case res can be created by passed argument so we only thumbail has to be created
-    * @since Series 60 2.6
-    * @return error code. KErrNone if no errors.
-    **/
-    TInt CreateResTagL( TInt aSessionId, 
-                       TDesC8& aFilePath, 
-                        TInt aImportNumber,
-                        TBool aOnlyThumbnail = EFalse  );
-
-
-    /**
-    * Notify transfer          
-    * @param aSessionId HTTP transaction identifier 
-    */    
-    void NotifyOutgoingTransferL (TInt aSessionId); 
-    
-    
-    CUpnpContentDirectoryDb*  ContentDirectoryDb();
-    
-    MUpnpTransferInterface* TransferHandler();
-    
-public: //from MUpnpTransferObserver
-    
-    virtual void TransferCompletedL( TInt akey, TInt aResultCode );
-
-public: //from MUpnpHttpServerTransactionCreator
-
-        IMPORT_C virtual void NewTransactionL(
-        const TDesC8& aMethod, const TDesC8& aUri, 
-        const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans );
-
-private: //form MUpnpHttpServerObserver
-    virtual void HttpEventLD( CUpnpHttpMessage* aMessage );
-    
-private://private methods
-
-
-    void PrepareAutoDestroyObjectL(TXmlEngElement aObject, TInt aObjId);
-
-    /**
-    * Gets ip and port number
-    * @since Series S60 3.1
-    * @return descriptor pointer
-    */
-    HBufC8* GetIpAndPortDes8L();
-
-    /**
-    * Sets size
-    * @since Series S60 3.1
-    * @parma aSize
-    * @parma aFilePath
-    */
-    void SetResSizeL(TXmlEngAttr aSize, const TDesC& aFilePath);
-        
-    /**
-    * Adds Import URI to Element
-    * @since Series S60 3.1
-    * @param aElement
-    */
-    void AddImportUriToElL(TXmlEngElement aElement);
-        
-    /**
-    *
-    * @since Series S60 3.1
-    * @return descriptor pointer
-    */
-    HBufC8* BuildImportUriLC();
-    HBufC8* BuildImportUriShorterLC();
-        
-    /**
-    * Checking whether thumbnail is available
-    * @since Series S60 3.1
-    * @param aFile
-    * @return 
-    **/
-    TBool IsThumbnailAvailableL(const TDesC& aFile);
-    
-    /**
-    * Checking whether thumbnail is available
-    * @since Series S60 3.1
-    * @param aFile 
-    * @return
-    */
-    TBool IsThumbnailAvailableL(const TDesC8& aFile);
-    
-    /**
-    * Creates thumbnail
-    * @since Series S60 3.1
-    * @param a SrcFile
-    * @param aObjId
-    */
-    void CreateThumbnailL(const TDesC& aSrcFile, TInt aObjId);
-    
-    /**
-    * Adds new res tag
-    * @since Series S60 3.1
-    * @param aObjEl 
-    */
-    void AddNewResTagL(TXmlEngElement aObjEl);
-    
-    /**
-    * Creates a name for thumbnail
-    * @since Series S60 3.1
-    * @param aFileName
-    * @return descriptor pointer
-    */
-    HBufC* CreateNameForThumbnailL(const TDesC& aFileName);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aRes
-    */      
-    void HandleLocalResourcesL(TXmlEngElement aRes, TInt aObjectId);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @parma aFileName
-    * @return descriptor pointer
-    */
-    HBufC8* BuildContentUriL(const TDesC& aFileExt, TInt aObjectId);  
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aAction  
-    * @param aSenAndDestroy
-    * @return
-    */
-    TInt DoActionReceivedL( CUpnpAction* aAction );
-    
-    /**
-    * 
-    * since Series S60 3.1
-    * @param aObjs
-    * return descriptor pointer
-    */
-    HBufC8* SerializeObjectsListL(const RArray<RXmlEngDocument>& aObjs);
-              
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aObj
-    * @param aImportUri
-    * @param ANewFile
-    */
-    void DeleteOldResourcesL( RXmlEngDocument& aObj, const TDesC8& aImportUri,
-                              const TDesC& aNewFile );
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @parma aMessage
-    * return descriptor pointer
-    */
-    HBufC8* GetImportUriLC(CUpnpHttpMessage* aMessage);     
-       
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aFileName
-    * @param aNextKey
-    * @return descriptor pointer
-    */
-    HBufC* BuildThumbnailUrlPathL(const TDesC& aFilename, const TDesC& aNextKey);
-
-    /**
-    * This function gets mime type for specified file. 
-    * @since Series 60 3.1
-    * @param aFilename -  filename, for which mimeType will be taken.
-    * @return pointer to variable storing mimeType. 
-    */
-    HBufC8* GetMimeTypeLC(const TDesC8& aFilename);    
-
-    /**
-    * Removes thumbnail creator and corresponding objectId from lists. 
-    * @since Series 60 3.1
-    * @param aThCreator - thumbnail creator for which the information will be deleted.
-    */
-    void RemoveThCreatorAndObjectIdLD( CUpnpThumbnailCreator* aThCreator);
-
-    /**
-    * Gives object id for specified thumbnail creator. 
-    * @since Series 60 3.1
-    * @param aThCreator - thumbnail creator for which object id will be searched for. 
-    * @return object id for specified thumbnail creator. 
-    */
-    TInt GetObjectIdFromThCreator( CUpnpThumbnailCreator* aThCreator);
-
-    /**
-    * Gives this server address in predefined format. 
-    * @since Series 60 3.1
-    * @return pointer to address. 
-    */
-    HBufC8* CreateAddressValueLC();
-
-    /**
-    * This function creates ProtocolInfo object for further use. 
-    * @since Series 60 3.1
-    * @param aMimeType - mime type, for which ProtocolInfo will be created.
-    * @param aAddInfo - additional information which can be choosen according to mime type and image size. 
-    * @return pointer to CProtocolInfo object, which describes all protocolInfo values for this element.
-    */
-    CUpnpDlnaProtocolInfo* CreateProtocolInfoFromMimeL(const TDesC8& aMimeType, TInt aAddInfo );
-
-    /**
-    * This function retrieves title from object description. 
-    * @since Series 60 3.1
-    * @param aObjId - objecty id for which title will be retrieved. 
-    * @return pointer to HBufC, with specified value. 
-    */
-    HBufC* GetFileNameL( TInt aObjId );    
-    HBufC* GetFileNameWithoutPathL( TInt aObjId );
-    
-    /**
-    * This function add underscore and number to existing filename. 
-    * @since Series 60 3.2
-    * @param aFileName - file that probably exist. 
-    * @return pointer to HBufC, with specified value. 
-    */
-    HBufC* CreateFileNameL( const TDesC16& aFileName );
-   
-    /**
-    * This function puts on stack upnp:class value for specific mime type.  
-    * @since Series 60 3.1
-    * @param aMimeType - mime type from which additional information will be retrieved. 
-    * @return pointer to HBufC8 object with new value, if the type is unknown there is null returned.
-    * Mapping: 
-    * image/* - object.item.imageItem
-    * video/* - object.item.videoItem 
-    * audio/* - object.item.audioItem 
-    * text/* - object.item.textItem 
-    */ 
-    HBufC8* GetItemTypeFromMimeTypeLC(const TDesC8& aMimeType);
-        
-    /**
-    * This function compares upnp:class tag value, with value denoted by aMimeType. 
-    * @since Series 60 3.1
-    * @param obj - object for which needed changes will be applied.
-    * @param aMimeType - mime type from which additional information will be retrieved. 
-    */ 
-    void CheckItemTypeForObjectL( RXmlEngDocument& obj, const TDesC8&  aMimeType );
-        
-  
-    /**
-    * This function returns a XML fragment containing the XML in the parameter
-    * @since Series 60 2.6
-    * @param aBuffer the XML is in this buffer
-    * @return A new CSenDomFragment that is on the cleanup stack
-    */
-    RXmlEngDocument XmlFragmentL(const TDesC8& aBuffer);
-        
-    /**
-    * This fuctions converts one XML element to a string 
-    * @since Series 60 2.6
-    * @param aResp XML string
-    * @param aSen an Sen element to be converted to string
-    */
-    void BrowseElementL( HBufC8*& aResp, TXmlEngElement& aSen );
-
-    /**
-    * This fuctions is a getter for container updateID. 
-    * @since Series 60 2.6
-    * @param aID ID of the container which updateID is returned
-    * @return a updateId of container
-    */
-    TInt ContainerUpdateId( const TDesC8& aContainerID );
-
-
-    /**
-    * Function to add data to metadb
-    * @param aFragment fragment to add to db
-    * @param aContainer container where to add data
-    * @param aId parameter returned by AddToMetaDbL method, stands for item id
-    * @return upnperrorcode descriping situation
-    */
-    TUpnpErrorCode AddToMetaDbL( RXmlEngDocument& aFragment, TInt aContainer, TInt* aId,
-                                 TBool aIsLocal );
-
-    /*
-    *
-    * @since Series S60 3.1
-    * @param aFragment
-    * @param aImportUris
-    * @param aRess
-    * @param aLocal
-    * @param aCreateThumbnailRes
-    * @param aNextKey
-    * @return upnperrorcode descriping situation
-    */
-    TUpnpErrorCode PrepareCreateOperationL( RXmlEngDocument& aFragment, 
-        RArray<TXmlEngAttr>& aImportUris, RArray<TXmlEngElement>& aRess, TBool& aLocal,
-        TBool& aCreateThumbnailRes, TInt& aNextKey );
-
-    /**
-    * Related to CreateObject, resultset of create is created here
-    * @since Series 60 2.6
-    * @param aAction action data structure is needed here
-    * @param aElement element added to db
-    * @param aId element's id
-    **/
-    void ConstructCreateResultsetL( CUpnpAction*& aAction, 
-                                    RXmlEngDocument aElement, 
-                                    TInt aId );
-
- 
-    /** 
-    * Function for creating a new object
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @return upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode CreateObjectL( CUpnpAction*& aAction );
-    /** 
-    * Function for browsing values of objects
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @return upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode BrowseL( CUpnpAction*& aAction );
-
-    /** 
-    * Function for destroying objects
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @return upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode DestroyObjectL( CUpnpAction*& aAction );
-
-    /** 
-    * Function for creating refense items
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @return upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode CreateReferenceL( CUpnpAction*& aAction );
-
-    /** 
-    * Function to solve CDS's search capabilities
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @retrun upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode GetSearchCapabilitiesL( CUpnpAction*& aAction );
-
-    /** 
-    * Function to solve CDS's sort capabilities
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @return upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode GetSortCapabilitiesL( CUpnpAction*& aAction );
-
-    /** 
-    * Getter for CDS's SystemUpdateID
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @return upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode GetSystemUpdateIdL( CUpnpAction*& aAction );
-
-    /** 
-    * Function for importing resources
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @return upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode ImportResourceL( CUpnpAction*& aAction );
-
-    /** 
-    * Function for exporting resources
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @return upnperrorcode descriping situation
-    */
-    TUpnpErrorCode ExportResourceL( CUpnpAction*& aAction );
-
-    /** 
-    * Function for stopping ongoing file transfer (import / export)
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @retrun upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode StopTransferResourceL( CUpnpAction*& aAction );
-
-    /** 
-    * Function for getting information about ongoing file transfer
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @return upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode GetTransferProgressL( CUpnpAction*& aAction );
-
-    /** 
-    * This functions removes a "res" tag from a object
-    * @since Series 60 2.6
-    * @param aAction received action
-    * @return upnperrorcode descriping situation
-    **/
-    TUpnpErrorCode DeleteResourceL( CUpnpAction*& aAction );
-
-    /**
-    * This function changes file name and its extension. 
-    * @since Series 60 3.1
-    * @param aFilePath - the target file. 
-    * @param aMimeType - mime type, for which file extension will be choosen. 
-    */
-    HBufC8* ChangeFileNameWithExtensionL(TDesC8& aFilePath, const TDesC8& aMimeType );
- 
- 
-   
-    /**
-    * @param aOnlyThumbnail  this method is used during two action - ImportResource and CreateObject. 
-    *           In CreateObject case res can be created by passed argument so we only thumbail has to be created
-    */
-    TInt CreateResTagInternalL( TInt aSessionId, 
-                                TDesC8& aFilePath,
-                                HBufC8* aImportUri, 
-                                TBool aOnlyThumbnail );
-
-    /**
-    * calls CreateResTagInternalL but KErrCorrupted is TRAPed in order to invoke recovery on DB
-    */
-    TInt CreateResTagInternalWithDBRecoveryL( TInt aSessionId,
-                                              TDesC8& aFilePath, 
-                                              HBufC8* aImportUri, 
-                                              TBool aOnlyThumbnail = EFalse );
-    
-private:    // New functions    
-
-   
-    void DoSendActionL(CUpnpAction* aAction, TUpnpErrorCode aError);
-    void DoSendMessageL(CUpnpHttpMessage* aMessage);
-    TBool IsValidUrlPath(const TDesC& aUrlPath);
-    
-    /**
-    * Gets protocolInfo from mimeType.
-    * @param aMimeType mime type for which protocolInfo will be created.
-    * @return string with protocolInfo
-    */
-    HBufC8* ProtocolInfoFromMimeL( const TDesC8& aMimeType, TInt aAddInfo, TBool aOpRangeParam,
-                                   TBool aCiParam = EFalse );
-
-    HBufC8* ProtocolInfoFromMimeL(const TDesC8& aMimeType, TXmlEngElement& aResEl);
-    
-    /**
-    * Notify message when the thumbnail creation has been finished. 
-    * From MUpnpThumbnailCreatorObserver interface.
-    * @param aThCreator this is a thumbnail creator.
-    * @param aResult result from thumbnail creation.
-    */
-    void NotifyThumbnailResultL( CUpnpThumbnailCreator* aThCreator, TInt aResult );
-
-    /**
-    * Notify message when the thumbnail creation has been finished. 
-    * From MUpnpThumbnailCreatorObserver interface.
-    * @param aThCreator this is a thumbnail creator.
-    * @param aResult result from thumbnail creation.
-    */
-    CUpnpThumbnailCreator* CreateThumbnailCreatorL(TInt aObjectId);
-    
-    /**
-    * Cheks if object exists.
-    * @param aObjectId
-    */
-    TBool IsObjectExistL( TInt aObjectId );
-    
-    /**
-    * Cheks if object is valid.
-    * if object doesn't exist or has no parent 
-    * object is removed from autodestoy table and EFalse is returned
-    * @param aObjectId
-    */
-    TBool ValidateObjectL( TInt aObjectId );
-         
-    /**
-    * Handles DB error
-    * Tries to recover, if fails tries to recreate
-    * @since Series S60 3.2
-    * @return TInt - KErrNone if succeed
-    */
-    TInt HandleDbError( TInt aError );
-    
-    /**
-    * Checks DB and disk Space
-    * Tries to recover DB, if fails tries to recreate
-    * @since Series S60 3.2
-    * @param aAction received action
-    * @return EFalse if succeed
-    */
-    TBool IsDbOrDiskProblemL( CUpnpAction* aAction );
-    
-    /**
-    * Determines if DB has benn recovered successfully
-    * returns ETrue if yes
-    * @param a Error - DB is revovered only if aError equal KErrCorrupted
-    * @since Series S60 3.2
-    * @returns ETrue if succeed 
-    */
-    TBool DataBaseHasBeenRecoveredL( TInt aError );
-    
-    /**
-    * Returns DB creation status
-    * @since Series S60 3.2
-    * @return TBool
-    */
-    TBool IsDbCreated(); 
-
-    /**
-    * Updates import URI
-    * @since Series S60 3.2
-    * @return TPtrC8
-    */
-    TPtrC8 UpdateImportUriL( const TDesC8& aImportUri );
-    
-private: // Constructors
-    
-    /**
-    * C++ default constructor.
-    */
-    CUpnpContentDirectory( CUpnpDevice& aDevice, 
-                           MUpnpThumbnailCreatorObserver* aThmbObs,
-                           MUpnpTransferInterface* aTransfer
-                         );
-
-    /**
-    * Second phase of the constructor.
-    * Initialises a DOM tree.
-    * By default Symbian 2nd phase constructor is private.
-    * @param service Parent service
-    */
-    void ConstructL( TUpnpCdSettings aSettings, 
-                     CUpnpMetadataStorage* aMetadataStorage 
-                   );
-    
-    void ConstructHttpL();
-    
-private:
-    
-    //Array containing objects ids, which will be updated after Thumbnail creation.
-    RArray<TInt> iThObjectIds;
-    
-    // Array of thumbnail creators in which creators can be searched for.
-    RPointerArray<CUpnpThumbnailCreator> iThumbnailCreators;
-
-    // Next free object ID, owned
-    TInt iNextFreeID;
-
-    // Pointerarray for pending actions (used in Import and Export), owned
-    //RPointerArray<CUpnpAction> iPendingActions;
-
-    // Elementfactory, owned
-    CUpnpElementFactory* iElementdb;
-    
-       
-    // Database
-    CUpnpContentDirectoryDb* iContentDirectoryDb;
-        
-    // file session
-    RFs iFs;
-    
-    // Download directory
-    HBufC* iDownloadDir;
-    
-   // Thumbnail directory
-    HBufC* iThumbDir;
-    // connection try to bitmap and font server. 
-    // if there is no such connection there will be no thumbcreated. 
-    TInt iBitmapServerConnection;
-        
-    TBool iEcomUsed;
-        
-    // Thumbnail creator observer
-    MUpnpThumbnailCreatorObserver* iThmbObs;
-
-    // auto-destroy object list    
-    CUpnpAutoDestroyObjectList* iAutoDestroyObjects;
-
-    
-    // Event observer
-    MUpnpContentDirectoryEventObserver* iEventObserver;
-    
-    // Thumbnail creation flag
-    TBool iCreateThumbnails; 
-    
-    // Max number of browsed object
-    TInt iMaxRequestCount;
-
-    TCurrentAction iCurrentAction;
-    
-    RXmlEngDOMImplementation iDOMImpl;
-    
-    MUpnpCdsSender* iSender; // not owned
-        
-    CUpnpMimeMapper* iMimeToExtMap;
-        
-    HBufC* iObjectsXmlPath;
-    
-    CUpnpStateHandler* iStateHandler;
-         
-
-    CUpnpTransferController* iTransferController;
-    
-    MUpnpTransferInterface* iTransferHandler;
-    
-    CUpnpDlnaFilter* iDlnaFilter;
-    
-    CUpnpHttpServerSession* iHttpServerSession;
-    
-    CUpnpSecurityManager* iSecurityManager;
-    
-    };
-
-#endif  // C_CUPNPCONTENTDIRECTORY_H
-
-// End Of File
+/** @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:  Declares ContentDirectory class.
+*
+*/
+
+
+#ifndef C_CUPNPCONTENTDIRECTORY_H
+#define C_CUPNPCONTENTDIRECTORY_H
+
+
+// INCLUDES
+#include "upnpserviceimplementation.h"
+#include "upnpelementfactory.h"
+
+// new xml
+#include <xmlengdom.h>
+
+#include "upnpfiletransfer.h"
+#include "upnpcontentdirectorydatafinder.h"
+#include "upnpthumbnailcreator.h"
+#include "upnpcdsettings.h"
+#include "upnptransferobserver.h"
+#include "upnphttpservertransactioncreator.h"
+#include "upnphttpserverobserver.h"
+
+// FORWARD DECLARATIONS
+
+class CUpnpElementFactory;
+class TUpnpContainerUpdateId;
+class CUpnpFileTransferTimerObserver;
+class CUpnpObject;
+class CUpnpItem;
+class CUpnpContentDirectoryDb;
+class CProtocolInfo;
+class CUpnpMetadataStorage;
+class CUpnpAutoDestroyObjectList;
+class MUpnpContentDirectoryEventObserver;
+class CUpnpFileTransferEvent;
+class MUpnpCdsSender;
+class CUpnpStateHandler;
+class CUpnpTransferUploader;
+class CUpnpMimeMapper;
+class CUpnpTransferController;
+class MUpnpTransferInterface;
+class CUpnpDlnaFilter;
+class CUpnpHttpServerSession;
+class CUpnpSecurityManager;
+
+// CONSTANTS
+static const TInt KMaxImportExportTransfers = 3;
+_LIT8( KContentDirectoryType, "ContentDirectory:1" );
+
+// CLASS DECLARATION
+
+/**
+*  @brief Main Content Directory Service Class
+*
+*  @lib ServiceFramework.lib
+*  @since Series60 2.6
+*/
+class CUpnpContentDirectory :             
+                public CUpnpServiceImplementation, 
+                public MUpnpContentDirectoryDataFinder,
+                public MUpnpThumbnailCreatorObserver,
+                public MUpnpTransferObserver,
+                public MUpnpHttpServerTransactionCreator,
+                public MUpnpHttpServerObserver
+{
+public: // Constructors and destructors
+    
+    /**
+    * Two-phased constructor for creating Content Directory Service (CDS).
+    * @since Series60 2.6
+    * @param aService Parent service 
+    */
+    static CUpnpContentDirectory* NewL( TUpnpCdSettings aSettings, 
+                                        CUpnpMetadataStorage* aMetadataStorage,
+                                        MUpnpTransferInterface* aTransfer );
+
+    /**
+    * Destructor function; called automatically from the destructor of a 
+    * derived class
+    **/
+    virtual ~CUpnpContentDirectory();
+    IMPORT_C void SetSender(MUpnpCdsSender* aSender);
+            
+
+public: //from CUpnpServiceImplementation
+    
+    CUpnpStateHandler* CUpnpContentDirectory::StateHandler();
+    /**
+    * Handles auto destroy events.
+    * @since Series 60 2.6
+    * @param aObjIdn id of evented upnp object
+    */
+    void AutoDestroyEventL(TInt aObjId, TBool aDeleteObj);
+
+    /**
+    * This functions is a entry point for actions. See coments in base class
+    * @since Series 60 2.6
+    * @param aAction Action received by CDS.
+    */
+    void ActionReceivedLD( CUpnpAction* aAction );
+    
+    /**
+    * Hnadle unknown http event
+    * Export for interneal use only    
+    */
+    IMPORT_C void UnknownHttpEventReceivedL( CUpnpHttpMessage& aHttpMsg );
+    
+    /**
+    * Handles address change event    
+    */
+    void AddressChangeL();
+    
+    /**
+    * This function is for informing service from evented statevariables.
+    * @since Series 60 2.6
+    * @param aVariableName Name of the evented statevariable.
+    */
+    void StateVariableEvented(const TDesC8& aVariableName);
+      
+    /**
+    * Checks if specified importUri is in database still active.
+    * @param aImportUri uri to be searched in databse. 
+    * @return objId if successful
+    */
+    TInt CheckImportUriL(const TDesC8& aImportUri);
+
+    /**
+    * Inserts Ip and Port
+    * @since Series S60 3.1
+    * @param aString
+    */
+    void InsertRealIpAndPortL(TDes8& aString);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aString
+    * @return descriptor pointer
+    */  
+    HBufC8* InsertIpAndPortPlaceholderL(const TDesC8& aString);
+    
+    /**
+    * Find protocolInfo by importUri (Not by importUri).
+    * @param aImportUri uri to be searched in database (Value of resource).
+    * @return aProtocolInfo related to resorce which has been founded 
+    */  
+    CUpnpDlnaProtocolInfo* GetProtocolInfoByImportUriL(const TDesC8& aImportUri);
+    
+    /**
+    * Gets infomation about protocol
+    * @since Series S60 3.1
+    * @param aContentUri
+    * @parma aProtocolInfo
+    * @return
+    */
+    TInt GetProtocolInfoL(const TDesC8& aContentUri, CUpnpDlnaProtocolInfo*& aProtocolInfo);
+        
+    /**
+    * Gets title of the object with given id from ContentDirectory service. 
+    * @since Series60 2.6
+    * @param aObjectId id of the object.
+    * @param aValue pointer to buffer in which the tilte of the object will be returned.
+    *       Buffer for aValue has to allocated first.
+    **/
+    void GetTitleForUriL( TInt aObjectId, TPtr& aValue );
+        
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aUrlPath
+    * @param aFileName
+    * @param aSystemPath
+    */
+    TInt FindSharedFolderL( const TDesC& aUrlPath, const TDesC& aFileName, HBufC*& aSystemPath);
+        
+    /**
+    *
+    * @since Series S60 3.1
+    * @return TPtrC
+    */
+    const TPtrC MediaRealDir();
+        
+        
+    /**
+    * Sets download directory
+    * @since Series S60 3.1
+    * @param aDownloadDir this directory is going to be set as download directory
+    * @return TInt
+    */
+    void SetDownloadDirectoryL(const TDesC& aDownloadDir);
+        
+    /**
+    * Sets thumbnail directory
+    * @since Series S60 3.1
+    * @param aDownloadDir this directory is going to be set as thumbnail directory
+    * @return TInt
+    */
+    void SetThumbnailDirectoryL(const TDesC& aDownloadDir);    
+    
+    TInetAddr GetAddress();
+    IMPORT_C void SendActionL(CUpnpAction* aAction, TUpnpErrorCode aError);
+    IMPORT_C void SendMessageL( CUpnpHttpMessage* aMessage );
+    CUpnpAutoDestroyObjectList* GetAutoDestroyObjectList();
+    
+    // For internal use only
+    IMPORT_C void HttpTransferEventReceivedL(CUpnpHttpMessage& aHttpMsg);
+    
+    /**
+    * Sends transfer failed event to Media Server       
+    * @param aSessionId transaction identifier
+    * @param aStatusCode HTTP Status code
+    */
+    void NotifyTransferFailL(TInt aSessionId, TInt aStatusCode);
+    
+    /**
+    * Sends transfer stopped event to Media Server       
+    * @param aSessionId transaction identifier
+    * @param aType import/export
+    */
+    void NotifyTransferStoppedL( TInt aSessionId, CUpnpFileTransfer::TTransferType aType);
+
+     // new functions for httptransfer.dll intergration
+    void HttpGetStartedSoapNotifyL(TInt aSessionId);    
+    void HttpPostStartedL(TInt aSessionId);   
+              
+
+    // helper functions
+    TCurrentAction ExecutedAction();
+    void SetExecutedAction(TCurrentAction aAction);
+    
+    
+    /**
+    * This function is a entry point for http messages.
+    * received from Symbian HTTP Stack
+    * @since Series 60 3.2
+    * @param aSessionId identifier of the HTTP request.
+    * @param aHttpStatusCode HTTP error code.
+    */
+    void HttpResponseReceivedL( TInt aSessionId,
+                                TInt aStatusCode);   
+    
+    /**
+    * Getter
+    * @since Series 60 3.2
+    * @return Event Observer
+    */
+    MUpnpContentDirectoryEventObserver* EventObserver();
+    
+public://temporary public methods
+
+    void TransferCompleteL(TInt aResId, TInt aObjId);
+    
+    void TransferProgress( TInt aId, TInt aBytes, TInt aTotalBytes );
+    
+    void TransferStartL(const TDesC8& aImpUri);
+
+    /** 
+    * This fuction removes a TransferID from the TransferIDs Statevariable
+    * @since Series 60 2.6
+    * @param aTransferID a id of file transfer
+    **/
+    void RemoveFileTransferFromTransferIDsStateVariableL(TInt aTransferID);
+    
+    /** 
+    * This fuction adds a TransferID to the TransferIDs Statevariable
+    * @since Series 60 2.6
+    * @param aTransferID a id of file transfer
+    **/
+    void AddFileTransferToTransferIDsStateVariableL( TInt aTransferID );
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aFileName
+    * @return boolean whether given file is drmfile
+    */
+    TBool IsDrmFileL(const TDesC& aFileName);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aFileName
+    * @return boolean whether given file is drmfile
+    */
+    TBool IsDrmFileL(const TDesC8& aFileName);
+    
+
+     /** 
+    * This functions is used for generating correct res tags for finished downloads.
+    * @param aOnlyThumbnail  this method is used during two action - ImportResource and CreateObject. 
+    *                           In CreateObject case res can be created by passed argument so we only thumbail has to be created
+    * @since Series 60 2.6
+    * @return error code. KErrNone if no errors.
+    **/
+    TInt CreateResTagL( TInt aSessionId, 
+                       TDesC8& aFilePath, 
+                        TInt aImportNumber,
+                        TBool aOnlyThumbnail = EFalse  );
+
+
+    /**
+    * Notify transfer          
+    * @param aSessionId HTTP transaction identifier 
+    */    
+    void NotifyOutgoingTransferL (TInt aSessionId); 
+    
+    
+    CUpnpContentDirectoryDb*  ContentDirectoryDb();
+    
+    MUpnpTransferInterface* TransferHandler();
+    
+public: //from MUpnpTransferObserver
+    
+    virtual void TransferCompletedL( TInt akey, TInt aResultCode );
+
+public: //from MUpnpHttpServerTransactionCreator
+
+        IMPORT_C virtual void NewTransactionL(
+        const TDesC8& aMethod, const TDesC8& aUri, 
+        const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans );
+
+private: //form MUpnpHttpServerObserver
+    virtual void HttpEventLD( CUpnpHttpMessage* aMessage );
+    
+private://private methods
+
+
+    void PrepareAutoDestroyObjectL(TXmlEngElement aObject, TInt aObjId);
+
+    /**
+    * Gets ip and port number
+    * @since Series S60 3.1
+    * @return descriptor pointer
+    */
+    HBufC8* GetIpAndPortDes8L();
+
+    /**
+    * Sets size
+    * @since Series S60 3.1
+    * @parma aSize
+    * @parma aFilePath
+    */
+    void SetResSizeL(TXmlEngAttr aSize, const TDesC& aFilePath);
+        
+    /**
+    * Adds Import URI to Element
+    * @since Series S60 3.1
+    * @param aElement
+    */
+    void AddImportUriToElL(TXmlEngElement aElement);
+        
+    /**
+    *
+    * @since Series S60 3.1
+    * @return descriptor pointer
+    */
+    HBufC8* BuildImportUriLC();
+    HBufC8* BuildImportUriShorterLC();
+        
+    /**
+    * Checking whether thumbnail is available
+    * @since Series S60 3.1
+    * @param aFile
+    * @return 
+    **/
+    TBool IsThumbnailAvailableL(const TDesC& aFile);
+    
+    /**
+    * Checking whether thumbnail is available
+    * @since Series S60 3.1
+    * @param aFile 
+    * @return
+    */
+    TBool IsThumbnailAvailableL(const TDesC8& aFile);
+    
+    /**
+    * Creates thumbnail
+    * @since Series S60 3.1
+    * @param a SrcFile
+    * @param aObjId
+    */
+    void CreateThumbnailL(const TDesC& aSrcFile, TInt aObjId);
+    
+    /**
+    * Adds new res tag
+    * @since Series S60 3.1
+    * @param aObjEl 
+    */
+    void AddNewResTagL(TXmlEngElement aObjEl);
+    
+    /**
+    * Creates a name for thumbnail
+    * @since Series S60 3.1
+    * @param aFileName
+    * @return descriptor pointer
+    */
+    HBufC* CreateNameForThumbnailL(const TDesC& aFileName);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aRes
+    */      
+    void HandleLocalResourcesL(TXmlEngElement aRes, TInt aObjectId);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @parma aFileName
+    * @return descriptor pointer
+    */
+    HBufC8* BuildContentUriL(const TDesC& aFileExt, TInt aObjectId);  
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aAction  
+    * @param aSenAndDestroy
+    * @return
+    */
+    TInt DoActionReceivedL( CUpnpAction* aAction );
+    
+    /**
+    * 
+    * since Series S60 3.1
+    * @param aObjs
+    * return descriptor pointer
+    */
+    HBufC8* SerializeObjectsListL(const RArray<RXmlEngDocument>& aObjs);
+              
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aObj
+    * @param aImportUri
+    * @param ANewFile
+    */
+    void DeleteOldResourcesL( RXmlEngDocument& aObj, const TDesC8& aImportUri,
+                              const TDesC& aNewFile );
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @parma aMessage
+    * return descriptor pointer
+    */
+    HBufC8* GetImportUriLC(CUpnpHttpMessage* aMessage);     
+       
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aFileName
+    * @param aNextKey
+    * @return descriptor pointer
+    */
+    HBufC* BuildThumbnailUrlPathL(const TDesC& aFilename, const TDesC& aNextKey);
+
+    /**
+    * This function gets mime type for specified file. 
+    * @since Series 60 3.1
+    * @param aFilename -  filename, for which mimeType will be taken.
+    * @return pointer to variable storing mimeType. 
+    */
+    HBufC8* GetMimeTypeLC(const TDesC8& aFilename);    
+
+    /**
+    * Removes thumbnail creator and corresponding objectId from lists. 
+    * @since Series 60 3.1
+    * @param aThCreator - thumbnail creator for which the information will be deleted.
+    */
+    void RemoveThCreatorAndObjectIdLD( CUpnpThumbnailCreator* aThCreator);
+
+    /**
+    * Gives object id for specified thumbnail creator. 
+    * @since Series 60 3.1
+    * @param aThCreator - thumbnail creator for which object id will be searched for. 
+    * @return object id for specified thumbnail creator. 
+    */
+    TInt GetObjectIdFromThCreator( CUpnpThumbnailCreator* aThCreator);
+
+    /**
+    * Gives this server address in predefined format. 
+    * @since Series 60 3.1
+    * @return pointer to address. 
+    */
+    HBufC8* CreateAddressValueLC();
+
+    /**
+    * This function creates ProtocolInfo object for further use. 
+    * @since Series 60 3.1
+    * @param aMimeType - mime type, for which ProtocolInfo will be created.
+    * @param aAddInfo - additional information which can be choosen according to mime type and image size. 
+    * @return pointer to CProtocolInfo object, which describes all protocolInfo values for this element.
+    */
+    CUpnpDlnaProtocolInfo* CreateProtocolInfoFromMimeL(const TDesC8& aMimeType, TInt aAddInfo );
+
+    /**
+    * This function retrieves title from object description. 
+    * @since Series 60 3.1
+    * @param aObjId - objecty id for which title will be retrieved. 
+    * @return pointer to HBufC, with specified value. 
+    */
+    HBufC* GetFileNameL( TInt aObjId );   
+    HBufC* GetCopyFileNameL( TInt aObjId );  
+    HBufC* GetFileNameWithoutPathL( TInt aObjId );
+    
+    /**
+    * This function add underscore and number to existing filename. 
+    * @since Series 60 3.2
+    * @param aFileName - file that probably exist. 
+    * @return pointer to HBufC, with specified value. 
+    */
+    HBufC* CreateFileNameL( const TDesC16& aFileName );
+   
+    /**
+    * This function puts on stack upnp:class value for specific mime type.  
+    * @since Series 60 3.1
+    * @param aMimeType - mime type from which additional information will be retrieved. 
+    * @return pointer to HBufC8 object with new value, if the type is unknown there is null returned.
+    * Mapping: 
+    * image/* - object.item.imageItem
+    * video/* - object.item.videoItem 
+    * audio/* - object.item.audioItem 
+    * text/* - object.item.textItem 
+    */ 
+    HBufC8* GetItemTypeFromMimeTypeLC(const TDesC8& aMimeType);
+        
+    /**
+    * This function compares upnp:class tag value, with value denoted by aMimeType. 
+    * @since Series 60 3.1
+    * @param obj - object for which needed changes will be applied.
+    * @param aMimeType - mime type from which additional information will be retrieved. 
+    */ 
+    void CheckItemTypeForObjectL( RXmlEngDocument& obj, const TDesC8&  aMimeType );
+        
+  
+    /**
+    * This function returns a XML fragment containing the XML in the parameter
+    * @since Series 60 2.6
+    * @param aBuffer the XML is in this buffer
+    * @return A new CSenDomFragment that is on the cleanup stack
+    */
+    RXmlEngDocument XmlFragmentL(const TDesC8& aBuffer);
+        
+    /**
+    * This fuctions converts one XML element to a string 
+    * @since Series 60 2.6
+    * @param aResp XML string
+    * @param aSen an Sen element to be converted to string
+    */
+    void BrowseElementL( HBufC8*& aResp, TXmlEngElement& aSen );
+
+    /**
+    * This fuctions is a getter for container updateID. 
+    * @since Series 60 2.6
+    * @param aID ID of the container which updateID is returned
+    * @return a updateId of container
+    */
+    TInt ContainerUpdateId( const TDesC8& aContainerID );
+
+
+    /**
+    * Function to add data to metadb
+    * @param aFragment fragment to add to db
+    * @param aContainer container where to add data
+    * @param aId parameter returned by AddToMetaDbL method, stands for item id
+    * @return upnperrorcode descriping situation
+    */
+    TUpnpErrorCode AddToMetaDbL( RXmlEngDocument& aFragment, TInt aContainer, TInt* aId,
+                                 TBool aIsLocal );
+
+    /*
+    *
+    * @since Series S60 3.1
+    * @param aFragment
+    * @param aImportUris
+    * @param aRess
+    * @param aLocal
+    * @param aCreateThumbnailRes
+    * @param aNextKey
+    * @return upnperrorcode descriping situation
+    */
+    TUpnpErrorCode PrepareCreateOperationL( RXmlEngDocument& aFragment, 
+        RArray<TXmlEngAttr>& aImportUris, RArray<TXmlEngElement>& aRess, TBool& aLocal,
+        TBool& aCreateThumbnailRes, TInt& aNextKey );
+
+    /**
+    * Related to CreateObject, resultset of create is created here
+    * @since Series 60 2.6
+    * @param aAction action data structure is needed here
+    * @param aElement element added to db
+    * @param aId element's id
+    **/
+    void ConstructCreateResultsetL( CUpnpAction*& aAction, 
+                                    RXmlEngDocument aElement, 
+                                    TInt aId );
+
+ 
+    /** 
+    * Function for creating a new object
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @return upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode CreateObjectL( CUpnpAction*& aAction );
+    /** 
+    * Function for browsing values of objects
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @return upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode BrowseL( CUpnpAction*& aAction );
+
+    /** 
+    * Function for destroying objects
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @return upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode DestroyObjectL( CUpnpAction*& aAction );
+
+    /** 
+    * Function for creating refense items
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @return upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode CreateReferenceL( CUpnpAction*& aAction );
+
+    /** 
+    * Function to solve CDS's search capabilities
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @retrun upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode GetSearchCapabilitiesL( CUpnpAction*& aAction );
+
+    /** 
+    * Function to solve CDS's sort capabilities
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @return upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode GetSortCapabilitiesL( CUpnpAction*& aAction );
+
+    /** 
+    * Getter for CDS's SystemUpdateID
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @return upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode GetSystemUpdateIdL( CUpnpAction*& aAction );
+
+    /** 
+    * Function for importing resources
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @return upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode ImportResourceL( CUpnpAction*& aAction );
+
+    /** 
+    * Function for exporting resources
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @return upnperrorcode descriping situation
+    */
+    TUpnpErrorCode ExportResourceL( CUpnpAction*& aAction );
+
+    /** 
+    * Function for stopping ongoing file transfer (import / export)
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @retrun upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode StopTransferResourceL( CUpnpAction*& aAction );
+
+    /** 
+    * Function for getting information about ongoing file transfer
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @return upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode GetTransferProgressL( CUpnpAction*& aAction );
+
+    /** 
+    * This functions removes a "res" tag from a object
+    * @since Series 60 2.6
+    * @param aAction received action
+    * @return upnperrorcode descriping situation
+    **/
+    TUpnpErrorCode DeleteResourceL( CUpnpAction*& aAction );
+
+    /**
+    * This function changes file name and its extension. 
+    * @since Series 60 3.1
+    * @param aFilePath - the target file. 
+    * @param aMimeType - mime type, for which file extension will be choosen. 
+    */
+    HBufC8* ChangeFileNameWithExtensionL(TDesC8& aFilePath, const TDesC8& aMimeType );
+ 
+ 
+   
+    /**
+    * @param aOnlyThumbnail  this method is used during two action - ImportResource and CreateObject. 
+    *           In CreateObject case res can be created by passed argument so we only thumbail has to be created
+    */
+    TInt CreateResTagInternalL( TInt aSessionId, 
+                                TDesC8& aFilePath,
+                                HBufC8* aImportUri, 
+                                TBool aOnlyThumbnail );
+
+    /**
+    * calls CreateResTagInternalL but KErrCorrupted is TRAPed in order to invoke recovery on DB
+    */
+    TInt CreateResTagInternalWithDBRecoveryL( TInt aSessionId,
+                                              TDesC8& aFilePath, 
+                                              HBufC8* aImportUri, 
+                                              TBool aOnlyThumbnail = EFalse );
+    
+private:    // New functions    
+
+   
+    void DoSendActionL(CUpnpAction* aAction, TUpnpErrorCode aError);
+    void DoSendMessageL(CUpnpHttpMessage* aMessage);
+    TBool IsValidUrlPath(const TDesC& aUrlPath);
+    
+    /**
+    * Gets protocolInfo from mimeType.
+    * @param aMimeType mime type for which protocolInfo will be created.
+    * @return string with protocolInfo
+    */
+    HBufC8* ProtocolInfoFromMimeL( const TDesC8& aMimeType, TInt aAddInfo, TBool aOpRangeParam,
+                                   TBool aCiParam = EFalse );
+
+    HBufC8* ProtocolInfoFromMimeL(const TDesC8& aMimeType, TXmlEngElement& aResEl);
+    
+    /**
+    * Notify message when the thumbnail creation has been finished. 
+    * From MUpnpThumbnailCreatorObserver interface.
+    * @param aThCreator this is a thumbnail creator.
+    * @param aResult result from thumbnail creation.
+    */
+    void NotifyThumbnailResultL( CUpnpThumbnailCreator* aThCreator, TInt aResult );
+
+    /**
+    * Notify message when the thumbnail creation has been finished. 
+    * From MUpnpThumbnailCreatorObserver interface.
+    * @param aThCreator this is a thumbnail creator.
+    * @param aResult result from thumbnail creation.
+    */
+    CUpnpThumbnailCreator* CreateThumbnailCreatorL(TInt aObjectId);
+    
+    /**
+    * Cheks if object exists.
+    * @param aObjectId
+    */
+    TBool IsObjectExistL( TInt aObjectId );
+    
+    /**
+    * Cheks if object is valid.
+    * if object doesn't exist or has no parent 
+    * object is removed from autodestoy table and EFalse is returned
+    * @param aObjectId
+    */
+    TBool ValidateObjectL( TInt aObjectId );
+         
+    /**
+    * Handles DB error
+    * Tries to recover, if fails tries to recreate
+    * @since Series S60 3.2
+    * @return TInt - KErrNone if succeed
+    */
+    TInt HandleDbError( TInt aError );
+    
+    /**
+    * Checks DB and disk Space
+    * Tries to recover DB, if fails tries to recreate
+    * @since Series S60 3.2
+    * @param aAction received action
+    * @return EFalse if succeed
+    */
+    TBool IsDbOrDiskProblemL( CUpnpAction* aAction );
+    
+    /**
+    * Determines if DB has benn recovered successfully
+    * returns ETrue if yes
+    * @param a Error - DB is revovered only if aError equal KErrCorrupted
+    * @since Series S60 3.2
+    * @returns ETrue if succeed 
+    */
+    TBool DataBaseHasBeenRecoveredL( TInt aError );
+    
+    /**
+    * Returns DB creation status
+    * @since Series S60 3.2
+    * @return TBool
+    */
+    TBool IsDbCreated(); 
+
+    /**
+    * Updates import URI
+    * @since Series S60 3.2
+    * @return TPtrC8
+    */
+    TPtrC8 UpdateImportUriL( const TDesC8& aImportUri );
+    
+private: // Constructors
+    
+    /**
+    * C++ default constructor.
+    */
+    CUpnpContentDirectory( CUpnpDevice& aDevice, 
+                           MUpnpThumbnailCreatorObserver* aThmbObs,
+                           MUpnpTransferInterface* aTransfer
+                         );
+
+    /**
+    * Second phase of the constructor.
+    * Initialises a DOM tree.
+    * By default Symbian 2nd phase constructor is private.
+    * @param service Parent service
+    */
+    void ConstructL( TUpnpCdSettings aSettings, 
+                     CUpnpMetadataStorage* aMetadataStorage 
+                   );
+    
+    void ConstructHttpL();
+    
+private:
+    
+    //Array containing objects ids, which will be updated after Thumbnail creation.
+    RArray<TInt> iThObjectIds;
+    
+    // Array of thumbnail creators in which creators can be searched for.
+    RPointerArray<CUpnpThumbnailCreator> iThumbnailCreators;
+
+    // Next free object ID, owned
+    TInt iNextFreeID;
+
+    // Pointerarray for pending actions (used in Import and Export), owned
+    //RPointerArray<CUpnpAction> iPendingActions;
+
+    // Elementfactory, owned
+    CUpnpElementFactory* iElementdb;
+    
+       
+    // Database
+    CUpnpContentDirectoryDb* iContentDirectoryDb;
+        
+    // file session
+    RFs iFs;
+    
+    // Download directory
+    HBufC* iDownloadDir;
+    
+   // Thumbnail directory
+    HBufC* iThumbDir;
+    // connection try to bitmap and font server. 
+    // if there is no such connection there will be no thumbcreated. 
+    TInt iBitmapServerConnection;
+        
+    TBool iEcomUsed;
+        
+    // Thumbnail creator observer
+    MUpnpThumbnailCreatorObserver* iThmbObs;
+
+    // auto-destroy object list    
+    CUpnpAutoDestroyObjectList* iAutoDestroyObjects;
+
+    
+    // Event observer
+    MUpnpContentDirectoryEventObserver* iEventObserver;
+    
+    // Thumbnail creation flag
+    TBool iCreateThumbnails; 
+    
+    // Max number of browsed object
+    TInt iMaxRequestCount;
+
+    TCurrentAction iCurrentAction;
+    
+    RXmlEngDOMImplementation iDOMImpl;
+    
+    MUpnpCdsSender* iSender; // not owned
+        
+    CUpnpMimeMapper* iMimeToExtMap;
+        
+    HBufC* iObjectsXmlPath;
+    
+    CUpnpStateHandler* iStateHandler;
+         
+
+    CUpnpTransferController* iTransferController;
+    
+    MUpnpTransferInterface* iTransferHandler;
+    
+    CUpnpDlnaFilter* iDlnaFilter;
+    
+    CUpnpHttpServerSession* iHttpServerSession;
+    
+    CUpnpSecurityManager* iSecurityManager;
+    
+    };
+
+#endif  // C_CUPNPCONTENTDIRECTORY_H
+
+// End Of File
--- a/upnpmediaserver/contentdirectoryservice/inc/upnpcontentdirectorydb.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/inc/upnpcontentdirectorydb.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,591 +1,591 @@
-/** @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:  Database for MediaServer
-*
-*/
-
-
-
-#ifndef C_CUPNPCONTENTDIRECTORYDB_H
-#define C_CUPNPCONTENTDIRECTORYDB_H
-
-//  INCLUDES
-#include <e32base.h>
-#include <d32dbms.h>
-#include <s32file.h>
-#include <flogger.h>
-#include <upnperrors.h>
-#include <xml/dom/xmlengdom.h>
-
-
-// CLASS DECLARATION
-class CUpnpElementBean;
-class CUpnpFilterElement;
-class CUpnpAttributeBean;
-class CUpnpObjectBean;
-class CUpnpDlnaProtocolInfo;
-class CUpnpShareMapBean;
-class CUpnpResourcesBean;
-class CUpnpMetadataStorage;
-
-
-
-/**
-*  Database for AVContentDirectory.
-*  Implements a database which is used to store descriptors of shared content.
-*
-*  @lib ContentDirectoryDb.lib
-*  @since Series 60 3.0
-*/
-class CUpnpContentDirectoryDb : public CBase
-{
- public:  // Constructors and destructor
- 
-    /**
-    * Two-phased constructor.
-    */
-    static CUpnpContentDirectoryDb* NewLC(CUpnpMetadataStorage* aMetadataStorage);
-    static CUpnpContentDirectoryDb* NewL(CUpnpMetadataStorage* aMetadataStorage);
-
-    /**
-    * Destructor
-    */
-    ~CUpnpContentDirectoryDb();
-    
- public: // New functions
-    
-    /**
-    * Checks if object with the given id exists, is a container and its 'restricted' attribute has value of 'false'
-    * @since Series S60 3.0
-    * @param aObjId id of the object to be checked
-    * @return returns EUpnpOk if object with the given id exists in database and is a "non restricted conainer"
-    */
-    TUpnpErrorCode CheckObjectRestrictionL(TInt aObjId);
-
-    /**
-    * Inserts object into database 
-    * @since Series S60 3.0
-    * @param aFragment RDocuemnt of the document to be added to database
-    * @param aId id of the object  
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode InsertObjectL( RXmlEngDocument& aFragment, TInt aContainer, TInt* aId);
-    
-    /**
-    * Function returns DIDL-Lite XML fragment with metadata for requested object.
-    * IMPORTANT: 1. Caller takes responsibility for returned document and is 
-    *               obliged to close it.
-    *        2. The root element of the document is <DIDL-Lite> element and
-    *               the object's element is its direct, onluy child.
-    * @param aObjectID id of requested object.
-    * @param aDoc handler to document containing object's metadata.
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode GetObjectL( TInt aObjectID, RXmlEngDocument& aDoc, 
-                               const TDesC8& aFilterString);
-                    
-    /**
-    * Gets id of reffered object 
-    * @since Series S60 3.0
-    * @param aObjectId object id
-    * @return reffered object id.
-    */
-    TInt ReferedObjectIdL( TInt aObjectId );
-    
-    /**
-    * Gets object list
-    * @since Series S60 3.1
-    * @param aParentId
-    * @parem aList
-    * @return upnperrorcode descriping situation
-    */
-    TUpnpErrorCode GetObjectListL(TInt aParentId, RArray<TInt>& aList);
-    
-    /**
-    * Deletes object from database
-    * @since Series S60 3.0
-    * @param aObjId id of the object to be deleted
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode DeleteObjectL(TInt aObjId,RArray<TInt>& aRefList, TBool aDeleteResource=ETrue);
-    
-    /**
-    * Updates the metadata of the object with specified id
-    * @since Series S60 3.0
-    * @param aObjId id of the object to be updated
-    * @param  aFragment XML DOM tree with the updated object's metadata
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode UpdateObjectL(TInt aObjId, RXmlEngDocument& aFragment);
-    
-
-    /**
-    * Deletes the res elements with the specified value.
-    * @since Series S60 3.0
-    * @param aResVal value of the res element which is to be deleted
-    * @param aTumbailResVal value of the thumbail res element which is to be deleted
-    */
-    void DeleteResourceL(const TDesC8& aResVal, RArray<TInt>& aContIds);
-
-    /**
-    * Gets object by its attribute value.
-    * @since Series S60 3.0
-    * @param aDoc on return, it contains the object's data
-    * @param aObjId on, return it contains the object's id
-    * @param aAttrName attribute's name
-    * @param aAttrVal attribute's value
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode GetObjectByAttrL(RXmlEngDocument& aDoc, TInt* aObjId, 
-                                    const TDesC8& aAttrName, const TDesC8& aAttrVal);   
-
-    /**
-    * Checks the restrictions of the parent object of the given object.
-    * @since Series S60 3.0
-    * @param aObjId object's id
-    * @return returns EUpnpOk if object with the given id exists in database and is a "non restricted conainer"    
-    */
-    TUpnpErrorCode CheckParentRestrictionL(TInt aObjId);
-
-    /**
-    * Gets the object id by its attribute value.
-    * @since Series S60 3.0
-    * @param aAttrName attribute's name
-    * @param aAttrVal attribute's value
-    * @return object's id
-    */
-    TInt GetObjIdByAttrL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
-
-    /**
-    * Gets the object id by its attribute value. Uses LIKE operator for comparison
-    * @since Series S60 3.0
-    * @param aAttrName attribute's name
-    * @param aAttrVal attribute's value
-    * @return object's id
-    */
-    TInt GetObjIdByAttrLikeL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
-
-
-    /**
-    * Prepares a new RXmlEngDocument with DIDL-Lite element 
-    * @since Series S60 3.0
-    * @return Returns just created document
-    */
-    RXmlEngDocument PrepareDidlDocumentL();
-    
-    
-    /**
-    * Find protocolInfo by contentUri (Not by importUri).
-    * @param aContentUri uri to be searched in database (Value of resource).
-    * @param aProtocolInfo ProtocolInfo related to resorce which has been founded. Ownership is transfered to the caller.
-    * @return KErrNone if successful, otherwise another of the system-wide error codes 
-    */
-    TInt GetProtocolInfoL(const TDesC8& aContentUri, CUpnpDlnaProtocolInfo*& aProtocolInfo); // virtual
-
-    
-    /**
-    * Gets object list
-    * @since Series S60 3.1
-    * @param aIds
-    * @param aFilter
-    * @param aObjs
-    * @return upnperrorcode descriping situation
-    */
-    void GetObjectListL(const RArray<TInt>& aIds, const TDesC8& aFilter, RArray<RXmlEngDocument>& aObjs);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aObjId
-    * @return boolean whether can be nested
-    */
-    TBool CanBeNestedL(TInt aObjId);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aResBean
-    */
-    void AddResourceL(CUpnpResourcesBean* aResBean, TInt aObjId);
-    
-    /**
-    * Deletes resource
-    * @since Series S60 3.1
-    * @param aResId
-	* @param aDeleteFile
-    */
-    void DeleteResourceByResIdL(TInt64 aResId, TBool aDeleteFile = ETrue);
-    
-    /**
-    * Deletes resource
-    * @since Series S60 3.1
-    * @param aResId
-	* @param aDeleteFile
-    */
-    void DeleteResourceByObjIdL(TInt aObjId, TBool aDeleteFile = ETrue);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aOldDir
-    */
-    void NewMediaDirectoryL(const TDesC& aOldDir);
-    
-    /**
-    * Gets resource
-    * @since Series S60 3.1
-    * @param aResId
-    * @return pointer to CUpnpResourceBean
-    */
-    CUpnpResourcesBean* GetResourceL(TInt64 aResId);
-    
-    /**
-    * Gets attribute
-    * @since Series S60 3.1
-    * @param aElmId
-    * @param aAttrName
-    * @param aAttrVal
-    * @return pointer to CUpnpAttributesBean
-    */
-    CUpnpAttributeBean* GetAttrByNameL(TInt aElmId, const TDesC8& aAttrName, HBufC8*& aAttrVal);
-    
-    /**
-    * Gets attribute
-    * @since Series S60 3.1
-    * @param aAttrName
-    * @param aAttrVal
-    * @return pointer to CUpnpAttributeBean
-    */
-    CUpnpAttributeBean* GetAttrByValueL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
-    
-    /**
-    * Gest protocol info
-    * @since Series S60 3,1
-    * @param aImportUri
-    * @return descriptor pointer
-    */
-    HBufC8* GetProtocolInfoByImportUriL(const TDesC8& aImportUri);
-    
-    
-    /**
-    * Getter
-    * @since Series S60 3.1
-    * @return TInt
-    */
-    TInt GetKeyForUriL();
-    
-    /**
-    * Gets first object ID by element value
-    * @param aElmName - element name
-    * @param aElmValue - element value
-    * @return object ID
-    */
-    TInt GetObjectIdByElementValueLikeL(const TDesC8& aElmName, const TDesC8& aElmValue);
-
-    /**
-    * Gets the parent object's id of the object with given id.
-    * @since Series S60 3.1
-    * @param aObjectId child object id
-    * @return parentid
-    */
-    TInt GetParentIdL(TInt aObjectId);
-    /**
-    * Gets the next object's id .
-    * @since Series S60 3.1
-    * @return id
-    */
-    TInt GetObjectIdL();
-    /**
-    * Gets the next object's id .
-    * @since Series S60 3.1
-    * @return id
-    */
-    HBufC8* GetObjectTitleL(TInt aId);
-
-   /**
-    * Checks if database have propper columns in each table.
-    * If not it leaves with KErrCorrupt.
-    * @since Series S60 3.2
-    */
-    void CheckDatabaseL();  
-    
-   /**
-    * Handles DB error
-    * Tries to recover, if fails tries to recreate
-    * @since Series S60 3.2
-    * @return TInt - KErrNone if succed
-    */
-    TInt HandleDbError( TInt aError );
-
-    /**
-    * Recreates the database file.
-    * @since Series S60 3.1
-    */
-    TInt RecreateDatabaseFile();
-    
-    /**
-    * Returns DB creation status
-    * @since Series S60 3.2
-    * @return TBool
-    */
-    TBool IsDbCreated();
-
- private:
-    
-    /**
-    * Getter
-    * @since Series S60 3.1
-    * @param aObjId
-    * @return pointer to CUpnpObjectBean
-    */
-    CUpnpObjectBean* GetObjBeanLC(TInt aObjId);
-    
-    /**
-    * Gets object
-    * @since Series S60 3.1
-    * @param aIns
-    * @param AresVal
-    */
-    void GetObjectsByResourceL(RArray<TInt>& aIds, const TDesC& aResVal);
-       
-      
-    /**
-    * Gets element
-    * @since Series S60 3.1
-    * @param aElmName
-    * @param ElmValue
-    * @return TInt
-    */
-    TInt GetElmIdByNameAndValL(const TDesC& aElmName, const TDesC& aElmValue);
-    
-    /**
-    * Gets attribute
-    * @since Series S60 3.1
-    * @param aElmId
-    * @param aAttrName
-    * @param aAttrValue
-    */
-    void GetAttrValueByNameL(TInt aElmId, const TDesC8& aAttrName, HBufC8*& aAttrVal);
-
-    /**
-    * Performs resource deletion of the object being destroyed
-    * @since Series S60 3.0
-    * @param aObjId aObjId id of the object being destroyed
-    * @param aObjId aCd pointer to the ContentDirectory object - it provides a function which deletes
-    *                  a file from the private directory
-    */
-    void DeleteResourcesL(TInt aObjId);
-
-    /**
-    * Performs the DeleteResource operation. 
-    * Deletes each res element with the value of aResVal and corresponding thumnail res elements
-    * @since Series S60 3.0
-    * @param aResVal value of the res whis is to be deleted
-    * @param aThumbailResVal value of the thumbail res whis is to be deleted
-    */
-    void DoDeleteResourceL(const TDesC8& aResVal, RArray<TInt>& aContIds);
-
-
-    /**
-    * Sets the childCount attribute in the given object's element.
-    * @since Series S60 3.0
-    * @param aElement object's element
-    * @param aId object's id
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    void SetChildCountL(TXmlEngElement aElement, TInt aId);
-    
-    /**
-    * Adds all (existing in the database) properties to the object's element.
-    * @since Series S60 3.0
-    * @param aElement object's element
-    * @param aObjBean object table description object
-    */
-    void AddAllPropertiesL(TXmlEngElement aElement, CUpnpObjectBean* aObjBean);
-
-    /**
-    * Adds new attribute to the element.
-    * @since Series S60 3.0
-    * @param aElement object's element
-    * @param aAttrName the name of the attribute which is to be added
-    * @param aElementId id of the element which the attribute belongs to
-    * @param aObjectId id of the object which the elements belongs to
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    void AddAttributeL( TXmlEngElement aElement, const TDesC8& aAttrName, TInt aElementId, TInt aObjectId );
-
-    /**
-    * Adds a requested properties to the object's element.
-    * @since Series S60 3.0
-    * @param aObjectID object's id
-    * @param aElement an array containing filter elements of the requested property
-    * @param aFilterElements ?description
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode AddRequestedPropertiesL(TInt aObjectID,TXmlEngElement aElement,
-                                           const RPointerArray<CUpnpFilterElement>& aFilterElements);
-
-    /**
-    * Adds requested element to the object's element.
-    * @since Series S60 3.0
-    * @param aElement an element wich we want to add a new element to
-    * @param aObjectID id of the object
-    * @param aReqElement filter object of the element to be added
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    void AddElementL(TXmlEngElement aElement, TInt aObjectID, const CUpnpFilterElement* aReqElement);
-
-    /**
-    * Adds required property to the object.
-    * @since Series S60 3.0
-    * @param aElement TXmlEngElement of the object which is to be added the required property
-    * @param aObjId id of the object being processed
-    * @param aFilterElement CUpnpFilterElement object of the property to be added
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode AddRequiredPropertyL(TXmlEngElement aElement, TInt aObjId, CUpnpFilterElement* aFilterElement);
-    
-    /**
-    * Parses filter string.
-    * @since Series S60 3.0
-    * @param aFilter filter string to be parsed
-    * @param aList  On return, contains CFilterElements objects of the filter string
-    */
-    void ParseFilterStringL(const TDesC8& aFilter, RPointerArray<CUpnpFilterElement>& aList);
-
-    /**
-    * Performs get object operation.
-    * @since Series S60 3.0
-    * @param aObjectID id of requested object.
-    * @param aDoc handler to document containing object's metadata.
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode DoGetObjectL(TInt aObjectID, RXmlEngDocument& aDoc, TBool aAll);
- 
-    /**
-    * Inserts element into database 
-    * @since Series S60 3.0
-    * @param aElementel TXmlEngElement of the element to be inserted
-    * @param aObjId id of the object this element belongs to
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode InsertElementL(const TXmlEngElement& aElementel, TInt aObjId);
- 
-    /**
-    * Performs object update; a transaction should be started before calling this function
-    * @since Series S60 3.0
-    * @param aObjId id of the object to be updated
-    * @param  aFragment XML DOM tree with the updated object's metadata
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode DoUpdateObjectL(TInt aObjId, TXmlEngElement aFragment);
-
-    /**
-    * Inserts updated object into database
-    * @since Series S60 3.0
-    * @param aObjId id of the object
-    * @param  aFragment XML DOM tree with the updated object's metadata
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode InsertUpdatedL(TInt aObjId, TXmlEngElement& aElement);
-
-    /**
-    * Sets the id attribute in the given object; adds attribute if does not exist
-    * @since Series S60 3.0
-    * @param aElement TXmlEngElement of the object
-    * @return value of the id
-    */
-    TInt SetObjectIdL(TXmlEngElement& aElement);
-
-    /**
-    * Inserts object into database; a transaction should be started before calling this function 
-    * @since Series S60 3.0
-    * @param param descr
-    * @return EUpnpOk, if successful; Leaves if the object could not be inserted into the database
-    *     In case it leaves the transaction must be rolled back
-    */
-    TUpnpErrorCode DoInsertObjectL( TXmlEngElement& aElement, TInt aContainerId, TInt* aId);
-
-
-    
-    /**
-    * Inserts attributes of the given element into the database
-    * @since Series S60 3.0
-    * @param aElement TXmlEngElement of the element 
-    * @param aElmId id of the element
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode InsertAttributesL(const TXmlEngElement aElement, TInt aElmId,TInt aObjId);
-    
-
-    /**
-    * Checks if the given attribute has a corresponding marker attr in the given array
-    * @since Series S60 3.0
-    * @param aAttr TXmlEngAttr of the attribute to be chceck
-    * @param aMarkers an array containing marker attributes
-    * @return ETrue if the attribute is required, otherwise EFalse
-    */
-    TBool IsAttrRequiredL(const TXmlEngAttr& aAttr, RArray<TXmlEngAttr>& aMarkers);
-
-    /**
-    * C++ default constructor.
-    */
-    CUpnpContentDirectoryDb(CUpnpMetadataStorage* aMetadataStorage);
-
-    /**
-    * By default Symbian 2nd phase constructor is private.
-    */
-    void ConstructL();
-
-    /**
-    * If data base file is present it just opens it, 
-    * otherwise creates new database storage file.
-    * @since Series S60 3.0
-    * @param aDatabaseFileName name of storage file
-    */
-    void ConstructDbL(const TFileName& aDatabaseFileName);
-    
-    /**
-    * Opens existing database.
-    * @since Series S60 3.0
-    * @param aDatabaseFileName name of storage file
-    */
-    void OpenDbL( const TFileName& aDatabaseFileName );
-    
-    /**
-    * Adds elements that are children of inquired object to passed DOM TXmlEngElement.
-    * @param aObjectID - id of the object, which child elements will be added.
-    * @param aObjectElement - element to which the elements will be added.
-    */
-    void AddElementsL( TInt aObjectID, TXmlEngElement aObjectElement, TBool aAll );
-    
-    /**
-    * Adds attributes to passed DOM TXmlEngElement.
-    * @param aElementID - id of the element, which attributes will be added.
-    * @param aObjectId id of the object which the elements belongs to
-    * @param aElement - element to which the attributes will be added.
-    */
-    void AddAttributesL( TInt aElementID, TInt aObjectID, TXmlEngElement& aElement, TBool aAll );
-    
-
-    
-
- private:    // Data
-    CUpnpMetadataStorage* iMetadataStorage; // not owned
-    RXmlEngDOMImplementation iDOMImpl;
- };
-
-#endif //CCONTENTDIRECTORYDB_H
-
-// End Of File
+/** @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:  Database for MediaServer
+*
+*/
+
+
+
+#ifndef C_CUPNPCONTENTDIRECTORYDB_H
+#define C_CUPNPCONTENTDIRECTORYDB_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <d32dbms.h>
+#include <s32file.h>
+#include <flogger.h>
+#include <upnperrors.h>
+#include <xmlengdom.h>
+
+
+// CLASS DECLARATION
+class CUpnpElementBean;
+class CUpnpFilterElement;
+class CUpnpAttributeBean;
+class CUpnpObjectBean;
+class CUpnpDlnaProtocolInfo;
+class CUpnpShareMapBean;
+class CUpnpResourcesBean;
+class CUpnpMetadataStorage;
+
+
+
+/**
+*  Database for AVContentDirectory.
+*  Implements a database which is used to store descriptors of shared content.
+*
+*  @lib ContentDirectoryDb.lib
+*  @since Series 60 3.0
+*/
+class CUpnpContentDirectoryDb : public CBase
+{
+ public:  // Constructors and destructor
+ 
+    /**
+    * Two-phased constructor.
+    */
+    static CUpnpContentDirectoryDb* NewLC(CUpnpMetadataStorage* aMetadataStorage);
+    static CUpnpContentDirectoryDb* NewL(CUpnpMetadataStorage* aMetadataStorage);
+
+    /**
+    * Destructor
+    */
+    ~CUpnpContentDirectoryDb();
+    
+ public: // New functions
+    
+    /**
+    * Checks if object with the given id exists, is a container and its 'restricted' attribute has value of 'false'
+    * @since Series S60 3.0
+    * @param aObjId id of the object to be checked
+    * @return returns EUpnpOk if object with the given id exists in database and is a "non restricted conainer"
+    */
+    TUpnpErrorCode CheckObjectRestrictionL(TInt aObjId);
+
+    /**
+    * Inserts object into database 
+    * @since Series S60 3.0
+    * @param aFragment RDocuemnt of the document to be added to database
+    * @param aId id of the object  
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode InsertObjectL( RXmlEngDocument& aFragment, TInt aContainer, TInt* aId);
+    
+    /**
+    * Function returns DIDL-Lite XML fragment with metadata for requested object.
+    * IMPORTANT: 1. Caller takes responsibility for returned document and is 
+    *               obliged to close it.
+    *        2. The root element of the document is <DIDL-Lite> element and
+    *               the object's element is its direct, onluy child.
+    * @param aObjectID id of requested object.
+    * @param aDoc handler to document containing object's metadata.
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode GetObjectL( TInt aObjectID, RXmlEngDocument& aDoc, 
+                               const TDesC8& aFilterString);
+                    
+    /**
+    * Gets id of reffered object 
+    * @since Series S60 3.0
+    * @param aObjectId object id
+    * @return reffered object id.
+    */
+    TInt ReferedObjectIdL( TInt aObjectId );
+    
+    /**
+    * Gets object list
+    * @since Series S60 3.1
+    * @param aParentId
+    * @parem aList
+    * @return upnperrorcode descriping situation
+    */
+    TUpnpErrorCode GetObjectListL(TInt aParentId, RArray<TInt>& aList);
+    
+    /**
+    * Deletes object from database
+    * @since Series S60 3.0
+    * @param aObjId id of the object to be deleted
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode DeleteObjectL(TInt aObjId,RArray<TInt>& aRefList, TBool aDeleteResource=ETrue);
+    
+    /**
+    * Updates the metadata of the object with specified id
+    * @since Series S60 3.0
+    * @param aObjId id of the object to be updated
+    * @param  aFragment XML DOM tree with the updated object's metadata
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode UpdateObjectL(TInt aObjId, RXmlEngDocument& aFragment);
+    
+
+    /**
+    * Deletes the res elements with the specified value.
+    * @since Series S60 3.0
+    * @param aResVal value of the res element which is to be deleted
+    * @param aTumbailResVal value of the thumbail res element which is to be deleted
+    */
+    void DeleteResourceL(const TDesC8& aResVal, RArray<TInt>& aContIds);
+
+    /**
+    * Gets object by its attribute value.
+    * @since Series S60 3.0
+    * @param aDoc on return, it contains the object's data
+    * @param aObjId on, return it contains the object's id
+    * @param aAttrName attribute's name
+    * @param aAttrVal attribute's value
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode GetObjectByAttrL(RXmlEngDocument& aDoc, TInt* aObjId, 
+                                    const TDesC8& aAttrName, const TDesC8& aAttrVal);   
+
+    /**
+    * Checks the restrictions of the parent object of the given object.
+    * @since Series S60 3.0
+    * @param aObjId object's id
+    * @return returns EUpnpOk if object with the given id exists in database and is a "non restricted conainer"    
+    */
+    TUpnpErrorCode CheckParentRestrictionL(TInt aObjId);
+
+    /**
+    * Gets the object id by its attribute value.
+    * @since Series S60 3.0
+    * @param aAttrName attribute's name
+    * @param aAttrVal attribute's value
+    * @return object's id
+    */
+    TInt GetObjIdByAttrL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
+
+    /**
+    * Gets the object id by its attribute value. Uses LIKE operator for comparison
+    * @since Series S60 3.0
+    * @param aAttrName attribute's name
+    * @param aAttrVal attribute's value
+    * @return object's id
+    */
+    TInt GetObjIdByAttrLikeL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
+
+
+    /**
+    * Prepares a new RXmlEngDocument with DIDL-Lite element 
+    * @since Series S60 3.0
+    * @return Returns just created document
+    */
+    RXmlEngDocument PrepareDidlDocumentL();
+    
+    
+    /**
+    * Find protocolInfo by contentUri (Not by importUri).
+    * @param aContentUri uri to be searched in database (Value of resource).
+    * @param aProtocolInfo ProtocolInfo related to resorce which has been founded. Ownership is transfered to the caller.
+    * @return KErrNone if successful, otherwise another of the system-wide error codes 
+    */
+    TInt GetProtocolInfoL(const TDesC8& aContentUri, CUpnpDlnaProtocolInfo*& aProtocolInfo); // virtual
+
+    
+    /**
+    * Gets object list
+    * @since Series S60 3.1
+    * @param aIds
+    * @param aFilter
+    * @param aObjs
+    * @return upnperrorcode descriping situation
+    */
+    void GetObjectListL(const RArray<TInt>& aIds, const TDesC8& aFilter, RArray<RXmlEngDocument>& aObjs);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aObjId
+    * @return boolean whether can be nested
+    */
+    TBool CanBeNestedL(TInt aObjId);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aResBean
+    */
+    void AddResourceL(CUpnpResourcesBean* aResBean, TInt aObjId);
+    
+    /**
+    * Deletes resource
+    * @since Series S60 3.1
+    * @param aResId
+	* @param aDeleteFile
+    */
+    void DeleteResourceByResIdL(TInt64 aResId, TBool aDeleteFile = ETrue);
+    
+    /**
+    * Deletes resource
+    * @since Series S60 3.1
+    * @param aResId
+	* @param aDeleteFile
+    */
+    void DeleteResourceByObjIdL(TInt aObjId, TBool aDeleteFile = ETrue);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aOldDir
+    */
+    void NewMediaDirectoryL(const TDesC& aOldDir);
+    
+    /**
+    * Gets resource
+    * @since Series S60 3.1
+    * @param aResId
+    * @return pointer to CUpnpResourceBean
+    */
+    CUpnpResourcesBean* GetResourceL(TInt64 aResId);
+    
+    /**
+    * Gets attribute
+    * @since Series S60 3.1
+    * @param aElmId
+    * @param aAttrName
+    * @param aAttrVal
+    * @return pointer to CUpnpAttributesBean
+    */
+    CUpnpAttributeBean* GetAttrByNameL(TInt aElmId, const TDesC8& aAttrName, HBufC8*& aAttrVal);
+    
+    /**
+    * Gets attribute
+    * @since Series S60 3.1
+    * @param aAttrName
+    * @param aAttrVal
+    * @return pointer to CUpnpAttributeBean
+    */
+    CUpnpAttributeBean* GetAttrByValueL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
+    
+    /**
+    * Gest protocol info
+    * @since Series S60 3,1
+    * @param aImportUri
+    * @return descriptor pointer
+    */
+    HBufC8* GetProtocolInfoByImportUriL(const TDesC8& aImportUri);
+    
+    
+    /**
+    * Getter
+    * @since Series S60 3.1
+    * @return TInt
+    */
+    TInt GetKeyForUriL();
+    
+    /**
+    * Gets first object ID by element value
+    * @param aElmName - element name
+    * @param aElmValue - element value
+    * @return object ID
+    */
+    TInt GetObjectIdByElementValueLikeL(const TDesC8& aElmName, const TDesC8& aElmValue);
+
+    /**
+    * Gets the parent object's id of the object with given id.
+    * @since Series S60 3.1
+    * @param aObjectId child object id
+    * @return parentid
+    */
+    TInt GetParentIdL(TInt aObjectId);
+    /**
+    * Gets the next object's id .
+    * @since Series S60 3.1
+    * @return id
+    */
+    TInt GetObjectIdL();
+    /**
+    * Gets the next object's id .
+    * @since Series S60 3.1
+    * @return id
+    */
+    HBufC8* GetObjectTitleL(TInt aId);
+
+   /**
+    * Checks if database have propper columns in each table.
+    * If not it leaves with KErrCorrupt.
+    * @since Series S60 3.2
+    */
+    void CheckDatabaseL();  
+    
+   /**
+    * Handles DB error
+    * Tries to recover, if fails tries to recreate
+    * @since Series S60 3.2
+    * @return TInt - KErrNone if succed
+    */
+    TInt HandleDbError( TInt aError );
+
+    /**
+    * Recreates the database file.
+    * @since Series S60 3.1
+    */
+    TInt RecreateDatabaseFile();
+    
+    /**
+    * Returns DB creation status
+    * @since Series S60 3.2
+    * @return TBool
+    */
+    TBool IsDbCreated();
+
+ private:
+    
+    /**
+    * Getter
+    * @since Series S60 3.1
+    * @param aObjId
+    * @return pointer to CUpnpObjectBean
+    */
+    CUpnpObjectBean* GetObjBeanLC(TInt aObjId);
+    
+    /**
+    * Gets object
+    * @since Series S60 3.1
+    * @param aIns
+    * @param AresVal
+    */
+    void GetObjectsByResourceL(RArray<TInt>& aIds, const TDesC& aResVal);
+       
+      
+    /**
+    * Gets element
+    * @since Series S60 3.1
+    * @param aElmName
+    * @param ElmValue
+    * @return TInt
+    */
+    TInt GetElmIdByNameAndValL(const TDesC& aElmName, const TDesC& aElmValue);
+    
+    /**
+    * Gets attribute
+    * @since Series S60 3.1
+    * @param aElmId
+    * @param aAttrName
+    * @param aAttrValue
+    */
+    void GetAttrValueByNameL(TInt aElmId, const TDesC8& aAttrName, HBufC8*& aAttrVal);
+
+    /**
+    * Performs resource deletion of the object being destroyed
+    * @since Series S60 3.0
+    * @param aObjId aObjId id of the object being destroyed
+    * @param aObjId aCd pointer to the ContentDirectory object - it provides a function which deletes
+    *                  a file from the private directory
+    */
+    void DeleteResourcesL(TInt aObjId);
+
+    /**
+    * Performs the DeleteResource operation. 
+    * Deletes each res element with the value of aResVal and corresponding thumnail res elements
+    * @since Series S60 3.0
+    * @param aResVal value of the res whis is to be deleted
+    * @param aThumbailResVal value of the thumbail res whis is to be deleted
+    */
+    void DoDeleteResourceL(const TDesC8& aResVal, RArray<TInt>& aContIds);
+
+
+    /**
+    * Sets the childCount attribute in the given object's element.
+    * @since Series S60 3.0
+    * @param aElement object's element
+    * @param aId object's id
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    void SetChildCountL(TXmlEngElement aElement, TInt aId);
+    
+    /**
+    * Adds all (existing in the database) properties to the object's element.
+    * @since Series S60 3.0
+    * @param aElement object's element
+    * @param aObjBean object table description object
+    */
+    void AddAllPropertiesL(TXmlEngElement aElement, CUpnpObjectBean* aObjBean);
+
+    /**
+    * Adds new attribute to the element.
+    * @since Series S60 3.0
+    * @param aElement object's element
+    * @param aAttrName the name of the attribute which is to be added
+    * @param aElementId id of the element which the attribute belongs to
+    * @param aObjectId id of the object which the elements belongs to
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    void AddAttributeL( TXmlEngElement aElement, const TDesC8& aAttrName, TInt aElementId, TInt aObjectId );
+
+    /**
+    * Adds a requested properties to the object's element.
+    * @since Series S60 3.0
+    * @param aObjectID object's id
+    * @param aElement an array containing filter elements of the requested property
+    * @param aFilterElements ?description
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode AddRequestedPropertiesL(TInt aObjectID,TXmlEngElement aElement,
+                                           const RPointerArray<CUpnpFilterElement>& aFilterElements);
+
+    /**
+    * Adds requested element to the object's element.
+    * @since Series S60 3.0
+    * @param aElement an element wich we want to add a new element to
+    * @param aObjectID id of the object
+    * @param aReqElement filter object of the element to be added
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    void AddElementL(TXmlEngElement aElement, TInt aObjectID, const CUpnpFilterElement* aReqElement);
+
+    /**
+    * Adds required property to the object.
+    * @since Series S60 3.0
+    * @param aElement TXmlEngElement of the object which is to be added the required property
+    * @param aObjId id of the object being processed
+    * @param aFilterElement CUpnpFilterElement object of the property to be added
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode AddRequiredPropertyL(TXmlEngElement aElement, TInt aObjId, CUpnpFilterElement* aFilterElement);
+    
+    /**
+    * Parses filter string.
+    * @since Series S60 3.0
+    * @param aFilter filter string to be parsed
+    * @param aList  On return, contains CFilterElements objects of the filter string
+    */
+    void ParseFilterStringL(const TDesC8& aFilter, RPointerArray<CUpnpFilterElement>& aList);
+
+    /**
+    * Performs get object operation.
+    * @since Series S60 3.0
+    * @param aObjectID id of requested object.
+    * @param aDoc handler to document containing object's metadata.
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode DoGetObjectL(TInt aObjectID, RXmlEngDocument& aDoc, TBool aAll);
+ 
+    /**
+    * Inserts element into database 
+    * @since Series S60 3.0
+    * @param aElementel TXmlEngElement of the element to be inserted
+    * @param aObjId id of the object this element belongs to
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode InsertElementL(const TXmlEngElement& aElementel, TInt aObjId);
+ 
+    /**
+    * Performs object update; a transaction should be started before calling this function
+    * @since Series S60 3.0
+    * @param aObjId id of the object to be updated
+    * @param  aFragment XML DOM tree with the updated object's metadata
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode DoUpdateObjectL(TInt aObjId, TXmlEngElement aFragment);
+
+    /**
+    * Inserts updated object into database
+    * @since Series S60 3.0
+    * @param aObjId id of the object
+    * @param  aFragment XML DOM tree with the updated object's metadata
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode InsertUpdatedL(TInt aObjId, TXmlEngElement& aElement);
+
+    /**
+    * Sets the id attribute in the given object; adds attribute if does not exist
+    * @since Series S60 3.0
+    * @param aElement TXmlEngElement of the object
+    * @return value of the id
+    */
+    TInt SetObjectIdL(TXmlEngElement& aElement);
+
+    /**
+    * Inserts object into database; a transaction should be started before calling this function 
+    * @since Series S60 3.0
+    * @param param descr
+    * @return EUpnpOk, if successful; Leaves if the object could not be inserted into the database
+    *     In case it leaves the transaction must be rolled back
+    */
+    TUpnpErrorCode DoInsertObjectL( TXmlEngElement& aElement, TInt aContainerId, TInt* aId);
+
+
+    
+    /**
+    * Inserts attributes of the given element into the database
+    * @since Series S60 3.0
+    * @param aElement TXmlEngElement of the element 
+    * @param aElmId id of the element
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode InsertAttributesL(const TXmlEngElement aElement, TInt aElmId,TInt aObjId);
+    
+
+    /**
+    * Checks if the given attribute has a corresponding marker attr in the given array
+    * @since Series S60 3.0
+    * @param aAttr TXmlEngAttr of the attribute to be chceck
+    * @param aMarkers an array containing marker attributes
+    * @return ETrue if the attribute is required, otherwise EFalse
+    */
+    TBool IsAttrRequiredL(const TXmlEngAttr& aAttr, RArray<TXmlEngAttr>& aMarkers);
+
+    /**
+    * C++ default constructor.
+    */
+    CUpnpContentDirectoryDb(CUpnpMetadataStorage* aMetadataStorage);
+
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    void ConstructL();
+
+    /**
+    * If data base file is present it just opens it, 
+    * otherwise creates new database storage file.
+    * @since Series S60 3.0
+    * @param aDatabaseFileName name of storage file
+    */
+    void ConstructDbL(const TFileName& aDatabaseFileName);
+    
+    /**
+    * Opens existing database.
+    * @since Series S60 3.0
+    * @param aDatabaseFileName name of storage file
+    */
+    void OpenDbL( const TFileName& aDatabaseFileName );
+    
+    /**
+    * Adds elements that are children of inquired object to passed DOM TXmlEngElement.
+    * @param aObjectID - id of the object, which child elements will be added.
+    * @param aObjectElement - element to which the elements will be added.
+    */
+    void AddElementsL( TInt aObjectID, TXmlEngElement aObjectElement, TBool aAll );
+    
+    /**
+    * Adds attributes to passed DOM TXmlEngElement.
+    * @param aElementID - id of the element, which attributes will be added.
+    * @param aObjectId id of the object which the elements belongs to
+    * @param aElement - element to which the attributes will be added.
+    */
+    void AddAttributesL( TInt aElementID, TInt aObjectID, TXmlEngElement& aElement, TBool aAll );
+    
+
+    
+
+ private:    // Data
+    CUpnpMetadataStorage* iMetadataStorage; // not owned
+    RXmlEngDOMImplementation iDOMImpl;
+ };
+
+#endif //CCONTENTDIRECTORYDB_H
+
+// End Of File
--- a/upnpmediaserver/contentdirectoryservice/inc/upnpcontentdirectoryglobals.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/inc/upnpcontentdirectoryglobals.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,404 +1,404 @@
-/** @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:  Database for MediaServer
-*
-*/
-
-#ifndef C_UPNPCONTENTDIRECTORYDBGLOBALS_H
-#define C_UPNPCONTENTDIRECTORYDBGLOBALS_H
-#include <platform_paths.hrh>
-#include <bldvariant.hrh>
-// CONSTANTS
-
-// integers
-const TInt KMaxIntegerLen               = 10;
-const TInt KMaxIDResLength              = 18;
-const TInt KMaxLongIntegerLen           = 20;
-const TInt KMaxBoolLen                  = 1;
-const TInt KColNameMaxLenth             = 10;
-const TInt KDefaultGranularity          = 5;
-const TInt KRespBufGranularity          = 128;
-const TInt KMinDiskSpace                = 10000;
-const TInt KDownloadContId              = 1;
-const TInt KAvailableNestedLevels       = 23;
-const TInt KMaxUpnpLongStringLen        = 1024;
-const TInt KMaxUpnpStringLen            = 255;
-const TInt KCommitEveryNum              = 200;
-const TInt KOnlyOnePair                 = 2;
-const TInt KExtensionLength             = 10;
-const TInt KThumbnailWidth              = 40; 
-const TInt KThumbnailHeight             = 30;
-const TInt KDefaultThumbnailSize        = 5120; // 5 kb
-const TInt KHttpGetStarted              = 800;  
-const TInt KHttpPostStarted             = 801;  
-const TInt KThumbnailDirLen             = 10;
-const TInt KCompactWeight               = 10000; // specify how often 
-const TInt KDeleteWeight                = 5;   // Compact function is called.
-const TInt KExecuteWeight               = 1;   
-const TInt KCharSize                    = 2;                                                  
-const TInt KAutoDestroyTimeLimit        = 35000000;
-const TInt KMapKeyMaxLength             = 32;
-const TInt KRandomMax                   = 8999;
-const TInt KRandomMin                   = 1000;
-const TInt KRandomRangeLength           = 4;
-const TInt KMaxSlashAmount              = 4;
-const TInt KCharLen						= 1;   
-
-// files
-_LIT(  KObjectsXmlFileName,             "z:objects.xml"                     );
-_LIT(  KDefaultMediaDrive,              "C:"                                );
-_LIT(  KMediaPath,                      "Media"                             );
-_LIT(  KDownloadPath,                   "Download"                          );
-_LIT8( KMediaPath8,                     "Media"                             );
-_LIT(  KThumbnailPath,                  "Thumbnail"                         );
-_LIT(  KSearchThumbnailPathPattern,     "/Thumbnail/"                       );
-_LIT(  KMediaThumbnailPath,             "Media/Thumbnail"                   );
-_LIT(  KMainDir,                        "\\"                                );
-_LIT(  KDiskPathElSep,                  "\\"                                );
-_LIT(  KSlash,                          "/"                                 );
-_LIT(  KDefaultThumbExtension,          ".jpeg"                             );
-_LIT(  KThumbDirectory11,               "Thumbnail\\"                       );
-_LIT8( KThumbMimeType,                  "image/jpeg"                        );
-_LIT(  KDefaultUploadDir,               "data\\Download\\Media\\"			);
-_LIT(  KThumbnailSubDir,                "thumbnail\\"                       );
-
-
-// common strings
-_LIT(  KSemicolon,                      ";"                                 );
-_LIT8( KSemicolon8,                     ";"                                 );
-_LIT(  KCol,                            ":"                                 );
-_LIT(  KCommaStr,                       ","                                 );
-_LIT8( KCommaStr8,                      ","                                 );
-_LIT(  KFalseString,                    "false"                             );
-_LIT8( KFalseString8,                   "false"                             );
-_LIT(  KFalseValue,                     "0"                                 );
-_LIT8( KFalseValue8,                    "0"                                 );
-_LIT(  KAsterisk,                       "*"                                 );
-_LIT8( KAsterisk8,                      "*"                                 );
-_LIT(  KAtStr,                          "@"                                 );
-_LIT8( KAtStr8,                         "@"                                 );
-_LIT8( KHash8,                          "#"                                 );
-_LIT8( KHashASCII8,                     "%23"                               );
-_LIT(  KMinusOne,                       "-1"                                );
-_LIT8( KMinusOne8,                      "-1"                                );
-_LIT(  KDot,                            "."                                 );
-_LIT8( KDot8,                           "."                                 );
-_LIT(  KPathSeparator,                  "."                                 );
-_LIT8( KPathSeparator8,                 "."                                 );
-_LIT(  KQuot,                           "'"                                 );
-_LIT(  KUndersc,                        "_"                                 );
- 
-_LIT(  KTrueString,                     "true"                              );
-_LIT8( KTrueString8,                    "true"                              );
-_LIT(  KTrueValue,                      "1"                                 );
-_LIT8( KTrueValue8,                     "1"                                 );
-_LIT(  KNullString,                     ""                                  );
-_LIT(  KSpc,                            " "                                 );
-
-// 8bit strings
-_LIT8( KNewLine,                        "\r\n"                              );
-_LIT8( KLF8,                            "\n"                                );
-_LIT8( KTwoSpaces,                      "  "                                );
-_LIT8( KNullString8,                    ""                                  );
-
-// anyContainer support
-_LIT8( KAnyContainerIndicator8,         "DLNA.ORG_AnyContainer"             );
-_LIT(  KAnyContainerIndicator,          "DLNA.ORG_AnyContainer"             );
-const TInt KAnyContainerId              = 1;
-
-// forbidden paths
-_LIT8( KForbiddenDrivez,                "z"                                 );
-_LIT8( KForbiddenDriveZ,                "Z"                                 );
-_LIT8( KForbiddenPrivatePattern,        "/?/private*"                       );
-
-
-// Database structures' names
-// object table
-_LIT(  KObjectTableName,                "object"                            );
-_LIT8( KObjectTableName8,               "object"                            );
-_LIT(  KObjIdColName,                   "id"                                );
-_LIT(  KObjParentIdColName,             "parentID"                          );
-_LIT(  KObjTiltleColName,               "title"                             );
-_LIT8( KObjTiltleColName8,              "title"                             );
-_LIT(  KObjClassColName,                "class"                             );
-_LIT8( KObjClassColName8,               "class"                             );
-_LIT(  KObjRestrictedColName,           "restricted"                        );
-_LIT(  KObjSearchableColName,           "searchable"                        );
-_LIT(  KObjRefIdColName,                "refID"                             );
-_LIT(  KObjPathColName,                 "path"                              );
-_LIT(  KObjIdIndexName,                 "obj_id_index"                      );
-_LIT(  KRefIdIndexName,                 "ref_id_index"                      );
-// element table
-_LIT(  KElementTableName,               "element"                           );
-_LIT8( KElementTableName8,              "element"                           );
-_LIT(  KElmIdColName,                   "elm_id"                            );
-_LIT(  KElmNameColName,                 "elm_name"                          );
-_LIT(  KElmHasAttrColName,              "elm_has_attribute"                 );
-_LIT(  KElmObjIdColName,                "elm_obj_id"                        );
-_LIT(  KElmValueColName,                "elm_value"                         );
-_LIT(  KElmIsRequiredColName,           "elm_is_required"                   );
-_LIT(  KElmIdIndexName,                 "elm_id_index"                      );
-_LIT(  KElmObjIdIndexName,              "elm_obj_id_index"                  );
-// attributes table 
-_LIT(  KAttributeTableName,             "attribute"                         );
-_LIT8( KAttributeTableName8,            "attribute"                         );
-_LIT(  KAtrIdColName,                   "atr_id"                            );
-_LIT(  KAtrNameColName,                 "atr_name"                          );
-_LIT(  KAtrElmIdColName,                "atr_elm_id"                        );
-_LIT(  KAtrObjIdColName,                "atr_elm_id"                        );
-_LIT(  KAtrValueColName,                "atr_value"                         );
-_LIT(  KAtrIsRequiredColName,           "atr_is_required"                   );
-_LIT(  KAtrIdIndexName,                 "atr_id_index"                      );
-_LIT(  KAtrElmIdIndexName,              "atr_elm_id_index"                  );
-_LIT(  KAtrIdObjColName,                "atr_id_obj"                        );
-// resources table
-_LIT(  KResourcesTableName,             "resources"                         );
-_LIT(  KRscIdColName,                   "rsc_id"                            );
-_LIT(  KRscPathColName,                 "rsc_path"                          );
-_LIT(  KRscReadonlyColName,             "rsc_readonly"                      );
-_LIT(  KRscThumbnailColName,            "rsc_thumbnail"                     );
-_LIT(  KRscIdObjIndexName,              "rsc_id_obj_index"                  );
-_LIT(  KRscIdIndexName,                 "rsc_id_index"                      );
-_LIT(  KRscIdObjColName,                "rsc_id_obj"                        );
-// sequences table
-_LIT(  KSequencesTableName,             "sequences"                         );
-_LIT(  KSeqColNameColName,              "seq_col_name"                      );
-_LIT(  KSeqNextKeyColName,              "seq_next_key"                      );
-_LIT(  KSeqColNameIndexName,            "seq_col_name_index"                );
-// importUri sequence
-_LIT(  KImportUriId,                    "uriId"                             );
-_LIT8( KImportUriId8,                   "uriId"                             );
-// database name
-_LIT(  KDatabaseFileName,               "c:AVMediaServerStore"              );
-
-// upnp 
-_LIT8( KContainerClass8,                "object.container"                  );
-_LIT(  KItemClass,                      "object.item"                       );
-_LIT8( KClassTagName,                   "class"                             );
-_LIT8( KTitleTagName,                   "title"                             );
-_LIT(  KClassTagNameWithNs,             "upnp:class"                        );
-_LIT8( KClassTagNameWithNs8,            "upnp:class"                        );
-_LIT(  KTitleTagNameWithNs,             "dc:title"                          );
-_LIT8( KTitleTagNameWithNs8,            "dc:title"                          );
-_LIT(  KResStr,                         "res"                               );
-_LIT8( KMimeBegin,                      "&quot;http-get:*:"                 );
-_LIT8( KMimeEnd,                        ":*&quot;"                          );
-_LIT8( KItemTypeImage,                  "imageItem"                         );
-_LIT8( KItemTypeAudio,                  "audioItem"                         );
-_LIT8( KItemTypeVideo,                  "videoItem"                         );
-_LIT8( KHTTPHeader,                     "http://"                           );
-_LIT8( KDrmMatchString,                 "<xmrcc:*/*>*"                      );
-_LIT8( KRequiredAtrName,                "el_required"                       );
-_LIT8( KRequiredAtrSuf,                 "_req"                              );
-_LIT8( KRequiredAtrSufPattern,          "*_req"                             );
-_LIT8( KProtInfoReqAtrSufPattern,       "protocolInfo_req"                  );
-_LIT8( KIpPortPlaceholder8,             "___.___.___.___:_____"             );
-_LIT(  KIpPortPlaceholder,              "___.___.___.___:_____"             );
-_LIT8( KTitle,                          "title"                             );
-_LIT8( KProInfoBegin,                   "http-get:*:"                       );
-_LIT8( KProInfoEnd,                     ":*"                                );
-_LIT8( KCompleted,                      "COMPLETED"                         );
-_LIT8( KError,                          "ERROR"                             );
-_LIT8( KInProgress,                     "IN_PROGRESS"                       );
-_LIT8( KStopped,                        "STOPPED"                           );
-_LIT8( KBrowseChilds,                   "BrowseDirectChildren"              );
-_LIT8( KBrowseFlag,                     "BrowseFlag"                        );
-_LIT8( KBrowseMeta,                     "BrowseMetadata"                    );
-_LIT8( KContainerID,                    "ContainerID"                       );
-_LIT8( KChildCount,                     "childCount"                        );
-_LIT(  KChildCount16,                   "childCount"                        );
-_LIT8( KContainer,                      "container"                         );
-_LIT8( KContainerUpdateIDs,             "ContainerUpdateIDs"                );
-_LIT8( KCurrentTagValue,                "CurrentTagValue"                   );
-_LIT8( KDcNsPrefix,                     "dc"                                );
-_LIT8( KDestinationURI,                 "DestinationURI"                    );
-_LIT8( KDidlEnd,                        "</DIDL-Lite>"                      );
-_LIT8( KXmlnsNsUri,                     "urn:schemas-upnp-org:"
-                                        "metadata-1-0/DIDL-Lite/"           );
-_LIT8( KCmlnsNsPref,                    "xmlns"                             );
-_LIT8( KDcNsUri,                        "http://purl.org/dc/elements/1.1/"  );
-_LIT8( KDcNsPref,                       "dc"                                );
-_LIT8( KUpnpNsUri,                      "urn:schemas-upnp-org:"
-                                        "metadata-1-0/upnp/"                );
-_LIT8( KUpnpNsPref,                     "upnp");
-_LIT8( KDidlTag,                        "<DIDL-Lite xmlns=\"urn:schemas-upnp"
-                                        "-org:metadata-1-0/DIDL-Lite/\" "
-                                        "xmlns:dc=\"http://purl.org/dc/"
-                                        "elements/1.1/\" xmlns:upnp=\"urn:"
-                                        "schemas-upnp-org:metadata-1-0/upnp"
-                                        "/\" xmlns:dlna=\"urn:schemas-dlna-"
-                                        "org:metadata-1-0\">");
-_LIT8( KElements,                       "Elements"                          );
-_LIT8( KFilter,                         "Filter"                            );
-_LIT8( KId,                             "Id"                                );
-_LIT8( KIdAttrName,                     "id"                                );
-_LIT(  KimportUri,                      "importUri"                         );
-_LIT8( KImportUri8,                     "importUri"                         );
-_LIT8( KItem,                           "item"                              );
-_LIT8( KNumberReturned,                 "NumberReturned"                    );
-_LIT8( KNewID,                          "NewID"                             );
-_LIT8( KNewTagValue,                    "NewTagValue"                       );
-_LIT8( KParentID,                       "parentID"                          );
-_LIT8( KRefID,                          "refID"                             );
-_LIT8( KRequestedCount,                 "RequestedCount"                    );
-_LIT8( KResourceURI,                    "ResourceURI"                       );
-_LIT8( KRestricted,                     "restricted"                        );
-_LIT8( KResult,                         "Result"                            );
-_LIT8( KCreator8,                       "dc:creator"                        );
-_LIT8( KDate8,                       "date"                        );
-_LIT8( KDuration8,                       "duration"                        );
-_LIT8( KSearchCaps,                     "SearchCaps"                        );
-_LIT8( KSearchCapabilities,             "");
-
-_LIT8( KSearchCapsVariableName,         "SearchCapabilities"                ); 
-
-_LIT8( KSearchClassTag,                 "<upnp:searchClass>"                );
-_LIT8( KSearchClassTagEnd,              "</upnp:searchClass>"               );
-_LIT8( KSize,                           "size"                              );
-_LIT8( KStartingIndex,                  "StartingIndex"                     );
-_LIT8( KSortCaps,                       "SortCaps"                          );
-_LIT8( KSortCapsVariableName,           "SortCapabilities"                  );
-_LIT8( KSortCapabilities,               ""                                  );
-_LIT8( KSortCriteria,                   "SortCriteria"                      );
-_LIT8( KSourceURI,                      "SourceURI"                         );
-_LIT8( KSystemUpdateID,                 "SystemUpdateID"                    );
-_LIT8( KTransferID,                     "TransferID"                        );
-_LIT8( KTransferIDs,                    "TransferIDs"                       );
-_LIT8( KTransferStatus,                 "TransferStatus"                    );
-_LIT8( KTransferLength,                 "TransferLength"                    );
-_LIT8( KTransferTotal,                  "TransferTotal"                     );
-_LIT8( KTotalMatches,                   "TotalMatches"                      );
-_LIT8( KUpnpNsPrefix,                   "upnp"                              );
-_LIT8( KUpdateID,                       "UpdateID"                          );
-_LIT8( KHttpTag,                        "http://"                           );
-_LIT(  KHttpTag16,                      "http://"                           );
-_LIT8( KprotocolInfo,                   "protocolInfo"                      );
-_LIT(  KProtocolInfo,                   "protocolInfo"                      );
-_LIT8( KDlnaPrefix,                     "dlna"                              );
-_LIT8( KDlnaProfileID,                  "dlna:profileID"                    );
-_LIT8( KProfileID,                      "profileID"                         );
-_LIT8( KDefaultProfileID,               "JPEG_TN"                           );
-_LIT8( KAlbumArtURI,                    "upnp:albumArtURI"                  );
-_LIT8( KXmlnsDlna,                      "urn:schemas-dlna-org:metadata-1-0/");
-_LIT8( KEmptyProtocolInfoVal8,          "http-get:*:*:*"                    );
-_LIT8( KRootNode,                       "<DIDL-Lite xmlns:dc=\"http://purl."
-                                        "org/dc/elements/1.1/\" xmlns:upnp="
-                                        "\"urn:schemas-upnp-org:metadata-1-"
-                                        "0/upnp/\" xmlns=\"urn:schemas-upnp"
-                                        "-org:metadata-1-0/DIDL-Lite/\">"   );
-_LIT8( KSearchable,                     "searchable"                        );
-_LIT8( KUpdateIds,                      "0,0"                               );
-_LIT8( KBrowse,                         "Browse"                            );
-_LIT8( KCreateReference,                "CreateReference"                   );
-_LIT8( KCreateObject,                   "CreateObject"                      );
-_LIT8( KDeleteResource,                 "DeleteResource"                    );
-_LIT8( KDestroyObject,                  "DestroyObject"                     );
-_LIT8( KExportResource,                 "ExportResource"                    );
-_LIT8( KGetSearchCapabilities,          "GetSearchCapabilities"             );
-_LIT8( KGetSortCapabilities,            "GetSortCapabilities"               );
-_LIT8( KGetSystemUpdateID,              "GetSystemUpdateID"                 ); 
-_LIT8( KGetTransferProgress,            "GetTransferProgress"               );
-_LIT8( KImportResource,                 "ImportResource"                    );
-_LIT8( KSearch,                         "Search"                            );
-_LIT8( KStopTransferResource,           "StopTransferResource"              );
-_LIT8( KMetadata,                       "urn:schemas-upnp-org:metadata"
-                                        "-1-0/upnp/"                        );
-_LIT8( KXmlNsDc,                        "xmlns:dc=\"http://purl.org/dc"
-                                        "/elements/1.1/\""                  );
-_LIT8( KType,                           "type"                              ); 
-_LIT8( KElement,                        "e"                                 );
-_LIT8( KClass,                          "class"                             );
-_LIT8( KImportUri,                      "importUri"                         );
-_LIT(  KImportUri16,                    "importUri"                         );
-_LIT8( KCharR,                          "r"                                 ); 
-_LIT8( KIParent,                        "i"                                 );
-_LIT8( KProperties,                     "ps"                                );
-_LIT8( KName,                           "n"                                 );
-_LIT8( KAttribute,                      "Attribute"                         );
-_LIT8( KResAttr,                        "res"                               );
-_LIT8( KMultiple,                       "m"                                 );
-_LIT8( KRes,                            "res"                               );
-_LIT(  KRes16,                          "res"                               );
-_LIT8( KNestAttr,                       "a"                                 );
-_LIT8( KObject,                         "object"                            );
-_LIT8( KDidlLite,                       "DIDL-Lite"                         );
-_LIT8( KTrue,                           "true"                              );
-_LIT8( KObjectProperty,                 "p"                                 );
-_LIT8( KObjectName,                     "n"                                 );
-_LIT8( KRequiredObject,                 "r"                                 );
-_LIT8( KMultiValueObject,               "m"                                 );
-_LIT8( KVendorDescriptor,               "desc"                              );
-_LIT8( KColon8,                         ":"                                 );
-_LIT8( KArtist,                         "artist"                            );
-_LIT8( KAlbum,                          "album"                             );
-_LIT8( KImageMime,                      "image"                             );
-_LIT8( KTextMime,                       "text"                              );
-_LIT8( KVideoMime,                      "video"                             );
-_LIT8( KAudioMime,                      "audio"                             );
-_LIT8( KObjectClassAudioItem,           "object.item.audioItem"             );
-_LIT8( KObjectClassVideoItem,           "object.item.videoItem"             );  
-_LIT8( KObjectClassTextItem,            "object.item.textItem"              );    
-_LIT8( KObjectClassImageItem,           "object.item.imageItem"             );      
-_LIT8( KJpegLrg,                        "JPEG_LRG"                          );
-_LIT8( KJpegMed,                        "JPEG_MED"                          );
-_LIT8( KJpegSm,                         "JPEG_SM"                           );
-
-// SQL Strings
-_LIT(  KDeleteFromSqlCmd,               "DELETE FROM %S WHERE %S=%S"        );
-_LIT(  KOpenParant,                     "("                                 );
-_LIT(  KValuesOpen,                     " VALUES("                          );
-_LIT(  KCloseParant,                    ")"                                 );
-_LIT(  KInsertInto,                     "INSERT INTO "                      );
-_LIT(  KOnlyRequiredFromElement,        " AND elm_is_required=1"            );
-_LIT(  KNamedElFromElement,             " AND elm_name='%S'"                );
-_LIT(  KSelectFromObjectSqlCmd,         "SELECT %S FROM object WHERE id=%d" );
-_LIT(  KOnlyRequiredFromAtr,            " AND atr_is_required=1"            );
-_LIT(  KNamedAtrFromAttribute,          " AND atr_name='%S'"                );
-_LIT(  KFullPathFromShareMap,           " OR %S='%S'"                       );
-_LIT(  KSelectFromSqlCmd,               "SELECT %S FROM %S WHERE %S='%S'"   );
-_LIT(  KSelectFromNumSqlCmd,            "SELECT %S FROM %S WHERE %S=%d"     );
-_LIT(  KSelectFromNumNotEqSqlCmd,       "SELECT %S FROM %S WHERE %S<>%d"    );
-_LIT(  KAndConditionSqlCmd,             " AND %S='%S'"                      );
-_LIT(  KAndLikeConditionSqlCmd,         " AND %S LIKE '*%S'"               );
-_LIT(  KSelectAttributeByValueSqlCmd,   "SELECT * FROM attribute WHERE atr_value LIKE '*%S*' AND atr_name = '%S' ");
-_LIT(  KNewMediaDirSqlCmd,              "UPDATE resources SET rsc_readonly=1 WHERE rsc_path LIKE '%S*' AND rsc_readonly=0");
-_LIT(  KInsertElementSqlCmd,            "INSERT INTO element (elm_id,elm_name,elm_value,elm_has_attribute,elm_obj_id,elm_is_required)VALUES(%d,'%S','%S',%d,%d,%d)");
-_LIT(  KInsertAttributeSqlCmd,          "INSERT INTO attribute(atr_id,atr_name,atr_value,atr_elm_id,atr_is_required) VALUES(%d,'%S','%S',%d,%d)");
-_LIT(  KGetObjectListSqlCmd,            "SELECT id FROM object WHERE parentID=%d");
-_LIT(  KGetItemListSqlCmd,              "SELECT id FROM object WHERE parentID=%d AND class LIKE 'object.item*'");
-_LIT(  KGetContainerListSqlCmd,         "SELECT id FROM object WHERE parentID=%d AND class LIKE 'object.container*'");
-_LIT(  KSelectIdFromElSqlCmd,           "SELECT elm_id, elm_name, elm_value FROM element WHERE elm_obj_id=%d" );
-_LIT(  KDeleteResElSqlCmd,              "DELETE FROM element WHERE elm_value='%S' AND elm_obj_id=%d");
-_LIT(  KSelectObjectFromObjSqlCmd,      "SELECT id, parentID, title, class, restricted, searchable, refID FROM object WHERE id = %d");
-_LIT(  KSelectElmFromElmSqlCmd,         "SELECT elm_name, elm_value, elm_has_attribute, elm_id, elm_is_required FROM element WHERE elm_obj_id = %d");
-_LIT(  KSelectAtrFromAttrSqlCmd,        "SELECT atr_name, atr_value FROM attribute WHERE atr_elm_id = %d");
-_LIT(  KSelectAtrFromAttrByObjSqlCmd,   "SELECT atr_name, atr_value, atr_elm_id FROM attribute WHERE atr_id_obj = %d");
-
-// initial data
-_LIT(  KInit1,                          "INSERT INTO object (id,parentID,title,class,restricted,searchable,path) VALUES(0,-1,'root','object.container',0,1,'-1')");
-_LIT(  KInit2,                          "INSERT INTO object (id,parentID,title,class,restricted,searchable,path) VALUES(1,0,'Uploaded','object.container',0,1,'-1.0')");
-_LIT(  KInit3,                          "INSERT INTO sequences(seq_col_name,seq_next_key) VALUES('object',2)" );
-_LIT(  KInit4,                          "INSERT INTO sequences(seq_col_name,seq_next_key) VALUES('element',0)");
-_LIT(  KInit5,                          "INSERT INTO sequences(seq_col_name,seq_next_key) VALUES('attribute',0)");
-_LIT(  KInit6,                          "INSERT INTO sequences(seq_col_name,seq_next_key) VALUES('uriId',1)"  );
-
-
-enum TCurrentAction 
-{
-    EUndefinedAction = 0,
-    ECreateObjectAction = 1,
-};
-
-#endif //C_UPNPCONTENTDIRECTORYDBGLOBALS_H
-// End of File
+/** @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:  Database for MediaServer
+*
+*/
+
+#ifndef C_UPNPCONTENTDIRECTORYDBGLOBALS_H
+#define C_UPNPCONTENTDIRECTORYDBGLOBALS_H
+#include <platform_paths.hrh>
+#include <bldvariant.hrh>
+// CONSTANTS
+
+// integers
+const TInt KMaxIntegerLen               = 10;
+const TInt KMaxIDResLength              = 18;
+const TInt KMaxLongIntegerLen           = 20;
+const TInt KMaxBoolLen                  = 1;
+const TInt KColNameMaxLenth             = 10;
+const TInt KDefaultGranularity          = 5;
+const TInt KRespBufGranularity          = 128;
+const TInt KMinDiskSpace                = 10000;
+const TInt KDownloadContId              = 1;
+const TInt KAvailableNestedLevels       = 23;
+const TInt KMaxUpnpLongStringLen        = 1024;
+const TInt KMaxUpnpStringLen            = 255;
+const TInt KCommitEveryNum              = 200;
+const TInt KOnlyOnePair                 = 2;
+const TInt KExtensionLength             = 10;
+const TInt KThumbnailWidth              = 40; 
+const TInt KThumbnailHeight             = 30;
+const TInt KDefaultThumbnailSize        = 5120; // 5 kb
+const TInt KHttpGetStarted              = 800;  
+const TInt KHttpPostStarted             = 801;  
+const TInt KThumbnailDirLen             = 10;
+const TInt KCompactWeight               = 10000; // specify how often 
+const TInt KDeleteWeight                = 5;   // Compact function is called.
+const TInt KExecuteWeight               = 1;   
+const TInt KCharSize                    = 2;                                                  
+const TInt KAutoDestroyTimeLimit        = 35000000;
+const TInt KMapKeyMaxLength             = 32;
+const TInt KRandomMax                   = 8999;
+const TInt KRandomMin                   = 1000;
+const TInt KRandomRangeLength           = 4;
+const TInt KMaxSlashAmount              = 4;
+const TInt KCharLen						= 1;   
+
+// files
+_LIT(  KObjectsXmlFileName,             "objects.xml"                     );
+_LIT(  KDefaultMediaDrive,              "C:"                                );
+_LIT(  KMediaPath,                      "Media"                             );
+_LIT(  KDownloadPath,                   "Download"                          );
+_LIT8( KMediaPath8,                     "Media"                             );
+_LIT(  KThumbnailPath,                  "Thumbnail"                         );
+_LIT(  KSearchThumbnailPathPattern,     "/Thumbnail/"                       );
+_LIT(  KMediaThumbnailPath,             "Media/Thumbnail"                   );
+_LIT(  KMainDir,                        "\\"                                );
+_LIT(  KDiskPathElSep,                  "\\"                                );
+_LIT(  KSlash,                          "/"                                 );
+_LIT(  KDefaultThumbExtension,          ".jpeg"                             );
+_LIT(  KThumbDirectory11,               "Thumbnail\\"                       );
+_LIT8( KThumbMimeType,                  "image/jpeg"                        );
+_LIT(  KDefaultUploadDir,               "data\\Download\\Media\\"			);
+_LIT(  KThumbnailSubDir,                "thumbnail\\"                       );
+
+
+// common strings
+_LIT(  KSemicolon,                      ";"                                 );
+_LIT8( KSemicolon8,                     ";"                                 );
+_LIT(  KCol,                            ":"                                 );
+_LIT(  KCommaStr,                       ","                                 );
+_LIT8( KCommaStr8,                      ","                                 );
+_LIT(  KFalseString,                    "false"                             );
+_LIT8( KFalseString8,                   "false"                             );
+_LIT(  KFalseValue,                     "0"                                 );
+_LIT8( KFalseValue8,                    "0"                                 );
+_LIT(  KAsterisk,                       "*"                                 );
+_LIT8( KAsterisk8,                      "*"                                 );
+_LIT(  KAtStr,                          "@"                                 );
+_LIT8( KAtStr8,                         "@"                                 );
+_LIT8( KHash8,                          "#"                                 );
+_LIT8( KHashASCII8,                     "%23"                               );
+_LIT(  KMinusOne,                       "-1"                                );
+_LIT8( KMinusOne8,                      "-1"                                );
+_LIT(  KDot,                            "."                                 );
+_LIT8( KDot8,                           "."                                 );
+_LIT(  KPathSeparator,                  "."                                 );
+_LIT8( KPathSeparator8,                 "."                                 );
+_LIT(  KQuot,                           "'"                                 );
+_LIT(  KUndersc,                        "_"                                 );
+ 
+_LIT(  KTrueString,                     "true"                              );
+_LIT8( KTrueString8,                    "true"                              );
+_LIT(  KTrueValue,                      "1"                                 );
+_LIT8( KTrueValue8,                     "1"                                 );
+_LIT(  KNullString,                     ""                                  );
+_LIT(  KSpc,                            " "                                 );
+
+// 8bit strings
+_LIT8( KNewLine,                        "\r\n"                              );
+_LIT8( KLF8,                            "\n"                                );
+_LIT8( KTwoSpaces,                      "  "                                );
+_LIT8( KNullString8,                    ""                                  );
+
+// anyContainer support
+_LIT8( KAnyContainerIndicator8,         "DLNA.ORG_AnyContainer"             );
+_LIT(  KAnyContainerIndicator,          "DLNA.ORG_AnyContainer"             );
+const TInt KAnyContainerId              = 1;
+
+// forbidden paths
+_LIT8( KForbiddenDrivez,                "z"                                 );
+_LIT8( KForbiddenDriveZ,                "Z"                                 );
+_LIT8( KForbiddenPrivatePattern,        "/?/private*"                       );
+
+
+// Database structures' names
+// object table
+_LIT(  KObjectTableName,                "object"                            );
+_LIT8( KObjectTableName8,               "object"                            );
+_LIT(  KObjIdColName,                   "id"                                );
+_LIT(  KObjParentIdColName,             "parentID"                          );
+_LIT(  KObjTiltleColName,               "title"                             );
+_LIT8( KObjTiltleColName8,              "title"                             );
+_LIT(  KObjClassColName,                "class"                             );
+_LIT8( KObjClassColName8,               "class"                             );
+_LIT(  KObjRestrictedColName,           "restricted"                        );
+_LIT(  KObjSearchableColName,           "searchable"                        );
+_LIT(  KObjRefIdColName,                "refID"                             );
+_LIT(  KObjPathColName,                 "path"                              );
+_LIT(  KObjIdIndexName,                 "obj_id_index"                      );
+_LIT(  KRefIdIndexName,                 "ref_id_index"                      );
+// element table
+_LIT(  KElementTableName,               "element"                           );
+_LIT8( KElementTableName8,              "element"                           );
+_LIT(  KElmIdColName,                   "elm_id"                            );
+_LIT(  KElmNameColName,                 "elm_name"                          );
+_LIT(  KElmHasAttrColName,              "elm_has_attribute"                 );
+_LIT(  KElmObjIdColName,                "elm_obj_id"                        );
+_LIT(  KElmValueColName,                "elm_value"                         );
+_LIT(  KElmIsRequiredColName,           "elm_is_required"                   );
+_LIT(  KElmIdIndexName,                 "elm_id_index"                      );
+_LIT(  KElmObjIdIndexName,              "elm_obj_id_index"                  );
+// attributes table 
+_LIT(  KAttributeTableName,             "attribute"                         );
+_LIT8( KAttributeTableName8,            "attribute"                         );
+_LIT(  KAtrIdColName,                   "atr_id"                            );
+_LIT(  KAtrNameColName,                 "atr_name"                          );
+_LIT(  KAtrElmIdColName,                "atr_elm_id"                        );
+_LIT(  KAtrObjIdColName,                "atr_elm_id"                        );
+_LIT(  KAtrValueColName,                "atr_value"                         );
+_LIT(  KAtrIsRequiredColName,           "atr_is_required"                   );
+_LIT(  KAtrIdIndexName,                 "atr_id_index"                      );
+_LIT(  KAtrElmIdIndexName,              "atr_elm_id_index"                  );
+_LIT(  KAtrIdObjColName,                "atr_id_obj"                        );
+// resources table
+_LIT(  KResourcesTableName,             "resources"                         );
+_LIT(  KRscIdColName,                   "rsc_id"                            );
+_LIT(  KRscPathColName,                 "rsc_path"                          );
+_LIT(  KRscReadonlyColName,             "rsc_readonly"                      );
+_LIT(  KRscThumbnailColName,            "rsc_thumbnail"                     );
+_LIT(  KRscIdObjIndexName,              "rsc_id_obj_index"                  );
+_LIT(  KRscIdIndexName,                 "rsc_id_index"                      );
+_LIT(  KRscIdObjColName,                "rsc_id_obj"                        );
+// sequences table
+_LIT(  KSequencesTableName,             "sequences"                         );
+_LIT(  KSeqColNameColName,              "seq_col_name"                      );
+_LIT(  KSeqNextKeyColName,              "seq_next_key"                      );
+_LIT(  KSeqColNameIndexName,            "seq_col_name_index"                );
+// importUri sequence
+_LIT(  KImportUriId,                    "uriId"                             );
+_LIT8( KImportUriId8,                   "uriId"                             );
+// database name
+_LIT(  KDatabaseFileName,               "c:AVMediaServerStore"              );
+
+// upnp 
+_LIT8( KContainerClass8,                "object.container"                  );
+_LIT(  KItemClass,                      "object.item"                       );
+_LIT8( KClassTagName,                   "class"                             );
+_LIT8( KTitleTagName,                   "title"                             );
+_LIT(  KClassTagNameWithNs,             "upnp:class"                        );
+_LIT8( KClassTagNameWithNs8,            "upnp:class"                        );
+_LIT(  KTitleTagNameWithNs,             "dc:title"                          );
+_LIT8( KTitleTagNameWithNs8,            "dc:title"                          );
+_LIT(  KResStr,                         "res"                               );
+_LIT8( KMimeBegin,                      "&quot;http-get:*:"                 );
+_LIT8( KMimeEnd,                        ":*&quot;"                          );
+_LIT8( KItemTypeImage,                  "imageItem"                         );
+_LIT8( KItemTypeAudio,                  "audioItem"                         );
+_LIT8( KItemTypeVideo,                  "videoItem"                         );
+_LIT8( KHTTPHeader,                     "http://"                           );
+_LIT8( KDrmMatchString,                 "<xmrcc:*/*>*"                      );
+_LIT8( KRequiredAtrName,                "el_required"                       );
+_LIT8( KRequiredAtrSuf,                 "_req"                              );
+_LIT8( KRequiredAtrSufPattern,          "*_req"                             );
+_LIT8( KProtInfoReqAtrSufPattern,       "protocolInfo_req"                  );
+_LIT8( KIpPortPlaceholder8,             "___.___.___.___:_____"             );
+_LIT(  KIpPortPlaceholder,              "___.___.___.___:_____"             );
+_LIT8( KTitle,                          "title"                             );
+_LIT8( KProInfoBegin,                   "http-get:*:"                       );
+_LIT8( KProInfoEnd,                     ":*"                                );
+_LIT8( KCompleted,                      "COMPLETED"                         );
+_LIT8( KError,                          "ERROR"                             );
+_LIT8( KInProgress,                     "IN_PROGRESS"                       );
+_LIT8( KStopped,                        "STOPPED"                           );
+_LIT8( KBrowseChilds,                   "BrowseDirectChildren"              );
+_LIT8( KBrowseFlag,                     "BrowseFlag"                        );
+_LIT8( KBrowseMeta,                     "BrowseMetadata"                    );
+_LIT8( KContainerID,                    "ContainerID"                       );
+_LIT8( KChildCount,                     "childCount"                        );
+_LIT(  KChildCount16,                   "childCount"                        );
+_LIT8( KContainer,                      "container"                         );
+_LIT8( KContainerUpdateIDs,             "ContainerUpdateIDs"                );
+_LIT8( KCurrentTagValue,                "CurrentTagValue"                   );
+_LIT8( KDcNsPrefix,                     "dc"                                );
+_LIT8( KDestinationURI,                 "DestinationURI"                    );
+_LIT8( KDidlEnd,                        "</DIDL-Lite>"                      );
+_LIT8( KXmlnsNsUri,                     "urn:schemas-upnp-org:"
+                                        "metadata-1-0/DIDL-Lite/"           );
+_LIT8( KCmlnsNsPref,                    "xmlns"                             );
+_LIT8( KDcNsUri,                        "http://purl.org/dc/elements/1.1/"  );
+_LIT8( KDcNsPref,                       "dc"                                );
+_LIT8( KUpnpNsUri,                      "urn:schemas-upnp-org:"
+                                        "metadata-1-0/upnp/"                );
+_LIT8( KUpnpNsPref,                     "upnp");
+_LIT8( KDidlTag,                        "<DIDL-Lite xmlns=\"urn:schemas-upnp"
+                                        "-org:metadata-1-0/DIDL-Lite/\" "
+                                        "xmlns:dc=\"http://purl.org/dc/"
+                                        "elements/1.1/\" xmlns:upnp=\"urn:"
+                                        "schemas-upnp-org:metadata-1-0/upnp"
+                                        "/\" xmlns:dlna=\"urn:schemas-dlna-"
+                                        "org:metadata-1-0\">");
+_LIT8( KElements,                       "Elements"                          );
+_LIT8( KFilter,                         "Filter"                            );
+_LIT8( KId,                             "Id"                                );
+_LIT8( KIdAttrName,                     "id"                                );
+_LIT(  KimportUri,                      "importUri"                         );
+_LIT8( KImportUri8,                     "importUri"                         );
+_LIT8( KItem,                           "item"                              );
+_LIT8( KNumberReturned,                 "NumberReturned"                    );
+_LIT8( KNewID,                          "NewID"                             );
+_LIT8( KNewTagValue,                    "NewTagValue"                       );
+_LIT8( KParentID,                       "parentID"                          );
+_LIT8( KRefID,                          "refID"                             );
+_LIT8( KRequestedCount,                 "RequestedCount"                    );
+_LIT8( KResourceURI,                    "ResourceURI"                       );
+_LIT8( KRestricted,                     "restricted"                        );
+_LIT8( KResult,                         "Result"                            );
+_LIT8( KCreator8,                       "dc:creator"                        );
+_LIT8( KDate8,                       "date"                        );
+_LIT8( KDuration8,                       "duration"                        );
+_LIT8( KSearchCaps,                     "SearchCaps"                        );
+_LIT8( KSearchCapabilities,             "");
+
+_LIT8( KSearchCapsVariableName,         "SearchCapabilities"                ); 
+
+_LIT8( KSearchClassTag,                 "<upnp:searchClass>"                );
+_LIT8( KSearchClassTagEnd,              "</upnp:searchClass>"               );
+_LIT8( KSize,                           "size"                              );
+_LIT8( KStartingIndex,                  "StartingIndex"                     );
+_LIT8( KSortCaps,                       "SortCaps"                          );
+_LIT8( KSortCapsVariableName,           "SortCapabilities"                  );
+_LIT8( KSortCapabilities,               ""                                  );
+_LIT8( KSortCriteria,                   "SortCriteria"                      );
+_LIT8( KSourceURI,                      "SourceURI"                         );
+_LIT8( KSystemUpdateID,                 "SystemUpdateID"                    );
+_LIT8( KTransferID,                     "TransferID"                        );
+_LIT8( KTransferIDs,                    "TransferIDs"                       );
+_LIT8( KTransferStatus,                 "TransferStatus"                    );
+_LIT8( KTransferLength,                 "TransferLength"                    );
+_LIT8( KTransferTotal,                  "TransferTotal"                     );
+_LIT8( KTotalMatches,                   "TotalMatches"                      );
+_LIT8( KUpnpNsPrefix,                   "upnp"                              );
+_LIT8( KUpdateID,                       "UpdateID"                          );
+_LIT8( KHttpTag,                        "http://"                           );
+_LIT(  KHttpTag16,                      "http://"                           );
+_LIT8( KprotocolInfo,                   "protocolInfo"                      );
+_LIT(  KProtocolInfo,                   "protocolInfo"                      );
+_LIT8( KDlnaPrefix,                     "dlna"                              );
+_LIT8( KDlnaProfileID,                  "dlna:profileID"                    );
+_LIT8( KProfileID,                      "profileID"                         );
+_LIT8( KDefaultProfileID,               "JPEG_TN"                           );
+_LIT8( KAlbumArtURI,                    "upnp:albumArtURI"                  );
+_LIT8( KXmlnsDlna,                      "urn:schemas-dlna-org:metadata-1-0/");
+_LIT8( KEmptyProtocolInfoVal8,          "http-get:*:*:*"                    );
+_LIT8( KRootNode,                       "<DIDL-Lite xmlns:dc=\"http://purl."
+                                        "org/dc/elements/1.1/\" xmlns:upnp="
+                                        "\"urn:schemas-upnp-org:metadata-1-"
+                                        "0/upnp/\" xmlns=\"urn:schemas-upnp"
+                                        "-org:metadata-1-0/DIDL-Lite/\">"   );
+_LIT8( KSearchable,                     "searchable"                        );
+_LIT8( KUpdateIds,                      "0,0"                               );
+_LIT8( KBrowse,                         "Browse"                            );
+_LIT8( KCreateReference,                "CreateReference"                   );
+_LIT8( KCreateObject,                   "CreateObject"                      );
+_LIT8( KDeleteResource,                 "DeleteResource"                    );
+_LIT8( KDestroyObject,                  "DestroyObject"                     );
+_LIT8( KExportResource,                 "ExportResource"                    );
+_LIT8( KGetSearchCapabilities,          "GetSearchCapabilities"             );
+_LIT8( KGetSortCapabilities,            "GetSortCapabilities"               );
+_LIT8( KGetSystemUpdateID,              "GetSystemUpdateID"                 ); 
+_LIT8( KGetTransferProgress,            "GetTransferProgress"               );
+_LIT8( KImportResource,                 "ImportResource"                    );
+_LIT8( KSearch,                         "Search"                            );
+_LIT8( KStopTransferResource,           "StopTransferResource"              );
+_LIT8( KMetadata,                       "urn:schemas-upnp-org:metadata"
+                                        "-1-0/upnp/"                        );
+_LIT8( KXmlNsDc,                        "xmlns:dc=\"http://purl.org/dc"
+                                        "/elements/1.1/\""                  );
+_LIT8( KType,                           "type"                              ); 
+_LIT8( KElement,                        "e"                                 );
+_LIT8( KClass,                          "class"                             );
+_LIT8( KImportUri,                      "importUri"                         );
+_LIT(  KImportUri16,                    "importUri"                         );
+_LIT8( KCharR,                          "r"                                 ); 
+_LIT8( KIParent,                        "i"                                 );
+_LIT8( KProperties,                     "ps"                                );
+_LIT8( KName,                           "n"                                 );
+_LIT8( KAttribute,                      "Attribute"                         );
+_LIT8( KResAttr,                        "res"                               );
+_LIT8( KMultiple,                       "m"                                 );
+_LIT8( KRes,                            "res"                               );
+_LIT(  KRes16,                          "res"                               );
+_LIT8( KNestAttr,                       "a"                                 );
+_LIT8( KObject,                         "object"                            );
+_LIT8( KDidlLite,                       "DIDL-Lite"                         );
+_LIT8( KTrue,                           "true"                              );
+_LIT8( KObjectProperty,                 "p"                                 );
+_LIT8( KObjectName,                     "n"                                 );
+_LIT8( KRequiredObject,                 "r"                                 );
+_LIT8( KMultiValueObject,               "m"                                 );
+_LIT8( KVendorDescriptor,               "desc"                              );
+_LIT8( KColon8,                         ":"                                 );
+_LIT8( KArtist,                         "artist"                            );
+_LIT8( KAlbum,                          "album"                             );
+_LIT8( KImageMime,                      "image"                             );
+_LIT8( KTextMime,                       "text"                              );
+_LIT8( KVideoMime,                      "video"                             );
+_LIT8( KAudioMime,                      "audio"                             );
+_LIT8( KObjectClassAudioItem,           "object.item.audioItem"             );
+_LIT8( KObjectClassVideoItem,           "object.item.videoItem"             );  
+_LIT8( KObjectClassTextItem,            "object.item.textItem"              );    
+_LIT8( KObjectClassImageItem,           "object.item.imageItem"             );      
+_LIT8( KJpegLrg,                        "JPEG_LRG"                          );
+_LIT8( KJpegMed,                        "JPEG_MED"                          );
+_LIT8( KJpegSm,                         "JPEG_SM"                           );
+
+// SQL Strings
+_LIT(  KDeleteFromSqlCmd,               "DELETE FROM %S WHERE %S=%S"        );
+_LIT(  KOpenParant,                     "("                                 );
+_LIT(  KValuesOpen,                     " VALUES("                          );
+_LIT(  KCloseParant,                    ")"                                 );
+_LIT(  KInsertInto,                     "INSERT INTO "                      );
+_LIT(  KOnlyRequiredFromElement,        " AND elm_is_required=1"            );
+_LIT(  KNamedElFromElement,             " AND elm_name='%S'"                );
+_LIT(  KSelectFromObjectSqlCmd,         "SELECT %S FROM object WHERE id=%d" );
+_LIT(  KOnlyRequiredFromAtr,            " AND atr_is_required=1"            );
+_LIT(  KNamedAtrFromAttribute,          " AND atr_name='%S'"                );
+_LIT(  KFullPathFromShareMap,           " OR %S='%S'"                       );
+_LIT(  KSelectFromSqlCmd,               "SELECT %S FROM %S WHERE %S='%S'"   );
+_LIT(  KSelectFromNumSqlCmd,            "SELECT %S FROM %S WHERE %S=%d"     );
+_LIT(  KSelectFromNumNotEqSqlCmd,       "SELECT %S FROM %S WHERE %S<>%d"    );
+_LIT(  KAndConditionSqlCmd,             " AND %S='%S'"                      );
+_LIT(  KAndLikeConditionSqlCmd,         " AND %S LIKE '*%S'"               );
+_LIT(  KSelectAttributeByValueSqlCmd,   "SELECT * FROM attribute WHERE atr_value LIKE '*%S*' AND atr_name = '%S' ");
+_LIT(  KNewMediaDirSqlCmd,              "UPDATE resources SET rsc_readonly=1 WHERE rsc_path LIKE '%S*' AND rsc_readonly=0");
+_LIT(  KInsertElementSqlCmd,            "INSERT INTO element (elm_id,elm_name,elm_value,elm_has_attribute,elm_obj_id,elm_is_required)VALUES(%d,'%S','%S',%d,%d,%d)");
+_LIT(  KInsertAttributeSqlCmd,          "INSERT INTO attribute(atr_id,atr_name,atr_value,atr_elm_id,atr_is_required) VALUES(%d,'%S','%S',%d,%d)");
+_LIT(  KGetObjectListSqlCmd,            "SELECT id FROM object WHERE parentID=%d");
+_LIT(  KGetItemListSqlCmd,              "SELECT id FROM object WHERE parentID=%d AND class LIKE 'object.item*'");
+_LIT(  KGetContainerListSqlCmd,         "SELECT id FROM object WHERE parentID=%d AND class LIKE 'object.container*'");
+_LIT(  KSelectIdFromElSqlCmd,           "SELECT elm_id, elm_name, elm_value FROM element WHERE elm_obj_id=%d" );
+_LIT(  KDeleteResElSqlCmd,              "DELETE FROM element WHERE elm_value='%S' AND elm_obj_id=%d");
+_LIT(  KSelectObjectFromObjSqlCmd,      "SELECT id, parentID, title, class, restricted, searchable, refID FROM object WHERE id = %d");
+_LIT(  KSelectElmFromElmSqlCmd,         "SELECT elm_name, elm_value, elm_has_attribute, elm_id, elm_is_required FROM element WHERE elm_obj_id = %d");
+_LIT(  KSelectAtrFromAttrSqlCmd,        "SELECT atr_name, atr_value FROM attribute WHERE atr_elm_id = %d");
+_LIT(  KSelectAtrFromAttrByObjSqlCmd,   "SELECT atr_name, atr_value, atr_elm_id FROM attribute WHERE atr_id_obj = %d");
+
+// initial data
+_LIT(  KInit1,                          "INSERT INTO object (id,parentID,title,class,restricted,searchable,path) VALUES(0,-1,'root','object.container',0,1,'-1')");
+_LIT(  KInit2,                          "INSERT INTO object (id,parentID,title,class,restricted,searchable,path) VALUES(1,0,'Uploaded','object.container',0,1,'-1.0')");
+_LIT(  KInit3,                          "INSERT INTO sequences(seq_col_name,seq_next_key) VALUES('object',2)" );
+_LIT(  KInit4,                          "INSERT INTO sequences(seq_col_name,seq_next_key) VALUES('element',0)");
+_LIT(  KInit5,                          "INSERT INTO sequences(seq_col_name,seq_next_key) VALUES('attribute',0)");
+_LIT(  KInit6,                          "INSERT INTO sequences(seq_col_name,seq_next_key) VALUES('uriId',1)"  );
+
+
+enum TCurrentAction 
+{
+    EUndefinedAction = 0,
+    ECreateObjectAction = 1,
+};
+
+#endif //C_UPNPCONTENTDIRECTORYDBGLOBALS_H
+// End of File
--- a/upnpmediaserver/contentdirectoryservice/inc/upnpelementfactory.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/inc/upnpelementfactory.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,305 +1,326 @@
-/** @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:  Declares ElementFactory class.
-*
-*/
-
-
-#ifndef C_CUPNPELEMENTFACTORY_H
-#define C_CUPNPELEMENTFACTORY_H
-
-
-// INCLUDES
-
-#include <xml/dom/xmlengdom.h>
-#include <xml/dom/xmlengdocument.h>
-#include "upnpcontentdirectory.h"
-#include "upnpfiletransfer.h"
-#include "upnperrors.h" // Added by ClassView
-#include "upnpdominterface.h"
-
-// FORWARD DECLARATIONS
-
-class CUpnpElementFactory;
-class TUpnpContainerUpdateId;
-class CUpnpFileTransferTimerObserver;
-class CUpnpObject;
-class CUpnpItem;
-
-
-// FORWARD DECLARATIONS
-
-class CUpnpContentDirectory;
-
-// CLASS DECLARATION
-
-/**
-*  @brief Used to create content objects
-*
-*
-*  @lib contentdirectory.lib
-*  @since Series60 2.6
-*/
-class CUpnpElementFactory : public CBase
-{
-public: // Constructors and destructors
-                         
-    /**
-    * Gets active element from XML document. An active element
-    * is a first element different from <DIDL-Lite> element.
-    * @param aDocument XML document which will be search for active element.
-    * @return handler to active element.
-    */
-    TXmlEngElement ActiveElementL( const RXmlEngDocument& aDocument );
-    
-    /**
-    * Extracts active element from XML document. 
-    * An active element is a first element different from <DIDL-Lite> element.
-    * IMPORTANT: Caller takes responsibility for returned element. 
-    * @param aDocument XML document which will be search for active element.
-    * @return handler to extracted active element.
-    */
-    RXmlEngDocument ExtractActiveElementL( const RXmlEngDocument& aDocument );
-    
-    /**
-    * Checks if two elements are equal and have exactly the same subtrees.
-    * @param aFirst - first element to compare
-    * @param aSecond - second element to compare
-    * @return ETrue if elemants are equal.
-    */
-    TBool ElementsMatchL( TXmlEngElement aFirst, TXmlEngElement aSecond );
-    
-    /**
-    * Counts elements in array that have the same name.
-    * @param aName - name of elements, which will be counted.
-    * @param aArray - array with elements to count.
-    * @return number of found elements.
-    */ 
-    TInt CountElementsL( const TDesC8& aName, RArray<RXmlEngDocument>& aArray );
-    
-    /**
-    * Counts elements in array that have the same name.
-    * @param aName - name of elements, which will be counted.
-    * @param aArray - array with elements to count.
-    * @return number of found elements.
-    */ 
-    TInt CountElementsL( const TDesC8& aName, RArray<TXmlEngElement>& aArray );   
-    
-    /**
-    * Gets classes descriptions for given object.
-    * @param aObject - element representing object, which classes 
-    *   descriptions we wan to acquire
-    * @param aArray - (OUT) reference to array which will be filled with classes
-    *   descriptions. 
-    * @param aObjType - object type [item or container]
-    */
-    void ClassesL( const TXmlEngElement& aObject, RArray<TXmlEngElement>& aArray, const TDesC8& aObjType = KNullDesC8() );
-    
-    /**
-    * Constructs descriptor with element's name and namespace prefix separated with colon.
-    * IMPORTANT: As the function name indicates, it leaves pointer to heap descriptor on 
-    * cleanup stack.
-    * @param aElement - element for which descriptor will be constructed.
-    * @return  - pointer to descriptor, allocated on the heap, containing element's name with prefix.
-    */ 
-    HBufC8* NameWithNsLC( const TXmlEngElement& aElement );
-    
-
-    /**
-    * Two-phased constructor for building CUpnpElementFactory.
-    * @since Series60 2.6
-    */
-    static CUpnpElementFactory* NewL( const TDesC& aObjectsXmlPath );
-
-    /**
-    * Two-phased constructor for building CUpnpElementFactory.
-    * @since Series60 2.6
-    */
-    static CUpnpElementFactory* NewLC( const TDesC& aObjectsXmlPath );
-
-    /**
-    * Destructor function; called automatically from the destructor of a 
-    * derived class
-    */
-    virtual ~CUpnpElementFactory();
-
-    /**
-    * Function to validate a new object given by Control Point, especially 
-    * upnp:class element field eg. object.item.musictrack
-    * IMPORTANT: If objects's description is invalid due to missing elements
-    * it tries to repair it by adding those missing elements.
-    * @since Series60 2.6
-    * @param aElement element (xml) given by Control Point
-    * @param aUpdateItem 
-    * @return Returns a error code that is to be sent to caller of action.
-    */
-    TUpnpErrorCode ValidateNewObjectL( const TXmlEngElement& aNewElement, TBool aNew = ETrue, TBool aLocalSharing = EFalse );
-    
-    /**     
-    * Function gets pointer to CUpnpContentDirectory and puts it into CUpnpElementFactory object 
-    * @param aCD - pointer to CUpnpContentDirectory object
-    */ 
-    void GetContentDirectoryReference(CUpnpContentDirectory* aCD);
-    
-private: // Constructors
-
-    /**
-    * C++ default constructor.
-    */
-    CUpnpElementFactory();
-
-    /**
-    * Second phase of the constructor.
-    * By default Symbian 2nd phase constructor is private.
-    * @param service Parent service
-    */
-    void ConstructL(const TDesC& aObjectsXmlPath);
-
-private: // New functions
-    
-    void ValidateBigImageL( TXmlEngElement aObj);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aPattern
-    * @return boolean 
-    */
-    TBool IsRequiredL(TXmlEngElement aPattern);
-    
-    /**
-    * Getter
-    * @since Series S60 3.1
-    * @param aPropertyName
-    * @param aClassList
-    * @return TXmlEngElement
-    */
-    TXmlEngElement GetPatternForResAttrL(const TDesC8& aPropertyName, RArray<TXmlEngElement>& aClassList );
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aElement
-    * @param aClassList
-    */
-    void ValidateResElL( TXmlEngElement aElement, RArray<TXmlEngElement>& aClassList);
-    
-    /**
-    * Validates element
-    * @since Series S60 3.1
-    * @param aElement
-    * @param aClasList
-    */
-    void ValidateElementL(TXmlEngElement aElement, RArray<TXmlEngElement>& aClassList);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aObj
-    * @parma aClassList
-    */
-    void ValidatePropertiesL(TXmlEngElement aObj, RArray<TXmlEngElement>& aClassList);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aObj
-    * @param aClassList
-    */
-    void ValidateMainAttributesL(TXmlEngElement aObj, RArray<TXmlEngElement>& aClassList);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aAttr
-    * @parma aPattern
-    */
-    void ValidateElWithPatternL(TXmlEngElement aAttr, TXmlEngElement aPattern);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aAttr
-    * @param aPattern
-    */
-    void ValidateAttrWithPatternL(TXmlEngAttr aAttr, TXmlEngElement aPattern);
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aPropertyName
-    * @param aClassList
-    * @return TXmlEngElement
-    */
-    TXmlEngElement GetPatternL( const TDesC8& aPropertyName, RArray<TXmlEngElement>& aClassList, const TDesC8& aType );
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aElement
-    * @return boolean
-    */
-    TBool IsClassElement( const TXmlEngElement& aElement );
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aElement
-    * @return boolean
-    */
-    TBool IsNotEmptyImportUriL( const TXmlEngElement& aElement );
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aElement
-    * @return boolean
-    */
-    TBool IsMainObjectTagL(TXmlEngElement aElement);
-
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aProtocolInfo
-    * @param aLocalSharing
-    * @return descriptor pointer
-    */        
-    HBufC8* ValidateProtocolInfoInResL( const TDesC8& aProtocolInfo, TBool aLocalSharing );
-    
-    /**
-    *
-    * @since Series S60 3.1
-    * @param aElement    
-    */
-    void CheckDurationOfResElementL(const TXmlEngElement& aElement);
-    
-    /**
-    *
-    * @since Series S60 3.2
-    * @param aElement    
-    */
-    void CheckSizeOfResElementL(const TXmlEngElement& aElement);
-                    
-private: // Data
-
-    // owned
-    RXmlEngDocument               iDocument;
-    // Pointer to content directory
-    CUpnpContentDirectory*  iContentDirectory;
-    RXmlEngDOMImplementation iDOMImpl;
-};
-
-#endif  // C_CUPNPELEMENTFACTORY_H
-
-// End of File
+/** @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:  Declares ElementFactory class.
+*
+*/
+
+
+#ifndef C_CUPNPELEMENTFACTORY_H
+#define C_CUPNPELEMENTFACTORY_H
+
+
+// INCLUDES
+
+#include <xmlengdom.h>
+#include <xmlengdocument.h>
+#include "upnpcontentdirectory.h"
+#include "upnpfiletransfer.h"
+#include "upnperrors.h" // Added by ClassView
+#include "upnpdominterface.h"
+
+// FORWARD DECLARATIONS
+
+class CUpnpElementFactory;
+class TUpnpContainerUpdateId;
+class CUpnpFileTransferTimerObserver;
+class CUpnpObject;
+class CUpnpItem;
+
+
+// FORWARD DECLARATIONS
+
+class CUpnpContentDirectory;
+
+// CLASS DECLARATION
+
+/**
+*  @brief Used to create content objects
+*
+*
+*  @lib contentdirectory.lib
+*  @since Series60 2.6
+*/
+class CUpnpElementFactory : public CBase
+{
+public: // Constructors and destructors
+                         
+    /**
+    * Gets active element from XML document. An active element
+    * is a first element different from <DIDL-Lite> element.
+    * @param aDocument XML document which will be search for active element.
+    * @return handler to active element.
+    */
+    TXmlEngElement ActiveElementL( const RXmlEngDocument& aDocument );
+    
+    /**
+    * Extracts active element from XML document. 
+    * An active element is a first element different from <DIDL-Lite> element.
+    * IMPORTANT: Caller takes responsibility for returned element. 
+    * @param aDocument XML document which will be search for active element.
+    * @return handler to extracted active element.
+    */
+    RXmlEngDocument ExtractActiveElementL( const RXmlEngDocument& aDocument );
+    
+    /**
+    * Checks if two elements are equal and have exactly the same subtrees.
+    * @param aFirst - first element to compare
+    * @param aSecond - second element to compare
+    * @return ETrue if elemants are equal.
+    */
+    TBool ElementsMatchL( TXmlEngElement aFirst, TXmlEngElement aSecond );
+    
+    /**
+    * Counts elements in array that have the same name.
+    * @param aName - name of elements, which will be counted.
+    * @param aArray - array with elements to count.
+    * @return number of found elements.
+    */ 
+    TInt CountElementsL( const TDesC8& aName, RArray<RXmlEngDocument>& aArray );
+    
+    /**
+    * Counts elements in array that have the same name.
+    * @param aName - name of elements, which will be counted.
+    * @param aArray - array with elements to count.
+    * @return number of found elements.
+    */ 
+    TInt CountElementsL( const TDesC8& aName, RArray<TXmlEngElement>& aArray );   
+    
+    /**
+    * Gets classes descriptions for given object.
+    * @param aObject - element representing object, which classes 
+    *   descriptions we wan to acquire
+    * @param aArray - (OUT) reference to array which will be filled with classes
+    *   descriptions. 
+    * @param aObjType - object type [item or container]
+    */
+    void ClassesL( const TXmlEngElement& aObject, RArray<TXmlEngElement>& aArray, const TDesC8& aObjType = KNullDesC8() );
+    
+    /**
+    * Constructs descriptor with element's name and namespace prefix separated with colon.
+    * IMPORTANT: As the function name indicates, it leaves pointer to heap descriptor on 
+    * cleanup stack.
+    * @param aElement - element for which descriptor will be constructed.
+    * @return  - pointer to descriptor, allocated on the heap, containing element's name with prefix.
+    */ 
+    HBufC8* NameWithNsLC( const TXmlEngElement& aElement );
+    
+
+    /**
+    * Two-phased constructor for building CUpnpElementFactory.
+    * @since Series60 2.6
+    */
+    static CUpnpElementFactory* NewL( const TDesC& aObjectsXmlPath );
+
+    /**
+    * Two-phased constructor for building CUpnpElementFactory.
+    * @since Series60 2.6
+    */
+    static CUpnpElementFactory* NewLC( const TDesC& aObjectsXmlPath );
+
+    /**
+    * Destructor function; called automatically from the destructor of a 
+    * derived class
+    */
+    virtual ~CUpnpElementFactory();
+
+    /**
+    * Function to validate a new object given by Control Point, especially 
+    * upnp:class element field eg. object.item.musictrack
+    * IMPORTANT: If objects's description is invalid due to missing elements
+    * it tries to repair it by adding those missing elements.
+    * @since Series60 2.6
+    * @param aElement element (xml) given by Control Point
+    * @param aUpdateItem 
+    * @return Returns a error code that is to be sent to caller of action.
+    */
+    TUpnpErrorCode ValidateNewObjectL( const TXmlEngElement& aNewElement, TBool aNew = ETrue, TBool aLocalSharing = EFalse );
+    
+    /**     
+    * Function gets pointer to CUpnpContentDirectory and puts it into CUpnpElementFactory object 
+    * @param aCD - pointer to CUpnpContentDirectory object
+    */ 
+    void GetContentDirectoryReference(CUpnpContentDirectory* aCD);
+    
+private: // Constructors
+
+    /**
+    * C++ default constructor.
+    */
+    CUpnpElementFactory();
+
+    /**
+    * Second phase of the constructor.
+    * By default Symbian 2nd phase constructor is private.
+    * @param service Parent service
+    */
+    void ConstructL(const TDesC& aObjectsXmlPath);
+
+private: // New functions
+    
+    void ValidateBigImageL( TXmlEngElement aObj);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aPattern
+    * @return boolean 
+    */
+    TBool IsRequiredL(TXmlEngElement aPattern);
+    
+    /**
+    * Getter
+    * @since Series S60 3.1
+    * @param aPropertyName
+    * @param aClassList
+    * @return TXmlEngElement
+    */
+    TXmlEngElement GetPatternForResAttrL(const TDesC8& aPropertyName, RArray<TXmlEngElement>& aClassList );
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aElement
+    * @param aClassList
+    */
+    void ValidateResElL( TXmlEngElement aElement, RArray<TXmlEngElement>& aClassList);
+    
+    /**
+    * Validates element
+    * @since Series S60 3.1
+    * @param aElement
+    * @param aClasList
+    */
+    void ValidateElementL(TXmlEngElement aElement, RArray<TXmlEngElement>& aClassList);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aObj
+    * @parma aClassList
+    */
+    void ValidatePropertiesL(TXmlEngElement aObj, RArray<TXmlEngElement>& aClassList);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aObj
+    * @param aClassList
+    */
+    void ValidateMainAttributesL(TXmlEngElement aObj, RArray<TXmlEngElement>& aClassList);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aAttr
+    * @parma aPattern
+    */
+    void ValidateElWithPatternL(TXmlEngElement aAttr, TXmlEngElement aPattern);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aAttr
+    * @param aPattern
+    */
+    void ValidateAttrWithPatternL(TXmlEngAttr aAttr, TXmlEngElement aPattern);
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aPropertyName
+    * @param aClassList
+    * @return TXmlEngElement
+    */
+    TXmlEngElement GetPatternL( const TDesC8& aPropertyName, RArray<TXmlEngElement>& aClassList, const TDesC8& aType );
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aElement
+    * @return boolean
+    */
+    TBool IsClassElement( const TXmlEngElement& aElement );
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aElement
+    * @return boolean
+    */
+    TBool IsNotEmptyImportUriL( const TXmlEngElement& aElement );
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aElement
+    * @return boolean
+    */
+    TBool IsMainObjectTagL(TXmlEngElement aElement);
+
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aProtocolInfo
+    * @param aLocalSharing
+    * @return descriptor pointer
+    */        
+    HBufC8* ValidateProtocolInfoInResL( const TDesC8& aProtocolInfo, TBool aLocalSharing );
+    
+    /**
+    *
+    * @since Series S60 3.1
+    * @param aElement    
+    */
+    void CheckDurationOfResElementL(const TXmlEngElement& aElement);
+    
+    /**
+    *
+    * @since Series S60 3.2
+    * @param aElement    
+    */
+    void CheckSizeOfResElementL(const TXmlEngElement& aElement);
+    
+    /**
+     * Checks if value is restricted
+     * @param restrVal
+     */
+    TBool CheckRestrictedValue (TPtrC8& restrVal);
+    
+    void ValidateAttributeL(TXmlEngElement aElement, TXmlEngElement aObject);
+    
+    void CheckNestedElementsL(RXmlEngNodeList<TXmlEngElement> aNestEls, TXmlEngElement aChild,
+            TBool aLocalSharing);
+    
+    TBool HandleChildrenL (RXmlEngNodeList<TXmlEngElement> aChildren, TBool aNew, TBool aLocalSharing,
+            TBool aElementFound, TXmlEngElement aEl);
+    
+    TBool ValidateElementL (TXmlEngElement aObject, 
+            const TDesC8& aPropertyType, TXmlEngElement aEl, TBool aElementFound, TBool aNew,
+            TBool aLocalSharing);
+    
+    void CheckElementValidity (TXmlEngElement& aElement);
+    
+                    
+private: // Data
+
+    // owned
+    RXmlEngDocument               iDocument;
+    // Pointer to content directory
+    CUpnpContentDirectory*  iContentDirectory;
+    RXmlEngDOMImplementation iDOMImpl;
+};
+
+#endif  // C_CUPNPELEMENTFACTORY_H
+
+// End of File
--- a/upnpmediaserver/contentdirectoryservice/inc/upnpmetadatastorage.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/inc/upnpmetadatastorage.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,482 +1,482 @@
-/** @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:  Database for MediaServer
-*
-*/
-
-
-
-#ifndef UPNPMETADATASTORAGE_H
-#define UPNPMETADATASTORAGE_H
-
-//  INCLUDES
-#include <e32base.h>
-#include <f32file.h>
-#include <d32dbms.h>
-#include <s32file.h>
-#include <upnperrors.h>
-#include <xml/dom/xmlengdom.h>
-
-// FORWARD DECLARATIONS
-class CUpnpObjectBean;
-class CUpnpElementBean;
-class CUpnpAttributeBean;
-class CUpnpResourcesBean;
-
-// CLASS DECLARATION
-
-/**
-*  Metadata storage
-*
-*  @lib avcontentdirectory.lib
-*  @since Series 60 3.0
-*/
-class CUpnpMetadataStorage : public CBase
-{
-public:  // Constructors and destructor
-    
-    /**
-    * Two-phased constructor.
-    */
-    static CUpnpMetadataStorage* NewL(const TDesC& aDatabaseFileName);
-    static CUpnpMetadataStorage* NewLC(const TDesC& aDatabaseFileName);
-    
-    /**
-    * Destructor.
-    */
-    virtual ~CUpnpMetadataStorage();
-
-public: // New functions
-    
-    /**
-    * Deletes object from database
-    * @since Series S60 3.0
-    * @param aObjId id of the object to be deleted
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-        TBool IsContainerL(TInt aObjId);
-        void DeleteResourcesL(RArray<TInt>& aObjList);
-        void AddResourceL(CUpnpResourcesBean* aResBean, TInt aObjId);
-       	TUpnpErrorCode DoDeleteObjectL(TInt aObjId, TBool aDeleteResource, TBool aDeleteRef=ETrue );
-		void InsertIntoAttributeTableL(TInt aElmId, CUpnpAttributeBean* aAtrBn, TInt aObjId, TInt aAtrId);
- 		TInt InsertIntoElementTableL(TInt aObjId, CUpnpElementBean* aElmBn, TInt aElmId);
-		TInt InsertIntoObjectTableL(TInt aContainer, CUpnpObjectBean* aObjBn);
-    /**
-    * @since Series S60 3.1
-    * @param aObjId
-    * @return RDbView
-    */
-    RDbView GetObjViewL(TInt aObjId);
-        
-    /**
-    *
-    * @since Series S60 3.1
-    */
-    void BeginTransactionL();
-    
-    /**
-    *
-    * @since Series S60 3.1
-    */
-    void CommitTransactionL();
-    
-    /**
-    *
-    * @since Series S60 3.1
-    */
-    void RollbackTransactionL();
-        
-    /**
-    * Getter
-    * @since Series S30 3.1
-    * @param aObjectID
-    * @param aAll
-    * @return RDbView
-    */
-    RDbView GetElementsViewL(TInt aObjectID, TBool aAll);
-        
-    /**
-    * Getter
-    * @since Series S30 3.1
-    * @param aElementID
-    * @param aAll
-    * @return RDbView
-    */
-    RDbView GetAttributesViewL(TInt aElementID, TBool aAll);
-       
-    /**
-    * Getter
-    * @since Series S30 3.2
-    * @param aObjectID
-    * @param aAll
-    * @return RDbView
-    */
-    RDbView GetAttributesViewByObjectIdL( TInt aObjectID, TBool aAll );
-
-    /**
-    * Getter
-    * @since Series S30 3.1
-    * @param aAttrNameID
-    * @param aAttrVal
-    * @return 
-    */
-    TInt GetElmIdForAttrL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
-        
-    /**
-    * Getter
-    * @since Series S30 3.1
-    * @param aAttrName
-    * @param aAttrVal
-    * @return 
-    */
-    TInt GetElmIdForAttrLikeL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
-        
-    /**
-    * 
-    * @since Series S30 3.1
-    * @param aResVal
-    * @param aObjId
-    */
-    void DeleteResElL(const TDesC& aResVal, TInt ObjId);
-        
-    /**
-    * Getter
-    * @since Series S30 3.1
-    * @param aResVal
-    * @return RDbView
-    */
-    RDbView GetViewOfObjectListForResL(const TDesC& aResVal);
-        
-    /**
-    * Getter
-    * @since Series S30 3.1
-    * @param aElmName
-    * @param aElmValue
-    * @return RDbView
-    */
-    RDbView GetViewOfElmIdByNameAndValL(const TDesC& aElmName,  const TDesC& aElmValue);
-        
-    /**
-    * Getter
-    * @since Series S30 3.1
-    * @param aAttrName
-    * @param aAttrVal
-    * @return RDbView
-    */
-    RDbView GetAttrViewL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
-        
-    /**
-    * Getter
-    * @since Series S30 3.1
-    * @param aElmId
-    * @param aAttrName
-    * @return RDbView
-    */
-    RDbView GetAttrViewL(TInt aElmId, const TDesC8& aAttrName);
-    
-    /**
-    * Getter
-    * @since Series S30 3.2
-    * @param aBjectId
-    * @param aAttrName
-    * @return RDbView
-    */
-    RDbView GetAttrViewByObjectIdL(TInt aBjectId, const TDesC8& aAttrName);    
-        
-    /**
-    * 
-    * @since Series S30 3.1
-    * @param aSqlQuery
-    * @return RDbView
-    */
-    RDbView PrepareViewL(const TDesC& aSqlQuery);
-        
-    /**
-    * Getter
-    * @since Series S30 3.1
-    * @param aSqlQuery
-    * @return RDbView
-    */
-	RDbView GetEvaluatedViewL(const TDesC& aSqlQuery);
- 	HBufC8* GetObjectPathL(TInt aObjId);
- 	HBufC8* GetObjectTitleL(TInt aObjId);
-	void ExecuteL(const TDesC& aSqlCommand);
- 	CUpnpResourcesBean* GetResourceL(TInt64 aResId);
-	void DeleteResourceByObjIdL(TInt aObjId, TBool aDeleteFile=ETrue);
-	void DeleteResourceByResIdL(TInt64 aResId, TBool aDeleteFile=ETrue);
-	void DeleteObjectsL(TInt aObjId);
-	void DeleteElementsL(TInt aObjId);
-	void DeleteAttributesL(TInt aObjId);
-	void DeleteReferencesL(TInt aObjId,RArray<TInt>& aRefList);
-
-    /**
-    * Performs object deletion; a transaction should be started before calling this function
-    * @since Series S60 3.0
-    * @param id of the object to be deleted
-    * @param aObjId aCd pointer to the ContentDirectory object - it provides a function which deletes
-    * 				a file from the private directory
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
- 	TInt DoDeleteObjectL(TInt aObjId,RArray<TInt>& aRefList,
- 	                     RArray<TInt>& aResList, TBool aDeleteResource, TBool aLocal, TBool aDeleteRef = ETrue );
-
-    /**
-    * Checks the restrictions of the parent object of the given object.
-    * @since Series S60 3.0
-    * @param aObjId object's id
-	* @return returns EUpnpOk if object with the given id exists in database and is a "non restricted conainer"    
-	*/
-	TUpnpErrorCode CheckParentRestrictionL(TInt aObjId);
-
-    /**
-    * Deletes object from database
-    * @since Series S60 3.0
-    * @param aObjId id of the object to be deleted
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-	TUpnpErrorCode DeleteObjectL(TInt aObjId,RArray<TInt>& aRefList, TBool aDeleteResource,
-	                             TBool aLocal = EFalse, TBool aDeleteRef = ETrue );
-   	
-
-    /**
-    * Gets the descriptor value of the specified column in the rowset.
-    * @since Series S60 3.0
-    * @param aRowset rowset object
-    * @param aColNo the number of the column to be get the value of
-    * @return descriptor containing the value of the specified column,
-    *       the caller should delete it when it is no longer needed
-    */
-    HBufC8* GetColDesValFromRowSetL(RDbRowSet aRowset, TDbColNo aColNo);
-
-    /**
-    * Gets the value of childCount property for the given object.
-    * @since Series S60 3.0
-    * @param aObjId object's id
-    * @return value of childCount property
-    */
-    TInt GetChildCountL(TInt aObjId);
-        
-    /**
-    * Gets the parent object's id of the object with given id.
-    * @since Series S60 3.0
-    * @param aObjId child object id
-    * @return perent object id
-    */
-    TInt GetParentIdL(TInt aObjId);
-
-    /**
-    * Gets the id of the object which the element with given id belongs to.
-    * @since Series S60 3.0
-    * @param aId element's id
-    * @return object's id
-    */
-    TInt GetObjIdForElmIdL(TInt aId);
-
-    /**
-    * Gets id of reffered object 
-    * @since Series S60 3.0
-    * @param aObjectId object id
-    * @return reffered object id.
-    */
-    TInt ReferedObjectIdL( TInt aObjectId );
-
-    /**
-    * Gets the next free id in the specified table 
-    * @since Series S60 3.0
-    * @param aName name of the table
-    * @return TInt next free id in the specified table
-    */
-    TInt GetNextKeyL(const TDesC8& aName);
-    TInt GetNextKeyL(const TDesC8& aName, TInt aAmount);
-    /**
-    * Gets the next free id in the specified table 
-    * @since Series S60 3.0
-    * @param aName name of the table
-    * @return TInt next free id in the specified table
-    */
-    TInt NextKeyL(const TDesC8& aName);
-
-    /**
-    * Insert object's data into 'object' table
-    * @since Series S60 3.0
-    * @param aElement TXmlEngElement of the object to be added
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    void InsertObjectIntoObjectTableL(const TXmlEngElement& aElement);
-
-    /**
-    * Inserts single attribute into the database 
-    * @since Series S60 3.0
-    * @param aAttr TXmlEngAttr of the attribute to be inserted
-    * @param aElmId id of the element this attribute belongs to
-    * 2param aIsRequired 
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    void InsertAttributeL(const TXmlEngAttr aAttr, TInt aElmId, TBool aIsRequired, TInt aObjId);
-
-    /**
-    * Inserts element into database 
-    * @since Series S60 3.0
-    * @param aElementel TXmlEngElement of the element to be inserted
-    * @param aObjId id of the object this element belongs to
-    */
-    TInt  InsertElementL(const TXmlEngElement& aElementel, TInt aObjId);
-
-    /**
-    * Gets the database view of the named element of the specified object.
-    * @since Series S60 3.0
-    * @param aObjId object's id
-    * @param aElName name of the element which we want to get the view of
-    * @return ?description
-    */
-    RDbView GetElementViewL(TInt aObjId, const TDesC8& aElName);
-
-    /**
-    * Adds an attribute from object table to the object's main element.
-    * @since Series S60 3.0
-    * @param aElement object's element
-    * @param aId object's id
-    * @param aName name of the attribute which is to be added
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode AddMainTagAttrL(TXmlEngElement aElement, TInt aId, const TDesC8& aName);
-
-
-    /**
-    * Gets the list direct children of object with specified id
-    * @since Series S60 3.0
-    * @param aParentId id of the parent object
-    * @param aList an array to be filled with object
-    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
-    */
-    TUpnpErrorCode GetObjectListL(TInt aParentId, RArray<TInt>& aList);
-    TUpnpErrorCode GetItemListL(TInt aParentId, RArray<TInt>& aList);
-    TUpnpErrorCode GetContainerListL(TInt aParentId, RArray<TInt>& aList);
-
-    /**
-    * Checks if object with the given id exists, is a container and its 'restricted' attribute has value of 'false'
-    * @since Series S60 3.0
-    * @param aObjId id of the object to be checked
-    * @return returns EUpnpOk if object with the given id exists in database and is a "non restricted conainer"
-    */
-    TUpnpErrorCode CheckObjectRestrictionL(TInt aObjId);
-
-    /**
-    * Recovers the database.
-    * @since Series S60 3.1
-    * @return Standard error code
-    */
-    TInt RecoverDatabase();
-
-    /**
-    * Recreates the database file.
-    * @since Series S60 3.1
-    */
-    void RecreateDatabaseFileL();
-
-    /**
-    * Checks if all database columns in each table have propper definitions.
-    * If not, it leaves with KErrCorrupt.
-    * @since Series S60 3.2
-    */
-    void CheckDatabaseL();  
-
-    /**
-    * Handles DB error
-    * Tries to recover, if fails tries to recreate
-    * @since Series S60 3.2
-    * @return TInt - KErrNone if succed
-    */
-    TInt HandleDbError( TInt aError );
-    
-    /**
-    * Returns DB creation status
-    * @since Series S60 3.2
-    * @return TBool
-    */
-    TBool IsDbCreated();
-   
-    
-private:
-
-    /**
-    * C++ default constructor.
-    */
-    CUpnpMetadataStorage();
-
-    /**
-    * By default Symbian 2nd phase constructor is private.
-    */
-    void ConstructL(const TDesC& aDatabaseFileName);
-
-private:
-    
-    void CompactDbL();    
-    TInt AddSubObjectsL(TInt aObjId, RArray<TInt>& aObjList, RArray<TInt>& aResList, TBool aLocal);
-
-    /**
-    * Compare two column sets (type, maxsize and attributes). Used by CheckDatabaseL() function.
-    * Leaves with KErrCorrupt when columns are not agree.
-    * @since Series S60 3.2
-    * @param aColSet1 First column set to compare
-    * @param aColSet2 Second column set to compare
-    */
-    void CompareDbColSetsL( CDbColSet *aColSet1, CDbColSet *aColSet2 );
-
-    /**
-    * Deletes the file
-    * @since Series S30 3.1
-    * @param aPath
-    */
-    void DeleteFileL(const TDesC& aPath);
-        
-    /**
-    *
-    * @since Series S30 3.1
-    * @param aElement
-    * @return descriptor pointer
-    */
-    HBufC8* CreatePathValL(const TXmlEngElement& aElement);
-		HBufC8* CreatePathValL(TInt aParentId);
-    /**
-    * Opens database
-    * @since Series S30 3.1
-    * @param aDatabaseFileName
-    */
-    void OpenDbL( const TFileName& aDatabaseFileName );
-        
-    /**
-    *
-    * @since Series S30 3.1
-    * @param aWeight
-    */
-    void DbChangedL(TInt aWeight);
-
-private:    
-
-    // For use of iFileStore
-    RFs                iFsSession; 
-    // For database operations
-    RDbStoreDatabase    iDatabase;  
-    TBool               iIsOpen;
-    // For creating and opening database files
-    CFileStore*         iFileStore; 
-    // compact counter
-    TInt                iCompactCounter;
-
-};
-
-#endif      // UPNPMETADATASTORAGE_H   
-        
-// End of File
+/** @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:  Database for MediaServer
+*
+*/
+
+
+
+#ifndef UPNPMETADATASTORAGE_H
+#define UPNPMETADATASTORAGE_H
+
+//  INCLUDES
+#include <e32base.h>
+#include <f32file.h>
+#include <d32dbms.h>
+#include <s32file.h>
+#include <upnperrors.h>
+#include <xmlengdom.h>
+
+// FORWARD DECLARATIONS
+class CUpnpObjectBean;
+class CUpnpElementBean;
+class CUpnpAttributeBean;
+class CUpnpResourcesBean;
+
+// CLASS DECLARATION
+
+/**
+*  Metadata storage
+*
+*  @lib avcontentdirectory.lib
+*  @since Series 60 3.0
+*/
+class CUpnpMetadataStorage : public CBase
+{
+public:  // Constructors and destructor
+    
+    /**
+    * Two-phased constructor.
+    */
+    static CUpnpMetadataStorage* NewL(const TDesC& aDatabaseFileName);
+    static CUpnpMetadataStorage* NewLC(const TDesC& aDatabaseFileName);
+    
+    /**
+    * Destructor.
+    */
+    virtual ~CUpnpMetadataStorage();
+
+public: // New functions
+    
+    /**
+    * Deletes object from database
+    * @since Series S60 3.0
+    * @param aObjId id of the object to be deleted
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+        TBool IsContainerL(TInt aObjId);
+        void DeleteResourcesL(RArray<TInt>& aObjList);
+        void AddResourceL(CUpnpResourcesBean* aResBean, TInt aObjId);
+       	TUpnpErrorCode DoDeleteObjectL(TInt aObjId, TBool aDeleteResource, TBool aDeleteRef=ETrue );
+		void InsertIntoAttributeTableL(TInt aElmId, CUpnpAttributeBean* aAtrBn, TInt aObjId, TInt aAtrId);
+ 		TInt InsertIntoElementTableL(TInt aObjId, CUpnpElementBean* aElmBn, TInt aElmId);
+		TInt InsertIntoObjectTableL(TInt aContainer, CUpnpObjectBean* aObjBn);
+    /**
+    * @since Series S60 3.1
+    * @param aObjId
+    * @return RDbView
+    */
+    RDbView GetObjViewL(TInt aObjId);
+        
+    /**
+    *
+    * @since Series S60 3.1
+    */
+    void BeginTransactionL();
+    
+    /**
+    *
+    * @since Series S60 3.1
+    */
+    void CommitTransactionL();
+    
+    /**
+    *
+    * @since Series S60 3.1
+    */
+    void RollbackTransactionL();
+        
+    /**
+    * Getter
+    * @since Series S30 3.1
+    * @param aObjectID
+    * @param aAll
+    * @return RDbView
+    */
+    RDbView GetElementsViewL(TInt aObjectID, TBool aAll);
+        
+    /**
+    * Getter
+    * @since Series S30 3.1
+    * @param aElementID
+    * @param aAll
+    * @return RDbView
+    */
+    RDbView GetAttributesViewL(TInt aElementID, TBool aAll);
+       
+    /**
+    * Getter
+    * @since Series S30 3.2
+    * @param aObjectID
+    * @param aAll
+    * @return RDbView
+    */
+    RDbView GetAttributesViewByObjectIdL( TInt aObjectID, TBool aAll );
+
+    /**
+    * Getter
+    * @since Series S30 3.1
+    * @param aAttrNameID
+    * @param aAttrVal
+    * @return 
+    */
+    TInt GetElmIdForAttrL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
+        
+    /**
+    * Getter
+    * @since Series S30 3.1
+    * @param aAttrName
+    * @param aAttrVal
+    * @return 
+    */
+    TInt GetElmIdForAttrLikeL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
+        
+    /**
+    * 
+    * @since Series S30 3.1
+    * @param aResVal
+    * @param aObjId
+    */
+    void DeleteResElL(const TDesC& aResVal, TInt ObjId);
+        
+    /**
+    * Getter
+    * @since Series S30 3.1
+    * @param aResVal
+    * @return RDbView
+    */
+    RDbView GetViewOfObjectListForResL(const TDesC& aResVal);
+        
+    /**
+    * Getter
+    * @since Series S30 3.1
+    * @param aElmName
+    * @param aElmValue
+    * @return RDbView
+    */
+    RDbView GetViewOfElmIdByNameAndValL(const TDesC& aElmName,  const TDesC& aElmValue);
+        
+    /**
+    * Getter
+    * @since Series S30 3.1
+    * @param aAttrName
+    * @param aAttrVal
+    * @return RDbView
+    */
+    RDbView GetAttrViewL(const TDesC8& aAttrName, const TDesC8& aAttrVal);
+        
+    /**
+    * Getter
+    * @since Series S30 3.1
+    * @param aElmId
+    * @param aAttrName
+    * @return RDbView
+    */
+    RDbView GetAttrViewL(TInt aElmId, const TDesC8& aAttrName);
+    
+    /**
+    * Getter
+    * @since Series S30 3.2
+    * @param aBjectId
+    * @param aAttrName
+    * @return RDbView
+    */
+    RDbView GetAttrViewByObjectIdL(TInt aBjectId, const TDesC8& aAttrName);    
+        
+    /**
+    * 
+    * @since Series S30 3.1
+    * @param aSqlQuery
+    * @return RDbView
+    */
+    RDbView PrepareViewL(const TDesC& aSqlQuery);
+        
+    /**
+    * Getter
+    * @since Series S30 3.1
+    * @param aSqlQuery
+    * @return RDbView
+    */
+	RDbView GetEvaluatedViewL(const TDesC& aSqlQuery);
+ 	HBufC8* GetObjectPathL(TInt aObjId);
+ 	HBufC8* GetObjectTitleL(TInt aObjId);
+	void ExecuteL(const TDesC& aSqlCommand);
+ 	CUpnpResourcesBean* GetResourceL(TInt64 aResId);
+	void DeleteResourceByObjIdL(TInt aObjId, TBool aDeleteFile=ETrue);
+	void DeleteResourceByResIdL(TInt64 aResId, TBool aDeleteFile=ETrue);
+	void DeleteObjectsL(TInt aObjId);
+	void DeleteElementsL(TInt aObjId);
+	void DeleteAttributesL(TInt aObjId);
+	void DeleteReferencesL(TInt aObjId,RArray<TInt>& aRefList);
+
+    /**
+    * Performs object deletion; a transaction should be started before calling this function
+    * @since Series S60 3.0
+    * @param id of the object to be deleted
+    * @param aObjId aCd pointer to the ContentDirectory object - it provides a function which deletes
+    * 				a file from the private directory
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+ 	TInt DoDeleteObjectL(TInt aObjId,RArray<TInt>& aRefList,
+ 	                     RArray<TInt>& aResList, TBool aDeleteResource, TBool aLocal, TBool aDeleteRef = ETrue );
+
+    /**
+    * Checks the restrictions of the parent object of the given object.
+    * @since Series S60 3.0
+    * @param aObjId object's id
+	* @return returns EUpnpOk if object with the given id exists in database and is a "non restricted conainer"    
+	*/
+	TUpnpErrorCode CheckParentRestrictionL(TInt aObjId);
+
+    /**
+    * Deletes object from database
+    * @since Series S60 3.0
+    * @param aObjId id of the object to be deleted
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+	TUpnpErrorCode DeleteObjectL(TInt aObjId,RArray<TInt>& aRefList, TBool aDeleteResource,
+	                             TBool aLocal = EFalse, TBool aDeleteRef = ETrue );
+   	
+
+    /**
+    * Gets the descriptor value of the specified column in the rowset.
+    * @since Series S60 3.0
+    * @param aRowset rowset object
+    * @param aColNo the number of the column to be get the value of
+    * @return descriptor containing the value of the specified column,
+    *       the caller should delete it when it is no longer needed
+    */
+    HBufC8* GetColDesValFromRowSetL(RDbRowSet aRowset, TDbColNo aColNo);
+
+    /**
+    * Gets the value of childCount property for the given object.
+    * @since Series S60 3.0
+    * @param aObjId object's id
+    * @return value of childCount property
+    */
+    TInt GetChildCountL(TInt aObjId);
+        
+    /**
+    * Gets the parent object's id of the object with given id.
+    * @since Series S60 3.0
+    * @param aObjId child object id
+    * @return perent object id
+    */
+    TInt GetParentIdL(TInt aObjId);
+
+    /**
+    * Gets the id of the object which the element with given id belongs to.
+    * @since Series S60 3.0
+    * @param aId element's id
+    * @return object's id
+    */
+    TInt GetObjIdForElmIdL(TInt aId);
+
+    /**
+    * Gets id of reffered object 
+    * @since Series S60 3.0
+    * @param aObjectId object id
+    * @return reffered object id.
+    */
+    TInt ReferedObjectIdL( TInt aObjectId );
+
+    /**
+    * Gets the next free id in the specified table 
+    * @since Series S60 3.0
+    * @param aName name of the table
+    * @return TInt next free id in the specified table
+    */
+    TInt GetNextKeyL(const TDesC8& aName);
+    TInt GetNextKeyL(const TDesC8& aName, TInt aAmount);
+    /**
+    * Gets the next free id in the specified table 
+    * @since Series S60 3.0
+    * @param aName name of the table
+    * @return TInt next free id in the specified table
+    */
+    TInt NextKeyL(const TDesC8& aName);
+
+    /**
+    * Insert object's data into 'object' table
+    * @since Series S60 3.0
+    * @param aElement TXmlEngElement of the object to be added
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    void InsertObjectIntoObjectTableL(const TXmlEngElement& aElement);
+
+    /**
+    * Inserts single attribute into the database 
+    * @since Series S60 3.0
+    * @param aAttr TXmlEngAttr of the attribute to be inserted
+    * @param aElmId id of the element this attribute belongs to
+    * 2param aIsRequired 
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    void InsertAttributeL(const TXmlEngAttr aAttr, TInt aElmId, TBool aIsRequired, TInt aObjId);
+
+    /**
+    * Inserts element into database 
+    * @since Series S60 3.0
+    * @param aElementel TXmlEngElement of the element to be inserted
+    * @param aObjId id of the object this element belongs to
+    */
+    TInt  InsertElementL(const TXmlEngElement& aElementel, TInt aObjId);
+
+    /**
+    * Gets the database view of the named element of the specified object.
+    * @since Series S60 3.0
+    * @param aObjId object's id
+    * @param aElName name of the element which we want to get the view of
+    * @return ?description
+    */
+    RDbView GetElementViewL(TInt aObjId, const TDesC8& aElName);
+
+    /**
+    * Adds an attribute from object table to the object's main element.
+    * @since Series S60 3.0
+    * @param aElement object's element
+    * @param aId object's id
+    * @param aName name of the attribute which is to be added
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode AddMainTagAttrL(TXmlEngElement aElement, TInt aId, const TDesC8& aName);
+
+
+    /**
+    * Gets the list direct children of object with specified id
+    * @since Series S60 3.0
+    * @param aParentId id of the parent object
+    * @param aList an array to be filled with object
+    * @return EUpnpOk, if successful; Otherwise, one of the other Upnp error codes.
+    */
+    TUpnpErrorCode GetObjectListL(TInt aParentId, RArray<TInt>& aList);
+    TUpnpErrorCode GetItemListL(TInt aParentId, RArray<TInt>& aList);
+    TUpnpErrorCode GetContainerListL(TInt aParentId, RArray<TInt>& aList);
+
+    /**
+    * Checks if object with the given id exists, is a container and its 'restricted' attribute has value of 'false'
+    * @since Series S60 3.0
+    * @param aObjId id of the object to be checked
+    * @return returns EUpnpOk if object with the given id exists in database and is a "non restricted conainer"
+    */
+    TUpnpErrorCode CheckObjectRestrictionL(TInt aObjId);
+
+    /**
+    * Recovers the database.
+    * @since Series S60 3.1
+    * @return Standard error code
+    */
+    TInt RecoverDatabase();
+
+    /**
+    * Recreates the database file.
+    * @since Series S60 3.1
+    */
+    void RecreateDatabaseFileL();
+
+    /**
+    * Checks if all database columns in each table have propper definitions.
+    * If not, it leaves with KErrCorrupt.
+    * @since Series S60 3.2
+    */
+    void CheckDatabaseL();  
+
+    /**
+    * Handles DB error
+    * Tries to recover, if fails tries to recreate
+    * @since Series S60 3.2
+    * @return TInt - KErrNone if succed
+    */
+    TInt HandleDbError( TInt aError );
+    
+    /**
+    * Returns DB creation status
+    * @since Series S60 3.2
+    * @return TBool
+    */
+    TBool IsDbCreated();
+   
+    
+private:
+
+    /**
+    * C++ default constructor.
+    */
+    CUpnpMetadataStorage();
+
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    void ConstructL(const TDesC& aDatabaseFileName);
+
+private:
+    
+    void CompactDbL();    
+    TInt AddSubObjectsL(TInt aObjId, RArray<TInt>& aObjList, RArray<TInt>& aResList, TBool aLocal);
+
+    /**
+    * Compare two column sets (type, maxsize and attributes). Used by CheckDatabaseL() function.
+    * Leaves with KErrCorrupt when columns are not agree.
+    * @since Series S60 3.2
+    * @param aColSet1 First column set to compare
+    * @param aColSet2 Second column set to compare
+    */
+    void CompareDbColSetsL( CDbColSet *aColSet1, CDbColSet *aColSet2 );
+
+    /**
+    * Deletes the file
+    * @since Series S30 3.1
+    * @param aPath
+    */
+    void DeleteFileL(const TDesC& aPath);
+        
+    /**
+    *
+    * @since Series S30 3.1
+    * @param aElement
+    * @return descriptor pointer
+    */
+    HBufC8* CreatePathValL(const TXmlEngElement& aElement);
+		HBufC8* CreatePathValL(TInt aParentId);
+    /**
+    * Opens database
+    * @since Series S30 3.1
+    * @param aDatabaseFileName
+    */
+    void OpenDbL( const TFileName& aDatabaseFileName );
+        
+    /**
+    *
+    * @since Series S30 3.1
+    * @param aWeight
+    */
+    void DbChangedL(TInt aWeight);
+
+private:    
+
+    // For use of iFileStore
+    RFs                iFsSession; 
+    // For database operations
+    RDbStoreDatabase    iDatabase;  
+    TBool               iIsOpen;
+    // For creating and opening database files
+    CFileStore*         iFileStore; 
+    // compact counter
+    TInt                iCompactCounter;
+
+};
+
+#endif      // UPNPMETADATASTORAGE_H   
+        
+// End of File
--- a/upnpmediaserver/contentdirectoryservice/inc/upnpmspathutility.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/inc/upnpmspathutility.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,222 +1,222 @@
-/*
-* Copyright (c) 2002-2007 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:  Utility class to get path related info for the media files
-*/
-
-
-
-
-
-
-#ifndef UPNP_MSPATHUTILITY_H
-#define UPNP_MSPATHUTILITY_H
-
-// INCLUDE FILES
-#include <e32base.h>    // CBase
-#include <f32file.h>    // TDriveNumber
-#include <xml/dom/xmlengdom.h>
-
-// FORWARD DECLARATIONS
-class CRepository;
-class CUpnpDlnaProtocolInfo;
-
-// CLASS DECLARATION
-/**
- *  Path utility class to get path related info for the media files
- *  @lib upnpcontentdirectoryservice.lib
- *  Note:- This class needs to be revisited once mediaserver refactoring is 
- *         over as there is definitely the need to remove duplicate code
- *        
- */
-NONSHARABLE_CLASS ( CUPnPMSPathUtility ) : public CBase
-    {
-public: // Constructors and destructor
-
-    /**
-     * Two-phased constructor.
-     */
-    static CUPnPMSPathUtility* NewL();
-
-    /**
-     * Two-phased constructor.
-     */
-    static CUPnPMSPathUtility* NewLC();
-
-    /**
-     * Destructor.
-     */
-    virtual ~CUPnPMSPathUtility();
-        
-        
-public: // new functions
-
-    /**
-     * Gets the drive for the copy operation
-     * @param aDrive, reference to copy path drive
-     */
-    void GetCopyPathDriveL( TDriveNumber& aDrive ) const;
-
-    /**
-     * Gets the path of the upnp item's file to be copied
-     * @param aItem, an xml item
-     * @param aProInfo, proto info of the resource of the xml item
-     * @return HBufC*, copy path. Ownership is transferred to the caller
-     *          Leaves in case of an error.    
-     */
-    HBufC* GetCopyPathL( const TXmlEngElement& aItem,
-                         CUpnpDlnaProtocolInfo& aProInfo ) const;
-
-    /**
-     * Gets and creates (if necessary) the path of the upnp item's 
-     * file to be copied.
-     * @param aItem, an xml item
-     * @param aProInfo, proto info of the resource of the xml item
-     * @return HBufC*, copy path. Ownership is transferred to the caller
-     *          Leaves in case of an error.    
-     */
-    HBufC* CreateCopyPathL( const TXmlEngElement& aItem,
-                            CUpnpDlnaProtocolInfo& aProInfo ) const;
-    
-private:
-    enum TMediaServerKeys 
-        {
-        EFriendlyName = 1, 
-        EUploadDirectory = 2, 
-        ESupportedMedia = 3, 
-        ESecurityManager = 4,
-        EModelUrl = 5,
-        EModelDescription = 6,
-        EModelNumber = 7,
-        ESerialNumber = 8,
-        EPresentationUrl = 9,
-        EModelName = 10,
-        EManufacturer = 11,
-        EManufacturerUrl = 12,
-        EUpnpMediaServerThumbnails = 13,
-        KUpnpMediaServerBrowseLimit = 14
-        };
-    
-    // DATA TYPES
-    enum TUPnPItemType
-        {
-        ETypeAudio = 0,
-        ETypeVideo,
-        ETypeImage,
-        ETypePlaylist,
-        ETypeOther
-        };
-    
-    /**
-     * C++ default constructor.
-     */
-    CUPnPMSPathUtility();
-
-    /**
-     * By default Symbian 2nd phase constructor is private.
-     */
-    void ConstructL(TUid aRepositoryUid);
-
-    /**
-     * Gets and creates (if necessary) the path of the upnp item's 
-     * file to be copied.
-     * @param aItem, an xml item
-     * @param aProInfo, proto info of the resource of the xml item
-     * @param aCreatePath, If ETrue path gets created otherwise not.
-     * @param aDriveNumber, drive number to be used for the path calculation
-     * @return HBufC*, copy path. Ownership is transferred to the caller
-     *          Leaves in case of an error.    
-     */
-    HBufC* GetCreateCopyPathL(const TXmlEngElement& aItem,
-                              CUpnpDlnaProtocolInfo& aProInfo,
-                              TBool aCreatePath,
-                              TDriveNumber aDriveNumber ) const;
-    /**
-    * Returns the file type according a mime type
-    *
-    * @param const TDesC8& mime type
-    * @return TUPnPItemType file type
-    */
-   TUPnPItemType FileTypeByMimeTypeL( const TDesC8& aMimeType ) const;
-   
-    /**
-     * Appends year, month and day to the path.
-     * @param aPath, path of the upnp item
-     * @param aItem, an xml item
-     */        
-    void AppendYearMonthDayL( 
-            TDes& aPath, const TXmlEngElement& aItem ) const;
-    
-    /**
-     * Appends artist and album to the path.
-     * @param aPath, path of the upnp item
-     * @param aItem, an xml item
-     */        
-    void AppendArtistAlbumL( 
-            TDes& aPath, const TXmlEngElement& aItem ) const;
-    
-    /**
-     * Appends data to the path's buffer.
-     * Leaves if data exceeds the maxlength of the buffer
-     * 
-     * @param aPath, path of the upnp item
-     * @param aData, data which needs to be appended
-     */    
-    void AppendDataL( TDes& aPath, const TDesC& aData ) const;
-    
-    /**
-     * Checks whether the data can be appended to buffer or not.
-     * Leaves if data exceeds the maxlength of the buffer
-     * 
-     * @param aPath, path of the upnp item
-     * @param aData, data which needs to be appended
-     */    
-    void CheckBufferSpaceL( const TDes& aPath, 
-            const TDesC& aData ) const;
-    
-    /**
-     * Checks whether the data of the specified length
-     * can be appended to buffer or not.
-     * Leaves if data exceeds the maxlength of the buffer
-     * 
-     * @param aPath, path of the upnp item
-     * @param aLength, length of the data which needs to be appended
-     */    
-    void CheckBufferSpaceL( const TDes& aPath, 
-            const TInt& aLength ) const;
-       
-    /**
-     * Converts given upnp date string into TTime.
-     *
-     * @param aUpnpDate value from item's dc:date element
-     * @param aTime out variable to receive corresponding TTime
-     * @return KErrNone if conversion was succesful, otherwise < 0
-     *         for error values see TTime::Parse()
-     */
-    void UPnPDateAsTTimeL( const TDesC8& aUpnpDate,
-        TTime& aTime ) const;
-
-private:    // data
-
-    /**
-    * Central repository client
-    * Note:- CUpnpMediaServerSettings is not used to avoid dependency
-    */  
-    CRepository* iRepository;
-    
-    };
-
-#endif  // UPNP_MSPATHUTILITY_H
-
-// End of file
+/*
+* Copyright (c) 2002-2007 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:  Utility class to get path related info for the media files
+*/
+
+
+
+
+
+
+#ifndef UPNP_MSPATHUTILITY_H
+#define UPNP_MSPATHUTILITY_H
+
+// INCLUDE FILES
+#include <e32base.h>    // CBase
+#include <f32file.h>    // TDriveNumber
+#include <xmlengdom.h>
+
+// FORWARD DECLARATIONS
+class CRepository;
+class CUpnpDlnaProtocolInfo;
+
+// CLASS DECLARATION
+/**
+ *  Path utility class to get path related info for the media files
+ *  @lib upnpcontentdirectoryservice.lib
+ *  Note:- This class needs to be revisited once mediaserver refactoring is 
+ *         over as there is definitely the need to remove duplicate code
+ *        
+ */
+NONSHARABLE_CLASS ( CUPnPMSPathUtility ) : public CBase
+    {
+public: // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUPnPMSPathUtility* NewL();
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUPnPMSPathUtility* NewLC();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUPnPMSPathUtility();
+        
+        
+public: // new functions
+
+    /**
+     * Gets the drive for the copy operation
+     * @param aDrive, reference to copy path drive
+     */
+    void GetCopyPathDriveL( TDriveNumber& aDrive ) const;
+
+    /**
+     * Gets the path of the upnp item's file to be copied
+     * @param aItem, an xml item
+     * @param aProInfo, proto info of the resource of the xml item
+     * @return HBufC*, copy path. Ownership is transferred to the caller
+     *          Leaves in case of an error.    
+     */
+    HBufC* GetCopyPathL( const TXmlEngElement& aItem,
+                         CUpnpDlnaProtocolInfo& aProInfo ) const;
+
+    /**
+     * Gets and creates (if necessary) the path of the upnp item's 
+     * file to be copied.
+     * @param aItem, an xml item
+     * @param aProInfo, proto info of the resource of the xml item
+     * @return HBufC*, copy path. Ownership is transferred to the caller
+     *          Leaves in case of an error.    
+     */
+    HBufC* CreateCopyPathL( const TXmlEngElement& aItem,
+                            CUpnpDlnaProtocolInfo& aProInfo ) const;
+    
+private:
+    enum TMediaServerKeys 
+        {
+        EFriendlyName = 1, 
+        EUploadDirectory = 2, 
+        ESupportedMedia = 3, 
+        ESecurityManager = 4,
+        EModelUrl = 5,
+        EModelDescription = 6,
+        EModelNumber = 7,
+        ESerialNumber = 8,
+        EPresentationUrl = 9,
+        EModelName = 10,
+        EManufacturer = 11,
+        EManufacturerUrl = 12,
+        EUpnpMediaServerThumbnails = 13,
+        KUpnpMediaServerBrowseLimit = 14
+        };
+    
+    // DATA TYPES
+    enum TUPnPItemType
+        {
+        ETypeAudio = 0,
+        ETypeVideo,
+        ETypeImage,
+        ETypePlaylist,
+        ETypeOther
+        };
+    
+    /**
+     * C++ default constructor.
+     */
+    CUPnPMSPathUtility();
+
+    /**
+     * By default Symbian 2nd phase constructor is private.
+     */
+    void ConstructL(TUid aRepositoryUid);
+
+    /**
+     * Gets and creates (if necessary) the path of the upnp item's 
+     * file to be copied.
+     * @param aItem, an xml item
+     * @param aProInfo, proto info of the resource of the xml item
+     * @param aCreatePath, If ETrue path gets created otherwise not.
+     * @param aDriveNumber, drive number to be used for the path calculation
+     * @return HBufC*, copy path. Ownership is transferred to the caller
+     *          Leaves in case of an error.    
+     */
+    HBufC* GetCreateCopyPathL(const TXmlEngElement& aItem,
+                              CUpnpDlnaProtocolInfo& aProInfo,
+                              TBool aCreatePath,
+                              TDriveNumber aDriveNumber ) const;
+    /**
+    * Returns the file type according a mime type
+    *
+    * @param const TDesC8& mime type
+    * @return TUPnPItemType file type
+    */
+   TUPnPItemType FileTypeByMimeTypeL( const TDesC8& aMimeType ) const;
+   
+    /**
+     * Appends year, month and day to the path.
+     * @param aPath, path of the upnp item
+     * @param aItem, an xml item
+     */        
+    void AppendYearMonthDayL( 
+            TDes& aPath, const TXmlEngElement& aItem ) const;
+    
+    /**
+     * Appends artist and album to the path.
+     * @param aPath, path of the upnp item
+     * @param aItem, an xml item
+     */        
+    void AppendArtistAlbumL( 
+            TDes& aPath, const TXmlEngElement& aItem ) const;
+    
+    /**
+     * Appends data to the path's buffer.
+     * Leaves if data exceeds the maxlength of the buffer
+     * 
+     * @param aPath, path of the upnp item
+     * @param aData, data which needs to be appended
+     */    
+    void AppendDataL( TDes& aPath, const TDesC& aData ) const;
+    
+    /**
+     * Checks whether the data can be appended to buffer or not.
+     * Leaves if data exceeds the maxlength of the buffer
+     * 
+     * @param aPath, path of the upnp item
+     * @param aData, data which needs to be appended
+     */    
+    void CheckBufferSpaceL( const TDes& aPath, 
+            const TDesC& aData ) const;
+    
+    /**
+     * Checks whether the data of the specified length
+     * can be appended to buffer or not.
+     * Leaves if data exceeds the maxlength of the buffer
+     * 
+     * @param aPath, path of the upnp item
+     * @param aLength, length of the data which needs to be appended
+     */    
+    void CheckBufferSpaceL( const TDes& aPath, 
+            const TInt& aLength ) const;
+       
+    /**
+     * Converts given upnp date string into TTime.
+     *
+     * @param aUpnpDate value from item's dc:date element
+     * @param aTime out variable to receive corresponding TTime
+     * @return KErrNone if conversion was succesful, otherwise < 0
+     *         for error values see TTime::Parse()
+     */
+    void UPnPDateAsTTimeL( const TDesC8& aUpnpDate,
+        TTime& aTime ) const;
+
+private:    // data
+
+    /**
+    * Central repository client
+    * Note:- CUpnpMediaServerSettings is not used to avoid dependency
+    */  
+    CRepository* iRepository;
+    
+    };
+
+#endif  // UPNP_MSPATHUTILITY_H
+
+// End of file
--- a/upnpmediaserver/contentdirectoryservice/inc/upnpobjectbean.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/inc/upnpobjectbean.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,273 +1,273 @@
-/** @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:  Element table data handler
-*
-*/
-
-
-
-#ifndef C_CUPNPOBJECTBEAN_H
-#define C_CUPNPOBJECTBEAN_H
-
-//  INCLUDES
-#include "upnptablebean.h"
-#include <e32base.h>
-#include <d32dbms.h>
-#include <xml/dom/xmlengdom.h>
-
-class CUpnpObject;
-
-// CLASS DECLARATION
-
-/**
-*  Stores the data of object table row.
-*
-*  @lib AVContentDirectory.lib
-*  @since Series60 3.1
-*/
-class CUpnpObjectBean: public CUpnpTableBean 
-{
-    public:  // Constructors and destructor
-    
-    /**
-    * Two-phased constructor.
-    */
-    //static CUpnpObjectBean* NewL();
-    static CUpnpObjectBean* NewLC();
-    static CUpnpObjectBean* NewLC(const RDbRowSet& aRowSet);
-    static CUpnpObjectBean* NewL(const RDbRowSet& aRowSet);
-    
-    /**
-    * Destructor.
-    */
-    virtual ~CUpnpObjectBean();
-
-    public: // New functions
-    	void CopyToUpnpObjectL(CUpnpObject* aElement);
-    /**
-    * Sets 
-    * @since Series S60 3.0
-    * @param aRowSet
-    */
-    void SetL(const RDbRowSet& aRowSet);
-
-    /**
-    * Sets iObjId value.
-    * @since Series S60 3.0
-    * @param aObjId value of id in the 'object' table
-    */
-    void SetObjId(TInt aObjId);
-
-    /**
-    * Sets iObjParentId value.
-    * @since Series S60 3.0
-    * @param aObjParentId value of 'parentID' in the object table
-    */
-    void SetObjParentId(TInt aObjParentId);
-
-    /**
-    * Sets iObjTitle value.
-    * @since Series S60 3.0
-    * @param aObjTitle value of 'title' in the object table
-    */
-    void SetObjTitleL(const TDesC8& aObjTitle);
-
-    /**
-    * Sets iObjClass value.
-    * @since Series S60 3.0
-    * @param aObjClass value of 'class' in the object table
-    */
-    void SetObjClassL(const TDesC8& aObjClass);
-
-    /**
-    * Sets iObjRestricted value.
-    * @since Series S60 3.0
-    * @param aObjRestricted value of 'restricted' in the object table
-    */
-    void SetObjRestricted(TBool aObjRestricted);
-
-    /**
-    * Sets iObjSearchable value.
-    * @since Series S60 3.0
-    * @param aObjSearchable value of 'searchable' in the object table, -1 when undefined
-    */
-    void SetObjSearchable(TInt aObjSearchable);
-
-    /**
-    * Sets iObjRefId value.
-    * @since Series S60 3.0
-    * @param aObjRefId value of 'refID' in the object table
-    */
-    void SetObjRefId(TInt aObjRefId);
-        
-    /**
-    * Gets iElmId value.
-    * @since Series S60 3.0
-    * @return Gets the value of iElmId
-    */  
-    TInt ObjId() const;
-        
-    /**
-    * Gets iElmId value.
-    * @since Series S60 3.0
-    * @return Gets the value of iElmId
-    */  
-    TInt ObjParentId() const;
-        
-    /**
-    * Gets iElmId value.
-    * @since Series S60 3.0
-    * @return Gets the value of iElmId
-    */  
-    TDesC8& ObjTitle() const;
-        
-    /**
-    * Gets iElmId value.
-    * @since Series S60 3.0
-    * @return Gets the value of iElmId
-    */  
-    TDesC8& ObjClass() const;
-        
-    /**
-    * Gets iElmId value.
-    * @since Series S60 3.0
-    * @return Gets the value of iElmId
-    */  
-    TBool ObjRestricted() const;
-        
-    /**
-    * Gets iElmId value.
-    * @since Series S60 3.0
-    * @return Gets the value of iElmId
-    */  
-    TInt ObjSearchable() const;
-        
-    /**
-    * Gets iElmId value.
-    * @since Series S60 3.0
-    * @return Gets the value of iElmId
-    */  
-    TInt ObjRefId() const;
-        
-    /**
-    * Adds object element and all required properties to the given TXmlEngElement.
-    * @since Series S60 3.0
-    * @param aElement
-    * @return TXmlEngElement just added object alement
-    */  
-    TXmlEngElement AttachObjectElL(TXmlEngElement aElement);
-        
-    /**
-    * Adds object element and all properties to the given TXmlEngElement.
-    * @since Series S60 3.0
-    * @param aElement
-    */  
-    TXmlEngElement AttachWholeObjectElL(TXmlEngElement aElement);
-
-    /**
-    * Adds refId attribute to the given object's TXmlEngElement.
-    * @since Series S60 3.0
-    * @param aElement
-    * @return TXmlEngAttr just added object alement
-    */  
-    void AttachRefIdL(TXmlEngElement aElement);
-    
-    /**
-    * Adds searchable attr to the given object's TXmlEngElement.
-    * @since Series S60 3.0
-    * @param aElement
-    * @return TXmlEngAttr just added object alement
-    */  
-    void AttachSearchableL(TXmlEngElement aElement);
- 
- private: 
-    /**
-    * Adds all required properties to the given object's TXmlEngElement.
-    * @since Series S60 3.0
-    * @param aElement
-    */  
-    void AttachRequiredPropertiesL(TXmlEngElement);
-        
-    /**
-    * Adds id attr to the given object's TXmlEngElement.
-    * @since Series S60 3.0
-    * @param aElement
-    */  
-    void AttachIdL(TXmlEngElement aElement);
-    
-    /**
-    * Adds ParentId attr to the given object's TXmlEngElement.
-    * @since Series S60 3.0
-    * @param aElement
-    */  
-    void AttachParentIdL(TXmlEngElement aElement);
-    
-    /**
-    * Adds restricted attr to the given object's TXmlEngElement.
-    * @since Series S60 3.0
-    * @param aElement
-    * @return TXmlEngAttr just added object alement
-    */  
-    void AttachRestrictedL(TXmlEngElement aElement);
-
-    /**
-    * Adds title element to the given object's TXmlEngElement.
-    * @since Series S60 3.0
-    * @param aElement
-    */  
-    void AttachTitleL(TXmlEngElement aElement);
-    
-    /**
-    * Adds class element to the given object's TXmlEngElement.
-    * @since Series S60 3.0
-    * @param aElement
-    */  
-    void AttachClassL(TXmlEngElement aElement);
-        
-        
-    private:
-
-    /**
-    * C++ default constructor.
-    */
-    CUpnpObjectBean();
-
-    /**
-    * By default Symbian 2nd phase constructor is private.
-    */
-    void ConstructL();
-
-    private:    // Data
-        
-    // Object Id
-    TInt        iObjId;
-    // Object parent Id
-    TInt        iObjParentId;
-    // Object Title
-    HBufC8*     iObjTitle;
-    // Object Class
-    HBufC8*     iObjClass;
-    //
-    TBool       iObjRestricted;
-    //
-    TInt        iObjSearchable;
-    // Object Reference Id
-    TInt        iObjRefId;
-};
-
-// inline functions
-#include"upnpobjectbean.inl"
-
-#endif      // C_CUPNPOBJECTBEAN_H   
-// End of File
+/** @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:  Element table data handler
+*
+*/
+
+
+
+#ifndef C_CUPNPOBJECTBEAN_H
+#define C_CUPNPOBJECTBEAN_H
+
+//  INCLUDES
+#include "upnptablebean.h"
+#include <e32base.h>
+#include <d32dbms.h>
+#include <xmlengdom.h>
+
+class CUpnpObject;
+
+// CLASS DECLARATION
+
+/**
+*  Stores the data of object table row.
+*
+*  @lib AVContentDirectory.lib
+*  @since Series60 3.1
+*/
+class CUpnpObjectBean: public CUpnpTableBean 
+{
+    public:  // Constructors and destructor
+    
+    /**
+    * Two-phased constructor.
+    */
+    //static CUpnpObjectBean* NewL();
+    static CUpnpObjectBean* NewLC();
+    static CUpnpObjectBean* NewLC(const RDbRowSet& aRowSet);
+    static CUpnpObjectBean* NewL(const RDbRowSet& aRowSet);
+    
+    /**
+    * Destructor.
+    */
+    virtual ~CUpnpObjectBean();
+
+    public: // New functions
+    	void CopyToUpnpObjectL(CUpnpObject* aElement);
+    /**
+    * Sets 
+    * @since Series S60 3.0
+    * @param aRowSet
+    */
+    void SetL(const RDbRowSet& aRowSet);
+
+    /**
+    * Sets iObjId value.
+    * @since Series S60 3.0
+    * @param aObjId value of id in the 'object' table
+    */
+    void SetObjId(TInt aObjId);
+
+    /**
+    * Sets iObjParentId value.
+    * @since Series S60 3.0
+    * @param aObjParentId value of 'parentID' in the object table
+    */
+    void SetObjParentId(TInt aObjParentId);
+
+    /**
+    * Sets iObjTitle value.
+    * @since Series S60 3.0
+    * @param aObjTitle value of 'title' in the object table
+    */
+    void SetObjTitleL(const TDesC8& aObjTitle);
+
+    /**
+    * Sets iObjClass value.
+    * @since Series S60 3.0
+    * @param aObjClass value of 'class' in the object table
+    */
+    void SetObjClassL(const TDesC8& aObjClass);
+
+    /**
+    * Sets iObjRestricted value.
+    * @since Series S60 3.0
+    * @param aObjRestricted value of 'restricted' in the object table
+    */
+    void SetObjRestricted(TBool aObjRestricted);
+
+    /**
+    * Sets iObjSearchable value.
+    * @since Series S60 3.0
+    * @param aObjSearchable value of 'searchable' in the object table, -1 when undefined
+    */
+    void SetObjSearchable(TInt aObjSearchable);
+
+    /**
+    * Sets iObjRefId value.
+    * @since Series S60 3.0
+    * @param aObjRefId value of 'refID' in the object table
+    */
+    void SetObjRefId(TInt aObjRefId);
+        
+    /**
+    * Gets iElmId value.
+    * @since Series S60 3.0
+    * @return Gets the value of iElmId
+    */  
+    TInt ObjId() const;
+        
+    /**
+    * Gets iElmId value.
+    * @since Series S60 3.0
+    * @return Gets the value of iElmId
+    */  
+    TInt ObjParentId() const;
+        
+    /**
+    * Gets iElmId value.
+    * @since Series S60 3.0
+    * @return Gets the value of iElmId
+    */  
+    TDesC8& ObjTitle() const;
+        
+    /**
+    * Gets iElmId value.
+    * @since Series S60 3.0
+    * @return Gets the value of iElmId
+    */  
+    TDesC8& ObjClass() const;
+        
+    /**
+    * Gets iElmId value.
+    * @since Series S60 3.0
+    * @return Gets the value of iElmId
+    */  
+    TBool ObjRestricted() const;
+        
+    /**
+    * Gets iElmId value.
+    * @since Series S60 3.0
+    * @return Gets the value of iElmId
+    */  
+    TInt ObjSearchable() const;
+        
+    /**
+    * Gets iElmId value.
+    * @since Series S60 3.0
+    * @return Gets the value of iElmId
+    */  
+    TInt ObjRefId() const;
+        
+    /**
+    * Adds object element and all required properties to the given TXmlEngElement.
+    * @since Series S60 3.0
+    * @param aElement
+    * @return TXmlEngElement just added object alement
+    */  
+    TXmlEngElement AttachObjectElL(TXmlEngElement aElement);
+        
+    /**
+    * Adds object element and all properties to the given TXmlEngElement.
+    * @since Series S60 3.0
+    * @param aElement
+    */  
+    TXmlEngElement AttachWholeObjectElL(TXmlEngElement aElement);
+
+    /**
+    * Adds refId attribute to the given object's TXmlEngElement.
+    * @since Series S60 3.0
+    * @param aElement
+    * @return TXmlEngAttr just added object alement
+    */  
+    void AttachRefIdL(TXmlEngElement aElement);
+    
+    /**
+    * Adds searchable attr to the given object's TXmlEngElement.
+    * @since Series S60 3.0
+    * @param aElement
+    * @return TXmlEngAttr just added object alement
+    */  
+    void AttachSearchableL(TXmlEngElement aElement);
+ 
+ private: 
+    /**
+    * Adds all required properties to the given object's TXmlEngElement.
+    * @since Series S60 3.0
+    * @param aElement
+    */  
+    void AttachRequiredPropertiesL(TXmlEngElement);
+        
+    /**
+    * Adds id attr to the given object's TXmlEngElement.
+    * @since Series S60 3.0
+    * @param aElement
+    */  
+    void AttachIdL(TXmlEngElement aElement);
+    
+    /**
+    * Adds ParentId attr to the given object's TXmlEngElement.
+    * @since Series S60 3.0
+    * @param aElement
+    */  
+    void AttachParentIdL(TXmlEngElement aElement);
+    
+    /**
+    * Adds restricted attr to the given object's TXmlEngElement.
+    * @since Series S60 3.0
+    * @param aElement
+    * @return TXmlEngAttr just added object alement
+    */  
+    void AttachRestrictedL(TXmlEngElement aElement);
+
+    /**
+    * Adds title element to the given object's TXmlEngElement.
+    * @since Series S60 3.0
+    * @param aElement
+    */  
+    void AttachTitleL(TXmlEngElement aElement);
+    
+    /**
+    * Adds class element to the given object's TXmlEngElement.
+    * @since Series S60 3.0
+    * @param aElement
+    */  
+    void AttachClassL(TXmlEngElement aElement);
+        
+        
+    private:
+
+    /**
+    * C++ default constructor.
+    */
+    CUpnpObjectBean();
+
+    /**
+    * By default Symbian 2nd phase constructor is private.
+    */
+    void ConstructL();
+
+    private:    // Data
+        
+    // Object Id
+    TInt        iObjId;
+    // Object parent Id
+    TInt        iObjParentId;
+    // Object Title
+    HBufC8*     iObjTitle;
+    // Object Class
+    HBufC8*     iObjClass;
+    //
+    TBool       iObjRestricted;
+    //
+    TInt        iObjSearchable;
+    // Object Reference Id
+    TInt        iObjRefId;
+};
+
+// inline functions
+#include"upnpobjectbean.inl"
+
+#endif      // C_CUPNPOBJECTBEAN_H   
+// End of File
--- a/upnpmediaserver/contentdirectoryservice/inc/upnpxmlcontentfilter.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/inc/upnpxmlcontentfilter.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,53 +1,53 @@
-/** @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:  Xml responses serialization filter
-*
-*/
-
-
-// INCLUDE FILES
-
-#include <e32svr.h>
-#include <xml/dom/xmlengdom.h>
-#include <xml/dom/xmlengnodefilter.h>
-
-//using namespace Xml;
-
-/**
-*  @brief Xml responses serialization filter
-*
-*  @lib ContentDirectory.lib
-*  @since Series60 3.2
-*/
-class CUpnpXmlContentFilter : public CBase, MXmlEngNodeFilter
-    {
-public: // from MXmlEngNodeFilter
-
-    /**
-    * Filters node by type CDATA and comments are rejected
-    * @since Series60 3.2
-    * @param aNode node
-    */    
-    virtual TXmlEngNodeFilterResult AcceptNode(TXmlEngNode aNode);
-    
-public:
-        
-    /**
-    * Aplies filter and serializes aElement to descriptor 
-    * @since Series60 3.2
-    * @param aService Parent service 
-    */
-    static HBufC8* SerializeLC(RXmlEngDocument& aDoc, TXmlEngElement& aElement );
-
-    };
+/** @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:  Xml responses serialization filter
+*
+*/
+
+
+// INCLUDE FILES
+
+#include <e32svr.h>
+#include <xmlengdom.h>
+#include <xmlengnodefilter.h>
+
+//using namespace Xml;
+
+/**
+*  @brief Xml responses serialization filter
+*
+*  @lib ContentDirectory.lib
+*  @since Series60 3.2
+*/
+class CUpnpXmlContentFilter : public CBase, MXmlEngNodeFilter
+    {
+public: // from MXmlEngNodeFilter
+
+    /**
+    * Filters node by type CDATA and comments are rejected
+    * @since Series60 3.2
+    * @param aNode node
+    */    
+    virtual TXmlEngNodeFilterResult AcceptNode(TXmlEngNode aNode);
+    
+public:
+        
+    /**
+    * Aplies filter and serializes aElement to descriptor 
+    * @since Series60 3.2
+    * @param aService Parent service 
+    */
+    static HBufC8* SerializeLC(RXmlEngDocument& aDoc, TXmlEngElement& aElement );
+
+    };
\ No newline at end of file
--- a/upnpmediaserver/contentdirectoryservice/src/dlna/upnpdlnafilter.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/dlna/upnpdlnafilter.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,901 +1,910 @@
-/** @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:  CUpnpDlnaFilter implementation.
- *
- */
-// INCLUDES
-#include <bautils.h> 
-#include "upnpdlnafilter.h"
-#include "upnpstring.h"
-#include "upnpcons.h"
-#include "upnpcontentdirectorydatafinder.h"
-#include "upnphttpmessage.h"
-#include "upnpdlnaprotocolinfo.h"
-#include "upnpfileutils.h"
-#include "upnpsecuritymanager.h"
-#define KLogFile _L("DLNAWebServer.txt")
-#include "upnpcustomlog.h"
-#include "upnphttpfilereceivetransaction.h"
-#include "upnphttpfileservetransaction.h"
-#include "upnpdlnafilterheaders.h"
-#include "upnpcommonupnplits.h"
-#include "upnpdlnacorelation.h"
-
-// CONSTANTS
-_LIT8( KDlnaFilter, "DLNA");
-_LIT8( KIpPortPlaceholder8, "___.___.___.___:_____" );
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::CUpnpDlnaFilter
-// C++ default constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpDlnaFilter::CUpnpDlnaFilter( MUpnpContentDirectoryDataFinder* aFinder,
-    CUpnpSecurityManager* aSecurityManager ) :
-    iCdDataFinder( aFinder ), iSecurityManager( aSecurityManager )
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::~CUpnpDlnaFilter
-// C++ default destructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpDlnaFilter::~CUpnpDlnaFilter()
-    {
-    iFs.Close();
-    delete iProtocolInfo;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::NewLC
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpDlnaFilter* CUpnpDlnaFilter::NewLC(
-    MUpnpContentDirectoryDataFinder* aFinder,
-    CUpnpSecurityManager* aSecurityManager )
-    {
-    CUpnpDlnaFilter* self = new (ELeave) CUpnpDlnaFilter( aFinder,
-        aSecurityManager );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpDlnaFilter* CUpnpDlnaFilter::NewL(
-    MUpnpContentDirectoryDataFinder* aFinder,
-    CUpnpSecurityManager* aSecurityManager )
-    {
-    CUpnpDlnaFilter* self =
-            CUpnpDlnaFilter::NewLC( aFinder, aSecurityManager );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::ConstructL
-// EPOC default constructor for performing 2nd stage construction.
-// -----------------------------------------------------------------------------
-//
-void CUpnpDlnaFilter::ConstructL()
-    {
-    User::LeaveIfError( iFs.Connect() );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::SecurityManager
-// 
-// -----------------------------------------------------------------------------
-//
-CUpnpSecurityManager* CUpnpDlnaFilter::SecurityManager()
-    {
-    return iSecurityManager;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::CheckImportUriL
-// Checks if specified URI exists in database and returns object id for
-//      given URI or KErrNotFound if URI is no registered in database.
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpDlnaFilter::CheckImportUriL( TDesC8& aImportUri )
-    {
-    TInt lastPosOfSlash = aImportUri.LocateReverse( '/' );
-    if ( lastPosOfSlash < 0 )
-        {
-        return KErrGeneral;
-        }
-    HBufC8* path = aImportUri.AllocLC();
-    TInt result = KErrNone;
-    result = iCdDataFinder->CheckImportUriL( path->Des() );
-    CleanupStack::PopAndDestroy( path );
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::Get3rdFieldFromCdL
-// Find protocolInfo by contentUri (Not by importUri) and extract 3rd field,
-//      using ContentDirectory.
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpDlnaFilter::ThirdFieldFromCdL( const TDesC8& aContentUri )
-    {
-    HBufC8* result = NULL;
-    CUpnpDlnaProtocolInfo* protocolInfo = ProtocolInfoL( aContentUri );
-    if ( protocolInfo )
-        {
-        TPtrC8 thirdField = protocolInfo->ThirdField();
-        if ( thirdField != KNullDesC8() )
-            {
-            result = thirdField.AllocL();
-            }
-        }
-    delete protocolInfo;
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::ProtocolInfoL
-// 
-// -----------------------------------------------------------------------------
-//
-CUpnpDlnaProtocolInfo* CUpnpDlnaFilter::ProtocolInfoL( const TDesC8& aContentUri )
-    {
-    //  "http:/:/" prefix is added to content path to provide backward 
-    // compatibility with old testing tools
-    HBufC8* fullContentUri = HBufC8::NewL( UpnpHTTP::KHTTPUrl().Length()
-            + KIpPortPlaceholder8().Length() + aContentUri.Length() );
-    CleanupStack::PushL( fullContentUri );
-    
-    fullContentUri->Des().Append( UpnpHTTP::KHTTPUrl );
-    fullContentUri->Des().Append( KIpPortPlaceholder8 );
-    fullContentUri->Des().Append( aContentUri );
-    
-    CUpnpDlnaProtocolInfo* protocolInfo = NULL;
-    if ( iCdDataFinder->GetProtocolInfoL( *fullContentUri, protocolInfo ) != KErrNone )
-        {
-        delete protocolInfo;
-        protocolInfo = NULL;
-        }
-    CleanupStack::PopAndDestroy( fullContentUri );
-    return protocolInfo;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::GetMediaFileNameL
-// Gets name of file with content for given object's id.
-// -----------------------------------------------------------------------------
-//
-void CUpnpDlnaFilter::GetMediaFileNameL( TInt aObjectId, TPtr& aFileName )
-    {
-    if ( aObjectId <= KErrNone )
-        {
-        return;
-        }
-    iCdDataFinder->GetTitleForUriL( aObjectId, aFileName );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::FindSharedFolderDBL
-// Find a folder shared from DB (ContentDirectory).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpDlnaFilter::FindSharedFolderDBL( const TDesC8& aUrlPath,
-    const TDesC8& aFileName, HBufC8*& aSystemPath )
-    {
-    HBufC* unicodeSharedFolder = NULL;
-    TInt result = KErrNone;
-    HBufC16* urlPathUnicode = UpnpString::ToUnicodeL( aUrlPath );
-    CleanupStack::PushL( urlPathUnicode );
-    HBufC16* fileNameUnicode = UpnpString::ToUnicodeL( aFileName );
-    CleanupStack::PushL( fileNameUnicode );
-
-    result = iCdDataFinder->FindSharedFolderL( *urlPathUnicode,
-        *fileNameUnicode, unicodeSharedFolder );
-    if ( unicodeSharedFolder )
-        {
-        CleanupStack::PushL( unicodeSharedFolder );
-        HBufC8* sharedFolder =
-                UpnpString::FromUnicodeL( *unicodeSharedFolder );
-        CleanupStack::PopAndDestroy( unicodeSharedFolder );
-        aSystemPath = sharedFolder;
-        }
-
-    CleanupStack::PopAndDestroy( fileNameUnicode );
-    CleanupStack::PopAndDestroy( urlPathUnicode );
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-//  CUpnpDlnaFilter::CheckDLNAPostCorrelationsL
-//
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpDlnaFilter::CheckDLNAPostCorrelationsL( CUpnpHttpFileReceiveTransaction& aTransaction )
-    {
-    TPtrC8 contentURI = aTransaction.SenderUri();
-    HBufC8* decodedContentURI = HBufC8::NewLC( contentURI.Length() );
-    TPtr8 ptrDecodedContentURI = decodedContentURI->Des();
-    ptrDecodedContentURI.Copy( contentURI );
-    UpnpString::ReplaceHttpCharacters( ptrDecodedContentURI );
-
-    TBool streamingSupport = 0;
-    TBool interactiveSupport = 0;
-
-    CUpnpDlnaProtocolInfo* protocolInfo = NULL;
-    TRAPD( error, protocolInfo =
-            iCdDataFinder->GetProtocolInfoByImportUriL( *decodedContentURI ) );
-    CleanupStack::PopAndDestroy( decodedContentURI );
-    if ( error )
-        {
-        if ( error == ERestrictedObject || error == ERestrictedParentObject )
-            {
-            return -EHttpForbidden;
-            }
-        else if ( error == ENoSuchObject )
-            {
-            return -EHttpNotFound;
-            }
-        else
-            {
-            return -EHttpBadRequest;
-            }
-        }
-    CleanupStack::PushL( protocolInfo );
-    if ( protocolInfo->FourthField().Find( KDlnaFilter ) == KErrNotFound )
-        {
-        aTransaction.FilterHeaders().RemoveHeaderL( UpnpDLNA::KHdrTransferMode );
-        CleanupStack::PopAndDestroy( protocolInfo );
-        return KErrNone;
-        }
-    else
-        {
-        streamingSupport = protocolInfo->DlnaFlag(
-            UpnpDlnaProtocolInfo::TM_S_FLAG );
-        interactiveSupport = protocolInfo->DlnaFlag(
-            UpnpDlnaProtocolInfo::TM_I_FLAG );
-        CleanupStack::PopAndDestroy( protocolInfo );
-        }
-
-    TDesC8& transferMode = aTransaction.FilterHeaders().QueryHeader(
-                           UpnpDLNA::KHdrTransferMode );
-
-    if ( transferMode.Length() > 0 )
-        {
-        if ( (transferMode.CompareC( UpnpDLNA::KTransferModeStreaming ) == 0
-                && !streamingSupport) || (transferMode.CompareC(
-            UpnpDLNA::KTransferModeInteractive ) == 0 && !interactiveSupport) )
-            {
-            return -EHttpNotAcceptable;
-            }
-
-        if ( transferMode.CompareC( UpnpDLNA::KTransferModeStreaming ) != 0
-                && transferMode.CompareC( UpnpDLNA::KTransferModeInteractive )
-                        != 0 && transferMode.CompareC(
-            UpnpDLNA::KTransferModeBackground ) != 0 )
-            {
-            return -EHttpBadRequest;
-            }
-        }
-
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-//  CUpnpDlnaFilter::CheckDLNACorrelations
-//
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpDlnaFilter::CheckDLNACorrelationsL( CUpnpHttpFileServeTransaction& aTransaction )
-    {
-    TPtrC8 contentURI = aTransaction.SenderUri() ;
-    HBufC8* decodedContentURI = HBufC8::NewL( contentURI.Length() );
-    TPtr8 ptrDecodedContentURI = decodedContentURI->Des();
-    ptrDecodedContentURI.Copy( contentURI );
-    UpnpString::ReplaceHttpCharacters( ptrDecodedContentURI );
-    CleanupStack::PushL( decodedContentURI );
-    delete iProtocolInfo;
-    iProtocolInfo = NULL;
-    iProtocolInfo = ProtocolInfoL( *decodedContentURI );
-    CleanupStack::PopAndDestroy( decodedContentURI );    
-    TPtrC8 fourthField( KNullDesC8 );
-    if ( iProtocolInfo )
-        {
-        fourthField.Set( iProtocolInfo->FourthField() );
-        }
-
-    if ( fourthField.Find( KDlnaFilter ) == KErrNotFound )
-        {
-        aTransaction.FilterHeaders().RemoveHeaderL( UpnpDLNA::KHdrTransferMode );
-        return KErrNone;
-        }
-
-    TUpnpDlnaCorelation dlnaCorelation;
-    dlnaCorelation.iFourthField.Set( fourthField );
-
-    TInt corelationError = CheckCorelationL( aTransaction, dlnaCorelation );
-    if ( corelationError != KErrNone )
-        {
-        return corelationError;
-        }
-    corelationError = CheckTransferModeL( aTransaction, dlnaCorelation );
-    if ( corelationError != KErrNone )
-        {
-        return corelationError;
-        }    
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpHttpServer::CheckCorelationL
-// -----------------------------------------------------------------------------
-//    
-TInt CUpnpDlnaFilter::CheckCorelationL(  CUpnpHttpFileServeTransaction& aTransaction,
-                                         TUpnpDlnaCorelation& aDlnaCorelation )
-    {
-    //-------------Checking DLNA correlations, response with HTTPerror if some problem occurs
-    // DLNA v0.75, 7.3.31.1 checking Operations Parameter    
-    if (
-    // We don't support timeSeek and playSpeed at the moment, so according to point 7.4.71.1 (ver 1.5 rev 0.96)
-    ((aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTimeSeekRange ) != KNullDesC8()
-            || aTransaction.QueryRequestHeader( UpnpDLNA::KHdrPlaySpeed )
-                    != KNullDesC8()) &&
-    // 7.4.71.2 - range takes precedence
-                    aTransaction.QueryRequestHeader( UpnpHTTP::KHdrRange ) == KNullDesC8())
-            ||
-            //
-            // or if request mode is Streaming and
-            (aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTransferMode ). CompareC(
-                UpnpDLNA::KTransferModeStreaming ) == 0 && (
-            // if we have no protocolInfo (because for example there is no cdDataFinder )
-                    !iProtocolInfo ||
-                    // Streaming is not supported for this content type
-                            iProtocolInfo -> DlnaFlag(
-                                UpnpDlnaProtocolInfo::TM_S_FLAG ) == EFalse)) )
-        {
-        // we respond with 406 error code - Not Acceptable.
-        return -EHttpNotAcceptable;
-        }
-
-    aDlnaCorelation.iStreamingSupport = EFalse;
-    aDlnaCorelation.iInteractiveSupport = EFalse;
-    aDlnaCorelation.iBackgrondSupport = EFalse;
-    aDlnaCorelation.iGetContentFeaturesExist = EFalse;
-    aDlnaCorelation.iGetContentFeaturesIsOK = ETrue;
-    
-    // We can only check for getcontentFeaturesExist if we have cdDataFinder ( protocolInfo is not null )
-    if ( iProtocolInfo )
-        {
-        aDlnaCorelation.iBackgrondSupport = 1;
-        aDlnaCorelation.iStreamingSupport = iProtocolInfo->DlnaFlag(
-            UpnpDlnaProtocolInfo::TM_S_FLAG );
-        aDlnaCorelation.iInteractiveSupport = iProtocolInfo->DlnaFlag(
-            UpnpDlnaProtocolInfo::TM_I_FLAG );
-        if( aTransaction.QueryRequestHeader( UpnpDLNA::KHdrGetcontentFeatures() ) != KNullDesC8() )
-            {
-            aDlnaCorelation.iGetContentFeaturesExist = ETrue;
-            }
-        if( aDlnaCorelation.iGetContentFeaturesExist )
-            {
-            TDesC8& cntHeaderValue = aTransaction.QueryRequestHeader(
-                                 UpnpDLNA::KHdrGetcontentFeatures() );
-            if ( cntHeaderValue != UpnpDLNA::KHdrGetcontentFeaturesValue() )
-                {
-                aDlnaCorelation.iGetContentFeaturesIsOK = EFalse;
-                }
-            }
-        }
-    
-    // Append contentFeatures.dlna.org
-    if ( aDlnaCorelation.iGetContentFeaturesExist )
-        {
-        if ( aDlnaCorelation.iFourthField.Length() > 0 )
-            {
-            aTransaction.FilterHeaders().AddHeaderL( UpnpDLNA::KHdrContentFeatures,
-                                                     aDlnaCorelation.iFourthField );
-            }
-        }
-    return KErrNone;    
-    }        
-        
-// -----------------------------------------------------------------------------
-// CUpnpHttpServer::CheckTransferMode
-// -----------------------------------------------------------------------------
-//        
-TInt CUpnpDlnaFilter::CheckTransferModeL( CUpnpHttpFileServeTransaction& aTransaction,
-                                         TUpnpDlnaCorelation& aDlnaCorelation )
-    {
-     TDesC8& transferMode = aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTransferMode );
-    // Check if requested transfer mode is handled
-    if (
-    // if client requested for transfer is not empty
-    (transferMode.Length() > 0 && (
-    // and if client requested for transfer is different than Background, Streaming or Interactive mode, reply with 400 error
-            (transferMode.CompareC( UpnpDLNA::KTransferModeStreaming ) != 0
-                    && transferMode.CompareC(
-                        UpnpDLNA::KTransferModeInteractive ) != 0
-                    && transferMode.CompareC(
-                        UpnpDLNA::KTransferModeBackground ) != 0) ||
-            // If Background or Interactive mode was requested, check if request doesn;t contain forbidden headers
-                    ((transferMode.CompareC(
-                        UpnpDLNA::KTransferModeBackground ) == 0
-                            || transferMode.CompareC(
-                                UpnpDLNA::KTransferModeInteractive ) == 0)
-                            && (aTransaction.QueryRequestHeader(
-                                UpnpDLNA::KHdrTimeSeekRange ) != KNullDesC8()
-                                    || aTransaction.QueryRequestHeader(
-                                        UpnpDLNA::KHdrPlaySpeed )
-                                            != KNullDesC8()
-                                    || aTransaction.QueryRequestHeader(
-                                        UpnpDLNA::KHdrRealTimeInfo )
-                                            != KNullDesC8())))) || (
-    
-        aTransaction.QueryRequestHeader( UpnpHTTP::KHdrRange ) == KNullDesC8()
-                && transferMode.Length() == 0 && (aTransaction.QueryRequestHeader(
-            UpnpDLNA::KHdrTimeSeekRange ) != KNullDesC8()
-                || aTransaction.QueryRequestHeader( UpnpDLNA::KHdrPlaySpeed )
-                        != KNullDesC8() || aTransaction.QueryRequestHeader(
-            UpnpDLNA::KHdrRealTimeInfo ) != KNullDesC8()))
-                || !aDlnaCorelation.iGetContentFeaturesIsOK
-    
-        )
-            {
-            return -EHttpBadRequest ;
-            }
-    
-    return AppendCorelationHeadersL( aTransaction, aDlnaCorelation, transferMode );    
-    }    
-
-// -----------------------------------------------------------------------------
-// CUpnpHttpServer::AppendCorelationHeaders
-// -----------------------------------------------------------------------------
-//        
-TInt CUpnpDlnaFilter::AppendCorelationHeadersL( CUpnpHttpFileServeTransaction& aTransaction,
-                             TUpnpDlnaCorelation& aDlnaCorelation, TDesC8& aTransferMode )
-    {
-    if ( aTransferMode.Length() > 0 && ((aTransferMode.CompareC(
-        UpnpDLNA::KTransferModeStreaming ) == 0 && !aDlnaCorelation.iStreamingSupport)
-            || (aTransferMode.CompareC( UpnpDLNA::KTransferModeInteractive )
-                    == 0 && !aDlnaCorelation.iInteractiveSupport)) )
-        {
-        return -EHttpNotAcceptable ;
-        }
-    else if ( aTransferMode.Length() <= 0 )
-        {
-        if ( aDlnaCorelation.iStreamingSupport )
-            {
-            aTransaction.FilterHeaders().AddHeaderL( UpnpDLNA::KHdrTransferMode,
-                    UpnpDLNA::KTransferModeStreaming );
-            }
-        else if ( aDlnaCorelation.iInteractiveSupport )
-            {
-            aTransaction.FilterHeaders().AddHeaderL( UpnpDLNA::KHdrTransferMode,
-                UpnpDLNA::KTransferModeInteractive );
-            }
-        else if ( aDlnaCorelation.iBackgrondSupport )
-            {
-            aTransaction.FilterHeaders().AddHeaderL( UpnpDLNA::KHdrTransferMode,
-                UpnpDLNA::KTransferModeBackground );
-            }
-        }
-     return KErrNone;   
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpHttpSession::FormatPathL
-//
-// -----------------------------------------------------------------------------
-//
-void CUpnpDlnaFilter::FormatPathL( CUpnpHttpFileServeTransaction *aTransaction, TDes &aPath )
-    {
-    LOGS( "%i, CUpnpHttpSession::FormatPathL " );
-
-    TPtrC8 contentURI = aTransaction->SenderUri();
-
-    HBufC8* decodedContentURI = HBufC8::NewL( contentURI.Length() );
-    TPtr8 ptrDecodedContentURI = decodedContentURI->Des();
-    ptrDecodedContentURI.Copy( contentURI );
-    UpnpString::ReplaceHttpCharacters( ptrDecodedContentURI );
-    CleanupStack::PushL( decodedContentURI );
-
-    //extracting URLpath (so removing IP, port )
-    TPtrC8 fileName;
-    TInt parseError( KErrNone );
-    TPtrC8 urlPath = UpnpFileUtil::ExtractUrlPath( ptrDecodedContentURI,
-        fileName, parseError );
-    if ( parseError )
-        {
-        User::Leave( -EHttpBadRequest );
-        }
-
-    HBufC8* sharedFolder = NULL;
-    TInt error = FindSharedFolderDBL( urlPath, fileName, sharedFolder );
-    CleanupStack::PushL( sharedFolder );            
-    if ( error == KErrNotFound || !sharedFolder )
-        {
-        User::Leave( -EHttpNotFound );
-        }
-    
-    //sharedFolder includes file name  
-    ASSERT( (*sharedFolder).Mid( (*sharedFolder).Length()
-            - UpnpString::KDoubleBackSlash().Length() )
-            != UpnpString::KDoubleBackSlash() );
-
-    HBufC* path16 = UpnpString::ToUnicodeL( *sharedFolder );
-    aPath.Copy( *path16 );
-    delete path16;
-    
-    CleanupStack::PopAndDestroy( sharedFolder );
-    CleanupStack::PopAndDestroy( decodedContentURI );
-    }
-
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::GetContentTypeL()
-// Retrieves a mime type from the third field of the protocol info read from CD
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpDlnaFilter::GetContentTypeL( CUpnpHttpFileServeTransaction &aTransaction,
-    HBufC8*& aMime, const TDesC16& aFilename )
-    {
-    TInt error = KErrNone;
-
-    TParse parse;
-    parse.Set( aFilename, NULL, NULL );
-    TBufC16<KMaxName> ext( parse.Ext() );
-    //XML mime type has to be set seperately
-    if ( ext.FindC( KXml16 ) == 0 && ext.Length() == KXml16().Length() )
-        {
-        // Extension says that's XML but we check content to be sure and get encoding
-        _LIT8( KXmlUtf8, "text/xml; charset=\"utf-8\"" );
-        aMime = HBufC8::NewL( KXmlUtf8().Length() );
-        aMime->Des().Zero();
-        aMime->Des().Append( KXmlUtf8() );
-        return error;
-        }
-
-    //decoding content URI
-    TPtrC8 contentURI = aTransaction.SenderUri();
-    HBufC8* decodedContentURI = HBufC8::NewL( contentURI.Length() );
-    TPtr8 ptrDecodedContentURI = decodedContentURI->Des();
-    ptrDecodedContentURI.Copy( contentURI );
-    UpnpString::ReplaceHttpCharacters( ptrDecodedContentURI );
-    CleanupStack::PushL( decodedContentURI );
-
-    //getting 3rd field
-    aMime = ThirdFieldFromCdL( *decodedContentURI );
-    CleanupStack::PopAndDestroy( decodedContentURI );
-    // asterick as mime type is not good - so error is KErrNotFound
-    _LIT8( KAseriskType, "*" );
-    if ( (NULL == aMime) || ((*aMime) == KAseriskType()) )
-        {
-        delete aMime;
-        aMime = NULL;
-        error = KErrNotFound;
-        }
-    return error;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::DetermineDownloadPathL
-//
-// -----------------------------------------------------------------------------
-//
-HBufC* CUpnpDlnaFilter::DetermineDownloadPathL(
-    CUpnpHttpFileReceiveTransaction& aTransaction )
-    {
-    TPtrC8 path = aTransaction.SenderUri();
-    TInt parseError( KErrNone );
-    TPtrC8 urlPath = UpnpFileUtil::ExtractUrlPath( path, parseError );
-    if ( parseError )
-        {
-        User::Leave( EHttpBadRequest );
-        }
-
-    // if importURI is bad then doesn't check shared folder just return error.
-    TInt result = CheckImportUriL( path );
-    if ( KErrNone == result )
-        {
-        return KNullDesC().AllocL();
-        }
-    if ( result < KErrNone && result != KErrGeneral )
-        {
-        return NULL;
-        }
-    HBufC* fileName = HBufC::NewLC( KMaxFileName );
-    TPtr fileNamePtr( fileName->Des() );
-    GetMediaFileNameL( result, fileNamePtr );
-    
-    HBufC8* sharedFolder = NULL;
-    FindSharedFolderDBL( urlPath, KNullDesC8, sharedFolder );
-    CleanupStack::PushL( sharedFolder );
-    
-    HBufC* folder = UpnpString::ToUnicodeL( *sharedFolder );
-    CleanupStack::PushL( folder );
-
-    if ( fileName->Length() == 0)
-       {
-       _LIT(KNoDcTitle, "no_dc_title");
-       fileName->Des().Copy(KNoDcTitle);
-       }
-    
-    HBufC* resultFileName = HBufC::NewL( folder->Length() + fileName->Length() );   
-    resultFileName->Des().Zero();
-    resultFileName->Des().Append( *folder );
-    resultFileName->Des().Append( *fileName );
-    
-    CleanupStack::PopAndDestroy( folder );
-    CleanupStack::PopAndDestroy( sharedFolder );
-    CleanupStack::PopAndDestroy( fileName );
-    
-    CleanupStack::PushL( resultFileName );        
-    HBufC* uniqueFileName = MakeFileNameUniqueL(*resultFileName, iFs );
-    CleanupStack::PopAndDestroy( resultFileName );
-        
-    return uniqueFileName;
-    }
-        
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::PrepareHeaderL
-//
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpDlnaFilter::PrepareHeaderL( CUpnpHttpFileServeTransaction& aTransaction )
-    {    
-    HBufC8* mimetype = NULL;
-    HBufC16* fileName = aTransaction.PathWithNewMethodL();
-    CleanupStack::PushL( fileName );
-    
-    if ( GetContentTypeL( aTransaction, mimetype, *fileName ) != KErrNone )
-        {
-        //getting mime type from Symbian or by the extension
-        mimetype = UpnpFileUtil::GetMimeTypeForFileL( *fileName );
-        }
-    CleanupStack::PushL( mimetype );
-    aTransaction.AddResponseHeaderL( UpnpGENA::KContentType(), *mimetype );
-    CleanupStack::PopAndDestroy( mimetype );
-    
-    // Checks if all DLNA correlations are ok and adds proper headers
-    // only for GET response
-
-    TInt dlnaCorrelationsError = CheckDLNACorrelationsL( aTransaction );
-    if ( dlnaCorrelationsError < KErrNone )
-        {
-        CleanupStack::PopAndDestroy( fileName );
-        return dlnaCorrelationsError;
-        }
-
-    
-    AddHeaderIfNotEmptyL( UpnpDLNA::KHdrContentFeatures(), aTransaction );
-    
-        // 7.4.42.2 HTTP Server Endpoints that transfer Non-Cacheable Content using · HTTP/1.0, and· GET responses.
-        // These devices must prevent intermediate caching by including among the HTTP response headers
-        // the directive:· Pragma:  no-cache
-    aTransaction.AddResponseHeaderL( UpnpHTTP::KHdrPragma(),
-                                     UpnpHTTP::KNoCache() );   
-    aTransaction.AddResponseHeaderL( UpnpHTTP::KHdrCacheControl(),
-                                     UpnpHTTP::KNoCache() );        
-
-
-    // If Accept-Language header is present
-    if ( aTransaction.QueryRequestHeader( UpnpHTTP::KHdrAcceptLanguage() ).Length() > 0 )
-        {
-        aTransaction.AddResponseHeaderL( UpnpHTTP::KHdrContentLanguage(),
-                                         UpnpHTTP::KLanguageEn() );        
-        }
-
-    // Transfer Mode
-    // If Transfer Mode header is present
-    AddHeaderIfNotEmptyL( UpnpDLNA::KHdrTransferMode, aTransaction );
-
-    CleanupStack::PopAndDestroy( fileName );
-    return KErrNone;
-    }
-    
-// -----------------------------------------------------------------------------
-//  CUpnpDlnaFilter::AddHeaderIfNotEmptyL
-//
-// -----------------------------------------------------------------------------
-//
-void CUpnpDlnaFilter::AddHeaderIfNotEmptyL( const TDesC8& aHeaderName, 
-    CUpnpHttpFileServeTransaction& aTransaction )
-    {
-    if ( aTransaction.FilterHeaders().QueryHeader( aHeaderName ).Length() > 0 )
-        {
-        aTransaction.AddResponseHeaderL( aHeaderName,
-            aTransaction.FilterHeaders().QueryHeader( aHeaderName ) );            
-        }
-    }
-
-// -----------------------------------------------------------------------------
-//  CUpnpDlnaFilter::NewTransactionL
-//
-// -----------------------------------------------------------------------------
-//
-void CUpnpDlnaFilter::NewTransactionL( const TDesC8& aMethod, const TDesC8& aUri, 
-    const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans )
-    {
-    if ( aMethod == KHttpPost() )
-        {
-        aResultTrans = CUpnpHttpFileReceiveTransaction::NewL( *this, aSender, aUri );
-        }
-    else
-        {
-        aResultTrans = CUpnpHttpFileServeTransaction::NewL( *this, aSender, aUri );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-//  CUpnpDlnaFilter::AuthorizeRequestL
-//
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpDlnaFilter::AuthorizeRequestL(
-    const TDesC& aFileName, const TInetAddr& aSender )
-    {
-    TInt result( KErrNone );
-    CUpnpHttpMessage* tempMessage = CUpnpHttpMessage::NewL( aSender );
-    CleanupStack::PushL( tempMessage );
-    if ( SecurityManager()
-            && SecurityManager()->AuthorizeMessage( tempMessage,
-                    (TFileName&) aFileName  ) != KErrNone )
-        { //not showing why resource is refused
-        result = -EHttpNotFound;
-        }
-    CleanupStack::PopAndDestroy( tempMessage );
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::FileSession
-// -----------------------------------------------------------------------------
-//
-RFs& CUpnpDlnaFilter::FileSession()
-    {
-    return iFs;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::PreparePostfixToMakeFileUniqueL
-// -----------------------------------------------------------------------------
-//
-HBufC* CUpnpDlnaFilter::PreparePostfixToMakeFileUniqueL( const TDesC& aFilename, RFs& aFs )
-    {
-    _LIT( KUnderScore, "_" );
-    const TInt KDotLength = 1;  // when aFileName is without extension
-
-    HBufC16* newFile = HBufC16::NewLC( aFilename.Length() + KUnderScore().Length() 
-                                       + UpnpString::KMaxTUintLength + KDotLength );
-
-    TParse parse;
-    parse.Set( aFilename, NULL, NULL );
-    TPtrC fileName = parse.Name();
-    TPtrC fileExt = parse.Ext();
-    TPtrC filePath = parse.DriveAndPath();
-
-    TUint64 postfixNumber = 1;
-
-    do
-        {
-        TBuf<UpnpString::KMaxTUintLength + 1> buf;
-        buf.AppendNum( postfixNumber++ );
-        if ( buf.Length() > UpnpString::KMaxTUintLength )
-            {
-            User::Leave( KErrOverflow );
-            }
-        newFile->Des().Copy( filePath );
-        newFile->Des().Append( fileName );
-        newFile->Des().Append( KUnderScore() );
-        newFile->Des().Append( buf );
-        newFile->Des().Append( fileExt );
-        }
-    while ( BaflUtils::FileExists( aFs, newFile->Des() ) );
-
-    CleanupStack::Pop( newFile );
-    return newFile;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::PrepareBaseFileNameL
-// -----------------------------------------------------------------------------
-//
-HBufC* CUpnpDlnaFilter::PrepareBaseFileNameL( const TDesC& aFilename, RFs& aFs )
-    {
-    HBufC* fileToServe;
-    if ( aFilename.LocateReverse( '\\' ) == aFilename.Length() - 1 )
-        {
-        _LIT( KNoName0, "noName_0" );
-        const TInt KZeroPostfixLen = 2;  //_0
-        
-        fileToServe = HBufC::NewL( aFilename.Length() + KNoName0().Length() );
-        fileToServe->Des().Copy( aFilename );
-        fileToServe->Des().Append( KNoName0() );
-        
-        if ( BaflUtils::FileExists( aFs, *fileToServe ) )
-            {
-            fileToServe->Des().Delete( fileToServe->Length() - KZeroPostfixLen, KZeroPostfixLen );
-            }
-        }
-    else
-        {
-        fileToServe = HBufC::NewL( aFilename.Length() );
-        fileToServe->Des().Copy( aFilename );
-        }
-
-    if ( BaflUtils::FileExists( aFs, *fileToServe ) )
-        {
-        CleanupStack::PushL( fileToServe );
-        HBufC* newFileName = PreparePostfixToMakeFileUniqueL( *fileToServe, aFs );
-        CleanupStack::PopAndDestroy( fileToServe );
-        fileToServe = newFileName;
-        }
-    return fileToServe;
-    }
-    
-// -----------------------------------------------------------------------------
-// CUpnpDlnaFilter::MakeFileNameUniqueL
-// -----------------------------------------------------------------------------
-//
-HBufC* CUpnpDlnaFilter::MakeFileNameUniqueL( const TDesC& aFilename, RFs& aFs )
-    {
-    HBufC* fileToServe = PrepareBaseFileNameL( aFilename, aFs );
-    
-    TPtrC questionmark;
-    questionmark.Set( *fileToServe );
-    TInt lastSlash = questionmark.LocateReverse( '\\' );
-    TInt lastQuestionMark = questionmark.LocateReverse( '?' );
-    if ( lastQuestionMark != KErrNotFound && lastSlash < lastQuestionMark )
-        {
-        CleanupStack::PushL( fileToServe );
-        questionmark.Set( questionmark.Left( lastQuestionMark ) );
-
-        // now setting new name for file        
-        HBufC* newFileName; //necessary not to loose current fileToServe
-        newFileName = HBufC::NewL( questionmark.Length() );
-        newFileName->Des().Copy( questionmark  );
-        CleanupStack::PopAndDestroy( fileToServe );
-        fileToServe = newFileName;
-        }
-    
-    TPtrC path;
-    path.Set( *fileToServe );
-    TInt lastPosOfSlash = 0;
-    TInt posOfBackSlash = path.Find( KDoubleBackSlash );
-    
-    while ( posOfBackSlash != KErrNotFound )
-        {
-        path.Set( path.Mid( posOfBackSlash + 1 ) );
-        lastPosOfSlash = lastPosOfSlash + posOfBackSlash + 1;
-        posOfBackSlash = path.Find( KDoubleBackSlash );
-        }
-    
-    if ( lastPosOfSlash > 0 )
-        {
-        path.Set( *fileToServe );
-        path.Set( path.Left( lastPosOfSlash ) );
-        }
-        
-    return fileToServe;
-    }
-
-
-//  End of File
+/** @file
+ * Copyright (c) 2005-2009 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:  CUpnpDlnaFilter implementation.
+ *
+ */
+// INCLUDES
+#include <bautils.h> 
+#include "upnpdlnafilter.h"
+#include "upnpstring.h"
+#include "upnpcons.h"
+#include "upnpcontentdirectorydatafinder.h"
+#include "upnphttpmessage.h"
+#include "upnpdlnaprotocolinfo.h"
+#include "upnpfileutils.h"
+#include "upnpsecuritymanager.h"
+#define KLogFile _L("DLNAWebServer.txt")
+#include "upnpcustomlog.h"
+#include "upnphttpfilereceivetransaction.h"
+#include "upnphttpdataservetransaction.h"
+#include "upnpdlnafilterheaders.h"
+#include "upnpcommonupnplits.h"
+#include "upnpdlnacorelation.h"
+
+
+// CONSTANTS
+_LIT8( KDlnaFilter, "DLNA");
+_LIT8( KIpPortPlaceholder8, "___.___.___.___:_____" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CUpnpDlnaFilter* CUpnpDlnaFilter::NewL(
+    MUpnpContentDirectoryDataFinder* aFinder,
+    CUpnpSecurityManager* aSecurityManager )
+    {
+    CUpnpDlnaFilter* self =
+            CUpnpDlnaFilter::NewLC( aFinder, aSecurityManager );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+//  CUpnpDlnaFilter::NewTransactionL
+//
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpDlnaFilter::NewTransactionL( const TDesC8& aMethod, const TDesC8& aUri, 
+    const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans )
+    {
+    if ( aMethod == KHttpPost() )
+        {
+        aResultTrans = CUpnpHttpFileReceiveTransaction::NewL( *this, aSender, aUri );
+        }
+    else
+        {
+        aResultTrans = CUpnpHttpDataServeTransaction::NewL( *this, aSender, aUri );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+EXPORT_C CUpnpDlnaFilter* CUpnpDlnaFilter::NewLC(
+    MUpnpContentDirectoryDataFinder* aFinder,
+    CUpnpSecurityManager* aSecurityManager )
+    {
+    CUpnpDlnaFilter* self = new (ELeave) CUpnpDlnaFilter( aFinder,
+        aSecurityManager );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::CUpnpDlnaFilter
+// C++ default constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpDlnaFilter::CUpnpDlnaFilter( MUpnpContentDirectoryDataFinder* aFinder,
+    CUpnpSecurityManager* aSecurityManager ) :
+    iCdDataFinder( aFinder ), iSecurityManager( aSecurityManager )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::~CUpnpDlnaFilter
+// C++ default destructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpDlnaFilter::~CUpnpDlnaFilter()
+    {
+    iFs.Close();
+    delete iProtocolInfo;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::ConstructL
+// EPOC default constructor for performing 2nd stage construction.
+// -----------------------------------------------------------------------------
+//
+void CUpnpDlnaFilter::ConstructL()
+    {
+    User::LeaveIfError( iFs.Connect() );
+    User::LeaveIfNull(iCdDataFinder);
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::SecurityManager
+// 
+// -----------------------------------------------------------------------------
+//
+CUpnpSecurityManager* CUpnpDlnaFilter::SecurityManager()
+    {
+    return iSecurityManager;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::CheckImportUriL
+// Checks if specified URI exists in database and returns object id for
+//      given URI or KErrNotFound if URI is no registered in database.
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpDlnaFilter::CheckImportUriL( TDesC8& aImportUri )
+    {
+    TInt lastPosOfSlash = aImportUri.LocateReverse( '/' );
+    if ( lastPosOfSlash < 0 )
+        {
+        return KErrGeneral;
+        }
+    HBufC8* path = aImportUri.AllocLC();
+    TInt result = KErrNone;
+    result = iCdDataFinder->CheckImportUriL( path->Des() );
+    CleanupStack::PopAndDestroy( path );
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::Get3rdFieldFromCdL
+// Find protocolInfo by contentUri (Not by importUri) and extract 3rd field,
+//      using ContentDirectory.
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpDlnaFilter::ThirdFieldFromCdL( const TDesC8& aContentUri )
+    {
+    HBufC8* result = NULL;
+    CUpnpDlnaProtocolInfo* protocolInfo = ProtocolInfoL( aContentUri );
+    CleanupStack::PushL(protocolInfo);
+    if ( protocolInfo )
+        {
+        TPtrC8 thirdField = protocolInfo->ThirdField();
+        if ( thirdField != KNullDesC8() )
+            {
+            result = thirdField.AllocL();
+            }
+        }
+    CleanupStack::PopAndDestroy(protocolInfo);
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::ProtocolInfoL
+// 
+// -----------------------------------------------------------------------------
+//
+CUpnpDlnaProtocolInfo* CUpnpDlnaFilter::ProtocolInfoL( const TDesC8& aContentUri )
+    {
+    //  "http:/:/" prefix is added to content path to provide backward 
+    // compatibility with old testing tools
+    HBufC8* fullContentUri = HBufC8::NewL( UpnpHTTP::KHTTPUrl().Length()
+            + KIpPortPlaceholder8().Length() + aContentUri.Length() );
+    CleanupStack::PushL( fullContentUri );
+    
+    fullContentUri->Des().Append( UpnpHTTP::KHTTPUrl );
+    fullContentUri->Des().Append( KIpPortPlaceholder8 );
+    fullContentUri->Des().Append( aContentUri );
+    
+    CUpnpDlnaProtocolInfo* protocolInfo = NULL;
+    if ( iCdDataFinder->GetProtocolInfoL( *fullContentUri, protocolInfo ) != KErrNone )
+        {
+        delete protocolInfo;
+        protocolInfo = NULL;
+        }
+    CleanupStack::PopAndDestroy( fullContentUri );
+    return protocolInfo;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::GetMediaFileNameL
+// Gets name of file with content for given object's id.
+// -----------------------------------------------------------------------------
+//
+void CUpnpDlnaFilter::GetMediaFileNameL( TInt aObjectId, TPtr& aFileName )
+    {
+    if ( aObjectId <= KErrNone )
+        {
+        return;
+        }
+    iCdDataFinder->GetTitleForUriL( aObjectId, aFileName );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::FindSharedFolderDBL
+// Find a folder shared from DB (ContentDirectory).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpDlnaFilter::FindSharedFolderDBL( const TDesC8& aUrlPath,
+    const TDesC8& aFileName, HBufC8*& aSystemPath )
+    {
+    HBufC* unicodeSharedFolder = NULL;
+    TInt result = KErrNone;
+    HBufC16* urlPathUnicode = UpnpString::ToUnicodeL( aUrlPath );
+    CleanupStack::PushL( urlPathUnicode );
+    HBufC16* fileNameUnicode = UpnpString::ToUnicodeL( aFileName );
+    CleanupStack::PushL( fileNameUnicode );
+
+    result = iCdDataFinder->FindSharedFolderL( *urlPathUnicode,
+        *fileNameUnicode, unicodeSharedFolder );
+    if ( unicodeSharedFolder )
+        {
+        CleanupStack::PushL( unicodeSharedFolder );
+        HBufC8* sharedFolder =
+                UpnpString::FromUnicodeL( *unicodeSharedFolder );
+        CleanupStack::PopAndDestroy( unicodeSharedFolder );
+        aSystemPath = sharedFolder;
+        }
+
+    CleanupStack::PopAndDestroy( fileNameUnicode );
+    CleanupStack::PopAndDestroy( urlPathUnicode );
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+//  CUpnpDlnaFilter::CheckDLNAPostCorrelationsL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpDlnaFilter::CheckDLNAPostCorrelationsL( CUpnpHttpFileReceiveTransaction& aTransaction )
+    {
+    HBufC8* decodedContentURI = DecodeContentUriLC(aTransaction.SenderUri());
+
+    TBool streamingSupport = 0;
+    TBool interactiveSupport = 0;
+
+    CUpnpDlnaProtocolInfo* protocolInfo = NULL;
+    TRAPD( error, protocolInfo =
+            iCdDataFinder->GetProtocolInfoByImportUriL( *decodedContentURI ) );
+    CleanupStack::PopAndDestroy( decodedContentURI );
+    if ( error )
+        {
+        if ( error == ERestrictedObject || error == ERestrictedParentObject )
+            {
+            return -EHttpForbidden;
+            }
+        else if ( error == ENoSuchObject )
+            {
+            return -EHttpNotFound;
+            }
+        else
+            {
+            return -EHttpBadRequest;
+            }
+        }
+    CleanupStack::PushL( protocolInfo );
+    if ( protocolInfo->FourthField().Find( KDlnaFilter ) == KErrNotFound )
+        {
+        aTransaction.FilterHeaders().RemoveHeaderL( UpnpDLNA::KHdrTransferMode );
+        CleanupStack::PopAndDestroy( protocolInfo );
+        return KErrNone;
+        }
+    else
+        {
+        streamingSupport = protocolInfo->DlnaFlag(
+            UpnpDlnaProtocolInfo::TM_S_FLAG );
+        interactiveSupport = protocolInfo->DlnaFlag(
+            UpnpDlnaProtocolInfo::TM_I_FLAG );
+        CleanupStack::PopAndDestroy( protocolInfo );
+        }
+
+    TDesC8& transferMode = aTransaction.FilterHeaders().QueryHeader(
+                           UpnpDLNA::KHdrTransferMode );
+
+    if ( transferMode.Length() > 0 )
+        {
+        if ( (transferMode.CompareC( UpnpDLNA::KTransferModeStreaming ) == 0
+                && !streamingSupport) || (transferMode.CompareC(
+            UpnpDLNA::KTransferModeInteractive ) == 0 && !interactiveSupport) )
+            {
+            return -EHttpNotAcceptable;
+            }
+
+        if ( transferMode.CompareC( UpnpDLNA::KTransferModeStreaming ) != 0
+                && transferMode.CompareC( UpnpDLNA::KTransferModeInteractive )
+                        != 0 && transferMode.CompareC(
+            UpnpDLNA::KTransferModeBackground ) != 0 )
+            {
+            return -EHttpBadRequest;
+            }
+        }
+
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+//  CUpnpDlnaFilter::CheckDLNACorrelations
+//
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpDlnaFilter::CheckDLNACorrelationsL( CUpnpHttpDataServeTransaction& aTransaction )
+    {
+    HBufC8* decodedContentURI = DecodeContentUriLC(aTransaction.SenderUri());
+    delete iProtocolInfo;
+    iProtocolInfo = NULL;
+    iProtocolInfo = ProtocolInfoL( *decodedContentURI );
+    CleanupStack::PopAndDestroy( decodedContentURI );    
+    TPtrC8 fourthField( KNullDesC8 );
+    if ( iProtocolInfo )
+        {
+        fourthField.Set( iProtocolInfo->FourthField() );
+        }
+
+    if ( fourthField.Find( KDlnaFilter ) == KErrNotFound )
+        {
+        aTransaction.FilterHeaders().RemoveHeaderL( UpnpDLNA::KHdrTransferMode );
+        return KErrNone;
+        }
+
+    TUpnpDlnaCorelation dlnaCorelation;
+    dlnaCorelation.iFourthField.Set( fourthField );
+
+    TInt corelationError = CheckCorelationL( aTransaction, dlnaCorelation );
+    if ( corelationError != KErrNone )
+        {
+        return corelationError;
+        }
+    corelationError = CheckTransferModeL( aTransaction, dlnaCorelation );
+    if ( corelationError != KErrNone )
+        {
+        return corelationError;
+        }    
+    return KErrNone;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpHttpServer::CheckCorelationL
+// -----------------------------------------------------------------------------
+//    
+TInt CUpnpDlnaFilter::CheckCorelationL(  CUpnpHttpDataServeTransaction& aTransaction,
+                                         TUpnpDlnaCorelation& aDlnaCorelation )
+    {
+    //-------------Checking DLNA correlations, response with HTTPerror if some problem occurs
+
+    aDlnaCorelation.iStreamingSupport = EFalse;
+    aDlnaCorelation.iInteractiveSupport = EFalse;
+    aDlnaCorelation.iBackgrondSupport = EFalse;
+    aDlnaCorelation.iGetContentFeaturesExist = EFalse;
+    aDlnaCorelation.iGetContentFeaturesIsOK = ETrue;
+    
+    /* We can only check for getcontentFeaturesExist if we have cdDataFinder 
+     * ( protocolInfo is not null )*/
+    if ( iProtocolInfo )
+        {
+        aDlnaCorelation.iBackgrondSupport = 1;
+        aDlnaCorelation.iStreamingSupport = iProtocolInfo->DlnaFlag(
+            UpnpDlnaProtocolInfo::TM_S_FLAG );
+        aDlnaCorelation.iInteractiveSupport = iProtocolInfo->DlnaFlag(
+            UpnpDlnaProtocolInfo::TM_I_FLAG );
+        if( aTransaction.QueryRequestHeader( UpnpDLNA::KHdrGetcontentFeatures() ) != KNullDesC8() )
+            {
+            aDlnaCorelation.iGetContentFeaturesExist = ETrue;
+            }
+        if( aDlnaCorelation.iGetContentFeaturesExist )
+            {
+            TDesC8& cntHeaderValue = aTransaction.QueryRequestHeader(
+                                 UpnpDLNA::KHdrGetcontentFeatures() );
+            if ( cntHeaderValue != UpnpDLNA::KHdrGetcontentFeaturesValue() )
+                {
+                aDlnaCorelation.iGetContentFeaturesIsOK = EFalse;
+                }
+            }
+        }
+
+    // DLNA v0.75, 7.3.31.1 checking Operations Parameter    
+    if (
+		/* We don't support timeSeek and playSpeed at the moment, so according to 
+		 * point 7.4.71.1 (ver 1.5 rev 0.96)*/
+            aDlnaCorelation.iGetContentFeaturesIsOK &&
+		((	(aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTimeSeekRange ) != KNullDesC8()
+			|| aTransaction.QueryRequestHeader( UpnpDLNA::KHdrPlaySpeed )!= KNullDesC8()) 
+			&&
+			// 7.4.71.2 - range takes precedence
+			aTransaction.QueryRequestHeader( UpnpHTTP::KHdrRange ) == KNullDesC8()	)
+		||
+		// or if request mode is Streaming and
+		(	aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTransferMode ). CompareC(
+			UpnpDLNA::KTransferModeStreaming ) == 0 
+			&& 
+			(
+			/* if we have no protocolInfo (because for example there is 
+			no cdDataFinder )*/
+			!iProtocolInfo ||
+			// Streaming is not supported for this content type
+			iProtocolInfo -> DlnaFlag(UpnpDlnaProtocolInfo::TM_S_FLAG ) == EFalse)	)) 
+		)
+        {
+        // we respond with 406 error code - Not Acceptable.
+        return -EHttpNotAcceptable;
+        }
+
+    
+    // Append contentFeatures.dlna.org
+    if ( aDlnaCorelation.iGetContentFeaturesExist )
+        {
+        if ( aDlnaCorelation.iFourthField.Length() > 0 )
+            {
+            aTransaction.FilterHeaders().AddHeaderL( UpnpDLNA::KHdrContentFeatures,
+                                                     aDlnaCorelation.iFourthField );
+            }
+        }
+    return KErrNone;    
+    }        
+        
+// -----------------------------------------------------------------------------
+// CUpnpHttpServer::CheckTransferMode
+// -----------------------------------------------------------------------------
+//        
+TInt CUpnpDlnaFilter::CheckTransferModeL( CUpnpHttpDataServeTransaction& aTransaction,
+                                         TUpnpDlnaCorelation& aDlnaCorelation )
+    {
+     TDesC8& transferMode = aTransaction.QueryRequestHeader( UpnpDLNA::KHdrTransferMode );
+    // Check if requested transfer mode is handled
+    if (
+    // if client requested for transfer is not empty
+    (transferMode.Length() > 0 && (
+    // and if client requested for transfer is different than Background, Streaming or Interactive mode, reply with 400 error
+            (transferMode.CompareC( UpnpDLNA::KTransferModeStreaming ) != 0
+                    && transferMode.CompareC(
+                        UpnpDLNA::KTransferModeInteractive ) != 0
+                    && transferMode.CompareC(
+                        UpnpDLNA::KTransferModeBackground ) != 0) ||
+            // If Background or Interactive mode was requested, check if request doesn;t contain forbidden headers
+                    ((transferMode.CompareC(
+                        UpnpDLNA::KTransferModeBackground ) == 0
+                            || transferMode.CompareC(
+                                UpnpDLNA::KTransferModeInteractive ) == 0)
+                            && (aTransaction.QueryRequestHeader(
+                                UpnpDLNA::KHdrTimeSeekRange ) != KNullDesC8()
+                                    || aTransaction.QueryRequestHeader(
+                                        UpnpDLNA::KHdrPlaySpeed )
+                                            != KNullDesC8()
+                                    || aTransaction.QueryRequestHeader(
+                                        UpnpDLNA::KHdrRealTimeInfo )
+                                            != KNullDesC8())))) || (
+    
+        aTransaction.QueryRequestHeader( UpnpHTTP::KHdrRange ) == KNullDesC8()
+                && transferMode.Length() == 0 && (aTransaction.QueryRequestHeader(
+            UpnpDLNA::KHdrTimeSeekRange ) != KNullDesC8()
+                || aTransaction.QueryRequestHeader( UpnpDLNA::KHdrPlaySpeed )
+                        != KNullDesC8() || aTransaction.QueryRequestHeader(
+            UpnpDLNA::KHdrRealTimeInfo ) != KNullDesC8()))
+                || !aDlnaCorelation.iGetContentFeaturesIsOK
+    
+        )
+            {
+            return -EHttpBadRequest ;
+            }
+    
+    return AppendCorelationHeadersL( aTransaction, aDlnaCorelation, transferMode );    
+    }    
+
+// -----------------------------------------------------------------------------
+// CUpnpHttpServer::AppendCorelationHeaders
+// -----------------------------------------------------------------------------
+//        
+TInt CUpnpDlnaFilter::AppendCorelationHeadersL( CUpnpHttpDataServeTransaction& aTransaction,
+                             TUpnpDlnaCorelation& aDlnaCorelation, TDesC8& aTransferMode )
+    {
+    if ( aTransferMode.Length() > 0 && ((aTransferMode.CompareC(
+        UpnpDLNA::KTransferModeStreaming ) == 0 && !aDlnaCorelation.iStreamingSupport)
+            || (aTransferMode.CompareC( UpnpDLNA::KTransferModeInteractive )
+                    == 0 && !aDlnaCorelation.iInteractiveSupport)) )
+        {
+        return -EHttpNotAcceptable ;
+        }
+    else if ( aTransferMode.Length() <= 0 )
+        {
+        if ( aDlnaCorelation.iStreamingSupport )
+            {
+            aTransaction.FilterHeaders().AddHeaderL( UpnpDLNA::KHdrTransferMode,
+                    UpnpDLNA::KTransferModeStreaming );
+            }
+        else if ( aDlnaCorelation.iInteractiveSupport )
+            {
+            aTransaction.FilterHeaders().AddHeaderL( UpnpDLNA::KHdrTransferMode,
+                UpnpDLNA::KTransferModeInteractive );
+            }
+        else if ( aDlnaCorelation.iBackgrondSupport )
+            {
+            aTransaction.FilterHeaders().AddHeaderL( UpnpDLNA::KHdrTransferMode,
+                UpnpDLNA::KTransferModeBackground );
+            }
+        }
+     return KErrNone;   
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpHttpSession::FormatPathL
+//
+// -----------------------------------------------------------------------------
+//
+void CUpnpDlnaFilter::FormatPathL( CUpnpHttpDataServeTransaction *aTransaction, TDes &aPath )
+    {
+    LOGS( "%i, CUpnpHttpSession::FormatPathL " );
+
+    TPtrC8 contentURI = aTransaction->SenderUri();
+
+    HBufC8* decodedContentURI = HBufC8::NewL( contentURI.Length() );
+    TPtr8 ptrDecodedContentURI = decodedContentURI->Des();
+    ptrDecodedContentURI.Copy( contentURI );
+    UpnpString::ReplaceHttpCharacters( ptrDecodedContentURI );
+    CleanupStack::PushL( decodedContentURI );
+
+    //extracting URLpath (so removing IP, port )
+    TPtrC8 fileName;
+    TInt parseError( KErrNone );
+    TPtrC8 urlPath = UpnpFileUtil::ExtractUrlPath( ptrDecodedContentURI,
+        fileName, parseError );
+    if ( parseError )
+        {
+        User::Leave( -EHttpBadRequest );
+        }
+
+    HBufC8* sharedFolder = NULL;
+    TInt error = FindSharedFolderDBL( urlPath, fileName, sharedFolder );
+    CleanupStack::PushL( sharedFolder );            
+    if ( error == KErrNotFound || !sharedFolder )
+        {
+        User::Leave( -EHttpNotFound );
+        }
+    
+    //sharedFolder includes file name  
+    ASSERT( (*sharedFolder).Mid( (*sharedFolder).Length()
+            - UpnpString::KDoubleBackSlash().Length() )
+            != UpnpString::KDoubleBackSlash() );
+
+    HBufC* path16 = UpnpString::ToUnicodeL( *sharedFolder );
+    aPath.Copy( *path16 );
+    delete path16;
+    
+    CleanupStack::PopAndDestroy( sharedFolder );
+    CleanupStack::PopAndDestroy( decodedContentURI );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::GetContentTypeL()
+// Retrieves a mime type from the third field of the protocol info read from CD
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpDlnaFilter::GetContentTypeL( CUpnpHttpDataServeTransaction &aTransaction,
+    HBufC8*& aMime, const TDesC16& aFilename )
+    {
+    TInt error = KErrNone;
+
+    TParse parse;
+    parse.Set( aFilename, NULL, NULL );
+    TBufC16<KMaxName> ext( parse.Ext() );
+    //XML mime type has to be set seperately
+    if ( ext.FindC( KXml16 ) == 0 && ext.Length() == KXml16().Length() )
+        {
+        // Extension says that's XML but we check content to be sure and get encoding
+        _LIT8( KXmlUtf8, "text/xml; charset=\"utf-8\"" );
+        aMime = HBufC8::NewL( KXmlUtf8().Length() );
+        aMime->Des().Zero();
+        aMime->Des().Append( KXmlUtf8() );
+        return error;
+        }
+
+    //decoding content URI
+    HBufC8* decodedContentURI = DecodeContentUriLC( aTransaction.SenderUri());
+
+    //getting 3rd field
+    aMime = ThirdFieldFromCdL( *decodedContentURI );
+    CleanupStack::PopAndDestroy( decodedContentURI );
+    // asterick as mime type is not good - so error is KErrNotFound
+    _LIT8( KAseriskType, "*" );
+    if ( (NULL == aMime) || ((*aMime) == KAseriskType()) )
+        {
+        delete aMime;
+        aMime = NULL;
+        error = KErrNotFound;
+        }
+    return error;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::DetermineDownloadPathL
+//
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpDlnaFilter::DetermineDownloadPathL(
+    CUpnpHttpFileReceiveTransaction& aTransaction )
+    {
+    TPtrC8 path = aTransaction.SenderUri();
+    TInt parseError( KErrNone );
+    TPtrC8 urlPath = UpnpFileUtil::ExtractUrlPath( path, parseError );
+    if ( parseError )
+        {
+        User::Leave( EHttpBadRequest );
+        }
+
+    // if importURI is bad then doesn't check shared folder just return error.
+    TInt result = CheckImportUriL( path );
+    if ( KErrNone == result )
+        {
+        return KNullDesC().AllocL();
+        }
+    if ( result < KErrNone && result != KErrGeneral )
+        {
+        return NULL;
+        }
+    HBufC* fileName = HBufC::NewLC( KMaxFileName );
+    TPtr fileNamePtr( fileName->Des() );
+    GetMediaFileNameL( result, fileNamePtr );
+    
+    HBufC8* sharedFolder = NULL;
+    FindSharedFolderDBL( urlPath, KNullDesC8, sharedFolder );
+    CleanupStack::PushL( sharedFolder );
+    
+    HBufC* folder = UpnpString::ToUnicodeL( *sharedFolder );
+    CleanupStack::PushL( folder );
+
+    if ( fileName->Length() == 0)
+       {
+       _LIT(KNoDcTitle, "no_dc_title");
+       fileName->Des().Copy(KNoDcTitle);
+       }
+    
+    HBufC* resultFileName = HBufC::NewL( folder->Length() + fileName->Length() );   
+    resultFileName->Des().Zero();
+    resultFileName->Des().Append( *folder );
+    resultFileName->Des().Append( *fileName );
+    
+    CleanupStack::PopAndDestroy( folder );
+    CleanupStack::PopAndDestroy( sharedFolder );
+    CleanupStack::PopAndDestroy( fileName );
+    
+    CleanupStack::PushL( resultFileName );        
+    HBufC* uniqueFileName = MakeFileNameUniqueL(*resultFileName, iFs );
+    CleanupStack::PopAndDestroy( resultFileName );
+        
+    return uniqueFileName;
+    }
+        
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::PrepareHeaderL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpDlnaFilter::PrepareHeaderL( CUpnpHttpDataServeTransaction& aTransaction )
+    {    
+    HBufC8* mimetype = NULL;
+    HBufC16* fileName = aTransaction.PathWithNewMethodL();
+    CleanupStack::PushL( fileName );
+    
+    if ( GetContentTypeL( aTransaction, mimetype, *fileName ) != KErrNone )
+        {
+        //getting mime type from Symbian or by the extension
+        mimetype = UpnpFileUtil::GetMimeTypeForFileL( *fileName );
+        }
+    CleanupStack::PushL( mimetype );
+    aTransaction.AddResponseHeaderL( UpnpGENA::KContentType(), *mimetype );
+    CleanupStack::PopAndDestroy( mimetype );
+    
+    // Checks if all DLNA correlations are ok and adds proper headers
+    // only for GET response
+
+    TInt dlnaCorrelationsError = CheckDLNACorrelationsL( aTransaction );
+    if ( dlnaCorrelationsError < KErrNone )
+        {
+        CleanupStack::PopAndDestroy( fileName );
+        return dlnaCorrelationsError;
+        }
+
+    
+    AddHeaderIfNotEmptyL( UpnpDLNA::KHdrContentFeatures(), aTransaction );
+    
+        // 7.4.42.2 HTTP Server Endpoints that transfer Non-Cacheable Content using ?HTTP/1.0, and?GET responses.
+        // These devices must prevent intermediate caching by including among the HTTP response headers
+        // the directive:?Pragma:  no-cache
+    aTransaction.AddResponseHeaderL( UpnpHTTP::KHdrPragma(),
+                                     UpnpHTTP::KNoCache() );   
+    aTransaction.AddResponseHeaderL( UpnpHTTP::KHdrCacheControl(),
+                                     UpnpHTTP::KNoCache() );        
+
+
+    // If Accept-Language header is present
+    if ( aTransaction.QueryRequestHeader( UpnpHTTP::KHdrAcceptLanguage() ).Length() > 0 )
+        {
+        aTransaction.AddResponseHeaderL( UpnpHTTP::KHdrContentLanguage(),
+                                         UpnpHTTP::KLanguageEn() );        
+        }
+
+    // Transfer Mode
+    // If Transfer Mode header is present
+    AddHeaderIfNotEmptyL( UpnpDLNA::KHdrTransferMode, aTransaction );
+
+    CleanupStack::PopAndDestroy( fileName );
+    return KErrNone;
+    }
+    
+// -----------------------------------------------------------------------------
+//  CUpnpDlnaFilter::AddHeaderIfNotEmptyL
+//
+// -----------------------------------------------------------------------------
+//
+void CUpnpDlnaFilter::AddHeaderIfNotEmptyL( const TDesC8& aHeaderName, 
+    CUpnpHttpDataServeTransaction& aTransaction )
+    {
+    if ( aTransaction.FilterHeaders().QueryHeader( aHeaderName ).Length() > 0 )
+        {
+        aTransaction.AddResponseHeaderL( aHeaderName,
+            aTransaction.FilterHeaders().QueryHeader( aHeaderName ) );            
+        }
+    }
+
+// -----------------------------------------------------------------------------
+//  CUpnpDlnaFilter::AuthorizeRequestL
+//
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpDlnaFilter::AuthorizeRequestL(
+    const TDesC& aFileName, const TInetAddr& aSender )
+    {
+    TInt result( KErrNone );
+    CUpnpHttpMessage* tempMessage = CUpnpHttpMessage::NewL( aSender );
+    CleanupStack::PushL( tempMessage );
+    if ( SecurityManager()
+            && SecurityManager()->AuthorizeMessage( tempMessage,
+                    (TFileName&) aFileName  ) != KErrNone )
+        { //not showing why resource is refused
+        result = -EHttpNotFound;
+        }
+    CleanupStack::PopAndDestroy( tempMessage );
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::FileSession
+// -----------------------------------------------------------------------------
+//
+RFs& CUpnpDlnaFilter::FileSession()
+    {
+    return iFs;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::PreparePostfixToMakeFileUniqueL
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpDlnaFilter::PreparePostfixToMakeFileUniqueL( const TDesC& aFilename, RFs& aFs )
+    {
+    _LIT( KUnderScore, "_" );
+    const TInt KDotLength = 1;  // when aFileName is without extension
+
+    HBufC16* newFile = HBufC16::NewLC( aFilename.Length() + KUnderScore().Length() 
+                                       + UpnpString::KMaxTUintLength + KDotLength );
+
+    TParse parse;
+    parse.Set( aFilename, NULL, NULL );
+    TPtrC fileName = parse.Name();
+    TPtrC fileExt = parse.Ext();
+    TPtrC filePath = parse.DriveAndPath();
+
+    TUint64 postfixNumber = 1;
+
+    do
+        {
+        TBuf<UpnpString::KMaxTUintLength + 1> buf;
+        buf.AppendNum( postfixNumber++ );
+        if ( buf.Length() > UpnpString::KMaxTUintLength )
+            {
+            User::Leave( KErrOverflow );
+            }
+        newFile->Des().Copy( filePath );
+        newFile->Des().Append( fileName );
+        newFile->Des().Append( KUnderScore() );
+        newFile->Des().Append( buf );
+        newFile->Des().Append( fileExt );
+        }
+    while ( BaflUtils::FileExists( aFs, newFile->Des() ) );
+
+    CleanupStack::Pop( newFile );
+    return newFile;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::PrepareBaseFileNameL
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpDlnaFilter::PrepareBaseFileNameL( const TDesC& aFilename, RFs& aFs )
+    {
+    HBufC* fileToServe;
+    if ( aFilename.LocateReverse( '\\' ) == aFilename.Length() - 1 )
+        {
+        _LIT( KNoName0, "noName_0" );
+        const TInt KZeroPostfixLen = 2;  //_0
+        
+        fileToServe = HBufC::NewL( aFilename.Length() + KNoName0().Length() );
+        fileToServe->Des().Copy( aFilename );
+        fileToServe->Des().Append( KNoName0() );
+        
+        if ( BaflUtils::FileExists( aFs, *fileToServe ) )
+            {
+            fileToServe->Des().Delete( fileToServe->Length() - KZeroPostfixLen, KZeroPostfixLen );
+            }
+        }
+    else
+        {
+        fileToServe = HBufC::NewL( aFilename.Length() );
+        fileToServe->Des().Copy( aFilename );
+        }
+
+    if ( BaflUtils::FileExists( aFs, *fileToServe ) )
+        {
+        CleanupStack::PushL( fileToServe );
+        HBufC* newFileName = PreparePostfixToMakeFileUniqueL( *fileToServe, aFs );
+        CleanupStack::PopAndDestroy( fileToServe );
+        fileToServe = newFileName;
+        }
+    return fileToServe;
+    }
+    
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::MakeFileNameUniqueL
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpDlnaFilter::MakeFileNameUniqueL( const TDesC& aFilename, RFs& aFs )
+    {
+    HBufC* fileToServe = PrepareBaseFileNameL( aFilename, aFs );
+    
+    TPtrC questionmark;
+    questionmark.Set( *fileToServe );
+    TInt lastSlash = questionmark.LocateReverse( '\\' );
+    TInt lastQuestionMark = questionmark.LocateReverse( '?' );
+    if ( lastQuestionMark != KErrNotFound && lastSlash < lastQuestionMark )
+        {
+        CleanupStack::PushL( fileToServe );
+        questionmark.Set( questionmark.Left( lastQuestionMark ) );
+
+        // now setting new name for file        
+        HBufC* newFileName; //necessary not to loose current fileToServe
+        newFileName = HBufC::NewL( questionmark.Length() );
+        newFileName->Des().Copy( questionmark  );
+        CleanupStack::PopAndDestroy( fileToServe );
+        fileToServe = newFileName;
+        }
+    
+    TPtrC path;
+    path.Set( *fileToServe );
+    TInt lastPosOfSlash = 0;
+    TInt posOfBackSlash = path.Find( KDoubleBackSlash );
+    
+    while ( posOfBackSlash != KErrNotFound )
+        {
+        path.Set( path.Mid( posOfBackSlash + 1 ) );
+        lastPosOfSlash = lastPosOfSlash + posOfBackSlash + 1;
+        posOfBackSlash = path.Find( KDoubleBackSlash );
+        }
+    
+    if ( lastPosOfSlash > 0 )
+        {
+        path.Set( *fileToServe );
+        path.Set( path.Left( lastPosOfSlash ) );
+        }
+        
+    return fileToServe;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpDlnaFilter::DecodeContentUriLC
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpDlnaFilter::DecodeContentUriLC( const TPtrC8& contentURI)
+	{
+	HBufC8* decodedContentURI = HBufC8::NewL( contentURI.Length() );
+	TPtr8 ptrDecodedContentURI = decodedContentURI->Des();
+	ptrDecodedContentURI.Copy( contentURI );
+	UpnpString::ReplaceHttpCharacters( ptrDecodedContentURI );
+	CleanupStack::PushL( decodedContentURI );
+	return decodedContentURI;
+	
+	}
+//  End of File
--- a/upnpmediaserver/contentdirectoryservice/src/dlna/upnphttpfilereceivetransaction.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/dlna/upnphttpfilereceivetransaction.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,186 +1,186 @@
-/** @file
- * Copyright (c) 2009 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:  CUpnpHttpFileReceiveTransaction implementation.
- *
- */     
-
-#include <bautils.h> 
-#include "upnphttpfilereceivetransaction.h"
-#include "upnpdlnafilter.h"
-#include "upnpdlnafilterheaders.h"
-#include "upnperrors.h"
-#include "upnpcons.h"
-
-// ---------------------------------------------------------------------------
-// CUpnpHttpFileReceiveTransaction::NewL
-// 
-// ---------------------------------------------------------------------------
-//
-CUpnpHttpFileReceiveTransaction* CUpnpHttpFileReceiveTransaction::NewL( 
-        CUpnpDlnaFilter& aClientContext, const TInetAddr& aSender, const TDesC8& aUri )
-    {
-    CUpnpHttpFileReceiveTransaction* self = 
-        new (ELeave) CUpnpHttpFileReceiveTransaction( aClientContext );
-    CleanupStack::PushL( self );
-    self->ConstructL( aSender, aUri );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
-// CUpnpHttpFileServeTransaction::ConstructL
-// 
-// ---------------------------------------------------------------------------
-//
-void CUpnpHttpFileReceiveTransaction::ConstructL( 
-    const TInetAddr& aSender, const TDesC8& aSenderUri )
-    {
-    iFilterHeaders = CUpnpDlnaFilterHeaders::NewL( );
-    iSender = aSender;
-    iSenderUri = aSenderUri.AllocL();
-    }
-
-// ---------------------------------------------------------------------------
-// CUpnpHttpFileReceiveTransaction::CUpnpHttpFileReceiveTransaction
-// 
-// ---------------------------------------------------------------------------
-//
-CUpnpHttpFileReceiveTransaction::CUpnpHttpFileReceiveTransaction(
-        CUpnpDlnaFilter& aClientContext ) :
-    iClientContext(aClientContext)
-    {
-    }
-        
-// ---------------------------------------------------------------------------
-// CUpnpHttpFileReceiveTransaction::~CUpnpHttpFileReceiveTransaction
-// 
-// ---------------------------------------------------------------------------
-//
-CUpnpHttpFileReceiveTransaction::~CUpnpHttpFileReceiveTransaction()
-    {
-    delete iFilterHeaders;
-    delete iSenderUri;
-    }
-
-// ---------------------------------------------------------------------------
-// CUpnpHttpFileReceiveTransaction::OnCallbackL
-// 
-// ---------------------------------------------------------------------------
-//    
-const TDesC8& CUpnpHttpFileReceiveTransaction::SenderUri()
-    {
-    return *iSenderUri;
-    }
-
-// ---------------------------------------------------------------------------
-// CUpnpHttpFileReceiveTransaction::FilterHeaders
-// 
-// ---------------------------------------------------------------------------
-//
-CUpnpDlnaFilterHeaders& CUpnpHttpFileReceiveTransaction::FilterHeaders()
-    {
-    return *iFilterHeaders;
-    }
-
-// ---------------------------------------------------------------------------
-// CUpnpHttpFileReceiveTransaction::OnCallbackL
-// 
-// ---------------------------------------------------------------------------
-//
-void CUpnpHttpFileReceiveTransaction::OnCallbackL( TUpnpHttpServerEvent aEvent )
-    {
-    TRAPD( err, DoCallbackL( aEvent ) );
-    if ( err )
-        {
-        SetHttpCode( err );
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// CUpnpHttpFileReceiveTransaction::DoCallbackL
-// 
-// ---------------------------------------------------------------------------
-//
-void CUpnpHttpFileReceiveTransaction::DoCallbackL( TUpnpHttpServerEvent aEvent )
-    {
-    switch ( aEvent )
-        {
-        case EOnRequestStart:
-            {
-            iFileName.Zero();
-            InitializeFilterHeadersL();
-            User::LeaveIfError(  iClientContext.CheckDLNAPostCorrelationsL(
-                                          *this ) );
-            
-            HBufC* fileNameBuf = iClientContext.DetermineDownloadPathL( *this );           
-            if ( fileNameBuf )
-                { 
-                CleanupStack::PushL( fileNameBuf );
-                
-                RFile file;
-                if ( file.Open( iClientContext.FileSession(),
-                                *fileNameBuf,
-                                EFileWrite ) == KErrNone ) 
-                    {
-                    SetDataSinkL( file );
-                    SetHttpCode( iClientContext.AuthorizeRequestL( *fileNameBuf, iSender ) );
-                    }
-                else
-                    {
-                    BaflUtils::EnsurePathExistsL( iClientContext.FileSession(),
-                                                   fileNameBuf->Des() );
-                    if ( file.Create( iClientContext.FileSession(),
-                                                    *fileNameBuf ,
-                                                    EFileWrite ) != KErrNone ) 
-                        {
-                        SetHttpCode( -EHttpNotFound );
-                        }
-                    else
-                        {
-                        SetDataSinkL( file );
-                        SetHttpCode( iClientContext.AuthorizeRequestL( *fileNameBuf, iSender ) );
-                        iFileName.Copy( *fileNameBuf );
-                        }
-                    }
-                CleanupStack::PopAndDestroy( fileNameBuf );
-                } 
-            else
-                {
-                SetHttpCode( -EHttpNotFound );
-                }
-            
-            break;
-            }
-        case EOnComplete:
-            break;    
-        default:
-            break;
-        }            
-    }
-
-void CUpnpHttpFileReceiveTransaction::InitializeFilterHeadersL()
-    {
-    //Copy current KHdrContentFeatures and KHdrTransferMode to filterHeaders
-    if ( QueryRequestHeader( UpnpDLNA::KHdrContentFeatures ).Length() > 0 )
-        {
-        iFilterHeaders->AddHeaderL( UpnpDLNA::KHdrContentFeatures,
-                QueryRequestHeader( UpnpDLNA::KHdrContentFeatures ) );            
-        }
-    if ( QueryRequestHeader( UpnpDLNA::KHdrTransferMode ).Length() > 0 )
-        {
-        iFilterHeaders->AddHeaderL( UpnpDLNA::KHdrTransferMode,
-                QueryRequestHeader( UpnpDLNA::KHdrTransferMode ) );            
-        }
-    }
-
+/** @file
+ * Copyright (c) 2009 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:  CUpnpHttpFileReceiveTransaction implementation.
+ *
+ */     
+
+#include <bautils.h> 
+#include "upnphttpfilereceivetransaction.h"
+#include "upnpdlnafilter.h"
+#include "upnpdlnafilterheaders.h"
+#include "upnperrors.h"
+#include "upnpcons.h"
+
+// ---------------------------------------------------------------------------
+// CUpnpHttpFileReceiveTransaction::NewL
+// 
+// ---------------------------------------------------------------------------
+//
+CUpnpHttpFileReceiveTransaction* CUpnpHttpFileReceiveTransaction::NewL( 
+        CUpnpDlnaFilter& aClientContext, const TInetAddr& aSender, const TDesC8& aUri )
+    {
+    CUpnpHttpFileReceiveTransaction* self = 
+        new (ELeave) CUpnpHttpFileReceiveTransaction( aClientContext );
+    CleanupStack::PushL( self );
+    self->ConstructL( aSender, aUri );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CUpnpHttpFileReceiveTransaction::ConstructL
+// 
+// ---------------------------------------------------------------------------
+//
+void CUpnpHttpFileReceiveTransaction::ConstructL( 
+    const TInetAddr& aSender, const TDesC8& aSenderUri )
+    {
+    iFilterHeaders = CUpnpDlnaFilterHeaders::NewL( );
+    iSender = aSender;
+    iSenderUri = aSenderUri.AllocL();
+    }
+
+// ---------------------------------------------------------------------------
+// CUpnpHttpFileReceiveTransaction::CUpnpHttpFileReceiveTransaction
+// 
+// ---------------------------------------------------------------------------
+//
+CUpnpHttpFileReceiveTransaction::CUpnpHttpFileReceiveTransaction(
+        CUpnpDlnaFilter& aClientContext ) :
+    iClientContext(aClientContext)
+    {
+    }
+        
+// ---------------------------------------------------------------------------
+// CUpnpHttpFileReceiveTransaction::~CUpnpHttpFileReceiveTransaction
+// 
+// ---------------------------------------------------------------------------
+//
+CUpnpHttpFileReceiveTransaction::~CUpnpHttpFileReceiveTransaction()
+    {
+    delete iFilterHeaders;
+    delete iSenderUri;
+    }
+
+// ---------------------------------------------------------------------------
+// CUpnpHttpFileReceiveTransaction::OnCallbackL
+// 
+// ---------------------------------------------------------------------------
+//    
+const TDesC8& CUpnpHttpFileReceiveTransaction::SenderUri()
+    {
+    return *iSenderUri;
+    }
+
+// ---------------------------------------------------------------------------
+// CUpnpHttpFileReceiveTransaction::FilterHeaders
+// 
+// ---------------------------------------------------------------------------
+//
+CUpnpDlnaFilterHeaders& CUpnpHttpFileReceiveTransaction::FilterHeaders()
+    {
+    return *iFilterHeaders;
+    }
+
+// ---------------------------------------------------------------------------
+// CUpnpHttpFileReceiveTransaction::OnCallbackL
+// 
+// ---------------------------------------------------------------------------
+//
+void CUpnpHttpFileReceiveTransaction::OnCallbackL( TUpnpHttpServerEvent aEvent )
+    {
+    TRAPD( err, DoCallbackL( aEvent ) );
+    if ( err )
+        {
+        SetHttpCode( err );
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// CUpnpHttpFileReceiveTransaction::DoCallbackL
+// 
+// ---------------------------------------------------------------------------
+//
+void CUpnpHttpFileReceiveTransaction::DoCallbackL( TUpnpHttpServerEvent aEvent )
+    {
+    switch ( aEvent )
+        {
+        case EOnRequestStart:
+            {
+            iFileName.Zero();
+            InitializeFilterHeadersL();
+            User::LeaveIfError(  iClientContext.CheckDLNAPostCorrelationsL(
+                                          *this ) );
+            
+            HBufC* fileNameBuf = iClientContext.DetermineDownloadPathL( *this );           
+            if ( fileNameBuf )
+                { 
+                CleanupStack::PushL( fileNameBuf );
+                
+                RFile file;
+                if ( file.Open( iClientContext.FileSession(),
+                                *fileNameBuf,
+                                EFileWrite ) == KErrNone ) 
+                    {
+                    SetDataSinkL( file );
+                    SetHttpCode( iClientContext.AuthorizeRequestL( *fileNameBuf, iSender ) );
+                    }
+                else
+                    {
+                    BaflUtils::EnsurePathExistsL( iClientContext.FileSession(),
+                                                   fileNameBuf->Des() );
+                    if ( file.Create( iClientContext.FileSession(),
+                                                    *fileNameBuf ,
+                                                    EFileWrite ) != KErrNone ) 
+                        {
+                        SetHttpCode( -EHttpNotFound );
+                        }
+                    else
+                        {
+                        SetDataSinkL( file );
+                        SetHttpCode( iClientContext.AuthorizeRequestL( *fileNameBuf, iSender ) );
+                        iFileName.Copy( *fileNameBuf );
+                        }
+                    }
+                CleanupStack::PopAndDestroy( fileNameBuf );
+                } 
+            else
+                {
+                SetHttpCode( -EHttpNotFound );
+                }
+            
+            break;
+            }
+        case EOnComplete:
+            break;    
+        default:
+            break;
+        }            
+    }
+
+void CUpnpHttpFileReceiveTransaction::InitializeFilterHeadersL()
+    {
+    //Copy current KHdrContentFeatures and KHdrTransferMode to filterHeaders
+    if ( QueryRequestHeader( UpnpDLNA::KHdrContentFeatures ).Length() > 0 )
+        {
+        iFilterHeaders->AddHeaderL( UpnpDLNA::KHdrContentFeatures,
+                QueryRequestHeader( UpnpDLNA::KHdrContentFeatures ) );            
+        }
+    if ( QueryRequestHeader( UpnpDLNA::KHdrTransferMode ).Length() > 0 )
+        {
+        iFilterHeaders->AddHeaderL( UpnpDLNA::KHdrTransferMode,
+                QueryRequestHeader( UpnpDLNA::KHdrTransferMode ) );            
+        }
+    }
+
--- a/upnpmediaserver/contentdirectoryservice/src/upnpattributebean.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnpattributebean.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,183 +1,183 @@
-/** @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:  Attribute table data handler
-*
-*/
-
-
-
-// INCLUDE FILES
-#include <xml/dom/xmlengdom.h>
-#include "upnpattributebean.h"
-#include "upnpcontentdirectoryglobals.h"
-#include <upnpattribute.h>
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::CUpnpAttributeBean
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CUpnpAttributeBean::CUpnpAttributeBean()
-{
-}
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CUpnpAttributeBean::ConstructL()
-{
-	iAtrValue = KNullString8().AllocL();
-}
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::NewLC
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpAttributeBean* CUpnpAttributeBean::NewLC()
-{
-    CUpnpAttributeBean* self = new( ELeave ) CUpnpAttributeBean;
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-}
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::NewLC
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpAttributeBean* CUpnpAttributeBean::NewLC(const RDbRowSet& aRowSet)
-{
-    CUpnpAttributeBean* self = NewLC();
-    self->SetL(aRowSet);
-    return self;
-}    
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::~CUpnpAttributeBean
-// Destructor
-// -----------------------------------------------------------------------------
-// 
-CUpnpAttributeBean::~CUpnpAttributeBean()
-{
-    delete iAtrName;
-    delete iAtrValue;
-}
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::SetL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpAttributeBean::SetL(const RDbRowSet& aRowSet)
-{
-    // get cols' ids
-    CDbColSet* colSet = aRowSet.ColSetL();
-    CleanupStack::PushL(colSet);
-    const TInt  idColNo         = colSet->ColNo(KAtrIdColName);
-    const TInt  nameColNo       = colSet->ColNo(KAtrNameColName);
-    const TInt  elmIdColNo      = colSet->ColNo(KAtrElmIdColName);
-    const TInt  isRequiredColNo = colSet->ColNo(KAtrIsRequiredColName);
-    const TInt  valueColNo      = colSet->ColNo(KAtrValueColName);
-    CleanupStack::PopAndDestroy(colSet);
-    
-    // for each column call setter
-    if( idColNo != KDbNullColNo )
-    {
-        SetAtrId( aRowSet.ColInt(idColNo) );
-    }
-    if( nameColNo != KDbNullColNo )
-    {
-        SetAtrNameL( aRowSet.ColDes8(nameColNo) );
-    }
-    if( elmIdColNo != KDbNullColNo )
-    {
-        SetAtrElmId( aRowSet.ColInt(elmIdColNo) );
-    }
-    if( isRequiredColNo != KDbNullColNo )
-    {
-        SetAtrIsRequired( aRowSet.ColUint8(isRequiredColNo) );
-    }
-    if( valueColNo != KDbNullColNo )
-    {
-        SetAtrValueL( aRowSet, valueColNo );
-    }
-}
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::SetAtrValueL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpAttributeBean::SetAtrValueL(const RDbRowSet& aRowSet, const TInt aColNo)
-{
-    delete iAtrValue;
-    iAtrValue = 0;
-    iAtrValue = ReadLongTextColL(aRowSet, aColNo);
-}
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::SetAtrValueL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpAttributeBean::SetAtrValueL(const TDesC8& aVal)
-{
-	delete iAtrValue;
-	iAtrValue = 0;
-	iAtrValue = aVal.AllocL();
-}
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::SetAtrNameL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpAttributeBean::SetAtrNameL(const TDesC8& aAtrName)
-{
-    delete iAtrName;
-    iAtrName = NULL;
-    iAtrName = aAtrName.AllocL();
-}
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::AttachToXmlElL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TXmlEngAttr CUpnpAttributeBean::AttachAttrL(TXmlEngElement aElement)
-{
-    // add attribute
-    TXmlEngAttr ret = aElement.AddNewAttributeL( AtrName(), AtrValue() );
-
-     return ret;
-}
-// -----------------------------------------------------------------------------
-// CUpnpAttributeBean::CopyToUpnpElementL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpAttributeBean::AttachAttrL(CUpnpElement* aElm)
-{
-    // create element
-    CUpnpAttribute* atr = CUpnpAttribute::NewLC(*iAtrName);
-	
-	// copy values
-	atr->SetValueL(*iAtrValue);
-	
-	// attach
-	aElm->AddAttributeL(atr);
-	
-	// clean up
-	CleanupStack::Pop(atr);
-}
-
-//  End of File  
+/** @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:  Attribute table data handler
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <xmlengdom.h>
+#include "upnpattributebean.h"
+#include "upnpcontentdirectoryglobals.h"
+#include <upnpattribute.h>
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::CUpnpAttributeBean
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUpnpAttributeBean::CUpnpAttributeBean()
+{
+}
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUpnpAttributeBean::ConstructL()
+{
+	iAtrValue = KNullString8().AllocL();
+}
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpAttributeBean* CUpnpAttributeBean::NewLC()
+{
+    CUpnpAttributeBean* self = new( ELeave ) CUpnpAttributeBean;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+}
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpAttributeBean* CUpnpAttributeBean::NewLC(const RDbRowSet& aRowSet)
+{
+    CUpnpAttributeBean* self = NewLC();
+    self->SetL(aRowSet);
+    return self;
+}    
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::~CUpnpAttributeBean
+// Destructor
+// -----------------------------------------------------------------------------
+// 
+CUpnpAttributeBean::~CUpnpAttributeBean()
+{
+    delete iAtrName;
+    delete iAtrValue;
+}
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::SetL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpAttributeBean::SetL(const RDbRowSet& aRowSet)
+{
+    // get cols' ids
+    CDbColSet* colSet = aRowSet.ColSetL();
+    CleanupStack::PushL(colSet);
+    const TInt  idColNo         = colSet->ColNo(KAtrIdColName);
+    const TInt  nameColNo       = colSet->ColNo(KAtrNameColName);
+    const TInt  elmIdColNo      = colSet->ColNo(KAtrElmIdColName);
+    const TInt  isRequiredColNo = colSet->ColNo(KAtrIsRequiredColName);
+    const TInt  valueColNo      = colSet->ColNo(KAtrValueColName);
+    CleanupStack::PopAndDestroy(colSet);
+    
+    // for each column call setter
+    if( idColNo != KDbNullColNo )
+    {
+        SetAtrId( aRowSet.ColInt(idColNo) );
+    }
+    if( nameColNo != KDbNullColNo )
+    {
+        SetAtrNameL( aRowSet.ColDes8(nameColNo) );
+    }
+    if( elmIdColNo != KDbNullColNo )
+    {
+        SetAtrElmId( aRowSet.ColInt(elmIdColNo) );
+    }
+    if( isRequiredColNo != KDbNullColNo )
+    {
+        SetAtrIsRequired( aRowSet.ColUint8(isRequiredColNo) );
+    }
+    if( valueColNo != KDbNullColNo )
+    {
+        SetAtrValueL( aRowSet, valueColNo );
+    }
+}
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::SetAtrValueL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpAttributeBean::SetAtrValueL(const RDbRowSet& aRowSet, const TInt aColNo)
+{
+    delete iAtrValue;
+    iAtrValue = 0;
+    iAtrValue = ReadLongTextColL(aRowSet, aColNo);
+}
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::SetAtrValueL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpAttributeBean::SetAtrValueL(const TDesC8& aVal)
+{
+	delete iAtrValue;
+	iAtrValue = 0;
+	iAtrValue = aVal.AllocL();
+}
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::SetAtrNameL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpAttributeBean::SetAtrNameL(const TDesC8& aAtrName)
+{
+    delete iAtrName;
+    iAtrName = NULL;
+    iAtrName = aAtrName.AllocL();
+}
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::AttachToXmlElL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TXmlEngAttr CUpnpAttributeBean::AttachAttrL(TXmlEngElement aElement)
+{
+    // add attribute
+    TXmlEngAttr ret = aElement.AddNewAttributeL( AtrName(), AtrValue() );
+
+     return ret;
+}
+// -----------------------------------------------------------------------------
+// CUpnpAttributeBean::CopyToUpnpElementL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpAttributeBean::AttachAttrL(CUpnpElement* aElm)
+{
+    // create element
+    CUpnpAttribute* atr = CUpnpAttribute::NewLC(*iAtrName);
+	
+	// copy values
+	atr->SetValueL(*iAtrValue);
+	
+	// attach
+	aElm->AddAttributeL(atr);
+	
+	// clean up
+	CleanupStack::Pop(atr);
+}
+
+//  End of File  
--- a/upnpmediaserver/contentdirectoryservice/src/upnpcdutils.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnpcdutils.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1037 +1,1049 @@
-/** @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:  ContentDirectory utils
-*
-*/
-
-
-
-// INCLUDE FILES
-#include <uri8.h>
-#include "upnpcdutils.h"
-#include "upnpcontentdirectoryglobals.h"
-#include "upnpdominterface.h"
-#include "upnperror.h"
-#include "upnpcommonupnplits.h"
-#include "upnpstring.h"
-#include "upnpcons.h"
-#include <utf.h>
-#include <xml/dom/xmlengdocument.h>
-#include <e32math.h>
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::RemoveWhiteSpacesL
-// -----------------------------------------------------------------------------
-//
-void UpnpCdUtils::RemoveWhiteSpacesL(TDes8& aString)
-{
-    for(TInt i=0; i<aString.Length(); i++)
-    {
-        if(    aString[i] == ' '
-           ||  aString[i] == '\r'
-           ||  aString[i] == '\n'
-           ||  aString[i] == '\t')
-        {
-            aString.Replace(i,1,_L8(""));
-            i--;
-        }
-    }
-}
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::IsWhiteString
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TBool UpnpCdUtils::IsWhiteString(const TDesC8& aString)
-{
-    TBool ret = ETrue;
-    for(TInt i = 0; i < aString.Length(); i++)
-    {
-        if( !(  aString[i] == '\n' ||
-                aString[i] == '\r' ||
-                aString[i] == ' '  ||
-                aString[i] == '\t' )  ) 
-        {
-            ret = EFalse;
-            break;
-        }
-    }
-    return ret;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::GetObjectElementL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TXmlEngElement UpnpCdUtils::GetObjectElementL(RXmlEngDocument& aFragment)
-{
-    TXmlEngElement element;
-    // try to get container
-    UpnpDomInterface::GetElementL( aFragment.DocumentElement(), element, KContainer );
-    if(element.IsNull())
-    { // this is not a container
-        // try to get an item
-        UpnpDomInterface::GetElementL( aFragment.DocumentElement(), element, KItem );
-        if(element.IsNull())
-        { // this is neither an item - error
-            User::Leave(EInvalidArgs);
-        }
-    }
-    return element;
-}
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::HasRefIdL
-// -----------------------------------------------------------------------------
-//
-TBool UpnpCdUtils::HasRefIdL( RXmlEngDocument& aFragment )
-    {
-    TXmlEngElement object = UpnpCdUtils::GetObjectElementL( aFragment );
-    //reference id value
-    TPtrC8 refID = UpnpDomInterface::GetAttrValueL( object, KRefID );
-    return !refID.CompareF( KNullDesC8 ) ? EFalse : ETrue;
-    }
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::EncodeXmlStringL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC8* UpnpCdUtils::EncodeXmlStringL(const TDesC8& aString)
-{
-    // new buffer size 
-    TInt extensionSize = 0;
-    for(TInt i = 0; i < aString.Length(); i++)
-    {
-        if(aString[i] == '&')       extensionSize += KEtAmp().Length() - 1;
-        else if(aString[i] == '<')  extensionSize += KEtlt().Length() - 1;
-        else if(aString[i] == '>')  extensionSize += KEtgt().Length() - 1;
-        else if(aString[i] == '\"') extensionSize += KEtQuot().Length() - 1;
-        else if(aString[i] == '\'') extensionSize += KEtApos().Length() - 1;
-    }
-    
-    // alloc new buffer
-    HBufC8* ret = HBufC8::NewLC(aString.Length() + extensionSize);
-    TPtr8 retPtr(ret->Des());
-    retPtr.Copy(aString);
-    
-    // replace
-    for(TInt i = 0; i < retPtr.Length(); i++)
-    {
-        if(retPtr[i] == '&')        retPtr.Replace(i, 1, KEtAmp);
-        else if(retPtr[i] == '<')   retPtr.Replace(i, 1, KEtlt);
-        else if(retPtr[i] == '>')   retPtr.Replace(i, 1, KEtgt);
-        else if(retPtr[i] == '\"')  retPtr.Replace(i, 1, KEtQuot);
-        else if(retPtr[i] == '\'')  retPtr.Replace(i, 1, KEtApos);
-    }
-    
-    // clean up
-    CleanupStack::Pop(ret);
-    
-    return ret; 
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::ReplaceTrueFalse
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void UpnpCdUtils::ReplaceTrueFalse(HBufC8* aBuf)
-{
-    TPtr8 ptr(aBuf->Des());
-    TInt pos;
-    // false -> 0
-    pos = ptr.FindC(KFalseString8);
-    if (pos != KErrNotFound)
-    {
-        ptr.Replace(pos, KFalseString8().Length(), KFalseValue8);
-    }
-    // true -> 1
-    pos = ptr.FindC(KTrueString8);
-    if (pos != KErrNotFound)
-    {
-        ptr.Replace(pos, KTrueString8().Length(), KTrueValue8);
-    }
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::GetElmNameWithNsL
-// -----------------------------------------------------------------------------
-//
-HBufC8* UpnpCdUtils::GetElmNameWithNsL(TXmlEngElement aElement)
-{
-    TPtrC8 elmName( aElement.Name() );
-    HBufC8* ret = NULL;
-    if( aElement.NamespaceDeclaration().Prefix().Length() )
-    {
-        TPtrC8 prefix( aElement.NamespaceDeclaration().Prefix() );
-        ret = HBufC8::NewL(elmName.Length() + prefix.Length() + 1);
-        TPtr8 ptr(ret->Des());
-        
-        // concatenate prefix and name
-        ptr.Copy(prefix);
-        ptr.Append(KCol);
-        ptr.Append(elmName);
-    }
-    else
-    {
-        ret = elmName.AllocL();
-    }
-    
-    return ret; // the caller should delete it
-}
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::Des8ToDesL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC* UpnpCdUtils::Des8ToDesL(const TDesC8& aString)
-{
-    HBufC* ret = Des8ToDesLC(aString);
-    CleanupStack::Pop(ret);
-    return ret;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::Des8ToDesLC
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC* UpnpCdUtils::Des8ToDesLC(const TDesC8& aString)
-{    
-    HBufC* ret = UpnpString::ToUnicodeL(aString);
-    CleanupStack::PushL(ret);
-    return ret;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::DesToDes8LC
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC8* UpnpCdUtils::DesToDes8LC(const TDesC& aString)
-{
-    HBufC8* ret = UpnpString::FromUnicodeL(aString);
-    CleanupStack::PushL(ret);
-    return ret;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::ResIdFromUriL
-// -----------------------------------------------------------------------------
-//
-TInt64 UpnpCdUtils::ResIdFromUriL(const TDesC8& aUri)
-{
-    TUriParser8 up;
-    User::LeaveIfError(up.Parse(aUri));
-    TPtrC8 path(up.Extract(EUriPath));
-    if (path.Length() == 0)
-    {
-    User::Leave(KErrNotFound);
-    }
-    
-    if(path[0] == '/')
-    {
-        path.Set(path.Mid(1));
-    }
-    TInt index = path.Locate(TChar('/'));
-    
-    if ((index>0)&&(index != KMaxIDResLength))
-    {
-    	User::Leave(KErrNotFound);    
-    }
-    TLex8 lexer(path);
-    TInt64 ret;
-    User::LeaveIfError(lexer.Val(ret));
-    return ret;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::ResIdFromUriL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TPtrC8 UpnpCdUtils::ResIdFromUriDesL(const TDesC8& aUri)
-{
-    TUriParser8 up;
-    User::LeaveIfError(up.Parse(aUri));
-    TPtrC8 path(up.Extract(EUriPath));
-    if (path.Length() == 0)
-    {
-    User::Leave(KErrNotFound);
-    }
-    
-    if(path[0] == '/')
-    {
-        path.Set(path.Mid(1));
-    }
-    
-    TInt index = path.Locate(TChar('/'));
-    
-    if (index > 0)       
-    {
-        path.Set(path.Left(index));        
-    }
-    
-    return path;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::SetObjectIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void UpnpCdUtils::SetObjectIdL(TXmlEngElement aElement, TInt aId)
-{
-    TXmlEngAttr idAttr = aElement.AttributeNodeL(KIdAttrName());
-    TBuf8<KMaxIntegerLen> idVal;
-    idVal.Num(aId);
-    if(idAttr.NotNull())
-    {
-        idAttr.SetValueL(idVal);
-    }
-    else
-    {
-        aElement.AddNewAttributeL(KIdAttrName(), idVal);
-    }
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::SetObjectRefIdL
-// -----------------------------------------------------------------------------
-//
-void UpnpCdUtils::SetObjectRefIdL(TXmlEngElement aElement, TInt aRefId)
-{
-    TXmlEngAttr refIdAttr = aElement.AttributeNodeL( KRefID() );
-    TBuf8<KMaxIntegerLen> refIdVal;
-    refIdVal.Num( aRefId );
-    if( refIdAttr.NotNull() )
-        {
-        refIdAttr.SetValueL( refIdVal );
-        }
-    else
-        {
-        aElement.AddNewAttributeL( KRefID(), refIdVal );
-        }
-}
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::SetObjectParentIdL
-// -----------------------------------------------------------------------------
-//
-void UpnpCdUtils::SetObjectParentIdL(TXmlEngElement aElement, TInt aParentId)
-{
-    TXmlEngAttr parentIdAttr = aElement.AttributeNodeL( KParentID() );
-    TBuf8<KMaxIntegerLen> parentIdVal;
-    parentIdVal.Num( aParentId );
-    if( parentIdAttr.NotNull() )
-        {
-        parentIdAttr.SetValueL( parentIdVal );
-        }
-    else
-        {
-        aElement.AddNewAttributeL( KParentID(), parentIdVal );
-        }
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::SetRestrictedFieldL
-// -----------------------------------------------------------------------------
-//
-void UpnpCdUtils::SetRestrictedFieldL(TXmlEngElement aElement, TBool aRestrictedFlag)
-{
-    TXmlEngAttr restrictedField = aElement.AttributeNodeL( KRestricted() );    
-    TBuf8<KMaxIntegerLen> restrictedVal;
-    
-    if( aRestrictedFlag )
-        {
-        restrictedVal.Copy( KTrueValue8 );
-        }    
-    else
-        {
-        restrictedVal.Copy( KFalseValue8 );
-        }    
-
-    if( restrictedField.NotNull() )
-        {
-        restrictedField.SetValueL( restrictedVal );
-        }
-    else
-        {
-        aElement.AddNewAttributeL( KRestricted(), restrictedVal );
-        }
-}
-
-// UpnpCdUtils::SetObjectIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void UpnpCdUtils::SetContainerIdL(TXmlEngElement aElement, TInt aParentId)
-{
-    TXmlEngAttr idAttr = aElement.AttributeNodeL(KParentID());
-    TBuf8<KMaxIntegerLen> idVal;
-    idVal.Num(aParentId);
-    if(idAttr.NotNull())
-    {
-        idAttr.SetValueL(idVal);
-    }
-    else
-    {
-        aElement.AddNewAttributeL(KParentID(), idVal);
-    }
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::IsElementRequiredL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TBool UpnpCdUtils::IsElementRequiredL(TXmlEngElement aElement)
-{
-    TBool ret = EFalse;
-    TXmlEngAttr reqAttr = aElement.AttributeNodeL( KRequiredAtrName() );
-    if(reqAttr.NotNull())
-    { // element required
-        ret = ETrue;
-        reqAttr.Remove();
-    }   
-    return ret;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::BuildImportUriL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-HBufC8* UpnpCdUtils::BuildImportUriLC(TInt aResId)
-{
-	// get next resId
-	TBuf8<KMaxIntegerLen + KRandomRangeLength> num;
-	TBuf8<KMaxIntegerLen + KRandomRangeLength> uriId;
-	num.Num(aResId);
-	uriId.Justify(num, KMaxIntegerLen + KRandomRangeLength, ERight, '0');
-
-	// build uri
-	HBufC8* impUri = HBufC8::NewLC(
-						  KHttpTag().Length()
-						+ KIpPortPlaceholder8().Length()						
-						+ KSlash8().Length()						
-						+ KMaxLongIntegerLen
-						+ KRandomRangeLength );
-	TPtr8 impUriPtr(impUri->Des());
-	impUriPtr.Append(KHttpTag);
-	impUriPtr.Append(KIpPortPlaceholder8);
-	impUriPtr.Append(KSlash8);		
-	impUriPtr.Append(uriId);
-	
-	
-	return impUri;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::BuildImportUriL
-// -----------------------------------------------------------------------------
-HBufC8* UpnpCdUtils::BuildImportUriShorterLC(TInt64 aResId)
-{
-	// get next resId
-	TBuf8<KMaxIntegerLen > num;
-	TBuf8<KMaxIntegerLen > uriId;
-	num.Num(aResId);
-	uriId.Justify(num, KMaxIntegerLen , ERight, '0');
-
-	// build uri
-	HBufC8* impUri = HBufC8::NewLC(
-						  KHttpTag().Length()
-						+ KIpPortPlaceholder8().Length()						
-						+ KSlash8().Length()						
-						+ KMaxLongIntegerLen
-						 );
-	TPtr8 impUriPtr(impUri->Des());
-	impUriPtr.Append(KHttpTag);
-	impUriPtr.Append(KIpPortPlaceholder8);
-	impUriPtr.Append(KSlash8);		
-	impUriPtr.Append(uriId);
-	
-	
-	return impUri;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::BuildContentUriL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-HBufC8* UpnpCdUtils::BuildContentUriL(TInt aResId, const TDesC& aFileExten,
-                                           TDesC8& aObjectId)
-{
-    HBufC8* number = UpnpCdUtils::RandomizeL(KRandomMax);
-    CleanupStack::PushL(number);
-    HBufC8* number2 = UpnpCdUtils::RandomizeL(KRandomMax);
-    CleanupStack::PushL(number2);
-    
-	HBufC8* impUri = BuildImportUriShorterLC(aResId);	
-	
-    HBufC8* fileExten8 = UpnpCdUtils::DesToDes8LC(aFileExten);
-	HBufC8* contUri = HBufC8::NewLC(
-								impUri->Length() 
-								+ number->Des().Length()
-								+ number2->Des().Length()
-								+ KSlash().Length()
-                                + aObjectId.Length()                                
-                                + fileExten8->Length());
-	TPtr8 contUriPtr(contUri->Des());
-	contUriPtr.Copy(*impUri);
-	contUriPtr.Append(*number);	
-	contUriPtr.Append(*number2);
-	contUriPtr.Append(KSlash);
-    contUriPtr.Append(aObjectId);    
-    contUriPtr.Append(*fileExten8);
-
-    // clean up
-	CleanupStack::Pop(contUri);
-    CleanupStack::PopAndDestroy(fileExten8);
-	CleanupStack::PopAndDestroy(impUri);
-	CleanupStack::PopAndDestroy(number2);
-	CleanupStack::PopAndDestroy(number);
-	return contUri;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::RandomizeL
-// -----------------------------------------------------------------------------
-HBufC8* UpnpCdUtils::RandomizeL(TInt aRange)
-{
-    TUint number = Math::Random();
-    number = number % aRange;    
-    HBufC8* numberDes = HBufC8::NewL(KRandomRangeLength);               
-   	TBuf8<KRandomRangeLength> num;	
-	num.Num(number);
-    numberDes->Des().Justify(num, KRandomRangeLength, ERight, '0');    
-
-    return numberDes;
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::ValidateFilePath
-// -----------------------------------------------------------------------------
-void UpnpCdUtils::ValidateFilePath(TDes8& aPath)
-{
-    // replace
-    for(TInt i = 0; i < aPath.Length(); i++)
-    {
-        if( aPath[i] == ':' && i!=1 || 
-            aPath[i] == '<'         ||
-            aPath[i] == '>'         ||
-            aPath[i] == '\"'        ||
-            aPath[i] == '/'         ||    
-            aPath[i] == '|'         ||
-            aPath[i] == '*'       ||
-            aPath[i] == '?'
-          )
-        {
-            aPath[i] = '_';
-        }
-    }
-}
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::ValidateFilePath
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-void UpnpCdUtils::ValidateFilePath(TDes& aPath)
-{
-    // replace
-    for(TInt i = 0; i < aPath.Length(); i++)
-    {
-        if( aPath[i] == ':' && i!=1 || 
-            aPath[i] == '<'         ||
-            aPath[i] == '>'         ||
-            aPath[i] == '\"'        ||
-            aPath[i] == '/'         ||    
-            aPath[i] == '|'         ||
-            aPath[i] == '*'       ||
-            aPath[i] == '?'
-          )
-        {
-            aPath[i] = '_';
-        }
-    }
-}
-
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::ValidateSrcUriL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-void UpnpCdUtils::ValidateSrcUriL(TDesC8& aPath,TDesC8& aIp )
-{
-    // Check if parsing is correct
-    TUriParser8 srcParser;
-    if (!(srcParser.Parse(aPath) == KErrNone))
-    {
-        User::Leave( ENoSourceResource );                        
-    }
-    
-    // check if source uri is correct one
-    TInt pos = aPath.Find(aIp);
-    if(pos != UpnpHTTP::KHTTPUrl().Length())
-        {
-        User::Leave( ENoSourceResource ); 
-        }
-
-    if (!(aPath.Find( UpnpHTTP::KHTTPUrl ) == 0))
-    {
-        User::Leave( ENoSourceResource );                        
-    }
-    TInt len = UpnpHTTP::KHTTPUrl().Length() + aIp.Length();
-    if ( aPath.Length() <= len || aPath[ len ] != '/' )
-        {
-        User::Leave( ENoSourceResource );
-        }
-}
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::EscapeAposL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-HBufC* UpnpCdUtils::EscapeAposL(const TDesC&  aValue)
-{
-    if (aValue.Length())
-    {            
-        HBufC8* value8 = DesToDes8LC(aValue);
-        HBufC8* valueReplaced8 = UpnpString::StringReplaceL(*value8,_L8("'"),_L8("\'\'"));
-        CleanupStack::Pop(value8);
-        HBufC* valueReplaced16 = UpnpCdUtils::Des8ToDesL(*valueReplaced8);
-        delete valueReplaced8;
-        delete value8;        
-        return valueReplaced16;
-    }
-    else
-    {
-        HBufC* valueReplaced16 = aValue.AllocL();
-        return valueReplaced16;
-    }   
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidateDateL()
-// Only Those date string is validate
-// YYYY-MM-DD
-// YYYY-MM-DDTHH:MM:SS
-// YYYY-MM-DDTHH:MM:SSZ
-// YYYY-MM-DDTHH:MM:SS.xxx
-// YYYY-MM-DDTHH:MM:SS.xxxZ
-// YYYY-MM-DDTHH:MM:SS+HH:MM
-// YYYY-MM-DDTHH:MM:SS.xxx+HH:MM
-// -----------------------------------------------------------------------------
-//
-TBool UpnpCdUtils::ValidateDateL( TPtrC8 aValue )
-    {         
- /*   TBool wrong = 0;
-
-    TInt dateLength = aValue.Length();                                         
-
-    if ((dateLength!=EDay)&&(dateLength!=ESecond)&&
-        (dateLength!=ETimeOffset1)&&(dateLength!=EMiliSecond)&&
-        (dateLength!=ETimeOffset2)&&(dateLength!=EZone1)&&
-        (dateLength!=EZone2))                                     
-        {
-        return EFalse;                
-        }
-    else
-        {
-        const TChar KColo = ':';
-        const TChar KMinus = '-';
-        const TChar KPlus = '+';
-        const TChar KDot = '.';       
-        const TChar KT = 'T';
-        const TChar KZ = 'Z'; 
-
-        TChar ch;
-        TLex8 input(aValue);         
-        for (TInt i =0; i<aValue.Length();i++)
-            {
-            ch = input.Get();         
-            if ((i!=EYear)&&(i!=EMonth)&&(i!=EDay)&&(i!=EHour)&&(i!=EMinute)&&(i!=ESecond)&&(i!=EHourOffset1)&&(i!=EMiliSecond)&&(i!=EHourOffset2))
-                {                
-                if (!ch.IsDigit())          
-                    {
-                    wrong = ETrue;
-                    break;  
-                    }
-                }
-            else if (((i==EYear)||(i==EMonth))&&(ch!=KMinus))
-                {
-                wrong = ETrue;
-                break;  
-                }    
-            else if ((i==EDay)&&(ch!= KT))
-                {
-                wrong = ETrue;
-                break;  
-                }     
-            else if (((i==EHour)||(i==EMinute)||(i==EHourOffset2))&&(ch!=KColo))
-                {
-                wrong = ETrue;
-                break;  
-                }     
-            else if (((i==ESecond)&&(dateLength==ETimeOffset1))&&((ch!=KPlus)&&(ch!=KMinus)))
-                {
-                wrong = ETrue;
-                break;  
-                }    
-            else if (((i==ESecond)&&(dateLength==EZone1))&&(ch!=KZ))
-                {
-                wrong = ETrue;
-                break;  
-                }
-            else if (((i==ESecond)&&((dateLength==ETimeOffset2)||(dateLength==EZone2)||(dateLength==EMiliSecond)))&&(ch!=KDot))
-                {
-                wrong = ETrue;
-                break;  
-                }              
-            else if (((i==EHourOffset1)&&(dateLength==ETimeOffset1))&&(ch!=KColo))
-                {
-                wrong = ETrue;
-                break;  
-                }   
-                                
-            else if ((i==EHourOffset1)&&((dateLength==ETimeOffset2)||(dateLength==EZone2)||(dateLength==EMiliSecond)))
-                {                    
-                if (!ch.IsDigit())          
-                    {
-                    wrong = ETrue;
-                    break;  
-                    }
-                }
-            else if (((i==EMiliSecond)&&(dateLength==ETimeOffset2))&&((ch!=KPlus)&&(ch!=KMinus)))
-                {
-                wrong = ETrue;
-                break;  
-                }            
-            else if (((i==EMiliSecond)&&(dateLength==EZone2))&&(ch!=KZ))
-                {
-                wrong = ETrue;
-                break;  
-                }      
-            else if ((i==EMiliSecond)&&(dateLength==ETimeOffset1))
-                {                
-                if (!ch.IsDigit())          
-                    {
-                    wrong = ETrue;
-                    break;  
-                    }                               
-                }
-            }
-        }
-            
-        TInt yearInt=0;
-        TInt monthInt=0;
-        TInt dayInt=0;
-        TInt hourInt=0;
-        TInt minuteInt=0;
-        TInt secondInt=0;
-        TInt milisecondInt=0;
-        TInt hhInt=0;
-        TInt mmInt=0;
-        TDateTime a;
-
-        TPtrC8 yearPtrC = aValue.Left(4);
-        TPtrC8 tmp = aValue.Mid(5);
-        TPtrC8 monthPtrC = tmp.Left(2);
-        tmp.Set(aValue.Mid(8));
-        TPtrC8 dayPtrC = tmp.Left(2);
-
-        TLex8 lexer(yearPtrC);	
-        lexer.Val(yearInt);
-        lexer.Assign(monthPtrC);
-        lexer.Val(monthInt);
-        monthInt--;
-        TMonth monthEnum = (TMonth)monthInt;
-        lexer.Assign(dayPtrC);
-        lexer.Val(dayInt);
-
-        if (dateLength>EDay)                
-            {
-            tmp.Set(aValue.Mid(11));
-            TPtrC8 hourPtrC = tmp.Left(2);
-            tmp.Set(aValue.Mid(14));
-            TPtrC8 minutePtrC = tmp.Left(2);
-            tmp.Set(aValue.Mid(17));
-            TPtrC8 secondPtrC = tmp.Left(2);  
-            lexer.Assign(hourPtrC);
-            lexer.Val(hourInt);
-            lexer.Assign(minutePtrC);
-            lexer.Val(minuteInt);
-            lexer.Assign(secondPtrC);
-            lexer.Val(secondInt);  
-            }                
-        if ((dateLength==ETimeOffset2)||(dateLength==EZone2)||(dateLength==EMiliSecond))
-            {
-            tmp.Set(aValue.Mid(20)); 
-            TPtrC8 milisecondPtrC = tmp.Left(3);  
-            lexer.Assign(milisecondPtrC);
-            lexer.Val(milisecondInt);
-            }
-        if (dateLength==ETimeOffset1)
-            {
-            tmp.Set(aValue.Mid(20)); 
-            TPtrC8 hhOffset = tmp.Left(2);
-            tmp.Set(aValue.Mid(23)); 
-            TPtrC8 mmOffset = tmp.Left(2);      
-            lexer.Assign(hhOffset);
-            lexer.Val(hhInt);
-            
-            if (hhInt>12) 
-                {
-                wrong = ETrue;                
-                }
-            
-            lexer.Assign(mmOffset);
-            lexer.Val(mmInt);     
-            
-            if (mmInt>59) 
-                {
-                wrong = ETrue;   
-                }
-            }
-            
-        if (dateLength==ETimeOffset2)
-            {
-            tmp.Set(aValue.Mid(24)); 
-            TPtrC8 hhOffset = tmp.Left(2);
-            tmp.Set(aValue.Mid(27)); 
-            TPtrC8 mmOffset = tmp.Left(2);     
-            lexer.Assign(hhOffset);
-            lexer.Val(hhInt);
-            if (hhInt>12) 
-                {
-                wrong = ETrue;                
-                }
-            lexer.Assign(mmOffset);
-            lexer.Val(mmInt); 
-                
-            if (mmInt>59) 
-                {
-                wrong = ETrue;                
-                }
-            }
-            
-        TInt err = a.Set(yearInt,monthEnum,dayInt,hourInt,minuteInt,secondInt,milisecondInt);
-        if (err<0) 
-            {
-            wrong = ETrue;    
-            }
-
-    if (wrong)
-        {                        
-        return EFalse;      
-        }
-*/
-    return ETrue;
-    }
-    
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::StringToUint
-// -----------------------------------------------------------------------------
-    TInt UpnpCdUtils::StringToTUint(const TDesC8& aStr, TUint* aInt)
-	{
-	if( 0 == aStr.Length() || aInt == NULL)
-		{
-		return KErrArgument;
-		}
-	TLex8 lex( aStr );
-	return lex.Val( *aInt );
-	}                   
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::SplitStringByDelimeter
-// -----------------------------------------------------------------------------
-void UpnpCdUtils::SplitStringByDelimeter(TLex8& aLexeme, TChar aDelimeter)
-{
-	aLexeme.Mark(); 
-	while( (aLexeme.Peek() != aDelimeter) && (!aLexeme.Eos()) )
-	{
-		aLexeme.Inc();		
-	}
-}
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::Skip
-// -----------------------------------------------------------------------------
-void UpnpCdUtils::Skip(TLex8& aLexer, TInt aValue)
-{
-    if(!aLexer.Eos())
-	{
-	    aLexer.Inc(aValue);
-	}
-}	
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::AreDigitsInSpecificRange
-// -----------------------------------------------------------------------------    
-TBool UpnpCdUtils::AreDigitsInSpecificRange(const TDesC8& aInput, TInt aNumber, TBool aExactDigitsNumber, TUint32 aRange)
-{
-    // checking length
-    TInt length = aInput.Length();
-    
-    if(aExactDigitsNumber)
-    {
-        // if exact number of digits = real number of digits -> ok
-        if(length != aNumber) 
-            return EFalse;
-    }
-    else
-    {
-        // if real number of digits fit into specific range -> ok
-        if(length > aNumber || length < 1)
-            return EFalse;
-    }
-    
-    // checking digits
-    for(TInt i=0; i < length; i++)
-    {
-        // if input characters are all digits -> ok
-        TChar tmp( aInput[i] );       
-        if( !tmp.IsDigit() )
-            return EFalse;            
-    }
-    
-    // checking range
-    TLex8 field(aInput);	        
-    TUint32 value;
-    
-    // if e.g minutes fit into range: 00-59 -> ok
-    TInt err = field.BoundedVal(value, EDecimal, aRange);
-    
-    if(err != KErrNone)
-        return EFalse;
-    
-    return ETrue;
-}    
-
-// -----------------------------------------------------------------------------
-// UpnpCdUtils::ValidateDurationValueL
-// -----------------------------------------------------------------------------
-TBool UpnpCdUtils::ValidateDurationValue(const TDesC8& aInput)
-{
-	/*
-	* 7.3.22 MM DIDL-Lite res@duration Format
-	* Requirement [7.3.22.1]: The syntax of the res@duration must be compliant to the following definition:
-	*    - duration = hours ":" minutes ":" seconds
-	*    - hours = 1*5 DIGIT; 0-99999
-	*    - minutes = 2 DIGIT ; 00-59
-	*    - seconds = 2 DIGIT ["." 3 DIGIT] ; 00-59 (.000-.999)
-	*/
-    TChar KColon(':');
-    TChar KDot('.');
-
-    TInt fieldNum = 1;        
-    TLex8 input(aInput);
-		
-	while( !input.Eos() )
-	{		
-	    // extract subsequent field
-		SplitStringByDelimeter( input, KColon );
-		TPtrC8 field( input.MarkedToken() );
-		
-		// if its length != 0 ...
-		if( field != KNullDesC8() )
-		{		
-		    if(fieldNum == 1)
-		    {	
-		        // if 1st field = 1-5 digits in range: 0-99999 -> ok
-		        if( !AreDigitsInSpecificRange(field, 5, EFalse, 99999) )
-		            return EFalse;
-		            
-		        ++fieldNum;
-		    }
-		    else if(fieldNum == 2)
-		    {
-		        // if 2nd field = exactly 2 digits in range: 0-59 -> ok
-		        if( !AreDigitsInSpecificRange(field, 2, ETrue, 59) )
-		            return EFalse;
-		        
-		        ++fieldNum;
-		    }		    
-		    else if(fieldNum == 3)
-		    {
-		        TInt length = field.Length();
-		    
-		        TLex8 fourth(field);		        		        
-		        SplitStringByDelimeter( fourth, KDot );
-		        
-		        // if 3rd field = exactly 2 digits in range: 0-59 -> ok
-		        TPtrC8 leftPart( fourth.MarkedToken() );
-		        if( !AreDigitsInSpecificRange(leftPart, 2, ETrue, 59) )
-		            return EFalse;
-		        
-		        Skip(fourth, 1);
-		        TPtrC8 rightPart( fourth.Remainder() );
-		        
-		        // if 3rd field is divided by dot and right part is exactly 3 digits in range: 000-999 -> ok
-		        if( rightPart != KNullDesC8() )
-		        {		        
-		            if( !AreDigitsInSpecificRange(rightPart, 3, ETrue, 999) )
-		                return EFalse;
-		        }
-		        else if( field[length-1] == '.' )
-		            return EFalse;
-		        
-		        ++fieldNum;
-		    }
-		    else
-		        return EFalse;
-		}
-		else
-		{
-		    return EFalse;
-		}
-				
-		Skip(input,1);	
-	}
-	
-	// if while loop is completed successfully -> ok
-	if(fieldNum == 4)
-	    return ETrue;
-	else
-	    return EFalse;	    
-}
-
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::StringToInteger
-// -----------------------------------------------------------------------------
-//
-TInt UpnpCdUtils::StringToInteger(const TDesC8& aStr, TInt* aInt)
-    {
-    if( aStr.Length() == 0 || aInt == NULL)
-        {
-        return KErrArgument;
-        }
-    
-    TLex8 lex(aStr);    
-    lex.Mark();
-    TBool isFirst = ETrue;
-    
-    while( !lex.Eos() )
-        {   
-        TChar tmp = lex.Get();
-        
-        if( tmp.IsDigit() )
-            {
-            if(isFirst && tmp == '0' && aStr.Length() > 1)
-                {
-                return KErrArgument;
-                }                        
-            }
-        else
-            {
-            return KErrArgument;
-            }
-        
-        isFirst = EFalse;        
-        }
-               
-    lex.UnGetToMark();                    
-    return lex.Val( *aInt );
-    }
-
-//  End of File  
+/** @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:  ContentDirectory utils
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <uri8.h>
+#include "upnpcdutils.h"
+#include "upnpcontentdirectoryglobals.h"
+#include "upnpdominterface.h"
+#include "upnperror.h"
+#include "upnpcommonupnplits.h"
+#include "upnpstring.h"
+#include "upnpcons.h"
+#include <utf.h>
+#include <xmlengdocument.h>
+#include <e32math.h>
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::RemoveWhiteSpacesL
+// -----------------------------------------------------------------------------
+//
+void UpnpCdUtils::RemoveWhiteSpacesL(TDes8& aString)
+{
+    for(TInt i=0; i<aString.Length(); i++)
+    {
+        if(    aString[i] == ' '
+           ||  aString[i] == '\r'
+           ||  aString[i] == '\n'
+           ||  aString[i] == '\t')
+        {
+            aString.Replace(i,1,_L8(""));
+            i--;
+        }
+    }
+}
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::IsWhiteString
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool UpnpCdUtils::IsWhiteString(const TDesC8& aString)
+{
+    TBool ret = ETrue;
+    for(TInt i = 0; i < aString.Length(); i++)
+    {
+        if( !(  aString[i] == '\n' ||
+                aString[i] == '\r' ||
+                aString[i] == ' '  ||
+                aString[i] == '\t' )  ) 
+        {
+            ret = EFalse;
+            break;
+        }
+    }
+    return ret;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::GetObjectElementL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TXmlEngElement UpnpCdUtils::GetObjectElementL(RXmlEngDocument& aFragment)
+{
+    TXmlEngElement element;
+    // try to get container
+    UpnpDomInterface::GetElementL( aFragment.DocumentElement(), element, KContainer );
+    if(element.IsNull())
+    { // this is not a container
+        // try to get an item
+        UpnpDomInterface::GetElementL( aFragment.DocumentElement(), element, KItem );
+        if(element.IsNull())
+        { // this is neither an item - error
+            User::Leave(EInvalidArgs);
+        }
+    }
+    return element;
+}
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::HasRefIdL
+// -----------------------------------------------------------------------------
+//
+TBool UpnpCdUtils::HasRefIdL( RXmlEngDocument& aFragment )
+    {
+    TXmlEngElement object = UpnpCdUtils::GetObjectElementL( aFragment );
+    //reference id value
+    TPtrC8 refID = UpnpDomInterface::GetAttrValueL( object, KRefID );
+    return !refID.CompareF( KNullDesC8 ) ? EFalse : ETrue;
+    }
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::EncodeXmlStringL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* UpnpCdUtils::EncodeXmlStringL(const TDesC8& aString)
+{
+    // new buffer size 
+    TInt extensionSize = 0;
+    for(TInt i = 0; i < aString.Length(); i++)
+    {
+        if(aString[i] == '&')       extensionSize += KEtAmp().Length() - 1;
+        else if(aString[i] == '<')  extensionSize += KEtlt().Length() - 1;
+        else if(aString[i] == '>')  extensionSize += KEtgt().Length() - 1;
+        else if(aString[i] == '\"') extensionSize += KEtQuot().Length() - 1;
+        else if(aString[i] == '\'') extensionSize += KEtApos().Length() - 1;
+    }
+    
+    // alloc new buffer
+    HBufC8* ret = HBufC8::NewLC(aString.Length() + extensionSize);
+    TPtr8 retPtr(ret->Des());
+    retPtr.Copy(aString);
+    
+    // replace
+    for(TInt i = 0; i < retPtr.Length(); i++)
+    {
+        if(retPtr[i] == '&')        retPtr.Replace(i, 1, KEtAmp);
+        else if(retPtr[i] == '<')   retPtr.Replace(i, 1, KEtlt);
+        else if(retPtr[i] == '>')   retPtr.Replace(i, 1, KEtgt);
+        else if(retPtr[i] == '\"')  retPtr.Replace(i, 1, KEtQuot);
+        else if(retPtr[i] == '\'')  retPtr.Replace(i, 1, KEtApos);
+    }
+    
+    // clean up
+    CleanupStack::Pop(ret);
+    
+    return ret; 
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::ReplaceTrueFalse
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void UpnpCdUtils::ReplaceTrueFalse(HBufC8* aBuf)
+{
+    TPtr8 ptr(aBuf->Des());
+    TInt pos;
+    // false -> 0
+    pos = ptr.FindC(KFalseString8);
+    if (pos != KErrNotFound)
+    {
+        ptr.Replace(pos, KFalseString8().Length(), KFalseValue8);
+    }
+    // true -> 1
+    pos = ptr.FindC(KTrueString8);
+    if (pos != KErrNotFound)
+    {
+        ptr.Replace(pos, KTrueString8().Length(), KTrueValue8);
+    }
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::GetElmNameWithNsL
+// -----------------------------------------------------------------------------
+//
+HBufC8* UpnpCdUtils::GetElmNameWithNsL(TXmlEngElement aElement)
+{
+    TPtrC8 elmName( aElement.Name() );
+    HBufC8* ret = NULL;
+    if( aElement.NamespaceDeclaration().Prefix().Length() )
+    {
+        TPtrC8 prefix( aElement.NamespaceDeclaration().Prefix() );
+        ret = HBufC8::NewL(elmName.Length() + prefix.Length() + 1);
+        TPtr8 ptr(ret->Des());
+        
+        // concatenate prefix and name
+        ptr.Copy(prefix);
+        ptr.Append(KCol);
+        ptr.Append(elmName);
+    }
+    else
+    {
+        ret = elmName.AllocL();
+    }
+    
+    return ret; // the caller should delete it
+}
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::Des8ToDesL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC* UpnpCdUtils::Des8ToDesL(const TDesC8& aString)
+{
+    HBufC* ret = Des8ToDesLC(aString);
+    CleanupStack::Pop(ret);
+    return ret;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::Des8ToDesLC
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC* UpnpCdUtils::Des8ToDesLC(const TDesC8& aString)
+{    
+    HBufC* ret = UpnpString::ToUnicodeL(aString);
+    CleanupStack::PushL(ret);
+    return ret;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::DesToDes8LC
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* UpnpCdUtils::DesToDes8LC(const TDesC& aString)
+{
+    HBufC8* ret = UpnpString::FromUnicodeL(aString);
+    CleanupStack::PushL(ret);
+    return ret;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::ResIdFromUriL
+// -----------------------------------------------------------------------------
+//
+TInt64 UpnpCdUtils::ResIdFromUriL(const TDesC8& aUri)
+{
+    TUriParser8 up;
+    User::LeaveIfError(up.Parse(aUri));
+    TPtrC8 path(up.Extract(EUriPath));
+    if (path.Length() == 0)
+    {
+    User::Leave(KErrNotFound);
+    }
+    
+    if(path[0] == '/')
+    {
+        path.Set(path.Mid(1));
+    }
+    TInt index = path.Locate(TChar('/'));
+    
+    if ((index>0)&&(index != KMaxIDResLength))
+    {
+    	User::Leave(KErrNotFound);    
+    }
+    TLex8 lexer(path);
+    TInt64 ret;
+    User::LeaveIfError(lexer.Val(ret));
+    return ret;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::ResIdFromUriL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TPtrC8 UpnpCdUtils::ResIdFromUriDesL(const TDesC8& aUri)
+{
+    TUriParser8 up;
+    User::LeaveIfError(up.Parse(aUri));
+    TPtrC8 path(up.Extract(EUriPath));
+    if (path.Length() == 0)
+    {
+    User::Leave(KErrNotFound);
+    }
+    
+    if(path[0] == '/')
+    {
+        path.Set(path.Mid(1));
+    }
+    
+    TInt index = path.Locate(TChar('/'));
+    
+    if (index > 0)       
+    {
+        path.Set(path.Left(index));        
+    }
+    
+    return path;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::SetObjectIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void UpnpCdUtils::SetObjectIdL(TXmlEngElement aElement, TInt aId)
+{
+    TXmlEngAttr idAttr = aElement.AttributeNodeL(KIdAttrName());
+    TBuf8<KMaxIntegerLen> idVal;
+    idVal.Num(aId);
+    if(idAttr.NotNull())
+    {
+        idAttr.SetValueL(idVal);
+    }
+    else
+    {
+        aElement.AddNewAttributeL(KIdAttrName(), idVal);
+    }
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::SetObjectRefIdL
+// -----------------------------------------------------------------------------
+//
+void UpnpCdUtils::SetObjectRefIdL(TXmlEngElement aElement, TInt aRefId)
+{
+    TXmlEngAttr refIdAttr = aElement.AttributeNodeL( KRefID() );
+    TBuf8<KMaxIntegerLen> refIdVal;
+    refIdVal.Num( aRefId );
+    if( refIdAttr.NotNull() )
+        {
+        refIdAttr.SetValueL( refIdVal );
+        }
+    else
+        {
+        aElement.AddNewAttributeL( KRefID(), refIdVal );
+        }
+}
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::SetObjectParentIdL
+// -----------------------------------------------------------------------------
+//
+void UpnpCdUtils::SetObjectParentIdL(TXmlEngElement aElement, TInt aParentId)
+{
+    TXmlEngAttr parentIdAttr = aElement.AttributeNodeL( KParentID() );
+    TBuf8<KMaxIntegerLen> parentIdVal;
+    parentIdVal.Num( aParentId );
+    if( parentIdAttr.NotNull() )
+        {
+        parentIdAttr.SetValueL( parentIdVal );
+        }
+    else
+        {
+        aElement.AddNewAttributeL( KParentID(), parentIdVal );
+        }
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::SetRestrictedFieldL
+// -----------------------------------------------------------------------------
+//
+void UpnpCdUtils::SetRestrictedFieldL(TXmlEngElement aElement, TBool aRestrictedFlag)
+{
+    TXmlEngAttr restrictedField = aElement.AttributeNodeL( KRestricted() );    
+    TBuf8<KMaxIntegerLen> restrictedVal;
+    
+    if( aRestrictedFlag )
+        {
+        restrictedVal.Copy( KTrueValue8 );
+        }    
+    else
+        {
+        restrictedVal.Copy( KFalseValue8 );
+        }    
+
+    if( restrictedField.NotNull() )
+        {
+        restrictedField.SetValueL( restrictedVal );
+        }
+    else
+        {
+        aElement.AddNewAttributeL( KRestricted(), restrictedVal );
+        }
+}
+
+// UpnpCdUtils::SetObjectIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void UpnpCdUtils::SetContainerIdL(TXmlEngElement aElement, TInt aParentId)
+{
+    TXmlEngAttr idAttr = aElement.AttributeNodeL(KParentID());
+    TBuf8<KMaxIntegerLen> idVal;
+    idVal.Num(aParentId);
+    if(idAttr.NotNull())
+    {
+        idAttr.SetValueL(idVal);
+    }
+    else
+    {
+        aElement.AddNewAttributeL(KParentID(), idVal);
+    }
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::IsElementRequiredL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool UpnpCdUtils::IsElementRequiredL(TXmlEngElement aElement)
+{
+    TBool ret = EFalse;
+    TXmlEngAttr reqAttr = aElement.AttributeNodeL( KRequiredAtrName() );
+    if(reqAttr.NotNull())
+    { // element required
+        ret = ETrue;
+        reqAttr.Remove();
+    }   
+    return ret;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::BuildImportUriL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+HBufC8* UpnpCdUtils::BuildImportUriLC(TInt aResId)
+{
+	// get next resId
+	TBuf8<KMaxIntegerLen + KRandomRangeLength> num;
+	TBuf8<KMaxIntegerLen + KRandomRangeLength> uriId;
+	num.Num(aResId);
+	uriId.Justify(num, KMaxIntegerLen + KRandomRangeLength, ERight, '0');
+
+	// build uri
+	HBufC8* impUri = HBufC8::NewLC(
+						  KHttpTag().Length()
+						+ KIpPortPlaceholder8().Length()						
+						+ KSlash8().Length()						
+						+ KMaxLongIntegerLen
+						+ KRandomRangeLength );
+	TPtr8 impUriPtr(impUri->Des());
+	impUriPtr.Append(KHttpTag);
+	impUriPtr.Append(KIpPortPlaceholder8);
+	impUriPtr.Append(KSlash8);		
+	impUriPtr.Append(uriId);
+	
+	
+	return impUri;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::BuildImportUriL
+// -----------------------------------------------------------------------------
+HBufC8* UpnpCdUtils::BuildImportUriShorterLC(TInt64 aResId)
+{
+	// get next resId
+	TBuf8<KMaxIntegerLen > num;
+	TBuf8<KMaxIntegerLen > uriId;
+	num.Num(aResId);
+	uriId.Justify(num, KMaxIntegerLen , ERight, '0');
+
+	// build uri
+	HBufC8* impUri = HBufC8::NewLC(
+						  KHttpTag().Length()
+						+ KIpPortPlaceholder8().Length()						
+						+ KSlash8().Length()						
+						+ KMaxLongIntegerLen
+						 );
+	TPtr8 impUriPtr(impUri->Des());
+	impUriPtr.Append(KHttpTag);
+	impUriPtr.Append(KIpPortPlaceholder8);
+	impUriPtr.Append(KSlash8);		
+	impUriPtr.Append(uriId);
+	
+	
+	return impUri;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::BuildContentUriL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+HBufC8* UpnpCdUtils::BuildContentUriL(TInt aResId, const TDesC& aFileExten,
+                                           TDesC8& aObjectId)
+{
+    HBufC8* number = UpnpCdUtils::RandomizeL(KRandomMax);
+    CleanupStack::PushL(number);
+    HBufC8* number2 = UpnpCdUtils::RandomizeL(KRandomMax);
+    CleanupStack::PushL(number2);
+    
+	HBufC8* impUri = BuildImportUriShorterLC(aResId);	
+	
+    HBufC8* fileExten8 = UpnpCdUtils::DesToDes8LC(aFileExten);
+	HBufC8* contUri = HBufC8::NewLC(
+								impUri->Length() 
+								+ number->Des().Length()
+								+ number2->Des().Length()
+								+ KSlash().Length()
+                                + aObjectId.Length()                                
+                                + fileExten8->Length());
+	TPtr8 contUriPtr(contUri->Des());
+	contUriPtr.Copy(*impUri);
+	contUriPtr.Append(*number);	
+	contUriPtr.Append(*number2);
+	contUriPtr.Append(KSlash);
+    contUriPtr.Append(aObjectId);    
+    contUriPtr.Append(*fileExten8);
+
+    // clean up
+	CleanupStack::Pop(contUri);
+    CleanupStack::PopAndDestroy(fileExten8);
+	CleanupStack::PopAndDestroy(impUri);
+	CleanupStack::PopAndDestroy(number2);
+	CleanupStack::PopAndDestroy(number);
+	return contUri;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::RandomizeL
+// -----------------------------------------------------------------------------
+HBufC8* UpnpCdUtils::RandomizeL(TInt aRange)
+{
+    TUint number = Math::Random();
+    number = number % aRange;    
+    HBufC8* numberDes = HBufC8::NewL(KRandomRangeLength);               
+   	TBuf8<KRandomRangeLength> num;	
+	num.Num(number);
+    numberDes->Des().Justify(num, KRandomRangeLength, ERight, '0');    
+
+    return numberDes;
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::ValidateFilePath
+// -----------------------------------------------------------------------------
+void UpnpCdUtils::ValidateFilePath(TDes8& aPath)
+{
+    // replace
+    for(TInt i = 0; i < aPath.Length(); i++)
+    {
+        if( aPath[i] == ':' && i!=1 || 
+            aPath[i] == '<'         ||
+            aPath[i] == '>'         ||
+            aPath[i] == '\"'        ||
+            aPath[i] == '/'         ||    
+            aPath[i] == '|'         ||
+            aPath[i] == '*'       ||
+            aPath[i] == '?'
+          )
+        {
+            aPath[i] = '_';
+        }
+    }
+}
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::ValidateFilePath
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void UpnpCdUtils::ValidateFilePath(TDes& aPath)
+{
+    // replace
+    for(TInt i = 0; i < aPath.Length(); i++)
+    {
+        if( aPath[i] == ':' && i!=1 || 
+            aPath[i] == '<'         ||
+            aPath[i] == '>'         ||
+            aPath[i] == '\"'        ||
+            aPath[i] == '/'         ||    
+            aPath[i] == '|'         ||
+            aPath[i] == '*'       ||
+            aPath[i] == '?'
+          )
+        {
+            aPath[i] = '_';
+        }
+    }
+}
+
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::ValidateSrcUriL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void UpnpCdUtils::ValidateSrcUriL(TDesC8& aPath,TDesC8& aIp )
+{
+    // Check if parsing is correct
+    TUriParser8 srcParser;
+    if (!(srcParser.Parse(aPath) == KErrNone))
+    {
+        User::Leave( ENoSourceResource );                        
+    }
+    
+    // check if source uri is correct one
+    TInt pos = aPath.Find(aIp);
+    if(pos != UpnpHTTP::KHTTPUrl().Length())
+        {
+        User::Leave( ENoSourceResource ); 
+        }
+
+    if (!(aPath.Find( UpnpHTTP::KHTTPUrl ) == 0))
+    {
+        User::Leave( ENoSourceResource );                        
+    }
+    TInt len = UpnpHTTP::KHTTPUrl().Length() + aIp.Length();
+    if ( aPath.Length() <= len || aPath[ len ] != '/' )
+        {
+        User::Leave( ENoSourceResource );
+        }
+}
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::EscapeAposL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+HBufC* UpnpCdUtils::EscapeAposL(const TDesC&  aValue)
+{
+    if (aValue.Length())
+    {            
+        HBufC8* value8 = DesToDes8LC(aValue);
+        HBufC8* valueReplaced8 = UpnpString::StringReplaceL(*value8,_L8("'"),_L8("\'\'"));
+        CleanupStack::Pop(value8);
+        HBufC* valueReplaced16 = UpnpCdUtils::Des8ToDesL(*valueReplaced8);
+        delete valueReplaced8;
+        delete value8;        
+        return valueReplaced16;
+    }
+    else
+    {
+        HBufC* valueReplaced16 = aValue.AllocL();
+        return valueReplaced16;
+    }   
+}
+
+TBool UpnpCdUtils::ValidateDateLength(TInt aDateLength)
+    {
+    TBool retVal = ETrue;
+    
+    if ((aDateLength!=EDay)&&(aDateLength!=ESecond)&&
+            (aDateLength!=ETimeOffset1)&&(aDateLength!=EMiliSecond)&&
+            (aDateLength!=ETimeOffset2)&&(aDateLength!=EZone1)&&
+            (aDateLength!=EZone2))                                     
+        {
+        retVal = EFalse;
+        }
+    
+    return retVal;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidateDateL()
+// Only Those date string is validate
+// YYYY-MM-DD
+// YYYY-MM-DDTHH:MM:SS
+// YYYY-MM-DDTHH:MM:SSZ
+// YYYY-MM-DDTHH:MM:SS.xxx
+// YYYY-MM-DDTHH:MM:SS.xxxZ
+// YYYY-MM-DDTHH:MM:SS+HH:MM
+// YYYY-MM-DDTHH:MM:SS.xxx+HH:MM
+// -----------------------------------------------------------------------------
+//
+TBool UpnpCdUtils::ValidateDateL( TPtrC8 aValue )
+    {         
+    TBool wrong = 0;
+
+    TInt dateLength = aValue.Length();                                         
+
+    if (!(ValidateDateLength(dateLength)))
+        {
+        return EFalse;
+        }
+    else
+        {
+        const TChar KColo = ':';
+        const TChar KMinus = '-';
+        const TChar KPlus = '+';
+        const TChar KDot = '.';       
+        const TChar KT = 'T';
+        const TChar KZ = 'Z'; 
+
+        TChar ch;
+        TLex8 input(aValue);         
+        for (TInt i =0; i<aValue.Length();i++)
+            {
+            ch = input.Get();         
+            if ((i!=EYear)&&(i!=EMonth)&&(i!=EDay)&&(i!=EHour)&&(i!=EMinute)&&(i!=ESecond)&&(i!=EHourOffset1)&&(i!=EMiliSecond)&&(i!=EHourOffset2))
+                {                
+                if (!ch.IsDigit())          
+                    {
+                    wrong = ETrue;
+                    break;  
+                    }
+                }
+            else if (((i==EYear)||(i==EMonth))&&(ch!=KMinus))
+                {
+                wrong = ETrue;
+                break;  
+                }    
+            else if ((i==EDay)&&(ch!= KT))
+                {
+                wrong = ETrue;
+                break;  
+                }     
+            else if (((i==EHour)||(i==EMinute)||(i==EHourOffset2))&&(ch!=KColo))
+                {
+                wrong = ETrue;
+                break;  
+                }     
+            else if (((i==ESecond)&&(dateLength==ETimeOffset1))&&((ch!=KPlus)&&(ch!=KMinus)))
+                {
+                wrong = ETrue;
+                break;  
+                }    
+            else if (((i==ESecond)&&(dateLength==EZone1))&&(ch!=KZ))
+                {
+                wrong = ETrue;
+                break;  
+                }
+            else if (((i==ESecond)&&((dateLength==ETimeOffset2)||(dateLength==EZone2)||(dateLength==EMiliSecond)))&&(ch!=KDot))
+                {
+                wrong = ETrue;
+                break;  
+                }              
+            else if (((i==EHourOffset1)&&(dateLength==ETimeOffset1))&&(ch!=KColo))
+                {
+                wrong = ETrue;
+                break;  
+                }   
+                                
+            else if ((i==EHourOffset1)&&((dateLength==ETimeOffset2)||(dateLength==EZone2)||(dateLength==EMiliSecond)))
+                {                    
+                if (!ch.IsDigit())          
+                    {
+                    wrong = ETrue;
+                    break;  
+                    }
+                }
+            else if (((i==EMiliSecond)&&(dateLength==ETimeOffset2))&&((ch!=KPlus)&&(ch!=KMinus)))
+                {
+                wrong = ETrue;
+                break;  
+                }            
+            else if (((i==EMiliSecond)&&(dateLength==EZone2))&&(ch!=KZ))
+                {
+                wrong = ETrue;
+                break;  
+                }      
+            else if ((i==EMiliSecond)&&(dateLength==ETimeOffset1))
+                {                
+                if (!ch.IsDigit())          
+                    {
+                    wrong = ETrue;
+                    break;  
+                    }                               
+                }
+            }
+        }
+            
+        TInt yearInt=0;
+        TInt monthInt=0;
+        TInt dayInt=0;
+        TInt hourInt=0;
+        TInt minuteInt=0;
+        TInt secondInt=0;
+        TInt milisecondInt=0;
+        TInt hhInt=0;
+        TInt mmInt=0;
+        TDateTime a;
+
+        TPtrC8 yearPtrC = aValue.Left(4);
+        TPtrC8 tmp = aValue.Mid(5);
+        TPtrC8 monthPtrC = tmp.Left(2);
+        tmp.Set(aValue.Mid(8));
+        TPtrC8 dayPtrC = tmp.Left(2);
+
+        TLex8 lexer(yearPtrC);	
+        lexer.Val(yearInt);
+        lexer.Assign(monthPtrC);
+        lexer.Val(monthInt);
+        monthInt--;
+        TMonth monthEnum = (TMonth)monthInt;
+        lexer.Assign(dayPtrC);
+        lexer.Val(dayInt);
+
+        if (dateLength>EDay)                
+            {
+            tmp.Set(aValue.Mid(11));
+            TPtrC8 hourPtrC = tmp.Left(2);
+            tmp.Set(aValue.Mid(14));
+            TPtrC8 minutePtrC = tmp.Left(2);
+            tmp.Set(aValue.Mid(17));
+            TPtrC8 secondPtrC = tmp.Left(2);  
+            lexer.Assign(hourPtrC);
+            lexer.Val(hourInt);
+            lexer.Assign(minutePtrC);
+            lexer.Val(minuteInt);
+            lexer.Assign(secondPtrC);
+            lexer.Val(secondInt);  
+            }                
+        if ((dateLength==ETimeOffset2)||(dateLength==EZone2)||(dateLength==EMiliSecond))
+            {
+            tmp.Set(aValue.Mid(20)); 
+            TPtrC8 milisecondPtrC = tmp.Left(3);  
+            lexer.Assign(milisecondPtrC);
+            lexer.Val(milisecondInt);
+            }
+        if (dateLength==ETimeOffset1)
+            {
+            tmp.Set(aValue.Mid(20)); 
+            TPtrC8 hhOffset = tmp.Left(2);
+            tmp.Set(aValue.Mid(23)); 
+            TPtrC8 mmOffset = tmp.Left(2);      
+            lexer.Assign(hhOffset);
+            lexer.Val(hhInt);
+            
+            if (hhInt>12) 
+                {
+                wrong = ETrue;                
+                }
+            
+            lexer.Assign(mmOffset);
+            lexer.Val(mmInt);     
+            
+            if (mmInt>59) 
+                {
+                wrong = ETrue;   
+                }
+            }
+            
+        if (dateLength==ETimeOffset2)
+            {
+            tmp.Set(aValue.Mid(24)); 
+            TPtrC8 hhOffset = tmp.Left(2);
+            tmp.Set(aValue.Mid(27)); 
+            TPtrC8 mmOffset = tmp.Left(2);     
+            lexer.Assign(hhOffset);
+            lexer.Val(hhInt);
+            if (hhInt>12) 
+                {
+                wrong = ETrue;                
+                }
+            lexer.Assign(mmOffset);
+            lexer.Val(mmInt); 
+                
+            if (mmInt>59) 
+                {
+                wrong = ETrue;                
+                }
+            }
+            
+        TInt err = a.Set(yearInt,monthEnum,dayInt,hourInt,minuteInt,secondInt,milisecondInt);
+        if (err<0) 
+            {
+            wrong = ETrue;    
+            }
+
+    if (wrong)
+        {                        
+        return EFalse;      
+        }
+
+    return ETrue;
+    }
+    
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::StringToUint
+// -----------------------------------------------------------------------------
+    TInt UpnpCdUtils::StringToTUint(const TDesC8& aStr, TUint* aInt)
+	{
+	if( 0 == aStr.Length() || aInt == NULL)
+		{
+		return KErrArgument;
+		}
+	TLex8 lex( aStr );
+	return lex.Val( *aInt );
+	}                   
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::SplitStringByDelimeter
+// -----------------------------------------------------------------------------
+void UpnpCdUtils::SplitStringByDelimeter(TLex8& aLexeme, TChar aDelimeter)
+{
+	aLexeme.Mark(); 
+	while( (aLexeme.Peek() != aDelimeter) && (!aLexeme.Eos()) )
+	{
+		aLexeme.Inc();		
+	}
+}
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::Skip
+// -----------------------------------------------------------------------------
+void UpnpCdUtils::Skip(TLex8& aLexer, TInt aValue)
+{
+    if(!aLexer.Eos())
+	{
+	    aLexer.Inc(aValue);
+	}
+}	
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::AreDigitsInSpecificRange
+// -----------------------------------------------------------------------------    
+TBool UpnpCdUtils::AreDigitsInSpecificRange(const TDesC8& aInput, TInt aNumber, TBool aExactDigitsNumber, TUint32 aRange)
+{
+    // checking length
+    TInt length = aInput.Length();
+    
+    if(aExactDigitsNumber)
+    {
+        // if exact number of digits = real number of digits -> ok
+        if(length != aNumber) 
+            return EFalse;
+    }
+    else
+    {
+        // if real number of digits fit into specific range -> ok
+        if(length > aNumber || length < 1)
+            return EFalse;
+    }
+    
+    // checking digits
+    for(TInt i=0; i < length; i++)
+    {
+        // if input characters are all digits -> ok
+        TChar tmp( aInput[i] );       
+        if( !tmp.IsDigit() )
+            return EFalse;            
+    }
+    
+    // checking range
+    TLex8 field(aInput);	        
+    TUint32 value;
+    
+    // if e.g minutes fit into range: 00-59 -> ok
+    TInt err = field.BoundedVal(value, EDecimal, aRange);
+    
+    if(err != KErrNone)
+        return EFalse;
+    
+    return ETrue;
+}    
+
+// -----------------------------------------------------------------------------
+// UpnpCdUtils::ValidateDurationValueL
+// -----------------------------------------------------------------------------
+TBool UpnpCdUtils::ValidateDurationValue(const TDesC8& aInput)
+{
+	/*
+	* 7.3.22 MM DIDL-Lite res@duration Format
+	* Requirement [7.3.22.1]: The syntax of the res@duration must be compliant to the following definition:
+	*    - duration = hours ":" minutes ":" seconds
+	*    - hours = 1*5 DIGIT; 0-99999
+	*    - minutes = 2 DIGIT ; 00-59
+	*    - seconds = 2 DIGIT ["." 3 DIGIT] ; 00-59 (.000-.999)
+	*/
+    TChar KColon(':');
+    TChar KDot('.');
+
+    TInt fieldNum = 1;        
+    TLex8 input(aInput);
+		
+	while( !input.Eos() )
+	{		
+	    // extract subsequent field
+		SplitStringByDelimeter( input, KColon );
+		TPtrC8 field( input.MarkedToken() );
+		
+		// if its length != 0 ...
+		if( field != KNullDesC8() )
+		{		
+		    if(fieldNum == 1)
+		    {	
+		        // if 1st field = 1-5 digits in range: 0-99999 -> ok
+		        if( !AreDigitsInSpecificRange(field, 5, EFalse, 99999) )
+		            return EFalse;
+		            
+		        ++fieldNum;
+		    }
+		    else if(fieldNum == 2)
+		    {
+		        // if 2nd field = exactly 2 digits in range: 0-59 -> ok
+		        if( !AreDigitsInSpecificRange(field, 2, ETrue, 59) )
+		            return EFalse;
+		        
+		        ++fieldNum;
+		    }		    
+		    else if(fieldNum == 3)
+		    {
+		        TInt length = field.Length();
+		    
+		        TLex8 fourth(field);		        		        
+		        SplitStringByDelimeter( fourth, KDot );
+		        
+		        // if 3rd field = exactly 2 digits in range: 0-59 -> ok
+		        TPtrC8 leftPart( fourth.MarkedToken() );
+		        if( !AreDigitsInSpecificRange(leftPart, 2, ETrue, 59) )
+		            return EFalse;
+		        
+		        Skip(fourth, 1);
+		        TPtrC8 rightPart( fourth.Remainder() );
+		        
+		        // if 3rd field is divided by dot and right part is exactly 3 digits in range: 000-999 -> ok
+		        if( rightPart != KNullDesC8() )
+		        {		        
+		            if( !AreDigitsInSpecificRange(rightPart, 3, ETrue, 999) )
+		                return EFalse;
+		        }
+		        else if( field[length-1] == '.' )
+		            return EFalse;
+		        
+		        ++fieldNum;
+		    }
+		    else
+		        return EFalse;
+		}
+		else
+		{
+		    return EFalse;
+		}
+				
+		Skip(input,1);	
+	}
+	
+	// if while loop is completed successfully -> ok
+	if(fieldNum == 4)
+	    return ETrue;
+	else
+	    return EFalse;	    
+}
+
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::StringToInteger
+// -----------------------------------------------------------------------------
+//
+TInt UpnpCdUtils::StringToInteger(const TDesC8& aStr, TInt* aInt)
+    {
+    if( aStr.Length() == 0 || aInt == NULL)
+        {
+        return KErrArgument;
+        }
+    
+    TLex8 lex(aStr);    
+    lex.Mark();
+    TBool isFirst = ETrue;
+    
+    while( !lex.Eos() )
+        {   
+        TChar tmp = lex.Get();
+        
+        if( tmp.IsDigit() )
+            {
+            if(isFirst && tmp == '0' && aStr.Length() > 1)
+                {
+                return KErrArgument;
+                }                        
+            }
+        else
+            {
+            return KErrArgument;
+            }
+        
+        isFirst = EFalse;        
+        }
+               
+    lex.UnGetToMark();                    
+    return lex.Val( *aInt );
+    }
+
+//  End of File  
--- a/upnpmediaserver/contentdirectoryservice/src/upnpcontentdirectory.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnpcontentdirectory.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,3727 +1,3858 @@
-/** @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:  Content Directory
- *
-*/
-
-
-// INCLUDE FILES
-#include <fbs.h>
-#include <uri8.h>
-#include <pathinfo.h>
-#include <xml/dom/xmlengdom.h>
-#include <xml/dom/xmlengserializationoptions.h>
-#include <xml/dom/xmlengdomparser.h>
-#include <sysutil.h>
-#include <bautils.h>
-#include <caf/caf.h>
-#include <caf/manager.h>
-
-#include "upnpsender.h"
-#include "upnpcontentdirectory.h"
-#include "upnperrors.h"
-#include "upnpdominterface.h"
-#include "upnpstring.h"
-#include "upnpargument.h" 
-#include "upnphttpmessagefactory.h" 
-#include "upnpcons.h"
-#include "upnpdevice.h"
-#include "upnpfileutils.h"
-#include "upnpcommonupnplits.h"
-#include "upnpcontainerupdateid.h"
-#include "upnpcontentdirectorydb.h"
-#include "upnpfiletransfertimerobserver.h"
-#include "upnperror.h"
-#include "upnpcustomlog.h"
-#include "upnpprotocolinfo.h"
-#include "upnpcontentdirectoryglobals.h"
-#include "upnpresourcesbean.h"
-#include "upnpcdutils.h"
-#include "upnpmetadatastorage.h"
-#include "upnpautodestroyobjectlist.h"
-#include "upnpautodestroyobject.h"
-#include "upnpcontentdirectoryeventobserver.h"
-#include "upnpfiletransferevent.h"
-#include "upnpfiletransfer.h"
-#include "upnpprotocolinfolocal.h"
-#include "upnpxmlcontentfilter.h"
-#include "upnpstatehandler.h"
-#include "upnptransferuploader.h"
-#include "upnpmimemapper.h"
-#include "upnptransfercontroller.h"
-#include "upnptransferinterface.h"
-#include "upnpdlnafilter.h"
-#include "upnphttpserversession.h"
-#include "upnphttpserverruntime.h"
-#include "upnpsettings.h"
-#include "upnpdeviceimplementationbase.h"
-#include "upnpsecuritymanager.h"
-#include "upnpmediaserversettings.h"
-
-// Constant definitions
-using namespace UpnpPaths;
-using namespace UpnpDlnaProtocolInfo;
-
-// ============================= LOCAL FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// DestroyRPointerArray
-// Defined in upnpelementfactory.cpp
-// -----------------------------------------------------------------------------
-//
-void DestroyRArray( TAny* aArray );
-void RPointerArrayTPtrC8( TAny* aArray )
-    {
-    RPointerArray<TPtrC8>* array =
-            reinterpret_cast<RPointerArray<TPtrC8>*>(aArray);
-    array->ResetAndDestroy( );
-    }
-
-// ================= MEMBER FUNCTIONS =======================
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CUpnpContentDirectory
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CUpnpContentDirectory::CUpnpContentDirectory( CUpnpDevice& aDevice,
-    MUpnpThumbnailCreatorObserver* aThmbObs, MUpnpTransferInterface* aTransfer ) :
-
-    CUpnpServiceImplementation(aDevice), iThmbObs(aThmbObs),
-            iTransferHandler(aTransfer)
-
-    {
-    SetExecutedAction( EUndefinedAction );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::~CUpnpContentDirectory
-// C++ default destructor
-// -----------------------------------------------------------------------------
-//
-CUpnpContentDirectory::~CUpnpContentDirectory()
-    {
-    delete iDownloadDir;
-    delete iThumbDir;
-    delete iElementdb;
-
-    delete iTransferController;
-    delete iMimeToExtMap;
-
-    delete iContentDirectoryDb;
-
-    iThObjectIds.Close( );
-
-    iThumbnailCreators.ResetAndDestroy( );
-
-    iDOMImpl.Close( );
-    if ( iBitmapServerConnection == KErrNone )
-        RFbsSession::Disconnect( );
-    iFs.Close( );
-    if ( iEcomUsed )
-        {
-        REComSession::FinalClose( );
-        }
-    delete iAutoDestroyObjects;
-    delete iStateHandler;
-    if ( iHttpServerSession )
-        {
-        iHttpServerSession->Stop();
-        }
-    delete iHttpServerSession;
-    delete iDlnaFilter;
-    delete iSecurityManager;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ConstructL
-// Two-phased constructor.
-// Initialize variables, set parent service and create XML reader.
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::ConstructL( TUpnpCdSettings aSettings,
-    CUpnpMetadataStorage* aMetadataStorage )
-    {
-    iDOMImpl.OpenL( );
-
-    iTransferController = CUpnpTransferController::NewL( this );
-
-    iMimeToExtMap = CUpnpMimeMapper::NewL( );
-
-    BaseConstructL( aSettings.iDescriptionPath, KContentDirectoryType( ) );
-
-    User::LeaveIfNull( aSettings.iDevice );
-    
-    CUpnpSecurityManager* secMan = CUpnpSecurityManager::NewInstanceFromUpnpSettingsL();
-    
-    iSecurityManager = secMan;
-    iDlnaFilter = CUpnpDlnaFilter::NewL( this, secMan );
-    
-    iElementdb = CUpnpElementFactory::NewL( aSettings.iObjectsXmlPath );
-    iElementdb->GetContentDirectoryReference( this );
-
-    SetStateVariableL( KSystemUpdateID( ), KZero( ) );
-    SetStateVariableL( KContainerUpdateIDs( ), UpnpCD::KEmptyString( ) );
-    SetStateVariableL( KTransferIDs( ), UpnpCD::KEmptyString( ) , EFalse );
-    SetStateVariableL( KSortCapsVariableName( ), KSortCapabilities( ) );
-    SetStateVariableL( KSearchCapsVariableName( ), KSearchCapabilities( ) );
-
-    // file session 
-    User::LeaveIfError( iFs.Connect( ) );
-
-    iBitmapServerConnection = RFbsSession::Connect( );
-    iDownloadDir = aSettings.iDownloadDir.AllocL( );
-    iThumbDir = aSettings.iThumbnailDir.AllocL( );
-    iContentDirectoryDb = CUpnpContentDirectoryDb::NewL( aMetadataStorage );
-    iAutoDestroyObjects = CUpnpAutoDestroyObjectList::NewL( );
-    iCreateThumbnails = aSettings.iCreateThumbnail;
-    iMaxRequestCount = aSettings.iMaxRequestCount;
-    iEventObserver = aSettings.iEventObserver;
-    iStateHandler = CUpnpStateHandler::NewL( this );
-    
-    ConstructHttpL();
-    }
-
-void CUpnpContentDirectory::ConstructHttpL()
-    {
-    TInt iapId = CUpnpSettings::GetIapL();
-    iHttpServerSession = CUpnpHttpServerSession::NewL( iapId, *this );
-    iHttpServerSession->DefaultRuntime().SetCreator( *this );
-    iHttpServerSession->StartL();
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpContentDirectory* CUpnpContentDirectory::NewL(
-    TUpnpCdSettings aSettings, CUpnpMetadataStorage* aMetadataStorage,
-    MUpnpTransferInterface* aTransfer )
-    {
-    CUpnpContentDirectory* cd = new (ELeave) CUpnpContentDirectory( *aSettings.iDevice,
-            aSettings.iThmbObs,
-            aTransfer
-    );
-    CleanupStack::PushL( cd );
-    cd->ConstructL( aSettings, aMetadataStorage );
-    CleanupStack::Pop( cd );
-    return cd;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ActionReceivedLD
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::ActionReceivedLD( CUpnpAction* aAction )
-    {
-    CleanupStack::PushL( aAction );
-    //check security
-    if ( iSecurityManager &&
-            KErrNone != iSecurityManager->AuthorizeAction( aAction ) )
-        {
-        //server returns upnp error action failed when not authorized
-        User::Leave(EActionFailed);
-        }
-    // in case of low disk space
-    if ( !IsDbOrDiskProblemL( aAction ) )
-        {
-        // handle event
-        TInt ret = EUpnpUndefined;
-        TRAPD( err, ret = DoActionReceivedL( aAction ) );
-        if ( DataBaseHasBeenRecoveredL( err ) )
-            {
-            TRAP( err, ret = DoActionReceivedL( aAction ) );
-            if ( err == KErrCorrupt )
-                {
-                err = iContentDirectoryDb->RecreateDatabaseFile();
-                }
-            }
-        else if ( err == KErrNone )
-            {
-            err = ret;
-            }
-        LOGS( "ContentDirectory ActionReceivedLD sending soon." );
-        DoSendActionL( aAction, TUpnpError( err ) );
-        }
-    CleanupStack::PopAndDestroy( aAction );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::DoActionReceivedL
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectory::DoActionReceivedL( CUpnpAction* aAction )
-    {
-    // sendAndDestroy defines that after processing action must be 
-    // sent and destroyed
-    TUpnpErrorCode err = EUndefined;
-
-    // Get the name, saves calls in the if-else statements
-    TPtrC8 name( aAction->Name() );
-    // Verify the action and do the operation(s)
-    if ( name.Compare( KBrowse ) == 0 )
-        {
-        err = BrowseL( aAction );
-        }
-    else if ( name.Compare( KCreateReference ) == 0 )
-        {
-        err = CreateReferenceL( aAction );
-        }
-    else if ( name.Compare( KCreateObject ) == 0 )
-        {
-        LOGS( "ContentDirectory: Creating a new object" );
-        err = CreateObjectL( aAction );
-        }
-    else if ( name.Compare( KDeleteResource ) == 0 )
-        {
-        err = DeleteResourceL( aAction );
-        }
-    else if ( name.Compare( KDestroyObject ) == 0 )
-        {
-        err = DestroyObjectL( aAction );
-        }
-    else if ( name.Compare( KExportResource ) == 0 )
-        {
-        err = ExportResourceL( aAction );
-        }
-    else if ( name.Compare( KGetSearchCapabilities ) == 0 )
-        {
-        err = GetSearchCapabilitiesL( aAction );
-        }
-    else if ( name.Compare( KGetSortCapabilities ) == 0 )
-        {
-        err = GetSortCapabilitiesL( aAction );
-        }
-    else if ( name.Compare( KGetSystemUpdateID ) == 0 )
-        {
-        err = GetSystemUpdateIdL( aAction );
-        }
-    else if ( name.Compare( KGetTransferProgress ) == 0 )
-        {
-        err = GetTransferProgressL( aAction );
-        }
-    else if ( name.Compare( KImportResource ) == 0 )
-        {
-        err = ImportResourceL( aAction );
-        }
-    else if ( name.Compare( KStopTransferResource ) == 0 )
-        {
-        err = StopTransferResourceL( aAction );
-        }
-    else
-        {
-        err = EInvalidAction;
-        }
-    return err;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::DoActionReceivedCDL
-// -----------------------------------------------------------------------------
-//    
-void CUpnpContentDirectory::HttpGetStartedSoapNotifyL( TInt /*aSessionId*/)
-    {
-    // not needed upnp response returned by ActionReceivedCDL
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::DoActionReceivedCDL
-// -----------------------------------------------------------------------------
-//    
-void CUpnpContentDirectory::HttpPostStartedL( TInt /*aSessionId*/)
-    {
-    // not needed upnp response returned by ActionReceivedCDL
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::UnknownHttpEventReceivedL 
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpContentDirectory::UnknownHttpEventReceivedL( CUpnpHttpMessage& aHttpMsg )
-    {
-    CUpnpFileTransferEvent* transferEvent =
-            iTransferController->TransferL( aHttpMsg.SessionId( ) );
-    if ( !transferEvent )
-        {
-        return;
-        }
-
-    TInt err = aHttpMsg.Error( );
-    if ( err != EHttpRequestTimeout && err != EHttpInsufficientStorage )
-        {
-        err = EHttpOk;
-        }
-
-    HBufC* fileName16 = UpnpString::ToUnicodeL( aHttpMsg.InFilename( ) );
-    CleanupStack::PushL( fileName16 );
-    transferEvent->SetFilePathL( *fileName16 );
-    CleanupStack::PopAndDestroy( fileName16 );
-
-    iTransferController->HttpResponseReceivedL( aHttpMsg.SessionId( ), err );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::IsDrmFileL 
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectory::IsDrmFileL( const TDesC8& aFileName )
-    {
-    HBufC* tmp = UpnpCdUtils::Des8ToDesLC( aFileName );
-    TBool ret = IsDrmFileL( *tmp );
-    CleanupStack::PopAndDestroy( tmp );
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::IsDrmFileL 
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectory::IsDrmFileL( const TDesC& aFileName )
-    {
-    if ( !BaflUtils::FileExists( iFs, aFileName ) )
-        {
-        return EFalse;
-        }
-    TBool ret = EFalse;
-    TInt value=0, err;
-
-    ContentAccess::CManager *manager = ContentAccess::CManager::NewL( );
-    CleanupStack::PushL( manager );
-
-    ContentAccess::CVirtualPath *path =
-            ContentAccess::CVirtualPath::NewL( aFileName );
-    CleanupStack::PushL( path );
-
-    ContentAccess::TVirtualPathPtr virtualPath = *path;
-
-    err = manager->GetAttribute( ContentAccess::EIsProtected, value,
-        virtualPath );
-    if ( err == KErrNone )
-        {
-        if ( value )
-            {
-            // delete file
-            iFs.Delete( aFileName );
-            ret = ETrue;
-            }
-        }
-    CleanupStack::PopAndDestroy( 2, manager );
-
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateReferenceL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::CreateReferenceL( CUpnpAction*& aAction )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-
-    // Get IDs from action 
-    TInt conId( KErrNotFound );
-    TInt objId( KErrNotFound );
-
-    TInt err = UpnpCdUtils::StringToInteger(
-        aAction->ArgumentValue( KContainerID ), &conId );
-    if ( err!=KErrNone )
-        {
-        err=ENoContainer;
-        User::Leave( ENoContainer );
-        }
-
-    err = UpnpCdUtils::StringToInteger(
-        aAction->ArgumentValue( UpnpCD::KObjectID ), &objId );
-    if ( err!=KErrNone )
-        {
-        err=ENoContainer;
-        User::Leave( ENoSuchObject );
-        }
-
-    objId = iContentDirectoryDb->ReferedObjectIdL( objId );
-
-    RXmlEngDocument conDidl;
-    RXmlEngDocument objDidl;
-    CleanupClosePushL( conDidl );
-    CleanupClosePushL( objDidl );
-
-    ret = iContentDirectoryDb->GetObjectL( conId, conDidl, KAsterisk8 );
-    if ( ret != EUpnpOk )
-        User::Leave( ENoContainer );
-
-    ret = iContentDirectoryDb->GetObjectL( objId, objDidl, KAsterisk8 );
-    if ( ret != EUpnpOk )
-        User::Leave( ENoSuchObject );
-
-    TXmlEngElement con = conDidl.DocumentElement().FirstChild().AsElement( );
-    TXmlEngElement obj = objDidl.DocumentElement().FirstChild().AsElement( );
-
-    if ( obj.Name().Compare( KItem ) != 0 )
-        {
-        User::Leave( ENoSuchObject );
-        }
-    if ( con.Name().Compare( KContainer ) != 0 )
-        {
-        User::Leave( ENoContainer );
-        }
-    if ( iContentDirectoryDb->CheckObjectRestrictionL( conId ) != EUpnpOk )
-        {
-        User::Leave( ERestrictedParentObject );
-        }
-
-    TInt refId;
-    RXmlEngDocument refDidl = iContentDirectoryDb->PrepareDidlDocumentL( );
-    CleanupClosePushL( refDidl );
-
-    TXmlEngElement refEl = refDidl.DocumentElement().AddNewElementSameNsL( KItem( ) );
-
-    refEl.AddNewAttributeL( KRefID( ),
-        aAction->ArgumentValue( UpnpCD::KObjectID ) );
-
-    refEl.AddNewAttributeL( KParentID( ),
-        aAction->ArgumentValue( KContainerID ) );
-
-    refEl.AddNewAttributeL( KRestricted( ), KFalseValue8( ) );
-
-    // title
-    TXmlEngElement objTitle;
-    UpnpDomInterface::GetElementL( obj, objTitle, KObjTiltleColName8( ) );
-    refEl.AppendChildL( objTitle.Unlink().AsElement( ) );
-
-    // class
-    TXmlEngElement objClass;
-    UpnpDomInterface::GetElementL( obj, objClass, KObjClassColName8( ) );
-    refEl.AppendChildL( objClass.Unlink().AsElement( ) );
-
-    iContentDirectoryDb->InsertObjectL( refDidl, conId, &refId );
-
-    //increase system update ID
-    iStateHandler->IncreaseSystemUpdateIdL( );
-    iStateHandler->IncreaseContainerUpdateIdL( (TDesC8&)aAction->ArgumentValue( KContainerID ) );
-
-    TBuf8<KMaxIntegerLen> newid;
-    newid.Num( refId );
-    aAction->SetArgumentL( (TDesC8&)KNewID, newid );
-
-    CleanupStack::PopAndDestroy( &refDidl );
-    CleanupStack::PopAndDestroy( &objDidl );
-    CleanupStack::PopAndDestroy( &conDidl );
-
-    return EHttpOk;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::BrowseL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::BrowseL( CUpnpAction*& aAction )
-    {
-    RDebug::Print( _L( "CUpnpContentDirectory::BrowseL start" ) );
-    TInt err( KErrGeneral );
-
-    //Check ObjectID
-    TInt objectID( KErrNotFound );
-    err = UpnpCdUtils::StringToInteger(
-        (TDesC8&)aAction->ArgumentValue( UpnpCD::KObjectID( ) ), &objectID );
-    if ( err != KErrNone )
-        {
-        User::Leave( ENoSuchObject );
-        }
-    //Check SortCriteria
-    if ( aAction->ArgumentValue( (TDesC8&) KSortCriteria ).Compare( (TDesC8&)KSortCapabilities )
-            != 0 )
-        {
-        User::Leave( EInvalidSort ); //wrong sort flag
-        }
-
-    //Check BrowseFlag
-    TDesC8& browseFlag =
-            (TDesC8&)aAction->ArgumentValue( (TDesC8&)KBrowseFlag );
-    if ( browseFlag.Compare( KBrowseMeta ) != 0
-            && browseFlag.Compare( KBrowseChilds ) != 0 )
-        {
-        User::Leave( EInvalidArgs ); //wrong browse flag    
-        }
-
-    //Check StartIndex
-    TInt startIndex( KErrNotFound );
-    err = UpnpString::StringToInt(
-        (TDesC8&)aAction->ArgumentValue( (TDesC8&)KStartingIndex ),
-        &startIndex );
-    if ( KErrNone != err )
-        {
-        User::Leave( EInvalidArgs );
-        }
-
-    //Additional check of StartIndex, see documentation
-    if ( browseFlag.Compare( KBrowseMeta ) == 0 && startIndex != 0 )
-        {
-        User::Leave( EInvalidArgs );
-        }
-
-    //Check RequestedCount
-    TInt reqCount( KErrNotFound );
-    err = UpnpString::StringToInt(
-        (TDesC8&)aAction->ArgumentValue( (TDesC8&)KRequestedCount ),
-        &reqCount );
-    if ( KErrNone != err )
-        {
-        User::Leave( EInvalidArgs );
-        }
-
-    //Filter
-    HBufC8* filter = aAction->ArgumentValue( KFilter() ).AllocLC( );
-    filter->Des().TrimAll( );
-
-    // Metadata browse
-    if ( browseFlag.Compare( KBrowseMeta ) == 0 )
-        {
-
-        RXmlEngDocument objectDoc;
-        CleanupClosePushL( objectDoc );
-        // Try to get original object not a reference 
-        TInt id = iContentDirectoryDb->ReferedObjectIdL( objectID );
-        CleanupStack::Check( &objectDoc );
-        TUpnpErrorCode err = EUndefined;
-        err = iContentDirectoryDb->GetObjectL( id, objectDoc, *filter );
-        if ( err != EUpnpOk )
-            User::Leave( err );
-        CleanupStack::Check( &objectDoc );
-        //--------- new solution for references --------
-
-        // if id != objectID it means that we have a reference, so now id = 'real object id' and objectID = 'reference object id' 
-        if ( id != objectID )
-            {
-            TInt refParentID = iContentDirectoryDb->GetParentIdL( objectID );
-            User::LeaveIfError( refParentID );
-
-            UpnpCdUtils::SetObjectIdL(
-                UpnpCdUtils::GetObjectElementL( objectDoc ), objectID );
-            UpnpCdUtils::SetObjectRefIdL(
-                UpnpCdUtils::GetObjectElementL( objectDoc ), id );
-            UpnpCdUtils::SetObjectParentIdL(
-                UpnpCdUtils::GetObjectElementL( objectDoc ), refParentID );
-            UpnpCdUtils::SetRestrictedFieldL(
-                UpnpCdUtils::GetObjectElementL( objectDoc ), EFalse );
-            }
-        //---------------------------------------------
-
-        // Serialize object to descriptor - without DIDL-Lite element
-        RBuf8 buf;
-        TXmlEngSerializationOptions
-                options(TXmlEngSerializationOptions::KOptionOmitXMLDeclaration
-                        | TXmlEngSerializationOptions::KOptionIncludeNsPrefixes);
-        objectDoc.SaveL( buf, iElementdb->ActiveElementL( objectDoc ),
-            options );
-        CleanupStack::Check( &objectDoc );
-        CleanupClosePushL( buf );
-        HBufC8* subResponse = buf.AllocLC( );
-
-        CBufFlat* response = CBufFlat::NewL( KRespBufGranularity );
-        CleanupStack::PushL( response );
-        UpnpString::AppendStringL( *response, KDidlTag );
-        UpnpString::AppendStringL( *response, *subResponse );
-        UpnpString::AppendStringL( *response, (TDesC8&) KDidlEnd( ) );
-
-        HBufC8* resultTmp =
-                UpnpCdUtils::EncodeXmlStringL( response->Ptr( 0 ) );
-        CleanupStack::PushL( resultTmp );
-        TPtr8 resultTmpPtr(resultTmp->Des( ));
-        InsertRealIpAndPortL( resultTmpPtr );
-
-        // Set action's OUT arguments       
-        TBuf8<KMaxIntegerLen> num;
-
-        //Result
-        aAction->SetArgumentL( KResult, *resultTmp );
-
-        //NumberReturned
-        num.Num( 1 );
-        aAction->SetArgumentL( KNumberReturned, num );
-
-        //TotalMatches
-        //num.Num(1);
-        aAction->SetArgumentL( KTotalMatches, num );
-
-        //UpadateID 
-        num.Format(
-            UpnpCD::KOneNumber,
-            ContainerUpdateId( (TDesC8&)aAction->ArgumentValue( (TDesC8&)UpnpCD::KObjectID ) ) );
-        aAction->SetArgumentL( KUpdateID, num );
-
-        // clean up
-        CleanupStack::PopAndDestroy( resultTmp );
-        CleanupStack::PopAndDestroy( response );
-        CleanupStack::PopAndDestroy( subResponse );
-        CleanupStack::PopAndDestroy( &buf );
-        CleanupStack::PopAndDestroy( &objectDoc );
-
-        }
-    //Children browse
-    else if ( browseFlag.Compare( KBrowseChilds ) == 0 )
-        {
-        //array contains pointers to direct childrens.
-        RArray<TInt> listOfAllObjects;
-        CleanupClosePushL( listOfAllObjects );
-
-        TUpnpErrorCode err = iContentDirectoryDb->GetObjectListL( objectID,
-            listOfAllObjects );
-
-        if ( err == ENoSuchObject )
-            {
-            User::Leave( err );
-            }
-
-        // if requestedCount==0 then return all matched objects
-        if ( !reqCount )
-            {
-            reqCount = listOfAllObjects.Count( );
-            }
-
-        // if requestedCount cannot be greater than iMaxRequestCount
-        if ( iMaxRequestCount > 0 && reqCount > iMaxRequestCount )
-            {
-            reqCount = iMaxRequestCount;
-            }
-
-        // get upnp objects
-        RArray<RXmlEngDocument> objs;
-        CleanupStack::PushL(TCleanupItem( DestroyRArray, &objs ));
-
-        if ( startIndex < listOfAllObjects.Count( ) )
-            { // prepare list of objects which are to be returned
-            if ( startIndex + reqCount > listOfAllObjects.Count( ) )
-                reqCount = listOfAllObjects.Count( ) - startIndex;
-            RArray<TInt> alistOfWantedObjs( &listOfAllObjects[startIndex],
-                reqCount);
-
-            iContentDirectoryDb->GetObjectListL( alistOfWantedObjs, *filter,
-                objs );
-            }
-
-        // prepare response
-        // Result
-        HBufC8* resp = SerializeObjectsListL( objs );
-        CleanupStack::PushL( resp );
-        TPtr8 respPtr(resp->Des( ));
-        InsertRealIpAndPortL( respPtr );
-        aAction->SetArgumentL( KResult, *resp );
-        // NumberReturned
-        TBuf8<KMaxIntegerLen> num;
-        num.Num( objs.Count( ) );
-        aAction->SetArgumentL( KNumberReturned, num );
-        // TotalMatches
-        num.Num( listOfAllObjects.Count( ) );
-        aAction->SetArgumentL( KTotalMatches, num );
-        // UpdateID
-        num.Format(
-            UpnpCD::KOneNumber,
-            ContainerUpdateId( (TDesC8&)aAction->ArgumentValue( (TDesC8&)UpnpCD::KObjectID ) ) );
-        aAction->SetArgumentL( KUpdateID, num );
-
-        // clean up
-        CleanupStack::PopAndDestroy( resp );
-        CleanupStack::PopAndDestroy( &objs );
-        CleanupStack::PopAndDestroy( &listOfAllObjects );
-        }
-    else //no valid browseflag
-        {
-        User::Leave( EInvalidArgs );
-        }
-
-    RDebug::Print( _L( "CUpnpContentDirectory::BrowseL Result got OK" ) );
-
-    CleanupStack::PopAndDestroy( filter );
-
-    return EHttpOk;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::SerializeObjectsListL
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpContentDirectory::SerializeObjectsListL(
-    const RArray<RXmlEngDocument>& aObjs )
-    {
-    CBufFlat* buff = CBufFlat::NewL( KRespBufGranularity );
-    CleanupStack::PushL( buff );
-
-    // Didl start
-    UpnpString::AppendStringL( *buff, KDidlTag );
-
-    // content
-    for ( TInt i = 0; i < aObjs.Count( ); i++ )
-        {
-        RBuf8 tmp;
-        TXmlEngSerializationOptions
-                options(TXmlEngSerializationOptions::KOptionOmitXMLDeclaration
-                        | TXmlEngSerializationOptions::KOptionIncludeNsPrefixes);
-        aObjs[i].SaveL( tmp, iElementdb->ActiveElementL( aObjs[i] ), options );
-        CleanupClosePushL( tmp );
-        UpnpString::AppendStringL( *buff, tmp );
-        UpnpString::AppendStringL( *buff, KLF8 );
-        CleanupStack::PopAndDestroy( &tmp );
-        }
-
-    // Didl end
-    UpnpString::AppendStringL( *buff, KDidlEnd );
-
-    // prepare to return
-    HBufC8* ret = UpnpCdUtils::EncodeXmlStringL( buff->Ptr( 0 ) );
-
-    // clean up
-    CleanupStack::PopAndDestroy( buff );
-
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::DestroyObjectL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::DestroyObjectL( CUpnpAction*& aAction )
-    {
-    TInt objId( KErrNotFound );
-
-    TInt error(0);
-    error = UpnpCdUtils::StringToInteger(
-        (TDesC8&)aAction->ArgumentValue( UpnpCD::KObjectID( ) ), &objId );
-    if ( (error == KErrArgument)||(error == KErrOverflow) )
-        {
-        User::Leave( ENoSuchObject );
-        }
-    else if ( error<0 )
-        {
-        User::Leave( error );
-        }
-    // check object restriction
-    TUpnpErrorCode err = iContentDirectoryDb->CheckObjectRestrictionL( objId ); // if returned ENoContainer it is OK because first of all the restriction is checked
-    if ( err == ERestrictedObject || err == ENoSuchObject )
-        {
-        User::Leave( err );
-        }
-
-    // check parent restriction
-    err = iContentDirectoryDb->CheckObjectRestrictionL( objId );
-    if ( err == ERestrictedObject )
-        {
-        User::Leave( ERestrictedParentObject );
-        }
-
-    // root and download containers must not be deleted
-    if ( objId <= KDownloadContId )
-        {
-        /*
-         Designing a UPnP AV MediaServer (3.2.4): 
-         "If a CDS implementation exposes a CDS object that is not restricted but cannot fulfill a
-         CDS:DestroyObject(), CDS:CreateObject(), or CDS:UpdateObject() request, then the MediaServer should
-         return error code 720 to indicate the request could not be processed."
-         */
-        User::Leave( ECannotProcess );
-        }
-
-    RArray<TInt> refList;
-    CleanupClosePushL( refList );
-
-    TBuf8<KMaxIntegerLen> containerID;
-    containerID.Num( iContentDirectoryDb->GetParentIdL( objId ) );
-
-    iContentDirectoryDb->DeleteObjectL( objId, refList, ETrue );
-
-    iStateHandler->IncreaseSystemUpdateIdL( );
-    iStateHandler->IncreaseContainerUpdateIdL( containerID );
-
-    for ( TInt i(0); i<refList.Count( ); i++ )
-        {
-        if ( objId!=refList[i] )
-            {
-            containerID.Num( refList[i] );
-            iStateHandler->IncreaseSystemUpdateIdL( );
-            iStateHandler->IncreaseContainerUpdateIdL( containerID );
-            }
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &refList );
-    return EHttpOk;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::AddToMetaDbL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::AddToMetaDbL(
-    RXmlEngDocument& aFragment, TInt aContainer, TInt* aId, TBool aIsLocal )
-    {
-    // res list
-    RArray<TXmlEngElement> resList;
-    CleanupClosePushL( resList );
-    UpnpDomInterface::GetElementListL( aFragment.DocumentElement( ), resList,
-        KRes );
-
-    // a source file for thumbnail
-    HBufC* thumbSrcFile = NULL;
-
-    if ( aIsLocal )
-        { // local action
-        // create thumbnail if there is only one res in the object
-        if ( resList.Count( ) == 1 )
-            {
-            // get resource file name
-            TPtrC8 val(resList[0].Text( ));
-            // ignore if empty string
-            if ( val.Length( ) && (!UpnpCdUtils::IsWhiteString( val )) )
-                {
-                TUriParser8 up;
-                User::LeaveIfError( up.Parse( val ) );
-                if ( up.Extract( EUriScheme ) == UpnpHTTP::KSchemeFile8 )
-                    {
-                    thumbSrcFile = up.GetFileNameL( ); // thumbnail will be created at the end of this function
-                    CleanupStack::PushL( thumbSrcFile );// and the pointer will be poped 
-                    }
-                }
-            }
-        TInt nextId = iContentDirectoryDb->GetObjectIdL( );
-        // handle resources
-        for ( TInt i = 0; i < resList.Count( ); i++ )
-            {
-            HandleLocalResourcesL( resList[i], nextId );
-            }
-        }
-
-    // if only one empty res add importUri
-    if ( resList.Count( ) )
-        {
-        TPtrC8 resValue(resList[0].Text( ));
-        if ( !resValue.Length( ) || UpnpCdUtils::IsWhiteString( resValue ) )
-            {
-            AddImportUriToElL( resList[0] );
-            }
-        }
-    if ( !resList.Count( ) )
-        {
-        AddNewResTagL( aFragment.DocumentElement( ) );
-        }
-    // add to database
-    TUpnpErrorCode ret = iContentDirectoryDb->InsertObjectL( aFragment,
-        aContainer, aId );
-    if ( ret == EUpnpOk )
-        {
-        PrepareAutoDestroyObjectL( aFragment.DocumentElement( ), *aId );
-        ret = EHttpOk;
-        }
-
-    if ( thumbSrcFile )
-        {
-        CreateThumbnailL( *thumbSrcFile, *aId );
-        CleanupStack::PopAndDestroy( thumbSrcFile );
-        }
-    CleanupStack::PopAndDestroy( &resList );
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateThumbnailForResourceL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::PrepareAutoDestroyObjectL(
-    TXmlEngElement aObject, TInt aObjId )
-    {
-    // check res
-    RArray<TXmlEngElement> resList;
-    CleanupClosePushL( resList );
-    UpnpDomInterface::GetElementListL( aObject, resList, KRes );
-    if ( resList.Count( ) > 0 )
-        {
-        // only first res is important
-        TPtrC8 resValue(resList[0].Text( ));
-        if ( !resValue.Length( ) || UpnpCdUtils::IsWhiteString( resValue ) )
-            {
-            TXmlEngAttr impUri = resList[0].AttributeNodeL( KImportUri( ) );
-            // auto destroy
-            CUpnpAutoDestroyObject* ado = CUpnpAutoDestroyObject::NewLC(
-                this, aObjId, UpnpCdUtils::ResIdFromUriL( impUri.Value( ) ) );
-            iAutoDestroyObjects->AppendL( ado );
-            CleanupStack::Pop( ado );
-            }
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy( &resList );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateThumbnailForResourceL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::CreateThumbnailL( const TDesC& aSrcFile,
-    TInt aObjId )
-    {
-    if ( iCreateThumbnails && IsThumbnailAvailableL( aSrcFile ) )
-        {
-        // thumbnail name
-        HBufC* thumbName = CreateNameForThumbnailL( aSrcFile );
-        CleanupStack::PushL( thumbName );
-
-        // create thumbnail creator
-        CUpnpThumbnailCreator* thCreator = CreateThumbnailCreatorL( aObjId ); // do not push it onto CleanupStack
-        // ThumbnailCreator is created and added to iThumbnailCreators
-        // but the creation process is not yet started,
-        // therefore, not leaving code should be performed until the thCreator->CreateL method is called
-        if ( thCreator )
-            {
-            // start creation process
-            TRAPD( err, thCreator->CreateL( aSrcFile, *thumbName ) );
-            if ( err )
-                {
-                RDebug::Print( _L( "Error while creating thumbnail, it won't be created. Removing from creator list." ) );
-                RemoveThCreatorAndObjectIdLD( thCreator );
-                }
-            iEcomUsed = ETrue;
-            }
-        // clean up
-        CleanupStack::PopAndDestroy( thumbName );
-        }
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::IsThumbnailAvailableL
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectory::IsThumbnailAvailableL( const TDesC& aFile )
-    {
-    HBufC8* tmp = HBufC8::NewLC( aFile.Length( ) );
-    tmp->Des().Copy( aFile );
-    TBool ret = IsThumbnailAvailableL( *tmp );
-    CleanupStack::PopAndDestroy( tmp );
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::IsThumbnailAvailableL
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectory::IsThumbnailAvailableL( const TDesC8& aFile )
-    {
-    TBool result = EFalse;
-
-    // get mime type for file
-    HBufC8* mt = GetMimeTypeLC( aFile );
-    TPtr8 mimeType(mt->Des( ));
-    mimeType.LowerCase( );
-
-    if ( !mimeType.Compare( KMT_IMAGE_JPEG( ) ) )
-        {
-        result = ETrue;
-        }
-    else if ( !mimeType.Compare( KMT_IMAGE_PNG( ) ) )
-        {
-        result = ETrue;
-        }
-    else if ( !mimeType.Compare( KMT_IMAGE_GIF( ) ) )
-        {
-        result = ETrue;
-        }
-    else if ( !mimeType.Compare( KMT_IMAGE_BMP( ) ) )
-        {
-        result = ETrue;
-        }
-    CleanupStack::PopAndDestroy( mt );
-
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::AddImportUriToElL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::AddImportUriToElL( TXmlEngElement aElement )
-    {
-    HBufC8* impUriVal = BuildImportUriShorterLC( );
-    HBufC8* impUriValRandomize = HBufC8::NewLC( impUriVal->Des().Length( )+ KRandomRangeLength );
-    HBufC8* number = UpnpCdUtils::RandomizeL( KRandomMax );
-    CleanupStack::PushL( number );
-    impUriValRandomize->Des().Copy( *impUriVal );
-    impUriValRandomize->Des().Append( *number );
-    aElement.AddNewAttributeL( KImportUri( ), *impUriValRandomize );
-    // clean up
-    CleanupStack::PopAndDestroy( number );
-    CleanupStack::PopAndDestroy( impUriValRandomize );
-    CleanupStack::PopAndDestroy( impUriVal );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::AddNewResTagL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::AddNewResTagL( TXmlEngElement aObjEl )
-    {
-    TXmlEngElement item;
-    UpnpDomInterface::GetElementL( aObjEl, item, KItem );
-
-    // ignore if null
-    if ( item.NotNull( ) )
-        {
-        TXmlEngElement newEl = item.AddNewElementL( KRes( ) );
-        newEl.AddNewAttributeL( KprotocolInfo( ), KEmptyProtocolInfoVal8( ) );
-        newEl.AddNewAttributeL( KProtInfoReqAtrSufPattern( ), KTrueValue8( ) );
-        // add importUri
-        AddImportUriToElL( newEl );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::BuildContentUriL
-// -----------------------------------------------------------------------------
-HBufC8* CUpnpContentDirectory::BuildContentUriL( const TDesC& aFileExt,
-    TInt aObjectId )
-    {
-    TBuf8<KMaxIntegerLen> objectId;
-    objectId.Num( aObjectId );
-    return UpnpCdUtils::BuildContentUriL(
-        iContentDirectoryDb->GetKeyForUriL( ), aFileExt, objectId );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::BuildImportUriL
-// -----------------------------------------------------------------------------
-HBufC8* CUpnpContentDirectory::BuildImportUriLC()
-    {
-    return UpnpCdUtils::BuildImportUriLC( iContentDirectoryDb->GetKeyForUriL( ) );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::BuildImportUriShorterLC
-// -----------------------------------------------------------------------------
-HBufC8* CUpnpContentDirectory::BuildImportUriShorterLC()
-    {
-    return UpnpCdUtils::BuildImportUriShorterLC( iContentDirectoryDb->GetKeyForUriL( ) );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::InsertRealIpAndPortL
-// -----------------------------------------------------------------------------
-void CUpnpContentDirectory::InsertRealIpAndPortL( TDes8& aString )
-    {
-    // prepare pettern
-    HBufC8* pattern = HBufC8::NewLC( KHttpTag().Length( ) + KIpPortPlaceholder8().Length( ) );
-    TPtr8 patternPtr(pattern->Des( ));
-    patternPtr.Append( KHttpTag );
-    patternPtr.Append( KIpPortPlaceholder8 );
-
-    // repare address
-    HBufC8* address = GetIpAndPortDes8L( );
-    CleanupStack::PushL( address );
-
-    TInt pos = aString.Find( patternPtr );
-
-    while ( pos != KErrNotFound )
-        {
-        aString.Replace( pos + KHttpTag().Length( ), KIpPortPlaceholder8().Length( ), *address );
-        pos = aString.Find( patternPtr );
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy( address );
-    CleanupStack::PopAndDestroy( pattern );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::InsertIpAndPortPlaceholderL
-// -----------------------------------------------------------------------------
-HBufC8* CUpnpContentDirectory::InsertIpAndPortPlaceholderL(
-    const TDesC8& aString )
-    {
-    HBufC8* ipAndPort = GetIpAndPortDes8L( );
-    CleanupStack::PushL( ipAndPort );
-
-    HBufC8* ret = aString.AllocLC( );
-
-    TInt pos = KErrNotFound;
-    while ( (pos = ret->Find( *ipAndPort )) != KErrNotFound )
-        {
-        // realloc if too small
-        if ( ipAndPort->Length( ) < KIpPortPlaceholder8().Length( ) )
-            {
-            HBufC8* tmp = ret->ReAllocL( ret->Length( )
-                    + KIpPortPlaceholder8().Length( ) - ipAndPort->Length( ) );
-            CleanupStack::Pop( ret );
-            ret = tmp;
-            CleanupStack::PushL( ret );
-            }
-        ret->Des().Replace( pos, ipAndPort->Length( ), KIpPortPlaceholder8 );
-        }
-    // clean up
-    CleanupStack::Pop( ret );
-    CleanupStack::PopAndDestroy( ipAndPort );
-
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetAddress
-// -----------------------------------------------------------------------------
-TInetAddr CUpnpContentDirectory::GetAddress()
-    {
-    TInetAddr resourceServerAddress;    
-    iHttpServerSession->GetAddress( resourceServerAddress );
-    return resourceServerAddress;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::AutoDestroyObjectList
-// -----------------------------------------------------------------------------
-CUpnpAutoDestroyObjectList* CUpnpContentDirectory::GetAutoDestroyObjectList()
-    {
-    return iAutoDestroyObjects;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetIpAndPortDes8L
-// -----------------------------------------------------------------------------
-HBufC8* CUpnpContentDirectory::GetIpAndPortDes8L()
-    {
-    TInetAddr resourceServerAddress = GetAddress();        
-    
-    TBuf<KMaxName> addrTmp;
-    resourceServerAddress.Output( addrTmp );
-    HBufC8* addr = UpnpString::FromUnicodeL( addrTmp );
-    CleanupStack::PushL( addr );
-    
-    TInt portNo = resourceServerAddress.Port();
-    TBuf8<KMaxName> port;
-    port.Num( portNo );
-    
-    HBufC8* temp = HBufC8::NewLC( addr->Length( ) + KColon8().Length( ) + port.Length( ) );
-    TPtr8 tempPtr( temp->Des() );
-    tempPtr.Copy( *addr );
-    tempPtr.Append( KColon8 );
-    tempPtr.Append( port );
-
-    CleanupStack::Pop( temp );
-    CleanupStack::PopAndDestroy( addr );
-
-    return temp;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetSearchCapabilitiesL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::GetSearchCapabilitiesL(
-    CUpnpAction*& aAction )
-    {
-    aAction->SetArgumentL( KSearchCaps,
-        StateVariableValue( KSearchCapsVariableName ) );
-    return EHttpOk;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetSortCapabilitiesL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::GetSortCapabilitiesL(
-    CUpnpAction*& aAction )
-    {
-    aAction->SetArgumentL( KSortCaps,
-        StateVariableValue( KSortCapsVariableName ) );
-    return EHttpOk;
-    } 
- 
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetSystemUpdateIdL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::GetSystemUpdateIdL(
-    CUpnpAction*& aAction )
-    {
-    const TPtrC8 idValue = StateVariableValue( (TDesC8&)KSystemUpdateID );
-    aAction->SetArgumentL( KId, idValue );
-    return EHttpOk;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ImportResourceL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::ImportResourceL( CUpnpAction*& aAction )
-    {
-    if ( iTransferController->IsMaxImportExportTransfers( ) )
-        {
-        return ETransferBusy;
-        }
-
-    TPtrC8 src = aAction->ArgumentValue( (TDesC8&) KSourceURI );
-    TPtrC8 dest = aAction->ArgumentValue( (TDesC8&) KDestinationURI );
-    TUriParser8 srcParser;
-    TUriParser8 dstParser;
-
-    if ( !(dstParser.Parse( dest ) == 
-          KErrNone && dstParser.Extract( EUriScheme ).CompareF( UpnpHTTP::KSchemeHTTP8 ) == 0 ) )
-        {
-        User::Leave( ENoDestinationResource );
-        }
-
-    // there are placeholders instead the real values in the database
-    HBufC8* destBuf = InsertIpAndPortPlaceholderL( dest );
-    CleanupStack::PushL( destBuf );
-
-    TInt objId;
-    // object existence
-    if ( (objId
-            = iContentDirectoryDb->GetObjIdByAttrL( KImportUri8, *destBuf ) )
-            == KErrNotFound )
-        {
-        User::Leave( ENoDestinationResource );
-        }
-    // object restrictions
-    if ( iContentDirectoryDb->CheckObjectRestrictionL( objId )
-            == ERestrictedObject )
-        {
-        User::Leave( ERestrictedObject );
-        }
-    // parent restricions
-    if ( iContentDirectoryDb->CheckParentRestrictionL( objId ) != EUpnpOk )
-        {
-        User::Leave( ERestrictedParentObject );
-        }
-
-    TInt destinationCut = dest.LocateReverse( '/' );
-    if ( destinationCut < KErrNone )
-        {
-        User::Leave( EInvalidArgs );
-        }
-
-    HBufC* name = GetFileNameL( objId );
-    CleanupStack::PushL( name );
-    if ( !name )
-        {
-        User::Leave( ENoDestinationResource );
-        }
-
-    for ( TInt i( 0); i < iTransferController->iFileTransfers.Count( ) ; i++ )
-        {
-        if ( iTransferController->iFileTransfers[i]->ObjectId( ) == objId
-                && iTransferController->iFileTransfers[i]->TransferState( )
-                        == ETransferInProgress )
-            {
-            User::Leave( EDestinationAccess );
-            }
-        }
-
-    HBufC8* name8 = UpnpString::FromUnicodeL( *name );
-    CleanupStack::PushL( name8 );
-
-    TPtr8 fileNamePtr(name8->Des( ) );
-
-    HBufC16* fileNamePtr16 = UpnpString::ToUnicodeL( fileNamePtr );
-    CleanupStack::PushL( fileNamePtr16 );
-    TParse parseFilename;
-    parseFilename.Set( fileNamePtr16->Des( ), NULL, NULL );
-    HBufC16* diskNameTemp=parseFilename.Drive().Alloc( );
-    HBufC16* diskName = diskNameTemp->ReAlloc( diskNameTemp->Des().Length( ) +
-                                               KDiskPathElSep().Length( ) );
-    CleanupStack::PushL( diskName );
-    TPtr16 diskNamePtr = diskName->Des( );
-    diskNamePtr.Append( KDiskPathElSep );
-    if ( !BaflUtils::PathExists( iFs, diskNamePtr ) )
-        {
-        User::Leave( ENoDestinationResource );
-        }
-
-    UpnpString::ReplaceHttpCharacters( fileNamePtr );
-
-    // forbidden chars
-    UpnpCdUtils::ValidateFilePath( fileNamePtr );
-
-    HBufC* targetPath = HBufC::NewMaxLC( fileNamePtr.Length( ) );
-    TPtr targetPtr = targetPath->Des( );
-    targetPtr.Copy( fileNamePtr );
-
-    TInt transferid = CUpnpHttpMessage::NewSessionIdL( );
-    iTransferHandler->DownloadFileL( transferid, src, targetPtr );
-
-    CleanupStack::PopAndDestroy( targetPath );
-
-    TransferStartL( dest );
-
-    TBuf8<KMaxIntegerLen> tid;
-    tid.Num( transferid );
-    aAction->SetArgumentL( (TDesC8&)KTransferID, tid );
-
-    CUpnpFileTransfer* transfer = CUpnpFileTransfer::NewLC( transferid,
-        objId, CUpnpFileTransfer::EImport );
-
-    transfer->SetTransferState(:: ETransferInProgress );
-
-    // starting to get the number if import
-    TPtrC8 dest1 = aAction->ArgumentValue( (TDesC8&) KDestinationURI );
-    TInt posOfLastSlash = dest1.LocateReverse( '/' );
-    if( posOfLastSlash != KErrNotFound )
-        {
-        dest1.Set( dest1.Mid( posOfLastSlash + 1 ) );
-        // converting value
-        TLex8 string( dest1 );
-        TInt value( 0 );
-        TInt error = string.Val( value );
-        // conversion ok, we can add this to 
-        if( error == KErrNone )
-            {
-            transfer->SetImportNumber( value );
-            }
-        }
-    //add transfer to transfers list
-    CleanupStack::Pop( transfer );
-    iTransferController->iFileTransfers.Append( transfer );
-
-    HBufC* fileName16 = UpnpString::ToUnicodeL( *name8 );
-    CleanupStack::PushL( fileName16 );
-
-    CUpnpFileTransferEvent* event = CUpnpFileTransferEvent::NewLC();
-    event->SetProgressState( CUpnpFileTransferEvent::ECompleted );
-    event->SetDirection( CUpnpFileTransferEvent::EIncoming );
-    event->SetFilePathL( *fileName16 );
-    event->SetContentDirectoryObjectId( objId );
-    event->SetTransferId( transferid );
-    CleanupStack::Pop( event );
-    transfer->SetEvent( event );
-
-    AddFileTransferToTransferIDsStateVariableL( transferid );
-    // clean up
-    CleanupStack::PopAndDestroy( fileName16 );
-    CleanupStack::PopAndDestroy( diskName );
-    CleanupStack::PopAndDestroy( fileNamePtr16 );
-    CleanupStack::PopAndDestroy( name8 );
-    CleanupStack::PopAndDestroy( name );
-    CleanupStack::PopAndDestroy( destBuf );
-
-    return EHttpOk;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ExportResourceL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::ExportResourceL( CUpnpAction*& aAction )
-    {
- /*   if ( iTransferController->IsMaxImportExportTransfers( ) )
-        {
-        return ETransferBusy;
-        }
-    HBufC8* srcBuf = aAction->ArgumentValue( KSourceURI ).AllocLC( );
-    TPtr8 src(srcBuf->Des( ));
-    UpnpString::ReplaceHttpCharacters( src );
-
-    HBufC8* ipAndPort = GetIpAndPortDes8L( );
-    CleanupStack::PushL( ipAndPort );
-    UpnpCdUtils::ValidateSrcUriL( src, *ipAndPort );
-    CleanupStack::PopAndDestroy( ipAndPort );
-
-    TPtrC8 dest = aAction->ArgumentValue( KDestinationURI );
-
-    // check src existence -----------------------------
-    CUpnpResourcesBean* rscBean = NULL;
-    TRAPD(
-        error,
-        rscBean
-                = iContentDirectoryDb->GetResourceL( UpnpCdUtils::ResIdFromUriL( src ) ) );
-    if ( error < 0 || !rscBean )
-        {
-        User::Leave( ENoSourceResource );
-        }
-    CleanupStack::PushL( rscBean );
-    // check whether resource and src uri file names matches
-    TPtrC rscPath(rscBean->Path( ) );
-
-    if ( !BaflUtils::FileExists( iFs, rscPath ) )
-        {
-        User::Leave( ENoSourceResource );
-        }
-
-    TParse rscParse;
-    rscParse.Set( rscPath, NULL, NULL );
-    TPtrC rscFileName = rscParse.NameAndExt( );
-
-    TBuf8<KMaxIntegerLen> objId;
-    objId.Num( rscBean->ObjectId( ) );
-
-    TPtrC rscFileExt = rscParse.Ext( );
-    HBufC8* srcNoEsc = src.AllocLC( );
-    TPtr8 srcNoEscPtr(srcNoEsc->Des( ));
-
-    HBufC* srcPath = UpnpCdUtils::Des8ToDesLC( srcNoEscPtr );
-    TPtr srcPathPtr(srcPath->Des( ) );
-
-    TInt position = srcPathPtr.LocateReverse( '/' );
-    HBufC* newFileName = HBufC::NewLC( KMaxIntegerLen + rscFileExt.Length( ) );
-    newFileName->Des().Copy( objId );
-    newFileName->Des().Append( rscFileExt );
-    if ( position )
-        {
-        position = srcPathPtr.Length( )-position-1;
-        TPtrC srcFilePtr = srcPathPtr.Right( position );
-        if ( srcFilePtr.Compare( *newFileName ) )
-            {
-            User::Leave( ENoSourceResource );
-            }
-        }
-    if ( srcPathPtr.Find( *newFileName ) == KErrNotFound )
-        {
-        User::Leave( ENoSourceResource );
-        }
-    // get mimeType = Content-Type in the header
-    HBufC8* contentType = UpnpFileUtil::GetMimeTypeForFileL( *newFileName );
-    TPtrC8 contentTypePtr(contentType->Des( ) );
-
-    CleanupStack::PopAndDestroy( newFileName );
-    CleanupStack::PushL( contentType );
-
-    //checking number of slash in sourceURI 
-    TInt numberOfSlash(0);
-    position = srcPathPtr.LocateReverse( '/' );
-    while ( position>0 )
-        {
-        numberOfSlash++;
-        if ( numberOfSlash>KMaxSlashAmount )
-            {
-            User::Leave( ENoSourceResource );
-            }
-        srcPathPtr = srcPathPtr.Left( position );
-        position = srcPathPtr.LocateReverse( '/' );
-        }
-
-    TInt transferid = CUpnpHttpMessage::NewSessionIdL( );
-    iTransferHandler->UploadFileL( transferid, dest, rscPath, contentTypePtr );
-
-    TBuf8<KMaxIntegerLen> tid;
-    tid.Num( transferid );
-    aAction->SetArgumentL( (TDesC8&)KTransferID, tid );
-
-    TPtrC8 pert = UpnpCdUtils::ResIdFromUriDesL( src );
-
-    TInt objectId = rscBean->ObjectId( );
-    CUpnpFileTransfer* transfer = CUpnpFileTransfer::NewL( transferid,
-        objectId, CUpnpFileTransfer::EExport );
-    transfer->SetTransferState(:: ETransferInProgress);
-
-    iTransferController->iFileTransfers.Append( transfer );
-
-    CUpnpFileTransferEvent* event = CUpnpFileTransferEvent::NewLC();
-    event->SetProgressState( CUpnpFileTransferEvent::ECompleted );
-    event->SetDirection( CUpnpFileTransferEvent::EOutgoing );
-    event->SetFilePathL( rscPath);
-    event->SetContentDirectoryObjectId( objectId );
-    event->SetTransferId( transferid );
-    CleanupStack::Pop( event );
-    transfer->SetEvent(event);
-
-    AddFileTransferToTransferIDsStateVariableL( transferid );
-    CleanupStack::PopAndDestroy( contentType );
-    CleanupStack::PopAndDestroy( srcPath );
-    CleanupStack::PopAndDestroy( srcNoEsc );
-    CleanupStack::PopAndDestroy( rscBean );
-    CleanupStack::PopAndDestroy( srcBuf );
-*/
-    return EHttpOk;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::StopTransferResourceL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::StopTransferResourceL(
-    CUpnpAction*& aAction )
-    {
-    TInt transferId;
-    TInt err =
-            UpnpString::StringToInt(
-                (TDesC8&) aAction->ArgumentValue( (TDesC8&)KTransferID ),
-                &transferId );
-    if ( KErrNone != err )
-        {
-        User::Leave( ENoFileTransfer );
-        }
-    TUpnpErrorCode
-            upnpErr(iTransferController->StopTransferResourceL( transferId ) );
-    TransferCompletedL( transferId, KErrCancel );
-    return upnpErr;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetTransferProgressL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::GetTransferProgressL(
-    CUpnpAction*& aAction )
-    {
-    TUint transferId;
-    TInt length( KErrNone );
-    TInt totalLength( KErrNone );
-    // TInt lenght is max 15 digits, KMaxInfoName is 16
-    TBuf8<KMaxInfoName> res;
-
-    TInt err = UpnpCdUtils::StringToTUint(
-        (TDesC8&)aAction->ArgumentValue( (TDesC8&)KTransferID ), &transferId );
-
-    if ( KErrNone != err )
-        {
-        User::Leave( EInvalidArgs );
-        }
-    if ( transferId > KMaxTInt )
-        {
-        User::Leave( ENoFileTransfer );
-        }
-    TInt transferFound = iTransferController->Transfer( transferId );
-    if ( KErrNotFound == transferFound )
-        {
-        User::Leave( ENoFileTransfer );
-        }
-
-    switch ( (iTransferController->iFileTransfers[ transferFound ])->TransferState( ) )
-        {
-        case:: ETransferInProgress:
-            {
-            aAction->SetArgumentL( (TDesC8&)KTransferStatus, KInProgress );
-            break;
-            }
-        case EStopped:
-            {
-            aAction->SetArgumentL( (TDesC8&)KTransferStatus, KStopped );
-            break;
-            }
-        case EError:
-            {
-            aAction->SetArgumentL( (TDesC8&)KTransferStatus, KError );
-            break;
-            }
-        case ECompleted:
-            {
-            aAction->SetArgumentL( (TDesC8&)KTransferStatus, KCompleted );
-            break;
-            }
-        default:
-            {
-            break;
-            }
-        }
-    length = (iTransferController->iFileTransfers[ transferFound ])->TransferLength();
-    totalLength = (iTransferController->iFileTransfers[ transferFound ])->TransferTotal();
-
-    res.Num( length );
-    aAction->SetArgumentL( (TDesC8&)KTransferLength, res );
-    res.Num( totalLength );
-    aAction->SetArgumentL( (TDesC8&)KTransferTotal, res );
-    return EHttpOk;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::DeleteResourceL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::DeleteResourceL( CUpnpAction*& aAction )
-    {
-    TPtrC8 uri8(aAction->ArgumentValue( KResourceURI( ) ));
-
-    if ( !uri8.Length( ) )
-        User::Leave( ENoSourceResource );
-
-    // replace http characters
-    HBufC8* uri = uri8.AllocLC( );
-    TPtr8 uriPtr(uri->Des( ));
-
-    // ip placeholder
-    HBufC8* internalUri = InsertIpAndPortPlaceholderL( uriPtr );
-    CleanupStack::PushL( internalUri );
-    // delete resource
-    RArray<TInt> contIds;
-    CleanupClosePushL( contIds );
-    iContentDirectoryDb->DeleteResourceL( *internalUri, contIds );
-
-    // updateIDs
-    for ( TInt i = 0; i < contIds.Count( ); i++ )
-        {
-        TBuf8<KMaxIntegerLen> num;
-        num.Num( contIds[i] );
-        iStateHandler->IncreaseContainerUpdateIdL( num );
-        }
-
-    // systemUpdateId
-    iStateHandler->IncreaseSystemUpdateIdL( );
-
-    // clean up
-    CleanupStack::PopAndDestroy( &contIds );
-    CleanupStack::PopAndDestroy( internalUri );
-    CleanupStack::PopAndDestroy( uri );
-
-    return EHttpOk;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::AddFileTransferL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::AddFileTransferToTransferIDsStateVariableL(
-    TInt aTransferID )
-    {
-    TBuf8<KMaxIntegerLen> tid;
-    tid.Format( UpnpCD::KOneNumber, aTransferID );
-    TPtrC8 tmp = StateVariableValue( KTransferIDs( ) );
-    HBufC8* buf = UpnpString::AddValueToCsvL( tmp, tid );
-    CleanupStack::PushL( buf );
-    SetStateVariableL( KTransferIDs( ), *buf, EFalse );
-    CleanupStack::PopAndDestroy( buf );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::RemoveFileTransferL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::RemoveFileTransferFromTransferIDsStateVariableL(
-    TInt aTransferID )
-    {
-    TBuf8<KMaxIntegerLen> tid;
-    tid.Format( UpnpCD::KOneNumber, aTransferID );
-    TPtrC8 tmp = StateVariableValue( KTransferIDs( ) );
-    HBufC8* buf = UpnpString::RemoveFromCsvLC( tmp, tid );
-    SetStateVariableL( KTransferIDs( ), *buf, EFalse );
-    CleanupStack::PopAndDestroy( buf );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ContainerUpdateId
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectory::ContainerUpdateId( const TDesC8& aContainerID )
-    {
-    return iStateHandler->ContainerUpdateId( aContainerID );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateObjectL
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectory::CreateObjectL( CUpnpAction*& aAction )
-    {
-    SetExecutedAction( ECreateObjectAction );
-
-    HBufC8* objNoDes(aAction->ArgumentValue(KContainerID()).AllocLC( ) );
-    TPtr8 objNoPtr(objNoDes->Des( ));
-    objNoPtr.TrimAll( );
-
-    TInt objNo = KErrNotFound; // container id
-    TInt error( KErrGeneral );
-
-    // any container support
-    if ( !objNoPtr.Compare( KAnyContainerIndicator8 ) )
-        {
-        objNo = KAnyContainerId;
-        }
-    else
-        {
-        // checking whether containerID has proper decimal value
-        error = UpnpCdUtils::StringToInteger( objNoPtr, &objNo );
-        if ( error != KErrNone )
-            {
-            User::Leave( ENoContainer );
-            }
-
-        TUpnpErrorCode err =
-                iContentDirectoryDb->CheckObjectRestrictionL( objNo );
-        if ( err != EUpnpOk )
-            {
-            CleanupStack::PopAndDestroy( objNoDes );
-            if ( err == ENoSuchObject )
-                err = ENoContainer;
-            if ( err == ERestrictedObject )
-                err = ERestrictedParentObject;
-            return err;
-            }
-        }
-    CleanupStack::PopAndDestroy( objNoDes );
-
-    // now we have found the unrestricted parent container
-    // let's inspect the element that should be added
-    // decode "elements" argument of the create action
-    const TDesC8& elem = (TDesC8&)aAction->ArgumentValue( KElements( ) );
-
-    // check that we've got correctly formed xml
-    if ( elem.FindF( KXmlNsDc( ) ) == KErrNotFound )
-        {
-        User::Leave( EBadMetadata );
-        }
-
-    HBufC8* trimmed = UpnpString::TrimLC( elem, EFalse );
-
-    HBufC8* trimmedlf8 = UpnpString::StringReplaceL( *trimmed, KLF8,
-        KNullString8 );
-    CleanupStack::PushL( trimmedlf8 );
-    // parse decoded buffer
-    RXmlEngDocument fragment;
-    TRAPD( xmlerr, fragment = XmlFragmentL( *trimmedlf8 ) );
-    if ( xmlerr )
-        {
-        RDebug::Print( _L( "CUpnpContentDirectory::CreateObjectL ERROR IN XML" ) );
-        User::Leave( xmlerr );
-        }
-    CleanupClosePushL( fragment );
-
-    // if container, check the number of nested levels
-    TXmlEngElement container;
-    UpnpDomInterface::GetElementL( fragment.DocumentElement( ), container,
-        KContainer );
-    if ( container.NotNull( ) && !iContentDirectoryDb->CanBeNestedL( objNo ) )
-        {
-        User::Leave( ECannotProcess );
-        }
-
-    RArray<TXmlEngAttr> importUris;
-    CleanupClosePushL( importUris );
-    RArray<TXmlEngElement> ress;
-    CleanupClosePushL( ress );
-
-    TBool isLocal = aAction->Local( );
-
-    // to avoid errors in validation process
-    UpnpCdUtils::SetObjectIdL( UpnpCdUtils::GetObjectElementL( fragment ),
-        objNo ); // value does not matter - it will be changed later
-    UpnpCdUtils::SetContainerIdL( UpnpCdUtils::GetObjectElementL( fragment ),
-        objNo );
-
-    //created new object shouldn't have refID value
-    if ( UpnpCdUtils::HasRefIdL( fragment ) )
-        {
-        User::Leave( EParameterMismatch );
-        }
-
-    // validate the new element
-    iElementdb->ValidateNewObjectL( fragment.DocumentElement( ), ETrue,
-        isLocal );
-
-    // now we have fragment, lets add this to CD metadata
-    TInt id( KErrNotFound );
-    TUpnpErrorCode err = AddToMetaDbL( fragment, objNo, &id, isLocal );
-
-    CleanupStack::PopAndDestroy( &ress );
-    CleanupStack::PopAndDestroy( &importUris );
-
-    ConstructCreateResultsetL( aAction, fragment, id );
-
-    CleanupStack::PopAndDestroy( &fragment );
-    CleanupStack::PopAndDestroy( trimmedlf8 );
-    CleanupStack::PopAndDestroy( trimmed );
-
-    if ( err == EHttpOk )
-        {
-        iStateHandler->IncreaseSystemUpdateIdL( );
-        iStateHandler->IncreaseContainerUpdateIdL( 
-                             ( TDesC8& )aAction->ArgumentValue( KContainerID ) );
-
-        }
-    return err;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::HandleLocalResourcesL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::HandleLocalResourcesL( TXmlEngElement aRes,
-    TInt aObjectId )
-    {
-    // contentUri, contentPath          
-    TUriParser8 up;
-    TPtrC8 resVal = aRes.Text( );
-    if ( resVal.Length( ) )
-        {
-        TPtrC8 resValCandidatePtr(resVal);
-
-        // There should be no slash at the end of URI, if so -> leave occurs
-        if ( resValCandidatePtr.Length( ) > 0 )
-            {
-            if ( !resValCandidatePtr.Right(1).Compare( KSlash8( ) ) )
-                {
-                User::Leave( EBadMetadata );
-                }
-            }
-
-        User::LeaveIfError( up.Parse( resValCandidatePtr ) );
-
-        // get schema
-        TPtrC8 scheme(up.Extract( EUriScheme ));
-
-        // only local sharing
-        if ( !scheme.Compare( UpnpHTTP::KSchemeFile8 ) )
-            {
-            HBufC* fn = UpnpString::ToUnicodeL( resValCandidatePtr );
-            CleanupStack::PushL( fn );
-
-            TInt extPosition = fn->Des().LocateReverse( '.' );
-            TPtrC ext;
-            if ( extPosition>0 )
-                ext.Set( fn->Des().Mid( extPosition ) );
-            else
-                ext.Set( KNullString );
-
-            HBufC8* contentUri = BuildContentUriL( ext, aObjectId );
-            CleanupStack::PushL( contentUri );
-
-            HBufC* contentPath = up.GetFileNameL( );
-            CleanupStack::PushL( contentPath );
-
-            // update res tag
-            aRes.SetTextL( *contentUri );
-
-            // add resource to the database
-            CUpnpResourcesBean* resBn = CUpnpResourcesBean::NewLC( );
-            resBn->SetId( UpnpCdUtils::ResIdFromUriL( *contentUri ) );
-            resBn->SetPathL( *contentPath );
-            resBn->SetIsReadonly( ETrue );
-            resBn->SetIsThumbnail( EFalse );
-
-            iContentDirectoryDb->AddResourceL( resBn, aObjectId );
-
-            // clean up
-            CleanupStack::PopAndDestroy( resBn );
-            CleanupStack::PopAndDestroy( contentPath );
-            CleanupStack::PopAndDestroy( contentUri );
-            CleanupStack::PopAndDestroy( fn );
-            }
-        // else -> ignore
-        }
-    // else -> ignore
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ConstructCreateResultsetL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::ConstructCreateResultsetL( CUpnpAction*& aAction,
-    RXmlEngDocument aDocument, TInt aId )
-    {
-    TBuf8<KMaxIntegerLen> num;
-    num.Num( aId );
-
-    aAction->SetArgumentL( KObjectID, num );
-    TXmlEngElement elem = aDocument.DocumentElement( );
-
-    HBufC8* buf = CUpnpXmlContentFilter::SerializeLC( aDocument, elem );
-
-    TPtr8 bufPtr(buf->Des( ));
-    InsertRealIpAndPortL( bufPtr );
-    HBufC8* encoded = UpnpCdUtils::EncodeXmlStringL( bufPtr );
-    CleanupStack::PushL( encoded );
-
-    aAction->SetArgumentL( KResult, *encoded );
-
-    CleanupStack::PopAndDestroy( encoded );
-    CleanupStack::PopAndDestroy( buf );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::XmlFragmentL
-// -----------------------------------------------------------------------------
-//
-RXmlEngDocument CUpnpContentDirectory::XmlFragmentL( const TDesC8 &aBuffer )
-    {
-    //Create a parser
-    RXmlEngDOMParser parser;
-    User::LeaveIfError( parser.Open( iDOMImpl ) );
-    CleanupClosePushL( parser );
-    // DOM document
-    RXmlEngDocument docTree;
-
-    if ( aBuffer.FindF( KXmlNsDc( ) ) == KErrNotFound )
-        {
-        HBufC8* withDidl = HBufC8::NewLC( KDidlTag().Length( ) + aBuffer.Length( ) +
-                                          KDidlEnd().Length( ) );
-        withDidl->Des().Append( KDidlTag( ) );
-        withDidl->Des().Append( aBuffer );
-        withDidl->Des().Append( KDidlEnd( ) );
-
-        docTree = parser.ParseL( *withDidl );
-        CleanupStack::PopAndDestroy( withDidl );
-        }
-    else
-        {
-        docTree = parser.ParseL( aBuffer );
-        }
-    CleanupStack::PopAndDestroy( &parser );
-    return docTree;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetMimeTypeLC
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpContentDirectory::GetMimeTypeLC( const TDesC8& aFilename )
-    {
-    HBufC16* filename16 = UpnpString::ToUnicodeL( aFilename );
-    CleanupStack::PushL( filename16 );
-    HBufC8* mimetype = UpnpFileUtil::GetMimeTypeForFileL( *filename16 );
-    if ( !mimetype )
-        {
-        mimetype = KNullString8().AllocL( );
-        }
-    CleanupStack::PopAndDestroy( filename16 );
-    CleanupStack::PushL( mimetype );
-    return mimetype;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ChangeFileNameWithExtensionL
-// -----------------------------------------------------------------------------
-HBufC8* CUpnpContentDirectory::ChangeFileNameWithExtensionL(
-    TDesC8& aFilePath, const TDesC8& aMimeType )
-    {
-
-    HBufC8* temp = NULL;
-    TInt position = aFilePath.LocateReverse( '.' );
-    if ( position != KErrNotFound )
-        {
-        return temp;
-        }
-    if ( aMimeType == KNullDesC8 )
-        {
-        return temp;
-        }
-
-    HBufC8* ext = iMimeToExtMap->GetExtensionL( aMimeType );
-    if ( ext == NULL )
-        {
-        return temp;
-        }
-    CleanupStack::PushL( ext );
-    HBufC8* newFilename = HBufC8::NewLC( ext->Length( ) + 1
-            + aFilePath.Length( ) );
-    TPtr8 fileNamePtr(newFilename->Des( ) );
-    fileNamePtr.Append( aFilePath );
-    //fileNamePtr.Append( KDot8());
-    fileNamePtr.Append( *ext );
-
-    HBufC* oldFilename16 = HBufC::NewLC( aFilePath.Length( ) );
-    TPtr oldFilename16Ptr(oldFilename16->Des( ));
-    oldFilename16Ptr.Copy( aFilePath );
-
-    HBufC* newFilename16 = HBufC::NewLC( newFilename->Length( ) );
-    TPtr newFilename16Ptr(newFilename16->Des( ));
-    newFilename16Ptr.Copy( *newFilename );
-
-    TBool exists = BaflUtils::FileExists( iFs, *newFilename16 );
-    if ( exists )
-        {
-        TInt error( KErrNone );
-        TInt count( 0);
-        _LIT( KUnderline, "_" );
-
-        CleanupStack::PopAndDestroy( newFilename16 );
-        newFilename16 = NULL;
-
-        HBufC16* ext16 = HBufC16::NewLC( ext->Length( ) );
-        ext16->Des().Copy( *ext );
-
-        TBuf<KMaxIntegerLen> value;
-        newFilename16 = HBufC16::NewLC( aFilePath.Length( ) + KMaxIntegerLen
-                + ext16->Length( ) + KUnderline().Length( ) + KDot().Length( ) );
-        for ( ;; )
-            {
-            // name_xxxxx.ext
-            value.Num( count );
-
-            newFilename16->Des().Copy( aFilePath );
-            newFilename16->Des().Append( KUnderline );
-            newFilename16->Des().Append( value );
-            //adding dot is not not needed anymore
-            newFilename16->Des().Append( *ext16 );
-
-            RFile file;
-            error = file.Open( iFs, *newFilename16, EFileShareExclusive );
-            file.Close( );
-
-            if ( error == KErrNotFound )
-                {
-                break;
-                }
-            else
-                {
-                count++;
-                }
-            }
-        CleanupStack::Pop( newFilename16 );
-        CleanupStack::PopAndDestroy( ext16 );
-        CleanupStack::PushL( newFilename16 );
-        }
-
-    TInt result = iFs.Rename( *oldFilename16, *newFilename16 );
-    if ( result == KErrNone )
-        {
-        temp = HBufC8::NewL( newFilename16->Length( ) );
-        temp->Des().Copy( *newFilename16 );
-
-        }
-    CleanupStack::PopAndDestroy( newFilename16 );
-    CleanupStack::PopAndDestroy( oldFilename16 );
-    CleanupStack::PopAndDestroy( newFilename );
-    CleanupStack::PopAndDestroy( ext );
-
-    return temp;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateResTagWithDBRecoveyrL
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectory::CreateResTagInternalWithDBRecoveryL(
-    TInt aSessionId, TDesC8& aFilePath, HBufC8* aImportUri,
-    TBool aOnlyThumbnail )
-    {
-    TInt result = 0;
-    TRAPD( err, result = CreateResTagInternalL( aSessionId, aFilePath,
-        aImportUri, aOnlyThumbnail ) );
-    if ( err )
-        {
-        if ( DataBaseHasBeenRecoveredL( err ) )
-            {
-            TRAP( err, iContentDirectoryDb->CheckDatabaseL( ) );
-            if ( err == KErrCorrupt )
-                {
-                err = iContentDirectoryDb->RecreateDatabaseFile( );
-                User::LeaveIfError( err );
-                }
-            TRAP( err, result = CreateResTagInternalL( aSessionId, aFilePath,
-                aImportUri, aOnlyThumbnail ) );
-            if ( err == KErrCorrupt )
-                {
-                err = iContentDirectoryDb->RecreateDatabaseFile( );
-                }
-            }
-        User::LeaveIfError( err );
-        }
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateResTagInternalL
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectory::CreateResTagInternalL( TInt aSessionId,
-    TDesC8& aFilePath, HBufC8* aImportUri, TBool aOnlyThumbnail )
-    {
-    TInt ret = KErrGeneral;
-    HBufC8* number = UpnpCdUtils::RandomizeL( KRandomMax );
-    CleanupStack::PushL( number );
-    HBufC8* number2 = UpnpCdUtils::RandomizeL( KRandomMax );
-    CleanupStack::PushL( number2 );
-    HBufC8* importRandomize = HBufC8::NewLC( aImportUri->Des().Length( )+number->Des().Length( ) );
-    importRandomize->Des().Copy( *aImportUri );
-    importRandomize->Des().Replace( importRandomize->Length( ) - 4, 4, *number2 );
-    importRandomize->Des().Append( *number );
-
-    RXmlEngDocument obj;
-    TInt objId = KErrNotFound;
-    iContentDirectoryDb->GetObjectByAttrL( obj, &objId, KImportUri8,
-        *aImportUri );
-    CleanupClosePushL( obj );
-
-    if ( !obj.NotNull( ) )
-        {
-        CleanupStack::PopAndDestroy( &obj );
-        CleanupStack::PopAndDestroy( importRandomize );
-        CleanupStack::PopAndDestroy( number2 );
-        CleanupStack::PopAndDestroy( number );
-        return ret;
-        }
-
-    HBufC8* mimeType = GetMimeTypeLC( aFilePath );
-    // CheckFileName 
-    HBufC8* newName = ChangeFileNameWithExtensionL( aFilePath, *mimeType );
-    if ( !newName )
-        {
-        // renaming file failed, set the old  name
-        newName = HBufC8::NewL( aFilePath.Length( ) );
-        newName->Des().Copy( aFilePath );
-        }
-    CleanupStack::PushL( newName );
-
-    TSize objectSize( 0, 0);
-
-    //GetFileName
-    HBufC16* filename16 = UpnpString::ToUnicodeL( *newName );
-    CleanupStack::PushL( filename16 );
-
-    if ( obj.NotNull( ) && !aOnlyThumbnail )
-        {
-        // if there is already a file related to this importUri delete it
-        DeleteOldResourcesL( obj, *aImportUri, *filename16 );
-
-        // set new contentUri
-        TXmlEngElement objEl = obj.DocumentElement( );
-
-        TPtrC8 fileNamePtr =
-                newName->Mid( newName->LocateReverse( '\\' ) + 1 );
-
-        TInt extPosition = fileNamePtr.LocateReverse( '.' );
-        TPtrC8 ext;
-        if ( extPosition>0 )
-            ext.Set( fileNamePtr.Mid( extPosition ) );
-        else
-            ext.Set( KNullString8 );
-        HBufC8* contUri = HBufC8::NewLC( importRandomize->Length( ) + KSlash().Length( ) +
-                                         KMaxLongIntegerLen + ext.Length( ) );
-        TPtr8 contUriPtr(contUri->Des( ));
-        contUriPtr.Copy( *importRandomize );
-        contUriPtr.Append( KSlash );
-
-        TBuf8<KMaxLongIntegerLen> num;
-        num.Num( objId );
-        contUriPtr.Append( num );
-        contUriPtr.Append( ext );
-
-        TXmlEngElement resEl;
-        UpnpDomInterface::GetDirectoryElementL( objEl, resEl, KRes( ),
-            KImportUri8( ), aImportUri->Des( ) );
-        resEl.SetTextL( contUriPtr );
-
-        CleanupStack::PopAndDestroy( contUri );
-
-        // set res@size  
-        TXmlEngAttr size = resEl.AttributeNodeL( KSize( ) );
-        if ( size.NotNull( ) )
-            {
-            SetResSizeL( size, *filename16 );
-            }
-
-        // set res@protocolInfo
-        HBufC8* protocolInfo =
-                ProtocolInfoFromMimeL( mimeType->Des( ), resEl );
-        CleanupStack::PushL( protocolInfo );
-
-        TXmlEngAttr protInf = resEl.AttributeNodeL( KprotocolInfo( ) );
-        protInf.SetValueL( *protocolInfo );
-
-        CleanupStack::PopAndDestroy( protocolInfo );
-
-        CheckItemTypeForObjectL( obj, *mimeType );
-
-        RemoveFileTransferFromTransferIDsStateVariableL( aSessionId );
-
-        // update database
-        iElementdb->ValidateNewObjectL( obj.DocumentElement( ), EFalse );
-        iContentDirectoryDb->UpdateObjectL( objId, obj );
-
-        // add resource
-        CUpnpResourcesBean* resBn = CUpnpResourcesBean::NewLC( );
-        resBn->SetId( UpnpCdUtils::ResIdFromUriL( *importRandomize ) );
-        resBn->SetPathL( *newName );
-        resBn->SetIsReadonly( EFalse );
-        resBn->SetIsThumbnail( EFalse );
-        iContentDirectoryDb->AddResourceL( resBn, objId );
-        // clean up
-        CleanupStack::PopAndDestroy( resBn );
-        ret = KErrNone;
-        }
-
-    //send event to Media server      
-
-
-    CUpnpFileTransferEvent* event =
-            iTransferController->TransferL( aSessionId );
-
-    if ( event )
-        {
-        event->SetFilePathL( *filename16 );
-        //CleanupStack::Pop( event);
-        //iEventObserver->FileTransferEvent( event );
-        }
-
-    // create thumbnail
-    CreateThumbnailL( *filename16, objId );
-
-    // clean up
-    CleanupStack::PopAndDestroy( filename16 );
-    CleanupStack::PopAndDestroy( newName );
-    CleanupStack::PopAndDestroy( mimeType );
-    CleanupStack::PopAndDestroy( &obj );
-    CleanupStack::PopAndDestroy( importRandomize );
-    CleanupStack::PopAndDestroy( number2 );
-    CleanupStack::PopAndDestroy( number );
-
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::SetResSizeL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::SetResSizeL( TXmlEngAttr aSize,
-    const TDesC& aFilePath )
-    {
-    // get file size
-    RFile file;
-    CleanupClosePushL( file );
-    User::LeaveIfError( file.Open( iFs, aFilePath, EFileRead|EFileShareAny ) );
-    TInt size;
-    User::LeaveIfError( file.Size( size ) );
-
-    // set size
-    TBuf8<KMaxLongIntegerLen> num;
-    num.Num( size );
-    aSize.SetValueL( num );
-
-    CleanupStack::PopAndDestroy( &file );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::DeleteOldResourcesL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::DeleteOldResourcesL( RXmlEngDocument& aObj,
-    const TDesC8& aImportUri, const TDesC& aNewFile )
-    {
-    // for main res tag delete only corresponding record in the resources table
-    TXmlEngElement el;
-    UpnpDomInterface::GetDirectoryElementL( aObj.DocumentElement( ), el,
-        KImportUri8( ), aImportUri );
-    if ( el.NotNull( ) ) //  should always be true
-        {
-        TPtrC8 resVal(UpnpDomInterface::GetElementValueL( el ));
-        if ( resVal.Length( ) )
-            {
-            TInt64 resId = UpnpCdUtils::ResIdFromUriL( resVal ) ;
-            // check src existence -----------------------------
-            CUpnpResourcesBean* rscBean = NULL;
-            rscBean = iContentDirectoryDb->GetResourceL( resId );
-            TBool deletefile = ETrue;
-            //checking if a new file is the same as the old one
-            //if so, it means the old one was by chance deleted from the file system
-            if ( rscBean )
-                {
-                TPtrC rscPath(rscBean->Path( ) );
-                if ( !rscPath.Compare( aNewFile ) )
-                    deletefile = EFalse;
-                delete rscBean;
-                }
-            iContentDirectoryDb->DeleteResourceByResIdL( resId, deletefile );
-            }
-
-        }
-
-    // destroy all other res tags   
-    RArray<TXmlEngElement> elms;
-    CleanupClosePushL( elms );
-    UpnpDomInterface::GetElementListL( aObj.DocumentElement( ), elms, KRes );
-    // for each element
-    for ( TInt i=0; i < elms.Count( ); i++ )
-        {
-        TXmlEngAttr impUri(elms[i].AttributeNodeL( KImportUri( ) ) );
-        if ( impUri.IsNull( ) && !el.IsSameNode( elms[i] ) )
-            {
-            TPtrC8 resVal(UpnpDomInterface::GetElementValueL( elms[i] ));
-            if ( resVal.Length( ) )
-                {
-                iContentDirectoryDb->DeleteResourceByResIdL( 
-                                                        UpnpCdUtils::ResIdFromUriL( resVal ) );
-                }
-            elms[i].Remove( );
-            }
-        }
-    CleanupStack::PopAndDestroy( &elms );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateThumbnailCreatorL
-// -----------------------------------------------------------------------------
-//
-CUpnpThumbnailCreator* CUpnpContentDirectory::CreateThumbnailCreatorL(
-    TInt aObjectId )
-    {
-    CUpnpThumbnailCreator* thumbCreator = NULL;
-
-    if ( iBitmapServerConnection == KErrNone )
-        {
-        //check if from the file THUMB can be created. 
-        //create thumbnail 
-        // in thumbnail save the information. 
-        thumbCreator = CUpnpThumbnailCreator::NewLC( this );
-        iThumbnailCreators.AppendL( thumbCreator );
-        TInt index = iThumbnailCreators.Find( thumbCreator );
-        User::LeaveIfError( index );
-        iThObjectIds.InsertL( aObjectId, index );
-        CleanupStack::Pop( thumbCreator );
-        }
-    return thumbCreator;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::RemoveThCreatorAndObjectIdLD
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::RemoveThCreatorAndObjectIdLD(
-    CUpnpThumbnailCreator* aThCreator )
-    {
-    TInt index = iThumbnailCreators.Find( aThCreator );
-    if ( index == KErrNotFound )
-        {
-        RDebug::Print( _L( "There is no corresponding thCreator in list. Error situation." ) );
-        delete aThCreator;
-        return;
-        }
-    else
-        {
-        iThumbnailCreators.Remove( index );
-        }
-    if ( index < iThObjectIds.Count( ) )
-        {
-        iThObjectIds.Remove( index );
-        }
-    delete aThCreator;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetObjectIdFromThCreator
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectory::GetObjectIdFromThCreator(
-    CUpnpThumbnailCreator* aThCreator )
-    {
-    TInt result = KErrNotFound;
-    TInt index = iThumbnailCreators.Find( aThCreator );
-    RDebug::Print( _L( "Whole number of objects. %d" ) ,
-        iThObjectIds.Count( ) );
-    if ( index < iThObjectIds.Count( ) )
-        {
-        result = iThObjectIds[index];
-        }
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::NotifyThumbnailResultL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::NotifyThumbnailResultL(
-    CUpnpThumbnailCreator* aThCreator, TInt aResult )
-    {
-    TInt result = aResult;
-    RDebug::Print( _L( "Thumbnail has been created with result: %d" ),
-        aResult );
-    if ( aResult == KErrNone )
-        {
-        RXmlEngDocument obj;
-        CleanupClosePushL( obj );
-        TInt objectId = GetObjectIdFromThCreator( aThCreator );
-        TInt err =
-                iContentDirectoryDb->GetObjectL( objectId, obj, KAsterisk8 );
-        if ( err == EUpnpOk )
-            {
-            // get item element
-            TXmlEngElement objElement;
-            UpnpDomInterface::GetElementL( obj.DocumentElement( ),
-                objElement, KItem );
-
-            // add new res tag
-            TXmlEngElement thumbRes(objElement.AddNewElementL( KRes( ) ) );
-
-            // add protocolInfo
-            HBufC8* protocolInfo = ProtocolInfoFromMimeL( KThumbMimeType( ),
-                JPEG_TN, ETrue, ETrue );
-            CleanupStack::PushL( protocolInfo );
-            thumbRes.AddNewAttributeL( KprotocolInfo( ), *protocolInfo );
-            CleanupStack::PopAndDestroy( protocolInfo );
-
-            // add contentUri
-            HBufC8* contUri = BuildContentUriL( aThCreator->GetFileExt( ),
-                objectId );
-            CleanupStack::PushL( contUri );
-            thumbRes.SetTextL( *contUri );
-
-            // add new resource
-            CUpnpResourcesBean* resBean = CUpnpResourcesBean::NewLC( );
-            resBean->SetId( UpnpCdUtils::ResIdFromUriL( *contUri ) );
-            resBean->SetPathL( aThCreator->GetPath( ) );
-            resBean->SetIsReadonly( EFalse );
-            resBean->SetIsThumbnail( ETrue );
-            iContentDirectoryDb->AddResourceL( resBean, objectId );
-
-            // update
-            iElementdb->ValidateNewObjectL( obj.DocumentElement( ), EFalse );
-            iContentDirectoryDb->UpdateObjectL( objectId, obj );
-            RemoveThCreatorAndObjectIdLD( aThCreator );
-
-            // clean up
-            CleanupStack::PopAndDestroy( resBean );
-            CleanupStack::PopAndDestroy( contUri );
-            }
-        else
-            {
-            // delete thumbnail file if exists
-            iFs.Delete( aThCreator->GetPath( ) ); // ignore errors
-            // remove thCreator and objectID from list 
-            RemoveThCreatorAndObjectIdLD( aThCreator );
-            result = err;
-            }
-        CleanupStack::PopAndDestroy( &obj );
-        }
-    else
-        {
-        // delete thumbnail file if exists
-        iFs.Delete( aThCreator->GetPath( ) ); // ignore errors
-        // remove thCreator and objectID from list 
-        RemoveThCreatorAndObjectIdLD( aThCreator );
-        }
-
-    // notify
-    if ( iThmbObs )
-        {
-        iThmbObs->NotifyThumbnailResultL( 0, result );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateResTagL
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectory::CreateResTagL( TInt aSessionId,
-    TDesC8& aFilePath, TInt aImportNumber, TBool aOnlyThumbnail )
-    {
-    HBufC8* importUri = UpnpCdUtils::BuildImportUriLC( aImportNumber );
-    TInt ret = CreateResTagInternalWithDBRecoveryL( aSessionId, aFilePath,
-        importUri, aOnlyThumbnail );
-    CleanupStack::PopAndDestroy( importUri );
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ProtocolInfoFromMimeLC
-// -----------------------------------------------------------------------------
-//
-CUpnpDlnaProtocolInfo* CUpnpContentDirectory::CreateProtocolInfoFromMimeL(
-    const TDesC8& aMimeType, TInt aAddInfo )
-    {
-    CUpnpProtocolInfoLocal* protInfo = CUpnpProtocolInfoLocal::NewL(
-        aMimeType, aAddInfo );
-    CleanupStack::PushL( protInfo );
-    protInfo->SetThirdFieldL( aMimeType );
-    CleanupStack::Pop( protInfo );
-    return protInfo;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ProtocolInfoFromMimeL
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpContentDirectory::ProtocolInfoFromMimeL(
-    const TDesC8& aMimeType, TInt aAddInfo, TBool aOpRangeParam,
-    TBool aCiParam /*= EFalse*/)
-    {
-    CUpnpDlnaProtocolInfo* protInfo = CreateProtocolInfoFromMimeL( aMimeType,
-        aAddInfo );
-    if ( aCiParam )
-        {
-        protInfo->SetCiParameter( ETrue );
-        }
-    if ( aOpRangeParam )
-        {
-        protInfo->SetOpParameterL( B_VAL, ETrue );
-        }
-
-    CleanupStack::PushL( protInfo );
-    TPtrC8 protocolInfo = protInfo->ProtocolInfoL( );
-    HBufC8* protocolInfoDes = protocolInfo.Alloc( );
-    CleanupStack::PopAndDestroy( protInfo );
-    return protocolInfoDes;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ProtocolInfoFromMimeL
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpContentDirectory::ProtocolInfoFromMimeL(
-    const TDesC8& aMimeType, TXmlEngElement& aResEl )
-    {
-    HBufC8* result = NULL;
-    const TDesC8& value = UpnpDomInterface::GetAttrValueL( aResEl,
-        KprotocolInfo );
-    if ( aMimeType.Length( ) > 0 )
-        {
-        if ( value.Length( ) )
-            {
-            CUpnpDlnaProtocolInfo* protocolInfo =
-                    CUpnpDlnaProtocolInfo::NewL( (TDesC8&) value );
-            CleanupStack::PushL( protocolInfo );
-            TPtrC8 third = protocolInfo->ThirdField( );
-            if ( !(aMimeType == third ) )
-                {
-                protocolInfo->SetThirdFieldL( (TDesC8&)aMimeType );
-                protocolInfo->SetFourthFieldL( KAsterisk8( ) );
-                }
-            TPtrC8 protInfo = protocolInfo->ProtocolInfoL( );
-            result = protInfo.Alloc( );
-            CleanupStack::PopAndDestroy( protocolInfo );
-            }
-        }
-    else
-        {
-        result = value.AllocL( );
-        }
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetFileNameL
-// -----------------------------------------------------------------------------
-//
-HBufC* CUpnpContentDirectory::GetFileNameL( TInt aObjId )
-    {
-    TInt objId = aObjId;
-    HBufC* result = NULL;
-    RXmlEngDocument objDidl;
-    iContentDirectoryDb->GetObjectL( objId, objDidl, KAsterisk8( ) );
-    CleanupClosePushL( objDidl );
-    TXmlEngElement obj = objDidl.DocumentElement().FirstChild().AsElement( );
-    if ( obj.IsNull( ) )
-        {
-        CleanupStack::PopAndDestroy( &objDidl );
-        return NULL;
-        }
-
-    // file name
-    TXmlEngElement objTitle;
-    UpnpDomInterface::GetElementL( obj, objTitle, KObjTiltleColName8( ) );
-    if ( objTitle.IsNull( ) )
-        {
-        CleanupStack::PopAndDestroy( &objDidl );
-        return NULL;
-        }
-
-    // mime type
-    RArray<TXmlEngElement> reses;
-    CleanupClosePushL( reses );
-    UpnpDomInterface::GetElementListL( obj, reses, KRes );
-    HBufC8* mimeType = NULL;
-    for ( TInt i = 0; i < reses.Count( ); i++ )
-        { // should be only one importUri
-        TXmlEngAttr impUri;
-        impUri = reses[i].AttributeNodeL( KImportUri );
-        if ( impUri.NotNull( ) )
-            {
-            TXmlEngAttr prInfoAttr = reses[i].AttributeNodeL( KprotocolInfo );
-            CUpnpDlnaProtocolInfo* prInfo =
-                    CUpnpDlnaProtocolInfo::NewL( prInfoAttr.Value( ) );
-            CleanupStack::PushL( prInfo );
-            mimeType = prInfo->ThirdField().AllocL( );
-            CleanupStack::PopAndDestroy( prInfo );
-            break;
-            }
-        }
-    CleanupStack::PopAndDestroy( &reses );
-
-    TPtrC ext;
-    if ( mimeType )
-        {
-        TPtrC8 mimeTypeCut( *mimeType);
-        TInt position = mimeType->Des().Find( KSemicolon8 );
-        if ( position != KErrNotFound )
-            {
-            mimeTypeCut.Set( mimeType->Des().Left( position ) );
-            }
-
-        const HBufC* tmp = iMimeToExtMap->Get( mimeTypeCut );
-        if ( tmp )
-            {
-            ext.Set( tmp->Ptr( ), tmp->Length( ) ); // do not delete
-            }
-        delete mimeType;
-        }
-
-    result = HBufC::NewLC( objTitle.Value().Length( ) + ext.Length( ) );
-    TPtr resPtr(result->Des( ) );
-    HBufC* title = UpnpCdUtils::Des8ToDesLC( objTitle.Value( ) );
-
-    resPtr.Copy( *title );
-
-    TInt wholeNameLength = title->Des().LocateReverse( '.' );
-    TInt extenLength = title->Length( )-wholeNameLength;
-    TPtrC exten;
-    if ( extenLength )
-        {
-        exten.Set( title->Right( extenLength ) );
-        }
-
-    if ( ext.CompareF( exten ) != 0 )
-        {
-        resPtr.Append( ext );
-        }
-
-    // forbidden chars
-    UpnpCdUtils::ValidateFilePath( resPtr );
-
-    HBufC* basePath = HBufC::NewL( iDownloadDir->Des().Length( ) + result->Des().Length( ) );
-    basePath -> Des().Append( iDownloadDir->Des( ) );
-    basePath -> Des().Append( result->Des( ) );
-
-    CleanupStack::PopAndDestroy( title );
-    CleanupStack::PopAndDestroy( result );
-    CleanupStack::PopAndDestroy( &objDidl );
-
-    if ( BaflUtils::FileExists( iFs, *basePath ) )
-        {
-        CleanupStack::PushL( basePath );
-        HBufC* fileName = CreateFileNameL( basePath->Des( ) );
-        CleanupStack::PopAndDestroy( basePath );
-        return fileName;
-        }
-
-    return basePath;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetFileNameWithoutPathL
-// -----------------------------------------------------------------------------
-//
-HBufC* CUpnpContentDirectory::GetFileNameWithoutPathL( TInt aObjId )
-    {
-    TInt objId = aObjId;
-    HBufC* result = NULL;
-    RXmlEngDocument objDidl;
-    iContentDirectoryDb->GetObjectL( objId, objDidl, KAsterisk8( ) );
-    CleanupClosePushL( objDidl );
-    TXmlEngElement obj = objDidl.DocumentElement().FirstChild().AsElement( );
-    if ( obj.IsNull( ) )
-        {
-        CleanupStack::PopAndDestroy( &objDidl );
-        return NULL;
-        }
-
-    // file name
-    TXmlEngElement objTitle;
-    UpnpDomInterface::GetElementL( obj, objTitle, KObjTiltleColName8( ) );
-    if ( objTitle.IsNull( ) )
-        {
-        CleanupStack::PopAndDestroy( &objDidl );
-        return NULL;
-        }
-
-    // mime type
-    RArray<TXmlEngElement> reses;
-    CleanupClosePushL( reses );
-    UpnpDomInterface::GetElementListL( obj, reses, KRes );
-    HBufC8* mimeType = NULL;
-    for ( TInt i = 0; i < reses.Count( ); i++ )
-        { // should be only one importUri
-        TXmlEngAttr impUri;
-        impUri = reses[i].AttributeNodeL( KImportUri );
-        if ( impUri.NotNull( ) )
-            {
-            TXmlEngAttr prInfoAttr = reses[i].AttributeNodeL( KprotocolInfo );
-            CUpnpDlnaProtocolInfo* prInfo =
-                    CUpnpDlnaProtocolInfo::NewL( prInfoAttr.Value( ) );
-            CleanupStack::PushL( prInfo );
-            mimeType = prInfo->ThirdField().AllocL( );
-            CleanupStack::PopAndDestroy( prInfo );
-            break;
-            }
-        }
-    CleanupStack::PopAndDestroy( &reses );
-
-    TPtrC ext;
-    if ( mimeType )
-        {
-        TPtrC8 mimeTypeCut(*mimeType);
-        TInt position = mimeType->Des().Find( KSemicolon8 );
-        if ( position != KErrNotFound )
-            {
-            mimeTypeCut.Set( mimeType->Des().Left( position ) );
-            }
-
-        const HBufC* tmp = iMimeToExtMap->Get( mimeTypeCut );
-        if ( tmp )
-            {
-            ext.Set( tmp->Ptr( ), tmp->Length( ) ); // do not delete
-            }
-        delete mimeType;
-        }
-
-    result = HBufC::NewLC( objTitle.Value().Length( ) + ext.Length( ) );
-    TPtr resPtr(result->Des( ));
-    HBufC* title = UpnpCdUtils::Des8ToDesLC( objTitle.Value( ) );
-
-    resPtr.Copy( *title );
-
-    TInt wholeNameLength = title->Des().LocateReverse( '.' );
-    TInt extenLength = title->Length( )-wholeNameLength;
-    TPtrC exten;
-    if ( extenLength )
-        {
-        exten.Set( title->Right( extenLength ) );
-        }
-
-    if ( ext.CompareF( exten )!=0 )
-        resPtr.Append( ext );
-
-    // forbidden chars
-    UpnpCdUtils::ValidateFilePath( resPtr );
-
-    // clean up
-    CleanupStack::PopAndDestroy( title );
-    CleanupStack::Pop( result );
-    CleanupStack::PopAndDestroy( &objDidl );
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateFileNameL
-// -----------------------------------------------------------------------------
-//
-HBufC* CUpnpContentDirectory::CreateFileNameL( const TDesC16& aFileName )
-    {
-    const TInt KMaxSameFileNames = 10000;
-    TParse parseFilename;
-    parseFilename.Set( aFileName, NULL, NULL );
-
-    // orginal file + underscore + number 
-    HBufC* name = HBufC::NewLC( aFileName.Length( ) + KMaxIntegerLen );
-    TPtr namePtr(name->Des( ) );
-
-    for ( TInt count = 1; count < KMaxSameFileNames; count++ )
-        {
-        TBuf<KMaxIntegerLen> value;
-        value.Num( count );
-
-        namePtr.Append( parseFilename.DriveAndPath( ) );
-        namePtr.Append( parseFilename.Name( ) );
-        namePtr.Append( KUndersc( ) );
-        namePtr.Append( value );
-        namePtr.Append( parseFilename.Ext( ) );
-
-        if ( !BaflUtils::FileExists( iFs, namePtr ) )
-            {
-            break;
-            }
-        namePtr.Zero( );
-        }
-
-    CleanupStack::Pop( name );
-    return name;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetTitleForUriL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::GetTitleForUriL( TInt aObjectId, TPtr& aValue )
-    {
-    HBufC* result = GetFileNameWithoutPathL( aObjectId );
-    TPtr des = result->Des( );
-    UpnpCdUtils::ValidateFilePath( des );
-    if ( result == NULL )
-        {
-        return;
-        }
-    aValue.Copy( *result );
-    delete result;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CheckImportUriL
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectory::CheckImportUriL( const TDesC8& aImportUri )
-    {
-    TInt objId = KErrNotFound;
-
-    // http characters  
-    HBufC8* dest8 = HBufC8::NewLC( aImportUri.Length( ) );
-    TPtr8 dest8Ptr(dest8->Des( ));
-    dest8Ptr.Copy( aImportUri );
-
-    UpnpString::ReplaceHttpCharacters( dest8Ptr );
-
-    // ip and port placeholder
-    HBufC8* dest = InsertIpAndPortPlaceholderL( dest8Ptr );
-    CleanupStack::PushL( dest );
-
-    objId = iContentDirectoryDb->GetObjIdByAttrLikeL( KImportUri8, *dest );
-
-    // clean up
-    CleanupStack::PopAndDestroy( dest );
-    CleanupStack::PopAndDestroy( dest8 );
-
-    return objId;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateAddressValueLC
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpContentDirectory::CreateAddressValueLC()
-    {
-
-    HBufC8* result = NULL;
-
-    CBufFlat* resBuf = CBufFlat::NewL( KMaxName );
-    CleanupStack::PushL( resBuf );
-
-    UpnpString::AppendStringL( *resBuf, KHttpTag( ) );
-    UpnpString::AppendStringL( *resBuf, KIpPortPlaceholder8( ) );
-
-    result = HBufC8::NewL( resBuf->Size( ) );
-    TPtr8 resultPtr(result->Des( ));
-    resultPtr.Copy( resBuf->Ptr( 0 ) );
-    CleanupStack::PopAndDestroy( resBuf );
-    CleanupStack::PushL( result );
-    return result;
-    // path 
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetImportUriLC
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpContentDirectory::GetImportUriLC( CUpnpHttpMessage* aMessage )
-    {
-    TPtrC8 path = aMessage->SenderPathFromHeader( );
-    if ( path.Find( KHttpTag ) == KErrNotFound )
-        {
-        HBufC8* serverAddr = CreateAddressValueLC( );
-        HBufC8* result =
-                HBufC8::NewL( serverAddr->Length( ) + path.Length( ) );
-        TPtr8 resultPtr(result->Des( ) );
-        resultPtr.Append( *serverAddr );
-        resultPtr.Append( path );
-        CleanupStack::PopAndDestroy( serverAddr );
-        CleanupStack::PushL( result );
-        return result;
-        }
-    else
-        {
-        HBufC8* pathHBuf = InsertIpAndPortPlaceholderL( path );
-        CleanupStack::PushL( pathHBuf );
-        return pathHBuf;
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetProtocolInfoByImportUriL
-// -----------------------------------------------------------------------------
-//
-CUpnpDlnaProtocolInfo* CUpnpContentDirectory::GetProtocolInfoByImportUriL(
-    const TDesC8& aImportUri )
-    {
-    TPtrC8 importUri;
-    importUri.Set( UpdateImportUriL( aImportUri ) );
-
-    CUpnpDlnaProtocolInfo* protocolInfo = NULL;
-    // check restriction - cannot export to the restricted object
-    TInt objId = iContentDirectoryDb->
-    GetObjIdByAttrLikeL( KImportUri8, importUri );
-
-    if ( objId < 0 )
-        {
-        User::Leave( ENoSuchObject );
-        }
-
-    if ( iContentDirectoryDb->
-    CheckObjectRestrictionL( objId ) == ERestrictedObject )
-        {
-        User::Leave( ERestrictedObject );
-        }
-    // parent restricions
-    if ( iContentDirectoryDb->CheckParentRestrictionL( objId ) != EUpnpOk )
-        {
-        User::Leave( ERestrictedParentObject );
-        }
-    else
-        {
-        HBufC8* protInfoBuf = iContentDirectoryDb->
-        GetProtocolInfoByImportUriL( importUri );
-
-        if ( protInfoBuf )
-            {
-            CleanupStack::PushL( protInfoBuf );
-            protocolInfo = CUpnpDlnaProtocolInfo::NewL( protInfoBuf->Des( ) );
-            CleanupStack::PopAndDestroy( protInfoBuf );
-            }
-        }
-    return protocolInfo;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::UpdateImportUriL
-// -----------------------------------------------------------------------------
-//
-TPtrC8 CUpnpContentDirectory::UpdateImportUriL( const TDesC8& aImportUri )
-    {
-    HBufC8* portAndIp =  GetIpAndPortDes8L();
-    CleanupStack::PushL( portAndIp );
-
-    TPtrC8 importUri;
-    importUri.Set( aImportUri );
-    
-    TInt index = aImportUri.Find( *portAndIp );
-    if ( index > 0 )
-        {
-        importUri.Set( aImportUri.Mid( index + portAndIp->Des().Length() ) );
-        }
-                
-    CleanupStack::PopAndDestroy( portAndIp );
-    
-    //--- replaceing e.g '/0000000004' -> '0000000004'   
-    index = importUri.Find( KSlash8() );
-	// importUri must begins with '/'
-    if ( !index )
-        {
-        importUri.Set( importUri.Mid( index + 1 ) );        
-        }
-     else
-        {
-        User::Leave( ENoSuchObject );         
-        }   
-    //----------------------------------------
-    
-    if ( importUri.Length() < KMaxIntegerLen )
-        {
-        User::Leave(ENoSuchObject);        
-        }
-    
-    // Check if all signs in uri are digits
-    TLex8 lex( importUri );
-    for( TInt i( 0 ); i < importUri.Length(); i++ )
-        {
-        if ( !( lex.Get() ).IsDigit() ) 
-            {
-            User::Leave( ENoSuchObject ); 
-            }
-        }    
-    return importUri; 
-    }
-    
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetProtocolInfoL
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectory::GetProtocolInfoL( const TDesC8& aContentUri,
-    CUpnpDlnaProtocolInfo*& aProtocolInfo )
-    {
-    HBufC8 *buf = InsertIpAndPortPlaceholderL( aContentUri );
-    CleanupStack::PushL( buf );
-    TInt err = iContentDirectoryDb->GetProtocolInfoL( buf->Des( ),
-        aProtocolInfo );
-    CleanupStack::PopAndDestroy( buf );
-    return err;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::FindSharedFolderL
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectory::FindSharedFolderL( const TDesC& aUrlPath,
-    const TDesC& aFileName, HBufC*& aSystemPath )
-    {
-    TInt ret = KErrNotFound;
-    aSystemPath = NULL;
-    if ( aUrlPath.Length( ) )
-        {
-        // validate the path string
-        if ( IsValidUrlPath( aUrlPath ) )
-            {
-            // get resource id
-            TLex lexer(aUrlPath);
-            TInt64 resId;
-            if ( !lexer.Val( resId ) )
-                {
-                // get resource
-                CUpnpResourcesBean* resBn = iContentDirectoryDb->
-                GetResourceL( resId );
-                if ( resBn )
-                    {
-                    CleanupStack::PushL( resBn );
-                    aSystemPath = resBn->Path().AllocL( );
-                    TInt objectId = resBn->ObjectId( );
-                    CleanupStack::PopAndDestroy( resBn );
-
-                    // make sure that systam path points to the wanted file
-                    TParse fp;
-                    fp.Set( *aSystemPath, 0, 0 );
-                    HBufC* tmp = aFileName.AllocLC( );
-                    TPtr tmpPtr(tmp->Des( ));
-                    UpnpString::ReplaceHttpCharactersL( tmpPtr );
-                    TPtrC ext = fp.Ext( );
-                    HBufC* file = HBufC::NewLC( KMaxIntegerLen
-                            + ext.Length( ) );
-                    TBuf<KMaxIntegerLen> num;
-                    num.Num( objectId );
-                    file->Des().Append( num );
-                    file->Des().Append( ext );
-
-                    if ( file->Des( ) == tmpPtr )
-                        {
-                        ret = KErrNone;
-                        }
-                    CleanupStack::PopAndDestroy( file );
-                    CleanupStack::PopAndDestroy( tmp );
-                    }
-                }
-            }
-        }
-    else
-        { // default download dir
-        aSystemPath = iDownloadDir->AllocL( );
-        }
-
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::IsValidUrlPathL
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectory::IsValidUrlPath( const TDesC& aUrlPath )
-    {
-    TInt ret = ETrue;
-    if ( (aUrlPath.Length( ) != KMaxIntegerLen + KRandomRangeLength)
-            && (aUrlPath.Length( ) != KMaxIntegerLen + KRandomRangeLength
-                    + KRandomRangeLength) )
-        {
-        ret = EFalse;
-        }
-    else
-        {
-        for ( TInt i = 0; i < aUrlPath.Length( ); i++ )
-            if ( aUrlPath[i] < '0' || aUrlPath[i] > '9' )
-                {
-                ret = EFalse;
-                break;
-                }
-        }
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetItemTypeFromMimeTypeLC
-// -----------------------------------------------------------------------------
-HBufC8* CUpnpContentDirectory::GetItemTypeFromMimeTypeLC(
-    const TDesC8& aMimeType )
-    {
-    HBufC8* result = NULL;
-    if ( aMimeType.Compare( KNullDesC8( ) ) == 0 )
-        {
-        return result;
-        }
-    TInt indexOfSlash = aMimeType.Find( KSlash8( ) );
-    if ( indexOfSlash < KErrNone )
-        {
-        return result;
-        }
-    TPtrC8 firstValue = aMimeType.Left( indexOfSlash );
-    if ( firstValue.Compare( KImageMime( ) ) == 0 )
-        {
-        result = KObjectClassImageItem().AllocLC( );
-        }
-    else if ( firstValue.Compare( KTextMime( ) ) == 0 )
-        {
-        result = KObjectClassTextItem().AllocLC( );
-        }
-    else if ( firstValue.Compare( KVideoMime( ) ) == 0 )
-        {
-        result = KObjectClassVideoItem().AllocLC( );
-        }
-    else if ( firstValue.Compare( KAudioMime( ) ) == 0 )
-        {
-        result = KObjectClassAudioItem().AllocLC( );
-        }
-    return result;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::GetItemTypeFromMimeTypeLC
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::CheckItemTypeForObjectL( RXmlEngDocument& aObj,
-    const TDesC8& aMimeType )
-    {
-    //  temporary disable because of mime-type recognition problem 
-    HBufC8* itemType = GetItemTypeFromMimeTypeLC( aMimeType );
-    if ( !itemType )
-        {
-        return;
-        }
-    TXmlEngElement obj = aObj.DocumentElement( );
-    TXmlEngElement objClass;
-    UpnpDomInterface::GetElementL( obj, objClass, KObjClassColName8 );
-    TPtrC8 classValue(UpnpDomInterface::GetElementValueL( objClass ));
-    if ( classValue.Compare( itemType->Des( ) ) < 0 )
-        {
-        objClass.SetTextL( *itemType );
-        }
-    CleanupStack::PopAndDestroy( itemType );
-
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::SetDownloadDirectoryL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::SetDownloadDirectoryL( const TDesC& aDownloadDir )
-    {
-    // perform necessary changes in database
-    iContentDirectoryDb->NewMediaDirectoryL( *iDownloadDir );
-
-    // alloc new string
-    delete iDownloadDir;
-    iDownloadDir = NULL;
-    TPtrC last = aDownloadDir.Right( 1 );
-    if ( last.Compare( KDiskPathElSep )!=0 )
-        {
-        iDownloadDir = HBufC::NewL( aDownloadDir.Length( )+ KDiskPathElSep().Length( ) );
-        iDownloadDir->Des().Copy( aDownloadDir );
-        iDownloadDir->Des().Append( KDiskPathElSep );
-        }
-    else
-        {
-        iDownloadDir = HBufC::NewL( aDownloadDir.Length( ) );
-        iDownloadDir->Des().Copy( aDownloadDir );
-        }
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::SetThumbnailDirectoryL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::SetThumbnailDirectoryL( const TDesC& aDownloadDir )
-    {
-    // perform necessary changes in database
-    iContentDirectoryDb->NewMediaDirectoryL( *iThumbDir );
-
-    // alloc new string
-    delete iThumbDir;
-    iThumbDir = NULL;
-    iThumbDir = aDownloadDir.AllocL( );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::HandleDbError
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectory::HandleDbError( TInt aError )
-    {
-    return iContentDirectoryDb->HandleDbError( aError );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::DataBaseHasBeenRecoveredL
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectory::DataBaseHasBeenRecoveredL( TInt aError )
-    {
-    TInt err = aError;
-    if ( err == KErrCorrupt )
-        {
-        err = HandleDbError( err );
-        }
-    return (err == KErrNone && aError == KErrCorrupt ) ? ETrue : EFalse;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::IsDbOrDiskProblemL
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectory::IsDbOrDiskProblemL( CUpnpAction* aAction )
-    {
-    TBool noSpace = SysUtil::DiskSpaceBelowCriticalLevelL( &iFs,
-        KMinDiskSpace, EDriveC );
-    TInt error( KErrNone );
-    if ( !noSpace )
-        {
-        if ( !IsDbCreated() )
-            {
-            error = HandleDbError( KErrCorrupt );
-            }
-        }
-    if ( noSpace || error != KErrNone )
-        {
-        DoSendActionL( aAction, ECannotProcess );
-        return ETrue;
-        }
-    return EFalse;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::IsDbCreated
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectory::IsDbCreated()
-    {
-    return iContentDirectoryDb->IsDbCreated( );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::CreateNameForThumbnailL
-// -----------------------------------------------------------------------------
-//
-HBufC* CUpnpContentDirectory::CreateNameForThumbnailL( const TDesC& aFileName )
-    {
-    // only name
-    TParse fp;
-    User::LeaveIfError( fp.Set( aFileName, 0, 0 ) );
-    TFileName bareName = fp.Name( );
-    // full name
-    User::LeaveIfError( fp.Set( bareName, iThumbDir, &KDefaultThumbExtension ) );
-    TFileName fullName = fp.FullName( );
-
-    //check if exists
-    TUint ignored;
-    TInt q = 0;
-    while ( iFs.Att( fullName, ignored ) == KErrNone )
-        {
-        q++;
-        TBuf<KMaxIntegerLen> num;
-        num.Num( q );
-        TFileName tmpName;
-        tmpName.Copy( bareName );
-        tmpName.Append( KUndersc );
-        tmpName.Append( num );
-        fp.Set( tmpName, iThumbDir, &KDefaultThumbExtension );
-        fullName = fp.FullName( );
-        }
-
-    return fullName.AllocL( );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::AutoDestroyEventL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::AutoDestroyEventL( TInt aObjId, TBool aDeleteObj )
-    {
-    if ( !ValidateObjectL( aObjId ) )
-        {
-        return;
-        }
-
-    if ( aDeleteObj )
-        {
-        TBuf8<KMaxIntegerLen> containerID;
-        containerID.Num( iContentDirectoryDb->GetParentIdL( aObjId ) );
-        RArray<TInt> refList;
-        CleanupClosePushL( refList );
-        iContentDirectoryDb->DeleteObjectL( aObjId, refList, ETrue );
-
-        // supporting ContainerUpdateIDs behaviour
-        iStateHandler->IncreaseSystemUpdateIdL( );
-        iStateHandler->IncreaseContainerUpdateIdL( containerID );
-        for ( TInt i(0); i<refList.Count( ); i++ )
-            {
-            iStateHandler->IncreaseSystemUpdateIdL( );
-            containerID.Num( refList[i] );
-            iStateHandler->IncreaseContainerUpdateIdL( containerID );
-            }
-
-        // clean up
-        CleanupStack::PopAndDestroy( &refList );
-        }
-    iAutoDestroyObjects->RemoveAndDestroyL( iAutoDestroyObjects->FindObjIndexByObjId( aObjId ) );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::HttpTransferEventReceivedL
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpContentDirectory::HttpTransferEventReceivedL( CUpnpHttpMessage& aHttpMsg )
-    {
-    switch ( aHttpMsg.Type( ) )
-        {
-        case ETransferStart:
-            {
-            TransferStartL( aHttpMsg.SenderPathFromHeader( ) );
-
-            CUpnpFileTransfer::TTransferType type;
-            TInt objectid(0);
-
-            if ( aHttpMsg.Method().Find( KHttpGet ) == 0 )
-                {
-                objectid = iContentDirectoryDb->GetObjIdByAttrL( KImportUri8,
-                    aHttpMsg.SenderPathFromHeader( ) );
-                type = CUpnpFileTransfer::EImport;
-                }
-            else
-                {
-                objectid = iContentDirectoryDb->GetObjIdByAttrLikeL(
-                    KImportUri8, aHttpMsg.SenderPathFromHeader( ) );
-                type = CUpnpFileTransfer::EUpload;
-
-                }
-            CUpnpFileTransfer* transfer = CUpnpFileTransfer::NewLC(
-                aHttpMsg.SessionId( ), objectid, type );
-
-            transfer->SetTransferState(:: ETransferInProgress);
-            transfer->SetImportNumber(UpnpCdUtils::ResIdFromUriL(
-                    aHttpMsg.SenderPathFromHeader()));
-
-            iTransferController->iFileTransfers.Append(transfer);
-            CleanupStack::Pop( transfer );
-
-            iTransferController->AddIncomingTransferInternalL(&aHttpMsg);
-            break;
-            }
-        case ETransferError:
-            {
-            iTransferController->TransferFailL( &aHttpMsg );
-            break;
-            }
-        default:
-        break;
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ImportComplete
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::TransferProgress( TInt aId, TInt aBytes,
-    TInt aTotalBytes )
-    {
-    TInt transferId = iTransferController->Transfer( aId );
-    if ( transferId != KErrNotFound )
-        {
-        (iTransferController->iFileTransfers[ transferId ])->SetTransferLength( aBytes );
-        (iTransferController->iFileTransfers[ transferId ])->SetTransferTotal( aTotalBytes );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::TransferStartL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::TransferStartL( const TDesC8& aImpUri )
-    {
-    TInt index = iAutoDestroyObjects->FindObjIndexByResId( UpnpCdUtils::ResIdFromUriL( aImpUri ) );
-    if ( index != KErrNotFound )
-        {
-        (*iAutoDestroyObjects)[index]->SetTransferStartedL( ETrue );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::TransferCompleteL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::TransferCompleteL( TInt aResId, TInt aObjId )
-    {
-    TInt index = iAutoDestroyObjects->FindObjIndexByResId( aResId );
-    if ( index != KErrNotFound )
-        {
-        iAutoDestroyObjects->RemoveAndDestroyL( index );
-        }
-
-    if ( (aObjId>=0)&&(aResId>=0)
-            &&(iContentDirectoryDb->GetParentIdL( aObjId )>=0) )
-        {
-        TBuf8<KMaxIntegerLen> containerID;
-        containerID.Num( iContentDirectoryDb->GetParentIdL( aObjId ) );
-        iStateHandler->IncreaseSystemUpdateIdL( );
-        iStateHandler->IncreaseContainerUpdateIdL( containerID );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::NotifyTransferFailL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::NotifyTransferFailL( TInt aSessionId,
-    TInt aStatusCode )
-    {
-    CUpnpFileTransferEvent* event =
-            iTransferController->RemoveTransferLC( aSessionId );
-    if ( event )
-        {
-        event->SetProgressState( CUpnpFileTransferEvent::EFailed );
-        event->SetErrorCode( aStatusCode );
-        CleanupStack::Pop( event );
-        iEventObserver->FileTransferEvent( event );
-        }
-
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::NotifyTransferStoppedL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::NotifyTransferStoppedL( TInt aSessionId,
-    CUpnpFileTransfer::TTransferType aType )
-    {
-    CUpnpFileTransferEvent* event =
-            iTransferController->RemoveTransferLC( aSessionId );
-    if ( event )
-        {
-        event->SetProgressState( CUpnpFileTransferEvent::EStopped );
-        if ( aType == CUpnpFileTransfer::EImport )
-            {
-            event->SetDirection( CUpnpFileTransferEvent::EIncoming );
-            }
-        else
-            {
-            event->SetDirection( CUpnpFileTransferEvent::EOutgoing );
-            }
-
-        CleanupStack::Pop( event );
-        iEventObserver->FileTransferEvent( event );
-        }
-
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::NotifyOutgoingTransferL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::NotifyOutgoingTransferL( TInt aSessionId )
-    {
-    CUpnpFileTransferEvent* event =
-            iTransferController->RemoveTransferLC( aSessionId );
-    if ( event )
-        {
-        CleanupStack::Pop( event );
-        //send event to Media Server        
-        iEventObserver->FileTransferEvent( event );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::SetSender
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpContentDirectory::SetSender( MUpnpCdsSender* aSender )
-    {
-    iSender = aSender;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::DoSendActionL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::DoSendActionL( CUpnpAction* aAction,
-    TUpnpErrorCode aError )
-    {
-    iSender->SendL( aAction, aError );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::DoSendActionL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::DoSendMessageL( CUpnpHttpMessage* aMessage )
-    {
-    iSender->SendL( aMessage );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::SendActionL
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpContentDirectory::SendActionL( CUpnpAction* aAction,
-    TUpnpErrorCode aError )
-    {
-    SendL( aAction, aError );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::DoSendActionL
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpContentDirectory::SendMessageL( CUpnpHttpMessage* aMessage )
-    {
-    SendL( aMessage );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::StateVariableEvented
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::StateVariableEvented( const TDesC8& aVariableName )
-    {
-    iStateHandler->StateVariableEvented( aVariableName );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::StateHandler
-// -----------------------------------------------------------------------------
-//
-CUpnpStateHandler* CUpnpContentDirectory::StateHandler()
-    {
-    return iStateHandler;
-    }
-
-// helper functions
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ExecutedAction
-// -----------------------------------------------------------------------------
-//
-TCurrentAction CUpnpContentDirectory::ExecutedAction()
-    {
-    return iCurrentAction;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::SetExecutedAction
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::SetExecutedAction( TCurrentAction aAction )
-    {
-    iCurrentAction = aAction;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::HttpResponseReceivedL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::HttpResponseReceivedL( TInt aSessionId,
-    TInt aStatusCode )
-    {
-    iTransferController->HttpResponseReceivedL( aSessionId, aStatusCode );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::EventObserver
-// -----------------------------------------------------------------------------
-//
-MUpnpContentDirectoryEventObserver* CUpnpContentDirectory::EventObserver()
-    {
-    return iEventObserver;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ContentDirectoryDb
-// -----------------------------------------------------------------------------
-//
-CUpnpContentDirectoryDb* CUpnpContentDirectory::ContentDirectoryDb()
-    {
-    return iContentDirectoryDb;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::IsObjectExistL
-// -----------------------------------------------------------------------------
-//    
-TBool CUpnpContentDirectory::IsObjectExistL( TInt aObjectId )
-    {
-    if ( iContentDirectoryDb->CheckObjectRestrictionL( aObjectId )
-            == ENoSuchObject )
-        {
-        return EFalse;
-        }
-    else
-        {
-        return ETrue;
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::ValidateObjectL
-// -----------------------------------------------------------------------------
-//   
-TBool CUpnpContentDirectory::ValidateObjectL( TInt aObjectId )
-    {
-    //removes from autodestroy array orphaned objects
-    TInt i(0);
-    TInt index(0);
-    while ( i < iAutoDestroyObjects->Count( ) )
-        {
-        TInt parentID( iContentDirectoryDb->GetParentIdL(
-                        ( *iAutoDestroyObjects )[ i ]->GetObjId( ) ) );
-        if ( parentID < 0 )
-            {
-            index = iAutoDestroyObjects->FindObjIndexByObjId( (
-                                             *iAutoDestroyObjects )[ i ]->GetObjId( ) );
-            iAutoDestroyObjects->RemoveAndDestroyL( index );
-            continue;
-            }
-        i++;
-        }
-
-    //checks if given object exists
-    if ( !IsObjectExistL( aObjectId ) )
-        {
-        index = iAutoDestroyObjects->FindObjIndexByObjId( aObjectId );
-        if ( index != KErrNotFound )
-            {
-            iAutoDestroyObjects->RemoveAndDestroyL( index );
-            }
-        }
-
-    //cheks if given object exists in autodestroy array
-    index = iAutoDestroyObjects->FindObjIndexByObjId( aObjectId );
-    if ( index != KErrNotFound )
-        {
-        return ETrue;
-        }
-
-    return EFalse;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::TransferHandler
-// -----------------------------------------------------------------------------
-//
-MUpnpTransferInterface* CUpnpContentDirectory::TransferHandler()
-    {
-    return iTransferHandler;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::TransferCompletedL
-// -----------------------------------------------------------------------------
-//    
-void CUpnpContentDirectory::TransferCompletedL( TInt aKey, TInt aResultCode )
-    {
-    HttpResponseReceivedL( aKey, aResultCode );
-    if ( aResultCode == EHttpOk )
-        {
-        TInt transferid = iTransferController->Transfer( aKey );
-        if ( transferid > KErrNotFound )
-            {
-            TInt
-                    len =
-                            iTransferController->iFileTransfers[transferid]->TransferTotal( );
-            iTransferController->iFileTransfers[transferid]->SetTransferLength( len );
-            }
-        }
-    }
-    
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::NewTransactionL
-// -----------------------------------------------------------------------------
-//
-EXPORT_C void CUpnpContentDirectory::NewTransactionL(
-        const TDesC8& aMethod, const TDesC8& aUri, 
-        const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans )
-    {
-    iDlnaFilter->NewTransactionL( aMethod, aUri, aSender, aResultTrans );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::HttpEventLD
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::HttpEventLD( CUpnpHttpMessage* aMessage )
-    {
-    if ( aMessage )
-        {
-        CleanupStack::PushL( aMessage );
-        if( aMessage->Type() >= ETransferStart )
-            {
-            HttpTransferEventReceivedL( *aMessage );
-            }
-        else
-            {
-            UnknownHttpEventReceivedL( *aMessage );
-            }
-        CleanupStack::PopAndDestroy( aMessage );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectory::AddressChangeL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectory::AddressChangeL()
-    {
-    iHttpServerSession->Stop();
-    iHttpServerSession->StartL();        
-    }
-
-//End of File
+/** @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:  Content Directory
+ *
+*/
+
+
+// INCLUDE FILES
+#include <fbs.h>
+#include <uri8.h>
+#include <pathinfo.h>
+#include <xmlengdom.h>
+#include <xmlengserializationoptions.h>
+#include <xmlengdomparser.h>
+#include <sysutil.h>
+#include <bautils.h>
+#include <caf/caf.h>
+#include <caf/manager.h>
+
+#include "upnpsender.h"
+#include "upnpcontentdirectory.h"
+#include "upnperrors.h"
+#include "upnpdominterface.h"
+#include "upnpstring.h"
+#include "upnpargument.h" 
+#include "upnphttpmessagefactory.h" 
+#include "upnpcons.h"
+#include "upnpdevice.h"
+#include "upnpfileutils.h"
+#include "upnpcommonupnplits.h"
+#include "upnpcontainerupdateid.h"
+#include "upnpcontentdirectorydb.h"
+#include "upnpfiletransfertimerobserver.h"
+#include "upnperror.h"
+#include "upnpcustomlog.h"
+#include "upnpprotocolinfo.h"
+#include "upnpcontentdirectoryglobals.h"
+#include "upnpresourcesbean.h"
+#include "upnpcdutils.h"
+#include "upnpmetadatastorage.h"
+#include "upnpautodestroyobjectlist.h"
+#include "upnpautodestroyobject.h"
+#include "upnpcontentdirectoryeventobserver.h"
+#include "upnpfiletransferevent.h"
+#include "upnpfiletransfer.h"
+#include "upnpprotocolinfolocal.h"
+#include "upnpxmlcontentfilter.h"
+#include "upnpstatehandler.h"
+#include "upnptransferuploader.h"
+#include "upnpmimemapper.h"
+#include "upnptransfercontroller.h"
+#include "upnptransferinterface.h"
+#include "upnpdlnafilter.h"
+#include "upnpmspathutility.h"
+#include "upnphttpserversession.h"
+#include "upnphttpserverruntime.h"
+#include "upnpsettings.h"
+#include "upnpdeviceimplementationbase.h"
+#include "upnpsecuritymanager.h"
+#include "upnpmediaserversettings.h"
+
+// Constant definitions
+using namespace UpnpPaths;
+using namespace UpnpDlnaProtocolInfo;
+
+// ============================= LOCAL FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// DestroyRPointerArray
+// Defined in upnpelementfactory.cpp
+// -----------------------------------------------------------------------------
+//
+void DestroyRArray( TAny* aArray );
+void RPointerArrayTPtrC8( TAny* aArray )
+    {
+    RPointerArray<TPtrC8>* array =
+            reinterpret_cast<RPointerArray<TPtrC8>*>(aArray);
+    array->ResetAndDestroy( );
+    }
+
+// ================= MEMBER FUNCTIONS =======================
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CUpnpContentDirectory
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUpnpContentDirectory::CUpnpContentDirectory( CUpnpDevice& aDevice,
+    MUpnpThumbnailCreatorObserver* aThmbObs, MUpnpTransferInterface* aTransfer ) :
+
+    CUpnpServiceImplementation(aDevice), iThmbObs(aThmbObs),
+            iTransferHandler(aTransfer)
+
+    {
+    SetExecutedAction( EUndefinedAction );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::~CUpnpContentDirectory
+// C++ default destructor
+// -----------------------------------------------------------------------------
+//
+CUpnpContentDirectory::~CUpnpContentDirectory()
+    {
+    delete iDownloadDir;
+    delete iThumbDir;
+    delete iElementdb;
+
+    delete iTransferController;
+    delete iMimeToExtMap;
+
+    delete iContentDirectoryDb;
+
+    iThObjectIds.Close( );
+
+    iThumbnailCreators.ResetAndDestroy( );
+
+    iDOMImpl.Close( );
+    if ( iBitmapServerConnection == KErrNone )
+        RFbsSession::Disconnect( );
+    iFs.Close( );
+    if ( iEcomUsed )
+        {
+        REComSession::FinalClose( );
+        }
+    delete iAutoDestroyObjects;
+    delete iStateHandler;
+    if ( iHttpServerSession )
+        {
+        iHttpServerSession->Stop();
+        }
+    delete iHttpServerSession;
+    delete iDlnaFilter;
+    delete iSecurityManager;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ConstructL
+// Two-phased constructor.
+// Initialize variables, set parent service and create XML reader.
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::ConstructL( TUpnpCdSettings aSettings,
+    CUpnpMetadataStorage* aMetadataStorage )
+    {
+    iDOMImpl.OpenL( );
+
+    iTransferController = CUpnpTransferController::NewL( this );
+
+    iMimeToExtMap = CUpnpMimeMapper::NewL( );
+
+    BaseConstructL( aSettings.iDescriptionPath, KContentDirectoryType( ) );
+
+    User::LeaveIfNull( aSettings.iDevice );
+    
+    CUpnpSecurityManager* secMan = CUpnpSecurityManager::NewInstanceFromUpnpSettingsL();
+    
+    iSecurityManager = secMan;
+    iDlnaFilter = CUpnpDlnaFilter::NewL( this, secMan );
+    
+    iElementdb = CUpnpElementFactory::NewL( aSettings.iObjectsXmlPath );
+    iElementdb->GetContentDirectoryReference( this );
+
+    SetStateVariableL( KSystemUpdateID( ), KZero( ) );
+    SetStateVariableL( KContainerUpdateIDs( ), UpnpCD::KEmptyString( ) );
+    SetStateVariableL( KTransferIDs( ), UpnpCD::KEmptyString( ) , EFalse );
+    SetStateVariableL( KSortCapsVariableName( ), KSortCapabilities( ) );
+    SetStateVariableL( KSearchCapsVariableName( ), KSearchCapabilities( ) );
+
+    // file session 
+    User::LeaveIfError( iFs.Connect( ) );
+
+    iBitmapServerConnection = RFbsSession::Connect( );
+    iDownloadDir = aSettings.iDownloadDir.AllocL( );
+    iThumbDir = aSettings.iThumbnailDir.AllocL( );
+    iContentDirectoryDb = CUpnpContentDirectoryDb::NewL( aMetadataStorage );
+    iAutoDestroyObjects = CUpnpAutoDestroyObjectList::NewL( );
+    iCreateThumbnails = aSettings.iCreateThumbnail;
+    iMaxRequestCount = aSettings.iMaxRequestCount;
+    iEventObserver = aSettings.iEventObserver;
+    iStateHandler = CUpnpStateHandler::NewL( this );
+    
+    ConstructHttpL();
+    }
+
+void CUpnpContentDirectory::ConstructHttpL()
+    {
+    TInt iapId = CUpnpSettings::GetIapL();
+    iHttpServerSession = CUpnpHttpServerSession::NewL( iapId, *this );
+    iHttpServerSession->DefaultRuntime().SetCreator( *this );
+    iHttpServerSession->StartL();
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpContentDirectory* CUpnpContentDirectory::NewL(
+    TUpnpCdSettings aSettings, CUpnpMetadataStorage* aMetadataStorage,
+    MUpnpTransferInterface* aTransfer )
+    {
+    CUpnpContentDirectory* cd = new (ELeave) CUpnpContentDirectory( *aSettings.iDevice,
+            aSettings.iThmbObs,
+            aTransfer
+    );
+    CleanupStack::PushL( cd );
+    cd->ConstructL( aSettings, aMetadataStorage );
+    CleanupStack::Pop( cd );
+    return cd;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ActionReceivedLD
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::ActionReceivedLD( CUpnpAction* aAction )
+    {
+    CleanupStack::PushL( aAction );
+    //check security
+    if ( iSecurityManager &&
+            KErrNone != iSecurityManager->AuthorizeAction( aAction ) )
+        {
+        //server returns upnp error action failed when not authorized
+        User::Leave(EActionFailed);
+        }
+    // in case of low disk space
+    if ( !IsDbOrDiskProblemL( aAction ) )
+        {
+        // handle event
+        TInt ret = EUpnpUndefined;
+        TRAPD( err, ret = DoActionReceivedL( aAction ) );
+        if ( DataBaseHasBeenRecoveredL( err ) )
+            {
+            TRAP( err, ret = DoActionReceivedL( aAction ) );
+            if ( err == KErrCorrupt )
+                {
+                err = iContentDirectoryDb->RecreateDatabaseFile();
+                }
+            }
+        else if ( err == KErrNone )
+            {
+            err = ret;
+            }
+        LOGS( "ContentDirectory ActionReceivedLD sending soon." );
+        DoSendActionL( aAction, TUpnpError( err ) );
+        }
+    CleanupStack::PopAndDestroy( aAction );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::DoActionReceivedL
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectory::DoActionReceivedL( CUpnpAction* aAction )
+    {
+    // sendAndDestroy defines that after processing action must be 
+    // sent and destroyed
+    TUpnpErrorCode err = EUndefined;
+
+    // Get the name, saves calls in the if-else statements
+    TPtrC8 name( aAction->Name() );
+    // Verify the action and do the operation(s)
+    if ( name.Compare( KBrowse ) == 0 )
+        {
+        err = BrowseL( aAction );
+        }
+    else if ( name.Compare( KCreateReference ) == 0 )
+        {
+        err = CreateReferenceL( aAction );
+        }
+    else if ( name.Compare( KCreateObject ) == 0 )
+        {
+        LOGS( "ContentDirectory: Creating a new object" );
+        err = CreateObjectL( aAction );
+        }
+    else if ( name.Compare( KDeleteResource ) == 0 )
+        {
+        err = DeleteResourceL( aAction );
+        }
+    else if ( name.Compare( KDestroyObject ) == 0 )
+        {
+        err = DestroyObjectL( aAction );
+        }
+    else if ( name.Compare( KExportResource ) == 0 )
+        {
+        err = ExportResourceL( aAction );
+        }
+    else if ( name.Compare( KGetSearchCapabilities ) == 0 )
+        {
+        err = GetSearchCapabilitiesL( aAction );
+        }
+    else if ( name.Compare( KGetSortCapabilities ) == 0 )
+        {
+        err = GetSortCapabilitiesL( aAction );
+        }
+    else if ( name.Compare( KGetSystemUpdateID ) == 0 )
+        {
+        err = GetSystemUpdateIdL( aAction );
+        }
+    else if ( name.Compare( KGetTransferProgress ) == 0 )
+        {
+        err = GetTransferProgressL( aAction );
+        }
+    else if ( name.Compare( KImportResource ) == 0 )
+        {
+        err = ImportResourceL( aAction );
+        }
+    else if ( name.Compare( KStopTransferResource ) == 0 )
+        {
+        err = StopTransferResourceL( aAction );
+        }
+    else
+        {
+        err = EInvalidAction;
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::DoActionReceivedCDL
+// -----------------------------------------------------------------------------
+//    
+void CUpnpContentDirectory::HttpGetStartedSoapNotifyL( TInt /*aSessionId*/)
+    {
+    // not needed upnp response returned by ActionReceivedCDL
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::DoActionReceivedCDL
+// -----------------------------------------------------------------------------
+//    
+void CUpnpContentDirectory::HttpPostStartedL( TInt /*aSessionId*/)
+    {
+    // not needed upnp response returned by ActionReceivedCDL
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::UnknownHttpEventReceivedL 
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpContentDirectory::UnknownHttpEventReceivedL( CUpnpHttpMessage& aHttpMsg )
+    {
+    CUpnpFileTransferEvent* transferEvent =
+            iTransferController->TransferL( aHttpMsg.SessionId( ) );
+    if ( !transferEvent )
+        {
+        return;
+        }
+
+    TInt err = aHttpMsg.Error( );
+    if ( err != EHttpRequestTimeout && err != EHttpInsufficientStorage )
+        {
+        err = EHttpOk;
+        }
+
+    HBufC* fileName16 = UpnpString::ToUnicodeL( aHttpMsg.InFilename( ) );
+    CleanupStack::PushL( fileName16 );
+    transferEvent->SetFilePathL( *fileName16 );
+    CleanupStack::PopAndDestroy( fileName16 );
+
+    iTransferController->HttpResponseReceivedL( aHttpMsg.SessionId( ), err );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::IsDrmFileL 
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectory::IsDrmFileL( const TDesC8& aFileName )
+    {
+    HBufC* tmp = UpnpCdUtils::Des8ToDesLC( aFileName );
+    TBool ret = IsDrmFileL( *tmp );
+    CleanupStack::PopAndDestroy( tmp );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::IsDrmFileL 
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectory::IsDrmFileL( const TDesC& aFileName )
+    {
+    if ( !BaflUtils::FileExists( iFs, aFileName ) )
+        {
+        return EFalse;
+        }
+    TBool ret = EFalse;
+    TInt value=0, err;
+
+    ContentAccess::CManager *manager = ContentAccess::CManager::NewL( );
+    CleanupStack::PushL( manager );
+
+    ContentAccess::CVirtualPath *path =
+            ContentAccess::CVirtualPath::NewL( aFileName );
+    CleanupStack::PushL( path );
+
+    ContentAccess::TVirtualPathPtr virtualPath = *path;
+
+    err = manager->GetAttribute( ContentAccess::EIsProtected, value,
+        virtualPath );
+    if ( err == KErrNone )
+        {
+        if ( value )
+            {
+            // delete file
+            iFs.Delete( aFileName );
+            ret = ETrue;
+            }
+        }
+    CleanupStack::PopAndDestroy( 2, manager );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateReferenceL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::CreateReferenceL( CUpnpAction*& aAction )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+
+    // Get IDs from action 
+    TInt conId( KErrNotFound );
+    TInt objId( KErrNotFound );
+
+    TInt err = UpnpCdUtils::StringToInteger(
+        aAction->ArgumentValue( KContainerID ), &conId );
+    if ( err!=KErrNone )
+        {
+        err=ENoContainer;
+        User::Leave( ENoContainer );
+        }
+
+    err = UpnpCdUtils::StringToInteger(
+        aAction->ArgumentValue( UpnpCD::KObjectID ), &objId );
+    if ( err!=KErrNone )
+        {
+        err=ENoContainer;
+        User::Leave( ENoSuchObject );
+        }
+
+    objId = iContentDirectoryDb->ReferedObjectIdL( objId );
+
+    RXmlEngDocument conDidl;
+    RXmlEngDocument objDidl;
+    CleanupClosePushL( conDidl );
+    CleanupClosePushL( objDidl );
+
+    ret = iContentDirectoryDb->GetObjectL( conId, conDidl, KAsterisk8 );
+    if ( ret != EUpnpOk )
+        User::Leave( ENoContainer );
+
+    ret = iContentDirectoryDb->GetObjectL( objId, objDidl, KAsterisk8 );
+    if ( ret != EUpnpOk )
+        User::Leave( ENoSuchObject );
+
+    TXmlEngElement con = conDidl.DocumentElement().FirstChild().AsElement( );
+    TXmlEngElement obj = objDidl.DocumentElement().FirstChild().AsElement( );
+
+    if ( obj.Name().Compare( KItem ) != 0 )
+        {
+        User::Leave( ENoSuchObject );
+        }
+    if ( con.Name().Compare( KContainer ) != 0 )
+        {
+        User::Leave( ENoContainer );
+        }
+    if ( iContentDirectoryDb->CheckObjectRestrictionL( conId ) != EUpnpOk )
+        {
+        User::Leave( ERestrictedParentObject );
+        }
+
+    TInt refId;
+    RXmlEngDocument refDidl = iContentDirectoryDb->PrepareDidlDocumentL( );
+    CleanupClosePushL( refDidl );
+
+    TXmlEngElement refEl = refDidl.DocumentElement().AddNewElementSameNsL( KItem( ) );
+
+    refEl.AddNewAttributeL( KRefID( ),
+        aAction->ArgumentValue( UpnpCD::KObjectID ) );
+
+    refEl.AddNewAttributeL( KParentID( ),
+        aAction->ArgumentValue( KContainerID ) );
+
+    refEl.AddNewAttributeL( KRestricted( ), KFalseValue8( ) );
+
+    // title
+    TXmlEngElement objTitle;
+    UpnpDomInterface::GetElementL( obj, objTitle, KObjTiltleColName8( ) );
+    refEl.AppendChildL( objTitle.Unlink().AsElement( ) );
+
+    // class
+    TXmlEngElement objClass;
+    UpnpDomInterface::GetElementL( obj, objClass, KObjClassColName8( ) );
+    refEl.AppendChildL( objClass.Unlink().AsElement( ) );
+
+    iContentDirectoryDb->InsertObjectL( refDidl, conId, &refId );
+
+    //increase system update ID
+    iStateHandler->IncreaseSystemUpdateIdL( );
+    iStateHandler->IncreaseContainerUpdateIdL( (TDesC8&)aAction->ArgumentValue( KContainerID ) );
+
+    TBuf8<KMaxIntegerLen> newid;
+    newid.Num( refId );
+    aAction->SetArgumentL( (TDesC8&)KNewID, newid );
+
+    CleanupStack::PopAndDestroy( &refDidl );
+    CleanupStack::PopAndDestroy( &objDidl );
+    CleanupStack::PopAndDestroy( &conDidl );
+
+    return EHttpOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::BrowseL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::BrowseL( CUpnpAction*& aAction )
+    {
+    RDebug::Print( _L( "CUpnpContentDirectory::BrowseL start" ) );
+    TInt err( KErrGeneral );
+
+    //Check ObjectID
+    TInt objectID( KErrNotFound );
+    err = UpnpCdUtils::StringToInteger(
+        (TDesC8&)aAction->ArgumentValue( UpnpCD::KObjectID( ) ), &objectID );
+    if ( err != KErrNone )
+        {
+        User::Leave( ENoSuchObject );
+        }
+    //Check SortCriteria
+    if ( aAction->ArgumentValue( (TDesC8&) KSortCriteria ).Compare( (TDesC8&)KSortCapabilities )
+            != 0 )
+        {
+        User::Leave( EInvalidSort ); //wrong sort flag
+        }
+
+    //Check BrowseFlag
+    TDesC8& browseFlag =
+            (TDesC8&)aAction->ArgumentValue( (TDesC8&)KBrowseFlag );
+    if ( browseFlag.Compare( KBrowseMeta ) != 0
+            && browseFlag.Compare( KBrowseChilds ) != 0 )
+        {
+        User::Leave( EInvalidArgs ); //wrong browse flag    
+        }
+
+    //Check StartIndex
+    TInt startIndex( KErrNotFound );
+    err = UpnpString::StringToInt(
+        (TDesC8&)aAction->ArgumentValue( (TDesC8&)KStartingIndex ),
+        &startIndex );
+    if ( KErrNone != err )
+        {
+        User::Leave( EInvalidArgs );
+        }
+
+    //Additional check of StartIndex, see documentation
+    if ( browseFlag.Compare( KBrowseMeta ) == 0 && startIndex != 0 )
+        {
+        User::Leave( EInvalidArgs );
+        }
+
+    //Check RequestedCount
+    TInt reqCount( KErrNotFound );
+    err = UpnpString::StringToInt(
+        (TDesC8&)aAction->ArgumentValue( (TDesC8&)KRequestedCount ),
+        &reqCount );
+    if ( KErrNone != err )
+        {
+        User::Leave( EInvalidArgs );
+        }
+
+    //Filter
+    HBufC8* filter = aAction->ArgumentValue( KFilter() ).AllocLC( );
+    filter->Des().TrimAll( );
+
+    // Metadata browse
+    if ( browseFlag.Compare( KBrowseMeta ) == 0 )
+        {
+
+        RXmlEngDocument objectDoc;
+        CleanupClosePushL( objectDoc );
+        // Try to get original object not a reference 
+        TInt id = iContentDirectoryDb->ReferedObjectIdL( objectID );
+        CleanupStack::Check( &objectDoc );
+        TUpnpErrorCode err = EUndefined;
+        err = iContentDirectoryDb->GetObjectL( id, objectDoc, *filter );
+        if ( err != EUpnpOk )
+            User::Leave( err );
+        CleanupStack::Check( &objectDoc );
+        //--------- new solution for references --------
+
+        // if id != objectID it means that we have a reference, so now id = 'real object id' and objectID = 'reference object id' 
+        if ( id != objectID )
+            {
+            TInt refParentID = iContentDirectoryDb->GetParentIdL( objectID );
+            User::LeaveIfError( refParentID );
+
+            UpnpCdUtils::SetObjectIdL(
+                UpnpCdUtils::GetObjectElementL( objectDoc ), objectID );
+            UpnpCdUtils::SetObjectRefIdL(
+                UpnpCdUtils::GetObjectElementL( objectDoc ), id );
+            UpnpCdUtils::SetObjectParentIdL(
+                UpnpCdUtils::GetObjectElementL( objectDoc ), refParentID );
+            UpnpCdUtils::SetRestrictedFieldL(
+                UpnpCdUtils::GetObjectElementL( objectDoc ), EFalse );
+            }
+        //---------------------------------------------
+
+        // Serialize object to descriptor - without DIDL-Lite element
+        RBuf8 buf;
+        TXmlEngSerializationOptions
+                options(TXmlEngSerializationOptions::KOptionOmitXMLDeclaration
+                        | TXmlEngSerializationOptions::KOptionIncludeNsPrefixes);
+        objectDoc.SaveL( buf, iElementdb->ActiveElementL( objectDoc ),
+            options );
+        CleanupStack::Check( &objectDoc );
+        CleanupClosePushL( buf );
+        HBufC8* subResponse = buf.AllocLC( );
+
+        CBufFlat* response = CBufFlat::NewL( KRespBufGranularity );
+        CleanupStack::PushL( response );
+        UpnpString::AppendStringL( *response, KDidlTag );
+        UpnpString::AppendStringL( *response, *subResponse );
+        UpnpString::AppendStringL( *response, (TDesC8&) KDidlEnd( ) );
+
+        HBufC8* resultTmp =
+                UpnpCdUtils::EncodeXmlStringL( response->Ptr( 0 ) );
+        CleanupStack::PushL( resultTmp );
+        TPtr8 resultTmpPtr(resultTmp->Des( ));
+        InsertRealIpAndPortL( resultTmpPtr );
+
+        // Set action's OUT arguments       
+        TBuf8<KMaxIntegerLen> num;
+
+        //Result
+        aAction->SetArgumentL( KResult, *resultTmp );
+
+        //NumberReturned
+        num.Num( 1 );
+        aAction->SetArgumentL( KNumberReturned, num );
+
+        //TotalMatches
+        //num.Num(1);
+        aAction->SetArgumentL( KTotalMatches, num );
+
+        //UpadateID 
+        num.Format(
+            UpnpCD::KOneNumber,
+            ContainerUpdateId( (TDesC8&)aAction->ArgumentValue( (TDesC8&)UpnpCD::KObjectID ) ) );
+        aAction->SetArgumentL( KUpdateID, num );
+
+        // clean up
+        CleanupStack::PopAndDestroy( resultTmp );
+        CleanupStack::PopAndDestroy( response );
+        CleanupStack::PopAndDestroy( subResponse );
+        CleanupStack::PopAndDestroy( &buf );
+        CleanupStack::PopAndDestroy( &objectDoc );
+
+        }
+    //Children browse
+    else if ( browseFlag.Compare( KBrowseChilds ) == 0 )
+        {
+        //array contains pointers to direct childrens.
+        RArray<TInt> listOfAllObjects;
+        CleanupClosePushL( listOfAllObjects );
+
+        TUpnpErrorCode err = iContentDirectoryDb->GetObjectListL( objectID,
+            listOfAllObjects );
+
+        if ( err == ENoSuchObject )
+            {
+            User::Leave( err );
+            }
+
+        // if requestedCount==0 then return all matched objects
+        if ( !reqCount )
+            {
+            reqCount = listOfAllObjects.Count( );
+            }
+
+        // if requestedCount cannot be greater than iMaxRequestCount
+        if ( iMaxRequestCount > 0 && reqCount > iMaxRequestCount )
+            {
+            reqCount = iMaxRequestCount;
+            }
+
+        // get upnp objects
+        RArray<RXmlEngDocument> objs;
+        CleanupStack::PushL(TCleanupItem( DestroyRArray, &objs ));
+
+        if ( startIndex < listOfAllObjects.Count( ) )
+            { // prepare list of objects which are to be returned
+            if ( startIndex + reqCount > listOfAllObjects.Count( ) )
+                reqCount = listOfAllObjects.Count( ) - startIndex;
+            RArray<TInt> alistOfWantedObjs( &listOfAllObjects[startIndex],
+                reqCount);
+
+            iContentDirectoryDb->GetObjectListL( alistOfWantedObjs, *filter,
+                objs );
+            }
+
+        // prepare response
+        // Result
+        HBufC8* resp = SerializeObjectsListL( objs );
+        CleanupStack::PushL( resp );
+        TPtr8 respPtr(resp->Des( ));
+        InsertRealIpAndPortL( respPtr );
+        aAction->SetArgumentL( KResult, *resp );
+        // NumberReturned
+        TBuf8<KMaxIntegerLen> num;
+        num.Num( objs.Count( ) );
+        aAction->SetArgumentL( KNumberReturned, num );
+        // TotalMatches
+        num.Num( listOfAllObjects.Count( ) );
+        aAction->SetArgumentL( KTotalMatches, num );
+        // UpdateID
+        num.Format(
+            UpnpCD::KOneNumber,
+            ContainerUpdateId( (TDesC8&)aAction->ArgumentValue( (TDesC8&)UpnpCD::KObjectID ) ) );
+        aAction->SetArgumentL( KUpdateID, num );
+
+        // clean up
+        CleanupStack::PopAndDestroy( resp );
+        CleanupStack::PopAndDestroy( &objs );
+        CleanupStack::PopAndDestroy( &listOfAllObjects );
+        }
+    else //no valid browseflag
+        {
+        User::Leave( EInvalidArgs );
+        }
+
+    RDebug::Print( _L( "CUpnpContentDirectory::BrowseL Result got OK" ) );
+
+    CleanupStack::PopAndDestroy( filter );
+
+    return EHttpOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::SerializeObjectsListL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpContentDirectory::SerializeObjectsListL(
+    const RArray<RXmlEngDocument>& aObjs )
+    {
+    CBufFlat* buff = CBufFlat::NewL( KRespBufGranularity );
+    CleanupStack::PushL( buff );
+
+    // Didl start
+    UpnpString::AppendStringL( *buff, KDidlTag );
+
+    // content
+    for ( TInt i = 0; i < aObjs.Count( ); i++ )
+        {
+        RBuf8 tmp;
+        TXmlEngSerializationOptions
+                options(TXmlEngSerializationOptions::KOptionOmitXMLDeclaration
+                        | TXmlEngSerializationOptions::KOptionIncludeNsPrefixes);
+        aObjs[i].SaveL( tmp, iElementdb->ActiveElementL( aObjs[i] ), options );
+        CleanupClosePushL( tmp );
+        UpnpString::AppendStringL( *buff, tmp );
+        UpnpString::AppendStringL( *buff, KLF8 );
+        CleanupStack::PopAndDestroy( &tmp );
+        }
+
+    // Didl end
+    UpnpString::AppendStringL( *buff, KDidlEnd );
+
+    // prepare to return
+    HBufC8* ret = UpnpCdUtils::EncodeXmlStringL( buff->Ptr( 0 ) );
+
+    // clean up
+    CleanupStack::PopAndDestroy( buff );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::DestroyObjectL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::DestroyObjectL( CUpnpAction*& aAction )
+    {
+    TInt objId( KErrNotFound );
+
+    TInt error(0);
+    error = UpnpCdUtils::StringToInteger(
+        (TDesC8&)aAction->ArgumentValue( UpnpCD::KObjectID( ) ), &objId );
+    if ( (error == KErrArgument)||(error == KErrOverflow) )
+        {
+        User::Leave( ENoSuchObject );
+        }
+    else if ( error<0 )
+        {
+        User::Leave( error );
+        }
+    // check object restriction
+    TUpnpErrorCode err = iContentDirectoryDb->CheckObjectRestrictionL( objId ); // if returned ENoContainer it is OK because first of all the restriction is checked
+    if ( err == ERestrictedObject || err == ENoSuchObject )
+        {
+        User::Leave( err );
+        }
+
+    // check parent restriction
+    err = iContentDirectoryDb->CheckObjectRestrictionL( objId );
+    if ( err == ERestrictedObject )
+        {
+        User::Leave( ERestrictedParentObject );
+        }
+
+    // root and download containers must not be deleted
+    if ( objId <= KDownloadContId )
+        {
+        /*
+         Designing a UPnP AV MediaServer (3.2.4): 
+         "If a CDS implementation exposes a CDS object that is not restricted but cannot fulfill a
+         CDS:DestroyObject(), CDS:CreateObject(), or CDS:UpdateObject() request, then the MediaServer should
+         return error code 720 to indicate the request could not be processed."
+         */
+        User::Leave( ECannotProcess );
+        }
+
+    RArray<TInt> refList;
+    CleanupClosePushL( refList );
+
+    TBuf8<KMaxIntegerLen> containerID;
+    containerID.Num( iContentDirectoryDb->GetParentIdL( objId ) );
+
+    iContentDirectoryDb->DeleteObjectL( objId, refList, ETrue );
+
+    iStateHandler->IncreaseSystemUpdateIdL( );
+    iStateHandler->IncreaseContainerUpdateIdL( containerID );
+
+    for ( TInt i(0); i<refList.Count( ); i++ )
+        {
+        if ( objId!=refList[i] )
+            {
+            containerID.Num( refList[i] );
+            iStateHandler->IncreaseSystemUpdateIdL( );
+            iStateHandler->IncreaseContainerUpdateIdL( containerID );
+            }
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &refList );
+    return EHttpOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::AddToMetaDbL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::AddToMetaDbL(
+    RXmlEngDocument& aFragment, TInt aContainer, TInt* aId, TBool aIsLocal )
+    {
+    // res list
+    RArray<TXmlEngElement> resList;
+    CleanupClosePushL( resList );
+    UpnpDomInterface::GetElementListL( aFragment.DocumentElement( ), resList,
+        KRes );
+
+    // a source file for thumbnail
+    HBufC* thumbSrcFile = NULL;
+
+    if ( aIsLocal )
+        { // local action
+        // create thumbnail if there is only one res in the object
+        if ( resList.Count( ) == 1 )
+            {
+            // get resource file name
+            TPtrC8 val(resList[0].Text( ));
+            // ignore if empty string
+            if ( val.Length( ) && (!UpnpCdUtils::IsWhiteString( val )) )
+                {
+                TUriParser8 up;
+                User::LeaveIfError( up.Parse( val ) );
+                if ( up.Extract( EUriScheme ) == UpnpHTTP::KSchemeFile8 )
+                    {
+                    thumbSrcFile = up.GetFileNameL( ); // thumbnail will be created at the end of this function
+                    CleanupStack::PushL( thumbSrcFile );// and the pointer will be poped 
+                    }
+                }
+            }
+        TInt nextId = iContentDirectoryDb->GetObjectIdL( );
+        // handle resources
+        for ( TInt i = 0; i < resList.Count( ); i++ )
+            {
+            HandleLocalResourcesL( resList[i], nextId );
+            }
+        }
+
+    // if only one empty res add importUri
+    if ( resList.Count( ) )
+        {
+        TPtrC8 resValue(resList[0].Text( ));
+        if ( !resValue.Length( ) || UpnpCdUtils::IsWhiteString( resValue ) )
+            {
+            AddImportUriToElL( resList[0] );
+            }
+        }
+    if ( !resList.Count( ) )
+        {
+        AddNewResTagL( aFragment.DocumentElement( ) );
+        }
+    // add to database
+    TUpnpErrorCode ret = iContentDirectoryDb->InsertObjectL( aFragment,
+        aContainer, aId );
+    if ( ret == EUpnpOk )
+        {
+        PrepareAutoDestroyObjectL( aFragment.DocumentElement( ), *aId );
+        ret = EHttpOk;
+        }
+
+    if ( thumbSrcFile )
+        {
+        CreateThumbnailL( *thumbSrcFile, *aId );
+        CleanupStack::PopAndDestroy( thumbSrcFile );
+        }
+    CleanupStack::PopAndDestroy( &resList );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateThumbnailForResourceL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::PrepareAutoDestroyObjectL(
+    TXmlEngElement aObject, TInt aObjId )
+    {
+    // check res
+    RArray<TXmlEngElement> resList;
+    CleanupClosePushL( resList );
+    UpnpDomInterface::GetElementListL( aObject, resList, KRes );
+    if ( resList.Count( ) > 0 )
+        {
+        // only first res is important
+        TPtrC8 resValue(resList[0].Text( ));
+        if ( !resValue.Length( ) || UpnpCdUtils::IsWhiteString( resValue ) )
+            {
+            TXmlEngAttr impUri = resList[0].AttributeNodeL( KImportUri( ) );
+            // auto destroy
+            CUpnpAutoDestroyObject* ado = CUpnpAutoDestroyObject::NewLC(
+                this, aObjId, UpnpCdUtils::ResIdFromUriL( impUri.Value( ) ) );
+            iAutoDestroyObjects->AppendL( ado );
+            CleanupStack::Pop( ado );
+            }
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy( &resList );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateThumbnailForResourceL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::CreateThumbnailL( const TDesC& aSrcFile,
+    TInt aObjId )
+    {
+    if ( iCreateThumbnails && IsThumbnailAvailableL( aSrcFile ) )
+        {
+        // thumbnail name
+        HBufC* thumbName = CreateNameForThumbnailL( aSrcFile );
+        CleanupStack::PushL( thumbName );
+
+        // create thumbnail creator
+        CUpnpThumbnailCreator* thCreator = CreateThumbnailCreatorL( aObjId ); // do not push it onto CleanupStack
+        // ThumbnailCreator is created and added to iThumbnailCreators
+        // but the creation process is not yet started,
+        // therefore, not leaving code should be performed until the thCreator->CreateL method is called
+        if ( thCreator )
+            {
+            // start creation process
+            TRAPD( err, thCreator->CreateL( aSrcFile, *thumbName ) );
+            if ( err )
+                {
+                RDebug::Print( _L( "Error while creating thumbnail, it won't be created. Removing from creator list." ) );
+                RemoveThCreatorAndObjectIdLD( thCreator );
+                }
+            iEcomUsed = ETrue;
+            }
+        // clean up
+        CleanupStack::PopAndDestroy( thumbName );
+        }
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::IsThumbnailAvailableL
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectory::IsThumbnailAvailableL( const TDesC& aFile )
+    {
+    HBufC8* tmp = HBufC8::NewLC( aFile.Length( ) );
+    tmp->Des().Copy( aFile );
+    TBool ret = IsThumbnailAvailableL( *tmp );
+    CleanupStack::PopAndDestroy( tmp );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::IsThumbnailAvailableL
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectory::IsThumbnailAvailableL( const TDesC8& aFile )
+    {
+    TBool result = EFalse;
+
+    // get mime type for file
+    HBufC8* mt = GetMimeTypeLC( aFile );
+    TPtr8 mimeType(mt->Des( ));
+    mimeType.LowerCase( );
+
+    if ( !mimeType.Compare( KMT_IMAGE_JPEG( ) ) )
+        {
+        result = ETrue;
+        }
+    else if ( !mimeType.Compare( KMT_IMAGE_PNG( ) ) )
+        {
+        result = ETrue;
+        }
+    else if ( !mimeType.Compare( KMT_IMAGE_GIF( ) ) )
+        {
+        result = ETrue;
+        }
+    else if ( !mimeType.Compare( KMT_IMAGE_BMP( ) ) )
+        {
+        result = ETrue;
+        }
+    CleanupStack::PopAndDestroy( mt );
+
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::AddImportUriToElL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::AddImportUriToElL( TXmlEngElement aElement )
+    {
+    HBufC8* impUriVal = BuildImportUriShorterLC( );
+    HBufC8* impUriValRandomize = HBufC8::NewLC( impUriVal->Des().Length( )+ KRandomRangeLength );
+    HBufC8* number = UpnpCdUtils::RandomizeL( KRandomMax );
+    CleanupStack::PushL( number );
+    impUriValRandomize->Des().Copy( *impUriVal );
+    impUriValRandomize->Des().Append( *number );
+    aElement.AddNewAttributeL( KImportUri( ), *impUriValRandomize );
+    // clean up
+    CleanupStack::PopAndDestroy( number );
+    CleanupStack::PopAndDestroy( impUriValRandomize );
+    CleanupStack::PopAndDestroy( impUriVal );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::AddNewResTagL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::AddNewResTagL( TXmlEngElement aObjEl )
+    {
+    TXmlEngElement item;
+    UpnpDomInterface::GetElementL( aObjEl, item, KItem );
+
+    // ignore if null
+    if ( item.NotNull( ) )
+        {
+        TXmlEngElement newEl = item.AddNewElementL( KRes( ) );
+        newEl.AddNewAttributeL( KprotocolInfo( ), KEmptyProtocolInfoVal8( ) );
+        newEl.AddNewAttributeL( KProtInfoReqAtrSufPattern( ), KTrueValue8( ) );
+        // add importUri
+        AddImportUriToElL( newEl );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::BuildContentUriL
+// -----------------------------------------------------------------------------
+HBufC8* CUpnpContentDirectory::BuildContentUriL( const TDesC& aFileExt,
+    TInt aObjectId )
+    {
+    TBuf8<KMaxIntegerLen> objectId;
+    objectId.Num( aObjectId );
+    return UpnpCdUtils::BuildContentUriL(
+        iContentDirectoryDb->GetKeyForUriL( ), aFileExt, objectId );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::BuildImportUriL
+// -----------------------------------------------------------------------------
+HBufC8* CUpnpContentDirectory::BuildImportUriLC()
+    {
+    return UpnpCdUtils::BuildImportUriLC( iContentDirectoryDb->GetKeyForUriL( ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::BuildImportUriShorterLC
+// -----------------------------------------------------------------------------
+HBufC8* CUpnpContentDirectory::BuildImportUriShorterLC()
+    {
+    return UpnpCdUtils::BuildImportUriShorterLC( iContentDirectoryDb->GetKeyForUriL( ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::InsertRealIpAndPortL
+// -----------------------------------------------------------------------------
+void CUpnpContentDirectory::InsertRealIpAndPortL( TDes8& aString )
+    {
+    // prepare pettern
+    HBufC8* pattern = HBufC8::NewLC( KHttpTag().Length( ) + KIpPortPlaceholder8().Length( ) );
+    TPtr8 patternPtr(pattern->Des( ));
+    patternPtr.Append( KHttpTag );
+    patternPtr.Append( KIpPortPlaceholder8 );
+
+    // repare address
+    HBufC8* address = GetIpAndPortDes8L( );
+    CleanupStack::PushL( address );
+
+    TInt pos = aString.Find( patternPtr );
+
+    while ( pos != KErrNotFound )
+        {
+        aString.Replace( pos + KHttpTag().Length( ), KIpPortPlaceholder8().Length( ), *address );
+        pos = aString.Find( patternPtr );
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy( address );
+    CleanupStack::PopAndDestroy( pattern );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::InsertIpAndPortPlaceholderL
+// -----------------------------------------------------------------------------
+HBufC8* CUpnpContentDirectory::InsertIpAndPortPlaceholderL(
+    const TDesC8& aString )
+    {
+    HBufC8* ipAndPort = GetIpAndPortDes8L( );
+    CleanupStack::PushL( ipAndPort );
+
+    HBufC8* ret = aString.AllocLC( );
+
+    TInt pos = KErrNotFound;
+    while ( (pos = ret->Find( *ipAndPort )) != KErrNotFound )
+        {
+        // realloc if too small
+        if ( ipAndPort->Length( ) < KIpPortPlaceholder8().Length( ) )
+            {
+            HBufC8* tmp = ret->ReAllocL( ret->Length( )
+                    + KIpPortPlaceholder8().Length( ) - ipAndPort->Length( ) );
+            CleanupStack::Pop( ret );
+            ret = tmp;
+            CleanupStack::PushL( ret );
+            }
+        ret->Des().Replace( pos, ipAndPort->Length( ), KIpPortPlaceholder8 );
+        }
+    // clean up
+    CleanupStack::Pop( ret );
+    CleanupStack::PopAndDestroy( ipAndPort );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetAddress
+// -----------------------------------------------------------------------------
+TInetAddr CUpnpContentDirectory::GetAddress()
+    {
+    TInetAddr resourceServerAddress;    
+    iHttpServerSession->GetAddress( resourceServerAddress );
+    return resourceServerAddress;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::AutoDestroyObjectList
+// -----------------------------------------------------------------------------
+CUpnpAutoDestroyObjectList* CUpnpContentDirectory::GetAutoDestroyObjectList()
+    {
+    return iAutoDestroyObjects;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetIpAndPortDes8L
+// -----------------------------------------------------------------------------
+HBufC8* CUpnpContentDirectory::GetIpAndPortDes8L()
+    {
+    TInetAddr resourceServerAddress = GetAddress();        
+    
+    TBuf<KMaxName> addrTmp;
+    resourceServerAddress.Output( addrTmp );
+    HBufC8* addr = UpnpString::FromUnicodeL( addrTmp );
+    CleanupStack::PushL( addr );
+    
+    TInt portNo = resourceServerAddress.Port();
+    TBuf8<KMaxName> port;
+    port.Num( portNo );
+    
+    HBufC8* temp = HBufC8::NewLC( addr->Length( ) + KColon8().Length( ) + port.Length( ) );
+    TPtr8 tempPtr( temp->Des() );
+    tempPtr.Copy( *addr );
+    tempPtr.Append( KColon8 );
+    tempPtr.Append( port );
+
+    CleanupStack::Pop( temp );
+    CleanupStack::PopAndDestroy( addr );
+
+    return temp;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetSearchCapabilitiesL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::GetSearchCapabilitiesL(
+    CUpnpAction*& aAction )
+    {
+    aAction->SetArgumentL( KSearchCaps,
+        StateVariableValue( KSearchCapsVariableName ) );
+    return EHttpOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetSortCapabilitiesL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::GetSortCapabilitiesL(
+    CUpnpAction*& aAction )
+    {
+    aAction->SetArgumentL( KSortCaps,
+        StateVariableValue( KSortCapsVariableName ) );
+    return EHttpOk;
+    } 
+ 
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetSystemUpdateIdL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::GetSystemUpdateIdL(
+    CUpnpAction*& aAction )
+    {
+    const TPtrC8 idValue = StateVariableValue( (TDesC8&)KSystemUpdateID );
+    aAction->SetArgumentL( KId, idValue );
+    return EHttpOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ImportResourceL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::ImportResourceL( CUpnpAction*& aAction )
+    {
+    if ( iTransferController->IsMaxImportExportTransfers( ) )
+        {
+        return ETransferBusy;
+        }
+
+    TPtrC8 src = aAction->ArgumentValue( (TDesC8&) KSourceURI );
+    TPtrC8 dest = aAction->ArgumentValue( (TDesC8&) KDestinationURI );
+    TUriParser8 srcParser;
+    TUriParser8 dstParser;
+
+    if ( !(dstParser.Parse( dest ) == 
+          KErrNone && dstParser.Extract( EUriScheme ).CompareF( UpnpHTTP::KSchemeHTTP8 ) == 0 ) )
+        {
+        User::Leave( ENoDestinationResource );
+        }
+
+    // there are placeholders instead the real values in the database
+    HBufC8* destBuf = InsertIpAndPortPlaceholderL( dest );
+    CleanupStack::PushL( destBuf );
+
+    TInt objId;
+    // object existence
+    if ( (objId
+            = iContentDirectoryDb->GetObjIdByAttrL( KImportUri8, *destBuf ) )
+            == KErrNotFound )
+        {
+        User::Leave( ENoDestinationResource );
+        }
+    // object restrictions
+    if ( iContentDirectoryDb->CheckObjectRestrictionL( objId )
+            == ERestrictedObject )
+        {
+        User::Leave( ERestrictedObject );
+        }
+    // parent restricions
+    if ( iContentDirectoryDb->CheckParentRestrictionL( objId ) != EUpnpOk )
+        {
+        User::Leave( ERestrictedParentObject );
+        }
+
+    TInt destinationCut = dest.LocateReverse( '/' );
+    if ( destinationCut < KErrNone )
+        {
+        User::Leave( EInvalidArgs );
+        }
+
+    HBufC* name = GetCopyFileNameL( objId );
+    CleanupStack::PushL( name );
+    if ( !name )
+        {
+        User::Leave( ENoDestinationResource );
+        }
+
+    for ( TInt i( 0); i < iTransferController->iFileTransfers.Count( ) ; i++ )
+        {
+        if ( iTransferController->iFileTransfers[i]->ObjectId( ) == objId
+                && iTransferController->iFileTransfers[i]->TransferState( )
+                        == ETransferInProgress )
+            {
+            User::Leave( EDestinationAccess );
+            }
+        }
+
+    HBufC8* name8 = UpnpString::FromUnicodeL( *name );
+    CleanupStack::PushL( name8 );
+
+    TPtr8 fileNamePtr(name8->Des( ) );
+
+    HBufC16* fileNamePtr16 = UpnpString::ToUnicodeL( fileNamePtr );
+    CleanupStack::PushL( fileNamePtr16 );
+    TParse parseFilename;
+    parseFilename.Set( fileNamePtr16->Des( ), NULL, NULL );
+    HBufC16* diskNameTemp=parseFilename.Drive().Alloc( );
+    HBufC16* diskName = diskNameTemp->ReAlloc( diskNameTemp->Des().Length( ) +
+                                               KDiskPathElSep().Length( ) );
+    CleanupStack::PushL( diskName );
+    TPtr16 diskNamePtr = diskName->Des( );
+    diskNamePtr.Append( KDiskPathElSep );
+    if ( !BaflUtils::PathExists( iFs, diskNamePtr ) )
+        {
+        User::Leave( ENoDestinationResource );
+        }
+
+    UpnpString::ReplaceHttpCharacters( fileNamePtr );
+
+    // forbidden chars
+    UpnpCdUtils::ValidateFilePath( fileNamePtr );
+
+    HBufC* targetPath = HBufC::NewMaxLC( fileNamePtr.Length( ) );
+    TPtr targetPtr = targetPath->Des( );
+    targetPtr.Copy( fileNamePtr );
+
+    TInt transferid = CUpnpHttpMessage::NewSessionIdL( );
+    iTransferHandler->DownloadFileL( transferid, src, targetPtr );
+
+    CleanupStack::PopAndDestroy( targetPath );
+
+    TransferStartL( dest );
+
+    TBuf8<KMaxIntegerLen> tid;
+    tid.Num( transferid );
+    aAction->SetArgumentL( (TDesC8&)KTransferID, tid );
+
+    CUpnpFileTransfer* transfer = CUpnpFileTransfer::NewLC( transferid,
+        objId, CUpnpFileTransfer::EImport );
+
+    transfer->SetTransferState(:: ETransferInProgress );
+
+    // starting to get the number if import
+    TPtrC8 dest1 = aAction->ArgumentValue( (TDesC8&) KDestinationURI );
+    TInt posOfLastSlash = dest1.LocateReverse( '/' );
+    if( posOfLastSlash != KErrNotFound )
+        {
+        dest1.Set( dest1.Mid( posOfLastSlash + 1 ) );
+        // converting value
+        TLex8 string( dest1 );
+        TInt value( 0 );
+        TInt error = string.Val( value );
+        // conversion ok, we can add this to 
+        if( error == KErrNone )
+            {
+            transfer->SetImportNumber( value );
+            }
+        }
+    //add transfer to transfers list
+    CleanupStack::Pop( transfer );
+    iTransferController->iFileTransfers.Append( transfer );
+
+    HBufC* fileName16 = UpnpString::ToUnicodeL( *name8 );
+    CleanupStack::PushL( fileName16 );
+
+    CUpnpFileTransferEvent* event = CUpnpFileTransferEvent::NewLC();
+    event->SetProgressState( CUpnpFileTransferEvent::ECompleted );
+    event->SetDirection( CUpnpFileTransferEvent::EIncoming );
+    event->SetFilePathL( *fileName16 );
+    event->SetContentDirectoryObjectId( objId );
+    event->SetTransferId( transferid );
+    CleanupStack::Pop( event );
+    transfer->SetEvent( event );
+
+    AddFileTransferToTransferIDsStateVariableL( transferid );
+    // clean up
+    CleanupStack::PopAndDestroy( fileName16 );
+    CleanupStack::PopAndDestroy( diskName );
+    CleanupStack::PopAndDestroy( fileNamePtr16 );
+    CleanupStack::PopAndDestroy( name8 );
+    CleanupStack::PopAndDestroy( name );
+    CleanupStack::PopAndDestroy( destBuf );
+
+    return EHttpOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ExportResourceL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::ExportResourceL( CUpnpAction*& aAction )
+    {
+    if ( iTransferController->IsMaxImportExportTransfers( ) )
+        {
+        return ETransferBusy;
+        }
+    HBufC8* srcBuf = aAction->ArgumentValue( KSourceURI ).AllocLC( );
+    TPtr8 src(srcBuf->Des( ));
+    UpnpString::ReplaceHttpCharacters( src );
+
+    HBufC8* ipAndPort = GetIpAndPortDes8L( );
+    CleanupStack::PushL( ipAndPort );
+    UpnpCdUtils::ValidateSrcUriL( src, *ipAndPort );
+    CleanupStack::PopAndDestroy( ipAndPort );
+
+    TPtrC8 dest = aAction->ArgumentValue( KDestinationURI );
+
+    // check src existence -----------------------------
+    CUpnpResourcesBean* rscBean = NULL;
+    TRAPD(
+        error,
+        rscBean
+                = iContentDirectoryDb->GetResourceL( UpnpCdUtils::ResIdFromUriL( src ) ) );
+    if ( error < 0 || !rscBean )
+        {
+        User::Leave( ENoSourceResource );
+        }
+    CleanupStack::PushL( rscBean );
+    // check whether resource and src uri file names matches
+    TPtrC rscPath(rscBean->Path( ) );
+
+    if ( !BaflUtils::FileExists( iFs, rscPath ) )
+        {
+        User::Leave( ENoSourceResource );
+        }
+
+    TParse rscParse;
+    rscParse.Set( rscPath, NULL, NULL );
+    TPtrC rscFileName = rscParse.NameAndExt( );
+
+    TBuf8<KMaxIntegerLen> objId;
+    objId.Num( rscBean->ObjectId( ) );
+
+    TPtrC rscFileExt = rscParse.Ext( );
+    HBufC8* srcNoEsc = src.AllocLC( );
+    TPtr8 srcNoEscPtr(srcNoEsc->Des( ));
+
+    HBufC* srcPath = UpnpCdUtils::Des8ToDesLC( srcNoEscPtr );
+    TPtr srcPathPtr(srcPath->Des( ) );
+
+    TInt position = srcPathPtr.LocateReverse( '/' );
+    HBufC* newFileName = HBufC::NewLC( KMaxIntegerLen + rscFileExt.Length( ) );
+    newFileName->Des().Copy( objId );
+    newFileName->Des().Append( rscFileExt );
+    if ( position )
+        {
+        position = srcPathPtr.Length( )-position-1;
+        TPtrC srcFilePtr = srcPathPtr.Right( position );
+        if ( srcFilePtr.Compare( *newFileName ) )
+            {
+            User::Leave( ENoSourceResource );
+            }
+        }
+    if ( srcPathPtr.Find( *newFileName ) == KErrNotFound )
+        {
+        User::Leave( ENoSourceResource );
+        }
+    // get mimeType = Content-Type in the header
+    HBufC8* contentType = UpnpFileUtil::GetMimeTypeForFileL( *newFileName );
+    TPtrC8 contentTypePtr(contentType->Des( ) );
+
+    CleanupStack::PopAndDestroy( newFileName );
+    CleanupStack::PushL( contentType );
+
+    //checking number of slash in sourceURI 
+    TInt numberOfSlash(0);
+    position = srcPathPtr.LocateReverse( '/' );
+    while ( position>0 )
+        {
+        numberOfSlash++;
+        if ( numberOfSlash>KMaxSlashAmount )
+            {
+            User::Leave( ENoSourceResource );
+            }
+        srcPathPtr = srcPathPtr.Left( position );
+        position = srcPathPtr.LocateReverse( '/' );
+        }
+
+    TInt transferid = CUpnpHttpMessage::NewSessionIdL( );
+    iTransferHandler->UploadFileL( transferid, dest, rscPath, contentTypePtr );
+
+    TBuf8<KMaxIntegerLen> tid;
+    tid.Num( transferid );
+    aAction->SetArgumentL( (TDesC8&)KTransferID, tid );
+
+    TPtrC8 pert = UpnpCdUtils::ResIdFromUriDesL( src );
+
+    TInt objectId = rscBean->ObjectId( );
+    CUpnpFileTransfer* transfer = CUpnpFileTransfer::NewL( transferid,
+        objectId, CUpnpFileTransfer::EExport );
+    transfer->SetTransferState(:: ETransferInProgress);
+
+    iTransferController->iFileTransfers.Append( transfer );
+
+    CUpnpFileTransferEvent* event = CUpnpFileTransferEvent::NewLC();
+    event->SetProgressState( CUpnpFileTransferEvent::ECompleted );
+    event->SetDirection( CUpnpFileTransferEvent::EOutgoing );
+    event->SetFilePathL( rscPath);
+    event->SetContentDirectoryObjectId( objectId );
+    event->SetTransferId( transferid );
+    CleanupStack::Pop( event );
+    transfer->SetEvent(event);
+
+    AddFileTransferToTransferIDsStateVariableL( transferid );
+    CleanupStack::PopAndDestroy( contentType );
+    CleanupStack::PopAndDestroy( srcPath );
+    CleanupStack::PopAndDestroy( srcNoEsc );
+    CleanupStack::PopAndDestroy( rscBean );
+    CleanupStack::PopAndDestroy( srcBuf );
+
+    return EHttpOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::StopTransferResourceL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::StopTransferResourceL(
+    CUpnpAction*& aAction )
+    {
+    TInt transferId;
+    TInt err =
+            UpnpString::StringToInt(
+                (TDesC8&) aAction->ArgumentValue( (TDesC8&)KTransferID ),
+                &transferId );
+    if ( KErrNone != err )
+        {
+        User::Leave( ENoFileTransfer );
+        }
+    TUpnpErrorCode
+            upnpErr(iTransferController->StopTransferResourceL( transferId ) );
+    TransferCompletedL( transferId, KErrCancel );
+    return upnpErr;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetTransferProgressL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::GetTransferProgressL(
+    CUpnpAction*& aAction )
+    {
+    TUint transferId;
+    TInt length( KErrNone );
+    TInt totalLength( KErrNone );
+    // TInt lenght is max 15 digits, KMaxInfoName is 16
+    TBuf8<KMaxInfoName> res;
+
+    TInt err = UpnpCdUtils::StringToTUint(
+        (TDesC8&)aAction->ArgumentValue( (TDesC8&)KTransferID ), &transferId );
+
+    if ( KErrNone != err )
+        {
+        User::Leave( EInvalidArgs );
+        }
+    if ( transferId > KMaxTInt )
+        {
+        User::Leave( ENoFileTransfer );
+        }
+    TInt transferFound = iTransferController->Transfer( transferId );
+    if ( KErrNotFound == transferFound )
+        {
+        User::Leave( ENoFileTransfer );
+        }
+
+    switch ( (iTransferController->iFileTransfers[ transferFound ])->TransferState( ) )
+        {
+        case:: ETransferInProgress:
+            {
+            aAction->SetArgumentL( (TDesC8&)KTransferStatus, KInProgress );
+            break;
+            }
+        case EStopped:
+            {
+            aAction->SetArgumentL( (TDesC8&)KTransferStatus, KStopped );
+            break;
+            }
+        case EError:
+            {
+            aAction->SetArgumentL( (TDesC8&)KTransferStatus, KError );
+            break;
+            }
+        case ECompleted:
+            {
+            aAction->SetArgumentL( (TDesC8&)KTransferStatus, KCompleted );
+            break;
+            }
+        default:
+            {
+            break;
+            }
+        }
+    length = (iTransferController->iFileTransfers[ transferFound ])->TransferLength();
+    totalLength = (iTransferController->iFileTransfers[ transferFound ])->TransferTotal();
+
+    res.Num( length );
+    aAction->SetArgumentL( (TDesC8&)KTransferLength, res );
+    res.Num( totalLength );
+    aAction->SetArgumentL( (TDesC8&)KTransferTotal, res );
+    return EHttpOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::DeleteResourceL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::DeleteResourceL( CUpnpAction*& aAction )
+    {
+    TPtrC8 uri8(aAction->ArgumentValue( KResourceURI( ) ));
+
+    if ( !uri8.Length( ) )
+        User::Leave( ENoSourceResource );
+
+    // replace http characters
+    HBufC8* uri = uri8.AllocLC( );
+    TPtr8 uriPtr(uri->Des( ));
+
+    // ip placeholder
+    HBufC8* internalUri = InsertIpAndPortPlaceholderL( uriPtr );
+    CleanupStack::PushL( internalUri );
+    // delete resource
+    RArray<TInt> contIds;
+    CleanupClosePushL( contIds );
+    iContentDirectoryDb->DeleteResourceL( *internalUri, contIds );
+
+    // updateIDs
+    for ( TInt i = 0; i < contIds.Count( ); i++ )
+        {
+        TBuf8<KMaxIntegerLen> num;
+        num.Num( contIds[i] );
+        iStateHandler->IncreaseContainerUpdateIdL( num );
+        }
+
+    // systemUpdateId
+    iStateHandler->IncreaseSystemUpdateIdL( );
+
+    // clean up
+    CleanupStack::PopAndDestroy( &contIds );
+    CleanupStack::PopAndDestroy( internalUri );
+    CleanupStack::PopAndDestroy( uri );
+
+    return EHttpOk;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::AddFileTransferL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::AddFileTransferToTransferIDsStateVariableL(
+    TInt aTransferID )
+    {
+    TBuf8<KMaxIntegerLen> tid;
+    tid.Format( UpnpCD::KOneNumber, aTransferID );
+    TPtrC8 tmp = StateVariableValue( KTransferIDs( ) );
+    HBufC8* buf = UpnpString::AddValueToCsvL( tmp, tid );
+    CleanupStack::PushL( buf );
+    SetStateVariableL( KTransferIDs( ), *buf, EFalse );
+    CleanupStack::PopAndDestroy( buf );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::RemoveFileTransferL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::RemoveFileTransferFromTransferIDsStateVariableL(
+    TInt aTransferID )
+    {
+    TBuf8<KMaxIntegerLen> tid;
+    tid.Format( UpnpCD::KOneNumber, aTransferID );
+    TPtrC8 tmp = StateVariableValue( KTransferIDs( ) );
+    HBufC8* buf = UpnpString::RemoveFromCsvLC( tmp, tid );
+    SetStateVariableL( KTransferIDs( ), *buf, EFalse );
+    CleanupStack::PopAndDestroy( buf );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ContainerUpdateId
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectory::ContainerUpdateId( const TDesC8& aContainerID )
+    {
+    return iStateHandler->ContainerUpdateId( aContainerID );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateObjectL
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectory::CreateObjectL( CUpnpAction*& aAction )
+    {
+    SetExecutedAction( ECreateObjectAction );
+
+    HBufC8* objNoDes(aAction->ArgumentValue(KContainerID()).AllocLC( ) );
+    TPtr8 objNoPtr(objNoDes->Des( ));
+    objNoPtr.TrimAll( );
+
+    TInt objNo = KErrNotFound; // container id
+    TInt error( KErrGeneral );
+
+    // any container support
+    if ( !objNoPtr.Compare( KAnyContainerIndicator8 ) )
+        {
+        objNo = KAnyContainerId;
+        }
+    else
+        {
+        // checking whether containerID has proper decimal value
+        error = UpnpCdUtils::StringToInteger( objNoPtr, &objNo );
+        if ( error != KErrNone )
+            {
+            User::Leave( ENoContainer );
+            }
+
+        TUpnpErrorCode err =
+                iContentDirectoryDb->CheckObjectRestrictionL( objNo );
+        if ( err != EUpnpOk )
+            {
+            CleanupStack::PopAndDestroy( objNoDes );
+            if ( err == ENoSuchObject )
+                err = ENoContainer;
+            if ( err == ERestrictedObject )
+                err = ERestrictedParentObject;
+            return err;
+            }
+        }
+    CleanupStack::PopAndDestroy( objNoDes );
+
+    // now we have found the unrestricted parent container
+    // let's inspect the element that should be added
+    // decode "elements" argument of the create action
+    const TDesC8& elem = (TDesC8&)aAction->ArgumentValue( KElements( ) );
+
+    // check that we've got correctly formed xml
+    if ( elem.FindF( KXmlNsDc( ) ) == KErrNotFound )
+        {
+        User::Leave( EBadMetadata );
+        }
+
+    HBufC8* trimmed = UpnpString::TrimLC( elem, EFalse );
+
+    HBufC8* trimmedlf8 = UpnpString::StringReplaceL( *trimmed, KLF8,
+        KNullString8 );
+    CleanupStack::PushL( trimmedlf8 );
+    // parse decoded buffer
+    RXmlEngDocument fragment;
+    TRAPD( xmlerr, fragment = XmlFragmentL( *trimmedlf8 ) );
+    if ( xmlerr )
+        {
+        RDebug::Print( _L( "CUpnpContentDirectory::CreateObjectL ERROR IN XML" ) );
+        User::Leave( xmlerr );
+        }
+    CleanupClosePushL( fragment );
+
+    // if container, check the number of nested levels
+    TXmlEngElement container;
+    UpnpDomInterface::GetElementL( fragment.DocumentElement( ), container,
+        KContainer );
+    if ( container.NotNull( ) && !iContentDirectoryDb->CanBeNestedL( objNo ) )
+        {
+        User::Leave( ECannotProcess );
+        }
+
+    RArray<TXmlEngAttr> importUris;
+    CleanupClosePushL( importUris );
+    RArray<TXmlEngElement> ress;
+    CleanupClosePushL( ress );
+
+    TBool isLocal = aAction->Local( );
+
+    // to avoid errors in validation process
+    UpnpCdUtils::SetObjectIdL( UpnpCdUtils::GetObjectElementL( fragment ),
+        objNo ); // value does not matter - it will be changed later
+    UpnpCdUtils::SetContainerIdL( UpnpCdUtils::GetObjectElementL( fragment ),
+        objNo );
+
+    //created new object shouldn't have refID value
+    if ( UpnpCdUtils::HasRefIdL( fragment ) )
+        {
+        User::Leave( EParameterMismatch );
+        }
+
+    // validate the new element
+    iElementdb->ValidateNewObjectL( fragment.DocumentElement( ), ETrue,
+        isLocal );
+
+    // now we have fragment, lets add this to CD metadata
+    TInt id( KErrNotFound );
+    TUpnpErrorCode err = AddToMetaDbL( fragment, objNo, &id, isLocal );
+
+    CleanupStack::PopAndDestroy( &ress );
+    CleanupStack::PopAndDestroy( &importUris );
+
+    ConstructCreateResultsetL( aAction, fragment, id );
+
+    CleanupStack::PopAndDestroy( &fragment );
+    CleanupStack::PopAndDestroy( trimmedlf8 );
+    CleanupStack::PopAndDestroy( trimmed );
+
+    if ( err == EHttpOk )
+        {
+        iStateHandler->IncreaseSystemUpdateIdL( );
+        iStateHandler->IncreaseContainerUpdateIdL( 
+                             ( TDesC8& )aAction->ArgumentValue( KContainerID ) );
+
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::HandleLocalResourcesL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::HandleLocalResourcesL( TXmlEngElement aRes,
+    TInt aObjectId )
+    {
+    // contentUri, contentPath          
+    TUriParser8 up;
+    TPtrC8 resVal = aRes.Text( );
+    if ( resVal.Length( ) )
+        {
+        TPtrC8 resValCandidatePtr(resVal);
+
+        // There should be no slash at the end of URI, if so -> leave occurs
+        if ( resValCandidatePtr.Length( ) > 0 )
+            {
+            if ( !resValCandidatePtr.Right(1).Compare( KSlash8( ) ) )
+                {
+                User::Leave( EBadMetadata );
+                }
+            }
+
+        User::LeaveIfError( up.Parse( resValCandidatePtr ) );
+
+        // get schema
+        TPtrC8 scheme(up.Extract( EUriScheme ));
+
+        // only local sharing
+        if ( !scheme.Compare( UpnpHTTP::KSchemeFile8 ) )
+            {
+            HBufC* fn = UpnpString::ToUnicodeL( resValCandidatePtr );
+            CleanupStack::PushL( fn );
+
+            TInt extPosition = fn->Des().LocateReverse( '.' );
+            TPtrC ext;
+            if ( extPosition>0 )
+                ext.Set( fn->Des().Mid( extPosition ) );
+            else
+                ext.Set( KNullString );
+
+            HBufC8* contentUri = BuildContentUriL( ext, aObjectId );
+            CleanupStack::PushL( contentUri );
+
+            HBufC* contentPath = up.GetFileNameL( );
+            CleanupStack::PushL( contentPath );
+
+            // update res tag
+            aRes.SetTextL( *contentUri );
+
+            // add resource to the database
+            CUpnpResourcesBean* resBn = CUpnpResourcesBean::NewLC( );
+            resBn->SetId( UpnpCdUtils::ResIdFromUriL( *contentUri ) );
+            resBn->SetPathL( *contentPath );
+            resBn->SetIsReadonly( ETrue );
+            resBn->SetIsThumbnail( EFalse );
+
+            iContentDirectoryDb->AddResourceL( resBn, aObjectId );
+
+            // clean up
+            CleanupStack::PopAndDestroy( resBn );
+            CleanupStack::PopAndDestroy( contentPath );
+            CleanupStack::PopAndDestroy( contentUri );
+            CleanupStack::PopAndDestroy( fn );
+            }
+        // else -> ignore
+        }
+    // else -> ignore
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ConstructCreateResultsetL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::ConstructCreateResultsetL( CUpnpAction*& aAction,
+    RXmlEngDocument aDocument, TInt aId )
+    {
+    TBuf8<KMaxIntegerLen> num;
+    num.Num( aId );
+
+    aAction->SetArgumentL( KObjectID, num );
+    TXmlEngElement elem = aDocument.DocumentElement( );
+
+    HBufC8* buf = CUpnpXmlContentFilter::SerializeLC( aDocument, elem );
+
+    TPtr8 bufPtr(buf->Des( ));
+    InsertRealIpAndPortL( bufPtr );
+    HBufC8* encoded = UpnpCdUtils::EncodeXmlStringL( bufPtr );
+    CleanupStack::PushL( encoded );
+
+    aAction->SetArgumentL( KResult, *encoded );
+
+    CleanupStack::PopAndDestroy( encoded );
+    CleanupStack::PopAndDestroy( buf );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::XmlFragmentL
+// -----------------------------------------------------------------------------
+//
+RXmlEngDocument CUpnpContentDirectory::XmlFragmentL( const TDesC8 &aBuffer )
+    {
+    //Create a parser
+    RXmlEngDOMParser parser;
+    User::LeaveIfError( parser.Open( iDOMImpl ) );
+    CleanupClosePushL( parser );
+    // DOM document
+    RXmlEngDocument docTree;
+
+    if ( aBuffer.FindF( KXmlNsDc( ) ) == KErrNotFound )
+        {
+        HBufC8* withDidl = HBufC8::NewLC( KDidlTag().Length( ) + aBuffer.Length( ) +
+                                          KDidlEnd().Length( ) );
+        withDidl->Des().Append( KDidlTag( ) );
+        withDidl->Des().Append( aBuffer );
+        withDidl->Des().Append( KDidlEnd( ) );
+
+        docTree = parser.ParseL( *withDidl );
+        CleanupStack::PopAndDestroy( withDidl );
+        }
+    else
+        {
+        docTree = parser.ParseL( aBuffer );
+        }
+    CleanupStack::PopAndDestroy( &parser );
+    return docTree;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetMimeTypeLC
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpContentDirectory::GetMimeTypeLC( const TDesC8& aFilename )
+    {
+    HBufC16* filename16 = UpnpString::ToUnicodeL( aFilename );
+    CleanupStack::PushL( filename16 );
+    HBufC8* mimetype = UpnpFileUtil::GetMimeTypeForFileL( *filename16 );
+    if ( !mimetype )
+        {
+        mimetype = KNullString8().AllocL( );
+        }
+    CleanupStack::PopAndDestroy( filename16 );
+    CleanupStack::PushL( mimetype );
+    return mimetype;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ChangeFileNameWithExtensionL
+// -----------------------------------------------------------------------------
+HBufC8* CUpnpContentDirectory::ChangeFileNameWithExtensionL(
+    TDesC8& aFilePath, const TDesC8& aMimeType )
+    {
+
+    HBufC8* temp = NULL;
+    TInt position = aFilePath.LocateReverse( '.' );
+    if ( position != KErrNotFound )
+        {
+        return temp;
+        }
+    if ( aMimeType == KNullDesC8 )
+        {
+        return temp;
+        }
+
+    HBufC8* ext = iMimeToExtMap->GetExtensionL( aMimeType );
+    if ( ext == NULL )
+        {
+        return temp;
+        }
+    CleanupStack::PushL( ext );
+    HBufC8* newFilename = HBufC8::NewLC( ext->Length( ) + 1
+            + aFilePath.Length( ) );
+    TPtr8 fileNamePtr(newFilename->Des( ) );
+    fileNamePtr.Append( aFilePath );
+    //fileNamePtr.Append( KDot8());
+    fileNamePtr.Append( *ext );
+
+    HBufC* oldFilename16 = HBufC::NewLC( aFilePath.Length( ) );
+    TPtr oldFilename16Ptr(oldFilename16->Des( ));
+    oldFilename16Ptr.Copy( aFilePath );
+
+    HBufC* newFilename16 = HBufC::NewLC( newFilename->Length( ) );
+    TPtr newFilename16Ptr(newFilename16->Des( ));
+    newFilename16Ptr.Copy( *newFilename );
+
+    TBool exists = BaflUtils::FileExists( iFs, *newFilename16 );
+    if ( exists )
+        {
+        TInt error( KErrNone );
+        TInt count( 0);
+        _LIT( KUnderline, "_" );
+
+        CleanupStack::PopAndDestroy( newFilename16 );
+        newFilename16 = NULL;
+
+        HBufC16* ext16 = HBufC16::NewLC( ext->Length( ) );
+        ext16->Des().Copy( *ext );
+
+        TBuf<KMaxIntegerLen> value;
+        newFilename16 = HBufC16::NewLC( aFilePath.Length( ) + KMaxIntegerLen
+                + ext16->Length( ) + KUnderline().Length( ) + KDot().Length( ) );
+        for ( ;; )
+            {
+            // name_xxxxx.ext
+            value.Num( count );
+
+            newFilename16->Des().Copy( aFilePath );
+            newFilename16->Des().Append( KUnderline );
+            newFilename16->Des().Append( value );
+            //adding dot is not not needed anymore
+            newFilename16->Des().Append( *ext16 );
+
+            RFile file;
+            error = file.Open( iFs, *newFilename16, EFileShareExclusive );
+            file.Close( );
+
+            if ( error == KErrNotFound )
+                {
+                break;
+                }
+            else
+                {
+                count++;
+                }
+            }
+        CleanupStack::Pop( newFilename16 );
+        CleanupStack::PopAndDestroy( ext16 );
+        CleanupStack::PushL( newFilename16 );
+        }
+
+    TInt result = iFs.Rename( *oldFilename16, *newFilename16 );
+    if ( result == KErrNone )
+        {
+        temp = HBufC8::NewL( newFilename16->Length( ) );
+        temp->Des().Copy( *newFilename16 );
+
+        }
+    CleanupStack::PopAndDestroy( newFilename16 );
+    CleanupStack::PopAndDestroy( oldFilename16 );
+    CleanupStack::PopAndDestroy( newFilename );
+    CleanupStack::PopAndDestroy( ext );
+
+    return temp;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateResTagWithDBRecoveyrL
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectory::CreateResTagInternalWithDBRecoveryL(
+    TInt aSessionId, TDesC8& aFilePath, HBufC8* aImportUri,
+    TBool aOnlyThumbnail )
+    {
+    TInt result = 0;
+    TRAPD( err, result = CreateResTagInternalL( aSessionId, aFilePath,
+        aImportUri, aOnlyThumbnail ) );
+    if ( err )
+        {
+        if ( DataBaseHasBeenRecoveredL( err ) )
+            {
+            TRAP( err, iContentDirectoryDb->CheckDatabaseL( ) );
+            if ( err == KErrCorrupt )
+                {
+                err = iContentDirectoryDb->RecreateDatabaseFile( );
+                User::LeaveIfError( err );
+                }
+            TRAP( err, result = CreateResTagInternalL( aSessionId, aFilePath,
+                aImportUri, aOnlyThumbnail ) );
+            if ( err == KErrCorrupt )
+                {
+                err = iContentDirectoryDb->RecreateDatabaseFile( );
+                }
+            }
+        User::LeaveIfError( err );
+        }
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateResTagInternalL
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectory::CreateResTagInternalL( TInt aSessionId,
+    TDesC8& aFilePath, HBufC8* aImportUri, TBool aOnlyThumbnail )
+    {
+    TInt ret = KErrGeneral;
+    HBufC8* number = UpnpCdUtils::RandomizeL( KRandomMax );
+    CleanupStack::PushL( number );
+    HBufC8* number2 = UpnpCdUtils::RandomizeL( KRandomMax );
+    CleanupStack::PushL( number2 );
+    HBufC8* importRandomize = HBufC8::NewLC( aImportUri->Des().Length( )+number->Des().Length( ) );
+    importRandomize->Des().Copy( *aImportUri );
+    importRandomize->Des().Replace( importRandomize->Length( ) - 4, 4, *number2 );
+    importRandomize->Des().Append( *number );
+
+    RXmlEngDocument obj;
+    TInt objId = KErrNotFound;
+    iContentDirectoryDb->GetObjectByAttrL( obj, &objId, KImportUri8,
+        *aImportUri );
+    CleanupClosePushL( obj );
+
+    if ( !obj.NotNull( ) )
+        {
+        CleanupStack::PopAndDestroy( &obj );
+        CleanupStack::PopAndDestroy( importRandomize );
+        CleanupStack::PopAndDestroy( number2 );
+        CleanupStack::PopAndDestroy( number );
+        return ret;
+        }
+
+    HBufC8* mimeType = GetMimeTypeLC( aFilePath );
+    // CheckFileName 
+    HBufC8* newName = ChangeFileNameWithExtensionL( aFilePath, *mimeType );
+    if ( !newName )
+        {
+        // renaming file failed, set the old  name
+        newName = HBufC8::NewL( aFilePath.Length( ) );
+        newName->Des().Copy( aFilePath );
+        }
+    CleanupStack::PushL( newName );
+
+    TSize objectSize( 0, 0);
+
+    //GetFileName
+    HBufC16* filename16 = UpnpString::ToUnicodeL( *newName );
+    CleanupStack::PushL( filename16 );
+
+    if ( obj.NotNull( ) && !aOnlyThumbnail )
+        {
+        // if there is already a file related to this importUri delete it
+        DeleteOldResourcesL( obj, *aImportUri, *filename16 );
+
+        // set new contentUri
+        TXmlEngElement objEl = obj.DocumentElement( );
+
+        TPtrC8 fileNamePtr =
+                newName->Mid( newName->LocateReverse( '\\' ) + 1 );
+
+        TInt extPosition = fileNamePtr.LocateReverse( '.' );
+        TPtrC8 ext;
+        if ( extPosition>0 )
+            ext.Set( fileNamePtr.Mid( extPosition ) );
+        else
+            ext.Set( KNullString8 );
+        HBufC8* contUri = HBufC8::NewLC( importRandomize->Length( ) + KSlash().Length( ) +
+                                         KMaxLongIntegerLen + ext.Length( ) );
+        TPtr8 contUriPtr(contUri->Des( ));
+        contUriPtr.Copy( *importRandomize );
+        contUriPtr.Append( KSlash );
+
+        TBuf8<KMaxLongIntegerLen> num;
+        num.Num( objId );
+        contUriPtr.Append( num );
+        contUriPtr.Append( ext );
+
+        TXmlEngElement resEl;
+        UpnpDomInterface::GetDirectoryElementL( objEl, resEl, KRes( ),
+            KImportUri8( ), aImportUri->Des( ) );
+        resEl.SetTextL( contUriPtr );
+
+        CleanupStack::PopAndDestroy( contUri );
+
+        // set res@size  
+        TXmlEngAttr size = resEl.AttributeNodeL( KSize( ) );
+        if ( size.NotNull( ) )
+            {
+            SetResSizeL( size, *filename16 );
+            }
+
+        // set res@protocolInfo
+        HBufC8* protocolInfo =
+                ProtocolInfoFromMimeL( mimeType->Des( ), resEl );
+        CleanupStack::PushL( protocolInfo );
+
+        TXmlEngAttr protInf = resEl.AttributeNodeL( KprotocolInfo( ) );
+        protInf.SetValueL( *protocolInfo );
+
+        CleanupStack::PopAndDestroy( protocolInfo );
+
+        CheckItemTypeForObjectL( obj, *mimeType );
+
+        RemoveFileTransferFromTransferIDsStateVariableL( aSessionId );
+
+        // update database
+        iElementdb->ValidateNewObjectL( obj.DocumentElement( ), EFalse );
+        iContentDirectoryDb->UpdateObjectL( objId, obj );
+
+        // add resource
+        CUpnpResourcesBean* resBn = CUpnpResourcesBean::NewLC( );
+        resBn->SetId( UpnpCdUtils::ResIdFromUriL( *importRandomize ) );
+        resBn->SetPathL( *newName );
+        resBn->SetIsReadonly( EFalse );
+        resBn->SetIsThumbnail( EFalse );
+        iContentDirectoryDb->AddResourceL( resBn, objId );
+        // clean up
+        CleanupStack::PopAndDestroy( resBn );
+        ret = KErrNone;
+        }
+
+    //send event to Media server      
+
+
+    CUpnpFileTransferEvent* event =
+            iTransferController->TransferL( aSessionId );
+
+    if ( event )
+        {
+        event->SetFilePathL( *filename16 );
+        //CleanupStack::Pop( event);
+        //iEventObserver->FileTransferEvent( event );
+        }
+
+    // create thumbnail
+    CreateThumbnailL( *filename16, objId );
+
+    // clean up
+    CleanupStack::PopAndDestroy( filename16 );
+    CleanupStack::PopAndDestroy( newName );
+    CleanupStack::PopAndDestroy( mimeType );
+    CleanupStack::PopAndDestroy( &obj );
+    CleanupStack::PopAndDestroy( importRandomize );
+    CleanupStack::PopAndDestroy( number2 );
+    CleanupStack::PopAndDestroy( number );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::SetResSizeL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::SetResSizeL( TXmlEngAttr aSize,
+    const TDesC& aFilePath )
+    {
+    // get file size
+    RFile file;
+    CleanupClosePushL( file );
+    User::LeaveIfError( file.Open( iFs, aFilePath, EFileRead|EFileShareAny ) );
+    TInt size;
+    User::LeaveIfError( file.Size( size ) );
+
+    // set size
+    TBuf8<KMaxLongIntegerLen> num;
+    num.Num( size );
+    aSize.SetValueL( num );
+
+    CleanupStack::PopAndDestroy( &file );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::DeleteOldResourcesL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::DeleteOldResourcesL( RXmlEngDocument& aObj,
+    const TDesC8& aImportUri, const TDesC& aNewFile )
+    {
+    // for main res tag delete only corresponding record in the resources table
+    TXmlEngElement el;
+    UpnpDomInterface::GetDirectoryElementL( aObj.DocumentElement( ), el,
+        KImportUri8( ), aImportUri );
+    if ( el.NotNull( ) ) //  should always be true
+        {
+        TPtrC8 resVal(UpnpDomInterface::GetElementValueL( el ));
+        if ( resVal.Length( ) )
+            {
+            TInt64 resId = UpnpCdUtils::ResIdFromUriL( resVal ) ;
+            // check src existence -----------------------------
+            CUpnpResourcesBean* rscBean = NULL;
+            rscBean = iContentDirectoryDb->GetResourceL( resId );
+            TBool deletefile = ETrue;
+            //checking if a new file is the same as the old one
+            //if so, it means the old one was by chance deleted from the file system
+            if ( rscBean )
+                {
+                TPtrC rscPath(rscBean->Path( ) );
+                if ( !rscPath.Compare( aNewFile ) )
+                    deletefile = EFalse;
+                delete rscBean;
+                }
+            iContentDirectoryDb->DeleteResourceByResIdL( resId, deletefile );
+            }
+
+        }
+
+    // destroy all other res tags   
+    RArray<TXmlEngElement> elms;
+    CleanupClosePushL( elms );
+    UpnpDomInterface::GetElementListL( aObj.DocumentElement( ), elms, KRes );
+    // for each element
+    for ( TInt i=0; i < elms.Count( ); i++ )
+        {
+        TXmlEngAttr impUri(elms[i].AttributeNodeL( KImportUri( ) ) );
+        if ( impUri.IsNull( ) && !el.IsSameNode( elms[i] ) )
+            {
+            TPtrC8 resVal(UpnpDomInterface::GetElementValueL( elms[i] ));
+            if ( resVal.Length( ) )
+                {
+                iContentDirectoryDb->DeleteResourceByResIdL( 
+                                                        UpnpCdUtils::ResIdFromUriL( resVal ) );
+                }
+            elms[i].Remove( );
+            }
+        }
+    CleanupStack::PopAndDestroy( &elms );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateThumbnailCreatorL
+// -----------------------------------------------------------------------------
+//
+CUpnpThumbnailCreator* CUpnpContentDirectory::CreateThumbnailCreatorL(
+    TInt aObjectId )
+    {
+    CUpnpThumbnailCreator* thumbCreator = NULL;
+
+    if ( iBitmapServerConnection == KErrNone )
+        {
+        //check if from the file THUMB can be created. 
+        //create thumbnail 
+        // in thumbnail save the information. 
+        thumbCreator = CUpnpThumbnailCreator::NewLC( this );
+        iThumbnailCreators.AppendL( thumbCreator );
+        TInt index = iThumbnailCreators.Find( thumbCreator );
+        User::LeaveIfError( index );
+        iThObjectIds.Insert( aObjectId, index );
+        CleanupStack::Pop( thumbCreator );
+        }
+    return thumbCreator;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::RemoveThCreatorAndObjectIdLD
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::RemoveThCreatorAndObjectIdLD(
+    CUpnpThumbnailCreator* aThCreator )
+    {
+    TInt index = iThumbnailCreators.Find( aThCreator );
+    if ( index == KErrNotFound )
+        {
+        RDebug::Print( _L( "There is no corresponding thCreator in list. Error situation." ) );
+        delete aThCreator;
+        return;
+        }
+    else
+        {
+        iThumbnailCreators.Remove( index );
+        }
+    if ( index < iThObjectIds.Count( ) )
+        {
+        iThObjectIds.Remove( index );
+        }
+    delete aThCreator;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetObjectIdFromThCreator
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectory::GetObjectIdFromThCreator(
+    CUpnpThumbnailCreator* aThCreator )
+    {
+    TInt result = KErrNotFound;
+    TInt index = iThumbnailCreators.Find( aThCreator );
+    RDebug::Print( _L( "Whole number of objects. %d" ) ,
+        iThObjectIds.Count( ) );
+    if ( index < iThObjectIds.Count( ) )
+        {
+        result = iThObjectIds[index];
+        }
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::NotifyThumbnailResultL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::NotifyThumbnailResultL(
+    CUpnpThumbnailCreator* aThCreator, TInt aResult )
+    {
+    TInt result = aResult;
+    RDebug::Print( _L( "Thumbnail has been created with result: %d" ),
+        aResult );
+    if ( aResult == KErrNone )
+        {
+        RXmlEngDocument obj;
+        CleanupClosePushL( obj );
+        TInt objectId = GetObjectIdFromThCreator( aThCreator );
+        TInt err =
+                iContentDirectoryDb->GetObjectL( objectId, obj, KAsterisk8 );
+        if ( err == EUpnpOk )
+            {
+            // get item element
+            TXmlEngElement objElement;
+            UpnpDomInterface::GetElementL( obj.DocumentElement( ),
+                objElement, KItem );
+
+            // add new res tag
+            TXmlEngElement thumbRes(objElement.AddNewElementL( KRes( ) ) );
+
+            // add protocolInfo
+            HBufC8* protocolInfo = ProtocolInfoFromMimeL( KThumbMimeType( ),
+                JPEG_TN, ETrue, ETrue );
+            CleanupStack::PushL( protocolInfo );
+            thumbRes.AddNewAttributeL( KprotocolInfo( ), *protocolInfo );
+            CleanupStack::PopAndDestroy( protocolInfo );
+
+            // add contentUri
+            HBufC8* contUri = BuildContentUriL( aThCreator->GetFileExt( ),
+                objectId );
+            CleanupStack::PushL( contUri );
+            thumbRes.SetTextL( *contUri );
+
+            // add new resource
+            CUpnpResourcesBean* resBean = CUpnpResourcesBean::NewLC( );
+            resBean->SetId( UpnpCdUtils::ResIdFromUriL( *contUri ) );
+            resBean->SetPathL( aThCreator->GetPath( ) );
+            resBean->SetIsReadonly( EFalse );
+            resBean->SetIsThumbnail( ETrue );
+            iContentDirectoryDb->AddResourceL( resBean, objectId );
+
+            // update
+            iElementdb->ValidateNewObjectL( obj.DocumentElement( ), EFalse );
+            iContentDirectoryDb->UpdateObjectL( objectId, obj );
+            RemoveThCreatorAndObjectIdLD( aThCreator );
+
+            // clean up
+            CleanupStack::PopAndDestroy( resBean );
+            CleanupStack::PopAndDestroy( contUri );
+            }
+        else
+            {
+            // delete thumbnail file if exists
+            iFs.Delete( aThCreator->GetPath( ) ); // ignore errors
+            // remove thCreator and objectID from list 
+            RemoveThCreatorAndObjectIdLD( aThCreator );
+            result = err;
+            }
+        CleanupStack::PopAndDestroy( &obj );
+        }
+    else
+        {
+        // delete thumbnail file if exists
+        iFs.Delete( aThCreator->GetPath( ) ); // ignore errors
+        // remove thCreator and objectID from list 
+        RemoveThCreatorAndObjectIdLD( aThCreator );
+        }
+
+    // notify
+    if ( iThmbObs )
+        {
+        iThmbObs->NotifyThumbnailResultL( 0, result );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateResTagL
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectory::CreateResTagL( TInt aSessionId,
+    TDesC8& aFilePath, TInt aImportNumber, TBool aOnlyThumbnail )
+    {
+    HBufC8* importUri = UpnpCdUtils::BuildImportUriLC( aImportNumber );
+    TInt ret = CreateResTagInternalWithDBRecoveryL( aSessionId, aFilePath,
+        importUri, aOnlyThumbnail );
+    CleanupStack::PopAndDestroy( importUri );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ProtocolInfoFromMimeLC
+// -----------------------------------------------------------------------------
+//
+CUpnpDlnaProtocolInfo* CUpnpContentDirectory::CreateProtocolInfoFromMimeL(
+    const TDesC8& aMimeType, TInt aAddInfo )
+    {
+    CUpnpProtocolInfoLocal* protInfo = CUpnpProtocolInfoLocal::NewL(
+        aMimeType, aAddInfo );
+    CleanupStack::PushL( protInfo );
+    protInfo->SetThirdFieldL( aMimeType );
+    CleanupStack::Pop( protInfo );
+    return protInfo;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ProtocolInfoFromMimeL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpContentDirectory::ProtocolInfoFromMimeL(
+    const TDesC8& aMimeType, TInt aAddInfo, TBool aOpRangeParam,
+    TBool aCiParam /*= EFalse*/)
+    {
+    CUpnpDlnaProtocolInfo* protInfo = CreateProtocolInfoFromMimeL( aMimeType,
+        aAddInfo );
+    if ( aCiParam )
+        {
+        protInfo->SetCiParameter( ETrue );
+        }
+    if ( aOpRangeParam )
+        {
+        protInfo->SetOpParameterL( B_VAL, ETrue );
+        }
+
+    CleanupStack::PushL( protInfo );
+    TPtrC8 protocolInfo = protInfo->ProtocolInfoL( );
+    HBufC8* protocolInfoDes = protocolInfo.Alloc( );
+    CleanupStack::PopAndDestroy( protInfo );
+    return protocolInfoDes;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ProtocolInfoFromMimeL
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpContentDirectory::ProtocolInfoFromMimeL(
+    const TDesC8& aMimeType, TXmlEngElement& aResEl )
+    {
+    HBufC8* result = NULL;
+    const TDesC8& value = UpnpDomInterface::GetAttrValueL( aResEl,
+        KprotocolInfo );
+    if ( aMimeType.Length( ) > 0 )
+        {
+        if ( value.Length( ) )
+            {
+            CUpnpDlnaProtocolInfo* protocolInfo =
+                    CUpnpDlnaProtocolInfo::NewL( (TDesC8&) value );
+            CleanupStack::PushL( protocolInfo );
+            TPtrC8 third = protocolInfo->ThirdField( );
+            if ( !(aMimeType == third ) )
+                {
+                protocolInfo->SetThirdFieldL( (TDesC8&)aMimeType );
+                protocolInfo->SetFourthFieldL( KAsterisk8( ) );
+                }
+            TPtrC8 protInfo = protocolInfo->ProtocolInfoL( );
+            result = protInfo.Alloc( );
+            CleanupStack::PopAndDestroy( protocolInfo );
+            }
+        }
+    else
+        {
+        result = value.AllocL( );
+        }
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetFileNameL
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpContentDirectory::GetFileNameL( TInt aObjId )
+    {
+    TInt objId = aObjId;
+    HBufC* result = NULL;
+    RXmlEngDocument objDidl;
+    iContentDirectoryDb->GetObjectL( objId, objDidl, KAsterisk8( ) );
+    CleanupClosePushL( objDidl );
+    TXmlEngElement obj = objDidl.DocumentElement().FirstChild().AsElement( );
+    if ( obj.IsNull( ) )
+        {
+        CleanupStack::PopAndDestroy( &objDidl );
+        return NULL;
+        }
+
+    // file name
+    TXmlEngElement objTitle;
+    UpnpDomInterface::GetElementL( obj, objTitle, KObjTiltleColName8( ) );
+    if ( objTitle.IsNull( ) )
+        {
+        CleanupStack::PopAndDestroy( &objDidl );
+        return NULL;
+        }
+
+    // mime type
+    RArray<TXmlEngElement> reses;
+    CleanupClosePushL( reses );
+    UpnpDomInterface::GetElementListL( obj, reses, KRes );
+    HBufC8* mimeType = NULL;
+    for ( TInt i = 0; i < reses.Count( ); i++ )
+        { // should be only one importUri
+        TXmlEngAttr impUri;
+        impUri = reses[i].AttributeNodeL( KImportUri );
+        if ( impUri.NotNull( ) )
+            {
+            TXmlEngAttr prInfoAttr = reses[i].AttributeNodeL( KprotocolInfo );
+            CUpnpDlnaProtocolInfo* prInfo =
+                    CUpnpDlnaProtocolInfo::NewL( prInfoAttr.Value( ) );
+            CleanupStack::PushL( prInfo );
+            mimeType = prInfo->ThirdField().AllocL( );
+            CleanupStack::PopAndDestroy( prInfo );
+            break;
+            }
+        }
+    CleanupStack::PopAndDestroy( &reses );
+
+    TPtrC ext;
+    if ( mimeType )
+        {
+        TPtrC8 mimeTypeCut( *mimeType);
+        TInt position = mimeType->Des().Find( KSemicolon8 );
+        if ( position != KErrNotFound )
+            {
+            mimeTypeCut.Set( mimeType->Des().Left( position ) );
+            }
+
+        const HBufC* tmp = iMimeToExtMap->Get( mimeTypeCut );
+        if ( tmp )
+            {
+            ext.Set( tmp->Ptr( ), tmp->Length( ) ); // do not delete
+            }
+        delete mimeType;
+        }
+
+    result = HBufC::NewLC( objTitle.Value().Length( ) + ext.Length( ) );
+    TPtr resPtr(result->Des( ) );
+    HBufC* title = UpnpCdUtils::Des8ToDesLC( objTitle.Value( ) );
+
+    resPtr.Copy( *title );
+
+    TInt wholeNameLength = title->Des().LocateReverse( '.' );
+    TInt extenLength = title->Length( )-wholeNameLength;
+    TPtrC exten;
+    if ( extenLength )
+        {
+        exten.Set( title->Right( extenLength ) );
+        }
+
+    if ( ext.CompareF( exten ) != 0 )
+        {
+        resPtr.Append( ext );
+        }
+
+    // forbidden chars
+    UpnpCdUtils::ValidateFilePath( resPtr );
+
+    HBufC* basePath = HBufC::NewL( iDownloadDir->Des().Length( ) + 
+            result->Des().Length( ) );
+    basePath -> Des().Append( iDownloadDir->Des( ) );
+    basePath -> Des().Append( result->Des( ) );
+
+    CleanupStack::PopAndDestroy( title );
+    CleanupStack::PopAndDestroy( result );
+    CleanupStack::PopAndDestroy( &objDidl );
+
+    if ( BaflUtils::FileExists( iFs, *basePath ) )
+        {
+        CleanupStack::PushL( basePath );
+        HBufC* fileName = CreateFileNameL( basePath->Des( ) );
+        CleanupStack::PopAndDestroy( basePath );
+        return fileName;
+        }
+
+    return basePath;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetCopyFileNameL
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpContentDirectory::GetCopyFileNameL( TInt aObjId )
+    {
+    TInt objId = aObjId;
+    HBufC* result = NULL;
+    RXmlEngDocument objDidl;
+    iContentDirectoryDb->GetObjectL( objId, objDidl, KAsterisk8( ) );
+    CleanupClosePushL( objDidl );
+    TXmlEngElement obj = objDidl.DocumentElement().FirstChild().AsElement( );
+    if ( obj.IsNull( ) )
+        {
+        CleanupStack::PopAndDestroy( &objDidl );
+         return NULL;
+        }
+
+    // file name
+    TXmlEngElement objTitle;
+    UpnpDomInterface::GetElementL( obj, objTitle, KObjTiltleColName8( ) );
+    if ( objTitle.IsNull( ) )
+        {
+        CleanupStack::PopAndDestroy( &objDidl );
+        return NULL;
+        }
+  
+    // mime type
+    RArray<TXmlEngElement> reses;
+    CleanupClosePushL( reses );
+    UpnpDomInterface::GetElementListL( obj, reses, KRes );
+    HBufC8* mimeType = NULL;
+    CUpnpDlnaProtocolInfo* prInfo = NULL;
+    for ( TInt i = 0; i < reses.Count( ); i++ )
+        { // should be only one importUri
+        TXmlEngAttr impUri;
+        impUri = reses[i].AttributeNodeL( KImportUri );
+        if ( impUri.NotNull( ) )
+            {
+            TXmlEngAttr prInfoAttr = reses[i].AttributeNodeL(KprotocolInfo );
+            prInfo = CUpnpDlnaProtocolInfo::NewL( prInfoAttr.Value( ) );
+            CleanupStack::PushL( prInfo );
+            mimeType = prInfo->ThirdField().AllocL( );
+            //prInfo is pushed and destroyed later on
+            break;
+            }
+        }
+    // Destroy resources first
+    if ( NULL != prInfo )
+        {
+        CleanupStack::Pop( prInfo );
+        }
+    CleanupStack::PopAndDestroy( &reses );  
+    // prInfo is needed for creating the basePath
+    if ( NULL == prInfo )
+        {
+        CleanupStack::PopAndDestroy( &objDidl );
+        return NULL;
+        }
+    CleanupStack::PushL( prInfo );
+    
+    TPtrC ext;
+    if ( mimeType )
+        {
+        TPtrC8 mimeTypeCut( *mimeType);
+        TInt position = mimeType->Des().Find( KSemicolon8 );
+        if ( position != KErrNotFound )
+            {
+            mimeTypeCut.Set( mimeType->Des().Left( position ) );
+            }
+
+        const HBufC* tmp = iMimeToExtMap->Get( mimeTypeCut );
+        if ( tmp )
+            {
+            ext.Set( tmp->Ptr( ), tmp->Length( ) ); // do not delete
+            }
+        delete mimeType;
+        }
+
+    result = HBufC::NewLC( objTitle.Value().Length( ) + ext.Length( ) );
+    TPtr resPtr(result->Des( ) );
+    HBufC* title = UpnpCdUtils::Des8ToDesLC( objTitle.Value( ) );
+
+    resPtr.Copy( *title );
+
+    TInt wholeNameLength = title->Des().LocateReverse( '.' );
+    TInt extenLength = title->Length( )-wholeNameLength;
+    TPtrC exten;
+    if ( extenLength )
+        {
+        exten.Set( title->Right( extenLength ) );
+        }
+
+    if ( ext.CompareF( exten ) != 0 )
+        {
+        resPtr.Append( ext );
+        }
+
+    // forbidden chars
+    UpnpCdUtils::ValidateFilePath( resPtr );
+
+    // Create basePath   
+    CUPnPMSPathUtility* pathUtility = CUPnPMSPathUtility::NewLC();
+    HBufC* copyPath = pathUtility->GetCopyPathL( obj, *prInfo );
+    CleanupStack::PopAndDestroy( pathUtility );
+    CleanupStack::PushL( copyPath );
+    
+    HBufC* basePath = HBufC::NewL( copyPath->Des().Length( ) + 
+            result->Des().Length( ) );
+    basePath -> Des().Append( copyPath->Des( ) );
+    basePath -> Des().Append( result->Des( ) );
+
+    CleanupStack::PopAndDestroy( copyPath );
+    CleanupStack::PopAndDestroy( title );
+    CleanupStack::PopAndDestroy( result );
+    CleanupStack::PopAndDestroy( prInfo );
+    CleanupStack::PopAndDestroy( &objDidl );
+
+    if ( BaflUtils::FileExists( iFs, *basePath ) )
+        {
+        CleanupStack::PushL( basePath );
+        HBufC* fileName = CreateFileNameL( basePath->Des( ) );
+        CleanupStack::PopAndDestroy( basePath );
+        return fileName;
+        }
+
+    return basePath;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetFileNameWithoutPathL
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpContentDirectory::GetFileNameWithoutPathL( TInt aObjId )
+    {
+    TInt objId = aObjId;
+    HBufC* result = NULL;
+    RXmlEngDocument objDidl;
+    iContentDirectoryDb->GetObjectL( objId, objDidl, KAsterisk8( ) );
+    CleanupClosePushL( objDidl );
+    TXmlEngElement obj = objDidl.DocumentElement().FirstChild().AsElement( );
+    if ( obj.IsNull( ) )
+        {
+        CleanupStack::PopAndDestroy( &objDidl );
+        return NULL;
+        }
+
+    // file name
+    TXmlEngElement objTitle;
+    UpnpDomInterface::GetElementL( obj, objTitle, KObjTiltleColName8( ) );
+    if ( objTitle.IsNull( ) )
+        {
+        CleanupStack::PopAndDestroy( &objDidl );
+        return NULL;
+        }
+
+    // mime type
+    RArray<TXmlEngElement> reses;
+    CleanupClosePushL( reses );
+    UpnpDomInterface::GetElementListL( obj, reses, KRes );
+    HBufC8* mimeType = NULL;
+    for ( TInt i = 0; i < reses.Count( ); i++ )
+        { // should be only one importUri
+        TXmlEngAttr impUri;
+        impUri = reses[i].AttributeNodeL( KImportUri );
+        if ( impUri.NotNull( ) )
+            {
+            TXmlEngAttr prInfoAttr = reses[i].AttributeNodeL( KprotocolInfo );
+            CUpnpDlnaProtocolInfo* prInfo =
+                    CUpnpDlnaProtocolInfo::NewL( prInfoAttr.Value( ) );
+            CleanupStack::PushL( prInfo );
+            mimeType = prInfo->ThirdField().AllocL( );
+            CleanupStack::PopAndDestroy( prInfo );
+            break;
+            }
+        }
+    CleanupStack::PopAndDestroy( &reses );
+
+    TPtrC ext;
+    if ( mimeType )
+        {
+        TPtrC8 mimeTypeCut(*mimeType);
+        TInt position = mimeType->Des().Find( KSemicolon8 );
+        if ( position != KErrNotFound )
+            {
+            mimeTypeCut.Set( mimeType->Des().Left( position ) );
+            }
+
+        const HBufC* tmp = iMimeToExtMap->Get( mimeTypeCut );
+        if ( tmp )
+            {
+            ext.Set( tmp->Ptr( ), tmp->Length( ) ); // do not delete
+            }
+        delete mimeType;
+        }
+
+    result = HBufC::NewLC( objTitle.Value().Length( ) + ext.Length( ) );
+    TPtr resPtr(result->Des( ));
+    HBufC* title = UpnpCdUtils::Des8ToDesLC( objTitle.Value( ) );
+
+    resPtr.Copy( *title );
+
+    TInt wholeNameLength = title->Des().LocateReverse( '.' );
+    TInt extenLength = title->Length( )-wholeNameLength;
+    TPtrC exten;
+    if ( extenLength )
+        {
+        exten.Set( title->Right( extenLength ) );
+        }
+
+    if ( ext.CompareF( exten )!=0 )
+        resPtr.Append( ext );
+
+    // forbidden chars
+    UpnpCdUtils::ValidateFilePath( resPtr );
+
+    // clean up
+    CleanupStack::PopAndDestroy( title );
+    CleanupStack::Pop( result );
+    CleanupStack::PopAndDestroy( &objDidl );
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateFileNameL
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpContentDirectory::CreateFileNameL( const TDesC16& aFileName )
+    {
+    const TInt KMaxSameFileNames = 10000;
+    TParse parseFilename;
+    parseFilename.Set( aFileName, NULL, NULL );
+
+    // orginal file + underscore + number 
+    HBufC* name = HBufC::NewLC( aFileName.Length( ) + KMaxIntegerLen );
+    TPtr namePtr(name->Des( ) );
+
+    for ( TInt count = 1; count < KMaxSameFileNames; count++ )
+        {
+        TBuf<KMaxIntegerLen> value;
+        value.Num( count );
+
+        namePtr.Append( parseFilename.DriveAndPath( ) );
+        namePtr.Append( parseFilename.Name( ) );
+        namePtr.Append( KUndersc( ) );
+        namePtr.Append( value );
+        namePtr.Append( parseFilename.Ext( ) );
+
+        if ( !BaflUtils::FileExists( iFs, namePtr ) )
+            {
+            break;
+            }
+        namePtr.Zero( );
+        }
+
+    CleanupStack::Pop( name );
+    return name;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetTitleForUriL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::GetTitleForUriL( TInt aObjectId, TPtr& aValue )
+    {
+    HBufC* result = GetFileNameWithoutPathL( aObjectId );
+    TPtr des = result->Des( );
+    UpnpCdUtils::ValidateFilePath( des );
+    if ( result == NULL )
+        {
+        return;
+        }
+    aValue.Copy( *result );
+    delete result;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CheckImportUriL
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectory::CheckImportUriL( const TDesC8& aImportUri )
+    {
+    TInt objId = KErrNotFound;
+
+    // http characters  
+    HBufC8* dest8 = HBufC8::NewLC( aImportUri.Length( ) );
+    TPtr8 dest8Ptr(dest8->Des( ));
+    dest8Ptr.Copy( aImportUri );
+
+    UpnpString::ReplaceHttpCharacters( dest8Ptr );
+
+    // ip and port placeholder
+    HBufC8* dest = InsertIpAndPortPlaceholderL( dest8Ptr );
+    CleanupStack::PushL( dest );
+
+    objId = iContentDirectoryDb->GetObjIdByAttrLikeL( KImportUri8, *dest );
+
+    // clean up
+    CleanupStack::PopAndDestroy( dest );
+    CleanupStack::PopAndDestroy( dest8 );
+
+    return objId;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateAddressValueLC
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpContentDirectory::CreateAddressValueLC()
+    {
+
+    HBufC8* result = NULL;
+
+    CBufFlat* resBuf = CBufFlat::NewL( KMaxName );
+    CleanupStack::PushL( resBuf );
+
+    UpnpString::AppendStringL( *resBuf, KHttpTag( ) );
+    UpnpString::AppendStringL( *resBuf, KIpPortPlaceholder8( ) );
+
+    result = HBufC8::NewL( resBuf->Size( ) );
+    TPtr8 resultPtr(result->Des( ));
+    resultPtr.Copy( resBuf->Ptr( 0 ) );
+    CleanupStack::PopAndDestroy( resBuf );
+    CleanupStack::PushL( result );
+    return result;
+    // path 
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetImportUriLC
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpContentDirectory::GetImportUriLC( CUpnpHttpMessage* aMessage )
+    {
+    TPtrC8 path = aMessage->SenderPathFromHeader( );
+    if ( path.Find( KHttpTag ) == KErrNotFound )
+        {
+        HBufC8* serverAddr = CreateAddressValueLC( );
+        HBufC8* result =
+                HBufC8::NewL( serverAddr->Length( ) + path.Length( ) );
+        TPtr8 resultPtr(result->Des( ) );
+        resultPtr.Append( *serverAddr );
+        resultPtr.Append( path );
+        CleanupStack::PopAndDestroy( serverAddr );
+        CleanupStack::PushL( result );
+        return result;
+        }
+    else
+        {
+        HBufC8* pathHBuf = InsertIpAndPortPlaceholderL( path );
+        CleanupStack::PushL( pathHBuf );
+        return pathHBuf;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetProtocolInfoByImportUriL
+// -----------------------------------------------------------------------------
+//
+CUpnpDlnaProtocolInfo* CUpnpContentDirectory::GetProtocolInfoByImportUriL(
+    const TDesC8& aImportUri )
+    {
+    TPtrC8 importUri;
+    importUri.Set( UpdateImportUriL( aImportUri ) );
+
+    CUpnpDlnaProtocolInfo* protocolInfo = NULL;
+    // check restriction - cannot export to the restricted object
+    TInt objId = iContentDirectoryDb->
+    GetObjIdByAttrLikeL( KImportUri8, importUri );
+
+    if ( objId < 0 )
+        {
+        User::Leave( ENoSuchObject );
+        }
+
+    if ( iContentDirectoryDb->
+    CheckObjectRestrictionL( objId ) == ERestrictedObject )
+        {
+        User::Leave( ERestrictedObject );
+        }
+    // parent restricions
+    if ( iContentDirectoryDb->CheckParentRestrictionL( objId ) != EUpnpOk )
+        {
+        User::Leave( ERestrictedParentObject );
+        }
+    else
+        {
+        HBufC8* protInfoBuf = iContentDirectoryDb->
+        GetProtocolInfoByImportUriL( importUri );
+
+        if ( protInfoBuf )
+            {
+            CleanupStack::PushL( protInfoBuf );
+            protocolInfo = CUpnpDlnaProtocolInfo::NewL( protInfoBuf->Des( ) );
+            CleanupStack::PopAndDestroy( protInfoBuf );
+            }
+        }
+    return protocolInfo;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::UpdateImportUriL
+// -----------------------------------------------------------------------------
+//
+TPtrC8 CUpnpContentDirectory::UpdateImportUriL( const TDesC8& aImportUri )
+    {
+    HBufC8* portAndIp =  GetIpAndPortDes8L();
+    CleanupStack::PushL( portAndIp );
+
+    TPtrC8 importUri;
+    importUri.Set( aImportUri );
+    
+    TInt index = aImportUri.Find( *portAndIp );
+    if ( index > 0 )
+        {
+        importUri.Set( aImportUri.Mid( index + portAndIp->Des().Length() ) );
+        }
+                
+    CleanupStack::PopAndDestroy( portAndIp );
+    
+    //--- replaceing e.g '/0000000004' -> '0000000004'   
+    index = importUri.Find( KSlash8() );
+	// importUri must begins with '/'
+    if ( !index )
+        {
+        importUri.Set( importUri.Mid( index + 1 ) );        
+        }
+     else
+        {
+        User::Leave( ENoSuchObject );         
+        }   
+    //----------------------------------------
+    
+    if ( importUri.Length() < KMaxIntegerLen )
+        {
+        User::Leave(ENoSuchObject);        
+        }
+    
+    // Check if all signs in uri are digits
+    TLex8 lex( importUri );
+    for( TInt i( 0 ); i < importUri.Length(); i++ )
+        {
+        if ( !( lex.Get() ).IsDigit() ) 
+            {
+            User::Leave( ENoSuchObject ); 
+            }
+        }    
+    return importUri; 
+    }
+    
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetProtocolInfoL
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectory::GetProtocolInfoL( const TDesC8& aContentUri,
+    CUpnpDlnaProtocolInfo*& aProtocolInfo )
+    {
+    HBufC8 *buf = InsertIpAndPortPlaceholderL( aContentUri );
+    CleanupStack::PushL( buf );
+    TInt err = iContentDirectoryDb->GetProtocolInfoL( buf->Des( ),
+        aProtocolInfo );
+    CleanupStack::PopAndDestroy( buf );
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::FindSharedFolderL
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectory::FindSharedFolderL( const TDesC& aUrlPath,
+    const TDesC& aFileName, HBufC*& aSystemPath )
+    {
+    TInt ret = KErrNotFound;
+    aSystemPath = NULL;
+    if ( aUrlPath.Length( ) )
+        {
+        // validate the path string
+        if ( IsValidUrlPath( aUrlPath ) )
+            {
+            // get resource id
+            TLex lexer(aUrlPath);
+            TInt64 resId;
+            if ( !lexer.Val( resId ) )
+                {
+                // get resource
+                CUpnpResourcesBean* resBn = iContentDirectoryDb->
+                GetResourceL( resId );
+                if ( resBn )
+                    {
+                    CleanupStack::PushL( resBn );
+                    aSystemPath = resBn->Path().AllocL( );
+                    TInt objectId = resBn->ObjectId( );
+                    CleanupStack::PopAndDestroy( resBn );
+
+                    // make sure that systam path points to the wanted file
+                    TParse fp;
+                    fp.Set( *aSystemPath, 0, 0 );
+                    HBufC* tmp = aFileName.AllocLC( );
+                    TPtr tmpPtr(tmp->Des( ));
+                    UpnpString::ReplaceHttpCharactersL( tmpPtr );
+                    TPtrC ext = fp.Ext( );
+                    HBufC* file = HBufC::NewLC( KMaxIntegerLen
+                            + ext.Length( ) );
+                    TBuf<KMaxIntegerLen> num;
+                    num.Num( objectId );
+                    file->Des().Append( num );
+                    file->Des().Append( ext );
+
+                    if ( file->Des( ) == tmpPtr )
+                        {
+                        ret = KErrNone;
+                        }
+                    CleanupStack::PopAndDestroy( file );
+                    CleanupStack::PopAndDestroy( tmp );
+                    }
+                }
+            }
+        }
+    else
+        { // default download dir
+        aSystemPath = iDownloadDir->AllocL( );
+        }
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::IsValidUrlPathL
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectory::IsValidUrlPath( const TDesC& aUrlPath )
+    {
+    TInt ret = ETrue;
+    if ( (aUrlPath.Length( ) != KMaxIntegerLen + KRandomRangeLength)
+            && (aUrlPath.Length( ) != KMaxIntegerLen + KRandomRangeLength
+                    + KRandomRangeLength) )
+        {
+        ret = EFalse;
+        }
+    else
+        {
+        for ( TInt i = 0; i < aUrlPath.Length( ); i++ )
+            if ( aUrlPath[i] < '0' || aUrlPath[i] > '9' )
+                {
+                ret = EFalse;
+                break;
+                }
+        }
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetItemTypeFromMimeTypeLC
+// -----------------------------------------------------------------------------
+HBufC8* CUpnpContentDirectory::GetItemTypeFromMimeTypeLC(
+    const TDesC8& aMimeType )
+    {
+    HBufC8* result = NULL;
+    if ( aMimeType.Compare( KNullDesC8( ) ) == 0 )
+        {
+        return result;
+        }
+    TInt indexOfSlash = aMimeType.Find( KSlash8( ) );
+    if ( indexOfSlash < KErrNone )
+        {
+        return result;
+        }
+    TPtrC8 firstValue = aMimeType.Left( indexOfSlash );
+    if ( firstValue.Compare( KImageMime( ) ) == 0 )
+        {
+        result = KObjectClassImageItem().AllocLC( );
+        }
+    else if ( firstValue.Compare( KTextMime( ) ) == 0 )
+        {
+        result = KObjectClassTextItem().AllocLC( );
+        }
+    else if ( firstValue.Compare( KVideoMime( ) ) == 0 )
+        {
+        result = KObjectClassVideoItem().AllocLC( );
+        }
+    else if ( firstValue.Compare( KAudioMime( ) ) == 0 )
+        {
+        result = KObjectClassAudioItem().AllocLC( );
+        }
+    return result;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::GetItemTypeFromMimeTypeLC
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::CheckItemTypeForObjectL( RXmlEngDocument& aObj,
+    const TDesC8& aMimeType )
+    {
+    //  temporary disable because of mime-type recognition problem 
+    HBufC8* itemType = GetItemTypeFromMimeTypeLC( aMimeType );
+    if ( !itemType )
+        {
+        return;
+        }
+    TXmlEngElement obj = aObj.DocumentElement( );
+    TXmlEngElement objClass;
+    UpnpDomInterface::GetElementL( obj, objClass, KObjClassColName8 );
+    TPtrC8 classValue(UpnpDomInterface::GetElementValueL( objClass ));
+    if ( classValue.Compare( itemType->Des( ) ) < 0 )
+        {
+        objClass.SetTextL( *itemType );
+        }
+    CleanupStack::PopAndDestroy( itemType );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::SetDownloadDirectoryL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::SetDownloadDirectoryL( const TDesC& aDownloadDir )
+    {
+    // perform necessary changes in database
+    iContentDirectoryDb->NewMediaDirectoryL( *iDownloadDir );
+
+    // alloc new string
+    delete iDownloadDir;
+    iDownloadDir = NULL;
+    TPtrC last = aDownloadDir.Right( 1 );
+    if ( last.Compare( KDiskPathElSep )!=0 )
+        {
+        iDownloadDir = HBufC::NewL( aDownloadDir.Length( )+ KDiskPathElSep().Length( ) );
+        iDownloadDir->Des().Copy( aDownloadDir );
+        iDownloadDir->Des().Append( KDiskPathElSep );
+        }
+    else
+        {
+        iDownloadDir = HBufC::NewL( aDownloadDir.Length( ) );
+        iDownloadDir->Des().Copy( aDownloadDir );
+        }
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::SetThumbnailDirectoryL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::SetThumbnailDirectoryL( const TDesC& aDownloadDir )
+    {
+    // perform necessary changes in database
+    iContentDirectoryDb->NewMediaDirectoryL( *iThumbDir );
+
+    // alloc new string
+    delete iThumbDir;
+    iThumbDir = NULL;
+    iThumbDir = aDownloadDir.AllocL( );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::HandleDbError
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectory::HandleDbError( TInt aError )
+    {
+    return iContentDirectoryDb->HandleDbError( aError );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::DataBaseHasBeenRecoveredL
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectory::DataBaseHasBeenRecoveredL( TInt aError )
+    {
+    TInt err = aError;
+    if ( err == KErrCorrupt )
+        {
+        err = HandleDbError( err );
+        }
+    return (err == KErrNone && aError == KErrCorrupt ) ? ETrue : EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::IsDbOrDiskProblemL
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectory::IsDbOrDiskProblemL( CUpnpAction* aAction )
+    {
+    TBool noSpace = SysUtil::DiskSpaceBelowCriticalLevelL( &iFs,
+        KMinDiskSpace, EDriveC );
+    TInt error( KErrNone );
+    if ( !noSpace )
+        {
+        if ( !IsDbCreated() )
+            {
+            error = HandleDbError( KErrCorrupt );
+            }
+        }
+    if ( noSpace || error != KErrNone )
+        {
+        DoSendActionL( aAction, ECannotProcess );
+        return ETrue;
+        }
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::IsDbCreated
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectory::IsDbCreated()
+    {
+    return iContentDirectoryDb->IsDbCreated( );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::CreateNameForThumbnailL
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpContentDirectory::CreateNameForThumbnailL( const TDesC& aFileName )
+    {
+    // only name
+    TParse fp;
+    User::LeaveIfError( fp.Set( aFileName, 0, 0 ) );
+    TFileName bareName = fp.Name( );
+    // full name
+    User::LeaveIfError( fp.Set( bareName, iThumbDir, &KDefaultThumbExtension ) );
+    TFileName fullName = fp.FullName( );
+
+    //check if exists
+    TUint ignored;
+    TInt q = 0;
+    while ( iFs.Att( fullName, ignored ) == KErrNone )
+        {
+        q++;
+        TBuf<KMaxIntegerLen> num;
+        num.Num( q );
+        TFileName tmpName;
+        tmpName.Copy( bareName );
+        tmpName.Append( KUndersc );
+        tmpName.Append( num );
+        fp.Set( tmpName, iThumbDir, &KDefaultThumbExtension );
+        fullName = fp.FullName( );
+        }
+
+    return fullName.AllocL( );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::AutoDestroyEventL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::AutoDestroyEventL( TInt aObjId, TBool aDeleteObj )
+    {
+    if ( !ValidateObjectL( aObjId ) )
+        {
+        return;
+        }
+
+    if ( aDeleteObj )
+        {
+        TBuf8<KMaxIntegerLen> containerID;
+        containerID.Num( iContentDirectoryDb->GetParentIdL( aObjId ) );
+        RArray<TInt> refList;
+        CleanupClosePushL( refList );
+        iContentDirectoryDb->DeleteObjectL( aObjId, refList, ETrue );
+
+        // supporting ContainerUpdateIDs behaviour
+        iStateHandler->IncreaseSystemUpdateIdL( );
+        iStateHandler->IncreaseContainerUpdateIdL( containerID );
+        for ( TInt i(0); i<refList.Count( ); i++ )
+            {
+            iStateHandler->IncreaseSystemUpdateIdL( );
+            containerID.Num( refList[i] );
+            iStateHandler->IncreaseContainerUpdateIdL( containerID );
+            }
+
+        // clean up
+        CleanupStack::PopAndDestroy( &refList );
+        }
+    iAutoDestroyObjects->RemoveAndDestroyL( iAutoDestroyObjects->FindObjIndexByObjId( aObjId ) );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::HttpTransferEventReceivedL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpContentDirectory::HttpTransferEventReceivedL( CUpnpHttpMessage& aHttpMsg )
+    {
+    switch ( aHttpMsg.Type( ) )
+        {
+        case ETransferStart:
+            {
+            TransferStartL( aHttpMsg.SenderPathFromHeader( ) );
+
+            CUpnpFileTransfer::TTransferType type;
+            TInt objectid(0);
+
+            if ( aHttpMsg.Method().Find( KHttpGet ) == 0 )
+                {
+                objectid = iContentDirectoryDb->GetObjIdByAttrL( KImportUri8,
+                    aHttpMsg.SenderPathFromHeader( ) );
+                type = CUpnpFileTransfer::EImport;
+                }
+            else
+                {
+                objectid = iContentDirectoryDb->GetObjIdByAttrLikeL(
+                    KImportUri8, aHttpMsg.SenderPathFromHeader( ) );
+                type = CUpnpFileTransfer::EUpload;
+
+                }
+            CUpnpFileTransfer* transfer = CUpnpFileTransfer::NewLC(
+                aHttpMsg.SessionId( ), objectid, type );
+
+            transfer->SetTransferState(:: ETransferInProgress);
+            transfer->SetImportNumber(UpnpCdUtils::ResIdFromUriL(
+                    aHttpMsg.SenderPathFromHeader()));
+
+            iTransferController->iFileTransfers.Append(transfer);
+            CleanupStack::Pop( transfer );
+
+            iTransferController->AddIncomingTransferInternalL(&aHttpMsg);
+            break;
+            }
+        case ETransferError:
+            {
+            iTransferController->TransferFailL( &aHttpMsg );
+            break;
+            }
+        default:
+        break;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ImportComplete
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::TransferProgress( TInt aId, TInt aBytes,
+    TInt aTotalBytes )
+    {
+    TInt transferId = iTransferController->Transfer( aId );
+    if ( transferId != KErrNotFound )
+        {
+        (iTransferController->iFileTransfers[ transferId ])->SetTransferLength( aBytes );
+        (iTransferController->iFileTransfers[ transferId ])->SetTransferTotal( aTotalBytes );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::TransferStartL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::TransferStartL( const TDesC8& aImpUri )
+    {
+    TInt index = iAutoDestroyObjects->FindObjIndexByResId( UpnpCdUtils::ResIdFromUriL( aImpUri ) );
+    if ( index != KErrNotFound )
+        {
+        (*iAutoDestroyObjects)[index]->SetTransferStartedL( ETrue );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::TransferCompleteL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::TransferCompleteL( TInt aResId, TInt aObjId )
+    {
+    TInt index = iAutoDestroyObjects->FindObjIndexByResId( aResId );
+    if ( index != KErrNotFound )
+        {
+        iAutoDestroyObjects->RemoveAndDestroyL( index );
+        }
+
+    if ( (aObjId>=0)&&(aResId>=0)
+            &&(iContentDirectoryDb->GetParentIdL( aObjId )>=0) )
+        {
+        TBuf8<KMaxIntegerLen> containerID;
+        containerID.Num( iContentDirectoryDb->GetParentIdL( aObjId ) );
+        iStateHandler->IncreaseSystemUpdateIdL( );
+        iStateHandler->IncreaseContainerUpdateIdL( containerID );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::NotifyTransferFailL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::NotifyTransferFailL( TInt aSessionId,
+    TInt aStatusCode )
+    {
+    CUpnpFileTransferEvent* event =
+            iTransferController->RemoveTransferLC( aSessionId );
+    if ( event )
+        {
+        event->SetProgressState( CUpnpFileTransferEvent::EFailed );
+        event->SetErrorCode( aStatusCode );
+        CleanupStack::Pop( event );
+        iEventObserver->FileTransferEvent( event );
+        }
+
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::NotifyTransferStoppedL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::NotifyTransferStoppedL( TInt aSessionId,
+    CUpnpFileTransfer::TTransferType aType )
+    {
+    CUpnpFileTransferEvent* event =
+            iTransferController->RemoveTransferLC( aSessionId );
+    if ( event )
+        {
+        event->SetProgressState( CUpnpFileTransferEvent::EStopped );
+        if ( aType == CUpnpFileTransfer::EImport )
+            {
+            event->SetDirection( CUpnpFileTransferEvent::EIncoming );
+            }
+        else
+            {
+            event->SetDirection( CUpnpFileTransferEvent::EOutgoing );
+            }
+
+        CleanupStack::Pop( event );
+        iEventObserver->FileTransferEvent( event );
+        }
+
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::NotifyOutgoingTransferL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::NotifyOutgoingTransferL( TInt aSessionId )
+    {
+    CUpnpFileTransferEvent* event =
+            iTransferController->RemoveTransferLC( aSessionId );
+    if ( event )
+        {
+        CleanupStack::Pop( event );
+        //send event to Media Server        
+        iEventObserver->FileTransferEvent( event );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::SetSender
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpContentDirectory::SetSender( MUpnpCdsSender* aSender )
+    {
+    iSender = aSender;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::DoSendActionL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::DoSendActionL( CUpnpAction* aAction,
+    TUpnpErrorCode aError )
+    {
+    iSender->SendL( aAction, aError );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::DoSendActionL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::DoSendMessageL( CUpnpHttpMessage* aMessage )
+    {
+    iSender->SendL( aMessage );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::SendActionL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpContentDirectory::SendActionL( CUpnpAction* aAction,
+    TUpnpErrorCode aError )
+    {
+    SendL( aAction, aError );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::DoSendActionL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpContentDirectory::SendMessageL( CUpnpHttpMessage* aMessage )
+    {
+    SendL( aMessage );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::StateVariableEvented
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::StateVariableEvented( const TDesC8& aVariableName )
+    {
+    iStateHandler->StateVariableEvented( aVariableName );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::StateHandler
+// -----------------------------------------------------------------------------
+//
+CUpnpStateHandler* CUpnpContentDirectory::StateHandler()
+    {
+    return iStateHandler;
+    }
+
+// helper functions
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ExecutedAction
+// -----------------------------------------------------------------------------
+//
+TCurrentAction CUpnpContentDirectory::ExecutedAction()
+    {
+    return iCurrentAction;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::SetExecutedAction
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::SetExecutedAction( TCurrentAction aAction )
+    {
+    iCurrentAction = aAction;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::HttpResponseReceivedL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::HttpResponseReceivedL( TInt aSessionId,
+    TInt aStatusCode )
+    {
+    iTransferController->HttpResponseReceivedL( aSessionId, aStatusCode );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::EventObserver
+// -----------------------------------------------------------------------------
+//
+MUpnpContentDirectoryEventObserver* CUpnpContentDirectory::EventObserver()
+    {
+    return iEventObserver;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ContentDirectoryDb
+// -----------------------------------------------------------------------------
+//
+CUpnpContentDirectoryDb* CUpnpContentDirectory::ContentDirectoryDb()
+    {
+    return iContentDirectoryDb;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::IsObjectExistL
+// -----------------------------------------------------------------------------
+//    
+TBool CUpnpContentDirectory::IsObjectExistL( TInt aObjectId )
+    {
+    if ( iContentDirectoryDb->CheckObjectRestrictionL( aObjectId )
+            == ENoSuchObject )
+        {
+        return EFalse;
+        }
+    else
+        {
+        return ETrue;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::ValidateObjectL
+// -----------------------------------------------------------------------------
+//   
+TBool CUpnpContentDirectory::ValidateObjectL( TInt aObjectId )
+    {
+    //removes from autodestroy array orphaned objects
+    TInt i(0);
+    TInt index(0);
+    while ( i < iAutoDestroyObjects->Count( ) )
+        {
+        TInt parentID( iContentDirectoryDb->GetParentIdL(
+                        ( *iAutoDestroyObjects )[ i ]->GetObjId( ) ) );
+        if ( parentID < 0 )
+            {
+            index = iAutoDestroyObjects->FindObjIndexByObjId( (
+                                             *iAutoDestroyObjects )[ i ]->GetObjId( ) );
+            iAutoDestroyObjects->RemoveAndDestroyL( index );
+            continue;
+            }
+        i++;
+        }
+
+    //checks if given object exists
+    if ( !IsObjectExistL( aObjectId ) )
+        {
+        index = iAutoDestroyObjects->FindObjIndexByObjId( aObjectId );
+        if ( index != KErrNotFound )
+            {
+            iAutoDestroyObjects->RemoveAndDestroyL( index );
+            }
+        }
+
+    //cheks if given object exists in autodestroy array
+    index = iAutoDestroyObjects->FindObjIndexByObjId( aObjectId );
+    if ( index != KErrNotFound )
+        {
+        return ETrue;
+        }
+
+    return EFalse;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::TransferHandler
+// -----------------------------------------------------------------------------
+//
+MUpnpTransferInterface* CUpnpContentDirectory::TransferHandler()
+    {
+    return iTransferHandler;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::TransferCompletedL
+// -----------------------------------------------------------------------------
+//    
+void CUpnpContentDirectory::TransferCompletedL( TInt aKey, TInt aResultCode )
+    {
+    HttpResponseReceivedL( aKey, aResultCode );
+    if ( aResultCode == EHttpOk )
+        {
+        TInt transferid = iTransferController->Transfer( aKey );
+        if ( transferid > KErrNotFound )
+            {
+            TInt
+                    len =
+                            iTransferController->iFileTransfers[transferid]->TransferTotal( );
+            iTransferController->iFileTransfers[transferid]->SetTransferLength( len );
+            }
+        }
+    }
+    
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::NewTransactionL
+// -----------------------------------------------------------------------------
+//
+EXPORT_C void CUpnpContentDirectory::NewTransactionL(
+        const TDesC8& aMethod, const TDesC8& aUri, 
+        const TInetAddr& aSender, CUpnpHttpServerTransaction*& aResultTrans )
+    {
+    iDlnaFilter->NewTransactionL( aMethod, aUri, aSender, aResultTrans );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::HttpEventLD
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::HttpEventLD( CUpnpHttpMessage* aMessage )
+    {
+    if ( aMessage )
+        {
+        CleanupStack::PushL( aMessage );
+        if( aMessage->Type() >= ETransferStart )
+            {
+            HttpTransferEventReceivedL( *aMessage );
+            }
+        else
+            {
+            UnknownHttpEventReceivedL( *aMessage );
+            }
+        CleanupStack::PopAndDestroy( aMessage );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectory::AddressChangeL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectory::AddressChangeL()
+    {
+    iHttpServerSession->Stop();
+    iHttpServerSession->StartL();        
+    }
+
+//End of File
--- a/upnpmediaserver/contentdirectoryservice/src/upnpcontentdirectorydb.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnpcontentdirectorydb.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1418 +1,1418 @@
-/** @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:  Database for MediaServer
- *
-*/
-
-
-// INCLUDE FILES
-#include <barsread.h>
-#include <barsc.h>   
-#include <f32file.h>
-#include <xml/dom/xmlengdom.h>
-#include <sysutil.h>
-#include <upnpdominterface.h>
-#include <upnpstring.h>
-#include "upnpprotocolinfo.h"
-
-#include "upnpfileutils.h"
-#include "upnpcontentdirectorydb.h"
-#include "upnpcontentdirectoryglobals.h"
-#include "upnpelementfactory.h"
-#include "upnpelementbean.h"
-#include "upnpobjectbean.h"
-#include "upnpattributebean.h"
-#include "upnpfilterelement.h"
-#include "upnpresourcesbean.h"
-#include "upnpcdutils.h"
-#include "upnpcddbfactory.h"
-#include "upnpmetadatastorage.h"
-
-#define KLogFile _L("ContentDirectoryDb.log")
-#include "upnpcustomlog.h"
-
-// ============================= LOCAL FUNCTIONS ===============================
-// -----------------------------------------------------------------------------
-// CleanupFilterElementPointerArray
-// Used by TCleanupItem to clean a RPointerArray<CUpnpFilterElement>
-// -----------------------------------------------------------------------------
-//
-void CleanupFilterElementPointerArray( TAny* aArray )
-    {
-    (reinterpret_cast<RPointerArray<CUpnpFilterElement>*> (aArray))->ResetAndDestroy( );
-    }
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::CUpnpContentDirectoryDb
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CUpnpContentDirectoryDb::CUpnpContentDirectoryDb(
-    CUpnpMetadataStorage* aMetadataStorage )
-    {
-    iMetadataStorage =aMetadataStorage;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::ConstructL()
-    {
-    iDOMImpl.OpenL( );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::NewLC
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpContentDirectoryDb* CUpnpContentDirectoryDb::NewLC(
-    CUpnpMetadataStorage* aMetadataStorage )
-    {
-    CUpnpContentDirectoryDb* self = new ( ELeave ) CUpnpContentDirectoryDb(aMetadataStorage);
-    CleanupStack::PushL( self );
-    self->ConstructL( );
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpContentDirectoryDb* CUpnpContentDirectoryDb::NewL(
-    CUpnpMetadataStorage* aMetadataStorage )
-    {
-    CUpnpContentDirectoryDb* self = NewLC( aMetadataStorage );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::~~CUpnpContentDirectoryDb
-// Destructor
-// -----------------------------------------------------------------------------
-//
-CUpnpContentDirectoryDb::~CUpnpContentDirectoryDb()
-    {
-    iDOMImpl.Close( );
-    LOGCD( "CUpnpContentDirectoryDb::~CUpnpContentDirectoryDb", "", 0,
-        "DataBase closed" );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::InsertObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::InsertObjectL(
-    RXmlEngDocument& aFragment, TInt aContainerId, TInt* aId )
-    {
-    TUpnpErrorCode ret( EUpnpUndefined );
-    // get object element
-    TXmlEngElement element = UpnpCdUtils::GetObjectElementL( aFragment );
-
-    // start transaction
-    iMetadataStorage->BeginTransactionL( );
-
-    TRAPD( err, ret = DoInsertObjectL( element, aContainerId, aId ) );
-    if ( err )
-        { // rollback if error
-        iMetadataStorage->RollbackTransactionL( );
-        User::Leave( err );
-        }
-    iMetadataStorage->CommitTransactionL( );
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjectListL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::GetObjectListL( TInt aParentId,
-    RArray<TInt>& aList )
-    {
-    return iMetadataStorage->GetObjectListL( aParentId, aList );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjectListL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::GetObjectListL( const RArray<TInt>& aIds,
-    const TDesC8& aFilter, RArray<RXmlEngDocument>& aObjs )
-    {
-    for ( TInt i = 0; i < aIds.Count( ); i++ )
-        {
-        RXmlEngDocument obj;
-        CleanupClosePushL( obj );
-        GetObjectL( aIds[i], obj, aFilter );
-        aObjs.AppendL( obj );
-        CleanupStack::Pop( &obj );
-        }
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::DeleteObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::DeleteObjectL( TInt aObjId,
-    RArray<TInt>& aRefList, TBool aDeleteResource )
-    {
-    return iMetadataStorage->DeleteObjectL( aObjId, aRefList, aDeleteResource );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::UpdateObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::UpdateObjectL( TInt aObjId,
-    RXmlEngDocument& aFragment )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-
-    // // get object element
-    TXmlEngElement element = UpnpCdUtils::GetObjectElementL( aFragment );
-
-    // start transaction
-    iMetadataStorage->BeginTransactionL( );
-
-    TRAPD( err, ret = DoUpdateObjectL( aObjId, element ) );
-    if ( err )
-        { // rollback - error
-        iMetadataStorage->RollbackTransactionL( );
-        User::Leave( err );
-        }
-    // commit if success
-    iMetadataStorage->CommitTransactionL( );
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::DoUpdateObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::DoUpdateObjectL( TInt aObjId,
-    TXmlEngElement aFragment )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-
-    // delete object
-    ret = iMetadataStorage->DoDeleteObjectL( aObjId, EFalse, EFalse );
-    TXmlEngElement el = aFragment;
-    ret = InsertUpdatedL( aObjId, el );
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::InsertUpdatedL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::InsertUpdatedL( TInt aObjId,
-    TXmlEngElement& aElement )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-    iMetadataStorage->InsertObjectIntoObjectTableL( aElement );
-    ret = EUpnpOk;
-    RXmlEngNodeList<TXmlEngElement> elements;
-    CleanupClosePushL( elements );
-    aElement.GetChildElements( elements );
-
-    while ( elements.HasNext( ) )
-        {
-        TXmlEngElement el = elements.Next( );
-        if ( el.Name().CompareF( KClassTagName ) && el.Name().CompareF( KTitleTagName ) )
-            {
-            ret = InsertElementL( el, aObjId );
-            }
-        else
-            {
-            UpnpCdUtils::IsElementRequiredL( el ); // just remove the marker attr
-            }
-        }
-    CleanupStack::PopAndDestroy( &elements );
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::InsertElementL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::InsertElementL(
-    const TXmlEngElement& aElement, TInt aObjId )
-    {
-    return InsertAttributesL( aElement, iMetadataStorage->InsertElementL(
-        aElement, aObjId ), aObjId );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::PrepareDidlDocumentL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-RXmlEngDocument CUpnpContentDirectoryDb::PrepareDidlDocumentL()
-    {
-    RXmlEngDocument doc;
-    doc.OpenL( iDOMImpl );
-    TXmlEngElement el = doc.CreateDocumentElementL( KDidlLite( ) );
-    el.AddNamespaceDeclarationL( KXmlnsNsUri( ), KCmlnsNsPref( ) );
-    el.AddNamespaceDeclarationL( KDcNsUri( ), KDcNsPref( ) );
-    el.AddNamespaceDeclarationL( KUpnpNsUri( ), KUpnpNsPref( ) );
-    return doc;
-
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::CheckObjectRestrictionL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::CheckObjectRestrictionL( TInt aObjId )
-    {
-    return iMetadataStorage->CheckObjectRestrictionL( aObjId );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-TUpnpErrorCode CUpnpContentDirectoryDb::GetObjectL( TInt aObjectID,
-    RXmlEngDocument& aDoc, const TDesC8& aFilterString )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-
-    if ( aFilterString == KAsterisk8 )
-        { // get the whole object
-        ret = DoGetObjectL( aObjectID, aDoc, ETrue );
-        }
-    else if ( !aFilterString.Length( ) )
-        { // get only required properties
-        ret = DoGetObjectL( aObjectID, aDoc, EFalse );
-        }
-    else
-        {
-        RXmlEngDocument doc; // before the whole obj is created do not change the given reference,
-        CleanupClosePushL( doc ); // it prevents from returning not completed object if something goes wrong 
-        // during construction of response object
-        // get required properties
-        ret = DoGetObjectL( aObjectID, doc, EFalse );
-        if ( ret == EUpnpOk ) // do not not continue if something went wrong
-            {
-            // prepare a list of filter elements
-            RPointerArray<CUpnpFilterElement> filterElements;
-            TCleanupItem cleanupItem( CleanupFilterElementPointerArray,
-                &filterElements );
-            CleanupStack::PushL( cleanupItem );
-            // parse filter string
-            ParseFilterStringL( aFilterString, filterElements );
-            // add requested elements
-            AddRequestedPropertiesL( aObjectID,
-                UpnpCdUtils::GetObjectElementL( doc ), filterElements ); // ignore if error
-            //clean up
-            CleanupStack::PopAndDestroy( &filterElements );
-            }
-        if ( ret == EUpnpOk )
-            { // object is completed
-            aDoc = doc;
-            CleanupStack::Pop( &doc );
-            }
-        else
-            { // something went wrong
-            CleanupStack::PopAndDestroy( &doc );
-            }
-
-        }
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-TUpnpErrorCode CUpnpContentDirectoryDb::AddRequestedPropertiesL(
-    TInt aObjectID, TXmlEngElement aElement,
-    const RPointerArray<CUpnpFilterElement>& aFilterElements )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-    // aFilterElements must be sorted
-    for ( TInt i = 0; i < aFilterElements.Count( ); i++ )
-        {
-        const CUpnpFilterElement* filter = aFilterElements[i];
-        if ( filter->ElementName().Length( ) )
-            { // element part defined
-            AddElementL( aElement, aObjectID, filter );
-            }
-        else
-            { // element part not defined - it is attribute of main element tag
-            for ( TInt j = 0; j < filter->Count( ); j++ )
-                {
-                if ( (*filter)[j] == KChildCount )
-                    {
-                    SetChildCountL( aElement, aObjectID );
-                    ret = EUpnpOk;
-                    }
-                else
-                    {
-                    ret = iMetadataStorage->AddMainTagAttrL( aElement,
-                        aObjectID, (*filter)[j] );
-                    }
-                }
-            }
-        }
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::SetChildCountL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-void CUpnpContentDirectoryDb::SetChildCountL( TXmlEngElement aElement,
-    TInt aId )
-    {
-    if ( aElement.Name( ) == KContainer )
-        {
-        // value
-        TInt childCount = iMetadataStorage->GetChildCountL( aId );
-        TBuf8<KMaxIntegerLen> num;
-        num.Num( childCount );
-
-        // is it already exist?
-        TXmlEngAttr childAttr = aElement.AttributeNodeL( KChildCount( ) );
-        if ( childAttr.IsNull( ) )
-            { // not exist - add 
-            aElement.AddNewAttributeL( KChildCount( ), num );
-            }
-        else
-            { // already exists - update
-            childAttr.SetValueL( num );
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::AddElementL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-void CUpnpContentDirectoryDb::AddElementL( TXmlEngElement aElement,
-    TInt aObjectID, const CUpnpFilterElement* aReqElement )
-    {
-    // get elements from database
-    RDbView view = iMetadataStorage->GetElementViewL( aObjectID,
-        aReqElement->ElementName( ) );
-    CleanupClosePushL( view );
-
-    // for each element found
-    while ( view.NextL( ) )
-        {
-        view.GetL( );
-        CUpnpElementBean* elBean = CUpnpElementBean::NewLC( view );
-
-        // add element
-        TXmlEngElement newElement = elBean->AttachElmL( aElement );
-
-        // add required attributes
-        AddAttributesL( elBean->ElmId( ), aObjectID, newElement, EFalse );
-
-        // for each requested attribute
-        for ( TInt i = 0; i < aReqElement->Count( ); i++ )
-            {
-            TPtrC8 attrNamePtr((*aReqElement)[i]);
-
-            TXmlEngAttr attr = newElement.AttributeNodeL( attrNamePtr );
-            // add if not present
-            // ignore if element has not any attribute
-            if ( attr.IsNull( ) && elBean->ElmHasAttribute( ) )
-                {
-                AddAttributeL( newElement, attrNamePtr, elBean->ElmId( ),
-                    aObjectID );
-                }
-            }
-        // clean up
-        CleanupStack::PopAndDestroy( elBean );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::ParseFilterStringL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::ParseFilterStringL( const TDesC8& aFilter,
-    RPointerArray<CUpnpFilterElement>& aList )
-    {
-    // separate filter's parts
-    CDesC8ArrayFlat* list = new(ELeave) CDesC8ArrayFlat(KDefaultGranularity);
-    CleanupStack::PushL( list );
-    TInt commaPos;
-    TPtrC8 filter(aFilter);
-    while ( (commaPos = filter.Find( KCommaStr8( ) ) ) != KErrNotFound )
-        {
-        HBufC8* buf = filter.Left(commaPos).AllocLC( );
-        buf->Des().TrimAll( );
-        list->AppendL( *buf );
-        filter.Set( filter.Mid( commaPos+1 ) );
-        CleanupStack::PopAndDestroy( buf );
-        }
-    // add last
-    HBufC8* buf = filter.AllocLC( );
-    buf->Des().TrimAll( );
-    list->AppendL( *buf );
-    filter.Set( filter.Mid( commaPos+1 ) );
-    CleanupStack::PopAndDestroy( buf );
-
-    // sort to simplify
-    list->Sort( );
-
-    TPtrC8 curr( KMinusOne8 );
-    for ( TInt i = 0; i< list->Count( ); i++ ) // for each filter property
-        {
-        // split filter string - element@attribute
-        TInt atPos = (*list)[i].Find( KAtStr8 );
-        TPtrC8 attr;
-        if ( atPos == KErrNotFound ) // is it element name
-            { // it is element
-            attr.Set( KNullDesC8 );
-            atPos = (*list)[i].Length( );
-            }
-        else
-            {
-            attr.Set( (*list)[i].Mid( atPos+1 ) );
-            }
-        TPtrC8 element((*list)[i].Left( atPos ) );
-
-        // do not add "class" and "title" elements - required by default
-        if ( element.CompareF( KClassTagNameWithNs8 )
-                && element.CompareF( KTitleTagNameWithNs8 ) )
-            { // it is neither a class nor title element
-            if ( element == curr )
-                { // already exists, add next attribute
-                if ( attr.Length( ) ) // ignore empty attr
-                    aList[aList.Count()-1]->AppendAttributeL( attr );
-                }
-            else
-                { // create new filter element
-                CUpnpFilterElement* tmp = CUpnpFilterElement::NewLC( );
-                tmp->SetElementNameL( element );
-                if ( attr.Length( ) ) // ignore epmty attr
-                    tmp->AppendAttributeL( attr );
-                aList.AppendL( tmp );
-                CleanupStack::Pop( tmp );
-                curr.Set( element );
-                }
-            }
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( list );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::DoGetObjectL
-// Function returns DIDL-Lite XML fragment with metadata for requested object.
-// IMPORTANT: 1. Caller takes responsibility for returned document and is 
-//              obliged to close it.
-//           2. The root element of the document is <DIDL-Lite> element and
-//              the object's element is its direct, onluy child.
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::DoGetObjectL( TInt aObjectID,
-    RXmlEngDocument& aDoc, TBool aAll )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-    RDbView view = iMetadataStorage->GetObjViewL( aObjectID );
-    CleanupClosePushL( view );
-
-    // Get result
-    if ( view.FirstL( ) )
-        {
-        // get row
-        view.GetL( );
-
-        // prepare DIDL-Lite
-        RXmlEngDocument doc;
-        CleanupClosePushL( doc );
-        doc = PrepareDidlDocumentL( );
-
-        // object bean      
-        CUpnpObjectBean* objBean = CUpnpObjectBean::NewLC( view );
-        TXmlEngElement objElement;
-
-        if ( aAll )
-            { // all object's properties
-            objElement
-                    = objBean->AttachWholeObjectElL( doc.DocumentElement( ) );
-            // childCount
-            SetChildCountL( UpnpCdUtils::GetObjectElementL( doc ),
-                objBean->ObjId( ) );
-            }
-        else
-            { // only required
-            objElement = objBean->AttachObjectElL( doc.DocumentElement( ) );
-            }
-
-        // clean up
-        CleanupStack::PopAndDestroy( objBean );
-
-        // aObjectID might be a reference object, so trying to get real object id        
-        TInt realObjectId = ReferedObjectIdL( aObjectID );
-
-        // add elements to the tree
-        AddElementsL( realObjectId, objElement, aAll );
-
-        // assign to the given reference
-        aDoc = doc;
-        // everything went right
-        ret = EUpnpOk;
-        // do not remove doc
-        CleanupStack::Pop( &doc );
-        }
-    else
-        { // the is no such object
-        ret = ENoSuchObject;
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::AddElementsL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::AddElementsL( TInt aObjectID,
-    TXmlEngElement aObjectElement, TBool aAll )
-    {
-    RDbView view = iMetadataStorage->GetElementsViewL( aObjectID, aAll );
-    CleanupClosePushL( view );
-    // Iterate through elements
-    while ( view.NextL( ) )
-        {
-        view.GetL( );
-        CUpnpElementBean* elBean = CUpnpElementBean::NewLC( view );
-
-        // add new element
-        TXmlEngElement newElement = elBean->AttachElmL( aObjectElement );
-
-        // add attributes
-        AddAttributesL( elBean->ElmId( ), aObjectID, newElement, aAll );
-
-        // clean up
-        CleanupStack::PopAndDestroy( elBean );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::AddAttributesL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//  
-void CUpnpContentDirectoryDb::AddAttributesL( TInt aElementId,
-    TInt aObjectID, TXmlEngElement& aElement, TBool aAll )
-    {
-    RDbView view = iMetadataStorage->GetAttributesViewByObjectIdL( aObjectID,
-        aAll );
-    CleanupClosePushL( view );
-
-    CDbColSet* colSet = view.ColSetL( );
-    const TInt elmIdColNo = colSet->ColNo( KAtrElmIdColName );
-    delete colSet;
-
-    // Iterate through attributes
-    while ( view.NextL( ) )
-        {
-        view.GetL( );
-
-        if ( view.ColInt( elmIdColNo ) == aElementId )
-            {
-            CUpnpAttributeBean* atr = CUpnpAttributeBean::NewLC( view );
-            atr->AttachAttrL( aElement );
-            CleanupStack::PopAndDestroy( atr );
-            }
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::DoInsertObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::DoInsertObjectL(
-    TXmlEngElement& aElement, TInt aContainerId, TInt* aId )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-
-    *aId = SetObjectIdL( aElement );
-    UpnpCdUtils::SetContainerIdL( aElement, aContainerId );
-    iMetadataStorage->InsertObjectIntoObjectTableL( aElement );
-    ret = EUpnpOk;
-    RXmlEngNodeList<TXmlEngElement> elements;
-    CleanupClosePushL( elements );
-    aElement.GetChildElements( elements );
-
-    while ( elements.HasNext( ) )
-        {
-        TXmlEngElement el = elements.Next( );
-        if ( el.Name().CompareF( KClassTagName ) && el.Name().CompareF( KTitleTagName ) )
-            {
-            ret = InsertElementL( el, *aId );
-            }
-        else
-            {
-            UpnpCdUtils::IsElementRequiredL( el ); // just remove the marker attr
-            }
-        }
-    // set object childCount
-    SetChildCountL( aElement, *aId );
-
-    CleanupStack::PopAndDestroy( &elements );
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::InsertAttributesL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::InsertAttributesL(
-    const TXmlEngElement aElement, TInt aElmId, TInt aObjId )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-    RXmlEngNodeList<TXmlEngAttr> list;
-    CleanupClosePushL( list );
-    aElement.GetAttributes( list );
-    if ( list.Count( ) )
-        {
-        RArray<TXmlEngAttr> attributes; // to store real attr
-        CleanupClosePushL( attributes );
-        RArray<TXmlEngAttr> markers; // to store marker attr
-        CleanupClosePushL( markers );
-        // separate markers from attr
-        while ( list.HasNext( ) )
-            {
-            TXmlEngAttr attr = list.Next( );
-            if ( attr.Name().Match( KRequiredAtrSufPattern ) == KErrNotFound )
-                {
-                attributes.AppendL( attr );
-                }
-            else
-                {
-                markers.AppendL( attr );
-                }
-            }
-
-        // insert attributes
-        for ( TInt i = 0; i < attributes.Count( ); i++ )
-            {
-            iMetadataStorage->InsertAttributeL( attributes[i], aElmId,
-                IsAttrRequiredL( attributes[i], markers ), aObjId );
-            ret = EUpnpOk;
-            }
-        // remove markers from DOM tree
-        for ( TInt i = 0; i < markers.Count( ); i++ )
-            {
-            markers[i].Remove( );
-            }
-        // clean up
-        CleanupStack::PopAndDestroy( &markers );
-        CleanupStack::PopAndDestroy( &attributes );
-        }
-    else
-        {
-        ret = EUpnpOk;
-        }
-
-    CleanupStack::PopAndDestroy( &list );
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::IsAttrRequiredL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectoryDb::IsAttrRequiredL( const TXmlEngAttr& aAttr,
-    RArray<TXmlEngAttr>& aMarkers )
-    {
-    TBool ret = EFalse;
-
-    for ( TInt i = 0; i< aMarkers.Count( ); i++ )
-        {
-        if ( aMarkers[i].Name().Find( aAttr.Name( ) ) == 0 )
-            { // attr required
-            ret = ETrue;
-            break;
-            }
-        }
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::SetObjectIdL
-// Sets the id val in the objected to be created
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::SetObjectIdL( TXmlEngElement& aElement )
-    {
-    TInt ret = iMetadataStorage->GetNextKeyL( KObjectTableName8 );
-    UpnpCdUtils::SetObjectIdL( aElement, ret );
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjectIdL
-// Gets the id val in the objected to be created
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::GetObjectIdL()
-    {
-    TInt ret = iMetadataStorage->NextKeyL( KObjectTableName8 );
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjectIdL
-// Gets the id val in the objected to be created
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpContentDirectoryDb::GetObjectTitleL( TInt aId )
-    {
-    return iMetadataStorage->GetObjectTitleL( aId );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::ReferedObjectIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::ReferedObjectIdL( TInt aObjectId )
-    {
-    TInt ret = KErrNotFound;
-
-    TInt refId = iMetadataStorage->ReferedObjectIdL( aObjectId );
-
-    if ( refId != KErrNotFound )
-        {
-        ret = ReferedObjectIdL( refId );
-        }
-    else
-        {
-        ret = aObjectId;
-        }
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetElIdByAttrL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::GetObjIdByAttrL( const TDesC8& aAttrName,
-    const TDesC8& aAttrVal )
-    {
-    TInt objId = KErrNotFound;
-
-    TInt elmId = iMetadataStorage->GetElmIdForAttrL( aAttrName, aAttrVal );
-    if ( elmId != KErrNotFound )
-        {
-        objId = iMetadataStorage->GetObjIdForElmIdL( elmId );
-        }
-
-    return objId;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjIdByAttrLikeL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::GetObjIdByAttrLikeL( const TDesC8& aAttrName,
-    const TDesC8& aAttrVal )
-    {
-    TInt objId = KErrNotFound;
-
-    TInt elmId = iMetadataStorage->GetElmIdForAttrLikeL( aAttrName, aAttrVal );
-    if ( elmId != KErrNotFound )
-        {
-        objId = iMetadataStorage->GetObjIdForElmIdL( elmId );
-        }
-
-    return objId;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjectByAttrL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::GetObjectByAttrL(
-    RXmlEngDocument& aDoc, TInt* aObjId, const TDesC8& aAttrName,
-    const TDesC8& aAttrVal )
-    {
-    TUpnpErrorCode ret = EUndefined;
-
-    *aObjId = GetObjIdByAttrL( aAttrName, aAttrVal );
-    if ( *aObjId >= 0 )
-        {
-        ret = GetObjectL( *aObjId, aDoc, KAsterisk8 );
-        }
-    else
-        { // something went wrong
-        ret = ENoSuchObject;
-        }
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::CheckParentRestrictionL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpContentDirectoryDb::CheckParentRestrictionL( TInt aObjId )
-    {
-    return iMetadataStorage->CheckParentRestrictionL( aObjId );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::DeleteResourceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::DeleteResourceL( const TDesC8& aResVal,
-    RArray<TInt>& aContIds )
-    {
-    // start transaction
-    iMetadataStorage->BeginTransactionL( );
-
-    TRAPD( err, DoDeleteResourceL( aResVal, aContIds ) );
-    if ( err != KErrNone )
-        { // rollback - error
-        iMetadataStorage->RollbackTransactionL( );
-        User::Leave( err );
-        }
-    // commit if success
-    iMetadataStorage->CommitTransactionL( );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::DoDeleteResourceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::DoDeleteResourceL( const TDesC8& aResVal,
-    RArray<TInt>& aContIds )
-    {
-    HBufC* resVal = HBufC::NewLC( aResVal.Length( ) );
-    resVal->Des().Copy( aResVal );
-
-    HBufC* resValReplaced16 = UpnpCdUtils::EscapeAposL( *resVal );
-    CleanupStack::PushL( resValReplaced16 );
-    HBufC8* resValReplaced8 = UpnpCdUtils::DesToDes8LC( *resValReplaced16 );
-    RArray<TInt> objs;
-    CleanupClosePushL( objs );
-    GetObjectsByResourceL( objs, *resValReplaced16 );
-
-    // not any obj?
-    if ( !objs.Count( ) )
-        {
-        User::Leave( ENoSourceResource );
-        }
-
-    TUpnpErrorCode err = EUpnpOk;
-
-    // for each object
-    for ( TInt i = 0; i < objs.Count( ); i++ )
-        {
-        CUpnpObjectBean* objBn = GetObjBeanLC( objs[i] );
-        if ( !objBn->ObjRestricted( ) )
-            {
-            if ( CheckObjectRestrictionL( objBn->ObjParentId( ) ) == EUpnpOk )
-                {
-                iMetadataStorage->DeleteResElL( *resValReplaced16,
-                    objBn->ObjId( ) );
-                aContIds.AppendL( objBn->ObjParentId( ) );
-                }
-            else
-                {
-                err = ERestrictedParentObject;
-                }
-            }
-        else
-            {
-            err = ERestrictedObject;
-            }
-        CleanupStack::PopAndDestroy( objBn );
-        }
-
-    // was any deleted
-    if ( !aContIds.Count( ) )
-        {
-        User::Leave( err );
-        }
-
-    // if each deleted?
-    if ( aContIds.Count( ) == objs.Count( ) )
-        {
-        // try to fetch resource id
-        TRAPD( err, UpnpCdUtils::ResIdFromUriL( *resValReplaced8 ) );
-        // ignore if error - resource id could not be fetched
-        if ( !err )
-            { // OK
-            // delete resource
-            DeleteResourceByResIdL( UpnpCdUtils::ResIdFromUriL( *resValReplaced8 ) );
-            }
-        }
-
-    CleanupStack::PopAndDestroy( &objs );
-    CleanupStack::PopAndDestroy( resValReplaced8 );
-    CleanupStack::PopAndDestroy( resValReplaced16 );
-    CleanupStack::PopAndDestroy( resVal );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjBeanLC
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpObjectBean* CUpnpContentDirectoryDb::GetObjBeanLC( TInt aObjId )
-    {
-    CUpnpObjectBean* objBn = 0;
-
-    RDbView view = iMetadataStorage->GetObjViewL( aObjId );
-    CleanupClosePushL( view );
-
-    if ( view.FirstL( ) )
-        {
-        // get values
-        view.GetL( );
-        objBn = CUpnpObjectBean::NewL( view );
-        }
-
-    // clean up 
-    CleanupStack::PopAndDestroy( &view );
-
-    CleanupStack::PushL( objBn );
-    return objBn;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjectIdsL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::GetObjectsByResourceL( RArray<TInt>& aIds,
-    const TDesC& aResVal )
-    {
-
-    RDbView view = iMetadataStorage->GetViewOfObjectListForResL( aResVal );
-    CleanupClosePushL( view );
-
-    CDbColSet* colSet = view.ColSetL( );
-    const TInt colNo = colSet->ColNo( KElmObjIdColName );
-    delete colSet;
-
-    // for each row
-    while ( view.NextL( ) )
-        {
-        view.GetL( );
-        TInt no = view.ColInt( colNo );
-        aIds.AppendL( no );
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetProtocolInfoL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::GetProtocolInfoL( const TDesC8& aContentUri,
-    CUpnpDlnaProtocolInfo*& aProtocolInfo )
-    {
-    HBufC* uri = HBufC::NewLC( aContentUri.Length( ) );
-    TPtr uriPtr(uri->Des( ));
-    uriPtr.Copy( aContentUri );
-    TInt ret = GetElmIdByNameAndValL( KRes16, uriPtr );
-    if ( ret >= 0 )
-        {
-        HBufC8* attrVal;
-        GetAttrValueByNameL( ret, KprotocolInfo, attrVal );
-        CleanupStack::PushL( attrVal );
-        aProtocolInfo = CUpnpDlnaProtocolInfo::NewL( *attrVal );
-        CleanupStack::PopAndDestroy( attrVal );
-        }
-    CleanupStack::PopAndDestroy( uri );
-
-    if ( ret >= 0 ) //item ID number is't meaningfull for function caller
-        {
-        ret = KErrNone;
-        }
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetElmIdByNameAndValL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::GetElmIdByNameAndValL( const TDesC& aElmName,
-    const TDesC& aElmValue )
-    {
-    TInt ret = KErrNotFound;
-
-    RDbView view = iMetadataStorage->GetViewOfElmIdByNameAndValL( aElmName,
-        aElmValue );
-    CleanupClosePushL( view );
-
-    // col id
-    CDbColSet* colSet = view.ColSetL( );
-    const TInt colNo = colSet->ColNo( KElmIdColName );
-    delete colSet;
-
-    while ( view.NextL( ) )
-        {
-        view.GetL( );
-        ret = view.ColInt( colNo );
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetAttrValueByNameL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-
-HBufC8* CUpnpContentDirectoryDb::GetProtocolInfoByImportUriL(
-    const TDesC8& aImportUri )
-    {
-    CUpnpAttributeBean* attBean =
-            GetAttrByValueL( KImportUri8( ), aImportUri );
-    CleanupStack::PushL( attBean );
-
-    HBufC8* attValBuf = NULL;
-    if ( attBean )
-        {
-        //KprotocolInfo
-        CUpnpAttributeBean* att = GetAttrByNameL( attBean->AtrElmId( ),
-            KprotocolInfo( ), attValBuf );
-        delete att;
-        }
-    CleanupStack::PopAndDestroy( attBean );
-    return attValBuf;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetAttrValueByNameL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::GetAttrValueByNameL( TInt aElmId,
-    const TDesC8& aAttrName, HBufC8*& aAttrVal )
-    {
-    CUpnpAttributeBean* atrBean =
-            GetAttrByNameL( aElmId, aAttrName, aAttrVal );
-    delete atrBean;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetAttrByValueL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpAttributeBean* CUpnpContentDirectoryDb::GetAttrByValueL(
-    const TDesC8& aAttrName, const TDesC8& aAttrVal )
-    {
-    RDbView view = iMetadataStorage->GetAttrViewL( aAttrName, aAttrVal );
-    CleanupClosePushL( view );
-
-    TInt number = view.CountL( );
-
-    CDbColSet* colSet = view.ColSetL( );
-    const TInt colNo = colSet->ColNo( KAtrValueColName );
-    delete colSet;
-
-    CUpnpAttributeBean* atrBean = NULL;
-    if ( view.FirstL( ) )
-        {
-        view.GetL( );
-        atrBean = CUpnpAttributeBean::NewLC( view );
-        CleanupStack::Pop( atrBean );
-        }
-    else
-        {
-        User::Leave( KErrNotFound );
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    return atrBean;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetAttrByNameL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpAttributeBean* CUpnpContentDirectoryDb::GetAttrByNameL( TInt aElmId,
-    const TDesC8& aAttrName, HBufC8*& aAttrVal )
-    {
-    RDbView view = iMetadataStorage->GetAttrViewL( aElmId, aAttrName );
-    CleanupClosePushL( view );
-
-    CDbColSet* colSet = view.ColSetL( );
-    const TInt colNo = colSet->ColNo( KAtrValueColName );
-    delete colSet;
-
-    CUpnpAttributeBean* atrBean = NULL;
-    if ( view.FirstL( ) )
-        {
-        view.GetL( );
-        atrBean = CUpnpAttributeBean::NewLC( view );
-        aAttrVal = atrBean->AtrValue().AllocL( );
-        CleanupStack::Pop( atrBean );
-        }
-    else
-        {
-        User::Leave( KErrNotFound );
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    return atrBean;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetObjectIdByElementValueLikeL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::GetObjectIdByElementValueLikeL(
-    const TDesC8& aElmName, const TDesC8& aElmValue )
-    {
-    // convert to unicode
-    HBufC* elmName = UpnpCdUtils::Des8ToDesLC( aElmName );
-    HBufC* elmValue = UpnpCdUtils::Des8ToDesLC( aElmValue );
-
-    // prepare query buf
-    HBufC* query = HBufC::NewLC( KSelectFromSqlCmd().Length( ) + KElmObjIdColName().Length( ) + KElementTableName().Length( ) + KElmNameColName().Length( ) + elmName->Length( ) + KAndLikeConditionSqlCmd().Length( ) + KElmValueColName().Length( ) + elmValue->Length( ) );
-
-    TPtr queryPtr(query->Des( ));
-
-    // format query
-    queryPtr.Format( KSelectFromSqlCmd, &KElmObjIdColName,
-        &KElementTableName, &KElmNameColName, elmName );
-    queryPtr.AppendFormat( KAndLikeConditionSqlCmd, &KElmValueColName,
-        elmValue );
-
-    // prepare
-    RDbView view = iMetadataStorage->GetEvaluatedViewL( queryPtr );
-    CleanupClosePushL( view );
-
-    // col no
-    CDbColSet* colSet = view.ColSetL( );
-    const TInt colNo = colSet->ColNo( KElmObjIdColName );
-    delete colSet;
-
-    TInt ret = KErrNotFound;
-
-    // for one row
-    if ( view.NextL( ) )
-        {
-        view.GetL( );
-        if ( !view.IsColNull( colNo ) )
-            {
-            ret = view.ColInt( colNo );
-            }
-        }
-
-    CleanupStack::PopAndDestroy( &view );
-    CleanupStack::PopAndDestroy( query );
-
-    CleanupStack::PopAndDestroy( elmValue );
-    CleanupStack::PopAndDestroy( elmName );
-
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetParentIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::GetParentIdL( TInt aObjectId )
-    {
-    return iMetadataStorage->GetParentIdL( aObjectId );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::AddAttributeL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-
-void CUpnpContentDirectoryDb::AddAttributeL( TXmlEngElement aElement,
-    const TDesC8& aAttrName, TInt aElementId, TInt aObjectId )
-    {
-    RDbView view = iMetadataStorage->GetAttrViewByObjectIdL( aObjectId,
-        aAttrName );
-    CleanupClosePushL( view );
-
-    CDbColSet* colSet = view.ColSetL( );
-    const TInt elmIdColNo = colSet->ColNo( KAtrElmIdColName );
-    delete colSet;
-
-    // Iterate through attributes - usually there is only one
-    while ( view.NextL( ) )
-        {
-        view.GetL( );
-
-        if ( view.ColInt( elmIdColNo ) == aElementId )
-            {
-            CUpnpAttributeBean* atr = CUpnpAttributeBean::NewLC( view );
-            atr->AttachAttrL( aElement );
-            CleanupStack::PopAndDestroy( atr );
-            }
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    }
-// -----------------------------------------------------------------------------
-// CContentDirectoryDb::CanBeNestedL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectoryDb::CanBeNestedL( TInt aObjId )
-    {
-    // get path
-    HBufC8* path = iMetadataStorage->GetObjectPathL( aObjId );
-    CleanupStack::PushL( path );
-
-    // count levels
-    TPtrC8 rest(path->Des( ));
-    TInt levelNo(1); // root level
-    TInt pos( KErrNotFound );
-    while ( (pos = rest.Find( KPathSeparator8 )) != KErrNotFound )
-        {
-        rest.Set( rest.Mid( pos + KPathSeparator8().Length( ) ) );
-        levelNo++;
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( path );
-    return (levelNo < KAvailableNestedLevels);
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::AddResourceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::AddResourceL( CUpnpResourcesBean* aResBean,
-    TInt aObjId )
-    {
-    iMetadataStorage->AddResourceL( aResBean, aObjId );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::DeleteResourceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::DeleteResourceByResIdL( TInt64 aResId,
-    TBool aDeleteFile )
-    {
-    iMetadataStorage->DeleteResourceByResIdL( aResId, aDeleteFile );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::DeleteResourceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::DeleteResourceByObjIdL( TInt aObjId,
-    TBool aDeleteFile )
-    {
-    iMetadataStorage->DeleteResourceByObjIdL( aObjId, aDeleteFile );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetResourceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpResourcesBean* CUpnpContentDirectoryDb::GetResourceL( TInt64 aResId )
-    {
-    return iMetadataStorage->GetResourceL( aResId );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::ResNewDownloadDirectoryL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::NewMediaDirectoryL( const TDesC& aOldDir )
-    {
-    //UPDATE resources SET rsc_readonly=1 WHERE KRscPathColName LIKE $aOldDir* AND KRscReadonlyColName=0
-    // prepare command
-    HBufC* query = HBufC::NewLC( KNewMediaDirSqlCmd().Length( ) + aOldDir.Length( ) );
-    TPtr SqlCmd(query->Des( ));
-    SqlCmd.Format( KNewMediaDirSqlCmd, &aOldDir );
-
-    // execute
-    iMetadataStorage->ExecuteL( SqlCmd );
-
-    CleanupStack::PopAndDestroy( query );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetKeyForUriL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::GetKeyForUriL()
-    {
-    return iMetadataStorage->GetNextKeyL( KImportUriId8 );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::CheckDatabaseL
-// -----------------------------------------------------------------------------
-//
-void CUpnpContentDirectoryDb::CheckDatabaseL()
-    {
-    iMetadataStorage->CheckDatabaseL( );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::RecreateDatabaseFile
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::RecreateDatabaseFile()
-    {
-    TRAPD( err, iMetadataStorage->RecreateDatabaseFileL( ) );
-    return err;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::HandleDbError
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpContentDirectoryDb::HandleDbError( TInt aError )
-    {
-    return iMetadataStorage->HandleDbError( aError );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::IsDbCreated
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpContentDirectoryDb::IsDbCreated()
-    {
-    return iMetadataStorage->IsDbCreated( );
-    }
-
-//  End of File  
+/** @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:  Database for MediaServer
+ *
+*/
+
+
+// INCLUDE FILES
+#include <barsread.h>
+#include <barsc.h>   
+#include <f32file.h>
+#include <xmlengdom.h>
+#include <sysutil.h>
+#include <upnpdominterface.h>
+#include <upnpstring.h>
+#include "upnpprotocolinfo.h"
+
+#include "upnpfileutils.h"
+#include "upnpcontentdirectorydb.h"
+#include "upnpcontentdirectoryglobals.h"
+#include "upnpelementfactory.h"
+#include "upnpelementbean.h"
+#include "upnpobjectbean.h"
+#include "upnpattributebean.h"
+#include "upnpfilterelement.h"
+#include "upnpresourcesbean.h"
+#include "upnpcdutils.h"
+#include "upnpcddbfactory.h"
+#include "upnpmetadatastorage.h"
+
+#define KLogFile _L("ContentDirectoryDb.log")
+#include "upnpcustomlog.h"
+
+// ============================= LOCAL FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// CleanupFilterElementPointerArray
+// Used by TCleanupItem to clean a RPointerArray<CUpnpFilterElement>
+// -----------------------------------------------------------------------------
+//
+void CleanupFilterElementPointerArray( TAny* aArray )
+    {
+    (reinterpret_cast<RPointerArray<CUpnpFilterElement>*> (aArray))->ResetAndDestroy( );
+    }
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::CUpnpContentDirectoryDb
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUpnpContentDirectoryDb::CUpnpContentDirectoryDb(
+    CUpnpMetadataStorage* aMetadataStorage )
+    {
+    iMetadataStorage =aMetadataStorage;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::ConstructL()
+    {
+    iDOMImpl.OpenL( );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpContentDirectoryDb* CUpnpContentDirectoryDb::NewLC(
+    CUpnpMetadataStorage* aMetadataStorage )
+    {
+    CUpnpContentDirectoryDb* self = new ( ELeave ) CUpnpContentDirectoryDb(aMetadataStorage);
+    CleanupStack::PushL( self );
+    self->ConstructL( );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpContentDirectoryDb* CUpnpContentDirectoryDb::NewL(
+    CUpnpMetadataStorage* aMetadataStorage )
+    {
+    CUpnpContentDirectoryDb* self = NewLC( aMetadataStorage );
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::~~CUpnpContentDirectoryDb
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CUpnpContentDirectoryDb::~CUpnpContentDirectoryDb()
+    {
+    iDOMImpl.Close( );
+    LOGCD( "CUpnpContentDirectoryDb::~CUpnpContentDirectoryDb", "", 0,
+        "DataBase closed" );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::InsertObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::InsertObjectL(
+    RXmlEngDocument& aFragment, TInt aContainerId, TInt* aId )
+    {
+    TUpnpErrorCode ret( EUpnpUndefined );
+    // get object element
+    TXmlEngElement element = UpnpCdUtils::GetObjectElementL( aFragment );
+
+    // start transaction
+    iMetadataStorage->BeginTransactionL( );
+
+    TRAPD( err, ret = DoInsertObjectL( element, aContainerId, aId ) );
+    if ( err )
+        { // rollback if error
+        iMetadataStorage->RollbackTransactionL( );
+        User::Leave( err );
+        }
+    iMetadataStorage->CommitTransactionL( );
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjectListL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::GetObjectListL( TInt aParentId,
+    RArray<TInt>& aList )
+    {
+    return iMetadataStorage->GetObjectListL( aParentId, aList );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjectListL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::GetObjectListL( const RArray<TInt>& aIds,
+    const TDesC8& aFilter, RArray<RXmlEngDocument>& aObjs )
+    {
+    for ( TInt i = 0; i < aIds.Count( ); i++ )
+        {
+        RXmlEngDocument obj;
+        CleanupClosePushL( obj );
+        GetObjectL( aIds[i], obj, aFilter );
+        aObjs.AppendL( obj );
+        CleanupStack::Pop( &obj );
+        }
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::DeleteObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::DeleteObjectL( TInt aObjId,
+    RArray<TInt>& aRefList, TBool aDeleteResource )
+    {
+    return iMetadataStorage->DeleteObjectL( aObjId, aRefList, aDeleteResource );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::UpdateObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::UpdateObjectL( TInt aObjId,
+    RXmlEngDocument& aFragment )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+
+    // // get object element
+    TXmlEngElement element = UpnpCdUtils::GetObjectElementL( aFragment );
+
+    // start transaction
+    iMetadataStorage->BeginTransactionL( );
+
+    TRAPD( err, ret = DoUpdateObjectL( aObjId, element ) );
+    if ( err )
+        { // rollback - error
+        iMetadataStorage->RollbackTransactionL( );
+        User::Leave( err );
+        }
+    // commit if success
+    iMetadataStorage->CommitTransactionL( );
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::DoUpdateObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::DoUpdateObjectL( TInt aObjId,
+    TXmlEngElement aFragment )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+
+    // delete object
+    ret = iMetadataStorage->DoDeleteObjectL( aObjId, EFalse, EFalse );
+    TXmlEngElement el = aFragment;
+    ret = InsertUpdatedL( aObjId, el );
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::InsertUpdatedL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::InsertUpdatedL( TInt aObjId,
+    TXmlEngElement& aElement )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+    iMetadataStorage->InsertObjectIntoObjectTableL( aElement );
+    ret = EUpnpOk;
+    RXmlEngNodeList<TXmlEngElement> elements;
+    CleanupClosePushL( elements );
+    aElement.GetChildElements( elements );
+
+    while ( elements.HasNext( ) )
+        {
+        TXmlEngElement el = elements.Next( );
+        if ( el.Name().CompareF( KClassTagName ) && el.Name().CompareF( KTitleTagName ) )
+            {
+            ret = InsertElementL( el, aObjId );
+            }
+        else
+            {
+            UpnpCdUtils::IsElementRequiredL( el ); // just remove the marker attr
+            }
+        }
+    CleanupStack::PopAndDestroy( &elements );
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::InsertElementL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::InsertElementL(
+    const TXmlEngElement& aElement, TInt aObjId )
+    {
+    return InsertAttributesL( aElement, iMetadataStorage->InsertElementL(
+        aElement, aObjId ), aObjId );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::PrepareDidlDocumentL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+RXmlEngDocument CUpnpContentDirectoryDb::PrepareDidlDocumentL()
+    {
+    RXmlEngDocument doc;
+    doc.OpenL( iDOMImpl );
+    TXmlEngElement el = doc.CreateDocumentElementL( KDidlLite( ) );
+    el.AddNamespaceDeclarationL( KXmlnsNsUri( ), KCmlnsNsPref( ) );
+    el.AddNamespaceDeclarationL( KDcNsUri( ), KDcNsPref( ) );
+    el.AddNamespaceDeclarationL( KUpnpNsUri( ), KUpnpNsPref( ) );
+    return doc;
+
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::CheckObjectRestrictionL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::CheckObjectRestrictionL( TInt aObjId )
+    {
+    return iMetadataStorage->CheckObjectRestrictionL( aObjId );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+TUpnpErrorCode CUpnpContentDirectoryDb::GetObjectL( TInt aObjectID,
+    RXmlEngDocument& aDoc, const TDesC8& aFilterString )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+
+    if ( aFilterString == KAsterisk8 )
+        { // get the whole object
+        ret = DoGetObjectL( aObjectID, aDoc, ETrue );
+        }
+    else if ( !aFilterString.Length( ) )
+        { // get only required properties
+        ret = DoGetObjectL( aObjectID, aDoc, EFalse );
+        }
+    else
+        {
+        RXmlEngDocument doc; // before the whole obj is created do not change the given reference,
+        CleanupClosePushL( doc ); // it prevents from returning not completed object if something goes wrong 
+        // during construction of response object
+        // get required properties
+        ret = DoGetObjectL( aObjectID, doc, EFalse );
+        if ( ret == EUpnpOk ) // do not not continue if something went wrong
+            {
+            // prepare a list of filter elements
+            RPointerArray<CUpnpFilterElement> filterElements;
+            TCleanupItem cleanupItem( CleanupFilterElementPointerArray,
+                &filterElements );
+            CleanupStack::PushL( cleanupItem );
+            // parse filter string
+            ParseFilterStringL( aFilterString, filterElements );
+            // add requested elements
+            AddRequestedPropertiesL( aObjectID,
+                UpnpCdUtils::GetObjectElementL( doc ), filterElements ); // ignore if error
+            //clean up
+            CleanupStack::PopAndDestroy( &filterElements );
+            }
+        if ( ret == EUpnpOk )
+            { // object is completed
+            aDoc = doc;
+            CleanupStack::Pop( &doc );
+            }
+        else
+            { // something went wrong
+            CleanupStack::PopAndDestroy( &doc );
+            }
+
+        }
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+TUpnpErrorCode CUpnpContentDirectoryDb::AddRequestedPropertiesL(
+    TInt aObjectID, TXmlEngElement aElement,
+    const RPointerArray<CUpnpFilterElement>& aFilterElements )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+    // aFilterElements must be sorted
+    for ( TInt i = 0; i < aFilterElements.Count( ); i++ )
+        {
+        const CUpnpFilterElement* filter = aFilterElements[i];
+        if ( filter->ElementName().Length( ) )
+            { // element part defined
+            AddElementL( aElement, aObjectID, filter );
+            }
+        else
+            { // element part not defined - it is attribute of main element tag
+            for ( TInt j = 0; j < filter->Count( ); j++ )
+                {
+                if ( (*filter)[j] == KChildCount )
+                    {
+                    SetChildCountL( aElement, aObjectID );
+                    ret = EUpnpOk;
+                    }
+                else
+                    {
+                    ret = iMetadataStorage->AddMainTagAttrL( aElement,
+                        aObjectID, (*filter)[j] );
+                    }
+                }
+            }
+        }
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::SetChildCountL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CUpnpContentDirectoryDb::SetChildCountL( TXmlEngElement aElement,
+    TInt aId )
+    {
+    if ( aElement.Name( ) == KContainer )
+        {
+        // value
+        TInt childCount = iMetadataStorage->GetChildCountL( aId );
+        TBuf8<KMaxIntegerLen> num;
+        num.Num( childCount );
+
+        // is it already exist?
+        TXmlEngAttr childAttr = aElement.AttributeNodeL( KChildCount( ) );
+        if ( childAttr.IsNull( ) )
+            { // not exist - add 
+            aElement.AddNewAttributeL( KChildCount( ), num );
+            }
+        else
+            { // already exists - update
+            childAttr.SetValueL( num );
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::AddElementL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CUpnpContentDirectoryDb::AddElementL( TXmlEngElement aElement,
+    TInt aObjectID, const CUpnpFilterElement* aReqElement )
+    {
+    // get elements from database
+    RDbView view = iMetadataStorage->GetElementViewL( aObjectID,
+        aReqElement->ElementName( ) );
+    CleanupClosePushL( view );
+
+    // for each element found
+    while ( view.NextL( ) )
+        {
+        view.GetL( );
+        CUpnpElementBean* elBean = CUpnpElementBean::NewLC( view );
+
+        // add element
+        TXmlEngElement newElement = elBean->AttachElmL( aElement );
+
+        // add required attributes
+        AddAttributesL( elBean->ElmId( ), aObjectID, newElement, EFalse );
+
+        // for each requested attribute
+        for ( TInt i = 0; i < aReqElement->Count( ); i++ )
+            {
+            TPtrC8 attrNamePtr((*aReqElement)[i]);
+
+            TXmlEngAttr attr = newElement.AttributeNodeL( attrNamePtr );
+            // add if not present
+            // ignore if element has not any attribute
+            if ( attr.IsNull( ) && elBean->ElmHasAttribute( ) )
+                {
+                AddAttributeL( newElement, attrNamePtr, elBean->ElmId( ),
+                    aObjectID );
+                }
+            }
+        // clean up
+        CleanupStack::PopAndDestroy( elBean );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::ParseFilterStringL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::ParseFilterStringL( const TDesC8& aFilter,
+    RPointerArray<CUpnpFilterElement>& aList )
+    {
+    // separate filter's parts
+    CDesC8ArrayFlat* list = new(ELeave) CDesC8ArrayFlat(KDefaultGranularity);
+    CleanupStack::PushL( list );
+    TInt commaPos;
+    TPtrC8 filter(aFilter);
+    while ( (commaPos = filter.Find( KCommaStr8( ) ) ) != KErrNotFound )
+        {
+        HBufC8* buf = filter.Left(commaPos).AllocLC( );
+        buf->Des().TrimAll( );
+        list->AppendL( *buf );
+        filter.Set( filter.Mid( commaPos+1 ) );
+        CleanupStack::PopAndDestroy( buf );
+        }
+    // add last
+    HBufC8* buf = filter.AllocLC( );
+    buf->Des().TrimAll( );
+    list->AppendL( *buf );
+    filter.Set( filter.Mid( commaPos+1 ) );
+    CleanupStack::PopAndDestroy( buf );
+
+    // sort to simplify
+    list->Sort( );
+
+    TPtrC8 curr( KMinusOne8 );
+    for ( TInt i = 0; i< list->Count( ); i++ ) // for each filter property
+        {
+        // split filter string - element@attribute
+        TInt atPos = (*list)[i].Find( KAtStr8 );
+        TPtrC8 attr;
+        if ( atPos == KErrNotFound ) // is it element name
+            { // it is element
+            attr.Set( KNullDesC8 );
+            atPos = (*list)[i].Length( );
+            }
+        else
+            {
+            attr.Set( (*list)[i].Mid( atPos+1 ) );
+            }
+        TPtrC8 element((*list)[i].Left( atPos ) );
+
+        // do not add "class" and "title" elements - required by default
+        if ( element.CompareF( KClassTagNameWithNs8 )
+                && element.CompareF( KTitleTagNameWithNs8 ) )
+            { // it is neither a class nor title element
+            if ( element == curr )
+                { // already exists, add next attribute
+                if ( attr.Length( ) ) // ignore empty attr
+                    aList[aList.Count()-1]->AppendAttributeL( attr );
+                }
+            else
+                { // create new filter element
+                CUpnpFilterElement* tmp = CUpnpFilterElement::NewLC( );
+                tmp->SetElementNameL( element );
+                if ( attr.Length( ) ) // ignore epmty attr
+                    tmp->AppendAttributeL( attr );
+                aList.AppendL( tmp );
+                CleanupStack::Pop( tmp );
+                curr.Set( element );
+                }
+            }
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( list );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::DoGetObjectL
+// Function returns DIDL-Lite XML fragment with metadata for requested object.
+// IMPORTANT: 1. Caller takes responsibility for returned document and is 
+//              obliged to close it.
+//           2. The root element of the document is <DIDL-Lite> element and
+//              the object's element is its direct, onluy child.
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::DoGetObjectL( TInt aObjectID,
+    RXmlEngDocument& aDoc, TBool aAll )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+    RDbView view = iMetadataStorage->GetObjViewL( aObjectID );
+    CleanupClosePushL( view );
+
+    // Get result
+    if ( view.FirstL( ) )
+        {
+        // get row
+        view.GetL( );
+
+        // prepare DIDL-Lite
+        RXmlEngDocument doc;
+        CleanupClosePushL( doc );
+        doc = PrepareDidlDocumentL( );
+
+        // object bean      
+        CUpnpObjectBean* objBean = CUpnpObjectBean::NewLC( view );
+        TXmlEngElement objElement;
+
+        if ( aAll )
+            { // all object's properties
+            objElement
+                    = objBean->AttachWholeObjectElL( doc.DocumentElement( ) );
+            // childCount
+            SetChildCountL( UpnpCdUtils::GetObjectElementL( doc ),
+                objBean->ObjId( ) );
+            }
+        else
+            { // only required
+            objElement = objBean->AttachObjectElL( doc.DocumentElement( ) );
+            }
+
+        // clean up
+        CleanupStack::PopAndDestroy( objBean );
+
+        // aObjectID might be a reference object, so trying to get real object id        
+        TInt realObjectId = ReferedObjectIdL( aObjectID );
+
+        // add elements to the tree
+        AddElementsL( realObjectId, objElement, aAll );
+
+        // assign to the given reference
+        aDoc = doc;
+        // everything went right
+        ret = EUpnpOk;
+        // do not remove doc
+        CleanupStack::Pop( &doc );
+        }
+    else
+        { // the is no such object
+        ret = ENoSuchObject;
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::AddElementsL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::AddElementsL( TInt aObjectID,
+    TXmlEngElement aObjectElement, TBool aAll )
+    {
+    RDbView view = iMetadataStorage->GetElementsViewL( aObjectID, aAll );
+    CleanupClosePushL( view );
+    // Iterate through elements
+    while ( view.NextL( ) )
+        {
+        view.GetL( );
+        CUpnpElementBean* elBean = CUpnpElementBean::NewLC( view );
+
+        // add new element
+        TXmlEngElement newElement = elBean->AttachElmL( aObjectElement );
+
+        // add attributes
+        AddAttributesL( elBean->ElmId( ), aObjectID, newElement, aAll );
+
+        // clean up
+        CleanupStack::PopAndDestroy( elBean );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::AddAttributesL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//  
+void CUpnpContentDirectoryDb::AddAttributesL( TInt aElementId,
+    TInt aObjectID, TXmlEngElement& aElement, TBool aAll )
+    {
+    RDbView view = iMetadataStorage->GetAttributesViewByObjectIdL( aObjectID,
+        aAll );
+    CleanupClosePushL( view );
+
+    CDbColSet* colSet = view.ColSetL( );
+    const TInt elmIdColNo = colSet->ColNo( KAtrElmIdColName );
+    delete colSet;
+
+    // Iterate through attributes
+    while ( view.NextL( ) )
+        {
+        view.GetL( );
+
+        if ( view.ColInt( elmIdColNo ) == aElementId )
+            {
+            CUpnpAttributeBean* atr = CUpnpAttributeBean::NewLC( view );
+            atr->AttachAttrL( aElement );
+            CleanupStack::PopAndDestroy( atr );
+            }
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::DoInsertObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::DoInsertObjectL(
+    TXmlEngElement& aElement, TInt aContainerId, TInt* aId )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+
+    *aId = SetObjectIdL( aElement );
+    UpnpCdUtils::SetContainerIdL( aElement, aContainerId );
+    iMetadataStorage->InsertObjectIntoObjectTableL( aElement );
+    ret = EUpnpOk;
+    RXmlEngNodeList<TXmlEngElement> elements;
+    CleanupClosePushL( elements );
+    aElement.GetChildElements( elements );
+
+    while ( elements.HasNext( ) )
+        {
+        TXmlEngElement el = elements.Next( );
+        if ( el.Name().CompareF( KClassTagName ) && el.Name().CompareF( KTitleTagName ) )
+            {
+            ret = InsertElementL( el, *aId );
+            }
+        else
+            {
+            UpnpCdUtils::IsElementRequiredL( el ); // just remove the marker attr
+            }
+        }
+    // set object childCount
+    SetChildCountL( aElement, *aId );
+
+    CleanupStack::PopAndDestroy( &elements );
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::InsertAttributesL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::InsertAttributesL(
+    const TXmlEngElement aElement, TInt aElmId, TInt aObjId )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+    RXmlEngNodeList<TXmlEngAttr> list;
+    CleanupClosePushL( list );
+    aElement.GetAttributes( list );
+    if ( list.Count( ) )
+        {
+        RArray<TXmlEngAttr> attributes; // to store real attr
+        CleanupClosePushL( attributes );
+        RArray<TXmlEngAttr> markers; // to store marker attr
+        CleanupClosePushL( markers );
+        // separate markers from attr
+        while ( list.HasNext( ) )
+            {
+            TXmlEngAttr attr = list.Next( );
+            if ( attr.Name().Match( KRequiredAtrSufPattern ) == KErrNotFound )
+                {
+                attributes.AppendL( attr );
+                }
+            else
+                {
+                markers.AppendL( attr );
+                }
+            }
+
+        // insert attributes
+        for ( TInt i = 0; i < attributes.Count( ); i++ )
+            {
+            iMetadataStorage->InsertAttributeL( attributes[i], aElmId,
+                IsAttrRequiredL( attributes[i], markers ), aObjId );
+            ret = EUpnpOk;
+            }
+        // remove markers from DOM tree
+        for ( TInt i = 0; i < markers.Count( ); i++ )
+            {
+            markers[i].Remove( );
+            }
+        // clean up
+        CleanupStack::PopAndDestroy( &markers );
+        CleanupStack::PopAndDestroy( &attributes );
+        }
+    else
+        {
+        ret = EUpnpOk;
+        }
+
+    CleanupStack::PopAndDestroy( &list );
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::IsAttrRequiredL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectoryDb::IsAttrRequiredL( const TXmlEngAttr& aAttr,
+    RArray<TXmlEngAttr>& aMarkers )
+    {
+    TBool ret = EFalse;
+
+    for ( TInt i = 0; i< aMarkers.Count( ); i++ )
+        {
+        if ( aMarkers[i].Name().Find( aAttr.Name( ) ) == 0 )
+            { // attr required
+            ret = ETrue;
+            break;
+            }
+        }
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::SetObjectIdL
+// Sets the id val in the objected to be created
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::SetObjectIdL( TXmlEngElement& aElement )
+    {
+    TInt ret = iMetadataStorage->GetNextKeyL( KObjectTableName8 );
+    UpnpCdUtils::SetObjectIdL( aElement, ret );
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjectIdL
+// Gets the id val in the objected to be created
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::GetObjectIdL()
+    {
+    TInt ret = iMetadataStorage->NextKeyL( KObjectTableName8 );
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjectIdL
+// Gets the id val in the objected to be created
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpContentDirectoryDb::GetObjectTitleL( TInt aId )
+    {
+    return iMetadataStorage->GetObjectTitleL( aId );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::ReferedObjectIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::ReferedObjectIdL( TInt aObjectId )
+    {
+    TInt ret = KErrNotFound;
+
+    TInt refId = iMetadataStorage->ReferedObjectIdL( aObjectId );
+
+    if ( refId != KErrNotFound )
+        {
+        ret = ReferedObjectIdL( refId );
+        }
+    else
+        {
+        ret = aObjectId;
+        }
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetElIdByAttrL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::GetObjIdByAttrL( const TDesC8& aAttrName,
+    const TDesC8& aAttrVal )
+    {
+    TInt objId = KErrNotFound;
+
+    TInt elmId = iMetadataStorage->GetElmIdForAttrL( aAttrName, aAttrVal );
+    if ( elmId != KErrNotFound )
+        {
+        objId = iMetadataStorage->GetObjIdForElmIdL( elmId );
+        }
+
+    return objId;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjIdByAttrLikeL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::GetObjIdByAttrLikeL( const TDesC8& aAttrName,
+    const TDesC8& aAttrVal )
+    {
+    TInt objId = KErrNotFound;
+
+    TInt elmId = iMetadataStorage->GetElmIdForAttrLikeL( aAttrName, aAttrVal );
+    if ( elmId != KErrNotFound )
+        {
+        objId = iMetadataStorage->GetObjIdForElmIdL( elmId );
+        }
+
+    return objId;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjectByAttrL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::GetObjectByAttrL(
+    RXmlEngDocument& aDoc, TInt* aObjId, const TDesC8& aAttrName,
+    const TDesC8& aAttrVal )
+    {
+    TUpnpErrorCode ret = EUndefined;
+
+    *aObjId = GetObjIdByAttrL( aAttrName, aAttrVal );
+    if ( *aObjId >= 0 )
+        {
+        ret = GetObjectL( *aObjId, aDoc, KAsterisk8 );
+        }
+    else
+        { // something went wrong
+        ret = ENoSuchObject;
+        }
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::CheckParentRestrictionL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpContentDirectoryDb::CheckParentRestrictionL( TInt aObjId )
+    {
+    return iMetadataStorage->CheckParentRestrictionL( aObjId );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::DeleteResourceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::DeleteResourceL( const TDesC8& aResVal,
+    RArray<TInt>& aContIds )
+    {
+    // start transaction
+    iMetadataStorage->BeginTransactionL( );
+
+    TRAPD( err, DoDeleteResourceL( aResVal, aContIds ) );
+    if ( err != KErrNone )
+        { // rollback - error
+        iMetadataStorage->RollbackTransactionL( );
+        User::Leave( err );
+        }
+    // commit if success
+    iMetadataStorage->CommitTransactionL( );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::DoDeleteResourceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::DoDeleteResourceL( const TDesC8& aResVal,
+    RArray<TInt>& aContIds )
+    {
+    HBufC* resVal = HBufC::NewLC( aResVal.Length( ) );
+    resVal->Des().Copy( aResVal );
+
+    HBufC* resValReplaced16 = UpnpCdUtils::EscapeAposL( *resVal );
+    CleanupStack::PushL( resValReplaced16 );
+    HBufC8* resValReplaced8 = UpnpCdUtils::DesToDes8LC( *resValReplaced16 );
+    RArray<TInt> objs;
+    CleanupClosePushL( objs );
+    GetObjectsByResourceL( objs, *resValReplaced16 );
+
+    // not any obj?
+    if ( !objs.Count( ) )
+        {
+        User::Leave( ENoSourceResource );
+        }
+
+    TUpnpErrorCode err = EUpnpOk;
+
+    // for each object
+    for ( TInt i = 0; i < objs.Count( ); i++ )
+        {
+        CUpnpObjectBean* objBn = GetObjBeanLC( objs[i] );
+        if ( !objBn->ObjRestricted( ) )
+            {
+            if ( CheckObjectRestrictionL( objBn->ObjParentId( ) ) == EUpnpOk )
+                {
+                iMetadataStorage->DeleteResElL( *resValReplaced16,
+                    objBn->ObjId( ) );
+                aContIds.AppendL( objBn->ObjParentId( ) );
+                }
+            else
+                {
+                err = ERestrictedParentObject;
+                }
+            }
+        else
+            {
+            err = ERestrictedObject;
+            }
+        CleanupStack::PopAndDestroy( objBn );
+        }
+
+    // was any deleted
+    if ( !aContIds.Count( ) )
+        {
+        User::Leave( err );
+        }
+
+    // if each deleted?
+    if ( aContIds.Count( ) == objs.Count( ) )
+        {
+        // try to fetch resource id
+        TRAPD( err, UpnpCdUtils::ResIdFromUriL( *resValReplaced8 ) );
+        // ignore if error - resource id could not be fetched
+        if ( !err )
+            { // OK
+            // delete resource
+            DeleteResourceByResIdL( UpnpCdUtils::ResIdFromUriL( *resValReplaced8 ) );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &objs );
+    CleanupStack::PopAndDestroy( resValReplaced8 );
+    CleanupStack::PopAndDestroy( resValReplaced16 );
+    CleanupStack::PopAndDestroy( resVal );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjBeanLC
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpObjectBean* CUpnpContentDirectoryDb::GetObjBeanLC( TInt aObjId )
+    {
+    CUpnpObjectBean* objBn = 0;
+
+    RDbView view = iMetadataStorage->GetObjViewL( aObjId );
+    CleanupClosePushL( view );
+
+    if ( view.FirstL( ) )
+        {
+        // get values
+        view.GetL( );
+        objBn = CUpnpObjectBean::NewL( view );
+        }
+
+    // clean up 
+    CleanupStack::PopAndDestroy( &view );
+
+    CleanupStack::PushL( objBn );
+    return objBn;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjectIdsL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::GetObjectsByResourceL( RArray<TInt>& aIds,
+    const TDesC& aResVal )
+    {
+
+    RDbView view = iMetadataStorage->GetViewOfObjectListForResL( aResVal );
+    CleanupClosePushL( view );
+
+    CDbColSet* colSet = view.ColSetL( );
+    const TInt colNo = colSet->ColNo( KElmObjIdColName );
+    delete colSet;
+
+    // for each row
+    while ( view.NextL( ) )
+        {
+        view.GetL( );
+        TInt no = view.ColInt( colNo );
+        aIds.AppendL( no );
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetProtocolInfoL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::GetProtocolInfoL( const TDesC8& aContentUri,
+    CUpnpDlnaProtocolInfo*& aProtocolInfo )
+    {
+    HBufC* uri = HBufC::NewLC( aContentUri.Length( ) );
+    TPtr uriPtr(uri->Des( ));
+    uriPtr.Copy( aContentUri );
+    TInt ret = GetElmIdByNameAndValL( KRes16, uriPtr );
+    if ( ret >= 0 )
+        {
+        HBufC8* attrVal;
+        GetAttrValueByNameL( ret, KprotocolInfo, attrVal );
+        CleanupStack::PushL( attrVal );
+        aProtocolInfo = CUpnpDlnaProtocolInfo::NewL( *attrVal );
+        CleanupStack::PopAndDestroy( attrVal );
+        }
+    CleanupStack::PopAndDestroy( uri );
+
+    if ( ret >= 0 ) //item ID number is't meaningfull for function caller
+        {
+        ret = KErrNone;
+        }
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetElmIdByNameAndValL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::GetElmIdByNameAndValL( const TDesC& aElmName,
+    const TDesC& aElmValue )
+    {
+    TInt ret = KErrNotFound;
+
+    RDbView view = iMetadataStorage->GetViewOfElmIdByNameAndValL( aElmName,
+        aElmValue );
+    CleanupClosePushL( view );
+
+    // col id
+    CDbColSet* colSet = view.ColSetL( );
+    const TInt colNo = colSet->ColNo( KElmIdColName );
+    delete colSet;
+
+    while ( view.NextL( ) )
+        {
+        view.GetL( );
+        ret = view.ColInt( colNo );
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetAttrValueByNameL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+HBufC8* CUpnpContentDirectoryDb::GetProtocolInfoByImportUriL(
+    const TDesC8& aImportUri )
+    {
+    CUpnpAttributeBean* attBean =
+            GetAttrByValueL( KImportUri8( ), aImportUri );
+    CleanupStack::PushL( attBean );
+
+    HBufC8* attValBuf = NULL;
+    if ( attBean )
+        {
+        //KprotocolInfo
+        CUpnpAttributeBean* att = GetAttrByNameL( attBean->AtrElmId( ),
+            KprotocolInfo( ), attValBuf );
+        delete att;
+        }
+    CleanupStack::PopAndDestroy( attBean );
+    return attValBuf;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetAttrValueByNameL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::GetAttrValueByNameL( TInt aElmId,
+    const TDesC8& aAttrName, HBufC8*& aAttrVal )
+    {
+    CUpnpAttributeBean* atrBean =
+            GetAttrByNameL( aElmId, aAttrName, aAttrVal );
+    delete atrBean;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetAttrByValueL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpAttributeBean* CUpnpContentDirectoryDb::GetAttrByValueL(
+    const TDesC8& aAttrName, const TDesC8& aAttrVal )
+    {
+    RDbView view = iMetadataStorage->GetAttrViewL( aAttrName, aAttrVal );
+    CleanupClosePushL( view );
+
+    TInt number = view.CountL( );
+
+    CDbColSet* colSet = view.ColSetL( );
+    const TInt colNo = colSet->ColNo( KAtrValueColName );
+    delete colSet;
+
+    CUpnpAttributeBean* atrBean = NULL;
+    if ( view.FirstL( ) )
+        {
+        view.GetL( );
+        atrBean = CUpnpAttributeBean::NewLC( view );
+        CleanupStack::Pop( atrBean );
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    return atrBean;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetAttrByNameL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpAttributeBean* CUpnpContentDirectoryDb::GetAttrByNameL( TInt aElmId,
+    const TDesC8& aAttrName, HBufC8*& aAttrVal )
+    {
+    RDbView view = iMetadataStorage->GetAttrViewL( aElmId, aAttrName );
+    CleanupClosePushL( view );
+
+    CDbColSet* colSet = view.ColSetL( );
+    const TInt colNo = colSet->ColNo( KAtrValueColName );
+    delete colSet;
+
+    CUpnpAttributeBean* atrBean = NULL;
+    if ( view.FirstL( ) )
+        {
+        view.GetL( );
+        atrBean = CUpnpAttributeBean::NewLC( view );
+        aAttrVal = atrBean->AtrValue().AllocL( );
+        CleanupStack::Pop( atrBean );
+        }
+    else
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    return atrBean;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetObjectIdByElementValueLikeL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::GetObjectIdByElementValueLikeL(
+    const TDesC8& aElmName, const TDesC8& aElmValue )
+    {
+    // convert to unicode
+    HBufC* elmName = UpnpCdUtils::Des8ToDesLC( aElmName );
+    HBufC* elmValue = UpnpCdUtils::Des8ToDesLC( aElmValue );
+
+    // prepare query buf
+    HBufC* query = HBufC::NewLC( KSelectFromSqlCmd().Length( ) + KElmObjIdColName().Length( ) + KElementTableName().Length( ) + KElmNameColName().Length( ) + elmName->Length( ) + KAndLikeConditionSqlCmd().Length( ) + KElmValueColName().Length( ) + elmValue->Length( ) );
+
+    TPtr queryPtr(query->Des( ));
+
+    // format query
+    queryPtr.Format( KSelectFromSqlCmd, &KElmObjIdColName,
+        &KElementTableName, &KElmNameColName, elmName );
+    queryPtr.AppendFormat( KAndLikeConditionSqlCmd, &KElmValueColName,
+        elmValue );
+
+    // prepare
+    RDbView view = iMetadataStorage->GetEvaluatedViewL( queryPtr );
+    CleanupClosePushL( view );
+
+    // col no
+    CDbColSet* colSet = view.ColSetL( );
+    const TInt colNo = colSet->ColNo( KElmObjIdColName );
+    delete colSet;
+
+    TInt ret = KErrNotFound;
+
+    // for one row
+    if ( view.NextL( ) )
+        {
+        view.GetL( );
+        if ( !view.IsColNull( colNo ) )
+            {
+            ret = view.ColInt( colNo );
+            }
+        }
+
+    CleanupStack::PopAndDestroy( &view );
+    CleanupStack::PopAndDestroy( query );
+
+    CleanupStack::PopAndDestroy( elmValue );
+    CleanupStack::PopAndDestroy( elmName );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetParentIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::GetParentIdL( TInt aObjectId )
+    {
+    return iMetadataStorage->GetParentIdL( aObjectId );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::AddAttributeL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+void CUpnpContentDirectoryDb::AddAttributeL( TXmlEngElement aElement,
+    const TDesC8& aAttrName, TInt aElementId, TInt aObjectId )
+    {
+    RDbView view = iMetadataStorage->GetAttrViewByObjectIdL( aObjectId,
+        aAttrName );
+    CleanupClosePushL( view );
+
+    CDbColSet* colSet = view.ColSetL( );
+    const TInt elmIdColNo = colSet->ColNo( KAtrElmIdColName );
+    delete colSet;
+
+    // Iterate through attributes - usually there is only one
+    while ( view.NextL( ) )
+        {
+        view.GetL( );
+
+        if ( view.ColInt( elmIdColNo ) == aElementId )
+            {
+            CUpnpAttributeBean* atr = CUpnpAttributeBean::NewLC( view );
+            atr->AttachAttrL( aElement );
+            CleanupStack::PopAndDestroy( atr );
+            }
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    }
+// -----------------------------------------------------------------------------
+// CContentDirectoryDb::CanBeNestedL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectoryDb::CanBeNestedL( TInt aObjId )
+    {
+    // get path
+    HBufC8* path = iMetadataStorage->GetObjectPathL( aObjId );
+    CleanupStack::PushL( path );
+
+    // count levels
+    TPtrC8 rest(path->Des( ));
+    TInt levelNo(1); // root level
+    TInt pos( KErrNotFound );
+    while ( (pos = rest.Find( KPathSeparator8 )) != KErrNotFound )
+        {
+        rest.Set( rest.Mid( pos + KPathSeparator8().Length( ) ) );
+        levelNo++;
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( path );
+    return (levelNo < KAvailableNestedLevels);
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::AddResourceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::AddResourceL( CUpnpResourcesBean* aResBean,
+    TInt aObjId )
+    {
+    iMetadataStorage->AddResourceL( aResBean, aObjId );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::DeleteResourceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::DeleteResourceByResIdL( TInt64 aResId,
+    TBool aDeleteFile )
+    {
+    iMetadataStorage->DeleteResourceByResIdL( aResId, aDeleteFile );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::DeleteResourceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::DeleteResourceByObjIdL( TInt aObjId,
+    TBool aDeleteFile )
+    {
+    iMetadataStorage->DeleteResourceByObjIdL( aObjId, aDeleteFile );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetResourceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpResourcesBean* CUpnpContentDirectoryDb::GetResourceL( TInt64 aResId )
+    {
+    return iMetadataStorage->GetResourceL( aResId );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::ResNewDownloadDirectoryL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::NewMediaDirectoryL( const TDesC& aOldDir )
+    {
+    //UPDATE resources SET rsc_readonly=1 WHERE KRscPathColName LIKE $aOldDir* AND KRscReadonlyColName=0
+    // prepare command
+    HBufC* query = HBufC::NewLC( KNewMediaDirSqlCmd().Length( ) + aOldDir.Length( ) );
+    TPtr SqlCmd(query->Des( ));
+    SqlCmd.Format( KNewMediaDirSqlCmd, &aOldDir );
+
+    // execute
+    iMetadataStorage->ExecuteL( SqlCmd );
+
+    CleanupStack::PopAndDestroy( query );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetKeyForUriL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::GetKeyForUriL()
+    {
+    return iMetadataStorage->GetNextKeyL( KImportUriId8 );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::CheckDatabaseL
+// -----------------------------------------------------------------------------
+//
+void CUpnpContentDirectoryDb::CheckDatabaseL()
+    {
+    iMetadataStorage->CheckDatabaseL( );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::RecreateDatabaseFile
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::RecreateDatabaseFile()
+    {
+    TRAPD( err, iMetadataStorage->RecreateDatabaseFileL( ) );
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::HandleDbError
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpContentDirectoryDb::HandleDbError( TInt aError )
+    {
+    return iMetadataStorage->HandleDbError( aError );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::IsDbCreated
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpContentDirectoryDb::IsDbCreated()
+    {
+    return iMetadataStorage->IsDbCreated( );
+    }
+
+//  End of File  
--- a/upnpmediaserver/contentdirectoryservice/src/upnpelementbean.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnpelementbean.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,249 +1,249 @@
-/** @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:  Element table data handler
-*
-*/
-
-
-
-// INCLUDE FILES
-#include <xml/dom/xmlengdom.h>
-#include "upnpelementbean.h"
-#include "upnpcontentdirectoryglobals.h"
-#include "upnpcdutils.h"
-#include <upnpelement.h>
-#include <upnpobject.h>
-#include <uriutils.h>
-#include "upnpstring.h"
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::CUpnpElementBean
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CUpnpElementBean::CUpnpElementBean()
-{
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementBean::ConstructL()
-{
-	iElmValue = KNullString8().AllocL();
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::NewLC
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpElementBean* CUpnpElementBean::NewLC()
-{
-    CUpnpElementBean* self = new( ELeave ) CUpnpElementBean;
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::NewLC
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpElementBean* CUpnpElementBean::NewLC(const RDbRowSet& aRowSet)
-{
-    CUpnpElementBean* self = NewLC();
-    self->SetL(aRowSet);
-    return self;
-}    
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::~CUpnpElementBean
-// Destructor
-// -----------------------------------------------------------------------------
-//
-CUpnpElementBean::~CUpnpElementBean()
-{
-    delete iElmName;
-    delete iElmValue;
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::SetL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementBean::SetL(const RDbRowSet& aRowSet)
-{
-    // get cols' ids
-    CDbColSet* colSet = aRowSet.ColSetL();
-    CleanupStack::PushL(colSet);
-    const TInt  idColNo         = colSet->ColNo(KElmIdColName);
-    const TInt  nameColNo       = colSet->ColNo(KElmNameColName);
-    const TInt  hasAttrColNo    = colSet->ColNo(KElmHasAttrColName);
-    const TInt  objIdColNo      = colSet->ColNo(KElmObjIdColName);
-    const TInt  isRequiredColNo = colSet->ColNo(KElmIsRequiredColName);
-    const TInt  valueColNo      = colSet->ColNo(KElmValueColName);
-    CleanupStack::PopAndDestroy(colSet);
-    
-    // for each column call setter
-    if( idColNo != KDbNullColNo )
-    {
-        SetElmId( aRowSet.ColInt(idColNo) );
-    }
-    if( nameColNo != KDbNullColNo )
-    {
-        SetElmNameL( aRowSet.ColDes8(nameColNo) );
-    }
-    if( hasAttrColNo != KDbNullColNo )
-    {
-        SetElmHasAttribute( aRowSet.ColUint8(hasAttrColNo) );
-    }
-    if( objIdColNo != KDbNullColNo )
-    {
-        SetElmObjId( aRowSet.ColInt(objIdColNo) );
-    }
-    if( isRequiredColNo != KDbNullColNo )
-    {
-        SetElmIsRequired( aRowSet.ColUint8(isRequiredColNo) );
-    }
-    if( valueColNo != KDbNullColNo )
-    {
-        SetElmValueL(aRowSet, valueColNo);
-    }
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::SetElmNameL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementBean::SetElmNameL(const TDesC8& aElmName)
-{
-    delete iElmName;
-    iElmName = NULL;
-    iElmName = aElmName.AllocL();
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::SetElmValueL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementBean::SetElmValueL(const RDbRowSet& aRowSet, const TInt aColNo)
-{
-    delete iElmValue;
-    iElmValue = NULL;
-    iElmValue = ReadLongTextColL(aRowSet, aColNo);
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::SetElmValueL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementBean::SetElmValueL(const TDesC8& aVal)
-{
-	delete iElmValue;
-	iElmValue = NULL;
-	iElmValue = aVal.AllocL();
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::ElmName
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TDesC8& CUpnpElementBean::ElmName() const
-{
-    return *iElmName;
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::AttachToXmlElmL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TXmlEngElement CUpnpElementBean::AttachElmL(TXmlEngElement aElement) const
-{
-    // new element
-    TXmlEngElement element;
-    
-    // Check if it's local name or if it has a namespace prefix also
-    TInt pos = iElmName->Find( KColon8 );
-    if( pos == KErrNotFound )
-    { //local name
-        element = aElement.AddNewElementL( *iElmName );
-    }
-    else    
-    { //local name with prefix
-        element = aElement.AddNewElementUsePrefixL( 
-                    iElmName->Right( iElmName->Length() - pos - 1 ), // name
-                    iElmName->Left( pos ) ); // prefix
-    }
-
-    // value     
-    element.SetValueL( *iElmValue );
-
-    return element;
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::ValAsUriL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpElementBean::ValAsUriL() const 
-{    
-    // uris have to be properly escaped
-    HBufC* tmp = UpnpCdUtils::Des8ToDesLC(*iElmValue);        
-    TUriParser uripar;
-    uripar.Parse(*tmp);
-    CUri8* uri = uri = UriUtils::ConvertToInternetFormL(uripar);
-    CleanupStack::PopAndDestroy(tmp);        
-    if (uri->Uri().UriDes().Length())
-    {                
-        HBufC8* tmp2 = UpnpString::StringReplaceL(uri->Uri().UriDes(),KHash8,KHashASCII8);        
-        delete uri;
-        return tmp2;                         
-    }
-    HBufC8* uriDes = uri->Uri().UriDes().Alloc();
-    delete uri;
-    return uriDes;
-        
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::AttachElmL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpElement* CUpnpElementBean::AttachElmL(CUpnpObject* aObj)
-{
-    // create element
-    CUpnpElement* elm = CUpnpElement::NewLC(*iElmName);
-	
-	// copy values
-    elm->SetValueL(*iElmValue);
-
-	// is required
-	elm->SetIsRequired( ElmIsRequired() );
-	// attach
-	aObj->AddElementL(elm);
-	
-	// clean up
-	CleanupStack::Pop(elm);
-	
-	return elm;
-}
-
-
-//  End of File  
+/** @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:  Element table data handler
+*
+*/
+
+
+
+// INCLUDE FILES
+#include <xmlengdom.h>
+#include "upnpelementbean.h"
+#include "upnpcontentdirectoryglobals.h"
+#include "upnpcdutils.h"
+#include <upnpelement.h>
+#include <upnpobject.h>
+#include <uriutils.h>
+#include "upnpstring.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::CUpnpElementBean
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUpnpElementBean::CUpnpElementBean()
+{
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementBean::ConstructL()
+{
+	iElmValue = KNullString8().AllocL();
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpElementBean* CUpnpElementBean::NewLC()
+{
+    CUpnpElementBean* self = new( ELeave ) CUpnpElementBean;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::NewLC
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpElementBean* CUpnpElementBean::NewLC(const RDbRowSet& aRowSet)
+{
+    CUpnpElementBean* self = NewLC();
+    self->SetL(aRowSet);
+    return self;
+}    
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::~CUpnpElementBean
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CUpnpElementBean::~CUpnpElementBean()
+{
+    delete iElmName;
+    delete iElmValue;
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::SetL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementBean::SetL(const RDbRowSet& aRowSet)
+{
+    // get cols' ids
+    CDbColSet* colSet = aRowSet.ColSetL();
+    CleanupStack::PushL(colSet);
+    const TInt  idColNo         = colSet->ColNo(KElmIdColName);
+    const TInt  nameColNo       = colSet->ColNo(KElmNameColName);
+    const TInt  hasAttrColNo    = colSet->ColNo(KElmHasAttrColName);
+    const TInt  objIdColNo      = colSet->ColNo(KElmObjIdColName);
+    const TInt  isRequiredColNo = colSet->ColNo(KElmIsRequiredColName);
+    const TInt  valueColNo      = colSet->ColNo(KElmValueColName);
+    CleanupStack::PopAndDestroy(colSet);
+    
+    // for each column call setter
+    if( idColNo != KDbNullColNo )
+    {
+        SetElmId( aRowSet.ColInt(idColNo) );
+    }
+    if( nameColNo != KDbNullColNo )
+    {
+        SetElmNameL( aRowSet.ColDes8(nameColNo) );
+    }
+    if( hasAttrColNo != KDbNullColNo )
+    {
+        SetElmHasAttribute( aRowSet.ColUint8(hasAttrColNo) );
+    }
+    if( objIdColNo != KDbNullColNo )
+    {
+        SetElmObjId( aRowSet.ColInt(objIdColNo) );
+    }
+    if( isRequiredColNo != KDbNullColNo )
+    {
+        SetElmIsRequired( aRowSet.ColUint8(isRequiredColNo) );
+    }
+    if( valueColNo != KDbNullColNo )
+    {
+        SetElmValueL(aRowSet, valueColNo);
+    }
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::SetElmNameL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementBean::SetElmNameL(const TDesC8& aElmName)
+{
+    delete iElmName;
+    iElmName = NULL;
+    iElmName = aElmName.AllocL();
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::SetElmValueL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementBean::SetElmValueL(const RDbRowSet& aRowSet, const TInt aColNo)
+{
+    delete iElmValue;
+    iElmValue = NULL;
+    iElmValue = ReadLongTextColL(aRowSet, aColNo);
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::SetElmValueL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementBean::SetElmValueL(const TDesC8& aVal)
+{
+	delete iElmValue;
+	iElmValue = NULL;
+	iElmValue = aVal.AllocL();
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::ElmName
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TDesC8& CUpnpElementBean::ElmName() const
+{
+    return *iElmName;
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::AttachToXmlElmL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TXmlEngElement CUpnpElementBean::AttachElmL(TXmlEngElement aElement) const
+{
+    // new element
+    TXmlEngElement element;
+    
+    // Check if it's local name or if it has a namespace prefix also
+    TInt pos = iElmName->Find( KColon8 );
+    if( pos == KErrNotFound )
+    { //local name
+        element = aElement.AddNewElementL( *iElmName );
+    }
+    else    
+    { //local name with prefix
+        element = aElement.AddNewElementUsePrefixL( 
+                    iElmName->Right( iElmName->Length() - pos - 1 ), // name
+                    iElmName->Left( pos ) ); // prefix
+    }
+
+    // value     
+    element.SetValueL( *iElmValue );
+
+    return element;
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::ValAsUriL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpElementBean::ValAsUriL() const 
+{    
+    // uris have to be properly escaped
+    HBufC* tmp = UpnpCdUtils::Des8ToDesLC(*iElmValue);        
+    TUriParser uripar;
+    uripar.Parse(*tmp);
+    CUri8* uri = uri = UriUtils::ConvertToInternetFormL(uripar);
+    CleanupStack::PopAndDestroy(tmp);        
+    if (uri->Uri().UriDes().Length())
+    {                
+        HBufC8* tmp2 = UpnpString::StringReplaceL(uri->Uri().UriDes(),KHash8,KHashASCII8);        
+        delete uri;
+        return tmp2;                         
+    }
+    HBufC8* uriDes = uri->Uri().UriDes().Alloc();
+    delete uri;
+    return uriDes;
+        
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::AttachElmL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpElement* CUpnpElementBean::AttachElmL(CUpnpObject* aObj)
+{
+    // create element
+    CUpnpElement* elm = CUpnpElement::NewLC(*iElmName);
+	
+	// copy values
+    elm->SetValueL(*iElmValue);
+
+	// is required
+	elm->SetIsRequired( ElmIsRequired() );
+	// attach
+	aObj->AddElementL(elm);
+	
+	// clean up
+	CleanupStack::Pop(elm);
+	
+	return elm;
+}
+
+
+//  End of File  
--- a/upnpmediaserver/contentdirectoryservice/src/upnpelementfactory.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnpelementfactory.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1474 +1,1538 @@
-/** @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:  Element Factory.
-*
-*/
- 
-
-// INCLUDE FILES
-#include <sysutil.h>
-#include <uri8.h>
-#include <xml/dom/xmlengdomparser.h>
-
-#include "upnpelementfactory.h"
-#include "upnpcontentdirectoryglobals.h"
-#include "upnpstring.h"
-#include "upnpprotocolinfo.h"
-#include "upnpcommonupnplits.h"
-#include "upnpcdutils.h"
-#include "upnpprotocolinfolocal.h"
-
-using namespace UpnpDlnaProtocolInfo;
-
-// ============================= LOCAL FUNCTIONS ===============================
-// -----------------------------------------------------------------------------
-// DestroyRPointerArray
-// Used by TCleanupItem to destroy array
-// -----------------------------------------------------------------------------
-//
-void DestroyRArray(TAny* aArray)
-{
-    RArray<RXmlEngDocument>* array = (RArray<RXmlEngDocument>*) aArray;
-    for(TInt i = 0; i < array->Count(); i++ )
-            (*array)[i].Close();
-    (*array).Close();
-}
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::~CUpnpElementFactory()
-// C++ default destructor. (virtual destructor)
-// -----------------------------------------------------------------------------
-//
-CUpnpElementFactory::~CUpnpElementFactory()
-{
-    //Close XML document
-    iDocument.Close();
-    
-    iDOMImpl.Close(); 
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::NewL()
-// Two-phased constructor
-// -----------------------------------------------------------------------------
-//
-CUpnpElementFactory* CUpnpElementFactory::NewL( const TDesC& aObjectsXmlPath )
-{
-    CUpnpElementFactory* self = CUpnpElementFactory::NewLC( aObjectsXmlPath );
-    CleanupStack::Pop( self );
-    return self;
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::NewLC()
-// Two-phased constructor
-// -----------------------------------------------------------------------------
-//
-CUpnpElementFactory* CUpnpElementFactory::NewLC( const TDesC& aObjectsXmlPath )
-{
-    CUpnpElementFactory* self = new (ELeave) CUpnpElementFactory();
-    CleanupStack::PushL( self );
-    self->ConstructL( aObjectsXmlPath );
-    return self;
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ConstructL()
-// Two-phased constructor
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementFactory::ConstructL(const TDesC& aObjectsXmlPath)
-{
-
-    iDOMImpl.OpenL();
-
-    RXmlEngDOMParser parser;
-    User::LeaveIfError( parser.Open(iDOMImpl) );
-    CleanupClosePushL(parser);
-    
-    if ( aObjectsXmlPath == KNullDesC() )
-        {
-        RFs fs;
-        User::LeaveIfError(fs.Connect());
-        CleanupClosePushL(fs);
-
-        TFileName path;
-        User::LeaveIfError(fs.PrivatePath(path));
-
-        TParse fp;
-        fp.Set(KObjectsXmlFileName(),&path, 0);
-        path = fp.FullName();
-
-        iDocument = parser.ParseFileL( path );        
-        CleanupStack::PopAndDestroy(&fs);
-        }
-    else
-        {
-        iDocument = parser.ParseFileL( aObjectsXmlPath );                
-        }
-        
-    
-
-    CleanupStack::PopAndDestroy(&parser);
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::CUpnpElementFactory()
-// Default constructor
-// -----------------------------------------------------------------------------
-//
-CUpnpElementFactory::CUpnpElementFactory()
-{
-
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidateNewObjectL()
-// Function to validate a new object given by Control Point, especially 
-// upnp:class element field eg. object.item.musictrack
-// IMPORTANT: If objects's description is invalid due to missing elements
-// it tries to repair it by adding those missing elements.
-// -----------------------------------------------------------------------------
-//
-
-TUpnpErrorCode CUpnpElementFactory::ValidateNewObjectL( const TXmlEngElement& aNewElement, TBool aNew, TBool aLocalSharing)
-{
-    /*
-    TInt i;    
-    TPtrC8 objectType = KItem();
-
-    RXmlEngNodeList<TXmlEngElement> elements;
-    CleanupClosePushL(elements);
-    aNewElement.GetChildElements( elements );
-    
-    // invalid element if the count of the objects is less than 1 (=0)
-    if ( elements.Count() != 1 )
-    {
-        User::Leave( EInvalidArgs );
-    }
-    CleanupStack::PopAndDestroy(&elements);
-    // try to find the new item from the xml
-    TXmlEngElement object;
-    UpnpDomInterface::GetElementL( aNewElement, object, KItem() );
-    if ( object.IsNull() ) 
-    {   
-        
-        // if it's not an item, it's a container
-        UpnpDomInterface::GetElementL( aNewElement, object, KContainer() );
-        if ( object.IsNull() )
-        {
-            // not even a container, leave!
-            User::Leave ( EInvalidArgs );
-        }
-        objectType.Set( KContainer() );
-    }
-                           
-    // restriced value
-    TPtrC8 restrVal = UpnpDomInterface::GetAttrValueL( object,  KRestricted );
-    if ( 
-    (UpnpCD::Kfalse().Compare( restrVal ) != 0) &&
-    (UpnpCD::KZero().Compare( restrVal ) != 0) &&
-    (UpnpCD::Ktrue().Compare( restrVal ) != 0) &&
-    (UpnpCD::KOne().Compare( restrVal ) != 0)
-    )
-    {
-        User::Leave( EBadMetadata );
-    }
-    
-    // for convenience later, take now a reference to the children of the object
-    RXmlEngNodeList<TXmlEngElement> children;
-    CleanupClosePushL(children);
-    object.GetChildElements( children );
-            
-    // an exception: we can't have <res importUri=".. element in 
-    // a new object (set by control point)
-    while ( children.HasNext() )
-    {
-        TXmlEngElement child = children.Next();
-        
-        if ( IsNotEmptyImportUriL( child ) && aNew ) 
-        {
-            User::Leave ( EBadMetadata );
-        }
-        
-        //---- check res@duration, 7.3.22 MM DIDL-Lite res@duration Format        
-        CheckDurationOfResElementL(child);
-        CheckSizeOfResElementL(child);
-                    
-        RXmlEngNodeList<TXmlEngElement> forbiddenChildren;
-        CleanupClosePushL(forbiddenChildren);
-        child.GetChildElements( forbiddenChildren );
-
-        if ( forbiddenChildren.HasNext() 
-            && child.Name() != KVendorDescriptor ) // ignore <desc></desc>
-        {
-            User::Leave ( EBadMetadata );
-        }
-        CleanupStack::PopAndDestroy(&forbiddenChildren);
-        if ( child.Name() == KDate8() )
-        {
-            if (!UpnpCdUtils::ValidateDateL(child.Value())) 
-             child.Remove();
-        }
-        
-    }
-
-    // if survived here, we have the new element of type item or container
-    // let's analyze its type
-
-    // let's inspect each of types
-    // at first, collect object type descriptions from objects xml    
-    // to a pointer array
-    RArray<TXmlEngElement> objectDescrs;
-    CleanupClosePushL( objectDescrs );
-    // store class descriptor elements in this array
-    ClassesL( object, objectDescrs, objectType );
-    
-    // validate each separately
-    
-    ValidatePropertiesL(object, objectDescrs);
-    if(aNew)
-    {
-        ValidateBigImageL(object);
-    }
-    
-    // for each type, check that 
-    // this new object has all the required fields
-        
-    for (i=0; i<objectDescrs.Count(); i++)
-    {
-        // now we have to go through all the fields of the new item
-        // first, for convenience take a pointer to <ps>(properties) element
-        
-        RXmlEngNodeList<TXmlEngElement> propElems;
-        CleanupClosePushL(propElems);
-        objectDescrs[i].GetChildElements( propElems );
-    
-
-        while ( propElems.HasNext() )
-        {
-            
-            TXmlEngElement ps = propElems.Next(); // ps stands for properties
-            if ( ps.Name() == KProperties() )
-            {
-
-                // take the properties
-                RXmlEngNodeList<TXmlEngElement> properties;
-                CleanupClosePushL(properties);
-                ps.GetChildElements( properties );
-        
-                const TDesC8& propertyType = UpnpDomInterface::GetAttrValueL( ps, KType() );
-
-                TBool elementFound;
-                
-
-                // check each property
-                while ( properties.HasNext() )
-                {
-                    
-                    TXmlEngElement el = properties.Next();
-
-                    // Validate element
-                    if ( propertyType == KElement() )
-                    {
-                        elementFound = EFalse;
-                        
-                        // Check if this element is requiered
-                        const TDesC8& required = UpnpDomInterface::GetAttrValueL( el, KRequiredObject() );
-
-                        TPtrC8 elementName = UpnpDomInterface::GetAttrValueL( el, KName() );
-
-                        // If it's required then check it's existence
-
-                        if ( required == UpnpCD::KOne() || elementName == KRes()  ||  elementName == KAlbumArtURI() )
-                        {
-                        if( !KRes().Compare(elementName) ||  !KAlbumArtURI().Compare(elementName))
-                        {
-                            elementFound = ETrue;
-                        }
-                            // get children once more, because this kind of list does not have any reset function
-                            object.GetChildElements( children );
-                            while ( children.HasNext() )
-                            {
-                                
-                                TXmlEngElement child = children.Next();
-                                
-                                HBufC8* nameWithNs = NameWithNsLC( child );
-
-                                if ( *nameWithNs == elementName )
-                                {
-                                    // local sharing
-                                    if(aNew && *nameWithNs == KRes)
-                                    {
-                                        TUriParser8 up;
-                                        TPtrC8 rv(child.Text());
-                                        if(rv.Length())
-                                        {
-                                            User::LeaveIfError( up.Parse(child.Text()) );
-                                            TPtrC8 path( up.Extract(EUriPath) );
-                                            TPtrC8 scheme( up.Extract(EUriScheme) );
-
-                                            if(aLocalSharing)
-                                            { // local action
-                                                if( scheme == UpnpHTTP::KSchemeFile8())
-                                                {
-                                                    // The path can be: /c:/....
-                                                    // or /c/... - without colon.
-                                                    // Both situation are correct but 
-                                                    // in further operations we assume 
-                                                    // there is not any colon next to the drive letter.
-                                                    // Therefore, remove it if second element of path table equals ':'
-                                                    if(path[2] == KColon8()[0])
-                                                    { // There IS a colon next to the drive letter.
-                                                        // Here is an example uri:
-                                                        // file:///c:/...
-                                                        // As you can see the second colon must be removed
-                                                        HBufC8* uri = child.Text().AllocLC();
-                                                        TPtr8 uriPtr(uri->Des());
-                                                        TPtrC8 tmp(uri->Des());
-                                                        TInt second = 2;
-                                                        TInt colonPos = 0;
-                                                        for(TInt i = 0; i < second; i++)
-                                                        {
-                                                            colonPos += tmp.Find(KColon8) + 1;
-                                                            tmp.Set( uriPtr.Mid(colonPos) );                                                    
-                                                        }
-                                                        // remove the colon
-                                                        uriPtr.Replace(colonPos - 1, KColon8().Length(), KNullString8);
-                                                        // set TXmlEngElement value
-                                                        child.SetTextL(uriPtr);
-                                                        
-                                                        // clean up             
-                                                        CleanupStack::PopAndDestroy(uri);                                               
-                                                    }
-                        
-                                                    // check other  restrictions
-                                                    TUriParser8 up;
-                                                    User::LeaveIfError( up.Parse(child.Text()) );
-                                                    TPtrC8 path( up.Extract(EUriPath) );
-
-                                                    // sharing from Z: drive is forbidden
-                                                    // second character is a drive letter
-                                                    if(path[1] == KForbiddenDrivez()[0] || path[1] == KForbiddenDriveZ()[0])
-                                                    {
-                                                        User::Leave(EArgumentValue);
-                                                    }
-                                                    
-                                                    // cannot share from private directory
-                                                    if(!path.Match(KForbiddenPrivatePattern))
-                                                    {
-                                                        User::Leave(EArgumentValue);
-                                                    }
-                                                    
-                                                }
-                                            }
-                                            else
-                                            { // not local action
-                                                // "file" schema is forbidden here
-                                                if(scheme == UpnpHTTP::KSchemeFile8())
-                                                {
-                                                    User::Leave(EArgumentValue);
-                                                }
-                                            }
-                                        }
-                                    }
-
-
-                                    if ( elementFound ) 
-                                    {
-                                        // multiple values for one element!
-                                        const TDesC8& multiple = UpnpDomInterface::GetAttrValueL( el, KMultiple() );
-                                        
-                                        // if it's not allowed for this element, leave!
-                                        if ( !multiple.Length() )
-                                        {
-                                            User::Leave( EInvalidArgs );
-                                        }
-                                    }
-                                    elementFound = ETrue;
-                                    // mark the element required - if not res
-                                    if( KRes().Compare(elementName) && KAlbumArtURI().Compare(elementName))
-                                    {
-                                        child.AddNewAttributeL(KRequiredAtrName,KTrueValue8);
-                                    }
-                                    
-                                    // nested validation 
-                                    RXmlEngNodeList<TXmlEngElement> nestEls;
-                                    CleanupClosePushL(nestEls);
-                                    el.GetChildElements(nestEls);
-                                    while(nestEls.HasNext())
-                                    {
-                                        TXmlEngElement nestPs = nestEls.Next();
-
-                                        // take the properties
-                                        RXmlEngNodeList<TXmlEngElement> nestProperties;
-                                        nestPs.GetChildElements( nestProperties );
-                                        const TDesC8& nestPropertyType = UpnpDomInterface::GetAttrValueL( nestPs, KType() );
-                                        // Validate attribute   
-                                        if ( nestPropertyType == KAttribute() )
-                                        {
-                                            while(nestProperties.HasNext())
-                                            {   
-                                                TXmlEngElement nestEl = nestProperties.Next();
-                                                //TBool nestElementFound;
-
-                                                //nestElementFound = EFalse;
-                                                
-                                                const TDesC8& nestRequired = UpnpDomInterface::GetAttrValueL( nestEl, KRequiredObject() );
-                                                TPtrC8 nestElementName = UpnpDomInterface::GetAttrValueL( nestEl, KName() );
-                                                if ( nestRequired == UpnpCD::KOne() || nestElementName == KDlnaProfileID)
-                                                {
-                                                    TPtrC8 nestCurrentValue = UpnpDomInterface::GetAttrValueL( child, nestElementName );
-                                                    
-                                                    TPtrC8 nameOfAttr;
-                                                    TPtrC8 valOfAttr;
-                                                    nameOfAttr.Set( nestElementName );
-                                                    
-                                                    // Start of 'dlna:profileID' attribute case                                                 
-                                                    if( nameWithNs->Des() == KAlbumArtURI && nestElementName == KDlnaProfileID) // ---------------- 1 ------------
-                                                    {   
-                                                        TXmlEngAttr profId = child.AttributeNodeL(KProfileID, KXmlnsDlna);
-                                                        if(profId.NotNull())
-                                                        {
-                                                            if (profId.Value().Compare(KDefaultProfileID))
-                                                            {
-                                                                User::Leave( EBadMetadata );
-                                                            }
-                                                            // setting real name of attribute -> localName
-                                                            nestElementName.Set(KProfileID); // descriptor  
-                                                            nameOfAttr.Set( nestElementName ); // related TString
-                                                                                                                                                                                                                                                                                            
-                                                            // generating a new value of 'dlna:profileID'
-                                                            HBufC8* albumArtURIelemValue = UpnpDomInterface::GetElementValueL(child).AllocLC();
-                                                            TPtr8 albumArtURIelemValuePtr( albumArtURIelemValue->Des() );                                                       
-                                                            
-                                                            albumArtURIelemValuePtr.Trim(); // deletes leading and trailing whitespace characters                                                   
-                                                            child.SetValueL(albumArtURIelemValuePtr); // sets new trimmed value to albumArtURI
-                                                                                                                                                        
-                                                            CUpnpDlnaProtocolInfo* tempProtocolInfo = NULL;
-                                                            TInt error = iContentDirectory->GetProtocolInfoL( albumArtURIelemValuePtr, tempProtocolInfo );
-                                                            TPtrC8 tempPnParam;
-                                                            if( error >=0 )
-                                                            {
-                                                                tempPnParam.Set( tempProtocolInfo->PnParameter() );
-                                                                    
-                                                                nestCurrentValue.Set(tempPnParam); // descriptor
-                                                                valOfAttr.Set(tempPnParam); // related TString                                                         
-                                                            }
-                                                            else 
-                                                            {
-                                                                User::Leave( EBadMetadata );
-                                                            }                                                       
-                                                            CleanupStack::PopAndDestroy(albumArtURIelemValue);
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
-                                                            // if albumArtURI doesn't contain profileID -> it creates one and also related namespace
-                                                            // if albumArtURI contains profileID -> it modifies profileID's value
-                                                            child.SetAttributeL( nameOfAttr, valOfAttr, KXmlnsDlna(), KDlnaPrefix() );
-                                                                                                                    
-                                                            delete tempProtocolInfo;
-                                                            tempProtocolInfo = NULL;    
-                                                        }
-                                                        
-                                                    } // End of 'dlna:profileID' attribute case
-                                                    else                    
-                                                    {
-                                                        if ( !nestCurrentValue.Length() )  
-                                                        {
-                                                            
-                                                            if(nestElementName == KprotocolInfo)
-                                                            {
-                                                                if( ! aLocalSharing )
-                                                                {
-                                                                    valOfAttr.Set( KEmptyProtocolInfoVal8() );
-                                                                }
-                                                                else 
-                                                                {
-                                                                    User::Leave( EBadMetadata );
-                                                                }
-                                                            }                                                                                                   //------- 2 -----                                                                                    //------- 2 -----                  
-                                                            else
-                                                            {
-                                                                valOfAttr.Set( KNullDesC8() );
-                                                            }
-                                
-                                                            child.AddNewAttributeL( nameOfAttr, valOfAttr );                                                            
-                                                        }
-                                                        else 
-                                                        {
-                                                            if(nestElementName == KprotocolInfo) 
-                                                            {
-                                                                HBufC8* protInfoValue = NULL;
-                                                                TRAPD(err, protInfoValue = ValidateProtocolInfoInResL( nestCurrentValue, aLocalSharing ));
-                                                                if(err)
-                                                                {
-                                                                    User::Leave(EBadMetadata);
-                                                                }
-                                                                CleanupStack::PushL( protInfoValue );
-                                                                valOfAttr.Set( *protInfoValue );
-                                                                child.SetAttributeL( nameOfAttr, valOfAttr );
-                                                                CleanupStack::PopAndDestroy( protInfoValue );                                                           
-                                                            }                                                                                                 //------- 3 -----                                                                                         //------- 3 -----
-                                                        }
-                                                    }                                                                                                                                                                                                                                                                                                                                                                                       
-                                                                                                        
-
-                                                    // if not main tag mark the attr is required
-                                                    if( !IsMainObjectTagL(child) && nestElementName != KDlnaProfileID)
-                                                    {
-                                                       
-                                                        HBufC8* attrReq = HBufC8::NewLC(
-                                                            nestElementName.Length()
-                                                            +KRequiredAtrSuf().Length() );
-                                                        TPtr8 attrReqPtr(attrReq->Des());
-                                                        attrReqPtr = nestElementName;
-                                                        attrReqPtr.Append(KRequiredAtrSuf);
-                                                        child.AddNewAttributeL( attrReqPtr, KTrueValue8 );
-                                                        CleanupStack::PopAndDestroy(attrReq);
-                                                    }
-                                                }
-                                            }
-                                        }
-                                    
-                                    }
-                                    CleanupStack::PopAndDestroy(&nestEls);
-                                }
-                                CleanupStack::PopAndDestroy( nameWithNs );
-                                
-                            }
-                                
-                            // If not found, add it
-                            if ( !elementFound )
-                            {
-                                User::Leave(EBadMetadata);
-                            }
-                        } 
-                    }
-                        
-                    // Validate attribute   
-                    if ( propertyType == KAttribute() )
-                    {
-                        elementFound = EFalse;
-                        
-                        const TDesC8& required = UpnpDomInterface::GetAttrValueL( el, KRequiredObject() );
-                        if ( required == UpnpCD::KOne() )
-                        {
-
-                            const TDesC8& elementName = UpnpDomInterface::GetAttrValueL( el, KName() );
-
-                            const TDesC8& currentValue = UpnpDomInterface::GetAttrValueL( object, elementName );
-                            
-                            if ( !currentValue.Length() )  
-                            {
-                                TXmlEngAttr attr = object.AttributeNodeL( elementName );
-
-                                if(attr.NotNull())
-                                {
-                                    attr.SetValueL(KNullDesC8);
-                                }
-                                else
-                                {
-                                    object.AddNewAttributeL( elementName, KNullDesC8 );
-                                }                               
-                            }
-                            // if not main tag mark the attr is required
-                            if(!IsMainObjectTagL(object))
-                            {
-                                HBufC8* attrReq = HBufC8::NewLC(
-                                    elementName.Length()+KRequiredAtrSuf().Length() );
-                                TPtr8 attrReqPtr(attrReq->Des());
-                                attrReqPtr = elementName;
-                                attrReqPtr.Append(KRequiredAtrSuf);
-                                object.AddNewAttributeL( attrReqPtr, KTrueValue8 );
-                                CleanupStack::PopAndDestroy(attrReq);
-                            }
-                        }
-                    }
-                }
-                CleanupStack::PopAndDestroy(&properties);
-            }
-        }
-        CleanupStack::PopAndDestroy(&propElems);
-    }
-    CleanupStack::PopAndDestroy(); //objectDescrs.Close();
-    CleanupStack::PopAndDestroy(&children);
-    
-    // now the object 
-    // * has the all required fields (if some were missing, they are added)
-    // * had a proper xml structure (_not_ using UpnpDomInterface:: functions that do not care)
-    // * has for sure a mostly proper object structure 
-*/
-    return EUndefined;
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidatePropertiesL()
-// Function leaves on error.
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementFactory::ValidatePropertiesL( TXmlEngElement aObj,
-                                               RArray<TXmlEngElement>& aClassList)
-{
-    // validate main object's attributes
-    ValidateMainAttributesL(aObj, aClassList);
-    
-    // validate elements
-    RXmlEngNodeList<TXmlEngElement> elements;
-    CleanupClosePushL(elements);
-    aObj.GetChildElements (elements);
-    
-    // for each element
-    while(elements.HasNext())
-    {
-        TXmlEngElement el = elements.Next();
-        ValidateElementL(el, aClassList);
-    }
-    CleanupStack::PopAndDestroy(&elements);
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidateBigImageL()
-// Function leaves on error.
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementFactory::ValidateBigImageL( TXmlEngElement aObj)
-{
-    RArray<TXmlEngElement> elms;
-    CleanupClosePushL(elms);
-    
-    if( UpnpDomInterface::GetElementListL(aObj, elms, KRes) )
-    {
-        for(TInt i = 0; i < elms.Count(); i++)
-        {
-                
-            TXmlEngAttr prInfAttr = elms[i].AttributeNodeL(KprotocolInfo());
-            if(prInfAttr.NotNull())
-            {
-                CUpnpProtocolInfoLocal* protInf = CUpnpProtocolInfoLocal::NewL(
-                        UpnpDomInterface::GetAttrValueL(elms[i], KprotocolInfo) );
-                CleanupStack::PushL(protInf);
-                                                                                   
-                /* Only support for DLNA pn-params:
-                *  1) JPEG_SM
-                *  2) MP3 
-                *  3) AAC_ISO_320
-                *  4) AVC_MP4_BL_CIF15_AAC_520
-                */
-                if( protInf->PnParameter() != KDLNA_PN_JPEG_SM &&
-                    protInf->PnParameter() != KDLNA_PN_MP3 &&
-                    protInf->PnParameter() != KDLNA_PN_AAC_ISO_320 &&
-                    protInf->PnParameter() != KDLNA_PN_AVC_MP4_BL_CIF15_AAC_520                     
-                  )
-                {           
-                    // set 4th parameter to "*"
-                    protInf->SetFourthFieldL(KAsterisk8);
-                    TPtrC8 prInfo = protInf->ProtocolInfoL();
-                    HBufC8* prInfTmp = prInfo.Alloc();
-                    CleanupStack::PushL(prInfTmp);
-                    prInfAttr.SetValueL( *prInfTmp );
-                    CleanupStack::PopAndDestroy(prInfTmp);
-                }
-                // clean up
-                CleanupStack::PopAndDestroy(protInf);
-            }
-        }
-    }
-    
-    // clean up
-    CleanupStack::PopAndDestroy(&elms);
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidateElementL()
-// Function leaves on error.
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementFactory::ValidateElementL( TXmlEngElement aElement,
-                                            RArray<TXmlEngElement>& aClassList)
-{
-    if(aElement.Name() == KRes)
-    {
-        ValidateResElL(aElement, aClassList);
-    }
-    else
-    {
-        //  get pattern 
-        HBufC8* name = UpnpCdUtils::GetElmNameWithNsL(aElement);
-        CleanupStack::PushL(name);
-        TXmlEngElement pattern = GetPatternL(*name, aClassList, KElement);
-        if(pattern.NotNull())
-        {
-            ValidateElWithPatternL(aElement, pattern); // leaves on error
-        }
-        else
-        { // attr is not supported - remove
-            aElement.Remove();
-        }
-        // clean up
-        CleanupStack::PopAndDestroy(name);
-    }
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidateMainAttributesL()
-// Function leaves on error.
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementFactory::ValidateMainAttributesL( TXmlEngElement aObj, 
-                                                   RArray<TXmlEngElement>& aClassList)
-{
-    // list of attributes
-    RXmlEngNodeList<TXmlEngAttr> attrList;
-    CleanupClosePushL(attrList);
-    aObj.GetAttributes(attrList);
-    
-    // for each attr
-    while(attrList.HasNext())
-    {
-        // get attr
-        TXmlEngAttr attr = attrList.Next();
-        
-        //  get pattern 
-        TXmlEngElement pattern = GetPatternL(attr.Name(), aClassList, KAttribute);
-        if(pattern.NotNull())
-        {
-            ValidateAttrWithPatternL(attr, pattern); // leaves on error
-        }
-        else
-        { // attr is not supported - remove
-            attr.Remove();
-        }
-    }
-    CleanupStack::PopAndDestroy(&attrList);
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidateElWithPatternL()
-// Function leaves on error.
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementFactory::ValidateResElL( TXmlEngElement aElement, 
-                                         RArray<TXmlEngElement>& aClassList)
-{
-    // list of attributes
-    RXmlEngNodeList<TXmlEngAttr> attrList;
-    CleanupClosePushL(attrList);
-    aElement.GetAttributes(attrList);
-    
-    // for each attr
-    while(attrList.HasNext())
-    {
-        // get attr
-        TXmlEngAttr attr = attrList.Next();
-        
-        //  get pattern 
-        TXmlEngElement pattern = GetPatternForResAttrL(attr.Name(), aClassList);
-        if(pattern.NotNull())
-        {
-            ValidateAttrWithPatternL(attr, pattern); // leaves on error
-        }
-        else
-        { // attr is not supported - remove
-            attr.Remove();
-        }
-    }
-    CleanupStack::PopAndDestroy(&attrList);
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidateElWithPatternL()
-// Function leaves on error.
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementFactory::ValidateElWithPatternL(   TXmlEngElement aElement, 
-                                                    TXmlEngElement aPattern )
-{
-    // is required?
-    if(IsRequiredL(aPattern) )
-    { // cannot be empty
-        if( !aElement.Value().Length() || 
-            UpnpCdUtils::IsWhiteString( aElement.Value() ) )
-        {
-            User::Leave(EBadMetadata);
-        }
-    }
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidateAttrWithPatternL()
-// Function leaves on error.
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementFactory::ValidateAttrWithPatternL( TXmlEngAttr aAttr, 
-                                                    TXmlEngElement aPattern )
-{
-    // is required?
-    if(IsRequiredL(aPattern) )
-    { // cannot be empty
-        if( !aAttr.Value().Length() || 
-            UpnpCdUtils::IsWhiteString( aAttr.Value() ) )
-        {
-            User::Leave(EBadMetadata);
-        }
-    }
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidateAttrWithPatternL()
-// Function leaves on error.
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpElementFactory::IsRequiredL(TXmlEngElement aPattern) 
-{
-    TXmlEngAttr reqAttr = aPattern.AttributeNodeL(KRequiredObject());
-    TBool ret = EFalse;
-    if( reqAttr.NotNull() &&
-        reqAttr.Value().Length() && 
-        reqAttr.Value() == KTrueValue8() )
-    {
-        ret = ETrue;
-    }
-    return ret;
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::GetPatternForElL()
-// Function leaves on error.
-// -----------------------------------------------------------------------------
-//
-TXmlEngElement CUpnpElementFactory::GetPatternL( const TDesC8& aPropertyName,
-                                                RArray<TXmlEngElement>& aClassList,
-                                                const TDesC8& aType )
-{
-    TXmlEngElement retEl;
-    
-    // for each class
-    for(TInt i = 0; i < aClassList.Count(); i++)
-    {
-        TXmlEngElement elPattEl;      
-        UpnpDomInterface::GetDirectoryElementL(aClassList[i], elPattEl, KProperties, KType, aType);
-        if(elPattEl.NotNull())
-        {   
-            UpnpDomInterface::GetDirectoryElementL(elPattEl, retEl, KObjectProperty, KObjectName, aPropertyName);
-            
-            // break if found
-            if(retEl.NotNull())
-            {
-                break;
-            }
-        }
-    }
-    
-    return retEl;
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::GetPatternForResAttrL()
-// Function leaves on error.
-// -----------------------------------------------------------------------------
-//
-TXmlEngElement CUpnpElementFactory::GetPatternForResAttrL(const TDesC8& aPropertyName,
-                                                    RArray<TXmlEngElement>& aClassList )
-{
-    TXmlEngElement retEl;
-    
-    // for each class
-    for(TInt i = 0; i < aClassList.Count(); i++)
-    {
-        TXmlEngElement resAttrPattEl;     
-        UpnpDomInterface::GetDirectoryElementL(aClassList[i], resAttrPattEl, KProperties, KType, KResAttr);
-        if(resAttrPattEl.NotNull())
-        {   
-            UpnpDomInterface::GetDirectoryElementL(resAttrPattEl, retEl, KObjectProperty, KObjectName, aPropertyName);
-            
-            // break if found
-            if(retEl.NotNull())
-            {
-                break;
-            }
-        }
-    }
-    
-    return retEl;
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::IsMainObjectTagL()
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpElementFactory::IsMainObjectTagL(TXmlEngElement aElement)
-{
-    TXmlEngElement notNeeded;
-    return UpnpDomInterface::GetElementL(aElement, notNeeded, KClassTagName);
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ActiveElementL()
-// Gets active element from XML document. An active element
-// is a first element different from <DIDL-Lite> element.
-// -----------------------------------------------------------------------------
-//
-TXmlEngElement CUpnpElementFactory::ActiveElementL( const RXmlEngDocument& aDocument )
-{
-    if( aDocument.IsNull() || aDocument.DocumentElement().IsNull() )
-    {
-        User::Leave( KErrNotFound );            
-    }
-        
-    if ( aDocument.DocumentElement().Name().CompareF( KDidlLite() ) != 0 )
-    {
-        return aDocument.DocumentElement();
-    }
-    else
-    {
-        TXmlEngElement root = aDocument.DocumentElement();
-        RXmlEngNodeList<TXmlEngElement> children;
-        CleanupClosePushL(children);
-        root.GetChildElements( children );
-    //    children.HasNext();
-        CleanupStack::PopAndDestroy(&children);
-        return children.Next();
-    }
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ExtractActiveElementL()
-// Extracts active element from XML document. 
-// An active element is a first element different from <DIDL-Lite> element.
-// IMPORTANT: Caller takes responsibility for returned element. 
-// -----------------------------------------------------------------------------
-//
-RXmlEngDocument CUpnpElementFactory::ExtractActiveElementL( const RXmlEngDocument& aDocument )
-{
-    TXmlEngElement active;
-    RXmlEngDocument ret;
-    ret.OpenL(iDOMImpl);
-    CleanupClosePushL(ret);
-
- /*    if( aDocument.IsNull() || aDocument.DocumentElement().IsNull() )
-    {
-        User::Leave( KErrNotFound );            
-    }
-        
-    if ( aDocument.DocumentElement().Name().CompareF( KDidlLite() ) != 0 )
-    {
-        active = aDocument.DocumentElement().Unlink().AsElement();
-    }
-    else
-    {
-        TXmlEngElement root = aDocument.DocumentElement();
-        RXmlEngNodeList<TXmlEngElement> children;
-        CleanupClosePushL(children);
-        root.GetChildElements( children );
-        children.HasNext();
-        active = children.Next().Unlink().AsElement();
-        CleanupStack::PopAndDestroy(&children);
-    }
-    ret.SetDocumentElement(active);
-   */    
-    CleanupStack::Pop(&ret);
-    
-    return ret;
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ElementsMatchL()
-// Checks if two elements are equal and have exactly the same subtrees.
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpElementFactory::ElementsMatchL( TXmlEngElement aFirst, TXmlEngElement aSecond )
-{
-    // this function checks following things:
-    // 1. element names
-    // 2. contents of the elements
-    // 3. attributes of the elements
-    // 4. child elements of the elements
-    
-    if ( aFirst.Name().Compare(aSecond.Name()) == 0 )
-    {
-        // aFirst names match. next: check namespace
-        if ( aFirst.Prefix().Compare( aSecond.Prefix()) == 0 )
-        {
-            if (!aFirst.Text().Compare(aSecond.Text()))
-            {
-                
-                // namespacess match, next: check attributes
-                RXmlEngNodeList<TXmlEngAttr> elemAttrs;
-                CleanupClosePushL(elemAttrs);
-                RXmlEngNodeList<TXmlEngAttr> currAttrs;
-                CleanupClosePushL(currAttrs);
-                
-                aFirst.GetAttributes( elemAttrs );
-                aSecond.GetAttributes( currAttrs );
-                
-                if ( elemAttrs.Count() == currAttrs.Count() )
-                {
-                    // first step in comparing attributes ready (counts match!)
-                    // next, check names and values (for each attribute)
-
-                    while( elemAttrs.HasNext() && currAttrs.HasNext() )
-                    {
-                        TXmlEngAttr elemAttr = elemAttrs.Next();
-                        TXmlEngAttr currAttr = currAttrs.Next();
-                        
-                        // compare names and values
-                        if ( elemAttr.Name().Compare( currAttr.Name() ) )
-                        {
-                            CleanupStack::PopAndDestroy(&currAttrs);
-                            CleanupStack::PopAndDestroy(&elemAttrs);
-                            return EFalse;
-                        }
-                        if ( elemAttr.Value().Compare( currAttr.Value() ) )
-                        {
-                            CleanupStack::PopAndDestroy(&currAttrs);
-                            CleanupStack::PopAndDestroy(&elemAttrs);
-                            return EFalse;
-                        }
-                        
-                    }
-                    
-                    // compare child elements (recursive function call)
-                    RXmlEngNodeList<TXmlEngElement> fChildren;
-                    CleanupClosePushL(fChildren);
-                    RXmlEngNodeList<TXmlEngElement> sChildren;
-                    CleanupClosePushL(sChildren);
-                                        
-                    aFirst.GetChildElements( fChildren );
-                    aSecond.GetChildElements( sChildren );
-                
-                    
-                    if ( fChildren.Count() == sChildren.Count() )
-                    {
-                            while ( fChildren.HasNext() && sChildren.HasNext() )
-                            {
-                            // call this function again for children
-                                TBool matching = ElementsMatchL( fChildren.Next(), sChildren.Next() );
-
-                            // if some of the elements do not match, return false!
-                                if (matching == EFalse)
-                                {
-                                    CleanupStack::PopAndDestroy(&sChildren);
-                                    CleanupStack::PopAndDestroy(&fChildren);
-                                    CleanupStack::PopAndDestroy(&currAttrs);
-                                    CleanupStack::PopAndDestroy(&elemAttrs);
-                                    return EFalse;
-                                }
-                            }
-                        // only place to return ETrue
-                        // all the checks are made; if survived here, elements match!
-                        CleanupStack::PopAndDestroy(&sChildren);
-                        CleanupStack::PopAndDestroy(&fChildren);
-                        CleanupStack::PopAndDestroy(&currAttrs);
-                        CleanupStack::PopAndDestroy(&elemAttrs);
-                        return ETrue;
-                    }
-                    CleanupStack::PopAndDestroy(&sChildren);
-                    CleanupStack::PopAndDestroy(&fChildren);
-                }
-                CleanupStack::PopAndDestroy(&currAttrs);
-                CleanupStack::PopAndDestroy(&elemAttrs);
-            }
-        }
-    }
-    
-    return EFalse;
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::CountElementsL()
-// Prepares corresponding RArray<TXmlEngElements> and calls 
-// CountElementsL( const TDesC8& aName, RArray<TXmlEngElement>& aArray )
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpElementFactory::CountElementsL( const TDesC8& aName, RArray<RXmlEngDocument>& aArray )
-{
-    TInt count(0);
-        
-    for(TInt i = 0; i < aArray.Count(); i++)
-    {            
-        if ( aArray[i].DocumentElement().NotNull() )
-        {
-            if ( aArray[i].DocumentElement().Name() == aName )
-            {
-                count++;
-            }
-        }
-            
-    }
-    return count;
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::CountElementsL()
-// Counts elements in array that have the same name.
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpElementFactory::CountElementsL( const TDesC8& aName, RArray<TXmlEngElement>& aArray )
-{
-    TInt count(0);
-    
-    for (TInt v(0); v<aArray.Count(); v++)
-    {
-        if ( aArray[v].NotNull() )
-        {
-            if ( aArray[v].Name() == aName )
-            {
-                count++;
-            }
-        }
-    }
-    
-    return count;
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::NameWithNsLC()
-// Constructs descriptor with element's name and namespace prefix separated with colon.
-// IMPORTANT: As the function name indicates, it leaves pointer to heap descriptor on 
-// cleanup stack.
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpElementFactory::NameWithNsLC(const TXmlEngElement& aElement)
-{
-    const TDesC8& localName = aElement.Name();
-    TPtrC8 prefix = aElement.Prefix();
-
-    if ( prefix.Length() > 0)
-    {
-
-        HBufC8* nameWithNs = HBufC8::NewLC( 
-            localName.Length() + 
-            UpnpString::KColon().Length() +
-            prefix.Length() );
-
-        nameWithNs->Des().Append( prefix );
-        nameWithNs->Des().Append( UpnpString::KColon() );
-        nameWithNs->Des().Append( localName );
-
-        return nameWithNs;
-    }
-    else
-    {
-        return localName.AllocLC();
-    }
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ClassesL()
-// Gets classes descriptions for given object.
-// -----------------------------------------------------------------------------
-//
-void CUpnpElementFactory::ClassesL( const TXmlEngElement& aObject, RArray<TXmlEngElement>& aArray, const TDesC8& aObjType )
-{
-    TInt i(0);
-    
-    // if survived here, we have the new element of type item or container
-    // let's analyze its type
-    TXmlEngElement type;
-    UpnpDomInterface::GetElementL ( aObject, type, KClass() );
-
-    if ( type.IsNull() ) 
-    {
-        // no <class> element! leave
-        User::Leave( EBadMetadata );
-    }
-
-    // check that does the new element have all the required fields for its type
-    // and also check that it does not have whatever fields (only optional allowed)
-    RPointerArray<TPtrC8> objectFields;
-    
-    TPtrC8 content = type.Text();
-    if( !content.Length() )
-    {
-        User::Leave( EBadMetadata );
-    }
-    //--- removing white spaces ------------------      
-    HBufC8* tempBuffer = type.Text().AllocLC(); 
-    TPtr8 tmpPtr(tempBuffer->Des());
-    UpnpCdUtils::RemoveWhiteSpacesL(tmpPtr);        
-    CleanupStack::Check(tempBuffer);
-    type.SetTextL(tmpPtr);  
-    //--------------------------------------------
-    
-    UpnpString::CutToPiecesL(tmpPtr, TChar('.'), objectFields );    
-    CleanupStack::Check(tempBuffer);
-    // let's inspect each of types
-    // at first, collect object type descriptions from objects xml    
-    // to a pointer array
-    
-    TInt NumberOfObjectFields = objectFields.Count();
-    
-    for ( i=0; i < NumberOfObjectFields; i++ ) 
-    {
-        // seek for such object type
-        TXmlEngElement objectDescription;
-
-        UpnpDomInterface::GetDirectoryElementL( 
-                iDocument.DocumentElement(), 
-                objectDescription, 
-                KElement, 
-                KType, 
-                *objectFields[i] );
-        CleanupStack::Check(tempBuffer);
-        // if such type found
-        if ( objectDescription.NotNull() ) 
-        {
-            aArray.AppendL( objectDescription );
-        }
-        /* This case is valid for any numeric value of containerID used in CreateObject() action
-        *  We do some checking starting from 3rd string of <upnp:class> element, if the string isn't
-        *  recognizable, instead of leaving, we trims the value of <upnp:class> element, e.g:
-        *  'object.item.imageItem.abcd' -> is trimmed into -> 'object.item.imageItem'
-        *  DLNA 7.3.120.4 requirement
-        */
-        else if( i >= 2 )
-        {            
-            for( TInt j = NumberOfObjectFields - 1; j >= i; j-- )
-            {                            
-                TInt pos = tmpPtr.LocateReverse( TChar('.') );                    
-                if( pos > KErrNotFound )
-                {
-                    tmpPtr.Copy( tmpPtr.Left(pos) );                   
-                                                
-                    delete objectFields[j];
-                    objectFields.Remove(j);   
-                }                    
-            }                                                
-            type.SetTextL(tmpPtr); // changing xml                        
-            
-            break;
-        }
-        else 
-        {
-            objectFields.ResetAndDestroy();
-            objectFields.Close();
-            User::Leave( EBadMetadata );
-        }
-    }
-    CleanupStack::Check(tempBuffer);
-    /*  for each type, check that: 
-    *   1. it is referenced to its current parent type (e.g. audioItem -> item)
-    *   2. this new object has all the required fields
-    *   3. relations between object types and values of 'upnp:class':
-    *      <item> -> 'object.item' or <container> -> 'object.container'
-    */
-       
-    // we count the number of elements once again, because size of the array might change
-    NumberOfObjectFields = objectFields.Count(); 
-
-    for ( i=0; i < NumberOfObjectFields; i++ )
-    {
-        const TDesC8& field = *objectFields[i];
-
-        // 1. first, check the parent relation 
-        // first type must be "object"!
-        if ( i==0 ) 
-        {
-            /* Leave if:
-            *  1. first type isn't the 'object' OR
-            *  2. 'upnp:class' contains only 'object' type [which in matter of fact isn't instantiable]
-            */
-            if ( field != KObject() || 
-                 field == KObject() && NumberOfObjectFields == 1
-            ) 
-            {
-                // if not "item", leave!
-                objectFields.ResetAndDestroy();
-                objectFields.Close();
-                User::Leave( EBadMetadata );
-            }
-        }
-        // for later types, check the relation really
-        else 
-        {   
-            // checking relations between object types and values of 'upnp:class'
-            if( i == 1 && aObjType.Length() > 0 )
-            {
-                if(  !field.Compare(KItem) && aObjType.Compare(KItem) ||
-                     !field.Compare(KContainer) && aObjType.Compare(KContainer)
-                )
-                {          
-                    objectFields.ResetAndDestroy();
-                    objectFields.Close();                              
-                    User::Leave( EBadMetadata );
-                }
-            }            
-            //----------------------------------------    
-            const TDesC8& parent = *objectFields[i-1];
-            
-            // if we've survived to this point, this parent string
-            // should match with the one in the previous object description xml element
-            TXmlEngElement iparent;
-            UpnpDomInterface::GetElementL ( aArray[i], iparent, KIParent() );
-            CleanupStack::Check(tempBuffer);
-            TPtrC8 cont = iparent.Text();
-        
-            // now check the actual relation. leave if strings do not match!
-            if ( cont.Length() && parent != cont )
-            {
-                objectFields.ResetAndDestroy();
-                objectFields.Close();
-                User::Leave( EBadMetadata );
-            }
-        }
-    }
-    CleanupStack::PopAndDestroy(tempBuffer);
-    objectFields.ResetAndDestroy();
-    objectFields.Close();
-    return;
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::IsNotEmptyImportUriL()
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpElementFactory::IsNotEmptyImportUriL( const TXmlEngElement& aElement )
-{
-    TXmlEngAttr importUri;
-    
-    if ( aElement.Name() == KRes() )
-    {
-        importUri = aElement.AttributeNodeL( KImportUri8() );
-        
-        // remove if empty importUri: DLNA Requirement [7.3.134.5]
-        TPtrC8 val( importUri.Value() );
-        if( UpnpCdUtils::IsWhiteString( val ) )
-        {
-            importUri.Remove();
-        }
-    }
-
-    return importUri.NotNull();
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::IsClassElement()
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpElementFactory::IsClassElement( const TXmlEngElement& aElement )
-{
-    if ( aElement.Name() == KClass() )
-    {
-        return ETrue;
-    }
-    else
-    {
-        return EFalse;
-    }
-}
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::ValidateProtocolInfoInResL
-//  Allocates string, which is object type for this object. 
-// -----------------------------------------------------------------------------
-HBufC8* CUpnpElementFactory::ValidateProtocolInfoInResL( const TDesC8& aProtocolInfo, TBool aLocalSharing )
-{
-    HBufC8* result = NULL; 
-   // CUpnpDlnaProtocolInfo* protocolInfo = CUpnpDlnaProtocolInfo::NewL( (TDesC8&)aProtocolInfo );
-    CUpnpProtocolInfoLocal* protocolInfo = CUpnpProtocolInfoLocal::NewL( (TDesC8&)aProtocolInfo );
-    CleanupStack::PushL( protocolInfo ); 
-    _LIT8(KProtocolInfoHttpGet, "http-get"); 
-    protocolInfo->SetFirstFieldL( (TDesC8&)KProtocolInfoHttpGet() ); 
-    protocolInfo->SetSecondFieldL( (TDesC8&)KAsterisk8() ); 
-    TPtrC8 third = protocolInfo->ThirdField(); 
-    if(( third.Find( KSlash8()) == KErrNotFound) && 
-      ( third.Compare( KAsterisk8()) != KErrNone))
-    {
-        if( aLocalSharing)
-        {
-        User::Leave( EBadMetadata );
-        }
-        protocolInfo->SetThirdFieldL( (TDesC8&) KAsterisk8());                                  
-    }
-   // if( protocolInfo->IsDlnaInformationIncluded() ) // Check it !!!
-    {
-        protocolInfo->SetOpParameterL( UpnpDlnaProtocolInfo::B_VAL , ETrue );
-        protocolInfo->SetOpParameterL( UpnpDlnaProtocolInfo::A_VAL , EFalse ); 
-    }
-    TPtrC8 prInfo = protocolInfo->ProtocolInfoL();
-    result =  prInfo.Alloc();
-    CleanupStack::PopAndDestroy( protocolInfo ); 
-    return result; 
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::GetContentDirectoryReference
-// Function gets pointer to CUpnpContentDirectory and puts it into CUpnpElementFactory object  
-// -----------------------------------------------------------------------------
-void CUpnpElementFactory::GetContentDirectoryReference(CUpnpContentDirectory* aCD)
-{
-    iContentDirectory = aCD;
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::CheckDurationOfResElement
-// If res@duration attribute exists, the method checks whether it has valid format
-// -----------------------------------------------------------------------------
-
-void CUpnpElementFactory::CheckDurationOfResElementL(const TXmlEngElement& aElement)
-{
-    TXmlEngAttr duration;
-    
-    // if this is the 'res' element            
-    if( aElement.Name() == KRes() )
-    {
-        // and it has res@duration attribute
-        duration = aElement.AttributeNodeL( KDuration8() );                                        
-        if( duration.NotNull() )
-        {
-            TCurrentAction action = iContentDirectory->ExecutedAction();                                         
-            TPtrC8 val( duration.Value() );
-            
-            // if res@duration atrribute value is invalid [has improper format]
-            if( !UpnpCdUtils::ValidateDurationValue(val) )
-            {            
-                // remove it from 'res' element if it is CreateObject()
-                if( action == ECreateObjectAction )
-                {
-                    duration.Remove();
-                }                
-            }
-        }
-    }   
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpElementFactory::CheckSizeOfResElement
-// If res@size attribute exists, the method checks whether it has valid format
-// size should be unsigned int.
-// -----------------------------------------------------------------------------
-void CUpnpElementFactory::CheckSizeOfResElementL(
-    const TXmlEngElement& aElement )
-    {
-    TXmlEngAttr sizeAttr;
-
-    // if this is the 'res' element            
-    if ( aElement.Name() == KRes() )
-        {
-        // and it has res@size attribute
-        sizeAttr = aElement.AttributeNodeL( KSize() );
-        if ( sizeAttr.NotNull() )
-            {
-            TCurrentAction action = iContentDirectory->ExecutedAction();
-            TPtrC8 val( sizeAttr.Value() );
-
-            // if res@size atrribute value is invalid [is not an unsigned long]
-            TUint32 unsignedLong = 0;
-
-            TLex8 lexULong(val);
-            TInt error = lexULong.Val( unsignedLong, EDecimal );
-                         
-            TInt remainder = lexULong.Remainder().Length();
-
-            if ( error != KErrNone || remainder )
-                {
-                // remove it from 'res' element if it is CreateObject()
-                if ( action == ECreateObjectAction )
-                    {
-                    sizeAttr.Remove();
-                    }
-                }
-            }
-        }
-
-    }
-
-//  End of File
+/** @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:  Element Factory.
+*
+*/
+ 
+
+// INCLUDE FILES
+#include <sysutil.h>
+#include <uri8.h>
+#include <xmlengdomparser.h>
+
+#include "upnpelementfactory.h"
+#include "upnpcontentdirectoryglobals.h"
+#include "upnpstring.h"
+#include "upnpprotocolinfo.h"
+#include "upnpcommonupnplits.h"
+#include "upnpcdutils.h"
+#include "upnpprotocolinfolocal.h"
+
+using namespace UpnpDlnaProtocolInfo;
+
+// ============================= LOCAL FUNCTIONS ===============================
+// -----------------------------------------------------------------------------
+// DestroyRPointerArray
+// Used by TCleanupItem to destroy array
+// -----------------------------------------------------------------------------
+//
+void DestroyRArray(TAny* aArray)
+{
+    RArray<RXmlEngDocument>* array = (RArray<RXmlEngDocument>*) aArray;
+    for(TInt i = 0; i < array->Count(); i++ )
+            (*array)[i].Close();
+    (*array).Close();
+}
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::~CUpnpElementFactory()
+// C++ default destructor. (virtual destructor)
+// -----------------------------------------------------------------------------
+//
+CUpnpElementFactory::~CUpnpElementFactory()
+{
+    //Close XML document
+    iDocument.Close();
+    
+    iDOMImpl.Close(); 
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::NewL()
+// Two-phased constructor
+// -----------------------------------------------------------------------------
+//
+CUpnpElementFactory* CUpnpElementFactory::NewL( const TDesC& aObjectsXmlPath )
+{
+    CUpnpElementFactory* self = CUpnpElementFactory::NewLC( aObjectsXmlPath );
+    CleanupStack::Pop( self );
+    return self;
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::NewLC()
+// Two-phased constructor
+// -----------------------------------------------------------------------------
+//
+CUpnpElementFactory* CUpnpElementFactory::NewLC( const TDesC& aObjectsXmlPath )
+{
+    CUpnpElementFactory* self = new (ELeave) CUpnpElementFactory();
+    CleanupStack::PushL( self );
+    self->ConstructL( aObjectsXmlPath );
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ConstructL()
+// Two-phased constructor
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementFactory::ConstructL(const TDesC& aObjectsXmlPath)
+{
+
+    iDOMImpl.OpenL();
+
+    RXmlEngDOMParser parser;
+    User::LeaveIfError( parser.Open(iDOMImpl) );
+    CleanupClosePushL(parser);
+    
+    if ( aObjectsXmlPath == KNullDesC() )
+        {
+        RFs fs;
+        User::LeaveIfError(fs.Connect());
+        CleanupClosePushL(fs);
+
+        TFileName path;
+        User::LeaveIfError(fs.PrivatePath(path));
+
+        // Load dll file
+        TFileName objectsXmlFileName( KObjectsXmlFileName() );
+        TFileName dllName;
+        Dll::FileName( dllName );
+        TBuf<2> drive = dllName.Left( 2 ); // Drive letter followed by ':' 
+        objectsXmlFileName.Insert( 0, drive );
+        
+        TParse fp;
+        fp.Set(objectsXmlFileName,&path, 0);
+        path = fp.FullName();
+
+        iDocument = parser.ParseFileL( path );        
+        CleanupStack::PopAndDestroy(&fs);
+        }
+    else
+        {
+        iDocument = parser.ParseFileL( aObjectsXmlPath );                
+        }
+        
+    
+
+    CleanupStack::PopAndDestroy(&parser);
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::CUpnpElementFactory()
+// Default constructor
+// -----------------------------------------------------------------------------
+//
+CUpnpElementFactory::CUpnpElementFactory()
+{
+
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::CheckRestrictedValue()
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpElementFactory::CheckRestrictedValue (TPtrC8& restrVal)
+    {
+    TBool retVal = EFalse;
+
+    if ( 
+    (UpnpCD::Kfalse().Compare( restrVal ) != 0) &&
+    (UpnpCD::KZero().Compare( restrVal ) != 0) &&
+    (UpnpCD::Ktrue().Compare( restrVal ) != 0) &&
+    (UpnpCD::KOne().Compare( restrVal ) != 0)
+    )
+        {
+        retVal = ETrue;
+        }
+    return retVal;
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidateNewObjectL()
+// Function to validate a new object given by Control Point, especially 
+// upnp:class element field eg. object.item.musictrack
+// IMPORTANT: If objects's description is invalid due to missing elements
+// it tries to repair it by adding those missing elements.
+// -----------------------------------------------------------------------------
+//
+
+TUpnpErrorCode CUpnpElementFactory::ValidateNewObjectL( const TXmlEngElement& aNewElement, TBool aNew, TBool aLocalSharing)
+{
+    TInt i;    
+    TPtrC8 objectType = KItem();
+
+    RXmlEngNodeList<TXmlEngElement> elements;
+    CleanupClosePushL(elements);
+    aNewElement.GetChildElements( elements );
+    
+    // invalid element if the count of the objects is less than 1 (=0)
+    if ( elements.Count() != 1 )
+    {
+        User::Leave( EInvalidArgs );
+    }
+    CleanupStack::PopAndDestroy(&elements);
+    // try to find the new item from the xml
+    TXmlEngElement object;
+    UpnpDomInterface::GetElementL( aNewElement, object, KItem() );
+    if ( object.IsNull() ) 
+    {   
+        
+        // if it's not an item, it's a container
+        UpnpDomInterface::GetElementL( aNewElement, object, KContainer() );
+        if ( object.IsNull() )
+        {
+            // not even a container, leave!
+            User::Leave ( EInvalidArgs );
+        }
+        objectType.Set( KContainer() );
+    }
+                           
+    // restriced value
+    TPtrC8 restrVal = UpnpDomInterface::GetAttrValueL( object,  KRestricted );
+    
+    if (CheckRestrictedValue(restrVal))
+        {
+        User::Leave ( EBadMetadata);
+        }
+    
+    // for convenience later, take now a reference to the children of the object
+    RXmlEngNodeList<TXmlEngElement> children;
+    CleanupClosePushL(children);
+    object.GetChildElements( children );
+            
+    // an exception: we can't have <res importUri=".. element in 
+    // a new object (set by control point)
+    while ( children.HasNext() )
+    {
+        TXmlEngElement child = children.Next();
+        
+        if ( IsNotEmptyImportUriL( child ) && aNew ) 
+        {
+            User::Leave ( EBadMetadata );
+        }
+        
+        //---- check res@duration, 7.3.22 MM DIDL-Lite res@duration Format        
+        CheckDurationOfResElementL(child);
+        CheckSizeOfResElementL(child);
+                    
+        RXmlEngNodeList<TXmlEngElement> forbiddenChildren;
+        CleanupClosePushL(forbiddenChildren);
+        child.GetChildElements( forbiddenChildren );
+
+        if ( forbiddenChildren.HasNext() 
+            && child.Name() != KVendorDescriptor ) // ignore <desc></desc>
+        {
+            User::Leave ( EBadMetadata );
+        }
+        CleanupStack::PopAndDestroy(&forbiddenChildren);
+        if ( child.Name() == KDate8() )
+        {
+            if (!UpnpCdUtils::ValidateDateL(child.Value())) 
+             child.Remove();
+        }
+        
+    }
+
+    // if survived here, we have the new element of type item or container
+    // let's analyze its type
+
+    // let's inspect each of types
+    // at first, collect object type descriptions from objects xml    
+    // to a pointer array
+    RArray<TXmlEngElement> objectDescrs;
+    CleanupClosePushL( objectDescrs );
+    // store class descriptor elements in this array
+    ClassesL( object, objectDescrs, objectType );
+    
+    // validate each separately
+    
+    ValidatePropertiesL(object, objectDescrs);
+    if(aNew)
+    {
+        ValidateBigImageL(object);
+    }
+    
+    // for each type, check that 
+    // this new object has all the required fields
+        
+    for (i=0; i<objectDescrs.Count(); i++)
+    {
+        // now we have to go through all the fields of the new item
+        // first, for convenience take a pointer to <ps>(properties) element
+        
+        RXmlEngNodeList<TXmlEngElement> propElems;
+        CleanupClosePushL(propElems);
+        objectDescrs[i].GetChildElements( propElems );
+    
+
+        while ( propElems.HasNext() )
+        {
+            
+            TXmlEngElement ps = propElems.Next(); // ps stands for properties
+            if ( ps.Name() == KProperties() )
+            {
+
+                // take the properties
+                RXmlEngNodeList<TXmlEngElement> properties;
+                CleanupClosePushL(properties);
+                ps.GetChildElements( properties );
+        
+                const TDesC8& propertyType = UpnpDomInterface::GetAttrValueL( ps, KType() );
+
+                TBool elementFound(EFalse);
+
+                // check each property
+                while ( properties.HasNext() )
+                {
+                    
+                    TXmlEngElement el = properties.Next();
+
+                    elementFound = ValidateElementL (object, propertyType, el, elementFound, aNew, aLocalSharing);
+                        
+                    // Validate attribute   
+                    if ( propertyType == KAttribute() )
+                    {
+                        elementFound = EFalse;
+                        ValidateAttributeL(el, object);
+                    }
+                }
+                CleanupStack::PopAndDestroy(&properties);
+            }
+        }
+        CleanupStack::PopAndDestroy(&propElems);
+    }
+    CleanupStack::PopAndDestroy(); //objectDescrs.Close();
+    CleanupStack::PopAndDestroy(&children);
+    
+    // now the object 
+    // * has the all required fields (if some were missing, they are added)
+    // * had a proper xml structure (_not_ using UpnpDomInterface:: functions that do not care)
+    // * has for sure a mostly proper object structure 
+
+    return EUndefined;
+}
+
+TBool CUpnpElementFactory::ValidateElementL (TXmlEngElement aObject, 
+        const TDesC8& aPropertyType, TXmlEngElement aEl, TBool aElementFound, TBool aNew,
+        TBool aLocalSharing)
+    {
+        TBool elementFound = aElementFound;
+        RXmlEngNodeList<TXmlEngElement> children;
+        // Validate element
+        if ( aPropertyType == KElement() )
+        {
+            elementFound = EFalse;
+            
+            // Check if this element is requiered
+            const TDesC8& required = UpnpDomInterface::GetAttrValueL( aEl, KRequiredObject() );
+    
+            TPtrC8 elementName = UpnpDomInterface::GetAttrValueL( aEl, KName() );
+    
+            // If it's required then check it's existence
+    
+            if ( required == UpnpCD::KOne() || elementName == KRes()  ||  elementName == KAlbumArtURI() )
+            {
+                if( !KRes().Compare(elementName) ||  !KAlbumArtURI().Compare(elementName))
+                {
+                    elementFound = ETrue;
+                }
+                // get children once more, because this kind of list does not have any reset function
+                aObject.GetChildElements( children );
+    
+                elementFound = HandleChildrenL (children, aNew, aLocalSharing, elementFound, aEl);
+                    
+                // If not found, add it
+                if ( !elementFound )
+                {
+                    User::Leave(EBadMetadata);
+                }
+            } 
+        }
+        return elementFound;
+    }
+
+TBool CUpnpElementFactory::HandleChildrenL (RXmlEngNodeList<TXmlEngElement> aChildren, TBool aNew, TBool aLocalSharing,
+        TBool aElementFound, TXmlEngElement aEl)
+    {
+    TBool elementFound = aElementFound;
+    TPtrC8 elementName = UpnpDomInterface::GetAttrValueL( aEl, KName() );
+    
+    while ( aChildren.HasNext() )
+    {
+        TXmlEngElement child = aChildren.Next();
+        
+        HBufC8* nameWithNs = NameWithNsLC( child );
+
+        if ( *nameWithNs == elementName )
+        {
+            // local sharing
+            if(aNew && *nameWithNs == KRes)
+            {
+                TUriParser8 up;
+                TPtrC8 rv(child.Text());
+                if(rv.Length())
+                {
+                    User::LeaveIfError( up.Parse(child.Text()) );
+                    TPtrC8 path( up.Extract(EUriPath) );
+                    TPtrC8 scheme( up.Extract(EUriScheme) );
+
+                    if(aLocalSharing)
+                    { // local action
+                        if( scheme == UpnpHTTP::KSchemeFile8())
+                        {
+                            // The path can be: /c:/....
+                            // or /c/... - without colon.
+                            // Both situation are correct but 
+                            // in further operations we assume 
+                            // there is not any colon next to the drive letter.
+                            // Therefore, remove it if second element of path table equals ':'
+                            if(path[2] == KColon8()[0])
+                            { // There IS a colon next to the drive letter.
+                                // Here is an example uri:
+                                // file:///c:/...
+                                // As you can see the second colon must be removed
+                                HBufC8* uri = child.Text().AllocLC();
+                                TPtr8 uriPtr(uri->Des());
+                                TPtrC8 tmp(uri->Des());
+                                TInt second = 2;
+                                TInt colonPos = 0;
+                                for(TInt i = 0; i < second; i++)
+                                {
+                                    colonPos += tmp.Find(KColon8) + 1;
+                                    tmp.Set( uriPtr.Mid(colonPos) );                                                    
+                                }
+                                // remove the colon
+                                uriPtr.Replace(colonPos - 1, KColon8().Length(), KNullString8);
+                                // set TXmlEngElement value
+                                child.SetTextL(uriPtr);
+                                
+                                // clean up             
+                                CleanupStack::PopAndDestroy(uri);                                               
+                            }
+
+                            // check other  restrictions
+                            TUriParser8 up;
+                            User::LeaveIfError( up.Parse(child.Text()) );
+                            TPtrC8 path( up.Extract(EUriPath) );
+
+                            // sharing from Z: drive is forbidden
+                            // second character is a drive letter
+                            if(path[1] == KForbiddenDrivez()[0] || path[1] == KForbiddenDriveZ()[0])
+                            {
+                                User::Leave(EArgumentValue);
+                            }
+                            
+                            // cannot share from private directory
+                            if(!path.Match(KForbiddenPrivatePattern))
+                            {
+                                User::Leave(EArgumentValue);
+                            }
+                            
+                        }
+                    }
+                    else
+                    { // not local action
+                        // "file" schema is forbidden here
+                        if(scheme == UpnpHTTP::KSchemeFile8())
+                        {
+                            User::Leave(EArgumentValue);
+                        }
+                    }
+                }
+            }
+
+
+            if ( elementFound ) 
+            {
+                // multiple values for one element!
+                const TDesC8& multiple = UpnpDomInterface::GetAttrValueL( aEl, KMultiple() );
+                
+                // if it's not allowed for this element, leave!
+                if ( !multiple.Length() )
+                {
+                    User::Leave( EInvalidArgs );
+                }
+            }
+            elementFound = ETrue;
+            // mark the element required - if not res
+            if( KRes().Compare(elementName) && KAlbumArtURI().Compare(elementName))
+            {
+                child.AddNewAttributeL(KRequiredAtrName,KTrueValue8);
+            }
+            
+            // nested validation 
+            RXmlEngNodeList<TXmlEngElement> nestEls;
+            CleanupClosePushL(nestEls);
+            aEl.GetChildElements(nestEls);
+            CheckNestedElementsL(nestEls, child, aLocalSharing);
+            CleanupStack::PopAndDestroy(&nestEls);
+        }
+        CleanupStack::PopAndDestroy( nameWithNs );
+        
+    }
+
+    return elementFound;
+}
+
+
+void CUpnpElementFactory::CheckNestedElementsL(RXmlEngNodeList<TXmlEngElement> aNestEls, TXmlEngElement aChild,
+        TBool aLocalSharing)
+{
+    HBufC8* nameWithNs = NameWithNsLC( aChild );
+    while(aNestEls.HasNext())
+    {
+        TXmlEngElement nestPs = aNestEls.Next();
+    
+        // take the properties
+        RXmlEngNodeList<TXmlEngElement> nestProperties;
+        nestPs.GetChildElements( nestProperties );
+        const TDesC8& nestPropertyType = UpnpDomInterface::GetAttrValueL( nestPs, KType() );
+        // Validate attribute   
+        if ( nestPropertyType == KAttribute() )
+        {
+            while(nestProperties.HasNext())
+            {   
+                TXmlEngElement nestEl = nestProperties.Next();
+                //TBool nestElementFound;
+    
+                //nestElementFound = EFalse;
+                
+                const TDesC8& nestRequired = UpnpDomInterface::GetAttrValueL( nestEl, KRequiredObject() );
+                TPtrC8 nestElementName = UpnpDomInterface::GetAttrValueL( nestEl, KName() );
+                if ( nestRequired == UpnpCD::KOne() || nestElementName == KDlnaProfileID)
+                {
+                    TPtrC8 nestCurrentValue = UpnpDomInterface::GetAttrValueL( aChild, nestElementName );
+                    
+                    TPtrC8 nameOfAttr;
+                    TPtrC8 valOfAttr;
+                    nameOfAttr.Set( nestElementName );
+                    
+                    // Start of 'dlna:profileID' attribute case                                                 
+                    if( nameWithNs->Des() == KAlbumArtURI && nestElementName == KDlnaProfileID) // ---------------- 1 ------------
+                    {   
+                        TXmlEngAttr profId = aChild.AttributeNodeL(KProfileID, KXmlnsDlna);
+                        if(profId.NotNull())
+                        {
+                            if (profId.Value().Compare(KDefaultProfileID))
+                            {
+                                User::Leave( EBadMetadata );
+                            }
+                            // setting real name of attribute -> localName
+                            nestElementName.Set(KProfileID); // descriptor  
+                            nameOfAttr.Set( nestElementName ); // related TString
+                                                                                                                                                                                                                                                            
+                            // generating a new value of 'dlna:profileID'
+                            HBufC8* albumArtURIelemValue = UpnpDomInterface::GetElementValueL(aChild).AllocLC();
+                            TPtr8 albumArtURIelemValuePtr( albumArtURIelemValue->Des() );                                                       
+                            
+                            albumArtURIelemValuePtr.Trim(); // deletes leading and trailing whitespace characters                                                   
+                            aChild.SetValueL(albumArtURIelemValuePtr); // sets new trimmed value to albumArtURI
+                                                                                                                        
+                            CUpnpDlnaProtocolInfo* tempProtocolInfo = NULL;
+                            TInt error = iContentDirectory->GetProtocolInfoL( albumArtURIelemValuePtr, tempProtocolInfo );
+                            TPtrC8 tempPnParam;
+                            if( error >=0 )
+                            {
+                                tempPnParam.Set( tempProtocolInfo->PnParameter() );
+                                    
+                                nestCurrentValue.Set(tempPnParam); // descriptor
+                                valOfAttr.Set(tempPnParam); // related TString                                                         
+                            }
+                            else 
+                            {
+                                User::Leave( EBadMetadata );
+                            }                                                       
+                            CleanupStack::PopAndDestroy(albumArtURIelemValue);
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
+                            // if albumArtURI doesn't contain profileID -> it creates one and also related namespace
+                            // if albumArtURI contains profileID -> it modifies profileID's value
+                            aChild.SetAttributeL( nameOfAttr, valOfAttr, KXmlnsDlna(), KDlnaPrefix() );
+                                                                                    
+                            delete tempProtocolInfo;
+                            tempProtocolInfo = NULL;    
+                        }
+                        
+                    } // End of 'dlna:profileID' attribute case
+                    else                    
+                    {
+                        if ( !nestCurrentValue.Length() )  
+                        {
+                            
+                            if(nestElementName == KprotocolInfo)
+                            {
+                                if( ! aLocalSharing )
+                                {
+                                    valOfAttr.Set( KEmptyProtocolInfoVal8() );
+                                }
+                                else 
+                                {
+                                    User::Leave( EBadMetadata );
+                                }
+                            }                                                                                                   //------- 2 -----                                                                                    //------- 2 -----                  
+                            else
+                            {
+                                valOfAttr.Set( KNullDesC8() );
+                            }
+    
+                            aChild.AddNewAttributeL( nameOfAttr, valOfAttr );                                                            
+                        }
+                        else 
+                        {
+                            if(nestElementName == KprotocolInfo) 
+                            {
+                                HBufC8* protInfoValue = NULL;
+                                TRAPD(err, protInfoValue = ValidateProtocolInfoInResL( nestCurrentValue, aLocalSharing ));
+                                if(err)
+                                {
+                                    User::Leave(EBadMetadata);
+                                }
+                                CleanupStack::PushL( protInfoValue );
+                                valOfAttr.Set( *protInfoValue );
+                                aChild.SetAttributeL( nameOfAttr, valOfAttr );
+                                CleanupStack::PopAndDestroy( protInfoValue );                                                           
+                            }                                                                                                 //------- 3 -----                                                                                         //------- 3 -----
+                        }
+                    }                                                                                                                                                                                                                                                                                                                                                                                       
+                                                                        
+    
+                    // if not main tag mark the attr is required
+                    if( !IsMainObjectTagL(aChild) && nestElementName != KDlnaProfileID)
+                    {
+                       
+                        HBufC8* attrReq = HBufC8::NewLC(
+                            nestElementName.Length()
+                            +KRequiredAtrSuf().Length() );
+                        TPtr8 attrReqPtr(attrReq->Des());
+                        attrReqPtr = nestElementName;
+                        attrReqPtr.Append(KRequiredAtrSuf);
+                        aChild.AddNewAttributeL( attrReqPtr, KTrueValue8 );
+                        CleanupStack::PopAndDestroy(attrReq);
+                    }
+                }
+            }
+        }
+    
+    }
+}
+
+void CUpnpElementFactory::ValidateAttributeL(TXmlEngElement aElement, TXmlEngElement aObject)
+    {
+        
+        const TDesC8& required = UpnpDomInterface::GetAttrValueL( aElement, KRequiredObject() );
+        if ( required == UpnpCD::KOne() )
+        {
+
+            const TDesC8& elementName = UpnpDomInterface::GetAttrValueL( aElement, KName() );
+
+            const TDesC8& currentValue = UpnpDomInterface::GetAttrValueL( aObject, elementName );
+            
+            if ( !currentValue.Length() )  
+            {
+                TXmlEngAttr attr = aObject.AttributeNodeL( elementName );
+
+                if(attr.NotNull())
+                {
+                    attr.SetValueL(KNullDesC8);
+                }
+                else
+                {
+                    aObject.AddNewAttributeL( elementName, KNullDesC8 );
+                }                               
+            }
+            // if not main tag mark the attr is required
+            if(!IsMainObjectTagL(aObject))
+            {
+                HBufC8* attrReq = HBufC8::NewLC(
+                    elementName.Length()+KRequiredAtrSuf().Length() );
+                TPtr8 attrReqPtr(attrReq->Des());
+                attrReqPtr = elementName;
+                attrReqPtr.Append(KRequiredAtrSuf);
+                aObject.AddNewAttributeL( attrReqPtr, KTrueValue8 );
+                CleanupStack::PopAndDestroy(attrReq);
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidatePropertiesL()
+// Function leaves on error.
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementFactory::ValidatePropertiesL( TXmlEngElement aObj,
+                                               RArray<TXmlEngElement>& aClassList)
+{
+    // validate main object's attributes
+    ValidateMainAttributesL(aObj, aClassList);
+    
+    // validate elements
+    RXmlEngNodeList<TXmlEngElement> elements;
+    CleanupClosePushL(elements);
+    aObj.GetChildElements (elements);
+    
+    // for each element
+    while(elements.HasNext())
+    {
+        TXmlEngElement el = elements.Next();
+        ValidateElementL(el, aClassList);
+    }
+    CleanupStack::PopAndDestroy(&elements);
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidateBigImageL()
+// Function leaves on error.
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementFactory::ValidateBigImageL( TXmlEngElement aObj)
+{
+    RArray<TXmlEngElement> elms;
+    CleanupClosePushL(elms);
+    
+    if( UpnpDomInterface::GetElementListL(aObj, elms, KRes) )
+    {
+        for(TInt i = 0; i < elms.Count(); i++)
+        {
+                
+            TXmlEngAttr prInfAttr = elms[i].AttributeNodeL(KprotocolInfo());
+            if(prInfAttr.NotNull())
+            {
+                CUpnpProtocolInfoLocal* protInf = CUpnpProtocolInfoLocal::NewL(
+                        UpnpDomInterface::GetAttrValueL(elms[i], KprotocolInfo) );
+                CleanupStack::PushL(protInf);
+                                                                                   
+                /* Only support for DLNA pn-params:
+                *  1) JPEG_SM
+                *  2) MP3 
+                *  3) AAC_ISO_320
+                *  4) AVC_MP4_BL_CIF15_AAC_520
+                */
+                if( protInf->PnParameter() != KDLNA_PN_JPEG_SM &&
+                    protInf->PnParameter() != KDLNA_PN_MP3 &&
+                    protInf->PnParameter() != KDLNA_PN_AAC_ISO_320 &&
+                    protInf->PnParameter() != KDLNA_PN_AVC_MP4_BL_CIF15_AAC_520                     
+                  )
+                {           
+                    // set 4th parameter to "*"
+                    protInf->SetFourthFieldL(KAsterisk8);
+                    TPtrC8 prInfo = protInf->ProtocolInfoL();
+                    HBufC8* prInfTmp = prInfo.Alloc();
+                    CleanupStack::PushL(prInfTmp);
+                    prInfAttr.SetValueL( *prInfTmp );
+                    CleanupStack::PopAndDestroy(prInfTmp);
+                }
+                // clean up
+                CleanupStack::PopAndDestroy(protInf);
+            }
+        }
+    }
+    
+    // clean up
+    CleanupStack::PopAndDestroy(&elms);
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidateElementL()
+// Function leaves on error.
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementFactory::ValidateElementL( TXmlEngElement aElement,
+                                            RArray<TXmlEngElement>& aClassList)
+{
+    if(aElement.Name() == KRes)
+    {
+        ValidateResElL(aElement, aClassList);
+    }
+    else
+    {
+        //  get pattern 
+        HBufC8* name = UpnpCdUtils::GetElmNameWithNsL(aElement);
+        CleanupStack::PushL(name);
+        TXmlEngElement pattern = GetPatternL(*name, aClassList, KElement);
+        if(pattern.NotNull())
+        {
+            ValidateElWithPatternL(aElement, pattern); // leaves on error
+        }
+        else
+        { // attr is not supported - remove
+            aElement.Remove();
+        }
+        // clean up
+        CleanupStack::PopAndDestroy(name);
+    }
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidateMainAttributesL()
+// Function leaves on error.
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementFactory::ValidateMainAttributesL( TXmlEngElement aObj, 
+                                                   RArray<TXmlEngElement>& aClassList)
+{
+    // list of attributes
+    RXmlEngNodeList<TXmlEngAttr> attrList;
+    CleanupClosePushL(attrList);
+    aObj.GetAttributes(attrList);
+    
+    // for each attr
+    while(attrList.HasNext())
+    {
+        // get attr
+        TXmlEngAttr attr = attrList.Next();
+        
+        //  get pattern 
+        TXmlEngElement pattern = GetPatternL(attr.Name(), aClassList, KAttribute);
+        if(pattern.NotNull())
+        {
+            ValidateAttrWithPatternL(attr, pattern); // leaves on error
+        }
+        else
+        { // attr is not supported - remove
+            attr.Remove();
+        }
+    }
+    CleanupStack::PopAndDestroy(&attrList);
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidateElWithPatternL()
+// Function leaves on error.
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementFactory::ValidateResElL( TXmlEngElement aElement, 
+                                         RArray<TXmlEngElement>& aClassList)
+{
+    // list of attributes
+    RXmlEngNodeList<TXmlEngAttr> attrList;
+    CleanupClosePushL(attrList);
+    aElement.GetAttributes(attrList);
+    
+    // for each attr
+    while(attrList.HasNext())
+    {
+        // get attr
+        TXmlEngAttr attr = attrList.Next();
+        
+        //  get pattern 
+        TXmlEngElement pattern = GetPatternForResAttrL(attr.Name(), aClassList);
+        if(pattern.NotNull())
+        {
+            ValidateAttrWithPatternL(attr, pattern); // leaves on error
+        }
+        else
+        { // attr is not supported - remove
+            attr.Remove();
+        }
+    }
+    CleanupStack::PopAndDestroy(&attrList);
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidateElWithPatternL()
+// Function leaves on error.
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementFactory::ValidateElWithPatternL(   TXmlEngElement aElement, 
+                                                    TXmlEngElement aPattern )
+{
+    // is required?
+    if(IsRequiredL(aPattern) )
+    { // cannot be empty
+        if( !aElement.Value().Length() || 
+            UpnpCdUtils::IsWhiteString( aElement.Value() ) )
+        {
+            User::Leave(EBadMetadata);
+        }
+    }
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidateAttrWithPatternL()
+// Function leaves on error.
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementFactory::ValidateAttrWithPatternL( TXmlEngAttr aAttr, 
+                                                    TXmlEngElement aPattern )
+{
+    // is required?
+    if(IsRequiredL(aPattern) )
+    { // cannot be empty
+        if( !aAttr.Value().Length() || 
+            UpnpCdUtils::IsWhiteString( aAttr.Value() ) )
+        {
+            User::Leave(EBadMetadata);
+        }
+    }
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidateAttrWithPatternL()
+// Function leaves on error.
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpElementFactory::IsRequiredL(TXmlEngElement aPattern) 
+{
+    TXmlEngAttr reqAttr = aPattern.AttributeNodeL(KRequiredObject());
+    TBool ret = EFalse;
+    if( reqAttr.NotNull() &&
+        reqAttr.Value().Length() && 
+        reqAttr.Value() == KTrueValue8() )
+    {
+        ret = ETrue;
+    }
+    return ret;
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::GetPatternForElL()
+// Function leaves on error.
+// -----------------------------------------------------------------------------
+//
+TXmlEngElement CUpnpElementFactory::GetPatternL( const TDesC8& aPropertyName,
+                                                RArray<TXmlEngElement>& aClassList,
+                                                const TDesC8& aType )
+{
+    TXmlEngElement retEl;
+    
+    // for each class
+    for(TInt i = 0; i < aClassList.Count(); i++)
+    {
+        TXmlEngElement elPattEl;      
+        UpnpDomInterface::GetDirectoryElementL(aClassList[i], elPattEl, KProperties, KType, aType);
+        if(elPattEl.NotNull())
+        {   
+            UpnpDomInterface::GetDirectoryElementL(elPattEl, retEl, KObjectProperty, KObjectName, aPropertyName);
+            
+            // break if found
+            if(retEl.NotNull())
+            {
+                break;
+            }
+        }
+    }
+    
+    return retEl;
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::GetPatternForResAttrL()
+// Function leaves on error.
+// -----------------------------------------------------------------------------
+//
+TXmlEngElement CUpnpElementFactory::GetPatternForResAttrL(const TDesC8& aPropertyName,
+                                                    RArray<TXmlEngElement>& aClassList )
+{
+    TXmlEngElement retEl;
+    
+    // for each class
+    for(TInt i = 0; i < aClassList.Count(); i++)
+    {
+        TXmlEngElement resAttrPattEl;     
+        UpnpDomInterface::GetDirectoryElementL(aClassList[i], resAttrPattEl, KProperties, KType, KResAttr);
+        if(resAttrPattEl.NotNull())
+        {   
+            UpnpDomInterface::GetDirectoryElementL(resAttrPattEl, retEl, KObjectProperty, KObjectName, aPropertyName);
+            
+            // break if found
+            if(retEl.NotNull())
+            {
+                break;
+            }
+        }
+    }
+    
+    return retEl;
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::IsMainObjectTagL()
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpElementFactory::IsMainObjectTagL(TXmlEngElement aElement)
+{
+    TXmlEngElement notNeeded;
+    return UpnpDomInterface::GetElementL(aElement, notNeeded, KClassTagName);
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ActiveElementL()
+// Gets active element from XML document. An active element
+// is a first element different from <DIDL-Lite> element.
+// -----------------------------------------------------------------------------
+//
+TXmlEngElement CUpnpElementFactory::ActiveElementL( const RXmlEngDocument& aDocument )
+{
+    if( aDocument.IsNull() || aDocument.DocumentElement().IsNull() )
+    {
+        User::Leave( KErrNotFound );            
+    }
+        
+    if ( aDocument.DocumentElement().Name().CompareF( KDidlLite() ) != 0 )
+    {
+        return aDocument.DocumentElement();
+    }
+    else
+    {
+        TXmlEngElement root = aDocument.DocumentElement();
+        RXmlEngNodeList<TXmlEngElement> children;
+        CleanupClosePushL(children);
+        root.GetChildElements( children );
+        children.HasNext();
+        CleanupStack::PopAndDestroy(&children);
+        return children.Next();
+    }
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ExtractActiveElementL()
+// Extracts active element from XML document. 
+// An active element is a first element different from <DIDL-Lite> element.
+// IMPORTANT: Caller takes responsibility for returned element. 
+// -----------------------------------------------------------------------------
+//
+RXmlEngDocument CUpnpElementFactory::ExtractActiveElementL( const RXmlEngDocument& aDocument )
+{
+    TXmlEngElement active;
+    RXmlEngDocument ret;
+    ret.OpenL(iDOMImpl);
+    CleanupClosePushL(ret);
+
+    if( aDocument.IsNull() || aDocument.DocumentElement().IsNull() )
+    {
+        User::Leave( KErrNotFound );            
+    }
+        
+    if ( aDocument.DocumentElement().Name().CompareF( KDidlLite() ) != 0 )
+    {
+        active = aDocument.DocumentElement().Unlink().AsElement();
+    }
+    else
+    {
+        TXmlEngElement root = aDocument.DocumentElement();
+        RXmlEngNodeList<TXmlEngElement> children;
+        CleanupClosePushL(children);
+        root.GetChildElements( children );
+        children.HasNext();
+        active = children.Next().Unlink().AsElement();
+        CleanupStack::PopAndDestroy(&children);
+    }
+    ret.SetDocumentElement(active);
+    
+    CleanupStack::Pop(&ret);
+    
+    return ret;
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ElementsMatchL()
+// Checks if two elements are equal and have exactly the same subtrees.
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpElementFactory::ElementsMatchL( TXmlEngElement aFirst, TXmlEngElement aSecond )
+{
+    // this function checks following things:
+    // 1. element names
+    // 2. contents of the elements
+    // 3. attributes of the elements
+    // 4. child elements of the elements
+    
+    if ( aFirst.Name().Compare(aSecond.Name()) == 0 )
+    {
+        // aFirst names match. next: check namespace
+        if ( aFirst.Prefix().Compare( aSecond.Prefix()) == 0 )
+        {
+            if (!aFirst.Text().Compare(aSecond.Text()))
+            {
+                
+                // namespacess match, next: check attributes
+                RXmlEngNodeList<TXmlEngAttr> elemAttrs;
+                CleanupClosePushL(elemAttrs);
+                RXmlEngNodeList<TXmlEngAttr> currAttrs;
+                CleanupClosePushL(currAttrs);
+                
+                aFirst.GetAttributes( elemAttrs );
+                aSecond.GetAttributes( currAttrs );
+                
+                if ( elemAttrs.Count() == currAttrs.Count() )
+                {
+                    // first step in comparing attributes ready (counts match!)
+                    // next, check names and values (for each attribute)
+
+                    while( elemAttrs.HasNext() && currAttrs.HasNext() )
+                    {
+                        TXmlEngAttr elemAttr = elemAttrs.Next();
+                        TXmlEngAttr currAttr = currAttrs.Next();
+                        
+                        // compare names and values
+                        if ( elemAttr.Name().Compare( currAttr.Name() ) )
+                        {
+                            CleanupStack::PopAndDestroy(&currAttrs);
+                            CleanupStack::PopAndDestroy(&elemAttrs);
+                            return EFalse;
+                        }
+                        if ( elemAttr.Value().Compare( currAttr.Value() ) )
+                        {
+                            CleanupStack::PopAndDestroy(&currAttrs);
+                            CleanupStack::PopAndDestroy(&elemAttrs);
+                            return EFalse;
+                        }
+                        
+                    }
+                    
+                    // compare child elements (recursive function call)
+                    RXmlEngNodeList<TXmlEngElement> fChildren;
+                    CleanupClosePushL(fChildren);
+                    RXmlEngNodeList<TXmlEngElement> sChildren;
+                    CleanupClosePushL(sChildren);
+                                        
+                    aFirst.GetChildElements( fChildren );
+                    aSecond.GetChildElements( sChildren );
+                
+                    
+                    if ( fChildren.Count() == sChildren.Count() )
+                    {
+                            while ( fChildren.HasNext() && sChildren.HasNext() )
+                            {
+                            // call this function again for children
+                                TBool matching = ElementsMatchL( fChildren.Next(), sChildren.Next() );
+
+                            // if some of the elements do not match, return false!
+                                if (matching == EFalse)
+                                {
+                                    CleanupStack::PopAndDestroy(&sChildren);
+                                    CleanupStack::PopAndDestroy(&fChildren);
+                                    CleanupStack::PopAndDestroy(&currAttrs);
+                                    CleanupStack::PopAndDestroy(&elemAttrs);
+                                    return EFalse;
+                                }
+                            }
+                        // only place to return ETrue
+                        // all the checks are made; if survived here, elements match!
+                        CleanupStack::PopAndDestroy(&sChildren);
+                        CleanupStack::PopAndDestroy(&fChildren);
+                        CleanupStack::PopAndDestroy(&currAttrs);
+                        CleanupStack::PopAndDestroy(&elemAttrs);
+                        return ETrue;
+                    }
+                    CleanupStack::PopAndDestroy(&sChildren);
+                    CleanupStack::PopAndDestroy(&fChildren);
+                }
+                CleanupStack::PopAndDestroy(&currAttrs);
+                CleanupStack::PopAndDestroy(&elemAttrs);
+            }
+        }
+    }
+    
+    return EFalse;
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::CountElementsL()
+// Prepares corresponding RArray<TXmlEngElements> and calls 
+// CountElementsL( const TDesC8& aName, RArray<TXmlEngElement>& aArray )
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpElementFactory::CountElementsL( const TDesC8& aName, RArray<RXmlEngDocument>& aArray )
+{
+    TInt count(0);
+        
+    for(TInt i = 0; i < aArray.Count(); i++)
+    {            
+        if ( aArray[i].DocumentElement().NotNull() )
+        {
+            if ( aArray[i].DocumentElement().Name() == aName )
+            {
+                count++;
+            }
+        }
+            
+    }
+    return count;
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::CountElementsL()
+// Counts elements in array that have the same name.
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpElementFactory::CountElementsL( const TDesC8& aName, RArray<TXmlEngElement>& aArray )
+{
+    TInt count(0);
+    
+    for (TInt v(0); v<aArray.Count(); v++)
+    {
+        if ( aArray[v].NotNull() )
+        {
+            if ( aArray[v].Name() == aName )
+            {
+                count++;
+            }
+        }
+    }
+    
+    return count;
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::NameWithNsLC()
+// Constructs descriptor with element's name and namespace prefix separated with colon.
+// IMPORTANT: As the function name indicates, it leaves pointer to heap descriptor on 
+// cleanup stack.
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpElementFactory::NameWithNsLC(const TXmlEngElement& aElement)
+{
+    const TDesC8& localName = aElement.Name();
+    TPtrC8 prefix = aElement.Prefix();
+
+    if ( prefix.Length() > 0)
+    {
+
+        HBufC8* nameWithNs = HBufC8::NewLC( 
+            localName.Length() + 
+            UpnpString::KColon().Length() +
+            prefix.Length() );
+
+        nameWithNs->Des().Append( prefix );
+        nameWithNs->Des().Append( UpnpString::KColon() );
+        nameWithNs->Des().Append( localName );
+
+        return nameWithNs;
+    }
+    else
+    {
+        return localName.AllocLC();
+    }
+}
+
+void CUpnpElementFactory::CheckElementValidity (TXmlEngElement& aElement)
+{
+    if ( aElement.IsNull() ) 
+    {
+        // no <class> element! leave
+        User::Leave( EBadMetadata );
+    }
+    
+    // check that does the new element have all the required fields for its type
+    // and also check that it does not have whatever fields (only optional allowed)
+    
+    TPtrC8 content = aElement.Text();
+    if( !content.Length() )
+    {
+        User::Leave( EBadMetadata );
+    }
+}
+
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ClassesL()
+// Gets classes descriptions for given object.
+// -----------------------------------------------------------------------------
+//
+void CUpnpElementFactory::ClassesL( const TXmlEngElement& aObject, RArray<TXmlEngElement>& aArray, const TDesC8& aObjType )
+{
+    TInt i(0);
+    
+    // if survived here, we have the new element of type item or container
+    // let's analyze its type
+    TXmlEngElement type;
+    UpnpDomInterface::GetElementL ( aObject, type, KClass() );
+
+    CheckElementValidity (type);
+    RPointerArray<TPtrC8> objectFields;
+    
+    //--- removing white spaces ------------------      
+    HBufC8* tempBuffer = type.Text().AllocLC(); 
+    TPtr8 tmpPtr(tempBuffer->Des());
+    UpnpCdUtils::RemoveWhiteSpacesL(tmpPtr);        
+    CleanupStack::Check(tempBuffer);
+    type.SetTextL(tmpPtr);  
+    //--------------------------------------------
+    
+    UpnpString::CutToPiecesL(tmpPtr, TChar('.'), objectFields );    
+    CleanupStack::Check(tempBuffer);
+    // let's inspect each of types
+    // at first, collect object type descriptions from objects xml    
+    // to a pointer array
+    
+    TInt NumberOfObjectFields = objectFields.Count();
+    
+    for ( i=0; i < NumberOfObjectFields; i++ ) 
+    {
+        // seek for such object type
+        TXmlEngElement objectDescription;
+
+        UpnpDomInterface::GetDirectoryElementL( 
+                iDocument.DocumentElement(), 
+                objectDescription, 
+                KElement, 
+                KType, 
+                *objectFields[i] );
+        CleanupStack::Check(tempBuffer);
+        // if such type found
+        if ( objectDescription.NotNull() ) 
+        {
+            aArray.Append( objectDescription );
+        }
+        /* This case is valid for any numeric value of containerID used in CreateObject() action
+        *  We do some checking starting from 3rd string of <upnp:class> element, if the string isn't
+        *  recognizable, instead of leaving, we trims the value of <upnp:class> element, e.g:
+        *  'object.item.imageItem.abcd' -> is trimmed into -> 'object.item.imageItem'
+        *  DLNA 7.3.120.4 requirement
+        */
+        else if( i >= 2 )
+        {            
+            for( TInt j = NumberOfObjectFields - 1; j >= i; j-- )
+            {                            
+                TInt pos = tmpPtr.LocateReverse( TChar('.') );                    
+                if( pos > KErrNotFound )
+                {
+                    tmpPtr.Copy( tmpPtr.Left(pos) );                   
+                                                
+                    delete objectFields[j];
+                    objectFields.Remove(j);   
+                }                    
+            }                                                
+            type.SetTextL(tmpPtr); // changing xml                        
+            
+            break;
+        }
+        else 
+        {
+            objectFields.ResetAndDestroy();
+            objectFields.Close();
+            User::Leave( EBadMetadata );
+        }
+    }
+    CleanupStack::Check(tempBuffer);
+    /*  for each type, check that: 
+    *   1. it is referenced to its current parent type (e.g. audioItem -> item)
+    *   2. this new object has all the required fields
+    *   3. relations between object types and values of 'upnp:class':
+    *      <item> -> 'object.item' or <container> -> 'object.container'
+    */
+       
+    // we count the number of elements once again, because size of the array might change
+    NumberOfObjectFields = objectFields.Count(); 
+
+    for ( i=0; i < NumberOfObjectFields; i++ )
+    {
+        const TDesC8& field = *objectFields[i];
+
+        // 1. first, check the parent relation 
+        // first type must be "object"!
+        if ( i==0 ) 
+        {
+            /* Leave if:
+            *  1. first type isn't the 'object' OR
+            *  2. 'upnp:class' contains only 'object' type [which in matter of fact isn't instantiable]
+            */
+            if ( field != KObject() || 
+                 field == KObject() && NumberOfObjectFields == 1
+            ) 
+            {
+                // if not "item", leave!
+                objectFields.ResetAndDestroy();
+                objectFields.Close();
+                User::Leave( EBadMetadata );
+            }
+        }
+        // for later types, check the relation really
+        else 
+        {   
+            // checking relations between object types and values of 'upnp:class'
+            if( i == 1 && aObjType.Length() > 0 )
+            {
+                if(  !field.Compare(KItem) && aObjType.Compare(KItem) ||
+                     !field.Compare(KContainer) && aObjType.Compare(KContainer)
+                )
+                {          
+                    objectFields.ResetAndDestroy();
+                    objectFields.Close();                              
+                    User::Leave( EBadMetadata );
+                }
+            }            
+            //----------------------------------------    
+            const TDesC8& parent = *objectFields[i-1];
+            
+            // if we've survived to this point, this parent string
+            // should match with the one in the previous object description xml element
+            TXmlEngElement iparent;
+            UpnpDomInterface::GetElementL ( aArray[i], iparent, KIParent() );
+            CleanupStack::Check(tempBuffer);
+            TPtrC8 cont = iparent.Text();
+        
+            // now check the actual relation. leave if strings do not match!
+            if ( cont.Length() && parent != cont )
+            {
+                objectFields.ResetAndDestroy();
+                objectFields.Close();
+                User::Leave( EBadMetadata );
+            }
+        }
+    }
+    CleanupStack::PopAndDestroy(tempBuffer);
+    objectFields.ResetAndDestroy();
+    objectFields.Close();
+    return;
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::IsNotEmptyImportUriL()
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpElementFactory::IsNotEmptyImportUriL( const TXmlEngElement& aElement )
+{
+    TXmlEngAttr importUri;
+    
+    if ( aElement.Name() == KRes() )
+    {
+        importUri = aElement.AttributeNodeL( KImportUri8() );
+        
+        // remove if empty importUri: DLNA Requirement [7.3.134.5]
+        TPtrC8 val( importUri.Value() );
+        if( UpnpCdUtils::IsWhiteString( val ) )
+        {
+            importUri.Remove();
+        }
+    }
+
+    return importUri.NotNull();
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::IsClassElement()
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpElementFactory::IsClassElement( const TXmlEngElement& aElement )
+{
+    if ( aElement.Name() == KClass() )
+    {
+        return ETrue;
+    }
+    else
+    {
+        return EFalse;
+    }
+}
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::ValidateProtocolInfoInResL
+//  Allocates string, which is object type for this object. 
+// -----------------------------------------------------------------------------
+HBufC8* CUpnpElementFactory::ValidateProtocolInfoInResL( const TDesC8& aProtocolInfo, TBool aLocalSharing )
+{
+    HBufC8* result = NULL; 
+   // CUpnpDlnaProtocolInfo* protocolInfo = CUpnpDlnaProtocolInfo::NewL( (TDesC8&)aProtocolInfo );
+    CUpnpProtocolInfoLocal* protocolInfo = CUpnpProtocolInfoLocal::NewL( (TDesC8&)aProtocolInfo );
+    CleanupStack::PushL( protocolInfo ); 
+    _LIT8(KProtocolInfoHttpGet, "http-get"); 
+    protocolInfo->SetFirstFieldL( (TDesC8&)KProtocolInfoHttpGet() ); 
+    protocolInfo->SetSecondFieldL( (TDesC8&)KAsterisk8() ); 
+    TPtrC8 third = protocolInfo->ThirdField(); 
+    if(( third.Find( KSlash8()) == KErrNotFound) && 
+      ( third.Compare( KAsterisk8()) != KErrNone))
+    {
+        if( aLocalSharing)
+        {
+        User::Leave( EBadMetadata );
+        }
+        protocolInfo->SetThirdFieldL( (TDesC8&) KAsterisk8());                                  
+    }
+   // if( protocolInfo->IsDlnaInformationIncluded() ) // Check it !!!
+    {
+        protocolInfo->SetOpParameterL( UpnpDlnaProtocolInfo::B_VAL , ETrue );
+        protocolInfo->SetOpParameterL( UpnpDlnaProtocolInfo::A_VAL , EFalse ); 
+    }
+    TPtrC8 prInfo = protocolInfo->ProtocolInfoL();
+    result =  prInfo.Alloc();
+    CleanupStack::PopAndDestroy( protocolInfo ); 
+    return result; 
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::GetContentDirectoryReference
+// Function gets pointer to CUpnpContentDirectory and puts it into CUpnpElementFactory object  
+// -----------------------------------------------------------------------------
+void CUpnpElementFactory::GetContentDirectoryReference(CUpnpContentDirectory* aCD)
+{
+    iContentDirectory = aCD;
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::CheckDurationOfResElement
+// If res@duration attribute exists, the method checks whether it has valid format
+// -----------------------------------------------------------------------------
+
+void CUpnpElementFactory::CheckDurationOfResElementL(const TXmlEngElement& aElement)
+{
+    TXmlEngAttr duration;
+    
+    // if this is the 'res' element            
+    if( aElement.Name() == KRes() )
+    {
+        // and it has res@duration attribute
+        duration = aElement.AttributeNodeL( KDuration8() );                                        
+        if( duration.NotNull() )
+        {
+            TCurrentAction action = iContentDirectory->ExecutedAction();                                         
+            TPtrC8 val( duration.Value() );
+            
+            // if res@duration atrribute value is invalid [has improper format]
+            if( !UpnpCdUtils::ValidateDurationValue(val) )
+            {            
+                // remove it from 'res' element if it is CreateObject()
+                if( action == ECreateObjectAction )
+                {
+                    duration.Remove();
+                }                
+            }
+        }
+    }   
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpElementFactory::CheckSizeOfResElement
+// If res@size attribute exists, the method checks whether it has valid format
+// size should be unsigned int.
+// -----------------------------------------------------------------------------
+void CUpnpElementFactory::CheckSizeOfResElementL(
+    const TXmlEngElement& aElement )
+    {
+    TXmlEngAttr sizeAttr;
+
+    // if this is the 'res' element            
+    if ( aElement.Name() == KRes() )
+        {
+        // and it has res@size attribute
+        sizeAttr = aElement.AttributeNodeL( KSize() );
+        if ( sizeAttr.NotNull() )
+            {
+            TCurrentAction action = iContentDirectory->ExecutedAction();
+            TPtrC8 val( sizeAttr.Value() );
+
+            // if res@size atrribute value is invalid [is not an unsigned long]
+            TUint32 unsignedLong = 0;
+
+            TLex8 lexULong(val);
+            TInt error = lexULong.Val( unsignedLong, EDecimal );
+                         
+            TInt remainder = lexULong.Remainder().Length();
+
+            if ( error != KErrNone || remainder )
+                {
+                // remove it from 'res' element if it is CreateObject()
+                if ( action == ECreateObjectAction )
+                    {
+                    sizeAttr.Remove();
+                    }
+                }
+            }
+        }
+
+    }
+
+//  End of File
--- a/upnpmediaserver/contentdirectoryservice/src/upnperror.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnperror.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,90 +1,69 @@
-/** @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:  UPnP Error - this is internal class that converts 
-*                TInt to TUpnpErrorCode it helps to avoid excessive casting                    
-*
-*/
-
-
-
-// INCLUDE FILES
-#include    "upnperror.h"
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// TUpnpError::TUpnpError
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpError::TUpnpError(TInt aErrCode)
-{
-        if(aErrCode == EUpnpOk)                     iUpnpErrCode = EHttpOk;
-        else if(aErrCode == EHttpOk)                iUpnpErrCode = EHttpOk;
-        else if(aErrCode == EBadRequest)            iUpnpErrCode = EBadRequest;
-        else if(aErrCode == EInvalidAction)         iUpnpErrCode = EInvalidAction;
-        else if(aErrCode == EInvalidArgs)           iUpnpErrCode = EInvalidArgs;
-        else if(aErrCode == EInvalidVar)            iUpnpErrCode = EInvalidVar;
-        else if(aErrCode == EPreconditionFailed)    iUpnpErrCode = EPreconditionFailed;
-        else if(aErrCode == EInternalServerError)   iUpnpErrCode = EInternalServerError;
-        else if(aErrCode == EActionFailed)          iUpnpErrCode = EActionFailed;
-        else if(aErrCode == EArgumentValue)         iUpnpErrCode = EArgumentValue;
-        else if(aErrCode == EArgumentRange)         iUpnpErrCode = EArgumentRange;
-        else if(aErrCode == ENotImplemented)        iUpnpErrCode = ENotImplemented;
-        else if(aErrCode == EOutOfMemory)           iUpnpErrCode = EOutOfMemory;
-        else if(aErrCode == EHumanIntervention)     iUpnpErrCode = EHumanIntervention;
-        else if(aErrCode == EStringTooLong)         iUpnpErrCode = EStringTooLong;
-        else if(aErrCode == ENotAuthorized)         iUpnpErrCode = ENotAuthorized;
-        else if(aErrCode == ESignatureFailure)      iUpnpErrCode = ESignatureFailure;
-        else if(aErrCode == ESignatureMissing)      iUpnpErrCode = ESignatureMissing;
-        else if(aErrCode == ENotEncrypted)          iUpnpErrCode = ENotEncrypted;
-        else if(aErrCode == EInvalidSequence)       iUpnpErrCode = EInvalidSequence;
-        else if(aErrCode == EInvalidUrl)            iUpnpErrCode = EInvalidUrl;
-        else if(aErrCode == ENoSession)             iUpnpErrCode = ENoSession;
-        else if(aErrCode == ENoSuchObject)          iUpnpErrCode = ENoSuchObject;
-        else if(aErrCode == EInvalidCurrentTag)     iUpnpErrCode = EInvalidCurrentTag;
-        else if(aErrCode == EInvalidNewTag)         iUpnpErrCode = EInvalidNewTag;
-        else if(aErrCode == ERequiredTag)           iUpnpErrCode = ERequiredTag;
-        else if(aErrCode == EReadOnlyTag)           iUpnpErrCode = EReadOnlyTag;
-        else if(aErrCode == EParameterMismatch)     iUpnpErrCode = EParameterMismatch;
-        else if(aErrCode == EInvalidSearch)         iUpnpErrCode = EInvalidSearch;
-        else if(aErrCode == EInvalidSort)           iUpnpErrCode = EInvalidSort;
-        else if(aErrCode == ENoContainer)           iUpnpErrCode = ENoContainer;
-        else if(aErrCode == ERestrictedObject)      iUpnpErrCode = ERestrictedObject;
-        else if(aErrCode == EBadMetadata)           iUpnpErrCode = EBadMetadata;
-        else if(aErrCode == ERestrictedParentObject)iUpnpErrCode = ERestrictedParentObject;
-        else if(aErrCode == ENoSourceResource)      iUpnpErrCode = ENoSourceResource;
-        else if(aErrCode == ESourceAccess)          iUpnpErrCode = ESourceAccess;
-        else if(aErrCode == ETransferBusy)          iUpnpErrCode = ETransferBusy;
-        else if(aErrCode == ENoFileTransfer)        iUpnpErrCode = ENoFileTransfer;
-        else if(aErrCode == ENoDestinationResource) iUpnpErrCode = ENoDestinationResource;
-        else if(aErrCode == EDestinationAccess)     iUpnpErrCode = EDestinationAccess;
-        else if(aErrCode == ECannotProcess)         iUpnpErrCode = ECannotProcess;
-        else if(aErrCode == EUndefined)             iUpnpErrCode = EUndefined;
-        // all other
-        else iUpnpErrCode = EActionFailed;
-}
-
-// -----------------------------------------------------------------------------
-// TUpnpError::TUpnpErrorCode
-// ?implementation_description
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpError::operator TUpnpErrorCode()
-{
-    return iUpnpErrCode;
-}
-
-//  End of File
+/** @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:  UPnP Error - this is internal class that converts 
+*                TInt to TUpnpErrorCode it helps to avoid excessive casting                    
+*
+*/
+
+
+
+// INCLUDE FILES
+#include    "upnperror.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// TUpnpError::TUpnpError
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpError::TUpnpError(TInt aErrCode)
+    {
+    if(aErrCode == EUpnpOk)                     
+        {
+        iUpnpErrCode = EHttpOk;
+        }
+    else if ( ( aErrCode <= 620 && aErrCode >= 600 )
+           || ( aErrCode <= 720 && aErrCode >= 701 )
+           || aErrCode == EUpnpUndefined
+           || aErrCode == EHttpOk
+           || aErrCode == EBadRequest
+           || aErrCode == EInvalidAction
+           || aErrCode == EInvalidArgs
+           || aErrCode == EInvalidVar
+           || aErrCode == EPreconditionFailed
+           || aErrCode == EInternalServerError 
+           || aErrCode == EUndefined )
+        {
+        iUpnpErrCode = (TUpnpErrorCode)aErrCode;
+        }
+    // all other
+    else 
+        {
+        iUpnpErrCode = EActionFailed;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// TUpnpError::TUpnpErrorCode
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpError::operator TUpnpErrorCode()
+{
+    return iUpnpErrCode;
+}
+
+//  End of File
--- a/upnpmediaserver/contentdirectoryservice/src/upnplocalstorage.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnplocalstorage.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1060 +1,1060 @@
-/** @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:  Local interface
- *
-*/
-
-
-// INCLUDE FILES
-#include "upnpcontainer.h"
-#include "upnpitem.h"
-#include "upnpelement.h"
-#include "upnpattribute.h"
-#include "upnpitemlist.h"
-#include "upnpcontainerlist.h"
-#include "upnpbrowsecriteria.h"
-#include "upnplocalstorage.h"
-#include "upnpobjectbean.h"
-#include "upnpelementbean.h"
-#include "upnpattributebean.h"
-#include "upnpelementbean.h"
-#include "upnpmetadatastorage.h"
-#include "upnpcontentdirectoryglobals.h"
-#include "upnpresourcesbean.h"
-#include "upnpcdutils.h"
-#include "upnpstatehandler.h"
-#include "upnpstring.h"
-#include "upnpcontentdirectory.h"
-#include "upnpautodestroyobjectlist.h"
-#include "upnpautodestroyobject.h"
-#include <uriutils.h>
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::CUpnpLocalStorage
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CUpnpLocalStorage::CUpnpLocalStorage( CUpnpMetadataStorage* aMetadataStorage )
-    {
-    iMetadataStorage = aMetadataStorage; 
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::ConstructL()
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpLocalStorage* CUpnpLocalStorage::NewLC(
-        CUpnpMetadataStorage* aMetadataStorage )
-    {
-    CUpnpLocalStorage* self = new ( ELeave ) CUpnpLocalStorage( aMetadataStorage );
-    
-    CleanupStack::PushL( self );
-    self->ConstructL();
-
-    return self;
-    }
-
-CUpnpLocalStorage* CUpnpLocalStorage::NewL(
-        CUpnpMetadataStorage* aMetadataStorage )
-    {
-    CUpnpLocalStorage* self = CUpnpLocalStorage::NewLC( aMetadataStorage );
-    
-    CleanupStack::Pop();
-
-    return self;
-    }
-
-void CUpnpLocalStorage::SetStateHandler( CUpnpStateHandler* aStateHandler )
-    {
-    iStateHandler = aStateHandler;
-    }
-
-// Destructor
-CUpnpLocalStorage::~CUpnpLocalStorage()
-    {
-
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::ShareObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::ShareObjectL( CUpnpObject* aObj )
-    {
-    TLex8 lexer( aObj->ParentId() );
-    TPtrC8 parentId = aObj->ParentId();
-    TInt containerId;
-    User::LeaveIfError( lexer.Val( containerId ) );
-    // check parent
-    ValidateContainerL( containerId );
-
-    // start transaction
-    iMetadataStorage->BeginTransactionL();
-
-    TRAPD(err, DoShareObjectL( containerId, aObj ) );
-    if ( err )
-        { // rollback if error
-        iMetadataStorage->RollbackTransactionL();    
-        User::Leave( err );
-        }
-    iMetadataStorage->CommitTransactionL();
-    
-    // eventing
-    if (iStateHandler)
-        {
-        iStateHandler->IncreaseSystemUpdateIdL();     
-        iStateHandler->IncreaseContainerUpdateIdL( parentId );   
-        }
-    
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::ShareReferenceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::ShareReferenceL( CUpnpItem* aItem )
-    {	    
-	// check whether container exists and is not restricted
-    TLex8 lexer( aItem->ParentId() );
-    TPtrC8 parentId = aItem->ParentId();
-    TInt containerId;
-    User::LeaveIfError( lexer.Val( containerId ) );
-    
-    ValidateContainerL( containerId );    
-   
-    // if everything is OK -> start transaction
-    iMetadataStorage->BeginTransactionL();
-        
-    TRAPD(err, DoShareReferenceL( containerId, aItem ) );
-    if ( err )
-        { // rollback if error
-        iMetadataStorage->RollbackTransactionL();    
-        User::Leave( err );
-        }
-    iMetadataStorage->CommitTransactionL();
-    
-    // eventing
-    if (iStateHandler)
-        {
-        iStateHandler->IncreaseSystemUpdateIdL();                
-        iStateHandler->IncreaseContainerUpdateIdL( parentId );   
-        }               
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::ShareReferenceListL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::ShareReferenceListL( CUpnpItemList* aItemList, 
-											TInt* aExecutionStatus )
-	{
-	//----- firstly - validate all containers upon which references are to be created.
-	for ( TInt i = 0; i < aItemList->ObjectCount(); i++ )
-	    {	    
-	    TLex8 lex((*aItemList)[i]->ParentId());
-	    TInt containerId;
-	    User::LeaveIfError( lex.Val(containerId) );
-	    
-	    ValidateContainerL(containerId);	    
-	    }
-	
-	//----- if containers are OK, do the following ...
-	
-	// varaible used to do the rest of eventing
-	TInt itemCommited=0; 
-	    
-    // start transaction
-    iMetadataStorage->BeginTransactionL();
-    
-    // reset status
-    *aExecutionStatus = 0;
-
-    // for each item in the list ...
-    for ( TInt i = 0; i < aItemList->ObjectCount(); i++ )
-        {               
-        // get parentId field value [upon which 'reference item' will be created]
-        TLex8 lexer((*aItemList)[i]->ParentId());
-        TInt parentId = -1;
-        User::LeaveIfError( lexer.Val(parentId) );            
-                     
-        // commit every KCommitEveryNum inserts 
-        if ( !(i%KCommitEveryNum) ) 
-            {
-            // ignore if i == 0;
-            if ( i )
-                {
-                itemCommited=0;
-                // commit last transaction
-                iMetadataStorage->CommitTransactionL();
-               
-                // success - update status
-                *aExecutionStatus = i;
-                if ( iStateHandler )
-                    {                                          
-                    for ( TInt j = 0; j < KCommitEveryNum; j++ )
-                        {
-                        iStateHandler->IncreaseSystemUpdateIdL();    
-                        iStateHandler->IncreaseContainerUpdateIdL( ( (*aItemList)[j]->ParentId() ) );    
-                        }                       
-                    }
-                   // begin new transaction
-                   iMetadataStorage->BeginTransactionL();                   
-                }
-            }
-        
-        // insert object
-        CUpnpObject* object = ( *aItemList )[i];
-        CUpnpItem* item = dynamic_cast<CUpnpItem*>( object );
-        
-        TRAPD( err, DoShareReferenceL( parentId, item ) );
-        if ( err )
-            { // rollback if error
-            iMetadataStorage->RollbackTransactionL();    
-            User::Leave(err);
-            }
-        itemCommited++;
-        }
-    
-        // commit
-        iMetadataStorage->CommitTransactionL();
-        
-        // success - update status
-        *aExecutionStatus = aItemList->ObjectCount();
-       
-        //eventing
-        if ( iStateHandler )
-            {
-            // do the rest of eventing if number of items were greater than KCommitEveryNum
-            for ( TInt j = 0; j < itemCommited; j++ ) 
-                {
-                iStateHandler->IncreaseSystemUpdateIdL();     
-                iStateHandler->IncreaseContainerUpdateIdL( ( ( *aItemList )[j]->ParentId() ) );    
-                }            
-            }			
-	}
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::UnshareItemL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::UnshareItemL( TInt aId )
-    {
-    // check id
-    ValidateItemL( aId );
-    HBufC8* containerId = HBufC8::NewLC( KMaxIntegerLen );
-    TInt containerIdInt = iMetadataStorage->GetParentIdL( aId );
-    if ( containerIdInt == KErrGeneral )
-        {
-        User::Leave( KErrNotFound );
-        }
-    
-    containerId->Des().Num( containerIdInt );
-        
-    if (aId <= KDownloadContId)
-        {
-        User::Leave( KErrArgument );
-        }
-    RArray<TInt> refList;
-    CleanupClosePushL(refList);
-    if ( iMetadataStorage->DeleteObjectL( aId, refList, ETrue, ETrue ) == ENoSuchObject )
-        {
-        User::Leave( KErrNotFound );
-        }
-
-    // eventing
-    if ( iStateHandler )
-        {
-        TBuf8<KMaxIntegerLen> parentRefID;
-        iStateHandler->IncreaseSystemUpdateIdL();     
-        iStateHandler->IncreaseContainerUpdateIdL( *containerId );
-        for (TInt i(0);i<refList.Count();i++)
-            {
-            iStateHandler->IncreaseSystemUpdateIdL();                
-            parentRefID.Num( refList[i] );     
-            iStateHandler->IncreaseContainerUpdateIdL( parentRefID );
-            }
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy( &refList );
-    CleanupStack::PopAndDestroy( containerId );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::UnshareContainerL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::UnshareContainerL( TInt aId )
-    {
-    // check id
-    ValidateContainerL( aId );
-    HBufC8* containerId = HBufC8::NewLC( KMaxIntegerLen );
-    containerId->Des().Num(iMetadataStorage->GetParentIdL( aId ) );
-        
-    if ( aId <= KDownloadContId )
-        {
-        User::Leave( KErrArgument );
-        }
-    RArray<TInt> refList;
-    CleanupClosePushL(refList);    
-    if ( iMetadataStorage->DeleteObjectL( aId,refList, ETrue, ETrue ) == ENoSuchObject )
-        {
-        User::Leave( KErrNotFound );
-        }
-    
-    // eventing
-    if ( iStateHandler )
-        {            
-        iStateHandler->IncreaseSystemUpdateIdL();     
-        iStateHandler->IncreaseContainerUpdateIdL( *containerId );
-        TBuf8<KMaxIntegerLen> parentRefID;    
-        for (TInt i(0);i<refList.Count();i++)
-            {
-            parentRefID.Num( refList[i] );                 
-            if ( containerId->Compare( parentRefID ) )
-                {
-                iStateHandler->IncreaseSystemUpdateIdL();                           
-                iStateHandler->IncreaseContainerUpdateIdL( parentRefID );   
-                }            
-            }
-        refList.Reset();
-        }
-    CleanupStack::PopAndDestroy( &refList );
-    CleanupStack::PopAndDestroy( containerId );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::GetSharedItemL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpItem* CUpnpLocalStorage::GetSharedItemL( TInt aItemId )
-    {
-    // new item
-    CUpnpItem* item = CUpnpItem::NewL();
-    CleanupStack::PushL( item );
-    
-    // get object
-    GetObjectL( aItemId, item );
-    
-    // clean up
-    CleanupStack::Pop( item );
-    
-    return item;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::ShareItemListL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::ShareItemListL(CUpnpItemList* aItemList,
-        TInt* aExecutionStatus )
-    {
-    TInt itemCommited=0;
-    // check parent    
-    TLex8 lexer((*aItemList)[0]->ParentId());
-    TInt parentId;
-    User::LeaveIfError( lexer.Val(parentId) );
-    ValidateContainerL(parentId);
-    
-      // start transaction
-       iMetadataStorage->BeginTransactionL();
-       // reset status
-       *aExecutionStatus = 0;
-
-    // for each item
-    for ( TInt i = 0; i < aItemList->ObjectCount(); i++ )
-        {
-        // commit every KCommitEveryNum inserts
-        if ( !(i%KCommitEveryNum) ) 
-            {
-            // ignore if i == 0;
-            if ( i )
-                {
-                itemCommited=0;
-                // commit last transaction
-                iMetadataStorage->CommitTransactionL();
-               
-                // success - update status
-                *aExecutionStatus = i;
-                if ( iStateHandler )
-                    {                                          
-                    for ( TInt j =0; j<KCommitEveryNum; j++ )
-                        {
-                        iStateHandler->IncreaseSystemUpdateIdL();    
-                        iStateHandler->IncreaseContainerUpdateIdL( ( (*aItemList)[0]->ParentId() ) );    
-                        }                       
-                    }
-                   // begin new transaction
-                   iMetadataStorage->BeginTransactionL();                   
-                }
-            }
-        
-        // insert object
-        TRAPD( err, DoShareObjectL( parentId, ( *aItemList )[i]) );
-        if ( err )
-            { // rollback if error
-            iMetadataStorage->RollbackTransactionL();    
-            User::Leave(err);
-            }
-        itemCommited++;
-        }
-    
-        // commit
-        iMetadataStorage->CommitTransactionL();
-        // success - update status
-        *aExecutionStatus = aItemList->ObjectCount();
-       
-        //eventing
-        if ( iStateHandler )
-            {
-            for ( TInt j =0; j<itemCommited; j++ )
-                {
-                iStateHandler->IncreaseSystemUpdateIdL();     
-                iStateHandler->IncreaseContainerUpdateIdL( ( ( *aItemList )[0]->ParentId() ) );    
-                }            
-            }                       
-
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::ValidateContainerL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::ValidateContainerL( TInt aContainerId )
-    {
-    if ( !iMetadataStorage->IsContainerL( aContainerId ) )
-        {
-        User::Leave( KErrNotFound );
-        }
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::ValidateItemL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::ValidateItemL( TInt aItemId )
-    {
-    if ( iMetadataStorage->IsContainerL( aItemId ) )
-        {
-        User::Leave( KErrNotFound );
-        }
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::UnshareItemListL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::UnshareItemListL( RArray<TInt>& aObjList, 
-                                          TInt* aExecutionStatus )
-    {
-    // list of resources
-    RArray<TInt> refList;
-    RArray<TInt> resList;
-    RArray<TInt> objCommitedList;
-    CleanupClosePushL(objCommitedList);
-    CleanupClosePushL(resList);
-    CleanupClosePushL(refList);
-    TInt parentId(0);
-    // start transaction
-    iMetadataStorage->BeginTransactionL();
-    // reset status
-    *aExecutionStatus = 0;
-
-    // for each item
-    for (TInt i = 0; i < aObjList.Count(); i++ )
-        {
-        parentId = iMetadataStorage->GetParentIdL( aObjList[i] );
-        if ( parentId>=0 )
-            {
-            objCommitedList.AppendL(parentId);
-            // commit every KCommitEveryNum inserts
-            if( !( i%KCommitEveryNum ) ) 
-                {
-                // ignore if i == 0;
-                if ( i )
-                    {                
-                    // commit last transaction
-                    iMetadataStorage->CommitTransactionL();
-
-                    // everything went OK, delete files
-                    iMetadataStorage->DeleteResourcesL(resList);
-                    resList.Reset();
-                   
-                    // success - update status
-                    *aExecutionStatus = i;
-                   
-                    // eventing
-                    if (iStateHandler)
-                        {                   
-                        for (TInt j =0;j<objCommitedList.Count();j++)
-                            {
-                            iStateHandler->IncreaseSystemUpdateIdL();
-                             TBuf8<KMaxIntegerLen> containerId;                       
-                            containerId.Num( objCommitedList[j] );
-                            iStateHandler->IncreaseContainerUpdateIdL( containerId );                    
-                            }
-                        objCommitedList.Reset();
-                        TBuf8<KMaxIntegerLen> parentRefID;    
-                           for ( TInt i(0); i<refList.Count(); i++ )
-                            {   
-                            iStateHandler->IncreaseSystemUpdateIdL();                
-                            parentRefID.Num( refList[i] );     
-                            iStateHandler->IncreaseContainerUpdateIdL( parentRefID );
-                            }
-                        refList.Reset();
-                        }                                    
-                
-                    // begin new transaction
-                    iMetadataStorage->BeginTransactionL();
-                    }
-                }
-        
-        // insert object
-        TRAPD( err, iMetadataStorage->DoDeleteObjectL( aObjList[i],refList, resList,
-                                                       ETrue, ETrue) );
-        if ( err )
-            { // rollback if error
-            iMetadataStorage->RollbackTransactionL();    
-            User::Leave(err);
-                }
-            }
-        }
-
-    // commit
-    iMetadataStorage->CommitTransactionL();
-
-    // everything went OK, delete files
-    iMetadataStorage->DeleteResourcesL( resList );
-
-    // success - update status
-    *aExecutionStatus = objCommitedList.Count();
-
-    // eventing       
-    if ( iStateHandler )
-       {
-       for ( TInt j =0; j<objCommitedList.Count(); j++ )
-            {
-            if ( objCommitedList[j]>=0 )
-                {                    
-                TBuf8<KMaxIntegerLen> containerId;      
-                containerId.Num(objCommitedList[j]);
-                iStateHandler->IncreaseSystemUpdateIdL();
-                iStateHandler->IncreaseContainerUpdateIdL( containerId );               
-                }  
-            }   
-        objCommitedList.Reset(); 
-        TBuf8<KMaxIntegerLen> parentRefID;    
-        for ( TInt i(0); i<refList.Count(); i++ )
-            {
-            iStateHandler->IncreaseSystemUpdateIdL();                
-            parentRefID.Num( refList[i] );     
-            iStateHandler->IncreaseContainerUpdateIdL( parentRefID );
-            }
-        refList.Reset();
-       }
-                                                               
-    // clean up
-    CleanupStack::PopAndDestroy( &refList );
-    CleanupStack::PopAndDestroy( &resList );
-    CleanupStack::PopAndDestroy( &objCommitedList );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::GetItemListL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::GetItemListL(TInt aContainerId,
-        CUpnpBrowseCriteria* aBrowseCriteria, TInt* aTotalMatches,
-        CUpnpItemList* aItemList )
-    {
-    // filter
-    TBool all = aBrowseCriteria->Filter().Length();
-
-    // get children ids
-    RArray<TInt> items;
-    CleanupClosePushL( items );
-    if ( iMetadataStorage->GetItemListL( aContainerId, items ) == ENoSuchObject || !items.Count() )
-        {
-        User::Leave(KErrNotFound);
-        }
-
-    // total matches
-    *aTotalMatches = items.Count();
-
-    // add wanted children
-    for ( TInt i = aBrowseCriteria->StartingIndex();
-          i < *aTotalMatches  && 
-          i < aBrowseCriteria->StartingIndex() 
-          + aBrowseCriteria->RequestedCount() ; 
-          i++ 
-        )
-        {
-        // new item
-        CUpnpItem* item = CUpnpItem::NewL();
-        CleanupStack::PushL(item);
-
-        // get object
-        GetObjectL(items[i], item, all);
-        aItemList->AppendObjectL(*item);
-
-        // pop item
-        CleanupStack::Pop(item);
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy(&items);
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::GetContainerListL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::GetContainerListL(TInt aContainerId,
-        CUpnpBrowseCriteria* aBrowseCriteria, TInt* aTotalMatches,
-        CUpnpContainerList* aList )
-    {
-    // filter
-    TBool all = aBrowseCriteria->Filter().Length();
-
-    // get children ids
-    RArray<TInt> contrs;
-    CleanupClosePushL( contrs );
-    if( iMetadataStorage->GetContainerListL( aContainerId, contrs ) == ENoSuchObject )
-        {
-        User::Leave( KErrNotFound );
-        }
-
-    // total matches
-    *aTotalMatches = contrs.Count();
-
-    // add wanted children
-    for ( TInt i = aBrowseCriteria->StartingIndex();
-          i < *aTotalMatches  && 
-          i < aBrowseCriteria->StartingIndex() 
-          + aBrowseCriteria->RequestedCount() ; 
-          i++ 
-        )
-        {
-        // new item
-        CUpnpContainer* contr = CUpnpContainer::NewL();
-        CleanupStack::PushL( contr );
-
-        // get object
-        GetObjectL( contrs[i], contr, all );
-        aList->AppendObjectL( *contr );
-
-        // pop item
-        CleanupStack::Pop( contr );
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy( &contrs );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::GetSingleContainerL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpContainer* CUpnpLocalStorage::GetSingleContainerL(TInt aContainerId )
-    {
-    // new item
-    CUpnpContainer* cont = CUpnpContainer::NewL();
-    CleanupStack::PushL(cont);
-
-    // get object
-    GetObjectL( aContainerId, cont );
-
-    // clean up
-    CleanupStack::Pop( cont );
-
-    return cont;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::CreateObjectBeanLC
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpObjectBean* CUpnpLocalStorage::CreateObjectBeanLC(CUpnpObject* aItem )
-    {
-    CUpnpObjectBean* objBn = CUpnpObjectBean::NewLC();
-
-    // restricted
-    objBn->SetObjRestricted( aItem->Restricted() );
-
-    // searchable
-    objBn->SetObjSearchable( ETrue );
-
-    // class
-    objBn->SetObjClassL( aItem->ObjectClass() );
-
-    // title
-    objBn->SetObjTitleL( aItem->Title() );
-
-    return objBn;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::CreateElementBeanLC
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpElementBean* CUpnpLocalStorage::CreateElementBeanLC(CUpnpElement& aElement )
-    {
-    CUpnpElementBean* elmBn = CUpnpElementBean::NewLC();
-
-    // name
-    elmBn->SetElmNameL( aElement.Name() );
-
-    // value
-    elmBn->SetElmValueL( aElement.Value() );
-
-    // is required
-    elmBn->SetElmIsRequired( aElement.IsRequired() );
-
-    TBool hasAttribute = aElement.GetAttributes().Count() > 0;
-    elmBn->SetElmHasAttribute( hasAttribute );
-    return elmBn;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::CreateAttributeBeanLC
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpAttributeBean* CUpnpLocalStorage::CreateAttributeBeanLC(
-        CUpnpAttribute& aAttr )
-    {
-    CUpnpAttributeBean* atrBn = CUpnpAttributeBean::NewLC();
-    
-    // name
-    atrBn->SetAtrNameL( aAttr.Name() );
-    
-    // value
-    atrBn->SetAtrValueL( aAttr.Value() );
-    
-    // set required
-    if ( aAttr.Name() == KprotocolInfo )
-        {
-        atrBn->SetAtrIsRequired( ETrue );
-        }
-    
-    return atrBn;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::DoShareItemL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::DoShareObjectL(TInt aContainer, CUpnpObject* aObject )
-    {
-
-    // object table
-    CUpnpObjectBean* objBn = CreateObjectBeanLC( aObject );
-    TInt objId = iMetadataStorage->InsertIntoObjectTableL( aContainer, objBn );
-    CleanupStack::PopAndDestroy( objBn );
-
-    // set id
-    HBufC8* id = HBufC8::NewLC( KMaxIntegerLen );
-    id->Des().Num( objId );    
-    aObject->SetIdL( *id );
-    CleanupStack::PopAndDestroy( id ); 
-
-    // add resources
-    HandleResourcesL( aObject );
-
-    // elements
-    const RUPnPElementsArray& elms = aObject->GetElements ( );
-    TInt elmId = iMetadataStorage->GetNextKeyL(KElementTableName8,elms.Count());
-    for (TInt i = 0; i < elms.Count ( ); i++ )
-        {
-        CUpnpElementBean* elm = CreateElementBeanLC( *elms[i] );
-        iMetadataStorage->InsertIntoElementTableL( objId, elm, elmId );
-        CleanupStack::PopAndDestroy( elm );
-
-        // attributes
-        const RUPnPAttributesArray& attrs = elms[i]->GetAttributes ( );
-        TInt atrId = iMetadataStorage->GetNextKeyL( KAttributeTableName8, attrs.Count() );
-        for( TInt j = 0; j < attrs.Count(); j++ )
-            {
-            CUpnpAttributeBean* attr = CreateAttributeBeanLC (*attrs[j] );
-            iMetadataStorage->InsertIntoAttributeTableL(elmId, attr, objId,atrId);
-            atrId++;
-            CleanupStack::PopAndDestroy (attr );
-            }
-        elmId++;
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::DoShareReferenceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::DoShareReferenceL( TInt aContainerId, CUpnpItem* aRefItem ) 
-	{    			
-    // prepare for a while main object to get some data from it
-    CUpnpItem* mainObj = CUpnpItem::NewL();
-    CleanupStack::PushL( mainObj );
-    
-	TLex8 lexer( aRefItem->RefId() );
-	TInt mainObjId;
-	User::LeaveIfError(lexer.Val(mainObjId));
-
-	// try to get 'real object', not e.g reference to reference
-	mainObjId = ReferedObjectIdL( mainObjId );
-	
-	// set new refID, pointing onto real object
-	TBuf8<KMaxIntegerLen> newRefIdBuf;
-    newRefIdBuf.Num( mainObjId );               
-    aRefItem->SetRefIdL( newRefIdBuf );
-	// get all data from main object
-    GetObjectL( mainObjId, mainObj ); 
-    
-    // setting: title and class in reference object, basing on info from main object 
-    aRefItem->SetTitleL( mainObj->Title() );
-    aRefItem->SetObjectClassL( mainObj->ObjectClass() );
-    
-    CleanupStack::PopAndDestroy( mainObj );
-                                 
-    // setting 'restricted' field
-    aRefItem->SetRestricted(EFalse);    
-                  
-    // creating new 'object bean' basing on 'reference object' 
-    CUpnpObjectBean* refBn = CreateObjectBeanLC( aRefItem );        
-    refBn->SetObjRefId( mainObjId ); 
-    refBn->SetObjParentId( aContainerId );
-    
-    // inserting newly created reference object onto 'object table'
-    TInt id = iMetadataStorage->InsertIntoObjectTableL( aContainerId, refBn );
-    CleanupStack::PopAndDestroy( refBn );                   
-    
-    // setting new id in created reference object     
-	TBuf8<KMaxIntegerLen> idBuf;
-    idBuf.Num( id );               
-    aRefItem->SetIdL( idBuf );
-    }	    
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::HandleResourcesL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::HandleResourcesL(CUpnpObject* aItem )
-    {
-    //
-    const RUPnPElementsArray& elms = aItem->GetElements();
-    for ( TInt i = 0; i < elms.Count(); i++ )
-        {
-        if ( elms[i]->Name() == KRes )
-            {
-
-            // get file name
-            TParse fp;
-            fp.Set( elms[i]->FilePath(), 0, 0 );
-
-            TPtrC8 itemId = aItem->Id();
-            HBufC8* contUri = UpnpCdUtils::BuildContentUriL(
-                    iMetadataStorage->GetNextKeyL( KImportUriId8 ), fp.Ext(), 
-                    itemId );
-            CleanupStack::PushL(contUri);
-
-            // add resource to the database
-            CUpnpResourcesBean* resBn = CUpnpResourcesBean::NewLC();
-            resBn->SetId( UpnpCdUtils::ResIdFromUriL( *contUri ) );
-            resBn->SetPathL( elms[i]->FilePath() );
-            resBn->SetIsReadonly( ETrue );
-            resBn->SetIsThumbnail( EFalse );
-
-            TInt objectId;
-            TLex8 lexer( aItem->Id() );
-            User::LeaveIfError( lexer.Val( objectId ) );
-            iMetadataStorage->AddResourceL( resBn, objectId );
-
-            // update object
-            HBufC8* uri = ValAsUriL( *contUri );
-            CleanupStack::PushL( uri );
-            elms[i]->SetValueL( *uri );
-            CleanupStack::PopAndDestroy( uri );
-            CleanupStack::PopAndDestroy( resBn );
-            CleanupStack::PopAndDestroy( contUri );
-            }
-
-        }
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::GetObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::GetObjectL( TInt aObjId, CUpnpObject* aObj, TBool aAll )
-    {
-    // get view
-    RDbView view = iMetadataStorage->GetObjViewL( aObjId );
-    CleanupClosePushL( view );
-    
-    if ( view.FirstL() )
-        {
-        // get row
-        view.GetL(); 
-
-        // create bean
-        CUpnpObjectBean* objBn = CUpnpObjectBean::NewLC( view );
-        
-        // add values
-        objBn->CopyToUpnpObjectL( aObj );
-        
-        if ( aAll )
-            { // add elements
-            AddElementsL( aObjId, aObj );
-            }
-        
-        CleanupStack::PopAndDestroy( objBn );
-        } 
-    else
-        { // no such object
-        User::Leave( KErrNotFound );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::AddElementsL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpLocalStorage::AddElementsL( TInt aObjectID, CUpnpObject* aObj )
-    {
-    RDbView view = iMetadataStorage->GetElementsViewL( aObjectID, ETrue );
-    CleanupClosePushL( view );
-    // Iterate through elements
-    while( view.NextL() )
-        {
-        view.GetL();
-        CUpnpElementBean* elBean = CUpnpElementBean::NewLC( view );
-        
-        // add new element
-        CUpnpElement* elm = elBean->AttachElmL( aObj );
-        
-        // add attributes
-        AddAttributesL( elBean->ElmId(), elm );
-        
-        if( elBean->ElmName() == KRes && 
-            elBean->ElmValue().Length() ) // ignore if empty res
-            { // add file path
-            CUpnpResourcesBean* resBn =     
-                iMetadataStorage->GetResourceL(
-                    UpnpCdUtils::ResIdFromUriL( elBean->ElmValue() ) );
-            CleanupStack::PushL(resBn);
-            
-            // set file path
-            elm->SetFilePathL( resBn->Path() );
-            
-            CleanupStack::PopAndDestroy( resBn );
-            }
-        
-        // clean up
-        CleanupStack::PopAndDestroy( elBean );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpElementBean::ValAsUriL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpLocalStorage::ValAsUriL( const TDesC8& aElmValue ) const 
-    {    
-    // uris have to be properly escaped
-    HBufC8* uriDes = NULL;
-    HBufC* tmp = UpnpCdUtils::Des8ToDesLC( aElmValue );        
-    TUriParser uripar;
-    uripar.Parse( *tmp );
-    CUri8* uri = uri = UriUtils::ConvertToInternetFormL( uripar );             
-    CleanupStack::PopAndDestroy( tmp );          
-    CleanupStack::PushL(uri); 
-    if ( uri->Uri().UriDes().Length() )
-        {                
-        uriDes = UpnpString::StringReplaceL( uri->Uri().UriDes(), KHash8, KHashASCII8 );                                                       
-        }
-    else
-        {
-        uriDes = uri->Uri().UriDes().AllocL();    
-        }    
-    CleanupStack::PopAndDestroy( uri );                
-    return uriDes;        
-    }
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::AddAttributesL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//    
-void CUpnpLocalStorage::AddAttributesL( TInt aElmId, CUpnpElement* aElm )
-    {
-    RDbView view = iMetadataStorage->GetAttributesViewL( aElmId, ETrue );
-    CleanupClosePushL(view);
-
-    // Iterate through attributes
-    while ( view.NextL() )
-        {
-        view.GetL();
-        CUpnpAttributeBean* atr = CUpnpAttributeBean::NewLC( view );
-        atr->AttachAttrL( aElm );
-        CleanupStack::PopAndDestroy( atr );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpLocalStorage::ReferedObjectIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpLocalStorage::ReferedObjectIdL(TInt aObjectId)
-{
-    TInt ret = KErrNotFound;
-    
-    TInt refId = iMetadataStorage->ReferedObjectIdL(aObjectId);
-    
-    if( refId != KErrNotFound )
-    {
-        ret = ReferedObjectIdL( refId );
-    }
-    else
-    {
-        ret = aObjectId;
-    }
-
-    return ret;
-}
-
-//  End of File  
-
+/** @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:  Local interface
+ *
+*/
+
+
+// INCLUDE FILES
+#include "upnpcontainer.h"
+#include "upnpitem.h"
+#include "upnpelement.h"
+#include "upnpattribute.h"
+#include "upnpitemlist.h"
+#include "upnpcontainerlist.h"
+#include "upnpbrowsecriteria.h"
+#include "upnplocalstorage.h"
+#include "upnpobjectbean.h"
+#include "upnpelementbean.h"
+#include "upnpattributebean.h"
+#include "upnpelementbean.h"
+#include "upnpmetadatastorage.h"
+#include "upnpcontentdirectoryglobals.h"
+#include "upnpresourcesbean.h"
+#include "upnpcdutils.h"
+#include "upnpstatehandler.h"
+#include "upnpstring.h"
+#include "upnpcontentdirectory.h"
+#include "upnpautodestroyobjectlist.h"
+#include "upnpautodestroyobject.h"
+#include <uriutils.h>
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::CUpnpLocalStorage
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUpnpLocalStorage::CUpnpLocalStorage( CUpnpMetadataStorage* aMetadataStorage )
+    {
+    iMetadataStorage = aMetadataStorage; 
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::ConstructL()
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpLocalStorage* CUpnpLocalStorage::NewLC(
+        CUpnpMetadataStorage* aMetadataStorage )
+    {
+    CUpnpLocalStorage* self = new ( ELeave ) CUpnpLocalStorage( aMetadataStorage );
+    
+    CleanupStack::PushL( self );
+    self->ConstructL();
+
+    return self;
+    }
+
+CUpnpLocalStorage* CUpnpLocalStorage::NewL(
+        CUpnpMetadataStorage* aMetadataStorage )
+    {
+    CUpnpLocalStorage* self = CUpnpLocalStorage::NewLC( aMetadataStorage );
+    
+    CleanupStack::Pop();
+
+    return self;
+    }
+
+void CUpnpLocalStorage::SetStateHandler( CUpnpStateHandler* aStateHandler )
+    {
+    iStateHandler = aStateHandler;
+    }
+
+// Destructor
+CUpnpLocalStorage::~CUpnpLocalStorage()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::ShareObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::ShareObjectL( CUpnpObject* aObj )
+    {
+    TLex8 lexer( aObj->ParentId() );
+    TPtrC8 parentId = aObj->ParentId();
+    TInt containerId;
+    User::LeaveIfError( lexer.Val( containerId ) );
+    // check parent
+    ValidateContainerL( containerId );
+
+    // start transaction
+    iMetadataStorage->BeginTransactionL();
+
+    TRAPD(err, DoShareObjectL( containerId, aObj ) );
+    if ( err )
+        { // rollback if error
+        iMetadataStorage->RollbackTransactionL();    
+        User::Leave( err );
+        }
+    iMetadataStorage->CommitTransactionL();
+    
+    // eventing
+    if (iStateHandler)
+        {
+        iStateHandler->IncreaseSystemUpdateIdL();     
+        iStateHandler->IncreaseContainerUpdateIdL( parentId );   
+        }
+    
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::ShareReferenceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::ShareReferenceL( CUpnpItem* aItem )
+    {	    
+	// check whether container exists and is not restricted
+    TLex8 lexer( aItem->ParentId() );
+    TPtrC8 parentId = aItem->ParentId();
+    TInt containerId;
+    User::LeaveIfError( lexer.Val( containerId ) );
+    
+    ValidateContainerL( containerId );    
+   
+    // if everything is OK -> start transaction
+    iMetadataStorage->BeginTransactionL();
+        
+    TRAPD(err, DoShareReferenceL( containerId, aItem ) );
+    if ( err )
+        { // rollback if error
+        iMetadataStorage->RollbackTransactionL();    
+        User::Leave( err );
+        }
+    iMetadataStorage->CommitTransactionL();
+    
+    // eventing
+    if (iStateHandler)
+        {
+        iStateHandler->IncreaseSystemUpdateIdL();                
+        iStateHandler->IncreaseContainerUpdateIdL( parentId );   
+        }               
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::ShareReferenceListL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::ShareReferenceListL( CUpnpItemList* aItemList, 
+											TInt* aExecutionStatus )
+	{
+	//----- firstly - validate all containers upon which references are to be created.
+	for ( TInt i = 0; i < aItemList->ObjectCount(); i++ )
+	    {	    
+	    TLex8 lex((*aItemList)[i]->ParentId());
+	    TInt containerId;
+	    User::LeaveIfError( lex.Val(containerId) );
+	    
+	    ValidateContainerL(containerId);	    
+	    }
+	
+	//----- if containers are OK, do the following ...
+	
+	// varaible used to do the rest of eventing
+	TInt itemCommited=0; 
+	    
+    // start transaction
+    iMetadataStorage->BeginTransactionL();
+    
+    // reset status
+    *aExecutionStatus = 0;
+
+    // for each item in the list ...
+    for ( TInt i = 0; i < aItemList->ObjectCount(); i++ )
+        {               
+        // get parentId field value [upon which 'reference item' will be created]
+        TLex8 lexer((*aItemList)[i]->ParentId());
+        TInt parentId = -1;
+        User::LeaveIfError( lexer.Val(parentId) );            
+                     
+        // commit every KCommitEveryNum inserts 
+        if ( !(i%KCommitEveryNum) ) 
+            {
+            // ignore if i == 0;
+            if ( i )
+                {
+                itemCommited=0;
+                // commit last transaction
+                iMetadataStorage->CommitTransactionL();
+               
+                // success - update status
+                *aExecutionStatus = i;
+                if ( iStateHandler )
+                    {                                          
+                    for ( TInt j = 0; j < KCommitEveryNum; j++ )
+                        {
+                        iStateHandler->IncreaseSystemUpdateIdL();    
+                        iStateHandler->IncreaseContainerUpdateIdL( ( (*aItemList)[j]->ParentId() ) );    
+                        }                       
+                    }
+                   // begin new transaction
+                   iMetadataStorage->BeginTransactionL();                   
+                }
+            }
+        
+        // insert object
+        CUpnpObject* object = ( *aItemList )[i];
+        CUpnpItem* item = dynamic_cast<CUpnpItem*>( object );
+        
+        TRAPD( err, DoShareReferenceL( parentId, item ) );
+        if ( err )
+            { // rollback if error
+            iMetadataStorage->RollbackTransactionL();    
+            User::Leave(err);
+            }
+        itemCommited++;
+        }
+    
+        // commit
+        iMetadataStorage->CommitTransactionL();
+        
+        // success - update status
+        *aExecutionStatus = aItemList->ObjectCount();
+       
+        //eventing
+        if ( iStateHandler )
+            {
+            // do the rest of eventing if number of items were greater than KCommitEveryNum
+            for ( TInt j = 0; j < itemCommited; j++ ) 
+                {
+                iStateHandler->IncreaseSystemUpdateIdL();     
+                iStateHandler->IncreaseContainerUpdateIdL( ( ( *aItemList )[j]->ParentId() ) );    
+                }            
+            }			
+	}
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::UnshareItemL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::UnshareItemL( TInt aId )
+    {
+    // check id
+    ValidateItemL( aId );
+    HBufC8* containerId = HBufC8::NewLC( KMaxIntegerLen );
+    TInt containerIdInt = iMetadataStorage->GetParentIdL( aId );
+    if ( containerIdInt == KErrGeneral )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    containerId->Des().Num( containerIdInt );
+        
+    if (aId <= KDownloadContId)
+        {
+        User::Leave( KErrArgument );
+        }
+    RArray<TInt> refList;
+    CleanupClosePushL(refList);
+    if ( iMetadataStorage->DeleteObjectL( aId, refList, ETrue, ETrue ) == ENoSuchObject )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    // eventing
+    if ( iStateHandler )
+        {
+        TBuf8<KMaxIntegerLen> parentRefID;
+        iStateHandler->IncreaseSystemUpdateIdL();     
+        iStateHandler->IncreaseContainerUpdateIdL( *containerId );
+        for (TInt i(0);i<refList.Count();i++)
+            {
+            iStateHandler->IncreaseSystemUpdateIdL();                
+            parentRefID.Num( refList[i] );     
+            iStateHandler->IncreaseContainerUpdateIdL( parentRefID );
+            }
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy( &refList );
+    CleanupStack::PopAndDestroy( containerId );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::UnshareContainerL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::UnshareContainerL( TInt aId )
+    {
+    // check id
+    ValidateContainerL( aId );
+    HBufC8* containerId = HBufC8::NewLC( KMaxIntegerLen );
+    containerId->Des().Num(iMetadataStorage->GetParentIdL( aId ) );
+        
+    if ( aId <= KDownloadContId )
+        {
+        User::Leave( KErrArgument );
+        }
+    RArray<TInt> refList;
+    CleanupClosePushL(refList);    
+    if ( iMetadataStorage->DeleteObjectL( aId,refList, ETrue, ETrue ) == ENoSuchObject )
+        {
+        User::Leave( KErrNotFound );
+        }
+    
+    // eventing
+    if ( iStateHandler )
+        {            
+        iStateHandler->IncreaseSystemUpdateIdL();     
+        iStateHandler->IncreaseContainerUpdateIdL( *containerId );
+        TBuf8<KMaxIntegerLen> parentRefID;    
+        for (TInt i(0);i<refList.Count();i++)
+            {
+            parentRefID.Num( refList[i] );                 
+            if ( containerId->Compare( parentRefID ) )
+                {
+                iStateHandler->IncreaseSystemUpdateIdL();                           
+                iStateHandler->IncreaseContainerUpdateIdL( parentRefID );   
+                }            
+            }
+        refList.Reset();
+        }
+    CleanupStack::PopAndDestroy( &refList );
+    CleanupStack::PopAndDestroy( containerId );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::GetSharedItemL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpItem* CUpnpLocalStorage::GetSharedItemL( TInt aItemId )
+    {
+    // new item
+    CUpnpItem* item = CUpnpItem::NewL();
+    CleanupStack::PushL( item );
+    
+    // get object
+    GetObjectL( aItemId, item );
+    
+    // clean up
+    CleanupStack::Pop( item );
+    
+    return item;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::ShareItemListL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::ShareItemListL(CUpnpItemList* aItemList,
+        TInt* aExecutionStatus )
+    {
+    TInt itemCommited=0;
+    // check parent    
+    TLex8 lexer((*aItemList)[0]->ParentId());
+    TInt parentId;
+    User::LeaveIfError( lexer.Val(parentId) );
+    ValidateContainerL(parentId);
+    
+      // start transaction
+       iMetadataStorage->BeginTransactionL();
+       // reset status
+       *aExecutionStatus = 0;
+
+    // for each item
+    for ( TInt i = 0; i < aItemList->ObjectCount(); i++ )
+        {
+        // commit every KCommitEveryNum inserts
+        if ( !(i%KCommitEveryNum) ) 
+            {
+            // ignore if i == 0;
+            if ( i )
+                {
+                itemCommited=0;
+                // commit last transaction
+                iMetadataStorage->CommitTransactionL();
+               
+                // success - update status
+                *aExecutionStatus = i;
+                if ( iStateHandler )
+                    {                                          
+                    for ( TInt j =0; j<KCommitEveryNum; j++ )
+                        {
+                        iStateHandler->IncreaseSystemUpdateIdL();    
+                        iStateHandler->IncreaseContainerUpdateIdL( ( (*aItemList)[0]->ParentId() ) );    
+                        }                       
+                    }
+                   // begin new transaction
+                   iMetadataStorage->BeginTransactionL();                   
+                }
+            }
+        
+        // insert object
+        TRAPD( err, DoShareObjectL( parentId, ( *aItemList )[i]) );
+        if ( err )
+            { // rollback if error
+            iMetadataStorage->RollbackTransactionL();    
+            User::Leave(err);
+            }
+        itemCommited++;
+        }
+    
+        // commit
+        iMetadataStorage->CommitTransactionL();
+        // success - update status
+        *aExecutionStatus = aItemList->ObjectCount();
+       
+        //eventing
+        if ( iStateHandler )
+            {
+            for ( TInt j =0; j<itemCommited; j++ )
+                {
+                iStateHandler->IncreaseSystemUpdateIdL();     
+                iStateHandler->IncreaseContainerUpdateIdL( ( ( *aItemList )[0]->ParentId() ) );    
+                }            
+            }                       
+
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::ValidateContainerL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::ValidateContainerL( TInt aContainerId )
+    {
+    if ( !iMetadataStorage->IsContainerL( aContainerId ) )
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::ValidateItemL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::ValidateItemL( TInt aItemId )
+    {
+    if ( iMetadataStorage->IsContainerL( aItemId ) )
+        {
+        User::Leave( KErrNotFound );
+        }
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::UnshareItemListL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::UnshareItemListL( RArray<TInt>& aObjList, 
+                                          TInt* aExecutionStatus )
+    {
+    // list of resources
+    RArray<TInt> refList;
+    RArray<TInt> resList;
+    RArray<TInt> objCommitedList;
+    CleanupClosePushL(objCommitedList);
+    CleanupClosePushL(resList);
+    CleanupClosePushL(refList);
+    TInt parentId(0);
+    // start transaction
+    iMetadataStorage->BeginTransactionL();
+    // reset status
+    *aExecutionStatus = 0;
+
+    // for each item
+    for (TInt i = 0; i < aObjList.Count(); i++ )
+        {
+        parentId = iMetadataStorage->GetParentIdL( aObjList[i] );
+        if ( parentId>=0 )
+            {
+            objCommitedList.Append(parentId);
+            // commit every KCommitEveryNum inserts
+            if( !( i%KCommitEveryNum ) ) 
+                {
+                // ignore if i == 0;
+                if ( i )
+                    {                
+                    // commit last transaction
+                    iMetadataStorage->CommitTransactionL();
+
+                    // everything went OK, delete files
+                    iMetadataStorage->DeleteResourcesL(resList);
+                    resList.Reset();
+                   
+                    // success - update status
+                    *aExecutionStatus = i;
+                   
+                    // eventing
+                    if (iStateHandler)
+                        {                   
+                        for (TInt j =0;j<objCommitedList.Count();j++)
+                            {
+                            iStateHandler->IncreaseSystemUpdateIdL();
+                             TBuf8<KMaxIntegerLen> containerId;                       
+                            containerId.Num( objCommitedList[j] );
+                            iStateHandler->IncreaseContainerUpdateIdL( containerId );                    
+                            }
+                        objCommitedList.Reset();
+                        TBuf8<KMaxIntegerLen> parentRefID;    
+                           for ( TInt i(0); i<refList.Count(); i++ )
+                            {   
+                            iStateHandler->IncreaseSystemUpdateIdL();                
+                            parentRefID.Num( refList[i] );     
+                            iStateHandler->IncreaseContainerUpdateIdL( parentRefID );
+                            }
+                        refList.Reset();
+                        }                                    
+                
+                    // begin new transaction
+                    iMetadataStorage->BeginTransactionL();
+                    }
+                }
+        
+        // insert object
+        TRAPD( err, iMetadataStorage->DoDeleteObjectL( aObjList[i],refList, resList,
+                                                       ETrue, ETrue) );
+        if ( err )
+            { // rollback if error
+            iMetadataStorage->RollbackTransactionL();    
+            User::Leave(err);
+                }
+            }
+        }
+
+    // commit
+    iMetadataStorage->CommitTransactionL();
+
+    // everything went OK, delete files
+    iMetadataStorage->DeleteResourcesL( resList );
+
+    // success - update status
+    *aExecutionStatus = objCommitedList.Count();
+
+    // eventing       
+    if ( iStateHandler )
+       {
+       for ( TInt j =0; j<objCommitedList.Count(); j++ )
+            {
+            if ( objCommitedList[j]>=0 )
+                {                    
+                TBuf8<KMaxIntegerLen> containerId;      
+                containerId.Num(objCommitedList[j]);
+                iStateHandler->IncreaseSystemUpdateIdL();
+                iStateHandler->IncreaseContainerUpdateIdL( containerId );               
+                }  
+            }   
+        objCommitedList.Reset(); 
+        TBuf8<KMaxIntegerLen> parentRefID;    
+        for ( TInt i(0); i<refList.Count(); i++ )
+            {
+            iStateHandler->IncreaseSystemUpdateIdL();                
+            parentRefID.Num( refList[i] );     
+            iStateHandler->IncreaseContainerUpdateIdL( parentRefID );
+            }
+        refList.Reset();
+       }
+                                                               
+    // clean up
+    CleanupStack::PopAndDestroy( &refList );
+    CleanupStack::PopAndDestroy( &resList );
+    CleanupStack::PopAndDestroy( &objCommitedList );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::GetItemListL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::GetItemListL(TInt aContainerId,
+        CUpnpBrowseCriteria* aBrowseCriteria, TInt* aTotalMatches,
+        CUpnpItemList* aItemList )
+    {
+    // filter
+    TBool all = aBrowseCriteria->Filter().Length();
+
+    // get children ids
+    RArray<TInt> items;
+    CleanupClosePushL( items );
+    if ( iMetadataStorage->GetItemListL( aContainerId, items ) == ENoSuchObject || !items.Count() )
+        {
+        User::Leave(KErrNotFound);
+        }
+
+    // total matches
+    *aTotalMatches = items.Count();
+
+    // add wanted children
+    for ( TInt i = aBrowseCriteria->StartingIndex();
+          i < *aTotalMatches  && 
+          i < aBrowseCriteria->StartingIndex() 
+          + aBrowseCriteria->RequestedCount() ; 
+          i++ 
+        )
+        {
+        // new item
+        CUpnpItem* item = CUpnpItem::NewL();
+        CleanupStack::PushL(item);
+
+        // get object
+        GetObjectL(items[i], item, all);
+        aItemList->AppendObjectL(*item);
+
+        // pop item
+        CleanupStack::Pop(item);
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy(&items);
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::GetContainerListL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::GetContainerListL(TInt aContainerId,
+        CUpnpBrowseCriteria* aBrowseCriteria, TInt* aTotalMatches,
+        CUpnpContainerList* aList )
+    {
+    // filter
+    TBool all = aBrowseCriteria->Filter().Length();
+
+    // get children ids
+    RArray<TInt> contrs;
+    CleanupClosePushL( contrs );
+    if( iMetadataStorage->GetContainerListL( aContainerId, contrs ) == ENoSuchObject )
+        {
+        User::Leave( KErrNotFound );
+        }
+
+    // total matches
+    *aTotalMatches = contrs.Count();
+
+    // add wanted children
+    for ( TInt i = aBrowseCriteria->StartingIndex();
+          i < *aTotalMatches  && 
+          i < aBrowseCriteria->StartingIndex() 
+          + aBrowseCriteria->RequestedCount() ; 
+          i++ 
+        )
+        {
+        // new item
+        CUpnpContainer* contr = CUpnpContainer::NewL();
+        CleanupStack::PushL( contr );
+
+        // get object
+        GetObjectL( contrs[i], contr, all );
+        aList->AppendObjectL( *contr );
+
+        // pop item
+        CleanupStack::Pop( contr );
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy( &contrs );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::GetSingleContainerL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpContainer* CUpnpLocalStorage::GetSingleContainerL(TInt aContainerId )
+    {
+    // new item
+    CUpnpContainer* cont = CUpnpContainer::NewL();
+    CleanupStack::PushL(cont);
+
+    // get object
+    GetObjectL( aContainerId, cont );
+
+    // clean up
+    CleanupStack::Pop( cont );
+
+    return cont;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::CreateObjectBeanLC
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpObjectBean* CUpnpLocalStorage::CreateObjectBeanLC(CUpnpObject* aItem )
+    {
+    CUpnpObjectBean* objBn = CUpnpObjectBean::NewLC();
+
+    // restricted
+    objBn->SetObjRestricted( aItem->Restricted() );
+
+    // searchable
+    objBn->SetObjSearchable( ETrue );
+
+    // class
+    objBn->SetObjClassL( aItem->ObjectClass() );
+
+    // title
+    objBn->SetObjTitleL( aItem->Title() );
+
+    return objBn;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::CreateElementBeanLC
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpElementBean* CUpnpLocalStorage::CreateElementBeanLC(CUpnpElement& aElement )
+    {
+    CUpnpElementBean* elmBn = CUpnpElementBean::NewLC();
+
+    // name
+    elmBn->SetElmNameL( aElement.Name() );
+
+    // value
+    elmBn->SetElmValueL( aElement.Value() );
+
+    // is required
+    elmBn->SetElmIsRequired( aElement.IsRequired() );
+
+    TBool hasAttribute = aElement.GetAttributes().Count() > 0;
+    elmBn->SetElmHasAttribute( hasAttribute );
+    return elmBn;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::CreateAttributeBeanLC
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpAttributeBean* CUpnpLocalStorage::CreateAttributeBeanLC(
+        CUpnpAttribute& aAttr )
+    {
+    CUpnpAttributeBean* atrBn = CUpnpAttributeBean::NewLC();
+    
+    // name
+    atrBn->SetAtrNameL( aAttr.Name() );
+    
+    // value
+    atrBn->SetAtrValueL( aAttr.Value() );
+    
+    // set required
+    if ( aAttr.Name() == KprotocolInfo )
+        {
+        atrBn->SetAtrIsRequired( ETrue );
+        }
+    
+    return atrBn;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::DoShareItemL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::DoShareObjectL(TInt aContainer, CUpnpObject* aObject )
+    {
+
+    // object table
+    CUpnpObjectBean* objBn = CreateObjectBeanLC( aObject );
+    TInt objId = iMetadataStorage->InsertIntoObjectTableL( aContainer, objBn );
+    CleanupStack::PopAndDestroy( objBn );
+
+    // set id
+    HBufC8* id = HBufC8::NewLC( KMaxIntegerLen );
+    id->Des().Num( objId );    
+    aObject->SetIdL( *id );
+    CleanupStack::PopAndDestroy( id ); 
+
+    // add resources
+    HandleResourcesL( aObject );
+
+    // elements
+    const RUPnPElementsArray& elms = aObject->GetElements ( );
+    TInt elmId = iMetadataStorage->GetNextKeyL(KElementTableName8,elms.Count());
+    for (TInt i = 0; i < elms.Count ( ); i++ )
+        {
+        CUpnpElementBean* elm = CreateElementBeanLC( *elms[i] );
+        iMetadataStorage->InsertIntoElementTableL( objId, elm, elmId );
+        CleanupStack::PopAndDestroy( elm );
+
+        // attributes
+        const RUPnPAttributesArray& attrs = elms[i]->GetAttributes ( );
+        TInt atrId = iMetadataStorage->GetNextKeyL( KAttributeTableName8, attrs.Count() );
+        for( TInt j = 0; j < attrs.Count(); j++ )
+            {
+            CUpnpAttributeBean* attr = CreateAttributeBeanLC (*attrs[j] );
+            iMetadataStorage->InsertIntoAttributeTableL(elmId, attr, objId,atrId);
+            atrId++;
+            CleanupStack::PopAndDestroy (attr );
+            }
+        elmId++;
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::DoShareReferenceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::DoShareReferenceL( TInt aContainerId, CUpnpItem* aRefItem ) 
+	{    			
+    // prepare for a while main object to get some data from it
+    CUpnpItem* mainObj = CUpnpItem::NewL();
+    CleanupStack::PushL( mainObj );
+    
+	TLex8 lexer( aRefItem->RefId() );
+	TInt mainObjId;
+	User::LeaveIfError(lexer.Val(mainObjId));
+
+	// try to get 'real object', not e.g reference to reference
+	mainObjId = ReferedObjectIdL( mainObjId );
+	
+	// set new refID, pointing onto real object
+	TBuf8<KMaxIntegerLen> newRefIdBuf;
+    newRefIdBuf.Num( mainObjId );               
+    aRefItem->SetRefIdL( newRefIdBuf );
+	// get all data from main object
+    GetObjectL( mainObjId, mainObj ); 
+    
+    // setting: title and class in reference object, basing on info from main object 
+    aRefItem->SetTitleL( mainObj->Title() );
+    aRefItem->SetObjectClassL( mainObj->ObjectClass() );
+    
+    CleanupStack::PopAndDestroy( mainObj );
+                                 
+    // setting 'restricted' field
+    aRefItem->SetRestricted(EFalse);    
+                  
+    // creating new 'object bean' basing on 'reference object' 
+    CUpnpObjectBean* refBn = CreateObjectBeanLC( aRefItem );        
+    refBn->SetObjRefId( mainObjId ); 
+    refBn->SetObjParentId( aContainerId );
+    
+    // inserting newly created reference object onto 'object table'
+    TInt id = iMetadataStorage->InsertIntoObjectTableL( aContainerId, refBn );
+    CleanupStack::PopAndDestroy( refBn );                   
+    
+    // setting new id in created reference object     
+	TBuf8<KMaxIntegerLen> idBuf;
+    idBuf.Num( id );               
+    aRefItem->SetIdL( idBuf );
+    }	    
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::HandleResourcesL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::HandleResourcesL(CUpnpObject* aItem )
+    {
+    //
+    const RUPnPElementsArray& elms = aItem->GetElements();
+    for ( TInt i = 0; i < elms.Count(); i++ )
+        {
+        if ( elms[i]->Name() == KRes )
+            {
+
+            // get file name
+            TParse fp;
+            fp.Set( elms[i]->FilePath(), 0, 0 );
+
+            TPtrC8 itemId = aItem->Id();
+            HBufC8* contUri = UpnpCdUtils::BuildContentUriL(
+                    iMetadataStorage->GetNextKeyL( KImportUriId8 ), fp.Ext(), 
+                    itemId );
+            CleanupStack::PushL(contUri);
+
+            // add resource to the database
+            CUpnpResourcesBean* resBn = CUpnpResourcesBean::NewLC();
+            resBn->SetId( UpnpCdUtils::ResIdFromUriL( *contUri ) );
+            resBn->SetPathL( elms[i]->FilePath() );
+            resBn->SetIsReadonly( ETrue );
+            resBn->SetIsThumbnail( EFalse );
+
+            TInt objectId;
+            TLex8 lexer( aItem->Id() );
+            User::LeaveIfError( lexer.Val( objectId ) );
+            iMetadataStorage->AddResourceL( resBn, objectId );
+
+            // update object
+            HBufC8* uri = ValAsUriL( *contUri );
+            CleanupStack::PushL( uri );
+            elms[i]->SetValueL( *uri );
+            CleanupStack::PopAndDestroy( uri );
+            CleanupStack::PopAndDestroy( resBn );
+            CleanupStack::PopAndDestroy( contUri );
+            }
+
+        }
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::GetObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::GetObjectL( TInt aObjId, CUpnpObject* aObj, TBool aAll )
+    {
+    // get view
+    RDbView view = iMetadataStorage->GetObjViewL( aObjId );
+    CleanupClosePushL( view );
+    
+    if ( view.FirstL() )
+        {
+        // get row
+        view.GetL(); 
+
+        // create bean
+        CUpnpObjectBean* objBn = CUpnpObjectBean::NewLC( view );
+        
+        // add values
+        objBn->CopyToUpnpObjectL( aObj );
+        
+        if ( aAll )
+            { // add elements
+            AddElementsL( aObjId, aObj );
+            }
+        
+        CleanupStack::PopAndDestroy( objBn );
+        } 
+    else
+        { // no such object
+        User::Leave( KErrNotFound );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::AddElementsL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpLocalStorage::AddElementsL( TInt aObjectID, CUpnpObject* aObj )
+    {
+    RDbView view = iMetadataStorage->GetElementsViewL( aObjectID, ETrue );
+    CleanupClosePushL( view );
+    // Iterate through elements
+    while( view.NextL() )
+        {
+        view.GetL();
+        CUpnpElementBean* elBean = CUpnpElementBean::NewLC( view );
+        
+        // add new element
+        CUpnpElement* elm = elBean->AttachElmL( aObj );
+        
+        // add attributes
+        AddAttributesL( elBean->ElmId(), elm );
+        
+        if( elBean->ElmName() == KRes && 
+            elBean->ElmValue().Length() ) // ignore if empty res
+            { // add file path
+            CUpnpResourcesBean* resBn =     
+                iMetadataStorage->GetResourceL(
+                    UpnpCdUtils::ResIdFromUriL( elBean->ElmValue() ) );
+            CleanupStack::PushL(resBn);
+            
+            // set file path
+            elm->SetFilePathL( resBn->Path() );
+            
+            CleanupStack::PopAndDestroy( resBn );
+            }
+        
+        // clean up
+        CleanupStack::PopAndDestroy( elBean );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpElementBean::ValAsUriL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpLocalStorage::ValAsUriL( const TDesC8& aElmValue ) const 
+    {    
+    // uris have to be properly escaped
+    HBufC8* uriDes = NULL;
+    HBufC* tmp = UpnpCdUtils::Des8ToDesLC( aElmValue );        
+    TUriParser uripar;
+    uripar.Parse( *tmp );
+    CUri8* uri = uri = UriUtils::ConvertToInternetFormL( uripar );             
+    CleanupStack::PopAndDestroy( tmp );          
+    CleanupStack::PushL(uri); 
+    if ( uri->Uri().UriDes().Length() )
+        {                
+        uriDes = UpnpString::StringReplaceL( uri->Uri().UriDes(), KHash8, KHashASCII8 );                                                       
+        }
+    else
+        {
+        uriDes = uri->Uri().UriDes().AllocL();    
+        }    
+    CleanupStack::PopAndDestroy( uri );                
+    return uriDes;        
+    }
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::AddAttributesL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//    
+void CUpnpLocalStorage::AddAttributesL( TInt aElmId, CUpnpElement* aElm )
+    {
+    RDbView view = iMetadataStorage->GetAttributesViewL( aElmId, ETrue );
+    CleanupClosePushL(view);
+
+    // Iterate through attributes
+    while ( view.NextL() )
+        {
+        view.GetL();
+        CUpnpAttributeBean* atr = CUpnpAttributeBean::NewLC( view );
+        atr->AttachAttrL( aElm );
+        CleanupStack::PopAndDestroy( atr );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpLocalStorage::ReferedObjectIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpLocalStorage::ReferedObjectIdL(TInt aObjectId)
+{
+    TInt ret = KErrNotFound;
+    
+    TInt refId = iMetadataStorage->ReferedObjectIdL(aObjectId);
+    
+    if( refId != KErrNotFound )
+    {
+        ret = ReferedObjectIdL( refId );
+    }
+    else
+    {
+        ret = aObjectId;
+    }
+
+    return ret;
+}
+
+//  End of File  
+
--- a/upnpmediaserver/contentdirectoryservice/src/upnpmetadatastorage.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnpmetadatastorage.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,2353 +1,2353 @@
-/** @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:  Metadata storage
- *
-*/
-
-
-// INCLUDE FILES
-#include <upnpdominterface.h>
-#include "upnpmetadatastorage.h"
-#include "upnpcontentdirectoryglobals.h"
-#include "upnpobjectbean.h"
-#include "upnpelementbean.h"
-#include "upnpcdutils.h"
-#include "upnpresourcesbean.h"
-#include "upnpitem.h"
-#include "upnpelement.h"
-#include "upnpattributebean.h"
-#include "upnpcddbfactory.h"
-
-#define KLogFile _L("ContentDirectoryDb.log")
-#include "upnpcustomlog.h"
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::CUpnpMetadataStorage
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CUpnpMetadataStorage::CUpnpMetadataStorage()
-    {
-
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::ConstructL( const TDesC& aDatabaseFileName )
-    {
-    User::LeaveIfError( iFsSession.Connect( ) );
-    OpenDbL( aDatabaseFileName );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpMetadataStorage* CUpnpMetadataStorage::NewLC(
-    const TDesC& aDatabaseFileName )
-    {
-    CUpnpMetadataStorage* self = new( ELeave ) CUpnpMetadataStorage();
-
-    CleanupStack::PushL( self );
-    self->ConstructL( aDatabaseFileName );
-
-    return self;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpMetadataStorage* CUpnpMetadataStorage::NewL(
-    const TDesC& aDatabaseFileName )
-    {
-    CUpnpMetadataStorage* self =
-            CUpnpMetadataStorage::NewLC( aDatabaseFileName );
-
-    CleanupStack::Pop( self );
-
-    return self;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::~CUpnpMetadataStorage
-// Destructor
-// -----------------------------------------------------------------------------
-//    
-CUpnpMetadataStorage::~CUpnpMetadataStorage()
-    {
-    if ( iIsOpen )
-        {
-        iDatabase.Compact( );
-        }
-    iDatabase.Close( );
-    delete iFileStore;
-    iFsSession.Close( );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::OpenDbL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::OpenDbL( const TFileName& aDatabaseFileName )
-    {
-    iFileStore = CPermanentFileStore::OpenL( iFsSession, aDatabaseFileName,
-        EFileRead|EFileWrite );
-    iFileStore->SetTypeL( iFileStore->Layout( ) );
-    iDatabase.OpenL( iFileStore, iFileStore->Root( ) );
-    CheckDatabaseL( );
-    iIsOpen = ETrue;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DbChangedL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::DbChangedL( TInt aWeight )
-    {
-    iCompactCounter += aWeight;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DbChangedL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::CompactDbL()
-    {
-    if ( iCompactCounter >= KCompactWeight )
-        {
-        iCompactCounter = 0;
-        User::LeaveIfError( iDatabase.Compact( ) );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::BeginTransactionL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::BeginTransactionL()
-    {
-    iDatabase.Begin( );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::CommitTransactionL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::CommitTransactionL()
-    {
-    TInt err = iDatabase.Commit( );
-    if ( err != KErrNone )
-        {
-        iDatabase.Rollback( );
-        User::LeaveIfError( iDatabase.Recover( ) );
-        User::Leave( err );
-        }
-    CompactDbL( );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::RollbackTransactionL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::RollbackTransactionL()
-    {
-    iDatabase.Rollback( );
-    User::LeaveIfError( iDatabase.Recover( ) );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetObjectListL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpMetadataStorage::GetObjectListL( TInt aParentId,
-    RArray<TInt>& aList )
-    {
-    TUpnpErrorCode ret = CheckObjectRestrictionL( aParentId ); // make sure the parent exists
-    if ( ret != ENoSuchObject && ret != ENoContainer )
-        {
-        // prepare query
-        TBuf<sizeof(KGetObjectListSqlCmd)/KCharSize + KMaxIntegerLen> query;
-        query.Format( KGetObjectListSqlCmd, aParentId );
-        // prepare view
-        RDbView view;
-        User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( query ),
-            view.EReadOnly ) );
-        CleanupClosePushL( view );
-        // evaluate
-        User::LeaveIfError( view.EvaluateAll( ) );
-        // for each object
-        const TInt KIdColNo=1;
-
-        while ( view.NextL( ) )
-            {
-            view.GetL( );
-            // get object
-            TInt childId = view.ColInt( KIdColNo );
-            aList.AppendL( childId );
-            }
-        //clean up
-        CleanupStack::PopAndDestroy( &view );
-        ret = EUpnpOk;
-        }
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetObjectListL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpMetadataStorage::GetItemListL( TInt aParentId,
-    RArray<TInt>& aList )
-    {
-    TUpnpErrorCode ret = CheckObjectRestrictionL( aParentId ); // make sure the parent exists
-    if ( ret != ENoSuchObject )
-        {
-        // prepare query
-        TBuf<sizeof(KGetItemListSqlCmd)/KCharSize + KMaxIntegerLen> query;
-        query.Format( KGetItemListSqlCmd, aParentId );
-        // prepare view
-        RDbView view;
-        User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( query ),
-            view.EReadOnly ) );
-        CleanupClosePushL( view );
-        // evaluate
-        User::LeaveIfError( view.EvaluateAll( ) );
-        // for each object
-        const TInt KIdColNo=1;
-        while ( view.NextL( ) )
-            {
-            view.GetL( );
-            // get object
-            TInt childId = view.ColInt( KIdColNo );
-            aList.AppendL( childId );
-            }
-        //clean up
-        CleanupStack::PopAndDestroy( &view );
-        ret = EUpnpOk;
-        }
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetContainerListL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpMetadataStorage::GetContainerListL( TInt aParentId,
-    RArray<TInt>& aList )
-    {
-    TUpnpErrorCode ret = CheckObjectRestrictionL( aParentId ); // make sure the parent exists
-    if ( ret != ENoSuchObject )
-        {
-        // prepare query
-        TBuf<sizeof(KGetContainerListSqlCmd)/KCharSize + KMaxIntegerLen> query;
-        query.Format( KGetContainerListSqlCmd, aParentId );
-        // prepare view
-        RDbView view;
-        User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( query ),
-            view.EReadOnly ) );
-        CleanupClosePushL( view );
-        // evaluate
-        User::LeaveIfError( view.EvaluateAll( ) );
-        // for each object
-        const TInt KIdColNo=1;
-        while ( view.NextL( ) )
-            {
-            view.GetL( );
-            // get object
-            TInt childId = view.ColInt( KIdColNo );
-            aList.AppendL( childId );
-            }
-        //clean up
-        CleanupStack::PopAndDestroy( &view );
-        ret = EUpnpOk;
-        }
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::CheckObjectRestrictionL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpMetadataStorage::CheckObjectRestrictionL( TInt aObjId )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aObjId);
-    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
-        table.EReadOnly ) );
-    User::LeaveIfError( table.SetIndex( KObjIdIndexName ) ); // use index
-    if ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-
-        CDbColSet* colSet = table.ColSetL( );
-        TDbColNo colNo(colSet->ColNo( KObjRestrictedColName ) );
-        if ( !table.ColUint8( colNo ) ) // is restricted?
-            { // OK
-            TDbColNo colNo(colSet->ColNo( KObjClassColName ) );
-            if ( table.ColDes8(colNo).Find( KContainerClass8 ) == 0 ) // check whether the object is a container
-                { // this is a container
-                ret = EUpnpOk;
-                }
-            else
-                { // there is such object but this is not a container
-                ret = ENoContainer;
-                }
-            }
-        else
-            {
-            ret = ERestrictedObject;
-            }
-        delete colSet;
-        }
-    else
-        { // no such object
-        ret = ENoSuchObject;
-        }
-
-    CleanupStack::PopAndDestroy( &table );
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::CheckObjectRestrictionL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpMetadataStorage::IsContainerL( TInt aObjId )
-    {
-    TBool ret = EFalse;
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aObjId);
-    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
-        table.EReadOnly ) );
-    User::LeaveIfError( table.SetIndex( KObjIdIndexName ) ); // use index
-
-    if ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-
-        CDbColSet* colSet = table.ColSetL( );
-        TDbColNo colNo(colSet->ColNo( KObjClassColName ) );
-        if ( table.ColDes8(colNo).Find( KContainerClass8 ) == 0 ) // check whether the object is a container
-            { // this is a container
-            ret = ETrue;
-            }
-        delete colSet;
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &table );
-
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::AddMainTagAttrL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-TUpnpErrorCode CUpnpMetadataStorage::AddMainTagAttrL(
-    TXmlEngElement aElement, TInt aId, const TDesC8& aName )
-    {
-    TUpnpErrorCode ret = EUpnpUndefined;
-    // xml string of name
-
-    // is the attr exist?
-    TXmlEngAttr atr = aElement.AttributeNodeL( aName );
-    if ( atr.IsNull( ) )
-        { // attr does not exist - add
-        TBuf<sizeof(KSelectFromObjectSqlCmd)/KCharSize +
-        KMaxIntegerLen + KColNameMaxLenth> query;
-        query.Format( KSelectFromObjectSqlCmd, &aName, aId );
-
-        // Execute command
-        RDbView view;
-        CleanupClosePushL( view );
-        TInt dbErr = view.Prepare( iDatabase, TDbQuery( query ),
-            view.EReadOnly );
-        LOGSQL( "CUpnpContentDirectoryDb::AddMainTagAttrL",
-            "RDbView::Prepare", dbErr, &query );
-        if ( dbErr == KErrNone )
-            {
-            CleanupClosePushL( view );
-            User::LeaveIfError( view.EvaluateAll( ) );
-
-            // if there is a row, add attribute
-            if ( view.FirstL( ) )
-                {
-                // get row
-                view.GetL( );
-                // col's val as Des
-                HBufC8* buff = GetColDesValFromRowSetL( view, 1 );
-                CleanupStack::PushL( buff );
-                // prepare xml string of value
-                // add attributes
-                aElement.AddNewAttributeL( aName, *buff );
-                ret = EUpnpOk;
-                // clean up
-                CleanupStack::PopAndDestroy( buff );
-                }
-            else
-                { // no such object in the database
-                ret = ENoSuchObject;
-                }
-            }
-        else
-            { // probably the name of the attr was wrong - ignore
-            ret = ENoSuchObject;
-            }
-        // clean up
-        CleanupStack::PopAndDestroy( &view );
-        }
-    else // if(!atr.IsNull())
-        { // already exists - it is OK, do not need to do anything
-        ret = EUpnpOk;
-        }
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetElementViewL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-RDbView CUpnpMetadataStorage::GetElementViewL( TInt aObjId,
-    const TDesC8& aElName )
-    {
-    // convert to TDesC
-    HBufC* elName = HBufC::NewLC( aElName.Length( ) );
-    elName->Des().Copy( aElName );
-
-    // Prepare SQL command
-    HBufC* query = HBufC::NewLC( KSelectElmFromElmSqlCmd().Length( ) 
-                                + KNamedElFromElement().Length( ) 
-                                + KMaxIntegerLen 
-                                + elName->Length( ) );
-    TPtr queryPtr(query->Des( ));
-    queryPtr.Format( KSelectElmFromElmSqlCmd, aObjId );
-    queryPtr.AppendFormat( KNamedElFromElement, elName );
-    
-
-    // Execute command
-    RDbView view = GetEvaluatedViewL( queryPtr );
-    LOGSQL( "CUpnpContentDirectoryDb::GetElementViewL", "RDbView::Prepare",
-        0, &queryPtr );
-    CleanupStack::PopAndDestroy( query );
-    CleanupStack::PopAndDestroy( elName );
-
-    return view;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::AddAttributeL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-
-RDbView CUpnpMetadataStorage::GetObjViewL( TInt aObjId )
-    {
-    // Get data from object table
-    // Prepare SQL command
-    TBuf<sizeof(KSelectObjectFromObjSqlCmd)/KCharSize
-    + KMaxIntegerLen> query;
-    query.Format( KSelectObjectFromObjSqlCmd, aObjId );
-
-    LOGSQL( "CUpnpContentDirectoryDb::GetObjectL", "", 0, &query );
-
-    return GetEvaluatedViewL( query );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::AddAttributeL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-RDbView CUpnpMetadataStorage::GetElementsViewL( TInt aObjectID, TBool aAll )
-    {
-    // Get data from element table
-    // Prepare SQL command
-    TBuf<sizeof(KSelectElmFromElmSqlCmd)/KCharSize
-    + sizeof(KOnlyRequiredFromElement)/KCharSize + KMaxIntegerLen> query;
-    query.Format( KSelectElmFromElmSqlCmd, aObjectID );
-
-    query.Format( KSelectElmFromElmSqlCmd, aObjectID );
-    if ( !aAll )
-        { // only required properties
-        query.Append( KOnlyRequiredFromElement );
-        }
-
-    LOGSQL( "CUpnpContentDirectoryDb::GetElementsViewL", "", 0, &query );
-
-    return GetEvaluatedViewL( query );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::AddAttributeL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-RDbView CUpnpMetadataStorage::GetAttributesViewL( TInt aElementID, TBool aAll )
-    {
-    // Get data from element table
-    // Prepare SQL command
-    TBuf<sizeof(KSelectAtrFromAttrSqlCmd)/KCharSize
-    + sizeof(KOnlyRequiredFromAtr)/KCharSize + KMaxIntegerLen> query;
-    query.Format( KSelectAtrFromAttrSqlCmd, aElementID );
-    if ( !aAll )
-        { // only required attr are wanted
-        query.Append( KOnlyRequiredFromAtr );
-        }
-
-    LOGSQL( "CUpnpContentDirectoryDb::GetAttributesViewL", "", 0, &query );
-
-    return GetEvaluatedViewL( query );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetAttributesViewByObjectIdL
-// -----------------------------------------------------------------------------
-//
-RDbView CUpnpMetadataStorage::GetAttributesViewByObjectIdL( TInt aObjectID,
-    TBool aAll )
-    {
-    // Get data from element table
-    // Prepare SQL command
-    TBuf<sizeof(KSelectAtrFromAttrByObjSqlCmd)/KCharSize
-    + sizeof(KOnlyRequiredFromAtr)/KCharSize + KMaxIntegerLen> query;
-    query.Format( KSelectAtrFromAttrByObjSqlCmd, aObjectID );
-    if ( !aAll )
-        { // only required attr are wanted
-        query.Append( KOnlyRequiredFromAtr );
-        }
-
-    LOGSQL( "CUpnpContentDirectoryDb::GetAttributesViewByObjectIdL", "", 0,
-        &query );
-
-    return GetEvaluatedViewL( query );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::InsertElementL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::InsertElementL( const TXmlEngElement& aElement,
-    TInt aObjId )
-    {
-    // open table
-    RDbTable table;
-    User::LeaveIfError( table.Open( iDatabase, KElementTableName,
-        table.EUpdatable ) );
-    CleanupClosePushL( table );
-
-    // CdbColSet
-    CDbColSet* objColSet = table.ColSetL( );
-    CleanupStack::PushL( objColSet );
-
-    // rowset cursor to the beginning position
-    table.Reset( );
-
-    // insert empty row
-    table.InsertL( );
-
-    // elm_id
-    TInt elmId = GetNextKeyL( KElementTableName8 );
-    table.SetColL( objColSet->ColNo( KElmIdColName ), elmId );
-
-    // elm_name
-    HBufC8 * elmName = UpnpCdUtils::GetElmNameWithNsL( aElement );
-    CleanupStack::PushL( elmName );
-    table.SetColL( objColSet->ColNo( KElmNameColName ), *elmName );
-    CleanupStack::PopAndDestroy( elmName );
-
-    // elm_value
-    if ( aElement.Value().Length( ) )
-        {
-        TPtrC8 elmValue(aElement.Value( ) );
-        if ( elmValue.Length( ) > KMaxUpnpLongStringLen )
-            { // too long
-            User::Leave( EActionFailed );
-            }
-        // use write stream
-        RDbColWriteStream ws;
-        ws.OpenLC( table, objColSet->ColNo( KElmValueColName ) );
-        ws.WriteL( elmValue ); // write value
-        ws.CommitL( );
-        CleanupStack::PopAndDestroy( &ws );
-        }
-
-    // elm_has_attribute
-    table.SetColL( objColSet->ColNo( KElmHasAttrColName ),
-        aElement.HasAttributes( ) );
-
-    // elm_obj_id
-    table.SetColL( objColSet->ColNo( KElmObjIdColName ), aObjId );
-
-    // elm_is_required
-    table.SetColL( objColSet->ColNo( KElmIsRequiredColName ),
-        UpnpCdUtils::IsElementRequiredL( aElement ) );
-
-    // complete insertion
-    table.PutL( );
-
-    DbChangedL( KExecuteWeight );
-
-    // clean up
-    CleanupStack::PopAndDestroy( objColSet );
-    CleanupStack::PopAndDestroy( &table );
-
-    return elmId;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::CreatePathValL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpMetadataStorage::CreatePathValL( const TXmlEngElement& aElement )
-    {
-    TPtrC8
-            parentIdPtr(UpnpDomInterface::GetAttrValueL( aElement, KParentID ));
-    TLex8 lexer(parentIdPtr);
-    TInt parentId;
-    User::LeaveIfError( lexer.Val( parentId ) );
-
-    return CreatePathValL( parentId );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::CreatePathValL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpMetadataStorage::CreatePathValL( TInt aParentId )
-    {
-    HBufC8* path = NULL;
-    User::LeaveIfNull( path = GetObjectPathL( aParentId ) );
-
-    CleanupStack::PushL( path );
-
-    HBufC8* tmp = HBufC8::NewL( path->Length( ) 
-                                + KPathSeparator().Length( ) 
-                                + KMaxIntegerLen );
-    TPtr8 tmpPtr(tmp->Des( ));
-    tmpPtr.Copy( *path );
-    tmpPtr.Append( KPathSeparator );
-
-    TBuf<KMaxIntegerLen> num;
-    num.Num( aParentId );
-    tmpPtr.Append( num );
-
-    CleanupStack::PopAndDestroy( path );
-
-    return tmp;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::InsertAttributeL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::InsertAttributeL( const TXmlEngAttr aAttr,
-    TInt aElmId, TBool aIsRequired, TInt aObjId )
-    {
-
-    // open table
-    RDbTable table;
-    User::LeaveIfError( table.Open( iDatabase, KAttributeTableName,
-        table.EUpdatable ) );
-    CleanupClosePushL( table );
-
-    // CdbColSet
-    CDbColSet* objColSet = table.ColSetL( );
-    CleanupStack::PushL( objColSet );
-
-    // rowset cursor to the beginning position
-    table.Reset( );
-
-    // insert empty row
-    table.InsertL( );
-
-    // atr_id
-    table.SetColL( objColSet->ColNo( KAtrIdColName ),
-        GetNextKeyL( KAttributeTableName8 ) ); // leaves if error
-
-    // atr_name
-    table.SetColL( objColSet->ColNo( KAtrNameColName ), aAttr.Name( ) ); // name cannot be null
-
-    // atr_value
-    if ( aAttr.Value().Length( ) )
-        {
-        TPtrC8 atrValue(aAttr.Value( ) );
-        if ( atrValue.Length( ) > KMaxUpnpLongStringLen )
-            { // too long
-            User::Leave( EActionFailed );
-            }
-        // use write stream
-        RDbColWriteStream ws;
-        ws.OpenLC( table, objColSet->ColNo( KAtrValueColName ) );
-        ws.WriteL( atrValue ); // write value
-        ws.CommitL( );
-        CleanupStack::PopAndDestroy( &ws );
-        }
-
-    // atr_elm_id
-    table.SetColL( objColSet->ColNo( KAtrElmIdColName ), aElmId );
-
-    // atr_is_required
-    table.SetColL( objColSet->ColNo( KAtrIsRequiredColName ), aIsRequired );
-
-    // atr_obj_id
-    table.SetColL( objColSet->ColNo( KAtrIdObjColName ), aObjId );
-
-    // complete insertion
-    table.PutL( );
-
-    DbChangedL( KExecuteWeight );
-
-    // clean up
-    CleanupStack::PopAndDestroy( objColSet );
-    CleanupStack::PopAndDestroy( &table );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::InsertObjectIntoObjectTableL
-// ?implementation_description
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::InsertObjectIntoObjectTableL(
-    const TXmlEngElement& aElement )
-    {
-    // open table
-    RDbTable table;
-    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
-        table.EUpdatable ) );
-    CleanupClosePushL( table );
-
-    // CdbColSet
-    CDbColSet* objColSet = table.ColSetL( );
-    CleanupStack::PushL( objColSet );
-
-    // rowset cursor to the beginning position
-    table.Reset( );
-
-    // insert empty row
-    table.InsertL( );
-
-    // set attributes
-    RXmlEngNodeList<TXmlEngAttr> attrList;
-    CleanupClosePushL( attrList );
-    aElement.GetAttributes( attrList );
-    while ( attrList.HasNext( ) )
-        {
-        // get next
-        TXmlEngAttr attr = attrList.Next( );
-
-        // col ordinal
-        HBufC* colName = HBufC::NewLC( attr.Name().Length( ) );
-        colName->Des().Copy( attr.Name( ) );
-        TDbColNo colNo = objColSet->ColNo( *colName );
-        CleanupStack::PopAndDestroy( colName );
-
-        // insert if exists
-        if ( colNo != KDbNullColNo )
-            { // (not any string attribute in the main element)
-            HBufC8* tmp = attr.Value().AllocLC( );
-            UpnpCdUtils::ReplaceTrueFalse( tmp );// true -> 1, false -> 0
-            TLex8 lexer(*tmp);
-            TInt num;
-            User::LeaveIfError( lexer.Val( num ) ); // string -> integer
-            // set value
-            table.SetColL( colNo, num );
-            CleanupStack::PopAndDestroy( tmp );
-            }
-        }
-    CleanupStack::Check( &attrList );
-
-    // set title
-    TXmlEngElement objTitle;
-    UpnpDomInterface::GetElementL( aElement, objTitle, KObjTiltleColName8( ) );
-    table.SetColL( objColSet->ColNo( KObjTiltleColName ), objTitle.Value( ) );
-    CleanupStack::Check( &attrList );
-
-    // set class
-    TXmlEngElement objClass;
-    UpnpDomInterface::GetElementL( aElement, objClass, KObjClassColName8( ) );
-    table.SetColL( objColSet->ColNo( KObjClassColName ), objClass.Value( ) );
-    CleanupStack::Check( &attrList );
-
-    // set path
-    HBufC8* path = CreatePathValL( aElement );
-    CleanupStack::PushL( path );
-    table.SetColL( objColSet->ColNo( KObjPathColName ), *path );
-    CleanupStack::PopAndDestroy( path );
-    CleanupStack::Check( &attrList );
-
-    // complete insertion
-    table.PutL( );
-
-    DbChangedL( KExecuteWeight );
-
-    // clean up
-    CleanupStack::PopAndDestroy( &attrList );
-    CleanupStack::PopAndDestroy( objColSet );
-    CleanupStack::PopAndDestroy( &table );
-
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetNextKeyForTableL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::GetNextKeyL( const TDesC8& aName )
-    {
-    TInt ret = KErrNotFound;
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aName);
-    User::LeaveIfError( table.Open( iDatabase, KSequencesTableName,
-        table.EUpdatable ) );
-    User::LeaveIfError( table.SetIndex( KSeqColNameIndexName ) ); // use index
-    if ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-        CDbColSet* colSet = table.ColSetL( );
-        CleanupStack::PushL( colSet );
-        TDbColNo colNo(colSet->ColNo( KSeqNextKeyColName ) );
-        ret = table.ColInt( colNo );
-        table.UpdateL( );
-        table.SetColL( colNo, ret + 1 );
-        table.PutL( );
-
-        DbChangedL( KExecuteWeight );
-
-        CleanupStack::PopAndDestroy( colSet );
-        }
-    else
-        { // no such object
-        User::Leave( KErrCorrupt );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &table );
-
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetNextKeyForTableL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::GetNextKeyL( const TDesC8& aName, TInt aAmount )
-    {
-    TInt ret = KErrNotFound;
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aName);
-    User::LeaveIfError( table.Open( iDatabase, KSequencesTableName,
-        table.EUpdatable ) );
-    User::LeaveIfError( table.SetIndex( KSeqColNameIndexName ) ); // use index
-    if ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-        CDbColSet* colSet = table.ColSetL( );
-        CleanupStack::PushL( colSet );
-        TDbColNo colNo(colSet->ColNo( KSeqNextKeyColName ) );
-        ret = table.ColInt( colNo );
-        table.UpdateL( );
-        table.SetColL( colNo, ret + aAmount );
-        table.PutL( );
-
-        DbChangedL( KExecuteWeight );
-
-        CleanupStack::PopAndDestroy( colSet );
-        }
-    else
-        { // no such object
-        User::Leave( KErrCorrupt );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &table );
-
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::NextKeyL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::NextKeyL( const TDesC8& aName )
-    {
-    TInt ret = KErrNotFound;
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aName);
-    User::LeaveIfError( table.Open( iDatabase, KSequencesTableName,
-        table.EReadOnly ) );
-    User::LeaveIfError( table.SetIndex( KSeqColNameIndexName ) ); // use index
-    if ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-        CDbColSet* colSet = table.ColSetL( );
-        CleanupStack::PushL( colSet );
-        TDbColNo colNo(colSet->ColNo( KSeqNextKeyColName ) );
-        ret = table.ColInt( colNo );
-
-        CleanupStack::PopAndDestroy( colSet );
-        }
-    else
-        { // no such object
-        User::Leave( KErrCorrupt );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &table );
-
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::ReferedObjectIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::ReferedObjectIdL( TInt aObjectId )
-    {
-    TInt ret = KErrNotFound;
-    TBuf<sizeof(KSelectFromObjectSqlCmd)/KCharSize
-    + KMaxIntegerLen + KColNameMaxLenth> query;
-    query.Format( KSelectFromObjectSqlCmd, &KObjRefIdColName, aObjectId );
-
-    // Execute command
-    RDbView view;
-    CleanupClosePushL( view );
-    TInt dbErr = view.Prepare( iDatabase, TDbQuery( query ), view.EReadOnly );
-    LOGSQL( "CUpnpContentDirectoryDb::ReferedObjectIdL", "RDbView::Prepare",
-        dbErr, &query );
-    if ( dbErr == KErrNone )
-        {
-        User::LeaveIfError( view.Evaluate( ) );
-        if ( view.FirstL( ) )
-            {
-            // get col number -  there can by only one column but just in case get by name
-            CDbColSet* colSet = view.ColSetL( );
-            const TInt colNo = colSet->ColNo( KObjRefIdColName );
-            delete colSet;
-
-            view.GetL( );
-            if ( !view.IsColNull( colNo ) )
-                {
-                ret = view.ColInt( colNo );
-                }
-            }
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetElmIdForAttrL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::GetElmIdForAttrL( const TDesC8& aAttrName,
-    const TDesC8& aAttrVal )
-    {
-    // convert to unicode
-    HBufC* attrName = UpnpCdUtils::Des8ToDesLC( aAttrName );
-    HBufC* attrVal = UpnpCdUtils::Des8ToDesLC( aAttrVal );
-
-    TInt elmId = KErrNotFound;
-    HBufC* query = HBufC::NewLC( aAttrVal.Length( ) 
-                                 + KSelectFromSqlCmd().Length( ) 
-                                 + KAtrElmIdColName().Length( ) 
-                                 + KAttributeTableName().Length( ) 
-                                 + KAtrValueColName().Length( ) 
-                                 + KAndConditionSqlCmd().Length( ) 
-                                 + KAtrNameColName().Length( ) 
-                                 + aAttrName.Length( ) );
-    TPtr queryPtr(query->Des( ));
-    // prepare format string
-    HBufC* fmt = HBufC::NewLC( KSelectFromSqlCmd().Length( ) + KAndConditionSqlCmd().Length( ) );
-    TPtr fmtPtr(fmt->Des( ));
-    fmtPtr.Copy( KSelectFromSqlCmd );
-    fmtPtr.Append( KAndConditionSqlCmd );
-    // format query
-    queryPtr.Format( fmtPtr, &KAtrElmIdColName, &KAttributeTableName,
-        &KAtrNameColName, attrName, &KAtrValueColName, attrVal );
-    // clean up format string
-    CleanupStack::PopAndDestroy( fmt );
-
-    RDbView view;
-    CleanupClosePushL( view );
-    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
-        view.EReadOnly );
-    if ( dbErr == KErrNone )
-        {
-        User::LeaveIfError( view.Evaluate( ) );
-        if ( view.FirstL( ) )
-            {
-            // get col number -  there can by only one column but just in case get by name
-            CDbColSet* colSet = view.ColSetL( );
-            const TInt colNo = colSet->ColNo( KAtrElmIdColName );
-            delete colSet;
-
-            view.GetL( );
-            if ( !view.IsColNull( colNo ) )
-                {
-                elmId = view.ColInt( colNo );
-                }
-            }
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    CleanupStack::PopAndDestroy( query );
-    CleanupStack::PopAndDestroy( attrVal );
-    CleanupStack::PopAndDestroy( attrName );
-    return elmId;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetObjIdForElmIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::GetObjIdForElmIdL( TInt aId )
-    {
-    TInt objId = KErrNotFound;
-    HBufC* query = HBufC::NewLC( KMaxIntegerLen + KSelectFromNumSqlCmd().Length( ) 
-                                + KElementTableName().Length( ) 
-                                + KElmObjIdColName().Length( ) 
-                                + KElmIdColName().Length( ) );
-    TPtr queryPtr(query->Des( ));
-    queryPtr.Format( KSelectFromNumSqlCmd, &KElmObjIdColName,
-        &KElementTableName, &KElmIdColName, aId );
-
-    RDbView view;
-    CleanupClosePushL( view );
-    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
-        view.EReadOnly );
-    if ( dbErr == KErrNone )
-        {
-        User::LeaveIfError( view.Evaluate( ) );
-        if ( view.FirstL( ) )
-            {
-            // get col number -  there can by only one column but just in case get by name
-            CDbColSet* colSet = view.ColSetL( );
-            const TInt colNo = colSet->ColNo( KElmObjIdColName );
-            delete colSet;
-
-            view.GetL( );
-            if ( !view.IsColNull( colNo ) )
-                {
-                objId = view.ColInt( colNo );
-                }
-            }
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    CleanupStack::PopAndDestroy( query );
-    return objId;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetObjIdByAttrLikeL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::GetElmIdForAttrLikeL( const TDesC8& aAttrName,
-    const TDesC8& aAttrVal )
-    {
-    //convert to unicode 
-    HBufC* attrVal = UpnpCdUtils::Des8ToDesLC( aAttrVal );
-    HBufC* attrName = UpnpCdUtils::Des8ToDesLC( aAttrName );
-
-    // query buf
-    TInt elmId = KErrNotFound;
-    HBufC* query = HBufC::NewLC( attrVal->Length( ) 
-                                + KSelectFromSqlCmd().Length( ) 
-                                + KAtrElmIdColName().Length( ) 
-                                + KAttributeTableName().Length( ) 
-                                + KAtrValueColName().Length( ) 
-                                + KAndLikeConditionSqlCmd().Length( ) 
-                                + KAtrNameColName().Length( ) 
-                                + attrName->Length( ) );
-    TPtr queryPtr(query->Des( ));
-    // prepare format string
-    HBufC* fmt = HBufC::NewLC( KSelectFromSqlCmd().Length( ) + KAndLikeConditionSqlCmd().Length( ) );
-    TPtr fmtPtr(fmt->Des( ));
-    fmtPtr.Copy( KSelectFromSqlCmd );
-    fmtPtr.Append( KAndLikeConditionSqlCmd );
-    // format query
-    queryPtr.Format( fmtPtr, &KAtrElmIdColName, &KAttributeTableName,
-        &KAtrNameColName, attrName, &KAtrValueColName, attrVal );
-    // clean up format string
-    CleanupStack::PopAndDestroy( fmt );
-
-    RDbView view;
-    CleanupClosePushL( view );
-    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
-        view.EReadOnly );
-    if ( dbErr == KErrNone )
-        {
-        User::LeaveIfError( view.Evaluate( ) );
-        if ( view.FirstL( ) )
-            {
-            // get col number -  there can by only one column but just in case get by name
-            CDbColSet* colSet = view.ColSetL( );
-            const TInt colNo = colSet->ColNo( KAtrElmIdColName );
-            delete colSet;
-
-            view.GetL( );
-            if ( !view.IsColNull( colNo ) )
-                {
-                elmId = view.ColInt( colNo );
-                }
-            }
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    CleanupStack::PopAndDestroy( query );
-    CleanupStack::PopAndDestroy( attrName );
-    CleanupStack::PopAndDestroy( attrVal );
-    return elmId;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetParentIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::GetParentIdL( TInt aObjId )
-    {
-    TInt objId=KErrGeneral;
-    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
-                                + KObjParentIdColName().Length( ) 
-                                + KObjectTableName().Length( ) 
-                                + KObjIdColName().Length( ) 
-                                + KMaxIntegerLen );
-    TPtr queryPtr(query->Des( ));
-    queryPtr.Format( KSelectFromNumSqlCmd, &KObjParentIdColName,
-        &KObjectTableName, &KObjIdColName, aObjId );
-
-    RDbView view;
-    CleanupClosePushL( view );
-    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
-        view.EReadOnly );
-    if ( dbErr == KErrNone )
-        {
-        User::LeaveIfError( view.Evaluate( ) );
-        if ( view.FirstL( ) )
-            {
-            CDbColSet* colSet = view.ColSetL( );
-            const TInt colNo = colSet->ColNo( KObjParentIdColName );
-            delete colSet;
-
-            view.GetL( );
-            if ( !view.IsColNull( colNo ) )
-                {
-                objId = view.ColInt( colNo );
-                }
-            }
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    CleanupStack::PopAndDestroy( query );
-    return objId;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetChildCountL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::GetChildCountL( TInt aObjId )
-    {
-    TInt childCount = KErrGeneral;
-
-    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
-                                 + KObjIdColName().Length( ) 
-                                 + KObjectTableName().Length( ) 
-                                 + KObjParentIdColName().Length( ) 
-                                 + KMaxIntegerLen );
-    TPtr queryPtr(query->Des( ));
-    queryPtr.Format( KSelectFromNumSqlCmd, &KObjIdColName, &KObjectTableName,
-        &KObjParentIdColName, aObjId );
-
-    RDbView view;
-    CleanupClosePushL( view );
-    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
-        view.EReadOnly );
-    if ( dbErr == KErrNone )
-        {
-        User::LeaveIfError( view.EvaluateAll( ) );
-        childCount = view.CountL( );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    CleanupStack::PopAndDestroy( query );
-    return childCount;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteResElL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::DeleteResElL( const TDesC& aResVal, TInt ObjId )
-    {
-    HBufC* query = HBufC::NewLC( KDeleteResElSqlCmd().Length( ) + aResVal.Length( ) + KMaxIntegerLen );
-    TPtr SqlCmd(query->Des( ));
-    SqlCmd.Format( KDeleteResElSqlCmd, &aResVal, ObjId );
-
-    // execute
-    ExecuteL( SqlCmd );
-
-    // clean up
-    CleanupStack::PopAndDestroy( query );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteResElL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::ExecuteL( const TDesC& aSqlCmd )
-    {
-    // execute
-    TInt err = iDatabase.Execute( aSqlCmd );
-    LOGSQL( "CUpnpContentDirectoryDb::DeleteResElL", "iDataBase.Execute",
-        err, &aSqlCmd );
-    User::LeaveIfError( err );
-
-    // db compact
-    DbChangedL( KExecuteWeight );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteResElL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-RDbView CUpnpMetadataStorage::GetViewOfObjectListForResL( const TDesC& aResVal )
-    {
-    HBufC* query = HBufC::NewLC( KSelectFromSqlCmd().Length( ) 
-                                + KElmObjIdColName().Length( ) 
-                                + KElementTableName().Length( ) 
-                                + KElmValueColName().Length( ) 
-                                + aResVal.Length( )
-                                + KNamedElFromElement().Length()
-                                + KRes16().Length());
-    TPtr queryPtr(query->Des( ));
-    queryPtr.Format( KSelectFromSqlCmd, &KElmObjIdColName,
-        &KElementTableName, &KElmValueColName, &aResVal );
-    queryPtr.AppendFormat( KNamedElFromElement, &KRes16 );
-
-    RDbView view = GetEvaluatedViewL( queryPtr );
-
-    CleanupStack::PopAndDestroy( query );
-
-    return view;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetViewOfElmIdByNameAndValLC
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-RDbView CUpnpMetadataStorage::GetViewOfElmIdByNameAndValL(
-    const TDesC& aElmName, const TDesC& aElmValue )
-    {
-    HBufC* resValReplaced16 = UpnpCdUtils::EscapeAposL( aElmValue );
-    HBufC* query = HBufC::NewLC( KSelectFromSqlCmd().Length( ) 
-                                + KElmIdColName().Length( ) 
-                                + KElementTableName().Length( ) 
-                                + KElmNameColName().Length( ) 
-                                + aElmName.Length( ) 
-                                + KAndConditionSqlCmd().Length( ) 
-                                + KElmValueColName().Length( ) 
-                                + resValReplaced16->Des().Length( ) );
-    TPtr queryPtr(query->Des( ));
-
-    // format query
-    queryPtr.Format( KSelectFromSqlCmd, &KElmIdColName, &KElementTableName,
-        &KElmNameColName, &aElmName );
-    queryPtr.AppendFormat( KAndConditionSqlCmd, &KElmValueColName,
-        resValReplaced16 );
-
-    RDbView view = GetEvaluatedViewL( queryPtr );
-
-    CleanupStack::PopAndDestroy( query );
-
-    delete resValReplaced16;
-    return view;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetAttrViewL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-RDbView CUpnpMetadataStorage::GetAttrViewL( const TDesC8& aAttrName,
-    const TDesC8& aAttrVal )
-    {
-    HBufC* attrNameBuf = UpnpCdUtils::Des8ToDesLC( aAttrName );
-    HBufC* attrValueBuf = UpnpCdUtils::Des8ToDesLC( aAttrVal );
-
-    HBufC* query = HBufC::NewLC( KSelectAttributeByValueSqlCmd().Length( ) + aAttrName.Length( ) + aAttrVal.Length( )
-
-    );
-    TPtr queryPtr(query->Des( ));
-
-    // format query
-    queryPtr.Format( KSelectAttributeByValueSqlCmd( ), attrValueBuf,
-        attrNameBuf );
-
-    RDbView view = GetEvaluatedViewL( queryPtr );
-
-    CleanupStack::PopAndDestroy( query );
-    CleanupStack::PopAndDestroy( attrValueBuf );
-    CleanupStack::PopAndDestroy( attrNameBuf );
-
-    return view;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetAttrViewL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-RDbView CUpnpMetadataStorage::GetAttrViewL( TInt aElmId,
-    const TDesC8& aAttrName )
-    {
-    // convert ot unicode
-    HBufC* attrNameBuf = UpnpCdUtils::Des8ToDesLC( aAttrName );
-
-    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
-                                 + KAtrValueColName().Length( ) 
-                                 + KAttributeTableName().Length( ) 
-                                 + KAtrElmIdColName().Length( ) 
-                                 + KMaxIntegerLen 
-                                 + KAndConditionSqlCmd().Length( ) 
-                                 + KAtrNameColName().Length( ) 
-                                 + aAttrName.Length( ) );
-    TPtr queryPtr(query->Des( ));
-    // prepare format string
-    HBufC* fmt = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) + KAndConditionSqlCmd().Length( ) );
-    TPtr fmtPtr(fmt->Des( ));
-    fmtPtr.Copy( KSelectFromNumSqlCmd );
-    fmtPtr.Append( KAndConditionSqlCmd );
-    // format query
-    queryPtr.Format( fmtPtr, &KAsterisk, &KAttributeTableName,
-        &KAtrElmIdColName, aElmId, &KAtrNameColName, attrNameBuf );
-
-    CleanupStack::PopAndDestroy( fmt );
-
-    RDbView view = GetEvaluatedViewL( queryPtr );
-
-    CleanupStack::PopAndDestroy( query );
-    CleanupStack::PopAndDestroy( attrNameBuf );
-
-    return view;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetAttrViewByObjectIdL
-// -----------------------------------------------------------------------------
-//
-RDbView CUpnpMetadataStorage::GetAttrViewByObjectIdL( TInt aObjectId,
-    const TDesC8& aAttrName )
-    {
-    // convert ot unicode
-    HBufC* attrNameBuf = UpnpCdUtils::Des8ToDesLC( aAttrName );
-
-    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
-                                 + KAtrValueColName().Length( ) 
-                                 + KAttributeTableName().Length( ) 
-                                 + KAtrIdObjColName().Length( ) 
-                                 + KMaxIntegerLen 
-                                 + KAndConditionSqlCmd().Length( ) 
-                                 + KAtrNameColName().Length( ) 
-                                 + aAttrName.Length( ) );
-    TPtr queryPtr(query->Des( ));
-    // prepare format string
-    HBufC* fmt = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) + KAndConditionSqlCmd().Length( ) );
-    TPtr fmtPtr(fmt->Des( ));
-    fmtPtr.Copy( KSelectFromNumSqlCmd );
-    fmtPtr.Append( KAndConditionSqlCmd );
-    // format query
-    queryPtr.Format( fmtPtr, &KAsterisk, &KAttributeTableName,
-        &KAtrIdObjColName, aObjectId, &KAtrNameColName, attrNameBuf );
-
-    CleanupStack::PopAndDestroy( fmt );
-
-    RDbView view = GetEvaluatedViewL( queryPtr );
-
-    CleanupStack::PopAndDestroy( query );
-    CleanupStack::PopAndDestroy( attrNameBuf );
-
-    return view;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::PrepareViewL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-RDbView CUpnpMetadataStorage::PrepareViewL( const TDesC& aSqlQuery )
-    {
-    RDbView view;
-    TInt dbErr = view.Prepare( iDatabase, TDbQuery( aSqlQuery ),
-        view.EReadOnly );
-    LOGSQL( "CUpnpMetadataStorage::GetViewL", "RDbView::Prepare", dbErr,
-        &aSqlQuery );
-    User::LeaveIfError( dbErr );
-
-    return view;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpContentDirectoryDb::GetEvaluatedViewL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-RDbView CUpnpMetadataStorage::GetEvaluatedViewL( const TDesC& aSqlQuery )
-    {
-    RDbView view = PrepareViewL( aSqlQuery );
-
-    // evaluate
-    TInt dbErr = view.EvaluateAll( );
-    LOGCD( "CUpnpMetadataStorage::GetViewLC", "RDbView::EvaluateAll", dbErr,
-        "" );
-    User::LeaveIfError( dbErr );
-
-    return view;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetObjectPathL 
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpMetadataStorage::GetObjectPathL( TInt aObjId )
-    {
-    HBufC8* ret = NULL;
-    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
-                                + KObjPathColName().Length( ) 
-                                + KObjectTableName().Length( ) 
-                                + KObjIdColName().Length( ) 
-                                + KMaxIntegerLen );
-    TPtr queryPtr(query->Des( ));
-    // format query
-    queryPtr.Format( KSelectFromNumSqlCmd, &KObjPathColName,
-        &KObjectTableName, &KObjIdColName, aObjId );
-
-    RDbView view;
-    CleanupClosePushL( view );
-    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
-        view.EReadOnly );
-    if ( dbErr == KErrNone )
-        {
-        User::LeaveIfError( view.EvaluateAll( ) );
-
-        CDbColSet* colSet = view.ColSetL( );
-        const TInt colNo = colSet->ColNo( KObjPathColName );
-        delete colSet;
-
-        if ( view.FirstL( ) )
-            {
-            view.GetL( );
-            if ( !view.IsColNull( colNo ) )
-                {
-                ret = view.ColDes8( colNo ).AllocL( );
-                }
-            }
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    CleanupStack::PopAndDestroy( query );
-    return ret;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetObjectTitleL 
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-HBufC8* CUpnpMetadataStorage::GetObjectTitleL( TInt aObjId )
-    {
-    HBufC8* ret = NULL;
-    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
-                                + KObjTiltleColName().Length( ) 
-                                + KObjectTableName().Length( ) 
-                                + KObjIdColName().Length( ) 
-                                + KMaxIntegerLen );
-    TPtr queryPtr(query->Des( ));
-    // format query
-    queryPtr.Format( KSelectFromNumSqlCmd, &KObjTiltleColName,
-        &KObjectTableName, &KObjIdColName, aObjId );
-
-    RDbView view;
-    CleanupClosePushL( view );
-    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
-        view.EReadOnly );
-    if ( dbErr == KErrNone )
-        {
-        User::LeaveIfError( view.EvaluateAll( ) );
-
-        CDbColSet* colSet = view.ColSetL( );
-        const TInt colNo = colSet->ColNo( KObjTiltleColName );
-        delete colSet;
-
-        if ( view.FirstL( ) )
-            {
-            view.GetL( );
-            if ( !view.IsColNull( colNo ) )
-                {
-                ret = view.ColDes8( colNo ).AllocL( );
-                }
-            }
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &view );
-    CleanupStack::PopAndDestroy( query );
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetResourceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-CUpnpResourcesBean* CUpnpMetadataStorage::GetResourceL( TInt64 aResId )
-    {
-    CUpnpResourcesBean* resBn = NULL;
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aResId);
-    User::LeaveIfError( table.Open( iDatabase, KResourcesTableName,
-        table.EUpdatable ) );
-    User::LeaveIfError( table.SetIndex( KRscIdIndexName ) ); // use index
-    if ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-        // table bean
-        resBn = CUpnpResourcesBean::NewL( table );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &table );
-    return resBn;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteResourceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::DeleteResourceByObjIdL( TInt aObjId,
-    TBool aDeleteFile )
-    {
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aObjId);
-    User::LeaveIfError( table.Open( iDatabase, KResourcesTableName,
-        table.EUpdatable ) );
-    User::LeaveIfError( table.SetIndex( KRscIdObjIndexName ) ); // use index
-    while ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-
-        // table bean
-        CUpnpResourcesBean* resBn = CUpnpResourcesBean::NewLC( table );
-
-        if ( aDeleteFile && !resBn->IsReadonly( ) && resBn->IsThumbnail( ) )
-            { // delete the file
-            DeleteFileL( resBn->Path( ) );
-            }
-
-        // clean up 
-        CleanupStack::PopAndDestroy( resBn );
-
-        // delete the row
-        table.DeleteL( );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &table );
-
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteResourceByResIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::DeleteResourceByResIdL( TInt64 aResId,
-    TBool aDeleteFile )
-    {
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aResId);
-    User::LeaveIfError( table.Open( iDatabase, KResourcesTableName,
-        table.EUpdatable ) );
-    User::LeaveIfError( table.SetIndex( KRscIdIndexName ) ); // use index
-    while ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-
-        // table bean
-        CUpnpResourcesBean* resBn = CUpnpResourcesBean::NewLC( table );
-
-        if ( aDeleteFile && !resBn->IsReadonly( ) && resBn->IsThumbnail( ) )
-            { // delete the file
-            DeleteFileL( resBn->Path( ) );
-            }
-
-        // clean up 
-        CleanupStack::PopAndDestroy( resBn );
-
-        // delete the row
-        table.DeleteL( );
-        }
-    // clean up
-    CleanupStack::PopAndDestroy( &table );
-
-    }
-//
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteObjectsL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-void CUpnpMetadataStorage::DeleteObjectsL( TInt aObjId )
-    {
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aObjId);
-    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
-        table.EUpdatable ) );
-    User::LeaveIfError( table.SetIndex( KObjIdIndexName ) ); // use index
-    if ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-
-        // delete the row
-        table.DeleteL( );
-        }
-    CleanupStack::PopAndDestroy( &table );
-    }
-//
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteReferencesL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-void CUpnpMetadataStorage::DeleteReferencesL( TInt aObjId,
-    RArray<TInt>& aRefList )
-    {
-    RDbTable table;
-    TInt ret( KErrNotFound );
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aObjId);
-    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
-        table.EUpdatable ) );
-    User::LeaveIfError( table.SetIndex( KRefIdIndexName ) ); // use index
-    while ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-        CDbColSet* colSet = table.ColSetL( );
-        CleanupStack::PushL( colSet );
-        TDbColNo colNo(colSet->ColNo( KObjParentIdColName ) );
-        ret = table.ColInt( colNo );
-        aRefList.AppendL( ret );
-        CleanupStack::PopAndDestroy( colSet );
-        // delete the row
-        table.DeleteL( );
-        }
-    CleanupStack::PopAndDestroy( &table );
-    }
-//
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteElementsL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-void CUpnpMetadataStorage::DeleteElementsL( TInt aObjId )
-    {
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aObjId);
-    User::LeaveIfError( table.Open( iDatabase, KElementTableName,
-        table.EUpdatable ) );
-    User::LeaveIfError( table.SetIndex( KElmObjIdIndexName ) ); // use index
-    while ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-
-        // delete the row
-        table.DeleteL( );
-        }
-    CleanupStack::PopAndDestroy( &table );
-    }
-//
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteAttributesL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-void CUpnpMetadataStorage::DeleteAttributesL( TInt aObjId )
-    {
-    RDbTable table;
-    CleanupClosePushL( table );
-    TDbSeekKey seekKey(aObjId);
-    User::LeaveIfError( table.Open( iDatabase, KAttributeTableName,
-        table.EUpdatable ) );
-    User::LeaveIfError( table.SetIndex( KAtrElmIdIndexName ) ); // use index
-    while ( table.SeekL( seekKey ) ) // find object
-        { // object found
-        table.GetL( );
-
-        // delete the row
-        table.DeleteL( );
-        }
-    CleanupStack::PopAndDestroy( &table );
-    }
-//
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::GetColDesValFromRowSetL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-HBufC8* CUpnpMetadataStorage::GetColDesValFromRowSetL( RDbRowSet aRowset,
-    TDbColNo aColNo )
-    {
-    TDbColType colType = aRowset.ColType( aColNo );
-    TBuf8<KMaxIntegerLen> val;
-    switch ( colType )
-        // so far only 2 types are possible
-        {
-        case EDbColBit:
-            val.Num( aRowset.ColUint8( aColNo ) );
-            break;
-        case EDbColInt32:
-        case EDbColInt16:
-        case EDbColInt8:
-            val.Num( aRowset.ColInt( aColNo ) );
-            break;
-        default:
-            User::Leave( KErrGeneral );
-        }
-    return val.AllocL( );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteFileL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::DeleteFileL( const TDesC& aPath )
-    {
-    iFsSession.Delete( aPath );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::InsertIntoObjectTableL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::InsertIntoObjectTableL( TInt aContainerId,
-    CUpnpObjectBean* aObjBn )
-    {
-    // open table
-    RDbTable table;
-    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
-        table.EUpdatable ) );
-    CleanupClosePushL( table );
-
-    // CdbColSet
-    CDbColSet* objColSet = table.ColSetL( );
-    CleanupStack::PushL( objColSet );
-
-    // rowset cursor to the beginning position
-    table.Reset( );
-
-    // insert empty row
-    table.InsertL( );
-
-    // object id
-    TInt objId = GetNextKeyL( KObjectTableName8 );
-    table.SetColL( objColSet->ColNo( KObjIdColName ), objId );
-
-    // parent id
-    table.SetColL( objColSet->ColNo( KObjParentIdColName ), aContainerId );
-
-    // restricted
-    table.SetColL( objColSet->ColNo( KObjRestrictedColName ),
-        aObjBn->ObjRestricted( ) );
-
-    // set title
-    table.SetColL( objColSet->ColNo( KObjTiltleColName ), aObjBn->ObjTitle( ) );
-
-    // set class
-    table.SetColL( objColSet->ColNo( KObjClassColName ), aObjBn->ObjClass( ) );
-
-    table.SetColL( objColSet->ColNo( KObjRefIdColName ), aObjBn->ObjRefId( ) );
-    // set path
-    HBufC8* path = CreatePathValL( aContainerId );
-    CleanupStack::PushL( path );
-    table.SetColL( objColSet->ColNo( KObjPathColName ), *path );
-
-    // complete insertion
-    table.PutL( );
-
-    DbChangedL( KExecuteWeight );
-
-    // clean up
-    CleanupStack::PopAndDestroy( path );
-    CleanupStack::PopAndDestroy( objColSet );
-    CleanupStack::PopAndDestroy( &table );
-
-    return objId;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::InsertIntoElementTableL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::InsertIntoElementTableL( TInt aObjId,
-    CUpnpElementBean* aElmBn, TInt aElmId )
-    {
-    // open table
-    RDbTable table;
-    User::LeaveIfError( table.Open( iDatabase, KElementTableName,
-        table.EUpdatable ) );
-    CleanupClosePushL( table );
-
-    // CdbColSet
-    CDbColSet* objColSet = table.ColSetL( );
-    CleanupStack::PushL( objColSet );
-
-    // rowset cursor to the beginning position
-    table.Reset( );
-
-    // insert empty row
-    table.InsertL( );
-
-    // elm_id
-    table.SetColL( objColSet->ColNo( KElmIdColName ), aElmId );
-
-    // elm_name
-    table.SetColL( objColSet->ColNo( KElmNameColName ), aElmBn->ElmName( ) );
-
-    // elm_value
-    if ( aElmBn->ElmValue().Length( ) )
-        {
-        // use write stream
-        RDbColWriteStream ws;
-        ws.OpenLC( table, objColSet->ColNo( KElmValueColName ) );
-        ws.WriteL( aElmBn->ElmValue( ) ); // write value
-        ws.CommitL( );
-        CleanupStack::PopAndDestroy( &ws );
-        }
-
-    // elm_has_attribute
-    table.SetColL( objColSet->ColNo( KElmHasAttrColName ),
-        aElmBn->ElmHasAttribute( ) );
-
-    // elm_obj_id
-    table.SetColL( objColSet->ColNo( KElmObjIdColName ), aObjId );
-
-    // elm_is_required
-    table.SetColL( objColSet->ColNo( KElmIsRequiredColName ),
-        aElmBn->ElmIsRequired( ) );
-
-    // complete insertion
-    table.PutL( );
-
-    DbChangedL( KExecuteWeight );
-
-    // clean up
-    CleanupStack::PopAndDestroy( objColSet );
-    CleanupStack::PopAndDestroy( &table );
-
-    return aElmId;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::InsertIntoAttributeTableL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::InsertIntoAttributeTableL( TInt aElmId,
-    CUpnpAttributeBean* aAtrBn, TInt aObjId, TInt aAtrId )
-    {
-    // open table
-    RDbTable table;
-    User::LeaveIfError( table.Open( iDatabase, KAttributeTableName,
-        table.EUpdatable ) );
-    CleanupClosePushL( table );
-
-    // CdbColSet
-    CDbColSet* objColSet = table.ColSetL( );
-    CleanupStack::PushL( objColSet );
-
-    // rowset cursor to the beginning position
-    table.Reset( );
-
-    // insert empty row
-    table.InsertL( );
-
-    // atr_id
-    table.SetColL( objColSet->ColNo( KAtrIdColName ), aAtrId ); // leaves if error
-
-    // atr_name
-    table.SetColL( objColSet->ColNo( KAtrNameColName ), aAtrBn->AtrName( ) ); // name cannot be null
-
-    // atr_value
-    if ( aAtrBn->AtrValue().Length( ) )
-        {
-        // use write stream
-        RDbColWriteStream ws;
-        ws.OpenLC( table, objColSet->ColNo( KAtrValueColName ) );
-        ws.WriteL( aAtrBn->AtrValue( ) ); // write value
-        ws.CommitL( );
-        CleanupStack::PopAndDestroy( &ws );
-        }
-
-    // atr_elm_id
-    table.SetColL( objColSet->ColNo( KAtrElmIdColName ), aElmId );
-
-    // atr_is_required
-    table.SetColL( objColSet->ColNo( KAtrIsRequiredColName ),
-        aAtrBn->AtrIsRequired( ) );
-
-    // atr_obj_id
-    table.SetColL( objColSet->ColNo( KAtrIdObjColName ), aObjId );
-
-    // complete insertion
-    table.PutL( );
-
-    DbChangedL( KExecuteWeight );
-
-    // clean up
-    CleanupStack::PopAndDestroy( objColSet );
-    CleanupStack::PopAndDestroy( &table );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpMetadataStorage::DeleteObjectL( TInt aObjId,
-    RArray<TInt>& aRefList, TBool aDeleteResource, TBool aLocal,
-    TBool aDeleteRef )
-    {
-    TUpnpErrorCode ret = ENoSuchObject;
-
-    // start transaction
-    BeginTransactionL( );
-
-    RArray<TInt> resList;
-    CleanupClosePushL( resList );
-    TInt delNumber = NULL;
-    TRAPD( err, delNumber = DoDeleteObjectL( aObjId, aRefList, resList,
-        aDeleteResource, aLocal, aDeleteRef ) );
-    if ( err )
-        { // rollback - error
-        RollbackTransactionL( );
-        User::Leave( err );
-        }
-    // commit if success
-    CommitTransactionL( );
-
-    // everything went OK, delete files
-    DeleteResourcesL( resList );
-
-    // clean up
-    CleanupStack::PopAndDestroy( &resList );
-
-    if ( delNumber )
-        {
-        ret = EUpnpOk;
-        }
-
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DoDeleteObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpMetadataStorage::DoDeleteObjectL( TInt aObjId,
-    TBool aDeleteResource, TBool aDeleteRef )
-    {
-    TUpnpErrorCode ret = ENoSuchObject;
-    RArray<TInt> ignore;
-    CleanupClosePushL( ignore );
-    if ( DoDeleteObjectL( aObjId, ignore, ignore, aDeleteResource, EFalse,
-        aDeleteRef ) )
-        {
-        ret = EUpnpOk;
-        }
-    CleanupStack::PopAndDestroy( &ignore );
-    return ret;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DoDeleteObjectL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::DoDeleteObjectL( TInt aObjId,
-    RArray<TInt>& aRefList, RArray<TInt>& aResList, TBool aDeleteResource,
-    TBool aLocal, TBool aDeleteRef )
-    {
-    TInt numberDeleted = NULL;
-    RArray<TInt> objList;
-    CleanupClosePushL( objList );
-
-    // prepare list of object and resources in the object to be deleted
-    if ( aDeleteResource )
-        {
-        AddSubObjectsL( aObjId, objList, aResList, aLocal );
-        }
-    else
-        {
-        objList.AppendL( aObjId );
-        }
-
-    // error if nothing can be deleted
-    if ( !objList.Count( ) )
-        {
-        User::Leave( ERestrictedObject );
-        }
-
-    // delete each object
-    for ( TInt i = 0; i < objList.Count( ); i++ )
-        {
-        DeleteObjectsL( objList[i] );
-        DeleteElementsL( objList[i] );
-        DeleteAttributesL( objList[i] );
-        if ( aDeleteRef )
-            {
-            DeleteReferencesL( objList[i], aRefList );
-            }
-
-        numberDeleted++;
-        }
-    CleanupStack::PopAndDestroy( &objList );
-
-    return numberDeleted;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::DeleteResourcesL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::DeleteResourcesL( RArray<TInt>& aObjList )
-    {
-    for ( TInt i = 0; i < aObjList.Count( ); i++ )
-        {
-        DeleteResourceByObjIdL( aObjList[i] );
-        }
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::AddSubObjectsL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::AddSubObjectsL( TInt aObjId,
-    RArray<TInt>& aObjList, RArray<TInt>& aResList, TBool aLocal )
-    {
-    // number of restricted objects in the subtree 
-    TInt mustRemain = 0;
-
-    // direct children
-    RArray<TInt> children;
-    CleanupClosePushL( children );
-    GetObjectListL( aObjId, children );
-
-    // for each children
-    for ( TInt i = 0; i < children.Count( ); i++ )
-        {
-        // next level
-        mustRemain
-                += AddSubObjectsL( children[i], aObjList, aResList, aLocal );
-        }
-
-    // clean up
-    CleanupStack::PopAndDestroy( &children );
-
-    if ( !aLocal ) // local api can delete even restricted objects
-        {
-        // restricted?
-        if ( CheckObjectRestrictionL( aObjId ) == ERestrictedObject )
-            {
-            mustRemain++;
-            }
-
-        // restricted parent?
-        if ( CheckParentRestrictionL( aObjId ) == ERestrictedObject )
-            {
-            mustRemain++;
-            }
-        }
-
-    // can be deleted?
-    if ( !mustRemain )
-        { // delete the object
-        // add currrent object
-        aObjList.AppendL( aObjId );
-        aResList.AppendL( aObjId );
-        }
-    return mustRemain;
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::CheckParentRestrictionL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TUpnpErrorCode CUpnpMetadataStorage::CheckParentRestrictionL( TInt aObjId )
-    {
-    TInt parentId = GetParentIdL( aObjId );
-    return CheckObjectRestrictionL( parentId );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::AddResourceL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::AddResourceL( CUpnpResourcesBean* aResBean,
-    TInt aObjId )
-    {
-    HBufC* resValReplaced16 = UpnpCdUtils::EscapeAposL( aResBean->Path( ) );
-
-    // prepare command
-    HBufC* sqlCommand = HBufC::NewLC( KInsertInto().Length( ) 
-                                      + KResourcesTableName().Length( ) 
-                                      + KOpenParant().Length( ) 
-                                      + KRscIdColName().Length( ) 
-                                      + KRscPathColName().Length( ) 
-                                      + KRscReadonlyColName().Length( ) 
-                                      + KRscThumbnailColName().Length( ) 
-                                      + KRscIdObjColName().Length( ) 
-                                      + KCloseParant().Length( ) 
-                                      + KValuesOpen().Length( ) 
-                                      + KMaxIntegerLen 
-                                      + resValReplaced16->Des().Length( ) 
-                                      + KMaxBoolLen 
-                                      + KMaxBoolLen 
-                                      + KMaxLongIntegerLen
-                                      + KCloseParant().Length( )  
-                                      + 2 * KQuot().Length( ) 
-                                      + 8 * KCommaStr().Length( ) ); // we need 4 commas and 2 quotation-marks
-
-    TPtr sqlCmdPtr(sqlCommand->Des( ));
-
-    TBuf<KMaxIntegerLen> num;
-    TBuf<KMaxLongIntegerLen> numLong;
-
-    sqlCmdPtr.Append( KInsertInto );
-    sqlCmdPtr.Append( KResourcesTableName );
-    sqlCmdPtr.Append( KOpenParant );
-    sqlCmdPtr.Append( KRscIdColName );
-    sqlCmdPtr.Append( KCommaStr );
-    sqlCmdPtr.Append( KRscPathColName );
-    sqlCmdPtr.Append( KCommaStr );
-    sqlCmdPtr.Append( KRscReadonlyColName );
-    sqlCmdPtr.Append( KCommaStr );
-    sqlCmdPtr.Append( KRscThumbnailColName );
-    sqlCmdPtr.Append( KCommaStr );
-    sqlCmdPtr.Append( KRscIdObjColName );
-    sqlCmdPtr.Append( KCloseParant );
-    sqlCmdPtr.Append( KValuesOpen );
-    numLong.Num( aResBean->Id( ) );
-    sqlCmdPtr.Append( numLong );
-    sqlCmdPtr.Append( KCommaStr );
-    sqlCmdPtr.Append( KQuot );
-    sqlCmdPtr.Append( *resValReplaced16 );
-    sqlCmdPtr.Append( KQuot );
-    sqlCmdPtr.Append( KCommaStr );
-    num.Num( aResBean->IsReadonly( ) );
-    sqlCmdPtr.Append( num );
-    sqlCmdPtr.Append( KCommaStr );
-    num.Num( aResBean->IsThumbnail( ) );
-    sqlCmdPtr.Append( num );
-    sqlCmdPtr.Append( KCommaStr );
-    num.Num( aObjId );
-    sqlCmdPtr.Append( num );
-    sqlCmdPtr.Append( KCloseParant );
-
-    delete resValReplaced16;
-    // execute
-    ExecuteL( sqlCmdPtr );
-    // clean up
-    CleanupStack::PopAndDestroy( sqlCommand );
-
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::RecoverDatabase
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::RecoverDatabase()
-    {
-    return iDatabase.Recover( );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::RecreateDatabaseFileL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::RecreateDatabaseFileL()
-    {
-    iDatabase.Close( );
-    iIsOpen = EFalse;
-
-    delete iFileStore;
-    iFileStore = NULL;
-
-    CUpnpCdDbFactory* cdf = CUpnpCdDbFactory::NewLC( );
-
-    // database file name
-    RFs fs;
-    CleanupClosePushL( fs );
-    User::LeaveIfError( fs.Connect( ) );
-
-    TFileName path;
-    User::LeaveIfError( fs.PrivatePath( path ) );
-    TParse fp;
-    fp.Set( KDatabaseFileName( ), &path, 0 );
-    path = fp.FullName( );
-
-    // recreate database file
-    cdf->CreateDatabaseFileL( path );
-
-    CleanupStack::PopAndDestroy( &fs );
-    CleanupStack::PopAndDestroy( cdf );
-
-    OpenDbL( path );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::CompareDbColSetsL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::CompareDbColSetsL( CDbColSet *aColSet1,
-    CDbColSet *aColSet2 )
-    {
-    if ( !aColSet1 || !aColSet1 )
-        User::Leave( KErrCorrupt );
-    if ( aColSet1->Count( ) != aColSet1->Count( ) )
-        User::Leave( KErrCorrupt );
-
-    for ( TInt i=1; i<=aColSet1->Count( ); i++ )
-        {
-        TBool foundColumn = EFalse;
-        const TDbCol& col1 = (*aColSet1)[i];
-
-        for ( TInt j=1; j<=aColSet2->Count( ); j++ )
-            {
-            const TDbCol& col2 = (*aColSet2)[j];
-            TInt cmpResult = col1.iName.Compare( col2.iName );
-
-            if ( cmpResult == 0 && !foundColumn )
-                {
-                foundColumn = ETrue;
-                if ( col1.iType != col2.iType )
-                    User::Leave( KErrCorrupt );
-                if ( !col1.IsLong( col1.iType ) && col1.iMaxLength
-                        != col2.iMaxLength )
-                    User::Leave( KErrCorrupt );
-                if ( col1.iAttributes != col2.iAttributes )
-                    User::Leave( KErrCorrupt );
-                }
-            else if ( cmpResult == 0 && foundColumn )
-                User::Leave( KErrCorrupt );
-            }
-        if ( !foundColumn )
-            User::Leave( KErrCorrupt );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::CheckDatabaseL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMetadataStorage::CheckDatabaseL()
-    {
-    CDbTableNames *tableNames = iDatabase.TableNamesL( );
-    CleanupStack::PushL( tableNames );
-
-    if ( !tableNames )
-        User::Leave( KErrCorrupt );
-    CUpnpCdDbFactory* cdf = CUpnpCdDbFactory::NewLC( );
-
-    for ( TInt i=0; i<tableNames->Count( ); i++ )
-        {
-        CDbColSet *colSetRef = NULL;
-
-        if ( (*tableNames)[i].Compare( KObjectTableName ) == 0 )
-            {
-            colSetRef = cdf->CreateObjectTableColumnSequenceLC( );
-            }
-        else if ( (*tableNames)[i].Compare( KElementTableName ) == 0 )
-            {
-            colSetRef = cdf->CreateElementTableColumnSequenceLC( );
-            }
-        else if ( (*tableNames)[i].Compare( KAttributeTableName ) == 0 )
-            {
-            colSetRef = cdf->CreateAttributeTableColumnSequenceLC( );
-            }
-        else if ( (*tableNames)[i].Compare( KResourcesTableName ) == 0 )
-            {
-            colSetRef = cdf->CreateResourceTableColumnSequenceLC( );
-            }
-        else if ( (*tableNames)[i].Compare( KSequencesTableName ) == 0 )
-            {
-            colSetRef = cdf->CreateSequenceTableColumnSequenceLC( );
-            }
-        else
-            User::Leave( KErrCorrupt );
-
-        CDbColSet *colSet = iDatabase.ColSetL( (*tableNames)[i] );
-        CleanupStack::PushL( colSet );
-
-        CompareDbColSetsL( colSet, colSetRef );
-
-        CleanupStack::PopAndDestroy( colSet );
-        CleanupStack::PopAndDestroy( colSetRef );
-        }
-
-    CleanupStack::PopAndDestroy( cdf );
-    CleanupStack::PopAndDestroy( tableNames );
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::HandleDbError
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpMetadataStorage::HandleDbError( TInt aError )
-    {
-    TInt err = aError;
-    if ( err == KErrCorrupt )
-        {
-        if ( iIsOpen )
-            {
-            err = RecoverDatabase( );
-            }
-        if ( err!=KErrNone && err!=KErrDiskFull && err!=KErrNoMemory )
-            {
-            TRAP( err, RecreateDatabaseFileL( ) );
-            if ( err )
-                {
-                iIsOpen = EFalse;
-                err = KErrCorrupt;
-                }
-            else
-                {
-                iIsOpen = ETrue;
-                }
-            }
-        }
-    return err;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMetadataStorage::IsDbCreated
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpMetadataStorage::IsDbCreated()
-    {
-    return iIsOpen;
-    }
-
-//  End of File  
+/** @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:  Metadata storage
+ *
+*/
+
+
+// INCLUDE FILES
+#include <upnpdominterface.h>
+#include "upnpmetadatastorage.h"
+#include "upnpcontentdirectoryglobals.h"
+#include "upnpobjectbean.h"
+#include "upnpelementbean.h"
+#include "upnpcdutils.h"
+#include "upnpresourcesbean.h"
+#include "upnpitem.h"
+#include "upnpelement.h"
+#include "upnpattributebean.h"
+#include "upnpcddbfactory.h"
+
+#define KLogFile _L("ContentDirectoryDb.log")
+#include "upnpcustomlog.h"
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::CUpnpMetadataStorage
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUpnpMetadataStorage::CUpnpMetadataStorage()
+    {
+
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::ConstructL( const TDesC& aDatabaseFileName )
+    {
+    User::LeaveIfError( iFsSession.Connect( ) );
+    OpenDbL( aDatabaseFileName );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpMetadataStorage* CUpnpMetadataStorage::NewLC(
+    const TDesC& aDatabaseFileName )
+    {
+    CUpnpMetadataStorage* self = new( ELeave ) CUpnpMetadataStorage();
+
+    CleanupStack::PushL( self );
+    self->ConstructL( aDatabaseFileName );
+
+    return self;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpMetadataStorage* CUpnpMetadataStorage::NewL(
+    const TDesC& aDatabaseFileName )
+    {
+    CUpnpMetadataStorage* self =
+            CUpnpMetadataStorage::NewLC( aDatabaseFileName );
+
+    CleanupStack::Pop( self );
+
+    return self;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::~CUpnpMetadataStorage
+// Destructor
+// -----------------------------------------------------------------------------
+//    
+CUpnpMetadataStorage::~CUpnpMetadataStorage()
+    {
+    if ( iIsOpen )
+        {
+        iDatabase.Compact( );
+        }
+    iDatabase.Close( );
+    delete iFileStore;
+    iFsSession.Close( );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::OpenDbL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::OpenDbL( const TFileName& aDatabaseFileName )
+    {
+    iFileStore = CPermanentFileStore::OpenL( iFsSession, aDatabaseFileName,
+        EFileRead|EFileWrite );
+    iFileStore->SetTypeL( iFileStore->Layout( ) );
+    iDatabase.OpenL( iFileStore, iFileStore->Root( ) );
+    CheckDatabaseL( );
+    iIsOpen = ETrue;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DbChangedL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::DbChangedL( TInt aWeight )
+    {
+    iCompactCounter += aWeight;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DbChangedL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::CompactDbL()
+    {
+    if ( iCompactCounter >= KCompactWeight )
+        {
+        iCompactCounter = 0;
+        User::LeaveIfError( iDatabase.Compact( ) );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::BeginTransactionL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::BeginTransactionL()
+    {
+    iDatabase.Begin( );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::CommitTransactionL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::CommitTransactionL()
+    {
+    TInt err = iDatabase.Commit( );
+    if ( err != KErrNone )
+        {
+        iDatabase.Rollback( );
+        User::LeaveIfError( iDatabase.Recover( ) );
+        User::Leave( err );
+        }
+    CompactDbL( );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::RollbackTransactionL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::RollbackTransactionL()
+    {
+    iDatabase.Rollback( );
+    User::LeaveIfError( iDatabase.Recover( ) );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetObjectListL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpMetadataStorage::GetObjectListL( TInt aParentId,
+    RArray<TInt>& aList )
+    {
+    TUpnpErrorCode ret = CheckObjectRestrictionL( aParentId ); // make sure the parent exists
+    if ( ret != ENoSuchObject && ret != ENoContainer )
+        {
+        // prepare query
+        TBuf<sizeof(KGetObjectListSqlCmd)/KCharSize + KMaxIntegerLen> query;
+        query.Format( KGetObjectListSqlCmd, aParentId );
+        // prepare view
+        RDbView view;
+        User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( query ),
+            view.EReadOnly ) );
+        CleanupClosePushL( view );
+        // evaluate
+        User::LeaveIfError( view.EvaluateAll( ) );
+        // for each object
+        const TInt KIdColNo=1;
+
+        while ( view.NextL( ) )
+            {
+            view.GetL( );
+            // get object
+            TInt childId = view.ColInt( KIdColNo );
+            aList.AppendL( childId );
+            }
+        //clean up
+        CleanupStack::PopAndDestroy( &view );
+        ret = EUpnpOk;
+        }
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetObjectListL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpMetadataStorage::GetItemListL( TInt aParentId,
+    RArray<TInt>& aList )
+    {
+    TUpnpErrorCode ret = CheckObjectRestrictionL( aParentId ); // make sure the parent exists
+    if ( ret != ENoSuchObject )
+        {
+        // prepare query
+        TBuf<sizeof(KGetItemListSqlCmd)/KCharSize + KMaxIntegerLen> query;
+        query.Format( KGetItemListSqlCmd, aParentId );
+        // prepare view
+        RDbView view;
+        User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( query ),
+            view.EReadOnly ) );
+        CleanupClosePushL( view );
+        // evaluate
+        User::LeaveIfError( view.EvaluateAll( ) );
+        // for each object
+        const TInt KIdColNo=1;
+        while ( view.NextL( ) )
+            {
+            view.GetL( );
+            // get object
+            TInt childId = view.ColInt( KIdColNo );
+            aList.AppendL( childId );
+            }
+        //clean up
+        CleanupStack::PopAndDestroy( &view );
+        ret = EUpnpOk;
+        }
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetContainerListL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpMetadataStorage::GetContainerListL( TInt aParentId,
+    RArray<TInt>& aList )
+    {
+    TUpnpErrorCode ret = CheckObjectRestrictionL( aParentId ); // make sure the parent exists
+    if ( ret != ENoSuchObject )
+        {
+        // prepare query
+        TBuf<sizeof(KGetContainerListSqlCmd)/KCharSize + KMaxIntegerLen> query;
+        query.Format( KGetContainerListSqlCmd, aParentId );
+        // prepare view
+        RDbView view;
+        User::LeaveIfError( view.Prepare( iDatabase, TDbQuery( query ),
+            view.EReadOnly ) );
+        CleanupClosePushL( view );
+        // evaluate
+        User::LeaveIfError( view.EvaluateAll( ) );
+        // for each object
+        const TInt KIdColNo=1;
+        while ( view.NextL( ) )
+            {
+            view.GetL( );
+            // get object
+            TInt childId = view.ColInt( KIdColNo );
+            aList.AppendL( childId );
+            }
+        //clean up
+        CleanupStack::PopAndDestroy( &view );
+        ret = EUpnpOk;
+        }
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::CheckObjectRestrictionL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpMetadataStorage::CheckObjectRestrictionL( TInt aObjId )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aObjId);
+    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
+        table.EReadOnly ) );
+    User::LeaveIfError( table.SetIndex( KObjIdIndexName ) ); // use index
+    if ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+
+        CDbColSet* colSet = table.ColSetL( );
+        TDbColNo colNo(colSet->ColNo( KObjRestrictedColName ) );
+        if ( !table.ColUint8( colNo ) ) // is restricted?
+            { // OK
+            TDbColNo colNo(colSet->ColNo( KObjClassColName ) );
+            if ( table.ColDes8(colNo).Find( KContainerClass8 ) == 0 ) // check whether the object is a container
+                { // this is a container
+                ret = EUpnpOk;
+                }
+            else
+                { // there is such object but this is not a container
+                ret = ENoContainer;
+                }
+            }
+        else
+            {
+            ret = ERestrictedObject;
+            }
+        delete colSet;
+        }
+    else
+        { // no such object
+        ret = ENoSuchObject;
+        }
+
+    CleanupStack::PopAndDestroy( &table );
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::CheckObjectRestrictionL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpMetadataStorage::IsContainerL( TInt aObjId )
+    {
+    TBool ret = EFalse;
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aObjId);
+    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
+        table.EReadOnly ) );
+    User::LeaveIfError( table.SetIndex( KObjIdIndexName ) ); // use index
+
+    if ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+
+        CDbColSet* colSet = table.ColSetL( );
+        TDbColNo colNo(colSet->ColNo( KObjClassColName ) );
+        if ( table.ColDes8(colNo).Find( KContainerClass8 ) == 0 ) // check whether the object is a container
+            { // this is a container
+            ret = ETrue;
+            }
+        delete colSet;
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &table );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::AddMainTagAttrL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+TUpnpErrorCode CUpnpMetadataStorage::AddMainTagAttrL(
+    TXmlEngElement aElement, TInt aId, const TDesC8& aName )
+    {
+    TUpnpErrorCode ret = EUpnpUndefined;
+    // xml string of name
+
+    // is the attr exist?
+    TXmlEngAttr atr = aElement.AttributeNodeL( aName );
+    if ( atr.IsNull( ) )
+        { // attr does not exist - add
+        TBuf<sizeof(KSelectFromObjectSqlCmd)/KCharSize +
+        KMaxIntegerLen + KColNameMaxLenth> query;
+        query.Format( KSelectFromObjectSqlCmd, &aName, aId );
+
+        // Execute command
+        RDbView view;
+        CleanupClosePushL( view );
+        TInt dbErr = view.Prepare( iDatabase, TDbQuery( query ),
+            view.EReadOnly );
+        LOGSQL( "CUpnpContentDirectoryDb::AddMainTagAttrL",
+            "RDbView::Prepare", dbErr, &query );
+        if ( dbErr == KErrNone )
+            {
+            CleanupClosePushL( view );
+            User::LeaveIfError( view.EvaluateAll( ) );
+
+            // if there is a row, add attribute
+            if ( view.FirstL( ) )
+                {
+                // get row
+                view.GetL( );
+                // col's val as Des
+                HBufC8* buff = GetColDesValFromRowSetL( view, 1 );
+                CleanupStack::PushL( buff );
+                // prepare xml string of value
+                // add attributes
+                aElement.AddNewAttributeL( aName, *buff );
+                ret = EUpnpOk;
+                // clean up
+                CleanupStack::PopAndDestroy( buff );
+                }
+            else
+                { // no such object in the database
+                ret = ENoSuchObject;
+                }
+            }
+        else
+            { // probably the name of the attr was wrong - ignore
+            ret = ENoSuchObject;
+            }
+        // clean up
+        CleanupStack::PopAndDestroy( &view );
+        }
+    else // if(!atr.IsNull())
+        { // already exists - it is OK, do not need to do anything
+        ret = EUpnpOk;
+        }
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetElementViewL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+RDbView CUpnpMetadataStorage::GetElementViewL( TInt aObjId,
+    const TDesC8& aElName )
+    {
+    // convert to TDesC
+    HBufC* elName = HBufC::NewLC( aElName.Length( ) );
+    elName->Des().Copy( aElName );
+
+    // Prepare SQL command
+    HBufC* query = HBufC::NewLC( KSelectElmFromElmSqlCmd().Length( ) 
+                                + KNamedElFromElement().Length( ) 
+                                + KMaxIntegerLen 
+                                + elName->Length( ) );
+    TPtr queryPtr(query->Des( ));
+    queryPtr.Format( KSelectElmFromElmSqlCmd, aObjId );
+    queryPtr.AppendFormat( KNamedElFromElement, elName );
+    
+
+    // Execute command
+    RDbView view = GetEvaluatedViewL( queryPtr );
+    LOGSQL( "CUpnpContentDirectoryDb::GetElementViewL", "RDbView::Prepare",
+        0, &queryPtr );
+    CleanupStack::PopAndDestroy( query );
+    CleanupStack::PopAndDestroy( elName );
+
+    return view;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::AddAttributeL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+
+RDbView CUpnpMetadataStorage::GetObjViewL( TInt aObjId )
+    {
+    // Get data from object table
+    // Prepare SQL command
+    TBuf<sizeof(KSelectObjectFromObjSqlCmd)/KCharSize
+    + KMaxIntegerLen> query;
+    query.Format( KSelectObjectFromObjSqlCmd, aObjId );
+
+    LOGSQL( "CUpnpContentDirectoryDb::GetObjectL", "", 0, &query );
+
+    return GetEvaluatedViewL( query );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::AddAttributeL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+RDbView CUpnpMetadataStorage::GetElementsViewL( TInt aObjectID, TBool aAll )
+    {
+    // Get data from element table
+    // Prepare SQL command
+    TBuf<sizeof(KSelectElmFromElmSqlCmd)/KCharSize
+    + sizeof(KOnlyRequiredFromElement)/KCharSize + KMaxIntegerLen> query;
+    query.Format( KSelectElmFromElmSqlCmd, aObjectID );
+
+    query.Format( KSelectElmFromElmSqlCmd, aObjectID );
+    if ( !aAll )
+        { // only required properties
+        query.Append( KOnlyRequiredFromElement );
+        }
+
+    LOGSQL( "CUpnpContentDirectoryDb::GetElementsViewL", "", 0, &query );
+
+    return GetEvaluatedViewL( query );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::AddAttributeL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+RDbView CUpnpMetadataStorage::GetAttributesViewL( TInt aElementID, TBool aAll )
+    {
+    // Get data from element table
+    // Prepare SQL command
+    TBuf<sizeof(KSelectAtrFromAttrSqlCmd)/KCharSize
+    + sizeof(KOnlyRequiredFromAtr)/KCharSize + KMaxIntegerLen> query;
+    query.Format( KSelectAtrFromAttrSqlCmd, aElementID );
+    if ( !aAll )
+        { // only required attr are wanted
+        query.Append( KOnlyRequiredFromAtr );
+        }
+
+    LOGSQL( "CUpnpContentDirectoryDb::GetAttributesViewL", "", 0, &query );
+
+    return GetEvaluatedViewL( query );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetAttributesViewByObjectIdL
+// -----------------------------------------------------------------------------
+//
+RDbView CUpnpMetadataStorage::GetAttributesViewByObjectIdL( TInt aObjectID,
+    TBool aAll )
+    {
+    // Get data from element table
+    // Prepare SQL command
+    TBuf<sizeof(KSelectAtrFromAttrByObjSqlCmd)/KCharSize
+    + sizeof(KOnlyRequiredFromAtr)/KCharSize + KMaxIntegerLen> query;
+    query.Format( KSelectAtrFromAttrByObjSqlCmd, aObjectID );
+    if ( !aAll )
+        { // only required attr are wanted
+        query.Append( KOnlyRequiredFromAtr );
+        }
+
+    LOGSQL( "CUpnpContentDirectoryDb::GetAttributesViewByObjectIdL", "", 0,
+        &query );
+
+    return GetEvaluatedViewL( query );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::InsertElementL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::InsertElementL( const TXmlEngElement& aElement,
+    TInt aObjId )
+    {
+    // open table
+    RDbTable table;
+    User::LeaveIfError( table.Open( iDatabase, KElementTableName,
+        table.EUpdatable ) );
+    CleanupClosePushL( table );
+
+    // CdbColSet
+    CDbColSet* objColSet = table.ColSetL( );
+    CleanupStack::PushL( objColSet );
+
+    // rowset cursor to the beginning position
+    table.Reset( );
+
+    // insert empty row
+    table.InsertL( );
+
+    // elm_id
+    TInt elmId = GetNextKeyL( KElementTableName8 );
+    table.SetColL( objColSet->ColNo( KElmIdColName ), elmId );
+
+    // elm_name
+    HBufC8 * elmName = UpnpCdUtils::GetElmNameWithNsL( aElement );
+    CleanupStack::PushL( elmName );
+    table.SetColL( objColSet->ColNo( KElmNameColName ), *elmName );
+    CleanupStack::PopAndDestroy( elmName );
+
+    // elm_value
+    if ( aElement.Value().Length( ) )
+        {
+        TPtrC8 elmValue(aElement.Value( ) );
+        if ( elmValue.Length( ) > KMaxUpnpLongStringLen )
+            { // too long
+            User::Leave( EActionFailed );
+            }
+        // use write stream
+        RDbColWriteStream ws;
+        ws.OpenLC( table, objColSet->ColNo( KElmValueColName ) );
+        ws.WriteL( elmValue ); // write value
+        ws.CommitL( );
+        CleanupStack::PopAndDestroy( &ws );
+        }
+
+    // elm_has_attribute
+    table.SetColL( objColSet->ColNo( KElmHasAttrColName ),
+        aElement.HasAttributes( ) );
+
+    // elm_obj_id
+    table.SetColL( objColSet->ColNo( KElmObjIdColName ), aObjId );
+
+    // elm_is_required
+    table.SetColL( objColSet->ColNo( KElmIsRequiredColName ),
+        UpnpCdUtils::IsElementRequiredL( aElement ) );
+
+    // complete insertion
+    table.PutL( );
+
+    DbChangedL( KExecuteWeight );
+
+    // clean up
+    CleanupStack::PopAndDestroy( objColSet );
+    CleanupStack::PopAndDestroy( &table );
+
+    return elmId;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::CreatePathValL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpMetadataStorage::CreatePathValL( const TXmlEngElement& aElement )
+    {
+    TPtrC8
+            parentIdPtr(UpnpDomInterface::GetAttrValueL( aElement, KParentID ));
+    TLex8 lexer(parentIdPtr);
+    TInt parentId;
+    User::LeaveIfError( lexer.Val( parentId ) );
+
+    return CreatePathValL( parentId );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::CreatePathValL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpMetadataStorage::CreatePathValL( TInt aParentId )
+    {
+    HBufC8* path = NULL;
+    User::LeaveIfNull( path = GetObjectPathL( aParentId ) );
+
+    CleanupStack::PushL( path );
+
+    HBufC8* tmp = HBufC8::NewL( path->Length( ) 
+                                + KPathSeparator().Length( ) 
+                                + KMaxIntegerLen );
+    TPtr8 tmpPtr(tmp->Des( ));
+    tmpPtr.Copy( *path );
+    tmpPtr.Append( KPathSeparator );
+
+    TBuf<KMaxIntegerLen> num;
+    num.Num( aParentId );
+    tmpPtr.Append( num );
+
+    CleanupStack::PopAndDestroy( path );
+
+    return tmp;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::InsertAttributeL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::InsertAttributeL( const TXmlEngAttr aAttr,
+    TInt aElmId, TBool aIsRequired, TInt aObjId )
+    {
+
+    // open table
+    RDbTable table;
+    User::LeaveIfError( table.Open( iDatabase, KAttributeTableName,
+        table.EUpdatable ) );
+    CleanupClosePushL( table );
+
+    // CdbColSet
+    CDbColSet* objColSet = table.ColSetL( );
+    CleanupStack::PushL( objColSet );
+
+    // rowset cursor to the beginning position
+    table.Reset( );
+
+    // insert empty row
+    table.InsertL( );
+
+    // atr_id
+    table.SetColL( objColSet->ColNo( KAtrIdColName ),
+        GetNextKeyL( KAttributeTableName8 ) ); // leaves if error
+
+    // atr_name
+    table.SetColL( objColSet->ColNo( KAtrNameColName ), aAttr.Name( ) ); // name cannot be null
+
+    // atr_value
+    if ( aAttr.Value().Length( ) )
+        {
+        TPtrC8 atrValue(aAttr.Value( ) );
+        if ( atrValue.Length( ) > KMaxUpnpLongStringLen )
+            { // too long
+            User::Leave( EActionFailed );
+            }
+        // use write stream
+        RDbColWriteStream ws;
+        ws.OpenLC( table, objColSet->ColNo( KAtrValueColName ) );
+        ws.WriteL( atrValue ); // write value
+        ws.CommitL( );
+        CleanupStack::PopAndDestroy( &ws );
+        }
+
+    // atr_elm_id
+    table.SetColL( objColSet->ColNo( KAtrElmIdColName ), aElmId );
+
+    // atr_is_required
+    table.SetColL( objColSet->ColNo( KAtrIsRequiredColName ), aIsRequired );
+
+    // atr_obj_id
+    table.SetColL( objColSet->ColNo( KAtrIdObjColName ), aObjId );
+
+    // complete insertion
+    table.PutL( );
+
+    DbChangedL( KExecuteWeight );
+
+    // clean up
+    CleanupStack::PopAndDestroy( objColSet );
+    CleanupStack::PopAndDestroy( &table );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::InsertObjectIntoObjectTableL
+// ?implementation_description
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::InsertObjectIntoObjectTableL(
+    const TXmlEngElement& aElement )
+    {
+    // open table
+    RDbTable table;
+    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
+        table.EUpdatable ) );
+    CleanupClosePushL( table );
+
+    // CdbColSet
+    CDbColSet* objColSet = table.ColSetL( );
+    CleanupStack::PushL( objColSet );
+
+    // rowset cursor to the beginning position
+    table.Reset( );
+
+    // insert empty row
+    table.InsertL( );
+
+    // set attributes
+    RXmlEngNodeList<TXmlEngAttr> attrList;
+    CleanupClosePushL( attrList );
+    aElement.GetAttributes( attrList );
+    while ( attrList.HasNext( ) )
+        {
+        // get next
+        TXmlEngAttr attr = attrList.Next( );
+
+        // col ordinal
+        HBufC* colName = HBufC::NewLC( attr.Name().Length( ) );
+        colName->Des().Copy( attr.Name( ) );
+        TDbColNo colNo = objColSet->ColNo( *colName );
+        CleanupStack::PopAndDestroy( colName );
+
+        // insert if exists
+        if ( colNo != KDbNullColNo )
+            { // (not any string attribute in the main element)
+            HBufC8* tmp = attr.Value().AllocLC( );
+            UpnpCdUtils::ReplaceTrueFalse( tmp );// true -> 1, false -> 0
+            TLex8 lexer(*tmp);
+            TInt num;
+            User::LeaveIfError( lexer.Val( num ) ); // string -> integer
+            // set value
+            table.SetColL( colNo, num );
+            CleanupStack::PopAndDestroy( tmp );
+            }
+        }
+    CleanupStack::Check( &attrList );
+
+    // set title
+    TXmlEngElement objTitle;
+    UpnpDomInterface::GetElementL( aElement, objTitle, KObjTiltleColName8( ) );
+    table.SetColL( objColSet->ColNo( KObjTiltleColName ), objTitle.Value( ) );
+    CleanupStack::Check( &attrList );
+
+    // set class
+    TXmlEngElement objClass;
+    UpnpDomInterface::GetElementL( aElement, objClass, KObjClassColName8( ) );
+    table.SetColL( objColSet->ColNo( KObjClassColName ), objClass.Value( ) );
+    CleanupStack::Check( &attrList );
+
+    // set path
+    HBufC8* path = CreatePathValL( aElement );
+    CleanupStack::PushL( path );
+    table.SetColL( objColSet->ColNo( KObjPathColName ), *path );
+    CleanupStack::PopAndDestroy( path );
+    CleanupStack::Check( &attrList );
+
+    // complete insertion
+    table.PutL( );
+
+    DbChangedL( KExecuteWeight );
+
+    // clean up
+    CleanupStack::PopAndDestroy( &attrList );
+    CleanupStack::PopAndDestroy( objColSet );
+    CleanupStack::PopAndDestroy( &table );
+
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetNextKeyForTableL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::GetNextKeyL( const TDesC8& aName )
+    {
+    TInt ret = KErrNotFound;
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aName);
+    User::LeaveIfError( table.Open( iDatabase, KSequencesTableName,
+        table.EUpdatable ) );
+    User::LeaveIfError( table.SetIndex( KSeqColNameIndexName ) ); // use index
+    if ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+        CDbColSet* colSet = table.ColSetL( );
+        CleanupStack::PushL( colSet );
+        TDbColNo colNo(colSet->ColNo( KSeqNextKeyColName ) );
+        ret = table.ColInt( colNo );
+        table.UpdateL( );
+        table.SetColL( colNo, ret + 1 );
+        table.PutL( );
+
+        DbChangedL( KExecuteWeight );
+
+        CleanupStack::PopAndDestroy( colSet );
+        }
+    else
+        { // no such object
+        User::Leave( KErrCorrupt );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &table );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetNextKeyForTableL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::GetNextKeyL( const TDesC8& aName, TInt aAmount )
+    {
+    TInt ret = KErrNotFound;
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aName);
+    User::LeaveIfError( table.Open( iDatabase, KSequencesTableName,
+        table.EUpdatable ) );
+    User::LeaveIfError( table.SetIndex( KSeqColNameIndexName ) ); // use index
+    if ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+        CDbColSet* colSet = table.ColSetL( );
+        CleanupStack::PushL( colSet );
+        TDbColNo colNo(colSet->ColNo( KSeqNextKeyColName ) );
+        ret = table.ColInt( colNo );
+        table.UpdateL( );
+        table.SetColL( colNo, ret + aAmount );
+        table.PutL( );
+
+        DbChangedL( KExecuteWeight );
+
+        CleanupStack::PopAndDestroy( colSet );
+        }
+    else
+        { // no such object
+        User::Leave( KErrCorrupt );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &table );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::NextKeyL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::NextKeyL( const TDesC8& aName )
+    {
+    TInt ret = KErrNotFound;
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aName);
+    User::LeaveIfError( table.Open( iDatabase, KSequencesTableName,
+        table.EReadOnly ) );
+    User::LeaveIfError( table.SetIndex( KSeqColNameIndexName ) ); // use index
+    if ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+        CDbColSet* colSet = table.ColSetL( );
+        CleanupStack::PushL( colSet );
+        TDbColNo colNo(colSet->ColNo( KSeqNextKeyColName ) );
+        ret = table.ColInt( colNo );
+
+        CleanupStack::PopAndDestroy( colSet );
+        }
+    else
+        { // no such object
+        User::Leave( KErrCorrupt );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &table );
+
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::ReferedObjectIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::ReferedObjectIdL( TInt aObjectId )
+    {
+    TInt ret = KErrNotFound;
+    TBuf<sizeof(KSelectFromObjectSqlCmd)/KCharSize
+    + KMaxIntegerLen + KColNameMaxLenth> query;
+    query.Format( KSelectFromObjectSqlCmd, &KObjRefIdColName, aObjectId );
+
+    // Execute command
+    RDbView view;
+    CleanupClosePushL( view );
+    TInt dbErr = view.Prepare( iDatabase, TDbQuery( query ), view.EReadOnly );
+    LOGSQL( "CUpnpContentDirectoryDb::ReferedObjectIdL", "RDbView::Prepare",
+        dbErr, &query );
+    if ( dbErr == KErrNone )
+        {
+        User::LeaveIfError( view.Evaluate( ) );
+        if ( view.FirstL( ) )
+            {
+            // get col number -  there can by only one column but just in case get by name
+            CDbColSet* colSet = view.ColSetL( );
+            const TInt colNo = colSet->ColNo( KObjRefIdColName );
+            delete colSet;
+
+            view.GetL( );
+            if ( !view.IsColNull( colNo ) )
+                {
+                ret = view.ColInt( colNo );
+                }
+            }
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetElmIdForAttrL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::GetElmIdForAttrL( const TDesC8& aAttrName,
+    const TDesC8& aAttrVal )
+    {
+    // convert to unicode
+    HBufC* attrName = UpnpCdUtils::Des8ToDesLC( aAttrName );
+    HBufC* attrVal = UpnpCdUtils::Des8ToDesLC( aAttrVal );
+
+    TInt elmId = KErrNotFound;
+    HBufC* query = HBufC::NewLC( aAttrVal.Length( ) 
+                                 + KSelectFromSqlCmd().Length( ) 
+                                 + KAtrElmIdColName().Length( ) 
+                                 + KAttributeTableName().Length( ) 
+                                 + KAtrValueColName().Length( ) 
+                                 + KAndConditionSqlCmd().Length( ) 
+                                 + KAtrNameColName().Length( ) 
+                                 + aAttrName.Length( ) );
+    TPtr queryPtr(query->Des( ));
+    // prepare format string
+    HBufC* fmt = HBufC::NewLC( KSelectFromSqlCmd().Length( ) + KAndConditionSqlCmd().Length( ) );
+    TPtr fmtPtr(fmt->Des( ));
+    fmtPtr.Copy( KSelectFromSqlCmd );
+    fmtPtr.Append( KAndConditionSqlCmd );
+    // format query
+    queryPtr.Format( fmtPtr, &KAtrElmIdColName, &KAttributeTableName,
+        &KAtrNameColName, attrName, &KAtrValueColName, attrVal );
+    // clean up format string
+    CleanupStack::PopAndDestroy( fmt );
+
+    RDbView view;
+    CleanupClosePushL( view );
+    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
+        view.EReadOnly );
+    if ( dbErr == KErrNone )
+        {
+        User::LeaveIfError( view.Evaluate( ) );
+        if ( view.FirstL( ) )
+            {
+            // get col number -  there can by only one column but just in case get by name
+            CDbColSet* colSet = view.ColSetL( );
+            const TInt colNo = colSet->ColNo( KAtrElmIdColName );
+            delete colSet;
+
+            view.GetL( );
+            if ( !view.IsColNull( colNo ) )
+                {
+                elmId = view.ColInt( colNo );
+                }
+            }
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    CleanupStack::PopAndDestroy( query );
+    CleanupStack::PopAndDestroy( attrVal );
+    CleanupStack::PopAndDestroy( attrName );
+    return elmId;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetObjIdForElmIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::GetObjIdForElmIdL( TInt aId )
+    {
+    TInt objId = KErrNotFound;
+    HBufC* query = HBufC::NewLC( KMaxIntegerLen + KSelectFromNumSqlCmd().Length( ) 
+                                + KElementTableName().Length( ) 
+                                + KElmObjIdColName().Length( ) 
+                                + KElmIdColName().Length( ) );
+    TPtr queryPtr(query->Des( ));
+    queryPtr.Format( KSelectFromNumSqlCmd, &KElmObjIdColName,
+        &KElementTableName, &KElmIdColName, aId );
+
+    RDbView view;
+    CleanupClosePushL( view );
+    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
+        view.EReadOnly );
+    if ( dbErr == KErrNone )
+        {
+        User::LeaveIfError( view.Evaluate( ) );
+        if ( view.FirstL( ) )
+            {
+            // get col number -  there can by only one column but just in case get by name
+            CDbColSet* colSet = view.ColSetL( );
+            const TInt colNo = colSet->ColNo( KElmObjIdColName );
+            delete colSet;
+
+            view.GetL( );
+            if ( !view.IsColNull( colNo ) )
+                {
+                objId = view.ColInt( colNo );
+                }
+            }
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    CleanupStack::PopAndDestroy( query );
+    return objId;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetObjIdByAttrLikeL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::GetElmIdForAttrLikeL( const TDesC8& aAttrName,
+    const TDesC8& aAttrVal )
+    {
+    //convert to unicode 
+    HBufC* attrVal = UpnpCdUtils::Des8ToDesLC( aAttrVal );
+    HBufC* attrName = UpnpCdUtils::Des8ToDesLC( aAttrName );
+
+    // query buf
+    TInt elmId = KErrNotFound;
+    HBufC* query = HBufC::NewLC( attrVal->Length( ) 
+                                + KSelectFromSqlCmd().Length( ) 
+                                + KAtrElmIdColName().Length( ) 
+                                + KAttributeTableName().Length( ) 
+                                + KAtrValueColName().Length( ) 
+                                + KAndLikeConditionSqlCmd().Length( ) 
+                                + KAtrNameColName().Length( ) 
+                                + attrName->Length( ) );
+    TPtr queryPtr(query->Des( ));
+    // prepare format string
+    HBufC* fmt = HBufC::NewLC( KSelectFromSqlCmd().Length( ) + KAndLikeConditionSqlCmd().Length( ) );
+    TPtr fmtPtr(fmt->Des( ));
+    fmtPtr.Copy( KSelectFromSqlCmd );
+    fmtPtr.Append( KAndLikeConditionSqlCmd );
+    // format query
+    queryPtr.Format( fmtPtr, &KAtrElmIdColName, &KAttributeTableName,
+        &KAtrNameColName, attrName, &KAtrValueColName, attrVal );
+    // clean up format string
+    CleanupStack::PopAndDestroy( fmt );
+
+    RDbView view;
+    CleanupClosePushL( view );
+    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
+        view.EReadOnly );
+    if ( dbErr == KErrNone )
+        {
+        User::LeaveIfError( view.Evaluate( ) );
+        if ( view.FirstL( ) )
+            {
+            // get col number -  there can by only one column but just in case get by name
+            CDbColSet* colSet = view.ColSetL( );
+            const TInt colNo = colSet->ColNo( KAtrElmIdColName );
+            delete colSet;
+
+            view.GetL( );
+            if ( !view.IsColNull( colNo ) )
+                {
+                elmId = view.ColInt( colNo );
+                }
+            }
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    CleanupStack::PopAndDestroy( query );
+    CleanupStack::PopAndDestroy( attrName );
+    CleanupStack::PopAndDestroy( attrVal );
+    return elmId;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetParentIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::GetParentIdL( TInt aObjId )
+    {
+    TInt objId=KErrGeneral;
+    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
+                                + KObjParentIdColName().Length( ) 
+                                + KObjectTableName().Length( ) 
+                                + KObjIdColName().Length( ) 
+                                + KMaxIntegerLen );
+    TPtr queryPtr(query->Des( ));
+    queryPtr.Format( KSelectFromNumSqlCmd, &KObjParentIdColName,
+        &KObjectTableName, &KObjIdColName, aObjId );
+
+    RDbView view;
+    CleanupClosePushL( view );
+    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
+        view.EReadOnly );
+    if ( dbErr == KErrNone )
+        {
+        User::LeaveIfError( view.Evaluate( ) );
+        if ( view.FirstL( ) )
+            {
+            CDbColSet* colSet = view.ColSetL( );
+            const TInt colNo = colSet->ColNo( KObjParentIdColName );
+            delete colSet;
+
+            view.GetL( );
+            if ( !view.IsColNull( colNo ) )
+                {
+                objId = view.ColInt( colNo );
+                }
+            }
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    CleanupStack::PopAndDestroy( query );
+    return objId;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetChildCountL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::GetChildCountL( TInt aObjId )
+    {
+    TInt childCount = KErrGeneral;
+
+    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
+                                 + KObjIdColName().Length( ) 
+                                 + KObjectTableName().Length( ) 
+                                 + KObjParentIdColName().Length( ) 
+                                 + KMaxIntegerLen );
+    TPtr queryPtr(query->Des( ));
+    queryPtr.Format( KSelectFromNumSqlCmd, &KObjIdColName, &KObjectTableName,
+        &KObjParentIdColName, aObjId );
+
+    RDbView view;
+    CleanupClosePushL( view );
+    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
+        view.EReadOnly );
+    if ( dbErr == KErrNone )
+        {
+        User::LeaveIfError( view.EvaluateAll( ) );
+        childCount = view.CountL( );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    CleanupStack::PopAndDestroy( query );
+    return childCount;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteResElL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::DeleteResElL( const TDesC& aResVal, TInt ObjId )
+    {
+    HBufC* query = HBufC::NewLC( KDeleteResElSqlCmd().Length( ) + aResVal.Length( ) + KMaxIntegerLen );
+    TPtr SqlCmd(query->Des( ));
+    SqlCmd.Format( KDeleteResElSqlCmd, &aResVal, ObjId );
+
+    // execute
+    ExecuteL( SqlCmd );
+
+    // clean up
+    CleanupStack::PopAndDestroy( query );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteResElL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::ExecuteL( const TDesC& aSqlCmd )
+    {
+    // execute
+    TInt err = iDatabase.Execute( aSqlCmd );
+    LOGSQL( "CUpnpContentDirectoryDb::DeleteResElL", "iDataBase.Execute",
+        err, &aSqlCmd );
+    User::LeaveIfError( err );
+
+    // db compact
+    DbChangedL( KExecuteWeight );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteResElL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+RDbView CUpnpMetadataStorage::GetViewOfObjectListForResL( const TDesC& aResVal )
+    {
+    HBufC* query = HBufC::NewLC( KSelectFromSqlCmd().Length( ) 
+                                + KElmObjIdColName().Length( ) 
+                                + KElementTableName().Length( ) 
+                                + KElmValueColName().Length( ) 
+                                + aResVal.Length( )
+                                + KNamedElFromElement().Length()
+                                + KRes16().Length());
+    TPtr queryPtr(query->Des( ));
+    queryPtr.Format( KSelectFromSqlCmd, &KElmObjIdColName,
+        &KElementTableName, &KElmValueColName, &aResVal );
+    queryPtr.AppendFormat( KNamedElFromElement, &KRes16 );
+
+    RDbView view = GetEvaluatedViewL( queryPtr );
+
+    CleanupStack::PopAndDestroy( query );
+
+    return view;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetViewOfElmIdByNameAndValLC
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+RDbView CUpnpMetadataStorage::GetViewOfElmIdByNameAndValL(
+    const TDesC& aElmName, const TDesC& aElmValue )
+    {
+    HBufC* resValReplaced16 = UpnpCdUtils::EscapeAposL( aElmValue );
+    HBufC* query = HBufC::NewLC( KSelectFromSqlCmd().Length( ) 
+                                + KElmIdColName().Length( ) 
+                                + KElementTableName().Length( ) 
+                                + KElmNameColName().Length( ) 
+                                + aElmName.Length( ) 
+                                + KAndConditionSqlCmd().Length( ) 
+                                + KElmValueColName().Length( ) 
+                                + resValReplaced16->Des().Length( ) );
+    TPtr queryPtr(query->Des( ));
+
+    // format query
+    queryPtr.Format( KSelectFromSqlCmd, &KElmIdColName, &KElementTableName,
+        &KElmNameColName, &aElmName );
+    queryPtr.AppendFormat( KAndConditionSqlCmd, &KElmValueColName,
+        resValReplaced16 );
+
+    RDbView view = GetEvaluatedViewL( queryPtr );
+
+    CleanupStack::PopAndDestroy( query );
+
+    delete resValReplaced16;
+    return view;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetAttrViewL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+RDbView CUpnpMetadataStorage::GetAttrViewL( const TDesC8& aAttrName,
+    const TDesC8& aAttrVal )
+    {
+    HBufC* attrNameBuf = UpnpCdUtils::Des8ToDesLC( aAttrName );
+    HBufC* attrValueBuf = UpnpCdUtils::Des8ToDesLC( aAttrVal );
+
+    HBufC* query = HBufC::NewLC( KSelectAttributeByValueSqlCmd().Length( ) + aAttrName.Length( ) + aAttrVal.Length( )
+
+    );
+    TPtr queryPtr(query->Des( ));
+
+    // format query
+    queryPtr.Format( KSelectAttributeByValueSqlCmd( ), attrValueBuf,
+        attrNameBuf );
+
+    RDbView view = GetEvaluatedViewL( queryPtr );
+
+    CleanupStack::PopAndDestroy( query );
+    CleanupStack::PopAndDestroy( attrValueBuf );
+    CleanupStack::PopAndDestroy( attrNameBuf );
+
+    return view;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetAttrViewL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+RDbView CUpnpMetadataStorage::GetAttrViewL( TInt aElmId,
+    const TDesC8& aAttrName )
+    {
+    // convert ot unicode
+    HBufC* attrNameBuf = UpnpCdUtils::Des8ToDesLC( aAttrName );
+
+    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
+                                 + KAtrValueColName().Length( ) 
+                                 + KAttributeTableName().Length( ) 
+                                 + KAtrElmIdColName().Length( ) 
+                                 + KMaxIntegerLen 
+                                 + KAndConditionSqlCmd().Length( ) 
+                                 + KAtrNameColName().Length( ) 
+                                 + aAttrName.Length( ) );
+    TPtr queryPtr(query->Des( ));
+    // prepare format string
+    HBufC* fmt = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) + KAndConditionSqlCmd().Length( ) );
+    TPtr fmtPtr(fmt->Des( ));
+    fmtPtr.Copy( KSelectFromNumSqlCmd );
+    fmtPtr.Append( KAndConditionSqlCmd );
+    // format query
+    queryPtr.Format( fmtPtr, &KAsterisk, &KAttributeTableName,
+        &KAtrElmIdColName, aElmId, &KAtrNameColName, attrNameBuf );
+
+    CleanupStack::PopAndDestroy( fmt );
+
+    RDbView view = GetEvaluatedViewL( queryPtr );
+
+    CleanupStack::PopAndDestroy( query );
+    CleanupStack::PopAndDestroy( attrNameBuf );
+
+    return view;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetAttrViewByObjectIdL
+// -----------------------------------------------------------------------------
+//
+RDbView CUpnpMetadataStorage::GetAttrViewByObjectIdL( TInt aObjectId,
+    const TDesC8& aAttrName )
+    {
+    // convert ot unicode
+    HBufC* attrNameBuf = UpnpCdUtils::Des8ToDesLC( aAttrName );
+
+    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
+                                 + KAtrValueColName().Length( ) 
+                                 + KAttributeTableName().Length( ) 
+                                 + KAtrIdObjColName().Length( ) 
+                                 + KMaxIntegerLen 
+                                 + KAndConditionSqlCmd().Length( ) 
+                                 + KAtrNameColName().Length( ) 
+                                 + aAttrName.Length( ) );
+    TPtr queryPtr(query->Des( ));
+    // prepare format string
+    HBufC* fmt = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) + KAndConditionSqlCmd().Length( ) );
+    TPtr fmtPtr(fmt->Des( ));
+    fmtPtr.Copy( KSelectFromNumSqlCmd );
+    fmtPtr.Append( KAndConditionSqlCmd );
+    // format query
+    queryPtr.Format( fmtPtr, &KAsterisk, &KAttributeTableName,
+        &KAtrIdObjColName, aObjectId, &KAtrNameColName, attrNameBuf );
+
+    CleanupStack::PopAndDestroy( fmt );
+
+    RDbView view = GetEvaluatedViewL( queryPtr );
+
+    CleanupStack::PopAndDestroy( query );
+    CleanupStack::PopAndDestroy( attrNameBuf );
+
+    return view;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::PrepareViewL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+RDbView CUpnpMetadataStorage::PrepareViewL( const TDesC& aSqlQuery )
+    {
+    RDbView view;
+    TInt dbErr = view.Prepare( iDatabase, TDbQuery( aSqlQuery ),
+        view.EReadOnly );
+    LOGSQL( "CUpnpMetadataStorage::GetViewL", "RDbView::Prepare", dbErr,
+        &aSqlQuery );
+    User::LeaveIfError( dbErr );
+
+    return view;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpContentDirectoryDb::GetEvaluatedViewL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+RDbView CUpnpMetadataStorage::GetEvaluatedViewL( const TDesC& aSqlQuery )
+    {
+    RDbView view = PrepareViewL( aSqlQuery );
+
+    // evaluate
+    TInt dbErr = view.EvaluateAll( );
+    LOGCD( "CUpnpMetadataStorage::GetViewLC", "RDbView::EvaluateAll", dbErr,
+        "" );
+    User::LeaveIfError( dbErr );
+
+    return view;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetObjectPathL 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpMetadataStorage::GetObjectPathL( TInt aObjId )
+    {
+    HBufC8* ret = NULL;
+    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
+                                + KObjPathColName().Length( ) 
+                                + KObjectTableName().Length( ) 
+                                + KObjIdColName().Length( ) 
+                                + KMaxIntegerLen );
+    TPtr queryPtr(query->Des( ));
+    // format query
+    queryPtr.Format( KSelectFromNumSqlCmd, &KObjPathColName,
+        &KObjectTableName, &KObjIdColName, aObjId );
+
+    RDbView view;
+    CleanupClosePushL( view );
+    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
+        view.EReadOnly );
+    if ( dbErr == KErrNone )
+        {
+        User::LeaveIfError( view.EvaluateAll( ) );
+
+        CDbColSet* colSet = view.ColSetL( );
+        const TInt colNo = colSet->ColNo( KObjPathColName );
+        delete colSet;
+
+        if ( view.FirstL( ) )
+            {
+            view.GetL( );
+            if ( !view.IsColNull( colNo ) )
+                {
+                ret = view.ColDes8( colNo ).AllocL( );
+                }
+            }
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    CleanupStack::PopAndDestroy( query );
+    return ret;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetObjectTitleL 
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+HBufC8* CUpnpMetadataStorage::GetObjectTitleL( TInt aObjId )
+    {
+    HBufC8* ret = NULL;
+    HBufC* query = HBufC::NewLC( KSelectFromNumSqlCmd().Length( ) 
+                                + KObjTiltleColName().Length( ) 
+                                + KObjectTableName().Length( ) 
+                                + KObjIdColName().Length( ) 
+                                + KMaxIntegerLen );
+    TPtr queryPtr(query->Des( ));
+    // format query
+    queryPtr.Format( KSelectFromNumSqlCmd, &KObjTiltleColName,
+        &KObjectTableName, &KObjIdColName, aObjId );
+
+    RDbView view;
+    CleanupClosePushL( view );
+    TInt dbErr = view.Prepare( iDatabase, TDbQuery( queryPtr ),
+        view.EReadOnly );
+    if ( dbErr == KErrNone )
+        {
+        User::LeaveIfError( view.EvaluateAll( ) );
+
+        CDbColSet* colSet = view.ColSetL( );
+        const TInt colNo = colSet->ColNo( KObjTiltleColName );
+        delete colSet;
+
+        if ( view.FirstL( ) )
+            {
+            view.GetL( );
+            if ( !view.IsColNull( colNo ) )
+                {
+                ret = view.ColDes8( colNo ).AllocL( );
+                }
+            }
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &view );
+    CleanupStack::PopAndDestroy( query );
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetResourceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+CUpnpResourcesBean* CUpnpMetadataStorage::GetResourceL( TInt64 aResId )
+    {
+    CUpnpResourcesBean* resBn = NULL;
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aResId);
+    User::LeaveIfError( table.Open( iDatabase, KResourcesTableName,
+        table.EUpdatable ) );
+    User::LeaveIfError( table.SetIndex( KRscIdIndexName ) ); // use index
+    if ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+        // table bean
+        resBn = CUpnpResourcesBean::NewL( table );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &table );
+    return resBn;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteResourceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::DeleteResourceByObjIdL( TInt aObjId,
+    TBool aDeleteFile )
+    {
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aObjId);
+    User::LeaveIfError( table.Open( iDatabase, KResourcesTableName,
+        table.EUpdatable ) );
+    User::LeaveIfError( table.SetIndex( KRscIdObjIndexName ) ); // use index
+    while ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+
+        // table bean
+        CUpnpResourcesBean* resBn = CUpnpResourcesBean::NewLC( table );
+
+        if ( aDeleteFile && !resBn->IsReadonly( ) && resBn->IsThumbnail( ) )
+            { // delete the file
+            DeleteFileL( resBn->Path( ) );
+            }
+
+        // clean up 
+        CleanupStack::PopAndDestroy( resBn );
+
+        // delete the row
+        table.DeleteL( );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &table );
+
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteResourceByResIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::DeleteResourceByResIdL( TInt64 aResId,
+    TBool aDeleteFile )
+    {
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aResId);
+    User::LeaveIfError( table.Open( iDatabase, KResourcesTableName,
+        table.EUpdatable ) );
+    User::LeaveIfError( table.SetIndex( KRscIdIndexName ) ); // use index
+    while ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+
+        // table bean
+        CUpnpResourcesBean* resBn = CUpnpResourcesBean::NewLC( table );
+
+        if ( aDeleteFile && !resBn->IsReadonly( ) && resBn->IsThumbnail( ) )
+            { // delete the file
+            DeleteFileL( resBn->Path( ) );
+            }
+
+        // clean up 
+        CleanupStack::PopAndDestroy( resBn );
+
+        // delete the row
+        table.DeleteL( );
+        }
+    // clean up
+    CleanupStack::PopAndDestroy( &table );
+
+    }
+//
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteObjectsL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CUpnpMetadataStorage::DeleteObjectsL( TInt aObjId )
+    {
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aObjId);
+    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
+        table.EUpdatable ) );
+    User::LeaveIfError( table.SetIndex( KObjIdIndexName ) ); // use index
+    if ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+
+        // delete the row
+        table.DeleteL( );
+        }
+    CleanupStack::PopAndDestroy( &table );
+    }
+//
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteReferencesL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CUpnpMetadataStorage::DeleteReferencesL( TInt aObjId,
+    RArray<TInt>& aRefList )
+    {
+    RDbTable table;
+    TInt ret( KErrNotFound );
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aObjId);
+    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
+        table.EUpdatable ) );
+    User::LeaveIfError( table.SetIndex( KRefIdIndexName ) ); // use index
+    while ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+        CDbColSet* colSet = table.ColSetL( );
+        CleanupStack::PushL( colSet );
+        TDbColNo colNo(colSet->ColNo( KObjParentIdColName ) );
+        ret = table.ColInt( colNo );
+        aRefList.Append( ret );
+        CleanupStack::PopAndDestroy( colSet );
+        // delete the row
+        table.DeleteL( );
+        }
+    CleanupStack::PopAndDestroy( &table );
+    }
+//
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteElementsL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CUpnpMetadataStorage::DeleteElementsL( TInt aObjId )
+    {
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aObjId);
+    User::LeaveIfError( table.Open( iDatabase, KElementTableName,
+        table.EUpdatable ) );
+    User::LeaveIfError( table.SetIndex( KElmObjIdIndexName ) ); // use index
+    while ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+
+        // delete the row
+        table.DeleteL( );
+        }
+    CleanupStack::PopAndDestroy( &table );
+    }
+//
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteAttributesL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+void CUpnpMetadataStorage::DeleteAttributesL( TInt aObjId )
+    {
+    RDbTable table;
+    CleanupClosePushL( table );
+    TDbSeekKey seekKey(aObjId);
+    User::LeaveIfError( table.Open( iDatabase, KAttributeTableName,
+        table.EUpdatable ) );
+    User::LeaveIfError( table.SetIndex( KAtrElmIdIndexName ) ); // use index
+    while ( table.SeekL( seekKey ) ) // find object
+        { // object found
+        table.GetL( );
+
+        // delete the row
+        table.DeleteL( );
+        }
+    CleanupStack::PopAndDestroy( &table );
+    }
+//
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::GetColDesValFromRowSetL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+HBufC8* CUpnpMetadataStorage::GetColDesValFromRowSetL( RDbRowSet aRowset,
+    TDbColNo aColNo )
+    {
+    TDbColType colType = aRowset.ColType( aColNo );
+    TBuf8<KMaxIntegerLen> val;
+    switch ( colType )
+        // so far only 2 types are possible
+        {
+        case EDbColBit:
+            val.Num( aRowset.ColUint8( aColNo ) );
+            break;
+        case EDbColInt32:
+        case EDbColInt16:
+        case EDbColInt8:
+            val.Num( aRowset.ColInt( aColNo ) );
+            break;
+        default:
+            User::Leave( KErrGeneral );
+        }
+    return val.AllocL( );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteFileL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::DeleteFileL( const TDesC& aPath )
+    {
+    iFsSession.Delete( aPath );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::InsertIntoObjectTableL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::InsertIntoObjectTableL( TInt aContainerId,
+    CUpnpObjectBean* aObjBn )
+    {
+    // open table
+    RDbTable table;
+    User::LeaveIfError( table.Open( iDatabase, KObjectTableName,
+        table.EUpdatable ) );
+    CleanupClosePushL( table );
+
+    // CdbColSet
+    CDbColSet* objColSet = table.ColSetL( );
+    CleanupStack::PushL( objColSet );
+
+    // rowset cursor to the beginning position
+    table.Reset( );
+
+    // insert empty row
+    table.InsertL( );
+
+    // object id
+    TInt objId = GetNextKeyL( KObjectTableName8 );
+    table.SetColL( objColSet->ColNo( KObjIdColName ), objId );
+
+    // parent id
+    table.SetColL( objColSet->ColNo( KObjParentIdColName ), aContainerId );
+
+    // restricted
+    table.SetColL( objColSet->ColNo( KObjRestrictedColName ),
+        aObjBn->ObjRestricted( ) );
+
+    // set title
+    table.SetColL( objColSet->ColNo( KObjTiltleColName ), aObjBn->ObjTitle( ) );
+
+    // set class
+    table.SetColL( objColSet->ColNo( KObjClassColName ), aObjBn->ObjClass( ) );
+
+    table.SetColL( objColSet->ColNo( KObjRefIdColName ), aObjBn->ObjRefId( ) );
+    // set path
+    HBufC8* path = CreatePathValL( aContainerId );
+    CleanupStack::PushL( path );
+    table.SetColL( objColSet->ColNo( KObjPathColName ), *path );
+
+    // complete insertion
+    table.PutL( );
+
+    DbChangedL( KExecuteWeight );
+
+    // clean up
+    CleanupStack::PopAndDestroy( path );
+    CleanupStack::PopAndDestroy( objColSet );
+    CleanupStack::PopAndDestroy( &table );
+
+    return objId;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::InsertIntoElementTableL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::InsertIntoElementTableL( TInt aObjId,
+    CUpnpElementBean* aElmBn, TInt aElmId )
+    {
+    // open table
+    RDbTable table;
+    User::LeaveIfError( table.Open( iDatabase, KElementTableName,
+        table.EUpdatable ) );
+    CleanupClosePushL( table );
+
+    // CdbColSet
+    CDbColSet* objColSet = table.ColSetL( );
+    CleanupStack::PushL( objColSet );
+
+    // rowset cursor to the beginning position
+    table.Reset( );
+
+    // insert empty row
+    table.InsertL( );
+
+    // elm_id
+    table.SetColL( objColSet->ColNo( KElmIdColName ), aElmId );
+
+    // elm_name
+    table.SetColL( objColSet->ColNo( KElmNameColName ), aElmBn->ElmName( ) );
+
+    // elm_value
+    if ( aElmBn->ElmValue().Length( ) )
+        {
+        // use write stream
+        RDbColWriteStream ws;
+        ws.OpenLC( table, objColSet->ColNo( KElmValueColName ) );
+        ws.WriteL( aElmBn->ElmValue( ) ); // write value
+        ws.CommitL( );
+        CleanupStack::PopAndDestroy( &ws );
+        }
+
+    // elm_has_attribute
+    table.SetColL( objColSet->ColNo( KElmHasAttrColName ),
+        aElmBn->ElmHasAttribute( ) );
+
+    // elm_obj_id
+    table.SetColL( objColSet->ColNo( KElmObjIdColName ), aObjId );
+
+    // elm_is_required
+    table.SetColL( objColSet->ColNo( KElmIsRequiredColName ),
+        aElmBn->ElmIsRequired( ) );
+
+    // complete insertion
+    table.PutL( );
+
+    DbChangedL( KExecuteWeight );
+
+    // clean up
+    CleanupStack::PopAndDestroy( objColSet );
+    CleanupStack::PopAndDestroy( &table );
+
+    return aElmId;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::InsertIntoAttributeTableL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::InsertIntoAttributeTableL( TInt aElmId,
+    CUpnpAttributeBean* aAtrBn, TInt aObjId, TInt aAtrId )
+    {
+    // open table
+    RDbTable table;
+    User::LeaveIfError( table.Open( iDatabase, KAttributeTableName,
+        table.EUpdatable ) );
+    CleanupClosePushL( table );
+
+    // CdbColSet
+    CDbColSet* objColSet = table.ColSetL( );
+    CleanupStack::PushL( objColSet );
+
+    // rowset cursor to the beginning position
+    table.Reset( );
+
+    // insert empty row
+    table.InsertL( );
+
+    // atr_id
+    table.SetColL( objColSet->ColNo( KAtrIdColName ), aAtrId ); // leaves if error
+
+    // atr_name
+    table.SetColL( objColSet->ColNo( KAtrNameColName ), aAtrBn->AtrName( ) ); // name cannot be null
+
+    // atr_value
+    if ( aAtrBn->AtrValue().Length( ) )
+        {
+        // use write stream
+        RDbColWriteStream ws;
+        ws.OpenLC( table, objColSet->ColNo( KAtrValueColName ) );
+        ws.WriteL( aAtrBn->AtrValue( ) ); // write value
+        ws.CommitL( );
+        CleanupStack::PopAndDestroy( &ws );
+        }
+
+    // atr_elm_id
+    table.SetColL( objColSet->ColNo( KAtrElmIdColName ), aElmId );
+
+    // atr_is_required
+    table.SetColL( objColSet->ColNo( KAtrIsRequiredColName ),
+        aAtrBn->AtrIsRequired( ) );
+
+    // atr_obj_id
+    table.SetColL( objColSet->ColNo( KAtrIdObjColName ), aObjId );
+
+    // complete insertion
+    table.PutL( );
+
+    DbChangedL( KExecuteWeight );
+
+    // clean up
+    CleanupStack::PopAndDestroy( objColSet );
+    CleanupStack::PopAndDestroy( &table );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpMetadataStorage::DeleteObjectL( TInt aObjId,
+    RArray<TInt>& aRefList, TBool aDeleteResource, TBool aLocal,
+    TBool aDeleteRef )
+    {
+    TUpnpErrorCode ret = ENoSuchObject;
+
+    // start transaction
+    BeginTransactionL( );
+
+    RArray<TInt> resList;
+    CleanupClosePushL( resList );
+    TInt delNumber = NULL;
+    TRAPD( err, delNumber = DoDeleteObjectL( aObjId, aRefList, resList,
+        aDeleteResource, aLocal, aDeleteRef ) );
+    if ( err )
+        { // rollback - error
+        RollbackTransactionL( );
+        User::Leave( err );
+        }
+    // commit if success
+    CommitTransactionL( );
+
+    // everything went OK, delete files
+    DeleteResourcesL( resList );
+
+    // clean up
+    CleanupStack::PopAndDestroy( &resList );
+
+    if ( delNumber )
+        {
+        ret = EUpnpOk;
+        }
+
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DoDeleteObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpMetadataStorage::DoDeleteObjectL( TInt aObjId,
+    TBool aDeleteResource, TBool aDeleteRef )
+    {
+    TUpnpErrorCode ret = ENoSuchObject;
+    RArray<TInt> ignore;
+    CleanupClosePushL( ignore );
+    if ( DoDeleteObjectL( aObjId, ignore, ignore, aDeleteResource, EFalse,
+        aDeleteRef ) )
+        {
+        ret = EUpnpOk;
+        }
+    CleanupStack::PopAndDestroy( &ignore );
+    return ret;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DoDeleteObjectL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::DoDeleteObjectL( TInt aObjId,
+    RArray<TInt>& aRefList, RArray<TInt>& aResList, TBool aDeleteResource,
+    TBool aLocal, TBool aDeleteRef )
+    {
+    TInt numberDeleted = NULL;
+    RArray<TInt> objList;
+    CleanupClosePushL( objList );
+
+    // prepare list of object and resources in the object to be deleted
+    if ( aDeleteResource )
+        {
+        AddSubObjectsL( aObjId, objList, aResList, aLocal );
+        }
+    else
+        {
+        objList.AppendL( aObjId );
+        }
+
+    // error if nothing can be deleted
+    if ( !objList.Count( ) )
+        {
+        User::Leave( ERestrictedObject );
+        }
+
+    // delete each object
+    for ( TInt i = 0; i < objList.Count( ); i++ )
+        {
+        DeleteObjectsL( objList[i] );
+        DeleteElementsL( objList[i] );
+        DeleteAttributesL( objList[i] );
+        if ( aDeleteRef )
+            {
+            DeleteReferencesL( objList[i], aRefList );
+            }
+
+        numberDeleted++;
+        }
+    CleanupStack::PopAndDestroy( &objList );
+
+    return numberDeleted;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::DeleteResourcesL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::DeleteResourcesL( RArray<TInt>& aObjList )
+    {
+    for ( TInt i = 0; i < aObjList.Count( ); i++ )
+        {
+        DeleteResourceByObjIdL( aObjList[i] );
+        }
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::AddSubObjectsL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::AddSubObjectsL( TInt aObjId,
+    RArray<TInt>& aObjList, RArray<TInt>& aResList, TBool aLocal )
+    {
+    // number of restricted objects in the subtree 
+    TInt mustRemain = 0;
+
+    // direct children
+    RArray<TInt> children;
+    CleanupClosePushL( children );
+    GetObjectListL( aObjId, children );
+
+    // for each children
+    for ( TInt i = 0; i < children.Count( ); i++ )
+        {
+        // next level
+        mustRemain
+                += AddSubObjectsL( children[i], aObjList, aResList, aLocal );
+        }
+
+    // clean up
+    CleanupStack::PopAndDestroy( &children );
+
+    if ( !aLocal ) // local api can delete even restricted objects
+        {
+        // restricted?
+        if ( CheckObjectRestrictionL( aObjId ) == ERestrictedObject )
+            {
+            mustRemain++;
+            }
+
+        // restricted parent?
+        if ( CheckParentRestrictionL( aObjId ) == ERestrictedObject )
+            {
+            mustRemain++;
+            }
+        }
+
+    // can be deleted?
+    if ( !mustRemain )
+        { // delete the object
+        // add currrent object
+        aObjList.AppendL( aObjId );
+        aResList.AppendL( aObjId );
+        }
+    return mustRemain;
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::CheckParentRestrictionL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TUpnpErrorCode CUpnpMetadataStorage::CheckParentRestrictionL( TInt aObjId )
+    {
+    TInt parentId = GetParentIdL( aObjId );
+    return CheckObjectRestrictionL( parentId );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::AddResourceL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::AddResourceL( CUpnpResourcesBean* aResBean,
+    TInt aObjId )
+    {
+    HBufC* resValReplaced16 = UpnpCdUtils::EscapeAposL( aResBean->Path( ) );
+
+    // prepare command
+    HBufC* sqlCommand = HBufC::NewLC( KInsertInto().Length( ) 
+                                      + KResourcesTableName().Length( ) 
+                                      + KOpenParant().Length( ) 
+                                      + KRscIdColName().Length( ) 
+                                      + KRscPathColName().Length( ) 
+                                      + KRscReadonlyColName().Length( ) 
+                                      + KRscThumbnailColName().Length( ) 
+                                      + KRscIdObjColName().Length( ) 
+                                      + KCloseParant().Length( ) 
+                                      + KValuesOpen().Length( ) 
+                                      + KMaxIntegerLen 
+                                      + resValReplaced16->Des().Length( ) 
+                                      + KMaxBoolLen 
+                                      + KMaxBoolLen 
+                                      + KMaxLongIntegerLen
+                                      + KCloseParant().Length( )  
+                                      + 2 * KQuot().Length( ) 
+                                      + 8 * KCommaStr().Length( ) ); // we need 4 commas and 2 quotation-marks
+
+    TPtr sqlCmdPtr(sqlCommand->Des( ));
+
+    TBuf<KMaxIntegerLen> num;
+    TBuf<KMaxLongIntegerLen> numLong;
+
+    sqlCmdPtr.Append( KInsertInto );
+    sqlCmdPtr.Append( KResourcesTableName );
+    sqlCmdPtr.Append( KOpenParant );
+    sqlCmdPtr.Append( KRscIdColName );
+    sqlCmdPtr.Append( KCommaStr );
+    sqlCmdPtr.Append( KRscPathColName );
+    sqlCmdPtr.Append( KCommaStr );
+    sqlCmdPtr.Append( KRscReadonlyColName );
+    sqlCmdPtr.Append( KCommaStr );
+    sqlCmdPtr.Append( KRscThumbnailColName );
+    sqlCmdPtr.Append( KCommaStr );
+    sqlCmdPtr.Append( KRscIdObjColName );
+    sqlCmdPtr.Append( KCloseParant );
+    sqlCmdPtr.Append( KValuesOpen );
+    numLong.Num( aResBean->Id( ) );
+    sqlCmdPtr.Append( numLong );
+    sqlCmdPtr.Append( KCommaStr );
+    sqlCmdPtr.Append( KQuot );
+    sqlCmdPtr.Append( *resValReplaced16 );
+    sqlCmdPtr.Append( KQuot );
+    sqlCmdPtr.Append( KCommaStr );
+    num.Num( aResBean->IsReadonly( ) );
+    sqlCmdPtr.Append( num );
+    sqlCmdPtr.Append( KCommaStr );
+    num.Num( aResBean->IsThumbnail( ) );
+    sqlCmdPtr.Append( num );
+    sqlCmdPtr.Append( KCommaStr );
+    num.Num( aObjId );
+    sqlCmdPtr.Append( num );
+    sqlCmdPtr.Append( KCloseParant );
+
+    delete resValReplaced16;
+    // execute
+    ExecuteL( sqlCmdPtr );
+    // clean up
+    CleanupStack::PopAndDestroy( sqlCommand );
+
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::RecoverDatabase
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::RecoverDatabase()
+    {
+    return iDatabase.Recover( );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::RecreateDatabaseFileL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::RecreateDatabaseFileL()
+    {
+    iDatabase.Close( );
+    iIsOpen = EFalse;
+
+    delete iFileStore;
+    iFileStore = NULL;
+
+    CUpnpCdDbFactory* cdf = CUpnpCdDbFactory::NewLC( );
+
+    // database file name
+    RFs fs;
+    CleanupClosePushL( fs );
+    User::LeaveIfError( fs.Connect( ) );
+
+    TFileName path;
+    User::LeaveIfError( fs.PrivatePath( path ) );
+    TParse fp;
+    fp.Set( KDatabaseFileName( ), &path, 0 );
+    path = fp.FullName( );
+
+    // recreate database file
+    cdf->CreateDatabaseFileL( path );
+
+    CleanupStack::PopAndDestroy( &fs );
+    CleanupStack::PopAndDestroy( cdf );
+
+    OpenDbL( path );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::CompareDbColSetsL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::CompareDbColSetsL( CDbColSet *aColSet1,
+    CDbColSet *aColSet2 )
+    {
+    if ( !aColSet1 || !aColSet1 )
+        User::Leave( KErrCorrupt );
+    if ( aColSet1->Count( ) != aColSet1->Count( ) )
+        User::Leave( KErrCorrupt );
+
+    for ( TInt i=1; i<=aColSet1->Count( ); i++ )
+        {
+        TBool foundColumn = EFalse;
+        const TDbCol& col1 = (*aColSet1)[i];
+
+        for ( TInt j=1; j<=aColSet2->Count( ); j++ )
+            {
+            const TDbCol& col2 = (*aColSet2)[j];
+            TInt cmpResult = col1.iName.Compare( col2.iName );
+
+            if ( cmpResult == 0 && !foundColumn )
+                {
+                foundColumn = ETrue;
+                if ( col1.iType != col2.iType )
+                    User::Leave( KErrCorrupt );
+                if ( !col1.IsLong( col1.iType ) && col1.iMaxLength
+                        != col2.iMaxLength )
+                    User::Leave( KErrCorrupt );
+                if ( col1.iAttributes != col2.iAttributes )
+                    User::Leave( KErrCorrupt );
+                }
+            else if ( cmpResult == 0 && foundColumn )
+                User::Leave( KErrCorrupt );
+            }
+        if ( !foundColumn )
+            User::Leave( KErrCorrupt );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::CheckDatabaseL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMetadataStorage::CheckDatabaseL()
+    {
+    CDbTableNames *tableNames = iDatabase.TableNamesL( );
+    CleanupStack::PushL( tableNames );
+
+    if ( !tableNames )
+        User::Leave( KErrCorrupt );
+    CUpnpCdDbFactory* cdf = CUpnpCdDbFactory::NewLC( );
+
+    for ( TInt i=0; i<tableNames->Count( ); i++ )
+        {
+        CDbColSet *colSetRef = NULL;
+
+        if ( (*tableNames)[i].Compare( KObjectTableName ) == 0 )
+            {
+            colSetRef = cdf->CreateObjectTableColumnSequenceLC( );
+            }
+        else if ( (*tableNames)[i].Compare( KElementTableName ) == 0 )
+            {
+            colSetRef = cdf->CreateElementTableColumnSequenceLC( );
+            }
+        else if ( (*tableNames)[i].Compare( KAttributeTableName ) == 0 )
+            {
+            colSetRef = cdf->CreateAttributeTableColumnSequenceLC( );
+            }
+        else if ( (*tableNames)[i].Compare( KResourcesTableName ) == 0 )
+            {
+            colSetRef = cdf->CreateResourceTableColumnSequenceLC( );
+            }
+        else if ( (*tableNames)[i].Compare( KSequencesTableName ) == 0 )
+            {
+            colSetRef = cdf->CreateSequenceTableColumnSequenceLC( );
+            }
+        else
+            User::Leave( KErrCorrupt );
+
+        CDbColSet *colSet = iDatabase.ColSetL( (*tableNames)[i] );
+        CleanupStack::PushL( colSet );
+
+        CompareDbColSetsL( colSet, colSetRef );
+
+        CleanupStack::PopAndDestroy( colSet );
+        CleanupStack::PopAndDestroy( colSetRef );
+        }
+
+    CleanupStack::PopAndDestroy( cdf );
+    CleanupStack::PopAndDestroy( tableNames );
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::HandleDbError
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpMetadataStorage::HandleDbError( TInt aError )
+    {
+    TInt err = aError;
+    if ( err == KErrCorrupt )
+        {
+        if ( iIsOpen )
+            {
+            err = RecoverDatabase( );
+            }
+        if ( err!=KErrNone && err!=KErrDiskFull && err!=KErrNoMemory )
+            {
+            TRAP( err, RecreateDatabaseFileL( ) );
+            if ( err )
+                {
+                iIsOpen = EFalse;
+                err = KErrCorrupt;
+                }
+            else
+                {
+                iIsOpen = ETrue;
+                }
+            }
+        }
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMetadataStorage::IsDbCreated
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpMetadataStorage::IsDbCreated()
+    {
+    return iIsOpen;
+    }
+
+//  End of File  
--- a/upnpmediaserver/contentdirectoryservice/src/upnpmspathutility.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnpmspathutility.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,457 +1,472 @@
-/*
-* Copyright (c) 2002-2007 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:  Utility class to get path related info for the media files
-*/
-
-// INCLUDE FILES
-#include <bautils.h>    
-#include <upnpstring.h>
-#include <upnpdlnaprotocolinfo.h>
-#include <pathinfo.h>
-#include <centralrepository.h>
-
-#include "upnpmspathutility.h"
-#include "upnpcontentdirectoryglobals.h"
-#include "upnpcdutils.h"
-#include "upnpdominterface.h"
-
-// CONSTANTS
-_LIT( KYearMonthDayFormat,        "%04d\\%02d\\%02d\\");
-_LIT( KArtistFormat,              "%S\\");
-_LIT( KAlbumFormat,               "%S\\");
-_LIT( KBackSlash,                 "\\");
-_LIT( KSlashData,                 "\\Data\\");
-_LIT( KUnknown,                   "Unknown");
-
-_LIT( KSeparator,                 ":" );
-_LIT( KNullTime,                  "000000" );
-
-_LIT8( KMimeAudio,                "audio" );
-_LIT8( KMimeVideo,                "video" );
-_LIT8( KMimeImage,                "image" );
-_LIT8( KMimePlaylist,             "audio/mpegurl" );
-
-
-const TUid KCRUidMediaServer   = { 0x101F978F };
-const TInt KDateStringLength        = 10;
-const TInt KDateTimeStringLength    = 19;
-const TInt KMaxDateStringLength     = 30;
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// ---------------------------------------------------------------------------
-// CUPnPMSPathUtility::CUPnPMSPathUtility
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// ---------------------------------------------------------------------------
-//
-CUPnPMSPathUtility::CUPnPMSPathUtility()
-    {
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPMSPathUtility::NewL
-// Two-phased constructor.
-// ---------------------------------------------------------------------------
-//
-CUPnPMSPathUtility* CUPnPMSPathUtility::NewL()
-    {
-    CUPnPMSPathUtility* self = CUPnPMSPathUtility::NewLC();
-    CleanupStack::Pop();
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPMSPathUtility::NewLC
-// Two-phased constructor.
-// ---------------------------------------------------------------------------
-//
-CUPnPMSPathUtility* CUPnPMSPathUtility::NewLC()
-    {
-    CUPnPMSPathUtility* self = new( ELeave ) CUPnPMSPathUtility;
-    CleanupStack::PushL( self );
-    self->ConstructL( KCRUidMediaServer );
-       return self;
-    }
-
-// ---------------------------------------------------------------------------
-// CUPnPMSPathUtility::ConstructL
-// Symbian 2nd phase constructor can leave.
-// ---------------------------------------------------------------------------
-//
-void CUPnPMSPathUtility::ConstructL(TUid aRepositoryUid)
-    {
-    iRepository = CRepository::NewL(aRepositoryUid);
-    }
-    
-// ---------------------------------------------------------------------------
-// CUPnPMSPathUtility::~CUPnPMSPathUtility()
-// Destructor
-// ---------------------------------------------------------------------------
-//
-CUPnPMSPathUtility::~CUPnPMSPathUtility()
-    {
-    delete iRepository;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::GetCopyPathDriveL
-// Gets the drive for the copy operation
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-void CUPnPMSPathUtility::GetCopyPathDriveL( 
-             TDriveNumber& aDrive ) const
-    {
-    HBufC* location = HBufC::NewL(KMaxFileName);
-    CleanupStack::PushL( location );
-
-    TPtr locPtr = location->Des();
-    
-    // Get the location setting from ServerSettings
-    iRepository->Get( EUploadDirectory, locPtr );
-
-    // Check to see if drive is ready.
-    TVolumeInfo volInfo;
-    TDriveUnit driveUnit = TDriveUnit( locPtr );
-    
-    RFs fileServer;
-    User::LeaveIfError( fileServer.Connect() );
-    CleanupClosePushL( fileServer );
-    User::LeaveIfError( fileServer.Volume( volInfo, driveUnit ) );
-    CleanupStack::PopAndDestroy( &fileServer );
-
-    aDrive = (TDriveNumber)((TInt)driveUnit);
-
-    CleanupStack::PopAndDestroy( location );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::GetCopyPathL
-// Returns the path of the upnp item to be copied
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-HBufC* CUPnPMSPathUtility::GetCopyPathL(
-                        const TXmlEngElement& aItem,
-                        CUpnpDlnaProtocolInfo& aProInfo ) const
-    {
-    TDriveNumber drive;
-    GetCopyPathDriveL( drive );   
-    return GetCreateCopyPathL( aItem, 
-                               aProInfo, 
-                               EFalse,
-                               drive );
-    }   
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::CreateCopyPathL
-// Returns the path of the upnp item to be copied
-// Creates the path if necessary and appends the filename and extension if
-// required
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-HBufC* CUPnPMSPathUtility::CreateCopyPathL(
-                const TXmlEngElement& aItem,
-                CUpnpDlnaProtocolInfo& aProInfo ) const
-    {
-    TDriveNumber drive;
-    GetCopyPathDriveL( drive );
-    return GetCreateCopyPathL( aItem, 
-                               aProInfo, 
-                               ETrue,
-                               drive );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::GetCreateCopyPathL
-// Returns the path of the upnp item to be copied
-// Creates the path if necessary and appends the filename and extension if
-// required
-// (other items were commented in a header).
-// --------------------------------------------------------------------------
-//
-HBufC* CUPnPMSPathUtility::GetCreateCopyPathL(
-               const TXmlEngElement& aItem,
-               CUpnpDlnaProtocolInfo& aProInfo,
-               TBool aCreatePath,
-               TDriveNumber aDriveNumber ) const
-    {
-       
-    HBufC* path = HBufC::NewLC( KMaxPath );
-    TPtr refPath = path->Des();
-    
-    TDriveUnit driveUnit = TDriveUnit( aDriveNumber );
-    AppendDataL( refPath, driveUnit.Name() );
-    if ( EDriveC == driveUnit )
-        {
-        //C:\\Data\\(Images/Videos/Sounds)....
-        AppendDataL( refPath, KSlashData );
-        }
-    else
-        {
-        //\\(Images/Videos/Sounds)....
-        AppendDataL( refPath, KBackSlash );
-        }
-    
-    // Get the protocolinfo-attribute
-    TUPnPItemType fileType = FileTypeByMimeTypeL( 
-            aProInfo.ThirdField() );
-    
-    switch( fileType )
-        {
-        case ETypeAudio:
-            {
-            AppendDataL( refPath, PathInfo::SoundsPath() );
-            AppendArtistAlbumL( refPath, aItem );
-            break;
-            }
-        case ETypeVideo:
-            {
-            AppendDataL( refPath, PathInfo::VideosPath() );
-            AppendYearMonthDayL( refPath, aItem );
-            break;
-            }
-        case ETypeImage:
-            {
-            AppendDataL( refPath, PathInfo::ImagesPath() );
-            AppendYearMonthDayL( refPath, aItem );
-            break;
-            }
-        case ETypePlaylist:
-        case ETypeOther:
-        default:
-            {
-            AppendDataL( refPath, PathInfo::OthersPath() );
-            }                
-        }
-    if( aCreatePath )
-        {
-        RFs fs;
-        User::LeaveIfError( fs.Connect() );
-        CleanupClosePushL(fs);
-        BaflUtils::EnsurePathExistsL( fs, refPath );
-        CleanupStack::PopAndDestroy(&fs);
-        }
-    CleanupStack::Pop( path );
-    
-    return path;
-    }   
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::FileTypeByMimeTypeL
-// Get the file type based on MIME type of the file. Leaves in error cases.
-// --------------------------------------------------------------------------
-CUPnPMSPathUtility::TUPnPItemType CUPnPMSPathUtility::FileTypeByMimeTypeL(
-        const TDesC8& aMimeType ) const
-    {
-    TUPnPItemType returnValue = ETypeOther;
-
-    if( aMimeType != KNullDesC8 )
-        {
-        if( aMimeType.Find( KMimeImage() ) >= 0 )
-            {
-            returnValue = ETypeImage;
-            }
-        else if( aMimeType.Find( KMimePlaylist() ) >= 0 )
-            {
-            returnValue = ETypePlaylist;
-            }
-        else if( aMimeType.Find( KMimeAudio() ) >= 0 )
-            {
-            returnValue = ETypeAudio;
-            }
-        else if( aMimeType.Find( KMimeVideo() ) >= 0 )
-            {
-            returnValue = ETypeVideo;
-            }
-        else
-            {
-            returnValue = ETypeOther;
-            }
-        }
-    else
-        {
-        User::Leave( KErrArgument );
-        }
-
-    return returnValue;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::AppendYearMonthDayL
-// Appends year, month and day to the path.
-// --------------------------------------------------------------------------
-//
-void CUPnPMSPathUtility::AppendYearMonthDayL( 
-        TDes& aPath, const TXmlEngElement& aItem ) const
-    {  
-    // Get the date-element
-    TXmlEngElement dateElem;
-    UpnpDomInterface::GetElementL( aItem, dateElem, KDate8 );
-    TTime date; date.HomeTime();
-    if ( !dateElem.IsNull( ) )
-        {
-        UPnPDateAsTTimeL( dateElem.Value(), date );
-        }     
-    
-    TDateTime ymd = date.DateTime();
-    CheckBufferSpaceL( aPath, 11 ); //4(year)+2(month)+2(day)+3(\)
-    
-    aPath.AppendFormat( KYearMonthDayFormat(), 
-            ymd.Year(), ymd.Month()+1, ymd.Day()+1 );
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::AppendArtistAlbumL
-// Appends artist and album to the path.
-// --------------------------------------------------------------------------
-//
-void CUPnPMSPathUtility::AppendArtistAlbumL( 
-        TDes& aPath, const TXmlEngElement& aItem ) const
-    {
-    
-    // Get the artist-element
-    TXmlEngElement artistElem;
-    UpnpDomInterface::GetElementL( aItem, artistElem, KArtist );
-    if ( !artistElem.IsNull( )  )
-        {
-        HBufC* artist = UpnpString::ToUnicodeL( artistElem.Value() );
-        CleanupStack::PushL( artist );
-        
-        TPtr ptrArtist = artist->Des();
-        UpnpCdUtils::ValidateFilePath( ptrArtist );
-        
-        CheckBufferSpaceL( aPath, artist->Length()+1 );// 1 for '\'          
-        aPath.AppendFormat( KArtistFormat(), artist );
-        
-        CleanupStack::PopAndDestroy( artist );
-        }
-    else
-        {
-        CheckBufferSpaceL( aPath, KUnknown().Length()+1 );  // 1 for '\'       
-        aPath.AppendFormat( KArtistFormat(), &KUnknown() );
-        }
-    
-    // Get the album-element
-    TXmlEngElement albumElem;
-    UpnpDomInterface::GetElementL( aItem, albumElem, KAlbum );
-    if ( !albumElem.IsNull( ) )
-        {
-        HBufC* album = UpnpString::ToUnicodeL( albumElem.Value() );
-        CleanupStack::PushL( album );
-        
-        TPtr ptrAlbum = album->Des();
-        UpnpCdUtils::ValidateFilePath( ptrAlbum );
-        
-        CheckBufferSpaceL( aPath, album->Length()+1 );// 1 for '\'
-        aPath.AppendFormat( KAlbumFormat(), album );
-        CleanupStack::PopAndDestroy( album );
-        }
-    else
-        {
-        CheckBufferSpaceL( aPath, KUnknown().Length()+1 );  // 1 for '\'       
-        aPath.AppendFormat( KAlbumFormat(), &KUnknown() );
-        }
-    
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::AppendDataL
-// Appends data to the path's buffer.
-// --------------------------------------------------------------------------
-//
-void CUPnPMSPathUtility::AppendDataL( 
-        TDes& aPath, const TDesC& aData ) const
-    {  
-    CheckBufferSpaceL( aPath, aData );
-    aPath.Append( aData );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::CheckBufferSpaceL
-// Checks whether the data can be appended to buffer or not.
-// --------------------------------------------------------------------------
-//
-void CUPnPMSPathUtility::CheckBufferSpaceL( 
-        const TDes& aPath, const TDesC& aData ) const
-    {
-    CheckBufferSpaceL( aPath, aData.Length() );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::CheckBufferSpaceL
-// Checks whether the data of the specified length
-// can be appended to buffer or not.
-// --------------------------------------------------------------------------
-//
-void CUPnPMSPathUtility::CheckBufferSpaceL( 
-        const TDes& aPath, const TInt& aLength ) const
-    {  
-    if ( (aPath.Length() + aLength) > aPath.MaxLength() )
-        {
-        User::Leave( KErrOverflow );
-        }
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPMSPathUtility::UPnPDateAsTTimeL
-// Converts upnp date to TTime object.
-//---------------------------------------------------------------------------
-void CUPnPMSPathUtility::UPnPDateAsTTimeL( const TDesC8& aUpnpDate,
-    TTime& aTime ) const
-    {
-    // This method is capable of handling the most common dc:date formats:
-    // CCYY-MM-DD and CCYY-MM-DDThh:mm:ss
-    // Rest of the dc:date formats are handled as well, but they might not
-    // be converted precisely
-    
-    TBuf<KMaxDateStringLength> formatDateString;
-    HBufC* dateString = HBufC::NewL( aUpnpDate.Length() );
-    dateString->Des().Copy( aUpnpDate );
-
-    if( aUpnpDate.Length() >= KDateStringLength )
-        {
-        // CCYY-MM-DD --> CCYYMMDD
-        formatDateString.Copy( dateString->Des().Left( 4 ) ); // Year
-        formatDateString.Append( dateString->Des().Mid( 5,2 ) ); // Month
-        formatDateString.Append( dateString->Des().Mid( 8,2 ) ); // Day        
-
-        if( aUpnpDate.Length() >= KDateTimeStringLength )
-            {
-            // hh:mm:ss --> hhmmss
-            formatDateString.Append( KSeparator );
-            // Hours
-            formatDateString.Append( dateString->Des().Mid( 11, 2 ) ); 
-            // Minutes
-            formatDateString.Append( dateString->Des().Mid( 14, 2 ) );
-            // Seconds 
-            formatDateString.Append( dateString->Des().Mid( 17, 2 ) ); 
-            }
-        else
-            {
-            // hh:mm:ss --> 000000
-            formatDateString.Append( KSeparator );
-            formatDateString.Append( KNullTime );
-            }
-        }
-    delete dateString;
-    
-    User::LeaveIfError( aTime.Set( formatDateString ) );
-    }
-
-//  End of File  
+/*
+* Copyright (c) 2002-2007 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:  Utility class to get path related info for the media files
+*/
+
+// INCLUDE FILES
+#include <bautils.h>    
+#include <upnpstring.h>
+#include <upnpdlnaprotocolinfo.h>
+#include <pathinfo.h>
+#include <CentralRepository.h>
+
+#include "upnpmspathutility.h"
+#include "upnpcontentdirectoryglobals.h"
+#include "upnpcdutils.h"
+#include "upnpdominterface.h"
+
+// CONSTANTS
+_LIT( KYearMonthDayFormat,        "%04d\\%02d\\%02d\\");
+_LIT( KArtistFormat,              "%S\\");
+_LIT( KAlbumFormat,               "%S\\");
+_LIT( KBackSlash,                 "\\");
+_LIT( KSlashData,                 "\\Data\\");
+_LIT( KUnknown,                   "Unknown");
+
+_LIT( KSeparator,                 ":" );
+_LIT( KNullTime,                  "000000" );
+
+_LIT8( KMimeAudio,                "audio" );
+_LIT8( KMimeVideo,                "video" );
+_LIT8( KMimeImage,                "image" );
+_LIT8( KMimePlaylist,             "audio/mpegurl" );
+
+#if defined(__HN_31__) || defined(__HN_32__)
+const TUid KHnCRUidMediaServer = { 0x2000f87f }; //for parallel stack
+#else
+const TUid KCRUidMediaServer   = { 0x101F978F };
+#endif
+
+const TInt KDateStringLength        = 10;
+const TInt KDateTimeStringLength    = 19;
+const TInt KMaxDateStringLength     = 30;
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// ---------------------------------------------------------------------------
+// CUPnPMSPathUtility::CUPnPMSPathUtility
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// ---------------------------------------------------------------------------
+//
+CUPnPMSPathUtility::CUPnPMSPathUtility()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPMSPathUtility::NewL
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CUPnPMSPathUtility* CUPnPMSPathUtility::NewL()
+    {
+    CUPnPMSPathUtility* self = CUPnPMSPathUtility::NewLC();
+    CleanupStack::Pop();
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPMSPathUtility::NewLC
+// Two-phased constructor.
+// ---------------------------------------------------------------------------
+//
+CUPnPMSPathUtility* CUPnPMSPathUtility::NewLC()
+    {
+    CUPnPMSPathUtility* self = new( ELeave ) CUPnPMSPathUtility;
+    CleanupStack::PushL( self );
+    #if defined(__HN_31__) || defined(__HN_32__)
+    self->ConstructL( KHnCRUidMediaServer );
+    #else
+    self->ConstructL( KCRUidMediaServer );
+    #endif    
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// CUPnPMSPathUtility::ConstructL
+// Symbian 2nd phase constructor can leave.
+// ---------------------------------------------------------------------------
+//
+void CUPnPMSPathUtility::ConstructL(TUid aRepositoryUid)
+    {
+    iRepository = CRepository::NewL(aRepositoryUid);
+    }
+    
+// ---------------------------------------------------------------------------
+// CUPnPMSPathUtility::~CUPnPMSPathUtility()
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CUPnPMSPathUtility::~CUPnPMSPathUtility()
+    {
+    delete iRepository;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::GetCopyPathDriveL
+// Gets the drive for the copy operation
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+void CUPnPMSPathUtility::GetCopyPathDriveL( 
+             TDriveNumber& aDrive ) const
+    {
+    HBufC* location = HBufC::NewL(KMaxFileName);
+    CleanupStack::PushL( location );
+
+    TPtr locPtr = location->Des();
+    
+    // Get the location setting from ServerSettings
+    iRepository->Get( EUploadDirectory, locPtr );
+
+    // Check to see if drive is ready.
+    TVolumeInfo volInfo;
+    TDriveUnit driveUnit = TDriveUnit( locPtr );
+    
+    RFs fileServer;
+    User::LeaveIfError( fileServer.Connect() );
+    CleanupClosePushL( fileServer );
+    User::LeaveIfError( fileServer.Volume( volInfo, driveUnit ) );
+    CleanupStack::PopAndDestroy( &fileServer );
+
+    aDrive = (TDriveNumber)((TInt)driveUnit);
+
+    CleanupStack::PopAndDestroy( location );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::GetCopyPathL
+// Returns the path of the upnp item to be copied
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+HBufC* CUPnPMSPathUtility::GetCopyPathL(
+                        const TXmlEngElement& aItem,
+                        CUpnpDlnaProtocolInfo& aProInfo ) const
+    {
+    TDriveNumber drive;
+    GetCopyPathDriveL( drive );   
+    return GetCreateCopyPathL( aItem, 
+                               aProInfo, 
+                               EFalse,
+                               drive );
+    }   
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::CreateCopyPathL
+// Returns the path of the upnp item to be copied
+// Creates the path if necessary and appends the filename and extension if
+// required
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+HBufC* CUPnPMSPathUtility::CreateCopyPathL(
+                const TXmlEngElement& aItem,
+                CUpnpDlnaProtocolInfo& aProInfo ) const
+    {
+    TDriveNumber drive;
+    GetCopyPathDriveL( drive );
+    return GetCreateCopyPathL( aItem, 
+                               aProInfo, 
+                               ETrue,
+                               drive );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::GetCreateCopyPathL
+// Returns the path of the upnp item to be copied
+// Creates the path if necessary and appends the filename and extension if
+// required
+// (other items were commented in a header).
+// --------------------------------------------------------------------------
+//
+HBufC* CUPnPMSPathUtility::GetCreateCopyPathL(
+               const TXmlEngElement& aItem,
+               CUpnpDlnaProtocolInfo& aProInfo,
+               TBool aCreatePath,
+               TDriveNumber aDriveNumber ) const
+    {
+       
+    HBufC* path = HBufC::NewLC( KMaxPath );
+    TPtr refPath = path->Des();
+    
+    TDriveUnit driveUnit = TDriveUnit( aDriveNumber );
+    AppendDataL( refPath, driveUnit.Name() );
+    if ( EDriveC == driveUnit )
+        {
+        //C:\\Data\\(Images/Videos/Sounds)....
+        AppendDataL( refPath, KSlashData );
+        }
+    else
+        {
+        //\\(Images/Videos/Sounds)....
+        AppendDataL( refPath, KBackSlash );
+        }
+    
+    // Get the protocolinfo-attribute
+    TUPnPItemType fileType = FileTypeByMimeTypeL( 
+            aProInfo.ThirdField() );
+    
+    switch( fileType )
+        {
+        case ETypeAudio:
+            {
+            AppendDataL( refPath, PathInfo::SoundsPath() );
+            AppendArtistAlbumL( refPath, aItem );
+            break;
+            }
+        case ETypeVideo:
+            {
+            AppendDataL( refPath, PathInfo::VideosPath() );
+            AppendYearMonthDayL( refPath, aItem );
+            break;
+            }
+        case ETypeImage:
+            {
+            AppendDataL( refPath, PathInfo::ImagesPath() );
+            AppendYearMonthDayL( refPath, aItem );
+            break;
+            }
+        case ETypePlaylist:
+        case ETypeOther:
+        default:
+            {
+            AppendDataL( refPath, PathInfo::OthersPath() );
+            }                
+        }
+    if( aCreatePath )
+        {
+        RFs fs;
+        User::LeaveIfError( fs.Connect() );
+        CleanupClosePushL(fs);
+        BaflUtils::EnsurePathExistsL( fs, refPath );
+        CleanupStack::PopAndDestroy(&fs);
+        }
+    CleanupStack::Pop( path );
+    
+    return path;
+    }   
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::FileTypeByMimeTypeL
+// Get the file type based on MIME type of the file. Leaves in error cases.
+// --------------------------------------------------------------------------
+CUPnPMSPathUtility::TUPnPItemType CUPnPMSPathUtility::FileTypeByMimeTypeL(
+        const TDesC8& aMimeType ) const
+    {
+    TUPnPItemType returnValue = ETypeOther;
+
+    if( aMimeType != KNullDesC8 )
+        {
+        if( aMimeType.Find( KMimeImage() ) >= 0 )
+            {
+            returnValue = ETypeImage;
+            }
+        else if( aMimeType.Find( KMimePlaylist() ) >= 0 )
+            {
+            returnValue = ETypePlaylist;
+            }
+        else if( aMimeType.Find( KMimeAudio() ) >= 0 )
+            {
+            returnValue = ETypeAudio;
+            }
+        else if( aMimeType.Find( KMimeVideo() ) >= 0 )
+            {
+            returnValue = ETypeVideo;
+            }
+        else
+            {
+            returnValue = ETypeOther;
+            }
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    return returnValue;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::AppendYearMonthDayL
+// Appends year, month and day to the path.
+// --------------------------------------------------------------------------
+//
+void CUPnPMSPathUtility::AppendYearMonthDayL( 
+        TDes& aPath, const TXmlEngElement& aItem ) const
+    {  
+    // Get the date-element
+    TXmlEngElement dateElem;
+    UpnpDomInterface::GetElementL( aItem, dateElem, KDate8 );
+    
+    TTime date; date.HomeTime();
+    TInt offsetMonthDay = 1;
+    // Use date element time instead of current time,
+    // if element exist
+    if ( !dateElem.IsNull() )
+        {
+        UPnPDateAsTTimeL( dateElem.Value(), date );
+        offsetMonthDay = 0;
+        }
+    
+    TDateTime ymd = date.DateTime();
+    CheckBufferSpaceL( aPath, 11 ); //4(year)+2(month)+2(day)+3(\)
+        
+    aPath.AppendFormat( KYearMonthDayFormat(), 
+            ymd.Year(), 
+            ymd.Month() + offsetMonthDay, 
+            ymd.Day() + offsetMonthDay );
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::AppendArtistAlbumL
+// Appends artist and album to the path.
+// --------------------------------------------------------------------------
+//
+void CUPnPMSPathUtility::AppendArtistAlbumL( 
+        TDes& aPath, const TXmlEngElement& aItem ) const
+    {
+    
+    // Get the artist-element
+    TXmlEngElement artistElem;
+    UpnpDomInterface::GetElementL( aItem, artistElem, KArtist );
+    if ( !artistElem.IsNull( )  )
+        {
+        HBufC* artist = UpnpString::ToUnicodeL( artistElem.Value() );
+        CleanupStack::PushL( artist );
+        
+        TPtr ptrArtist = artist->Des();
+        UpnpCdUtils::ValidateFilePath( ptrArtist );
+        
+        CheckBufferSpaceL( aPath, artist->Length()+1 );// 1 for '\'          
+        aPath.AppendFormat( KArtistFormat(), artist );
+        
+        CleanupStack::PopAndDestroy( artist );
+        }
+    else
+        {
+        CheckBufferSpaceL( aPath, KUnknown().Length()+1 );  // 1 for '\'       
+        aPath.AppendFormat( KArtistFormat(), &KUnknown() );
+        }
+    
+    // Get the album-element
+    TXmlEngElement albumElem;
+    UpnpDomInterface::GetElementL( aItem, albumElem, KAlbum );
+    if ( !albumElem.IsNull( ) )
+        {
+        HBufC* album = UpnpString::ToUnicodeL( albumElem.Value() );
+        CleanupStack::PushL( album );
+        
+        TPtr ptrAlbum = album->Des();
+        UpnpCdUtils::ValidateFilePath( ptrAlbum );
+        
+        CheckBufferSpaceL( aPath, album->Length()+1 );// 1 for '\'
+        aPath.AppendFormat( KAlbumFormat(), album );
+        CleanupStack::PopAndDestroy( album );
+        }
+    else
+        {
+        CheckBufferSpaceL( aPath, KUnknown().Length()+1 );  // 1 for '\'       
+        aPath.AppendFormat( KAlbumFormat(), &KUnknown() );
+        }
+    
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::AppendDataL
+// Appends data to the path's buffer.
+// --------------------------------------------------------------------------
+//
+void CUPnPMSPathUtility::AppendDataL( 
+        TDes& aPath, const TDesC& aData ) const
+    {  
+    CheckBufferSpaceL( aPath, aData );
+    aPath.Append( aData );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::CheckBufferSpaceL
+// Checks whether the data can be appended to buffer or not.
+// --------------------------------------------------------------------------
+//
+void CUPnPMSPathUtility::CheckBufferSpaceL( 
+        const TDes& aPath, const TDesC& aData ) const
+    {
+    CheckBufferSpaceL( aPath, aData.Length() );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::CheckBufferSpaceL
+// Checks whether the data of the specified length
+// can be appended to buffer or not.
+// --------------------------------------------------------------------------
+//
+void CUPnPMSPathUtility::CheckBufferSpaceL( 
+        const TDes& aPath, const TInt& aLength ) const
+    {  
+    if ( (aPath.Length() + aLength) > aPath.MaxLength() )
+        {
+        User::Leave( KErrOverflow );
+        }
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPMSPathUtility::UPnPDateAsTTimeL
+// Converts upnp date to TTime object.
+//---------------------------------------------------------------------------
+void CUPnPMSPathUtility::UPnPDateAsTTimeL( const TDesC8& aUpnpDate,
+    TTime& aTime ) const
+    {
+    // This method is capable of handling the most common dc:date formats:
+    // CCYY-MM-DD and CCYY-MM-DDThh:mm:ss
+    // Rest of the dc:date formats are handled as well, but they might not
+    // be converted precisely
+    
+    TBuf<KMaxDateStringLength> formatDateString;
+    HBufC* dateString = HBufC::NewL( aUpnpDate.Length() );
+    dateString->Des().Copy( aUpnpDate );
+
+    if( aUpnpDate.Length() >= KDateStringLength )
+        {
+        // CCYY-MM-DD --> CCYYMMDD
+        formatDateString.Copy( dateString->Des().Left( 4 ) ); // Year
+        formatDateString.Append( dateString->Des().Mid( 5,2 ) ); // Month
+        formatDateString.Append( dateString->Des().Mid( 8,2 ) ); // Day        
+
+        if( aUpnpDate.Length() >= KDateTimeStringLength )
+            {
+            // hh:mm:ss --> hhmmss
+            formatDateString.Append( KSeparator );
+            // Hours
+            formatDateString.Append( dateString->Des().Mid( 11, 2 ) ); 
+            // Minutes
+            formatDateString.Append( dateString->Des().Mid( 14, 2 ) );
+            // Seconds 
+            formatDateString.Append( dateString->Des().Mid( 17, 2 ) ); 
+            }
+        else
+            {
+            // hh:mm:ss --> 000000
+            formatDateString.Append( KSeparator );
+            formatDateString.Append( KNullTime );
+            }
+        }
+    delete dateString;
+    
+    User::LeaveIfError( aTime.Set( formatDateString ) );
+    }
+
+//  End of File  
--- a/upnpmediaserver/contentdirectoryservice/src/upnpstatehandler.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnpstatehandler.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,305 +1,305 @@
-/** @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:  State handler
-*
-*/
-
-
-//  INCLUDES
-#include "upnpstatehandler.h"
-#include "upnpstring.h"
-#include "upnpcontainerupdateid.h"
-#include "upnpcontentdirectory.h"
-#include "upnpcontentdirectoryglobals.h"
-#include "upnpcommonupnplits.h"
-
-
-// -----------------------------------------------------------------------------
-// CUpnpStateHandler::CUpnpStateHandler
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CUpnpStateHandler::CUpnpStateHandler(  )
-{
-    iContainerUpdateIdsEvented = EFalse;          
-}
-
-
-// -----------------------------------------------------------------------------
-// CUpnpStateHandler::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CUpnpStateHandler::ConstructL( CUpnpContentDirectory* aCd )
-{    
-    iContainerUpdateIds.Reset();
-    iCurrentContainerUpdateIds.Reset();
-    iCd=aCd;
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpStateHandler::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpStateHandler* CUpnpStateHandler::NewL( CUpnpContentDirectory* aCd )
-{
-    CUpnpStateHandler* self = new (ELeave) CUpnpStateHandler(  );
-
-    CleanupStack::PushL( self );
-    self->ConstructL( aCd );
-    CleanupStack::Pop( self );
-    return self;
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpStateHandler::~CUpnpStateHandler
-// Destructor
-// -----------------------------------------------------------------------------
-//
-CUpnpStateHandler::~CUpnpStateHandler()
-{   
-    // clear tables related to ContainerUpdateIds state variable
-    for( TInt i( 0 ); i < iContainerUpdateIds.Count(); i++ )
-    {
-        delete iContainerUpdateIds[i].iContainerId;
-    }
-    iContainerUpdateIds.Close(); 
-    //--------------------------
-    for( TInt i( 0 ); i < iCurrentContainerUpdateIds.Count(); i++ )
-    {
-        delete iCurrentContainerUpdateIds[i].iContainerId;
-    }
-    iCurrentContainerUpdateIds.Close();
-    //-------------------------- 
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpStateHandler::ContainerUpdateIds
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpStateHandler::ContainerUpdateId( const TDesC8& aContainerID ) 
-{
-    if( aContainerID.Compare( KZero ) == 0 )
-    {
-        return iSystemUpdateId;
-    }
-
-    for(TInt i( 0 ); i < iContainerUpdateIds.Count(); i++ )
-    {
-        if( aContainerID.Compare(*(iContainerUpdateIds[i].iContainerId))==0)
-        {
-            return iContainerUpdateIds[i].iUpdateId;
-        }
-    }
-    return 0; //container not found so it is unmodified and updateId is zero.
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpStateHandler::ContainerUpdateIds
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-RArray<TUpnpContainerUpdateId>& CUpnpStateHandler::ContainerUpdateIds( )
-{    
-    return iContainerUpdateIds;
-}
-// -----------------------------------------------------------------------------
-// CUpnpStateHandler::IsEnableL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpStateHandler::IsEnable()
-{
-    if (iCd->SubcribersAmount() > 0) return ETrue;       
-    else return EFalse;
-}
-
-// -----------------------------------------------------------------------------
-// CUpnpStateHandler::IncreaseSystemUpdateIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-TInt CUpnpStateHandler::IncreaseSystemUpdateIdL()
-{
-    if( iSystemUpdateId < KMaxTUint )
-    {
-        iSystemUpdateId++;
-    }
-    else
-    {
-        iSystemUpdateId = 1;
-    }
-    TBuf8<UpnpString::KMaxIntLength> suid;
-    suid.Num( iSystemUpdateId );
-    iCd->SetStateVariableL( KSystemUpdateID, suid );
-    return iSystemUpdateId;
-}
-// -----------------------------------------------------------------------------
-// CUpnpStateHandler::IncreaseContainerUpdateIdL
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpStateHandler::IncreaseContainerUpdateIdL( const TDesC8& aContainerID )
-{
-    // DLNA.ORG_AnyContainer support - 'any container' 
-    //mapped into container with id=1 
-    HBufC8* properContainerID;
-    
-    if( !aContainerID.Compare(KAnyContainerIndicator8) )    
-        properContainerID = KOne().AllocLC();    
-    else    
-        properContainerID = aContainerID.AllocLC();
-    
-    // iContainerUpdateIds table serving ---------------           
-    TInt updateId( KErrNotFound );
-    TInt i( 0 );
-    for( ; i < iContainerUpdateIds.Count(); i++ )
-    {
-        if( properContainerID->Des().Compare(
-                         *(iContainerUpdateIds[i].iContainerId) ) == 0 )
-        {
-            updateId = iContainerUpdateIds[i].iUpdateId;
-            break;
-        }
-    }
-
-    if( KErrNotFound == updateId ) //first touch to this con´tainer
-    {
-        TUpnpContainerUpdateId cui;
-        
-        cui.iContainerId = properContainerID->AllocL();                                                                           
-        //First time of modification, thus ID is 1.
-        // No magic (white nor black) used here.
-        cui.iUpdateId = 1;
-        iContainerUpdateIds.AppendL( cui );
-        updateId = cui.iUpdateId;
-    }
-    else
-    {
-        if( iContainerUpdateIds[i].iUpdateId == KMaxTInt )
-        {
-            iContainerUpdateIds[i].iUpdateId = 1;
-        }
-        else
-        {
-            iContainerUpdateIds[i].iUpdateId++;
-        }
-        updateId = iContainerUpdateIds[i].iUpdateId;
-    }
-    
-    // iCurrentContainerUpdateIds table serving ---------------           
-    if (IsEnable())     //if any CP subscribed   
-    {
-    if(iContainerUpdateIdsEvented)
-    {
-        // clearing iCurrentContainerUpdateIds table after:
-        // 1. sending NOTIFY events, and
-        // 2. 'ContainerUpdateIds' state variable change
-        for( TInt i(0); i < iCurrentContainerUpdateIds.Count(); i++ )
-        {
-            delete iCurrentContainerUpdateIds[i].iContainerId;
-        }
-        iCurrentContainerUpdateIds.Reset();
-         
-       iContainerUpdateIdsEvented = EFalse; 
-    }
-    
-    // finding out whether element should be updated or added                                       
-    TBool isEelementFound = EFalse;
-    TInt j( 0 );
-    
-    for( ; j < iCurrentContainerUpdateIds.Count(); j++ )
-    {
-        if( properContainerID->Des().Compare(
-                         *(iCurrentContainerUpdateIds[j].iContainerId) ) == 0 )
-        {            
-            isEelementFound = ETrue;
-            break;
-        }
-    }
-    
-    if(isEelementFound)
-    {
-        iCurrentContainerUpdateIds[j].iUpdateId = updateId;                              
-    }
-    else
-    {
-        TUpnpContainerUpdateId newEl;
-        
-        newEl.iContainerId = properContainerID->AllocL();                                                                                   
-        newEl.iUpdateId = updateId;
-        
-        iCurrentContainerUpdateIds.AppendL(newEl);
-    }
-                            
-    // preparing new value of 'ContainerUpdateIds' state variable ----   
-                                
-    TInt elCount = iCurrentContainerUpdateIds.Count();
-    TInt totalDescLength = 0;
-        
-    for( TInt k = 0; k < elCount; k++ )
-    {
-        totalDescLength = totalDescLength + 
-                (iCurrentContainerUpdateIds[k].iContainerId)->Des().Length();
-    }    
-    
-    totalDescLength = totalDescLength + elCount*(UpnpString::KMaxIntLength)
-            + elCount - 1;// 'elCount-1'-> quantity of commas in the descriptor
-    
-    HBufC8* variableValue  = HBufC8::NewLC(totalDescLength);                        
-    TPtr8 pVar = variableValue->Des();
-    pVar.Zero();
-        
-    for( TInt k = 0; k < elCount; k++ )
-    {
-        pVar.Append( *(iCurrentContainerUpdateIds[k].iContainerId) );
-        pVar.Append(',');
-        if ((iCurrentContainerUpdateIds[k].iContainerId)->Compare(KZero) == 0)
-            pVar.AppendNum( iSystemUpdateId );
-        else        
-            pVar.AppendNum( iCurrentContainerUpdateIds[k].iUpdateId );    
-        
-        if( k != elCount - 1 ) // last comma not appended
-            pVar.Append(',');
-    }
-                    
-    //Set new value to be evented
-    iCd->SetStateVariableL( KContainerUpdateIDs, *variableValue );
-                            
-    CleanupStack::PopAndDestroy( variableValue );
-    }
-    CleanupStack::PopAndDestroy( properContainerID );   
-         
- }
-
-// -----------------------------------------------------------------------------
-// CUpnpStateHandler::StateVariableEvented
-// (other items were commented in a header).
-// -----------------------------------------------------------------------------
-//
-void CUpnpStateHandler::StateVariableEvented(const TDesC8& aVariableName)
-{
-   /* if( aVariableName.Compare(KContainerUpdateIDs) == 0 
-                        && (iCd->SubcribersAmount() > 0 )) */
-    if( aVariableName.Compare(KContainerUpdateIDs) == 0)                         
-    {        
-        iContainerUpdateIdsEvented = ETrue;                                                
-        return;
-    }
-}
-
-//end of file
+/** @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:  State handler
+*
+*/
+
+
+//  INCLUDES
+#include "upnpstatehandler.h"
+#include "upnpstring.h"
+#include "upnpcontainerupdateid.h"
+#include "upnpcontentdirectory.h"
+#include "upnpcontentdirectoryglobals.h"
+#include "upnpcommonupnplits.h"
+
+
+// -----------------------------------------------------------------------------
+// CUpnpStateHandler::CUpnpStateHandler
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUpnpStateHandler::CUpnpStateHandler(  )
+{
+    iContainerUpdateIdsEvented = EFalse;          
+}
+
+
+// -----------------------------------------------------------------------------
+// CUpnpStateHandler::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUpnpStateHandler::ConstructL( CUpnpContentDirectory* aCd )
+{    
+    iContainerUpdateIds.Reset();
+    iCurrentContainerUpdateIds.Reset();
+    iCd=aCd;
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpStateHandler::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpStateHandler* CUpnpStateHandler::NewL( CUpnpContentDirectory* aCd )
+{
+    CUpnpStateHandler* self = new (ELeave) CUpnpStateHandler(  );
+
+    CleanupStack::PushL( self );
+    self->ConstructL( aCd );
+    CleanupStack::Pop( self );
+    return self;
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpStateHandler::~CUpnpStateHandler
+// Destructor
+// -----------------------------------------------------------------------------
+//
+CUpnpStateHandler::~CUpnpStateHandler()
+{   
+    // clear tables related to ContainerUpdateIds state variable
+    for( TInt i( 0 ); i < iContainerUpdateIds.Count(); i++ )
+    {
+        delete iContainerUpdateIds[i].iContainerId;
+    }
+    iContainerUpdateIds.Close(); 
+    //--------------------------
+    for( TInt i( 0 ); i < iCurrentContainerUpdateIds.Count(); i++ )
+    {
+        delete iCurrentContainerUpdateIds[i].iContainerId;
+    }
+    iCurrentContainerUpdateIds.Close();
+    //-------------------------- 
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpStateHandler::ContainerUpdateIds
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpStateHandler::ContainerUpdateId( const TDesC8& aContainerID ) 
+{
+    if( aContainerID.Compare( KZero ) == 0 )
+    {
+        return iSystemUpdateId;
+    }
+
+    for(TInt i( 0 ); i < iContainerUpdateIds.Count(); i++ )
+    {
+        if( aContainerID.Compare(*(iContainerUpdateIds[i].iContainerId))==0)
+        {
+            return iContainerUpdateIds[i].iUpdateId;
+        }
+    }
+    return 0; //container not found so it is unmodified and updateId is zero.
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpStateHandler::ContainerUpdateIds
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+RArray<TUpnpContainerUpdateId>& CUpnpStateHandler::ContainerUpdateIds( )
+{    
+    return iContainerUpdateIds;
+}
+// -----------------------------------------------------------------------------
+// CUpnpStateHandler::IsEnableL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpStateHandler::IsEnable()
+{
+    if (iCd->SubcribersAmount() > 0) return ETrue;       
+    else return EFalse;
+}
+
+// -----------------------------------------------------------------------------
+// CUpnpStateHandler::IncreaseSystemUpdateIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpStateHandler::IncreaseSystemUpdateIdL()
+{
+    if( iSystemUpdateId < KMaxTUint )
+    {
+        iSystemUpdateId++;
+    }
+    else
+    {
+        iSystemUpdateId = 1;
+    }
+    TBuf8<UpnpString::KMaxIntLength> suid;
+    suid.Num( iSystemUpdateId );
+    iCd->SetStateVariableL( KSystemUpdateID, suid );
+    return iSystemUpdateId;
+}
+// -----------------------------------------------------------------------------
+// CUpnpStateHandler::IncreaseContainerUpdateIdL
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpStateHandler::IncreaseContainerUpdateIdL( const TDesC8& aContainerID )
+{
+    // DLNA.ORG_AnyContainer support - 'any container' 
+    //mapped into container with id=1 
+    HBufC8* properContainerID;
+    
+    if( !aContainerID.Compare(KAnyContainerIndicator8) )    
+        properContainerID = KOne().AllocLC();    
+    else    
+        properContainerID = aContainerID.AllocLC();
+    
+    // iContainerUpdateIds table serving ---------------           
+    TInt updateId( KErrNotFound );
+    TInt i( 0 );
+    for( ; i < iContainerUpdateIds.Count(); i++ )
+    {
+        if( properContainerID->Des().Compare(
+                         *(iContainerUpdateIds[i].iContainerId) ) == 0 )
+        {
+            updateId = iContainerUpdateIds[i].iUpdateId;
+            break;
+        }
+    }
+
+    if( KErrNotFound == updateId ) //first touch to this con´tainer
+    {
+        TUpnpContainerUpdateId cui;
+        
+        cui.iContainerId = properContainerID->AllocL();                                                                           
+        //First time of modification, thus ID is 1.
+        // No magic (white nor black) used here.
+        cui.iUpdateId = 1;
+        iContainerUpdateIds.Append( cui );
+        updateId = cui.iUpdateId;
+    }
+    else
+    {
+        if( iContainerUpdateIds[i].iUpdateId == KMaxTInt )
+        {
+            iContainerUpdateIds[i].iUpdateId = 1;
+        }
+        else
+        {
+            iContainerUpdateIds[i].iUpdateId++;
+        }
+        updateId = iContainerUpdateIds[i].iUpdateId;
+    }
+    
+    // iCurrentContainerUpdateIds table serving ---------------           
+    if (IsEnable())     //if any CP subscribed   
+    {
+    if(iContainerUpdateIdsEvented)
+    {
+        // clearing iCurrentContainerUpdateIds table after:
+        // 1. sending NOTIFY events, and
+        // 2. 'ContainerUpdateIds' state variable change
+        for( TInt i(0); i < iCurrentContainerUpdateIds.Count(); i++ )
+        {
+            delete iCurrentContainerUpdateIds[i].iContainerId;
+        }
+        iCurrentContainerUpdateIds.Reset();
+         
+       iContainerUpdateIdsEvented = EFalse; 
+    }
+    
+    // finding out whether element should be updated or added                                       
+    TBool isEelementFound = EFalse;
+    TInt j( 0 );
+    
+    for( ; j < iCurrentContainerUpdateIds.Count(); j++ )
+    {
+        if( properContainerID->Des().Compare(
+                         *(iCurrentContainerUpdateIds[j].iContainerId) ) == 0 )
+        {            
+            isEelementFound = ETrue;
+            break;
+        }
+    }
+    
+    if(isEelementFound)
+    {
+        iCurrentContainerUpdateIds[j].iUpdateId = updateId;                              
+    }
+    else
+    {
+        TUpnpContainerUpdateId newEl;
+        
+        newEl.iContainerId = properContainerID->AllocL();                                                                                   
+        newEl.iUpdateId = updateId;
+        
+        iCurrentContainerUpdateIds.Append(newEl);
+    }
+                            
+    // preparing new value of 'ContainerUpdateIds' state variable ----   
+                                
+    TInt elCount = iCurrentContainerUpdateIds.Count();
+    TInt totalDescLength = 0;
+        
+    for( TInt k = 0; k < elCount; k++ )
+    {
+        totalDescLength = totalDescLength + 
+                (iCurrentContainerUpdateIds[k].iContainerId)->Des().Length();
+    }    
+    
+    totalDescLength = totalDescLength + elCount*(UpnpString::KMaxIntLength)
+            + elCount - 1;// 'elCount-1'-> quantity of commas in the descriptor
+    
+    HBufC8* variableValue  = HBufC8::NewLC(totalDescLength);                        
+    TPtr8 pVar = variableValue->Des();
+    pVar.Zero();
+        
+    for( TInt k = 0; k < elCount; k++ )
+    {
+        pVar.Append( *(iCurrentContainerUpdateIds[k].iContainerId) );
+        pVar.Append(',');
+        if ((iCurrentContainerUpdateIds[k].iContainerId)->Compare(KZero) == 0)
+            pVar.AppendNum( iSystemUpdateId );
+        else        
+            pVar.AppendNum( iCurrentContainerUpdateIds[k].iUpdateId );    
+        
+        if( k != elCount - 1 ) // last comma not appended
+            pVar.Append(',');
+    }
+                    
+    //Set new value to be evented
+    iCd->SetStateVariableL( KContainerUpdateIDs, *variableValue );
+                            
+    CleanupStack::PopAndDestroy( variableValue );
+    }
+    CleanupStack::PopAndDestroy( properContainerID );   
+         
+ }
+
+// -----------------------------------------------------------------------------
+// CUpnpStateHandler::StateVariableEvented
+// (other items were commented in a header).
+// -----------------------------------------------------------------------------
+//
+void CUpnpStateHandler::StateVariableEvented(const TDesC8& aVariableName)
+{
+   /* if( aVariableName.Compare(KContainerUpdateIDs) == 0 
+                        && (iCd->SubcribersAmount() > 0 )) */
+    if( aVariableName.Compare(KContainerUpdateIDs) == 0)                         
+    {        
+        iContainerUpdateIdsEvented = ETrue;                                                
+        return;
+    }
+}
+
+//end of file
--- a/upnpmediaserver/contentdirectoryservice/src/upnpxmlcontentfilter.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/contentdirectoryservice/src/upnpxmlcontentfilter.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,74 +1,74 @@
-/** @file
-* Copyright (c) 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:  Xml responses serialization filter
-*
-*/
-
-
-// INCLUDE FILES
-#include "upnpxmlcontentfilter.h"
-
-#include <e32svr.h>
-
-#include <xml/parser.h>
-#include <xml/parserfeature.h>
-#include <xml/dom/xmlengnodefilter.h>
-#include <xml/dom/xmlengdomparser.h>
-
-#include <charconv.h>
-#include <utf.h>
-
-using namespace Xml;
-              
-               
-// -----------------------------------------------------------------------------
-// CUpnpXmlContentFilter::AcceptNode
-// -----------------------------------------------------------------------------
-//               
-TXmlEngNodeFilterResult CUpnpXmlContentFilter::AcceptNode( TXmlEngNode aNode )
-    {
-    if ( aNode.NodeType() == TXmlEngNode::ECDATASection ||
-         aNode.NodeType() == TXmlEngNode::EComment )
-        {
-        return EReject;
-        }
-    return EAccept;
-    }
-    
-// -----------------------------------------------------------------------------
-// CUpnpXmlContentFilter::SerializeLC
-// -----------------------------------------------------------------------------
-//     
-HBufC8* CUpnpXmlContentFilter::SerializeLC(RXmlEngDocument& aDoc, TXmlEngElement& aElement )
-    {
-    CUpnpXmlContentFilter* nodefilter = new (ELeave) CUpnpXmlContentFilter();
-    CleanupStack::PushL(nodefilter);
-    
-    RBuf8 buf;
-	    CleanupClosePushL( buf );               
-
-    TXmlEngSerializationOptions options(  TXmlEngSerializationOptions::KOptionOmitXMLDeclaration
-                          | TXmlEngSerializationOptions::KOptionIncludeNsPrefixes);	        			  
-	options.SetNodeFilter(nodefilter);	    	  
-    aDoc.SaveL( buf, aElement, options );
-    
-    HBufC8* res = buf.AllocL();
-    CleanupStack::PopAndDestroy( &buf );
-    CleanupStack::PopAndDestroy( nodefilter );
-    CleanupStack::PushL(res);
-    
-    return res;        
-    }
-
-// end of file
+/** @file
+* Copyright (c) 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:  Xml responses serialization filter
+*
+*/
+
+
+// INCLUDE FILES
+#include "upnpxmlcontentfilter.h"
+
+#include <e32svr.h>
+
+#include <xml/parser.h>
+#include <xml/parserfeature.h>
+#include <xmlengnodefilter.h>
+#include <xmlengdomparser.h>
+
+#include <charconv.h>
+#include <utf.h>
+
+using namespace Xml;
+              
+               
+// -----------------------------------------------------------------------------
+// CUpnpXmlContentFilter::AcceptNode
+// -----------------------------------------------------------------------------
+//               
+TXmlEngNodeFilterResult CUpnpXmlContentFilter::AcceptNode( TXmlEngNode aNode )
+    {
+    if ( aNode.NodeType() == TXmlEngNode::ECDATASection ||
+         aNode.NodeType() == TXmlEngNode::EComment )
+        {
+        return EReject;
+        }
+    return EAccept;
+    }
+    
+// -----------------------------------------------------------------------------
+// CUpnpXmlContentFilter::SerializeLC
+// -----------------------------------------------------------------------------
+//     
+HBufC8* CUpnpXmlContentFilter::SerializeLC(RXmlEngDocument& aDoc, TXmlEngElement& aElement )
+    {
+    CUpnpXmlContentFilter* nodefilter = new (ELeave) CUpnpXmlContentFilter();
+    CleanupStack::PushL(nodefilter);
+    
+    RBuf8 buf;
+	    CleanupClosePushL( buf );               
+
+    TXmlEngSerializationOptions options(  TXmlEngSerializationOptions::KOptionOmitXMLDeclaration
+                          | TXmlEngSerializationOptions::KOptionIncludeNsPrefixes);	        			  
+	options.SetNodeFilter(nodefilter);	    	  
+    aDoc.SaveL( buf, aElement, options );
+    
+    HBufC8* res = buf.AllocL();
+    CleanupStack::PopAndDestroy( &buf );
+    CleanupStack::PopAndDestroy( nodefilter );
+    CleanupStack::PushL(res);
+    
+    return res;        
+    }
+
+// end of file
--- a/upnpmediaserver/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,36 +1,37 @@
-/** @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:  Build info for the UPnP Stack subsystem
-*
-*/
-
-#include <platform_paths.hrh>
-
-PRJ_PLATFORMS
-WINSCW ARMV5
-//DEFAULT
-
-PRJ_EXPORTS
-
-PRJ_MMPFILES
-
-#include "../avobjects/group/bld.inf"
-#include "../mediaserverclient/group/bld.inf"
-#include "../connectionmanagerservice/group/bld.inf"
-#include "../contentdirectoryservice/group/bld.inf"
-#include "../mediaserverengine/group/bld.inf"
-#include "../rom/bld.inf"
-
-
-//  End of File
\ No newline at end of file
+/** @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:  Build info for the UPnP Stack subsystem
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+WINSCW ARMV5
+//DEFAULT
+
+PRJ_EXPORTS
+../conf/upnpmediaserver.confml MW_LAYER_CONFML(upnpmediaserver.confml)
+../conf/upnpmediaserver_101F978F.crml MW_LAYER_CRML(upnpmediaserver_101F978F.crml)
+
+PRJ_MMPFILES
+
+#include "../avobjects/group/bld.inf"
+#include "../mediaserverclient/group/bld.inf"
+#include "../connectionmanagerservice/group/bld.inf"
+#include "../contentdirectoryservice/group/bld.inf"
+#include "../mediaserverengine/group/bld.inf"
+
+
+//  End of File  
\ No newline at end of file
--- a/upnpmediaserver/mediaserverengine/src/upnpmediaserver.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpmediaserver/mediaserverengine/src/upnpmediaserver.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1049 +1,1049 @@
-/** @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:  Media Server
-*
-*/
-
-
-// INCLUDE FILES
-#include "upnpmediaserver.h"
-#include "upnpcontentdirectoryservice.h"
-#include "upnpmediaserversession.h"
-#include "upnpmediaserverglobals.h"
-#include "upnpcontentdirectoryglobals.h"
-#include "upnpmediaserverclient.h"
-#include "upnpsecuritymanager.h"
-#include "upnpfiletransferevent.h"
-#include <upnpdevicedescriptionstore.h>
-
-#include "upnpdeviceimplementation.h"
-#include "upnpcm.h"
-#include "upnpiconmanager.h"
-#include "upnpdiskremovedetector.h"
-#include <sysutil.h>
-#define KLogFile _L("upnpmediaserver.txt")
-#include "upnpcustomlog.h"
-#include <upnpconnectionmanagernetworkeventprovider.h>
-#include "upnpmediaserverdescriptionprovider.h"
-
-const TVersion KServerSupportedVersion(
-    KMediaServerMajorVersionNumber,
-    KMediaServerMinorVersionNumber,
-    KMediaServerBuildVersionNumber );
-
-using namespace UpnpMediaServerSettings;
-
-_LIT8( KUriMediaServer, "/mediaserver1/mediaserver1.xml" );
-_LIT8( KUriContentDirectory, "/mediaserver1/contentdirectory1.xml" );
-_LIT8( KUriConnectionManager, "/mediaserver1/connectionmanager1.xml" );
-
-// ============================ MEMBER FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::CUpnpMediaServer
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// -----------------------------------------------------------------------------
-//
-CUpnpMediaServer::CUpnpMediaServer():
-    iMsStatus( RUpnpMediaServerClient::EStopped )
-    {
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::ConstructL
-// Symbian 2nd phase constructor can leave.
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::ConstructL()
-    {
-    BaseConstructL();
-    iSettings = CUpnpMediaServerSettings::NewL();
-    iDiskDetector = CUpnpDiskRemoveDetector::NewL( this );
-    iStopAVMediaServerTimer = CUpnpNotifyTimer::NewL( this );
-    iConnectionManagerNetworkEventProvider = 
-        CUpnpConnectionManagerNetworkEventProvider::NewL( *this );
-    iDescriptionProvider = CUpnpMediaServerDescriptionProvider::NewL();
-    
-    InitializeL( EFalse );
-    
-    iDescriptionStore = CUpnpDeviceDescriptionStore::NewL( *iMsName );
-    iIconManager = CUpnpIconManager::NewL( *iDescriptionStore, *iDescriptionProvider );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CUpnpSymbianServerBase* CUpnpMediaServer::NewLC()
-    {
-    CUpnpMediaServer* self = new( ELeave ) CUpnpMediaServer();
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-// Destructor
-CUpnpMediaServer::~CUpnpMediaServer()
-    {
-    if ( iDescriptionStore )
-        {
-        TRAP_IGNORE( iDescriptionStore->SaveL() );
-        }
-
-    ASSERT( CanBeStopped() );//check if we are in correct state
-    delete iStopAVMediaServerTimer;
-    delete iMsName;
-    delete iCdName;
-    delete iCmName;
-
-    delete iConnectionManagerNetworkEventProvider;
-    
-    iObserverList.ResetAndDestroy();
-
-    delete iSettings;
-    delete iManager;
-    delete iIconManager;
-
-    delete iDevice;
-    delete iDescriptionStore;
-    delete iContentDirecory;
-    delete iCm;
-    delete iDiskDetector;
-    delete iDescriptionProvider;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::StopAVMediaServer
-//
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::StopAVMediaServer( TBool aSilent )
-    {
-    LOGS( "CUpnpMediaServer::StopAVMediaServer begin" );
-    iIsSilentShutdown = aSilent;
-    //ms will be stopped in KStopAVMediaServerDelay unless he gets start request
-    iStopAVMediaServerTimer->Start( KStopAVMediaServerDelay );
-    }
-
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::StopAVMediaServerImmediately
-// Immediately stops media server ( no delay )
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::StopAVMediaServerImmediately( TBool aSilent, TBool aWlanLost )
-    {
-    iStopAVMediaServerTimer->Cancel();
-    iDiskDetector->Cancel();
-
-    delete iManager;
-    iManager = NULL;
-
-    // we do not want any stop devices in case of WLAN lost
-    if ( !aWlanLost )
-        {
-        if ( iDevice )
-            {
-            if ( !aSilent )
-                {
-                TRAP_IGNORE( iDevice->StopL() );
-                }
-            else
-                {
-                TRAP_IGNORE( iDevice->StopL( CUpnpDeviceImplementation::EStopSilent ) );
-                }
-            }
-        }
-
-    delete iContentDirecory;
-    iContentDirecory = NULL;
-
-    delete iCm;
-    iCm = NULL;
-
-    delete iDevice;
-    iDevice = NULL;
-
-    SetStatus( RUpnpMediaServerClient::EStopped );
-
-    SuggestShutdown();
-    LOGS( "CUpnpMediaServer::StopAVMediaServer end" );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::NewSessionL
-// Create new session.
-// -----------------------------------------------------------------------------
-//
-CSession2* CUpnpMediaServer::NewSessionL( const RMessage2& /*aMessage*/ ) const
-    {
-    return CUpnpMediaServerSession::NewL( (CUpnpMediaServer*) this );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::Status
-// Check status of the server.
-// -----------------------------------------------------------------------------
-//
-RUpnpMediaServerClient::TServerStatus CUpnpMediaServer::Status() const
-    {
-    if ( iStopAVMediaServerTimer && iStopAVMediaServerTimer->IsActive() )
-        {
-        return RUpnpMediaServerClient::EStopped;
-        }
-    return iMsStatus;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::StartAVMediaServerL
-// Create and start the AV Media Server.
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::StartAVMediaServerL()
-    {
-    LOGS( "CUpnpMediaServer::StartAVMediaServerL begin" );
-
-    // cleanup because previous start could fail
-    StopAVMediaServerImmediately( EFalse, EFalse );
-    
-    // save description
-    iDescriptionStore->SaveL();
-
-    // create device
-    iDevice = CUpnpDeviceImplementation::NewL( KUriMediaServer, 
-                                               *iDescriptionStore, 
-                                               *iDescriptionProvider );
-
-    // create security manager
-    iManager = CUpnpSecurityManager::NewInstanceFromUpnpSettingsL();
-    //iDevice->SetSecurityManager( iManager );
-
-    // create content direcory service
-    HBufC8* uploadtmp = iSettings->GetL( EUploadDirectory );
-    CleanupStack::PushL( uploadtmp );
-    if ( uploadtmp->Length() == 0 )
-        {
-        User::Leave( KErrNotReady );
-        }
-    HBufC* uploaddir = HBufC::NewL( uploadtmp->Length() );
-    CleanupStack::PushL( uploaddir );
-    uploaddir->Des().Copy( uploadtmp->Des() );
-    HBufC* thumbnaildir = HBufC::NewL( uploaddir->Length()
-            + KThumbnailDirLen );
-    CleanupStack::PushL( thumbnaildir );
-    thumbnaildir->Des().Copy( uploaddir->Des() );
-    thumbnaildir->Des().Append( KThumbnailSubDir );
-
-    TInt createThumbnails;
-    User::LeaveIfError( iSettings->Get( EUpnpMediaServerThumbnails,
-        createThumbnails ) );
-
-    TInt maxReqCount;
-    User::LeaveIfError( iSettings->Get( KUpnpMediaServerBrowseLimit,
-        maxReqCount ) );
-
-    TUpnpCdSettings cdset =
-        {
-        iDevice, *uploaddir, *thumbnaildir, *iCdName, NULL, createThumbnails,
-                maxReqCount, this, KNullDesC(), NULL
-        };
-
-    iContentDirecory = CUpnpContentDirectoryService::NewL( cdset );
-
-    // create connection manager service
-    HBufC8* media = iSettings->GetL( ESupportedMedia );
-    CleanupStack::PushL( media );
-    if ( media->Length() == 0 )
-        {
-        User::Leave( KErrNotReady );
-        }
-    iCm = CUpnpCM::NewL( *iDevice, *media, *iCmName );
-    CleanupStack::PopAndDestroy( media );
-
-    CleanupStack::PopAndDestroy( thumbnaildir );
-    CleanupStack::PopAndDestroy( uploaddir );
-    CleanupStack::PopAndDestroy( uploadtmp );
-
-    SetDescriptionSettingsL( iDevice );
-
-    // start media server
-    iDevice->StartL();
-    iDiskDetector->StartL();
-
-    SetStatus( RUpnpMediaServerClient::EStartedOnline );
-    LOGS( "CUpnpMediaServer::StartAVMediaServerL end" );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::StartAVMediaServerOfflineL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::StartAVMediaServerOfflineL()
-    {
-    LOGS( "StartAVMediaServerOfflineL begin" );
-
-    // cleanup because previous start could fail
-    StopAVMediaServerImmediately( EFalse, EFalse );
-
-    // create content directory
-    iContentDirecory = CUpnpContentDirectoryService::NewL();
-    SetStatus( RUpnpMediaServerClient::EStartedOffline );
-    LOGS( "StartAVMediaServerOfflineL end" );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::RestartAVMediaServerL
-// Start and stop the AV Media Server.
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::RestartAVMediaServerL()
-    {
-    if ( iDevice )
-        {
-        iDevice->StopL();
-        SetDescriptionSettingsL( iDevice );
-        iDevice->StartL();
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::SetFriendlyNameL
-// Sets friendly name for device, changes are available after restarting
-// the server
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::SetDescriptionSettingsL(
-    CUpnpDeviceImplementation* aDevice )
-    {
-    SetDescriptionRequiredPropertyL( aDevice, EFriendlyName, KFriendlyName );
-    SetDescriptionRequiredPropertyL( aDevice, EModelName, KModelName );
-    SetDescriptionRequiredPropertyL( aDevice, EManufacturer, KManufacturer );
-
-    SetDescriptionPropertyL( aDevice, EModelUrl, KModelUrl );
-    SetDescriptionPropertyL( aDevice, EModelDescription, KModelDescription );
-    SetDescriptionPropertyL( aDevice, EModelNumber, KModelNumber );
-    SetDescriptionPropertyL( aDevice, ESerialNumber, KSerialNumber );
-    SetDescriptionPropertyL( aDevice, EPresentationUrl, KPresentationUrl );
-    SetDescriptionPropertyL( aDevice, EManufacturerUrl, KManufacturerUrl );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::RemoveIconL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::RemoveIconL( const TDesC8& aUrl )
-    {
-    iIconManager->RemoveIconL( aUrl );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::RemoveIconsL
-// ------------------------------------------------------------------------------
-//
-void CUpnpMediaServer::RemoveIconsL()
-    {
-    iIconManager->RemoveIconsL();
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::AddIconL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::AddIconL( const TDesC8& aProperty )
-    {
-    iIconManager->AddIconL( aProperty );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::UpdateIconL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::UpdateIconL( const TDesC8& aProperty,
-    const TDesC8& aUrl )
-    {
-    iIconManager->UpdateIconL( aProperty, aUrl );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::SetUploadDirToCDL
-// Set the download and thumbnail in CD according to the value
-// of the upload directory
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::SetUploadDirToCDL( const TDesC& aPath )
-    {
-    if ( iContentDirecory )
-        {
-        HBufC* uploaddir= NULL;
-
-        if ( aPath != KNullDesC() )
-            {
-            uploaddir = aPath.AllocLC();
-            }
-        else
-            {
-            HBufC8* uploadtmp = iSettings->GetL( EUploadDirectory );
-            CleanupStack::PushL( uploadtmp );
-
-            uploaddir = HBufC::NewL( uploadtmp->Length() );
-            uploaddir->Des().Copy( uploadtmp->Des() );
-            CleanupStack::PopAndDestroy( uploadtmp );
-            CleanupStack::PushL( uploaddir );
-            }
-
-        HBufC* thumbnaildir = HBufC::NewL( uploaddir->Length()
-                + KThumbnailDirLen );
-        CleanupStack::PushL( thumbnaildir );
-        thumbnaildir->Des().Copy( uploaddir->Des() );
-        thumbnaildir->Des().Append( KThumbnailSubDir );
-
-        iContentDirecory->SetDownloadDirectoryL( uploaddir->Des() );
-        iContentDirecory->SetThumbnailDirectoryL( thumbnaildir->Des() );
-
-        CleanupStack::PopAndDestroy( thumbnaildir );
-        CleanupStack::PopAndDestroy( uploaddir );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::SetUploadDirL
-// Set the upload and thumbnail path in CD and central repository.
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::SetUploadDirL( const TDesC& aPath )
-    {
-    User::LeaveIfError( iSettings->Set(
-        UpnpMediaServerSettings::EUploadDirectory, aPath ) ) ;
-
-    SetUploadDirToCDL( KNullDesC( )); // empty descriptor -> it means, value will be taken directly from cenrep
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::SetDescriptionPropertyL
-// Sets description property for device
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::SetDescriptionPropertyL(
-    CUpnpDeviceImplementation* aDevice, TInt aKey, const TDesC8& aName )
-    {
-    HBufC8* value = iSettings->GetL( aKey );
-    CleanupStack::PushL( value );
-    if ( value->Size() )
-        {
-        aDevice->SetDescriptionPropertyL( aName, *value );
-        }
-    else
-        {
-        aDevice->RemoveDescriptionPropertyL( aName );
-        }
-
-    CleanupStack::PopAndDestroy( value );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::SetDescriptionRequiredPropertyL
-// Sets description required property for device
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::SetDescriptionRequiredPropertyL(
-    CUpnpDeviceImplementation* aDevice, TInt aKey, const TDesC8& aName )
-    {
-    HBufC8* value = iSettings->GetL( aKey );
-
-    if ( !value )
-        {
-        User::Leave( KErrNotFound );
-        }
-    else
-        {
-        CleanupStack::PushL( value );
-
-        HBufC8* tmpBuf = (*value).AllocLC();
-        TPtr8 tmpPtr(tmpBuf->Des() );
-
-        RemoveWhiteSpaces( tmpPtr );
-        if ( tmpPtr.Length() == 0 )
-            {
-            User::Leave( KErrNotFound );
-            }
-        CleanupStack::PopAndDestroy( tmpBuf );
-        }
-
-    TRAPD( error, aDevice->SetDescriptionPropertyL( aName, *value ) )
-    if ( error != KErrNotFound )
-        {
-        User::LeaveIfError( error );
-        }
-
-    CleanupStack::PopAndDestroy( value );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::RemoveWhiteSpaces
-// Removes white characters from input descriptor
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::RemoveWhiteSpaces( TDes8& aString )
-    {
-    for ( TInt i=0; i<aString.Length(); i++ )
-        {
-        if ( aString[i] == ' ' || aString[i] == '\r' || aString[i] == '\n'
-                || aString[i] == '\t' )
-            {
-            aString.Replace( i, 1, KNullDesC8() );
-            i--;
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::InitPrivateDir
-// Init Media Server directory structure in private directory
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::InitPrivateDirL( RFs &aFs )
-    {
-    TParse fp;
-    TFileName path;
-    aFs.PrivatePath( path );
-    fp.Set( KDefaultMediaDrive(), &path, 0 );
-    User::LeaveIfError( fp.AddDir( KMSPublicAccessedDir() ) );
-    User::LeaveIfError( fp.AddDir( KMSDeviceXmlDescDir() ) );
-    User::LeaveIfError( fp.AddDir( KIconDirectory() ) );
-    path = fp.DriveAndPath();
-
-    aFs.MkDirAll( path ) ;
-    fp.PopDir();
-    User::LeaveIfError( fp.AddDir( KMSMediaDir ) );
-    path = fp.DriveAndPath();
-    aFs.MkDirAll( path );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::InitDescFileL
-// Checks is description file exists. If not creates it from teplate stored on Z:
-// -----------------------------------------------------------------------------
-//
-HBufC* CUpnpMediaServer::InitDescFileL( RFs &aFs,
-    const TDesC& aTempleteDescFile, TBool aOverwrite )
-    {
-    TUint temp;
-    HBufC* descName = CreateFullNameL( aFs, KDefaultMediaDrive(),
-        aTempleteDescFile );
-    CleanupStack::PushL( descName );
-
-    if ( aFs.Att( *descName, temp ) != KErrNone || aOverwrite )
-        {
-
-        HBufC* templName = CreateFullNameL( aFs, KDescTemplateDrive(),
-            aTempleteDescFile );
-        CleanupStack::PushL( templName );
-        CFileMan* fileMan = CFileMan::NewL( aFs );
-        CleanupStack::PushL( fileMan );
-        User::LeaveIfError( fileMan->Copy( *templName, *descName ) );
-        User::LeaveIfError( fileMan->Attribs( *descName, KEntryAttNormal,
-            KEntryAttReadOnly, TTime( 0 ) ) );
-        CleanupStack::PopAndDestroy( fileMan );
-        CleanupStack::PopAndDestroy( templName );
-        }
-    CleanupStack::Pop( descName );
-    return descName;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::InitializeL
-// Initialize Media Server using files from drive z:
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::InitializeL( TBool aOverwrite )
-    {
-    RFs fs;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL( fs );
-
-    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fs, KMSDescriptionMaxSize,
-        EDriveC ) )
-        {
-        User::Leave( KErrDiskFull );
-        }
-
-    InitPrivateDirL( fs );
-
-    delete iMsName;
-    iMsName= NULL;
-    iMsName = InitDescFileL( fs, KMSDeviceXmlDescFile(), aOverwrite );
-    iDescriptionProvider->AddUriToFileMapL( KUriMediaServer(), iMsName->Des() );
-    delete iCdName;
-    iCdName = NULL;
-    iCdName = InitDescFileL( fs, KCDXmlDescFile(), aOverwrite );
-    iDescriptionProvider->AddUriToFileMapL( KUriContentDirectory(), iCdName->Des() );
-    delete iCmName;
-    iCmName = NULL;
-    iCmName = InitDescFileL( fs, KCMXmlDescFile(), aOverwrite );
-    iDescriptionProvider->AddUriToFileMapL( KUriConnectionManager(), iCmName->Des() );
-
-    CleanupStack::PopAndDestroy( &fs );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::ResetDbL
-// Reset database, renaming name of original DB
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::ResetDbL()
-    {
-    RFs fs;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL( fs );
-
-    TFileName orgPath;
-
-    User::LeaveIfError( fs.PrivatePath( orgPath ) );
-
-    TParse fp;
-    fp.Set( KDatabaseFileName(), &orgPath, 0 );
-    orgPath = fp.FullName();
-
-    TFileName newPath;
-    newPath = orgPath;
-    newPath.Append( KBackupSuffix );
-
-    CFileMan* fileMan = CFileMan::NewL( fs );
-    CleanupStack::PushL( fileMan );
-    User::LeaveIfError( fileMan->Rename( orgPath, newPath ) );
-    CleanupStack::PopAndDestroy( fileMan );
-
-    CleanupStack::PopAndDestroy( &fs );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::DeleteDbL
-// Delete database
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::DeleteDbL()
-    {
-    RFs fs;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL( fs );
-
-    TFileName orgPath;
-
-    User::LeaveIfError( fs.PrivatePath( orgPath ) );
-
-    TParse fp;
-    fp.Set( KDatabaseFileName(), &orgPath, 0 );
-    orgPath = fp.FullName();
-
-    CFileMan* fileMan = CFileMan::NewL( fs );
-    CleanupStack::PushL( fileMan );
-    User::LeaveIfError( fileMan->Delete( orgPath ) );
-    CleanupStack::PopAndDestroy( fileMan );
-
-    CleanupStack::PopAndDestroy( &fs );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::SettingChangedL
-// Function notify when setting will change
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::SettingChangedL()
-    {
-    //no actions needed
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::CreateFullNameL
-// Create full name using drive MS directory structure and file name.
-// -----------------------------------------------------------------------------
-//
-HBufC* CUpnpMediaServer::CreateFullNameL( RFs &aFs, const TDesC& aDrive,
-    const TDesC& aName )
-    {
-    TParse fp;
-    TFileName path;
-    User::LeaveIfError( aFs.PrivatePath( path ) );
-    fp.Set( aDrive, &path, &aName );
-    User::LeaveIfError( fp.AddDir( KMSPublicAccessedDir() ) );
-    User::LeaveIfError( fp.AddDir( KMSDeviceXmlDescDir() ) );
-    return fp.FullName().AllocL();
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::ShareItemL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::ShareObjectL( CUpnpObject* aItem )
-    {
-    iContentDirecory->ShareObjectL( aItem );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::ShareReferenceL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::ShareReferenceL( CUpnpItem* aItem )
-    {
-    iContentDirecory->ShareReferenceL( aItem );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::ShareReferenceListL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::ShareReferenceListL( CUpnpItemList* aItemList,
-    TInt* aStatus )
-    {
-    iContentDirecory->ShareReferenceListL( aItemList, aStatus );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::ShareItemListL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::ShareItemListL( CUpnpItemList* aItemList, TInt* aStatus )
-    {
-    iContentDirecory->ShareItemListL( aItemList, aStatus );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::UnshareRootL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::UnshareRootL()
-    {
-    TBool online = ETrue;
-
-    if ( Status()==RUpnpMediaServerClient::EStartedOnline )
-        {
-        online = ETrue;
-        }
-    else if ( Status()==RUpnpMediaServerClient::EStartedOffline )
-        {
-        online = EFalse;
-        }
-
-    StopAVMediaServerImmediately( EFalse, EFalse );
-
-    DeleteDbL();
-
-    if ( online )
-        {
-        StartAVMediaServerL();
-        }
-    else
-        {
-        StartAVMediaServerOfflineL();
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::UnshareItemL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::UnshareItemL( TInt aId )
-    {
-    iContentDirecory->UnshareItemL( aId );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::UnshareContainerL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::UnshareContainerL( TInt aId )
-    {
-    iContentDirecory->UnshareContainerL( aId );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::GetSharedItemL
-// -----------------------------------------------------------------------------
-//
-CUpnpItem* CUpnpMediaServer::GetSharedItemL( TInt aItem )
-    {
-    return iContentDirecory->GetSharedItemL( aItem );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::GetSingleContainerL
-// -----------------------------------------------------------------------------
-//
-CUpnpContainer* CUpnpMediaServer::GetSingleContainerL( TInt aContainerId )
-    {
-    return iContentDirecory->GetSingleContainerL( aContainerId );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::UnshareItemListL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::UnshareItemListL( RArray<TInt>& aItemList,
-    TInt* aExecutionStatus )
-    {
-    iContentDirecory->UnshareItemListL( aItemList, aExecutionStatus );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::GetSharedItemListL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::GetSharedItemListL( TInt aContId,
-    CUpnpBrowseCriteria* aBrowseCriteria, TInt* TotalMatches,
-    CUpnpItemList* aItemList )
-    {
-    iContentDirecory->GetItemListL( aContId, aBrowseCriteria, TotalMatches,
-        aItemList );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::GetSharedContainerListL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::GetSharedContainerListL( TInt aContId,
-    CUpnpBrowseCriteria* aBrowseCriteria, TInt* TotalMatches,
-    CUpnpContainerList* aContainerList )
-    {
-    iContentDirecory->GetContainerListL( aContId, aBrowseCriteria,
-        TotalMatches, aContainerList );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::GetIpAndPortL
-// -----------------------------------------------------------------------------
-//
-TInetAddr CUpnpMediaServer::GetAddress()
-    {
-    return iContentDirecory->GetAddress();
-    }
-
-// ============================= EVENT FUNCTIONS ===============================
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::SubscribeEvents
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::SubscribeEvents(
-    MUpnpContentDirectoryEventObserver* aObserver )
-    {
-    iObserverList.AppendL( aObserver );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::UnsubscribeEvents
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::UnsubscribeEvents(
-    MUpnpContentDirectoryEventObserver* aObserver )
-    {
-    TInt index = iObserverList.Find( aObserver );
-    if ( index != KErrNotFound )
-        {
-        iObserverList.Remove( index );
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::FileTransferEvent
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::FileTransferEvent( CUpnpFileTransferEvent* aMessage )
-    {
-    for ( TInt i=0; i<iObserverList.Count(); i++ )
-        {
-        iObserverList[i]->FileTransferEvent( aMessage );
-        }
-    delete aMessage;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::IsInterfaceUp
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpMediaServer::IsInterfaceUp()
-    {
-    return ( iMsStatus == RUpnpMediaServerClient::EStartedOnline );
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::CancelAVMediaServerStop
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::CancelAVMediaServerStop()
-    {
-    iStopAVMediaServerTimer->Cancel();
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::CanBeStopped
-// -----------------------------------------------------------------------------
-//
-TBool CUpnpMediaServer::CanBeStopped() const
-    {
-    return RUpnpMediaServerClient::EStopped == Status(); //note: Status(),not iMsStatus
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::TimerEventL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::TimerEventL( CUpnpNotifyTimer* aTimer )
-    {
-    if ( aTimer == iStopAVMediaServerTimer )
-        {
-        StopAVMediaServerImmediately( iIsSilentShutdown, EFalse );
-        }
-    else
-        {
-        CUpnpSymbianServerBase::TimerEventL( aTimer );
-        }
-    }
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::SupportedVersion
-// -----------------------------------------------------------------------------
-//
-TVersion CUpnpMediaServer::SupportedVersion() const
-    {
-    return KServerSupportedVersion;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::ServerName
-// -----------------------------------------------------------------------------
-//
-const TDesC& CUpnpMediaServer::ServerName() const
-    {
-    return KMediaServerName;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::NetworkEvent
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::NetworkEvent( CUpnpNetworkEventBase* aEvent )
-    {
-    LOG_FUNC_NAME;
-
-    if ( aEvent->SubscriberError() < KErrNone && aEvent->Type() == EUnknownEvent )
-        {
-        LOGS( "CUpnpMediaServer::NetworkEvent error" );
-        return;
-        }
-        
-    switch ( aEvent->Type() )
-        {
-        case EWlanLostEvent:
-            {
-            if ( IsInterfaceUp() )
-                {
-                StopAVMediaServerImmediately( ETrue, ETrue );
-                NotifyStatusChanged();
-                }
-            }
-            break;
-
-        case EAddressChangeEvent:
-            {
-            if ( iMsStatus == RUpnpMediaServerClient::EStartedOnline )
-                {
-                TRAPD( error, RestartAVMediaServerL() );
-                if ( error != KErrNone )
-                    {
-                    if ( iStopAVMediaServerTimer->IsActive() )
-                        {
-                        StopAVMediaServerImmediately( EFalse, EFalse );
-                        }
-                    TRAP( error, StartAVMediaServerL() );
-                    if ( error != KErrNone )
-                         {
-                         StopAVMediaServerImmediately( EFalse, EFalse );
-                         NotifyStatusChanged();
-                         }
-                     }
-                else if ( iContentDirecory )
-                    {
-                    TRAP( error, iContentDirecory->AddressChangeL() );
-                    if ( error != KErrNone )
-                         {
-                         StopAVMediaServerImmediately( EFalse, EFalse );
-                         NotifyStatusChanged();
-                         } 
-                    }                     
-                }
-            }
-            break; 
-        
-        case EConnectionClosedEvent:
-            {
-            ASSERT( iMsStatus != RUpnpMediaServerClient::EStartedOnline );
-            }
-            break;
-        }
-    }                
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::SetStatus
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::SetStatus( RUpnpMediaServerClient::TServerStatus aStatus )
-    {
-    iMsStatus = aStatus;
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::NotifyStatusChanged
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::NotifyStatusChanged()
-    {
-    CUpnpMediaServerSession* ses = NULL;
-    iSessionIter.SetToFirst();
-    CSession2* cses = iSessionIter++;
-    ses = reinterpret_cast<CUpnpMediaServerSession*>( cses );
-    while ( ses )
-        {
-        ses->StatusChanged();
-        ses = reinterpret_cast<CUpnpMediaServerSession*>( iSessionIter++ );    
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CUpnpMediaServer::RunL
-// -----------------------------------------------------------------------------
-//
-void CUpnpMediaServer::RunL()
-    {
-    const RUpnpMediaServerClient::TServerStatus beforeStatus = Status();
-    CUpnpSymbianServerBase::RunL();
-    if ( Status() != beforeStatus )
-        {
-        NotifyStatusChanged();
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// E32Main entry point.
-// Returns: KErrNone
-// -----------------------------------------------------------------------------
-//
-TInt E32Main()
-    {
-    return CUpnpMediaServer::StartServer(
-        KMediaServerThreadName, CUpnpMediaServer::NewLC );
-    }
-
-
-// End of File
+/** @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:  Media Server
+*
+*/
+
+
+// INCLUDE FILES
+#include "upnpmediaserver.h"
+#include "upnpcontentdirectoryservice.h"
+#include "upnpmediaserversession.h"
+#include "upnpmediaserverglobals.h"
+#include "upnpcontentdirectoryglobals.h"
+#include "upnpmediaserverclient.h"
+#include "upnpsecuritymanager.h"
+#include "upnpfiletransferevent.h"
+#include <upnpdevicedescriptionstore.h>
+
+#include "upnpdeviceimplementation.h"
+#include "upnpcm.h"
+#include "upnpiconmanager.h"
+#include "upnpdiskremovedetector.h"
+#include <sysutil.h>
+#define KLogFile _L("upnpmediaserver.txt")
+#include "upnpcustomlog.h"
+#include <upnpconnectionmanagernetworkeventprovider.h>
+#include "upnpmediaserverdescriptionprovider.h"
+
+const TVersion KServerSupportedVersion(
+    KMediaServerMajorVersionNumber,
+    KMediaServerMinorVersionNumber,
+    KMediaServerBuildVersionNumber );
+
+using namespace UpnpMediaServerSettings;
+
+_LIT8( KUriMediaServer, "/mediaserver1/mediaserver1.xml" );
+_LIT8( KUriContentDirectory, "/mediaserver1/contentdirectory1.xml" );
+_LIT8( KUriConnectionManager, "/mediaserver1/connectionmanager1.xml" );
+
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::CUpnpMediaServer
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// -----------------------------------------------------------------------------
+//
+CUpnpMediaServer::CUpnpMediaServer():
+    iMsStatus( RUpnpMediaServerClient::EStopped )
+    {
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::ConstructL
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::ConstructL()
+    {
+    BaseConstructL();
+    iSettings = CUpnpMediaServerSettings::NewL();
+    iDiskDetector = CUpnpDiskRemoveDetector::NewL( this );
+    iStopAVMediaServerTimer = CUpnpNotifyTimer::NewL( this );
+    iConnectionManagerNetworkEventProvider = 
+        CUpnpConnectionManagerNetworkEventProvider::NewL( *this );
+    iDescriptionProvider = CUpnpMediaServerDescriptionProvider::NewL();
+    
+    InitializeL( EFalse );
+    
+    iDescriptionStore = CUpnpDeviceDescriptionStore::NewL( *iMsName );
+    iIconManager = CUpnpIconManager::NewL( *iDescriptionStore, *iDescriptionProvider );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::NewL
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CUpnpSymbianServerBase* CUpnpMediaServer::NewLC()
+    {
+    CUpnpMediaServer* self = new( ELeave ) CUpnpMediaServer();
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// Destructor
+CUpnpMediaServer::~CUpnpMediaServer()
+    {
+    if ( iDescriptionStore )
+        {
+        TRAP_IGNORE( iDescriptionStore->SaveL() );
+        }
+
+    ASSERT( CanBeStopped() );//check if we are in correct state
+    delete iStopAVMediaServerTimer;
+    delete iMsName;
+    delete iCdName;
+    delete iCmName;
+
+    delete iConnectionManagerNetworkEventProvider;
+    
+    iObserverList.ResetAndDestroy();
+
+    delete iSettings;
+    delete iManager;
+    delete iIconManager;
+
+    delete iDevice;
+    delete iDescriptionStore;
+    delete iContentDirecory;
+    delete iCm;
+    delete iDiskDetector;
+    delete iDescriptionProvider;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::StopAVMediaServer
+//
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::StopAVMediaServer( TBool aSilent )
+    {
+    LOGS( "CUpnpMediaServer::StopAVMediaServer begin" );
+    iIsSilentShutdown = aSilent;
+    //ms will be stopped in KStopAVMediaServerDelay unless he gets start request
+    iStopAVMediaServerTimer->Start( KStopAVMediaServerDelay );
+    }
+
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::StopAVMediaServerImmediately
+// Immediately stops media server ( no delay )
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::StopAVMediaServerImmediately( TBool aSilent, TBool aWlanLost )
+    {
+    iStopAVMediaServerTimer->Cancel();
+    iDiskDetector->Cancel();
+
+    delete iManager;
+    iManager = NULL;
+
+    // we do not want any stop devices in case of WLAN lost
+    if ( !aWlanLost )
+        {
+        if ( iDevice )
+            {
+            if ( !aSilent )
+                {
+                TRAP_IGNORE( iDevice->StopL() );
+                }
+            else
+                {
+                TRAP_IGNORE( iDevice->StopL( CUpnpDeviceImplementation::EStopSilent ) );
+                }
+            }
+        }
+
+    delete iContentDirecory;
+    iContentDirecory = NULL;
+
+    delete iCm;
+    iCm = NULL;
+
+    delete iDevice;
+    iDevice = NULL;
+
+    SetStatus( RUpnpMediaServerClient::EStopped );
+
+    SuggestShutdown();
+    LOGS( "CUpnpMediaServer::StopAVMediaServer end" );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::NewSessionL
+// Create new session.
+// -----------------------------------------------------------------------------
+//
+CSession2* CUpnpMediaServer::NewSessionL( const RMessage2& /*aMessage*/ ) const
+    {
+    return CUpnpMediaServerSession::NewL( (CUpnpMediaServer*) this );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::Status
+// Check status of the server.
+// -----------------------------------------------------------------------------
+//
+RUpnpMediaServerClient::TServerStatus CUpnpMediaServer::Status() const
+    {
+    if ( iStopAVMediaServerTimer && iStopAVMediaServerTimer->IsActive() )
+        {
+        return RUpnpMediaServerClient::EStopped;
+        }
+    return iMsStatus;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::StartAVMediaServerL
+// Create and start the AV Media Server.
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::StartAVMediaServerL()
+    {
+    LOGS( "CUpnpMediaServer::StartAVMediaServerL begin" );
+
+    // cleanup because previous start could fail
+    StopAVMediaServerImmediately( EFalse, EFalse );
+    
+    // save description
+    iDescriptionStore->SaveL();
+
+    // create device
+    iDevice = CUpnpDeviceImplementation::NewL( KUriMediaServer, 
+                                               *iDescriptionStore, 
+                                               *iDescriptionProvider );
+
+    // create security manager
+    iManager = CUpnpSecurityManager::NewInstanceFromUpnpSettingsL();
+    //iDevice->SetSecurityManager( iManager );
+
+    // create content direcory service
+    HBufC8* uploadtmp = iSettings->GetL( EUploadDirectory );
+    CleanupStack::PushL( uploadtmp );
+    if ( uploadtmp->Length() == 0 )
+        {
+        User::Leave( KErrNotReady );
+        }
+    HBufC* uploaddir = HBufC::NewL( uploadtmp->Length() );
+    CleanupStack::PushL( uploaddir );
+    uploaddir->Des().Copy( uploadtmp->Des() );
+    HBufC* thumbnaildir = HBufC::NewL( uploaddir->Length()
+            + KThumbnailDirLen );
+    CleanupStack::PushL( thumbnaildir );
+    thumbnaildir->Des().Copy( uploaddir->Des() );
+    thumbnaildir->Des().Append( KThumbnailSubDir );
+
+    TInt createThumbnails;
+    User::LeaveIfError( iSettings->Get( EUpnpMediaServerThumbnails,
+        createThumbnails ) );
+
+    TInt maxReqCount;
+    User::LeaveIfError( iSettings->Get( KUpnpMediaServerBrowseLimit,
+        maxReqCount ) );
+
+    TUpnpCdSettings cdset =
+        {
+        iDevice, *uploaddir, *thumbnaildir, *iCdName, NULL, createThumbnails,
+                maxReqCount, this, KNullDesC(), NULL
+        };
+
+    iContentDirecory = CUpnpContentDirectoryService::NewL( cdset );
+
+    // create connection manager service
+    HBufC8* media = iSettings->GetL( ESupportedMedia );
+    CleanupStack::PushL( media );
+    if ( media->Length() == 0 )
+        {
+        User::Leave( KErrNotReady );
+        }
+    iCm = CUpnpCM::NewL( *iDevice, *media, *iCmName );
+    CleanupStack::PopAndDestroy( media );
+
+    CleanupStack::PopAndDestroy( thumbnaildir );
+    CleanupStack::PopAndDestroy( uploaddir );
+    CleanupStack::PopAndDestroy( uploadtmp );
+
+    SetDescriptionSettingsL( iDevice );
+
+    // start media server
+    iDevice->StartL();
+    iDiskDetector->StartL();
+
+    SetStatus( RUpnpMediaServerClient::EStartedOnline );
+    LOGS( "CUpnpMediaServer::StartAVMediaServerL end" );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::StartAVMediaServerOfflineL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::StartAVMediaServerOfflineL()
+    {
+    LOGS( "StartAVMediaServerOfflineL begin" );
+
+    // cleanup because previous start could fail
+    StopAVMediaServerImmediately( EFalse, EFalse );
+
+    // create content directory
+    iContentDirecory = CUpnpContentDirectoryService::NewL();
+    SetStatus( RUpnpMediaServerClient::EStartedOffline );
+    LOGS( "StartAVMediaServerOfflineL end" );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::RestartAVMediaServerL
+// Start and stop the AV Media Server.
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::RestartAVMediaServerL()
+    {
+    if ( iDevice )
+        {
+        iDevice->StopL();
+        SetDescriptionSettingsL( iDevice );
+        iDevice->StartL();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::SetFriendlyNameL
+// Sets friendly name for device, changes are available after restarting
+// the server
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::SetDescriptionSettingsL(
+    CUpnpDeviceImplementation* aDevice )
+    {
+    SetDescriptionRequiredPropertyL( aDevice, EFriendlyName, KFriendlyName );
+    SetDescriptionRequiredPropertyL( aDevice, EModelName, KModelName );
+    SetDescriptionRequiredPropertyL( aDevice, EManufacturer, KManufacturer );
+
+    SetDescriptionPropertyL( aDevice, EModelUrl, KModelUrl );
+    SetDescriptionPropertyL( aDevice, EModelDescription, KModelDescription );
+    SetDescriptionPropertyL( aDevice, EModelNumber, KModelNumber );
+    SetDescriptionPropertyL( aDevice, ESerialNumber, KSerialNumber );
+    SetDescriptionPropertyL( aDevice, EPresentationUrl, KPresentationUrl );
+    SetDescriptionPropertyL( aDevice, EManufacturerUrl, KManufacturerUrl );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::RemoveIconL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::RemoveIconL( const TDesC8& aUrl )
+    {
+    iIconManager->RemoveIconL( aUrl );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::RemoveIconsL
+// ------------------------------------------------------------------------------
+//
+void CUpnpMediaServer::RemoveIconsL()
+    {
+    iIconManager->RemoveIconsL();
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::AddIconL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::AddIconL( const TDesC8& aProperty )
+    {
+    iIconManager->AddIconL( aProperty );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::UpdateIconL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::UpdateIconL( const TDesC8& aProperty,
+    const TDesC8& aUrl )
+    {
+    iIconManager->UpdateIconL( aProperty, aUrl );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::SetUploadDirToCDL
+// Set the download and thumbnail in CD according to the value
+// of the upload directory
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::SetUploadDirToCDL( const TDesC& aPath )
+    {
+    if ( iContentDirecory )
+        {
+        HBufC* uploaddir= NULL;
+
+        if ( aPath != KNullDesC() )
+            {
+            uploaddir = aPath.AllocLC();
+            }
+        else
+            {
+            HBufC8* uploadtmp = iSettings->GetL( EUploadDirectory );
+            CleanupStack::PushL( uploadtmp );
+
+            uploaddir = HBufC::NewL( uploadtmp->Length() );
+            uploaddir->Des().Copy( uploadtmp->Des() );
+            CleanupStack::PopAndDestroy( uploadtmp );
+            CleanupStack::PushL( uploaddir );
+            }
+
+        HBufC* thumbnaildir = HBufC::NewL( uploaddir->Length()
+                + KThumbnailDirLen );
+        CleanupStack::PushL( thumbnaildir );
+        thumbnaildir->Des().Copy( uploaddir->Des() );
+        thumbnaildir->Des().Append( KThumbnailSubDir );
+
+        iContentDirecory->SetDownloadDirectoryL( uploaddir->Des() );
+        iContentDirecory->SetThumbnailDirectoryL( thumbnaildir->Des() );
+
+        CleanupStack::PopAndDestroy( thumbnaildir );
+        CleanupStack::PopAndDestroy( uploaddir );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::SetUploadDirL
+// Set the upload and thumbnail path in CD and central repository.
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::SetUploadDirL( const TDesC& aPath )
+    {
+    User::LeaveIfError( iSettings->Set(
+        UpnpMediaServerSettings::EUploadDirectory, aPath ) ) ;
+
+    SetUploadDirToCDL( KNullDesC( )); // empty descriptor -> it means, value will be taken directly from cenrep
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::SetDescriptionPropertyL
+// Sets description property for device
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::SetDescriptionPropertyL(
+    CUpnpDeviceImplementation* aDevice, TInt aKey, const TDesC8& aName )
+    {
+    HBufC8* value = iSettings->GetL( aKey );
+    CleanupStack::PushL( value );
+    if ( value->Size() )
+        {
+        aDevice->SetDescriptionPropertyL( aName, *value );
+        }
+    else
+        {
+        aDevice->RemoveDescriptionPropertyL( aName );
+        }
+
+    CleanupStack::PopAndDestroy( value );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::SetDescriptionRequiredPropertyL
+// Sets description required property for device
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::SetDescriptionRequiredPropertyL(
+    CUpnpDeviceImplementation* aDevice, TInt aKey, const TDesC8& aName )
+    {
+    HBufC8* value = iSettings->GetL( aKey );
+
+    if ( !value )
+        {
+        User::Leave( KErrNotFound );
+        }
+    else
+        {
+        CleanupStack::PushL( value );
+
+        HBufC8* tmpBuf = (*value).AllocLC();
+        TPtr8 tmpPtr(tmpBuf->Des() );
+
+        RemoveWhiteSpaces( tmpPtr );
+        if ( tmpPtr.Length() == 0 )
+            {
+            User::Leave( KErrNotFound );
+            }
+        CleanupStack::PopAndDestroy( tmpBuf );
+        }
+
+    TRAPD( error, aDevice->SetDescriptionPropertyL( aName, *value ) )
+    if ( error != KErrNotFound )
+        {
+        User::LeaveIfError( error );
+        }
+
+    CleanupStack::PopAndDestroy( value );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::RemoveWhiteSpaces
+// Removes white characters from input descriptor
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::RemoveWhiteSpaces( TDes8& aString )
+    {
+    for ( TInt i=0; i<aString.Length(); i++ )
+        {
+        if ( aString[i] == ' ' || aString[i] == '\r' || aString[i] == '\n'
+                || aString[i] == '\t' )
+            {
+            aString.Replace( i, 1, KNullDesC8() );
+            i--;
+            }
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::InitPrivateDir
+// Init Media Server directory structure in private directory
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::InitPrivateDirL( RFs &aFs )
+    {
+    TParse fp;
+    TFileName path;
+    aFs.PrivatePath( path );
+    fp.Set( KDefaultMediaDrive(), &path, 0 );
+    User::LeaveIfError( fp.AddDir( KMSPublicAccessedDir() ) );
+    User::LeaveIfError( fp.AddDir( KMSDeviceXmlDescDir() ) );
+    User::LeaveIfError( fp.AddDir( KIconDirectory() ) );
+    path = fp.DriveAndPath();
+
+    aFs.MkDirAll( path ) ;
+    fp.PopDir();
+    User::LeaveIfError( fp.AddDir( KMSMediaDir ) );
+    path = fp.DriveAndPath();
+    aFs.MkDirAll( path );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::InitDescFileL
+// Checks is description file exists. If not creates it from teplate stored on Z:
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpMediaServer::InitDescFileL( RFs &aFs,
+    const TDesC& aTempleteDescFile, TBool aOverwrite )
+    {
+    TUint temp;
+    HBufC* descName = CreateFullNameL( aFs, KDefaultMediaDrive(),
+        aTempleteDescFile );
+    CleanupStack::PushL( descName );
+
+    if ( aFs.Att( *descName, temp ) != KErrNone || aOverwrite )
+        {
+
+        HBufC* templName = CreateFullNameL( aFs, KDescTemplateDrive(),
+            aTempleteDescFile );
+        CleanupStack::PushL( templName );
+        CFileMan* fileMan = CFileMan::NewL( aFs );
+        CleanupStack::PushL( fileMan );
+        User::LeaveIfError( fileMan->Copy( *templName, *descName ) );
+        User::LeaveIfError( fileMan->Attribs( *descName, KEntryAttNormal,
+            KEntryAttReadOnly, TTime( 0 ) ) );
+        CleanupStack::PopAndDestroy( fileMan );
+        CleanupStack::PopAndDestroy( templName );
+        }
+    CleanupStack::Pop( descName );
+    return descName;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::InitializeL
+// Initialize Media Server using files from drive z:
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::InitializeL( TBool aOverwrite )
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+
+    if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fs, KMSDescriptionMaxSize,
+        EDriveC ) )
+        {
+        User::Leave( KErrDiskFull );
+        }
+
+    InitPrivateDirL( fs );
+
+    delete iMsName;
+    iMsName= NULL;
+    iMsName = InitDescFileL( fs, KMSDeviceXmlDescFile(), aOverwrite );
+    iDescriptionProvider->AddUriToFileMapL( KUriMediaServer(), iMsName->Des() );
+    delete iCdName;
+    iCdName = NULL;
+    iCdName = InitDescFileL( fs, KCDXmlDescFile(), aOverwrite );
+    iDescriptionProvider->AddUriToFileMapL( KUriContentDirectory(), iCdName->Des() );
+    delete iCmName;
+    iCmName = NULL;
+    iCmName = InitDescFileL( fs, KCMXmlDescFile(), aOverwrite );
+    iDescriptionProvider->AddUriToFileMapL( KUriConnectionManager(), iCmName->Des() );
+
+    CleanupStack::PopAndDestroy( &fs );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::ResetDbL
+// Reset database, renaming name of original DB
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::ResetDbL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+
+    TFileName orgPath;
+
+    User::LeaveIfError( fs.PrivatePath( orgPath ) );
+
+    TParse fp;
+    fp.Set( KDatabaseFileName(), &orgPath, 0 );
+    orgPath = fp.FullName();
+
+    TFileName newPath;
+    newPath = orgPath;
+    newPath.Append( KBackupSuffix );
+
+    CFileMan* fileMan = CFileMan::NewL( fs );
+    CleanupStack::PushL( fileMan );
+    User::LeaveIfError( fileMan->Rename( orgPath, newPath ) );
+    CleanupStack::PopAndDestroy( fileMan );
+
+    CleanupStack::PopAndDestroy( &fs );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::DeleteDbL
+// Delete database
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::DeleteDbL()
+    {
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+
+    TFileName orgPath;
+
+    User::LeaveIfError( fs.PrivatePath( orgPath ) );
+
+    TParse fp;
+    fp.Set( KDatabaseFileName(), &orgPath, 0 );
+    orgPath = fp.FullName();
+
+    CFileMan* fileMan = CFileMan::NewL( fs );
+    CleanupStack::PushL( fileMan );
+    User::LeaveIfError( fileMan->Delete( orgPath ) );
+    CleanupStack::PopAndDestroy( fileMan );
+
+    CleanupStack::PopAndDestroy( &fs );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::SettingChangedL
+// Function notify when setting will change
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::SettingChangedL()
+    {
+    //no actions needed
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::CreateFullNameL
+// Create full name using drive MS directory structure and file name.
+// -----------------------------------------------------------------------------
+//
+HBufC* CUpnpMediaServer::CreateFullNameL( RFs &aFs, const TDesC& aDrive,
+    const TDesC& aName )
+    {
+    TParse fp;
+    TFileName path;
+    User::LeaveIfError( aFs.PrivatePath( path ) );
+    fp.Set( aDrive, &path, &aName );
+    User::LeaveIfError( fp.AddDir( KMSPublicAccessedDir() ) );
+    User::LeaveIfError( fp.AddDir( KMSDeviceXmlDescDir() ) );
+    return fp.FullName().AllocL();
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::ShareItemL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::ShareObjectL( CUpnpObject* aItem )
+    {
+    iContentDirecory->ShareObjectL( aItem );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::ShareReferenceL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::ShareReferenceL( CUpnpItem* aItem )
+    {
+    iContentDirecory->ShareReferenceL( aItem );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::ShareReferenceListL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::ShareReferenceListL( CUpnpItemList* aItemList,
+    TInt* aStatus )
+    {
+    iContentDirecory->ShareReferenceListL( aItemList, aStatus );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::ShareItemListL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::ShareItemListL( CUpnpItemList* aItemList, TInt* aStatus )
+    {
+    iContentDirecory->ShareItemListL( aItemList, aStatus );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::UnshareRootL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::UnshareRootL()
+    {
+    TBool online = ETrue;
+
+    if ( Status()==RUpnpMediaServerClient::EStartedOnline )
+        {
+        online = ETrue;
+        }
+    else if ( Status()==RUpnpMediaServerClient::EStartedOffline )
+        {
+        online = EFalse;
+        }
+
+    StopAVMediaServerImmediately( EFalse, EFalse );
+
+    DeleteDbL();
+
+    if ( online )
+        {
+        StartAVMediaServerL();
+        }
+    else
+        {
+        StartAVMediaServerOfflineL();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::UnshareItemL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::UnshareItemL( TInt aId )
+    {
+    iContentDirecory->UnshareItemL( aId );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::UnshareContainerL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::UnshareContainerL( TInt aId )
+    {
+    iContentDirecory->UnshareContainerL( aId );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::GetSharedItemL
+// -----------------------------------------------------------------------------
+//
+CUpnpItem* CUpnpMediaServer::GetSharedItemL( TInt aItem )
+    {
+    return iContentDirecory->GetSharedItemL( aItem );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::GetSingleContainerL
+// -----------------------------------------------------------------------------
+//
+CUpnpContainer* CUpnpMediaServer::GetSingleContainerL( TInt aContainerId )
+    {
+    return iContentDirecory->GetSingleContainerL( aContainerId );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::UnshareItemListL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::UnshareItemListL( RArray<TInt>& aItemList,
+    TInt* aExecutionStatus )
+    {
+    iContentDirecory->UnshareItemListL( aItemList, aExecutionStatus );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::GetSharedItemListL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::GetSharedItemListL( TInt aContId,
+    CUpnpBrowseCriteria* aBrowseCriteria, TInt* TotalMatches,
+    CUpnpItemList* aItemList )
+    {
+    iContentDirecory->GetItemListL( aContId, aBrowseCriteria, TotalMatches,
+        aItemList );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::GetSharedContainerListL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::GetSharedContainerListL( TInt aContId,
+    CUpnpBrowseCriteria* aBrowseCriteria, TInt* TotalMatches,
+    CUpnpContainerList* aContainerList )
+    {
+    iContentDirecory->GetContainerListL( aContId, aBrowseCriteria,
+        TotalMatches, aContainerList );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::GetIpAndPortL
+// -----------------------------------------------------------------------------
+//
+TInetAddr CUpnpMediaServer::GetAddress()
+    {
+    return iContentDirecory->GetAddress();
+    }
+
+// ============================= EVENT FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::SubscribeEvents
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::SubscribeEvents(
+    MUpnpContentDirectoryEventObserver* aObserver )
+    {
+    iObserverList.Append( aObserver );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::UnsubscribeEvents
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::UnsubscribeEvents(
+    MUpnpContentDirectoryEventObserver* aObserver )
+    {
+    TInt index = iObserverList.Find( aObserver );
+    if ( index != KErrNotFound )
+        {
+        iObserverList.Remove( index );
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::FileTransferEvent
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::FileTransferEvent( CUpnpFileTransferEvent* aMessage )
+    {
+    for ( TInt i=0; i<iObserverList.Count(); i++ )
+        {
+        iObserverList[i]->FileTransferEvent( aMessage );
+        }
+    delete aMessage;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::IsInterfaceUp
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpMediaServer::IsInterfaceUp()
+    {
+    return ( iMsStatus == RUpnpMediaServerClient::EStartedOnline );
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::CancelAVMediaServerStop
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::CancelAVMediaServerStop()
+    {
+    iStopAVMediaServerTimer->Cancel();
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::CanBeStopped
+// -----------------------------------------------------------------------------
+//
+TBool CUpnpMediaServer::CanBeStopped() const
+    {
+    return RUpnpMediaServerClient::EStopped == Status(); //note: Status(),not iMsStatus
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::TimerEventL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::TimerEventL( CUpnpNotifyTimer* aTimer )
+    {
+    if ( aTimer == iStopAVMediaServerTimer )
+        {
+        StopAVMediaServerImmediately( iIsSilentShutdown, EFalse );
+        }
+    else
+        {
+        CUpnpSymbianServerBase::TimerEventL( aTimer );
+        }
+    }
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::SupportedVersion
+// -----------------------------------------------------------------------------
+//
+TVersion CUpnpMediaServer::SupportedVersion() const
+    {
+    return KServerSupportedVersion;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::ServerName
+// -----------------------------------------------------------------------------
+//
+const TDesC& CUpnpMediaServer::ServerName() const
+    {
+    return KMediaServerName;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::NetworkEvent
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::NetworkEvent( CUpnpNetworkEventBase* aEvent )
+    {
+    LOG_FUNC_NAME;
+
+    if ( aEvent->SubscriberError() < KErrNone && aEvent->Type() == EUnknownEvent )
+        {
+        LOGS( "CUpnpMediaServer::NetworkEvent error" );
+        return;
+        }
+        
+    switch ( aEvent->Type() )
+        {
+        case EWlanLostEvent:
+            {
+            if ( IsInterfaceUp() )
+                {
+                StopAVMediaServerImmediately( ETrue, ETrue );
+                NotifyStatusChanged();
+                }
+            }
+            break;
+
+        case EAddressChangeEvent:
+            {
+            if ( iMsStatus == RUpnpMediaServerClient::EStartedOnline )
+                {
+                TRAPD( error, RestartAVMediaServerL() );
+                if ( error != KErrNone )
+                    {
+                    if ( iStopAVMediaServerTimer->IsActive() )
+                        {
+                        StopAVMediaServerImmediately( EFalse, EFalse );
+                        }
+                    TRAP( error, StartAVMediaServerL() );
+                    if ( error != KErrNone )
+                         {
+                         StopAVMediaServerImmediately( EFalse, EFalse );
+                         NotifyStatusChanged();
+                         }
+                     }
+                else if ( iContentDirecory )
+                    {
+                    TRAP( error, iContentDirecory->AddressChangeL() );
+                    if ( error != KErrNone )
+                         {
+                         StopAVMediaServerImmediately( EFalse, EFalse );
+                         NotifyStatusChanged();
+                         } 
+                    }                     
+                }
+            }
+            break; 
+        
+        case EConnectionClosedEvent:
+            {
+            ASSERT( iMsStatus != RUpnpMediaServerClient::EStartedOnline );
+            }
+            break;
+        }
+    }                
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::SetStatus
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::SetStatus( RUpnpMediaServerClient::TServerStatus aStatus )
+    {
+    iMsStatus = aStatus;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::NotifyStatusChanged
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::NotifyStatusChanged()
+    {
+    CUpnpMediaServerSession* ses = NULL;
+    iSessionIter.SetToFirst();
+    CSession2* cses = iSessionIter++;
+    ses = reinterpret_cast<CUpnpMediaServerSession*>( cses );
+    while ( ses )
+        {
+        ses->StatusChanged();
+        ses = reinterpret_cast<CUpnpMediaServerSession*>( iSessionIter++ );    
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpMediaServer::RunL
+// -----------------------------------------------------------------------------
+//
+void CUpnpMediaServer::RunL()
+    {
+    const RUpnpMediaServerClient::TServerStatus beforeStatus = Status();
+    CUpnpSymbianServerBase::RunL();
+    if ( Status() != beforeStatus )
+        {
+        NotifyStatusChanged();
+        }
+    }
+
+// -----------------------------------------------------------------------------
+// E32Main entry point.
+// Returns: KErrNone
+// -----------------------------------------------------------------------------
+//
+TInt E32Main()
+    {
+    return CUpnpMediaServer::StartServer(
+        KMediaServerThreadName, CUpnpMediaServer::NewLC );
+    }
+
+
+// End of File
--- a/upnpsettings/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsettings/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,48 +1,34 @@
-/*
-* Copyright (c) 2008 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:      Build information file for upnpsettings
-*
-*/
-
-// For compatibility with S60 3.2 and IAD branch
-#include "../../group/upnpplatformvar.hrh"
-
-PRJ_PLATFORMS
-
-PRJ_EXPORTS
-
-PRJ_MMPFILES
-
-// settings engine
-#include "../upnpsettingsengine/group/bld.inf"
-
-// Exports for upnpsettings
-#include "../rom/bld.inf"
-
-#ifdef FF_UPNP_FRAMEWORK_2_0  // UPnP feature flag
-    // multiselectionui
-    #include "../multiselectionui/group/bld.inf"
-
-    // upnp setup wizard
-    #include "../appwizard/group/bld.inf"
-
-    // Sharing ui
-    #include "../upnpsharingui/group/bld.inf"
-
-    // GS plugin
-    #include "../upnpgsplugin/group/bld.inf"
-
-#endif // FF_UPNP_FRAMEWORK_2_0
-
-// end of file
+/*
+* Copyright (c) 2008 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:      Build information file for upnpsettings
+*
+*/
+
+// For compatibility with S60 3.2 and IAD branch
+#include "../../group/upnpplatformvar.hrh"
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+// LOC files
+UPNP_LOC_EXPORT(upnpsettings.loc)
+
+PRJ_MMPFILES
+// none
+
+    // settings engine
+    #include "../upnpsettingsengine/group/bld.inf"
+
+// End of file
--- a/upnpsettings/loc/upnpsettings.loc	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsettings/loc/upnpsettings.loc	Mon Nov 01 12:37:49 2010 +0200
@@ -1,489 +1,489 @@
-/*
-* Copyright (c) 2008 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:      upnpsettings localisable strings
-*
-*/
-
-
-
-
-
-
-// LOCALISATION STRINGS
-
-/***************************************************
- *
- *                  upnpappwizard 
- *
- ***************************************************
-*/ 
-
-
-//d:Text for the wait dialog when file sharing is in progress
-//l:popup_note_wait_window
-//r:1.0
-//
-#define qtn_iupnp_wait_sharing              "Turning sharing on"
-
-//d:Text for the wait dialog shown while sharing is turned off
-//l:popup_note_wait_window
-//r:wk50/2008
-//
-#define qtn_iupnp_wait_sharing_off          "Turning sharing off"
-
-//d:Message when starting sharing
-//d:Purpose is to describe that this is a background operation
-//l:popup_info_list_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_wait_updating_content     "Updating shared content on the background. This may take several minutes. The application can be closed meanwhile."
-
-//d:Message title when starting background sharing
-//l:heading_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_updating_content_header   "Updating shared content"
-
-//d:Error message when file sharing activation fails
-//l:popup_note_window/opt2
-//r:1.0
-//
-#define qtn_iupnp_start_sharing_error       "Sharing activation failed"
-
-//d:Header for wizard step 1
-//l:heading_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_head_1             "Setup wizard 1/9"
-
-//d:Message for wizard step 1. 
-//l:popup_info_list_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_1                  "This wizard sets up Home Media for browsing and sharing files. Please run the wizard within range of your WLAN."
-
-//d:Header for wizard step 2
-//l:heading_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_head_2             "Device name 2/9"
-
-//d:Message for wizard step 2
-//l:popup_info_list_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_2                  "Enter a device name you want to show on your network"
-
-//d:Header for wizard step 3
-//l:heading_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_head_3             "My device name 3/9"
-
-//d:Header for wizard step 4
-//l:heading_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_head_4             "Access point 4/9"
-
-//d:Message for wizard step 4
-//l:popup_info_list_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_4                  "Define your Home access point or choose %U to select it manually each time"
-
-//d:Header for wizard step 5
-//l:heading_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_head_5             "Home access point 5/9"
-
-//d:Static list item in wizard iap selection list. 
-//l:list_single_pane_t1_cp2
-//r:1.0
-//
-#define qtn_iupnp_always_ask                "Always ask"
-
-//d:Static list item in wizard iap selection list.
-//d:The user can create and edit iap items.
-//l:list_single_pane_t1_cp2
-//r:1.0
-//
-#define qtn_iupnp_create_new                "Create / edit"
-
-//d:Header for wizard step 6
-//l:heading_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_head_6             "File sharing 6/9"
-
-//d:Message for wizard step 6.
-//l:popup_info_list_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_wizard_6_2                "Select the content that is shown on the Home Network when sharing is on. You can select to share individual albums and playlists or all the files of a media type."
-
-//d:Header for wizard step 7
-//l:heading_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_head_7             "Share images & video 7/9"
-
-//d:Header for wizard step 8
-//l:heading_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_head_8             "Share music 8/9"
-
-//d:Header for wizard step 9
-//l:heading_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_head_9             "Setup wizard 9/9"
-
-//d:Message for wizard step 9a.
-//l:popup_info_list_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_wizard_9a_2               "The Home Media options are available in media applications and sharing is turned on."
-
-//d:Message for wizard step 9b.
-//l:popup_info_list_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_wizard_9b_2               "The Home Media options are available in media applications but sharing is turned off."
-
-//d:Middle soft key
-//d:for wizard dialogs
-//l:control_pane_t1/opt7
-//r:wk50/2008
-//
-#define qtn_iupnp_softkey_next              "Next"
-
-
-/***************************************************
- *
- *                  upnpmultiselectionui 
- *
- ***************************************************
-*/
-
-
-//d:Title text for the multiselection dialog when
-//d:image and video albums are shown
-//d:This is visible in the title pane
-//l:title_pane_t2/opt9
-//r:1.0
-//
-#define qtn_iupnp_title_visual              "Images & videos"
-
-//d:Title text for the multiselection dialog when
-//d:playlists are shown
-//d:This is visible in the title pane
-//l:title_pane_t2/opt9
-//r:1.0
-//
-#define qtn_iupnp_title_music               "Music"
-
-//d:Text for the second item of the multiselection listbox
-//d:With this selection all files from specific folders
-//d:will be shared
-//l:list_single_graphic_pane_t1_cp2
-//r:1.0
-//
-#define qtn_iupnp_set_share_all             "Share all files"
-
-//d:Text for wait note
-//d:Indicates that phone is collecting files to share
-//l:popup_note_wait_window
-//r:1.0
-//
-#define qtn_iupnp_saving_changes_note       "Saving changes"
-
-//d:Text for wait note
-//d:Indicates that phone is searching files to display to user
-//l:popup_note_wait_window
-//r:1.0
-//
-#define qtn_iupnp_searching_files_note      "Searching files"
-
-//d:Text for the first item of the multiselection listbox
-//d:With this selection all files from specific folders
-//d:will be shared
-//l:list_single_graphic_pane_t1_cp2
-//r:1.0
-//
-#define qtn_iupnp_set_do_not_share          "Do not share"
-
-//d:Middle soft key
-//d:for unselecting the playlists & albums
-//l:control_pane_t3/opt7
-//r:wk50/2008
-//
-#define qtn_iupnp_msk_unselect              "Unselect"
-
-
-/***************************************************
- *
- *                  upnpgsplugin
- *
- ***************************************************
-*/
-
-//d:line text for the Home Media -listbox item of
-//d:Settings
-//l:list_single_large_graphic_pane_t1
-//r:wk50/2008
-//
-#define qtn_iupnp_gs_caption                "Home Media"
-
-//d:upnp gs settings view title
-//d:This is visible in the title pane
-//l:title_pane_t2/opt9
-//r:1.0
-//
-#define qtn_iupnp_title_sharing             "Settings"
-
-
-//d:First line text for the access point -listbox item of
-//d:settings dialog
-//d:Through "home access point" phone can communicate with
-//d:other devices in the network
-//l:list_setting_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_home_ap                   "Home access point"
-
-//d:First line text for the device name -listbox item of
-//d:settings dialog
-//d:User can set the device name that other devices can see
-//l:list_setting_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_device_name               "Device name"
-
-//d:Warning text when "all networks" selected from the allowed connections
-//d:of settings dialog
-//l:popup_note_window/opt1
-//r:1.0
-//
-#define qtn_iupnp_conf_unsecure             "Unsecured wireless LAN connections involve security hazards. Continue anyway?"
-
-//d:Left softkey text for the error dialog of sharing activation
-//l:control_pane_t1/opt7
-//r:1.0
-//
-#define qtn_iupnp_conf_continue             "Continue"
-
-//d:Text for information note 
-//d:Indicates that setting could not be set yet because connection active 
-//l:popup_note_window/opt1
-//r:1.0
-//
-#define qtn_iupnp_ibu_gallery_connectionactive_note     "Cannot change setting while connection to home media is active"
-
-//d:Heading of the IAP setting page
-//l:list_setting_pane_t1
-//r:wk51/2008
-//
-#define qtn_iupnp_ap_head_set               "Home access point"
-
-//d:Heading of the Device Name setting page
-//l:list_setting_pane_t1
-//r:wk51/2008
-//
-#define qtn_iupnp_head_set_device_name      "Device name"
-
-//d:Home Network IAP option text "User defined" in setting item
-//l:set_value_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_ap_user_defined           "User Defined"
-
-//d:Home Network IAP option text "Always ask" in setting page
-//l:list_set_graphic_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_ap_ask_set                "Always ask"
-
-//d:Home Network IAP option text "Create / edit" in setting page
-//l:list_set_graphic_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_ap_new_set                "Create / edit"
-
-//d:Home Network IAP option text "None" in setting page
-//l:list_set_graphic_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_ap_none_set               "None"
-
-//d:Text for information note 
-//d:Indicates that Gallery UI has been changed
-//l:heading_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_ibu_gallery_update_note_title_2   "Availability changed"
-
-//d:Text for information note
-//d:Indicates that Home Network features are available in media gallery
-//l:popup_info_list_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_ibu_gallery_update_note_2         "Home Media features are now available. Use \"Sharing\" to select what content you want to share."
-
-//d:Text for information note 
-//d:Indicates that Home Network features are removed from media gallery
-//l:popup_info_list_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_ibu_gallery_notavail_note_2       "Home Media features removed from the device."
-
-//d:Supported memory setting title in settings page
-//l:list_setting_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_copy_location                     "Copy location"
-
-
-/***************************************************
- *
- *                  upnpsharingui
- *
- ***************************************************
-*/
-
-//d:Text for the title of share content -dialog
-//d:This is visible in the title pane
-//d:Collection of shared files
-//l:title_pane_t2/opt9
-//r:1.0
-//
-#define qtn_iupnp_title_share               "Share content"
-
-//d:Menu text for manual refresh
-//l:list_single_pane_t1_cp2
-//r:1.0
-//
-#define qtn_iupnp_options_update_content    "Refresh collection"
-
-//d:First line text for the settings listbox item of
-//d:share content dialog
-//l:list_setting_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_set_sharing               "Sharing"
-
-//d:Second line text for the share content listbox item
-//d:Indicates that file sharing is active
-//l:set_value_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_set_sharing_on            "On"
-
-//d:Second line text for the shard content listbox
-//d:Indicates that file sharing is disabled
-//l:set_value_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_set_sharing_off           "Off"
-
-//d:Information note text when sharing has been turned off.
-//d:Indicates that phone can not be seen through wlan network.
-//l:popup_note_window/opt2
-//r:wk51/2008
-//
-#define qtn_iupnp_phone_hidden              "Phone is now hidden from Home network"
-
-//d:Information note text when sharing has been turned on.
-//d:Indicates that phone can be seen through wlan network.
-//l:popup_note_window/opt2
-//r:wk51/2008
-//
-#define qtn_iupnp_phone_visible             "Phone is now visible to Home network"
-
-//d:First line text for the share content -listbox item
-//d:With this option user can select image and video files
-//d:and albums for sharing
-//l:list_setting_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_visual_albums             "Images & videos"
-
-//d:First line text for the music listbox item of share content -dialog
-//d:With this option user can select music files
-//d:and playlists for sharing
-//l:list_setting_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_music_pl                  "Music"
-
-//d:Alternative second line text for the images & videos -listbox item of 
-//d:share content -dialog
-//d:Indicates that sharing is in progress and displays the progress in percents
-//l:set_value_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_updating_progress         "Updating %N%"
-
-//d:Alternative second line text for the images & videos -listbox item of 
-//d:share content -dialog
-//d:Indicates that nothing (images & videos) is shared
-//l:set_value_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_visual_nothing            "Nothing selected"
-
-//d:Alternative second line text for the images & videos -listbox item of 
-//d:share content -dialog
-//d:Indicates that some files
-//l:set_value_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_visual_one                "Selected files"
-
-//d:Alternative second line text for the images & videos -listbox item of 
-//d:share content -dialog
-//d:Indicates that all files are shared
-//l:set_value_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_visual_many               "All files"
-
-//d:Alternative second line text for the music listbox item of
-//d:share content -dialog
-//d:Indicates that nothing (music) is shared
-//l:set_value_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_music_nothing             "Nothing selected"
-
-//d:Alternative second line text for the music listbox item of 
-//d:share content -dialog
-//d:Indicates that some playlists are shared
-//l:set_value_pane_t1
-//r:2.0
-//
-#define qtn_iupnp_music_one                 "Selected playlists"
-
-//d:Alternative second line text for the music listbox item of 
-//d:share content -dialog
-//d:Indicates that all music files are shared
-//l:set_value_pane_t1
-//r:1.0
-//
-#define qtn_iupnp_music_many                "All files"
-
-// End of File
-
+/*
+* Copyright (c) 2008 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:      upnpsettings localisable strings
+*
+*/
+
+
+
+
+
+
+// LOCALISATION STRINGS
+
+/***************************************************
+ *
+ *                  upnpappwizard 
+ *
+ ***************************************************
+*/ 
+
+
+//d:Text for the wait dialog when file sharing is in progress
+//l:popup_note_wait_window
+//r:1.0
+//
+#define qtn_iupnp_wait_sharing              "Turning sharing on"
+
+//d:Text for the wait dialog shown while sharing is turned off
+//l:popup_note_wait_window
+//r:wk50/2008
+//
+#define qtn_iupnp_wait_sharing_off          "Turning sharing off"
+
+//d:Message when starting sharing
+//d:Purpose is to describe that this is a background operation
+//l:popup_info_list_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_wait_updating_content     "Updating shared content on the background. This may take several minutes. The application can be closed meanwhile."
+
+//d:Message title when starting background sharing
+//l:heading_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_updating_content_header   "Updating shared content"
+
+//d:Error message when file sharing activation fails
+//l:popup_note_window/opt2
+//r:1.0
+//
+#define qtn_iupnp_start_sharing_error       "Sharing activation failed"
+
+//d:Header for wizard step 1
+//l:heading_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_head_1             "Setup wizard 1/9"
+
+//d:Message for wizard step 1. 
+//l:popup_info_list_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_1                  "This wizard sets up Home Media for browsing and sharing files. Please run the wizard within range of your WLAN."
+
+//d:Header for wizard step 2
+//l:heading_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_head_2             "Device name 2/9"
+
+//d:Message for wizard step 2
+//l:popup_info_list_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_2                  "Enter a device name you want to show on your network"
+
+//d:Header for wizard step 3
+//l:heading_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_head_3             "My device name 3/9"
+
+//d:Header for wizard step 4
+//l:heading_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_head_4             "Access point 4/9"
+
+//d:Message for wizard step 4
+//l:popup_info_list_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_4                  "Define your Home access point or choose \"%U\" to select it manually each time"
+
+//d:Header for wizard step 5
+//l:heading_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_head_5             "Home access point 5/9"
+
+//d:Static list item in wizard iap selection list. 
+//l:list_single_pane_t1_cp2
+//r:1.0
+//
+#define qtn_iupnp_always_ask                "Always ask"
+
+//d:Static list item in wizard iap selection list.
+//d:The user can create and edit iap items.
+//l:list_single_pane_t1_cp2
+//r:1.0
+//
+#define qtn_iupnp_create_new                "Create / edit"
+
+//d:Header for wizard step 6
+//l:heading_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_head_6             "File sharing 6/9"
+
+//d:Message for wizard step 6.
+//l:popup_info_list_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_wizard_6_2                "Select the content that is shown on the Home Network when sharing is on. You can select to share individual albums and playlists or all the files of a media type."
+
+//d:Header for wizard step 7
+//l:heading_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_head_7             "Share images & video 7/9"
+
+//d:Header for wizard step 8
+//l:heading_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_head_8             "Share music 8/9"
+
+//d:Header for wizard step 9
+//l:heading_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_head_9             "Setup wizard 9/9"
+
+//d:Message for wizard step 9a.
+//l:popup_info_list_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_wizard_9a_2               "The Home Media options are available in media applications and sharing is turned on."
+
+//d:Message for wizard step 9b.
+//l:popup_info_list_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_wizard_9b_2               "The Home Media options are available in media applications but sharing is turned off."
+
+//d:Middle soft key
+//d:for wizard dialogs
+//l:control_pane_t1/opt7
+//r:wk50/2008
+//
+#define qtn_iupnp_softkey_next              "Next"
+
+
+/***************************************************
+ *
+ *                  upnpmultiselectionui 
+ *
+ ***************************************************
+*/
+
+
+//d:Title text for the multiselection dialog when
+//d:image and video albums are shown
+//d:This is visible in the title pane
+//l:title_pane_t2/opt9
+//r:1.0
+//
+#define qtn_iupnp_title_visual              "Images & videos"
+
+//d:Title text for the multiselection dialog when
+//d:playlists are shown
+//d:This is visible in the title pane
+//l:title_pane_t2/opt9
+//r:1.0
+//
+#define qtn_iupnp_title_music               "Music"
+
+//d:Text for the second item of the multiselection listbox
+//d:With this selection all files from specific folders
+//d:will be shared
+//l:list_single_graphic_pane_t1_cp2
+//r:1.0
+//
+#define qtn_iupnp_set_share_all             "Share all files"
+
+//d:Text for wait note
+//d:Indicates that phone is collecting files to share
+//l:popup_note_wait_window
+//r:1.0
+//
+#define qtn_iupnp_saving_changes_note       "Saving changes"
+
+//d:Text for wait note
+//d:Indicates that phone is searching files to display to user
+//l:popup_note_wait_window
+//r:1.0
+//
+#define qtn_iupnp_searching_files_note      "Searching files"
+
+//d:Text for the first item of the multiselection listbox
+//d:With this selection all files from specific folders
+//d:will be shared
+//l:list_single_graphic_pane_t1_cp2
+//r:1.0
+//
+#define qtn_iupnp_set_do_not_share          "Do not share"
+
+//d:Middle soft key
+//d:for unselecting the playlists & albums
+//l:control_pane_t3/opt7
+//r:wk50/2008
+//
+#define qtn_iupnp_msk_unselect              "Unselect"
+
+
+/***************************************************
+ *
+ *                  upnpgsplugin
+ *
+ ***************************************************
+*/
+
+//d:line text for the Home Media -listbox item of
+//d:Settings
+//l:list_single_large_graphic_pane_t1
+//r:wk50/2008
+//
+#define qtn_iupnp_gs_caption                "Home Media"
+
+//d:upnp gs settings view title
+//d:This is visible in the title pane
+//l:title_pane_t2/opt9
+//r:1.0
+//
+#define qtn_iupnp_title_sharing             "Settings"
+
+
+//d:First line text for the access point -listbox item of
+//d:settings dialog
+//d:Through "home access point" phone can communicate with
+//d:other devices in the network
+//l:list_setting_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_home_ap                   "Home access point"
+
+//d:First line text for the device name -listbox item of
+//d:settings dialog
+//d:User can set the device name that other devices can see
+//l:list_setting_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_device_name               "Device name"
+
+//d:Warning text when "all networks" selected from the allowed connections
+//d:of settings dialog
+//l:popup_note_window/opt1
+//r:1.0
+//
+#define qtn_iupnp_conf_unsecure             "Unsecured wireless LAN connections involve security hazards. Continue anyway?"
+
+//d:Left softkey text for the error dialog of sharing activation
+//l:control_pane_t1/opt7
+//r:1.0
+//
+#define qtn_iupnp_conf_continue             "Continue"
+
+//d:Text for information note 
+//d:Indicates that setting could not be set yet because connection active 
+//l:popup_note_window/opt1
+//r:1.0
+//
+#define qtn_iupnp_ibu_gallery_connectionactive_note     "Cannot change setting while connection to home media is active"
+
+//d:Heading of the IAP setting page
+//l:list_setting_pane_t1
+//r:wk51/2008
+//
+#define qtn_iupnp_ap_head_set               "Home access point"
+
+//d:Heading of the Device Name setting page
+//l:list_setting_pane_t1
+//r:wk51/2008
+//
+#define qtn_iupnp_head_set_device_name      "Device name"
+
+//d:Home Network IAP option text "User defined" in setting item
+//l:set_value_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_ap_user_defined           "User Defined"
+
+//d:Home Network IAP option text "Always ask" in setting page
+//l:list_set_graphic_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_ap_ask_set                "Always ask"
+
+//d:Home Network IAP option text "Create / edit" in setting page
+//l:list_set_graphic_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_ap_new_set                "Create / edit"
+
+//d:Home Network IAP option text "None" in setting page
+//l:list_set_graphic_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_ap_none_set               "None"
+
+//d:Text for information note 
+//d:Indicates that Gallery UI has been changed
+//l:heading_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_ibu_gallery_update_note_title_2   "Availability changed"
+
+//d:Text for information note
+//d:Indicates that Home Network features are available in media gallery
+//l:popup_info_list_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_ibu_gallery_update_note_2         "Home Media features are now available. Use \"Sharing\" to select what content you want to share."
+
+//d:Text for information note 
+//d:Indicates that Home Network features are removed from media gallery
+//l:popup_info_list_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_ibu_gallery_notavail_note_2       "Home Media features removed from the device."
+
+//d:Supported memory setting title in settings page
+//l:list_setting_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_copy_location                     "Copy location"
+
+
+/***************************************************
+ *
+ *                  upnpsharingui
+ *
+ ***************************************************
+*/
+
+//d:Text for the title of share content -dialog
+//d:This is visible in the title pane
+//d:Collection of shared files
+//l:title_pane_t2/opt9
+//r:1.0
+//
+#define qtn_iupnp_title_share               "Share content"
+
+//d:Menu text for manual refresh
+//l:list_single_pane_t1_cp2
+//r:1.0
+//
+#define qtn_iupnp_options_update_content    "Refresh collection"
+
+//d:First line text for the settings listbox item of
+//d:share content dialog
+//l:list_setting_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_set_sharing               "Sharing"
+
+//d:Second line text for the share content listbox item
+//d:Indicates that file sharing is active
+//l:set_value_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_set_sharing_on            "On"
+
+//d:Second line text for the shard content listbox
+//d:Indicates that file sharing is disabled
+//l:set_value_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_set_sharing_off           "Off"
+
+//d:Information note text when sharing has been turned off.
+//d:Indicates that phone can not be seen through wlan network.
+//l:popup_note_window/opt2
+//r:wk51/2008
+//
+#define qtn_iupnp_phone_hidden              "Phone is now hidden from Home network"
+
+//d:Information note text when sharing has been turned on.
+//d:Indicates that phone can be seen through wlan network.
+//l:popup_note_window/opt2
+//r:wk51/2008
+//
+#define qtn_iupnp_phone_visible             "Phone is now visible to Home network"
+
+//d:First line text for the share content -listbox item
+//d:With this option user can select image and video files
+//d:and albums for sharing
+//l:list_setting_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_visual_albums             "Images & videos"
+
+//d:First line text for the music listbox item of share content -dialog
+//d:With this option user can select music files
+//d:and playlists for sharing
+//l:list_setting_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_music_pl                  "Music"
+
+//d:Alternative second line text for the images & videos -listbox item of 
+//d:share content -dialog
+//d:Indicates that sharing is in progress and displays the progress in percents
+//l:set_value_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_updating_progress         "Updating %N%"
+
+//d:Alternative second line text for the images & videos -listbox item of 
+//d:share content -dialog
+//d:Indicates that nothing (images & videos) is shared
+//l:set_value_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_visual_nothing            "Nothing selected"
+
+//d:Alternative second line text for the images & videos -listbox item of 
+//d:share content -dialog
+//d:Indicates that some files
+//l:set_value_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_visual_one                "Selected files"
+
+//d:Alternative second line text for the images & videos -listbox item of 
+//d:share content -dialog
+//d:Indicates that all files are shared
+//l:set_value_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_visual_many               "All files"
+
+//d:Alternative second line text for the music listbox item of
+//d:share content -dialog
+//d:Indicates that nothing (music) is shared
+//l:set_value_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_music_nothing             "Nothing selected"
+
+//d:Alternative second line text for the music listbox item of 
+//d:share content -dialog
+//d:Indicates that some playlists are shared
+//l:set_value_pane_t1
+//r:2.0
+//
+#define qtn_iupnp_music_one                 "Selected playlists"
+
+//d:Alternative second line text for the music listbox item of 
+//d:share content -dialog
+//d:Indicates that all music files are shared
+//l:set_value_pane_t1
+//r:1.0
+//
+#define qtn_iupnp_music_many                "All files"
+
+// End of File
+
Binary file upnpsettings/upnpsettingsengine/cenrep/20009CAE.txt has changed
--- a/upnpsettings/upnpsettingsengine/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsettings/upnpsettingsengine/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,53 +1,50 @@
-/*
-* Copyright (c) 2006-2008 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:      Build information file for project SettingsEngine
-*
-*/
-
-
-
-
-
-
-PRJ_PLATFORMS
-DEFAULT
-
-PRJ_EXPORTS
-
-// Central repository default keys
-../cenrep/20009CAE.txt    /epoc32/release/winscw/udeb/z/private/10202be9/20009cae.txt
-../cenrep/20009CAE.txt    /epoc32/release/winscw/urel/z/private/10202be9/20009cae.txt
-../cenrep/20009CAE.txt    /epoc32/release/armv5/udeb/z/private/10202be9/20009cae.txt
-../cenrep/20009CAE.txt    /epoc32/release/armv5/urel/z/private/10202be9/20009cae.txt
-../conf/upnpsettingsengine.confml              APP_LAYER_CONFML(upnpsettingsengine.confml)
-../conf/upnpsettingsengine_20009CAE.crml       APP_LAYER_CRML(upnpsettingsengine_20009CAE.crml)
-
-// Backup registration file
-#ifndef __COMMDB_PROTECTION
-backup_registration.xml  /epoc32/data/z/private/20009CAE/backup_registration.xml  
-backup_registration.xml  /epoc32/release/winscw/udeb/z/private/20009CAE/backup_registration.xml 
-backup_registration.xml  /epoc32/release/winscw/urel/z/private/20009CAE/backup_registration.xml
-#endif
-
-
-// ADO internal interfaces
-../inc/upnpsettingsengine.h        |../../../inc/upnpsettingsengine.h
-../inc/upnpsettingsengine.hrh      |../../../inc/upnpsettingsengine.hrh
-../inc/upnpapplicationcrkeys.h     |../../../inc/upnpapplicationcrkeys.h
-
-PRJ_MMPFILES
-upnpsettingsengine.mmp
-
-
-// End of file
+/*
+* Copyright (c) 2006-2008 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:      Build information file for project SettingsEngine
+*
+*/
+
+#include <platform_paths.hrh>
+
+PRJ_PLATFORMS
+DEFAULT
+
+PRJ_EXPORTS
+
+// Central repository default keys
+../cenrep/20009CAE.txt    /epoc32/release/winscw/udeb/z/private/10202be9/20009cae.txt
+../cenrep/20009CAE.txt    /epoc32/release/winscw/urel/z/private/10202be9/20009cae.txt
+../cenrep/20009CAE.txt    /epoc32/release/armv5/udeb/z/private/10202be9/20009cae.txt
+../cenrep/20009CAE.txt    /epoc32/release/armv5/urel/z/private/10202be9/20009cae.txt
+../conf/upnpsettingsengine.confml              APP_LAYER_CONFML(upnpsettingsengine.confml)
+../conf/upnpsettingsengine_20009CAE.crml       APP_LAYER_CRML(upnpsettingsengine_20009CAE.crml)
+
+// Backup registration file
+#ifndef __COMMDB_PROTECTION
+backup_registration.xml  /epoc32/data/z/private/20009CAE/backup_registration.xml  
+backup_registration.xml  /epoc32/release/winscw/udeb/z/private/20009CAE/backup_registration.xml 
+backup_registration.xml  /epoc32/release/winscw/urel/z/private/20009CAE/backup_registration.xml
+#endif
+
+
+// ADO internal interfaces
+../inc/upnpsettingsengine.h        |../../../inc/upnpsettingsengine.h
+../inc/upnpsettingsengine.hrh      |../../../inc/upnpsettingsengine.hrh
+../inc/upnpapplicationcrkeys.h     |../../../inc/upnpapplicationcrkeys.h
+
+PRJ_MMPFILES
+upnpsettingsengine.mmp
+
+
+// End of file
--- a/upnpsettings/upnpsettingsengine/group/upnpsettingsengine.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsettings/upnpsettingsengine/group/upnpsettingsengine.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,68 +1,69 @@
-/*
-* Copyright (c) 2006-2009 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:      Project definition file for project SettingsEngine
-*
-*/
-
-
-
-
-
-
-#include "../../../group/upnpplatformvar.hrh"
-
-TARGET upnpsettingsengine.dll
-TARGETTYPE dll
-UID 0x1000008d 0x20009CAE
-
-// Enable UPnPSecurity
-MACRO ENABLE_UPNP_SECURITY
-
-// Capability assignment.
-CAPABILITY CAP_GENERAL_DLL
-VENDORID VID_DEFAULT
-
-// SIS installation + IAD support
-VERSION 10.1
-paged
-
-//User include paths
-USERINCLUDE ../inc
-USERINCLUDE ../../../inc
-
-// System include paths
-MW_LAYER_SYSTEMINCLUDE
-
-SOURCEPATH ../src
-SOURCE upnpsettingsengine.cpp
-
-LIBRARY euser.lib
-LIBRARY bafl.lib
-LIBRARY centralrepository.lib
-LIBRARY upnpserviceframework.lib
-LIBRARY avmediaserverclient.lib
-LIBRARY upnpipserversutils.lib
-LIBRARY efsrv.lib
-LIBRARY estor.lib
-
-// PathInfo
-LIBRARY PlatformEnv.lib
-LIBRARY commdb.lib
-
-// Connection Manager, new APIs for getting IAPs, etc.
-LIBRARY cmmanager.lib
-
-DEBUGLIBRARY flogger.lib
-
-// End of file
+/*
+* Copyright (c) 2006-2009 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:      Project definition file for project SettingsEngine
+*
+*/
+
+
+
+
+
+
+#include "../../../group/upnpplatformvar.hrh"
+
+TARGET upnpsettingsengine.dll
+TARGETTYPE dll
+UID 0x1000008d 0x20009CAE
+
+// Enable UPnPSecurity
+MACRO ENABLE_UPNP_SECURITY
+
+// Capability assignment.
+CAPABILITY CAP_GENERAL_DLL
+VENDORID VID_DEFAULT
+
+// SIS installation + IAD support
+VERSION 10.1
+paged
+
+//User include paths
+USERINCLUDE ../inc
+USERINCLUDE ../../../inc
+
+// System include paths
+MW_LAYER_SYSTEMINCLUDE
+
+SOURCEPATH ../src
+SOURCE upnpsettingsengine.cpp
+
+LIBRARY euser.lib
+LIBRARY bafl.lib
+LIBRARY centralrepository.lib
+LIBRARY upnpserviceframework.lib
+LIBRARY avmediaserverclient.lib
+LIBRARY upnpipserversutils.lib
+LIBRARY efsrv.lib
+LIBRARY estor.lib
+
+// PathInfo
+LIBRARY PlatformEnv.lib
+LIBRARY commdb.lib
+
+// Connection Manager, new APIs for getting IAPs, etc.
+LIBRARY cmmanager.lib
+LIBRARY apengine.lib 
+
+DEBUGLIBRARY flogger.lib
+
+// End of file
--- a/upnpsettings/upnpsettingsengine/inc/upnpapplicationcrkeys.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsettings/upnpsettingsengine/inc/upnpapplicationcrkeys.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,62 +1,62 @@
-/*
-* Copyright (c) 2006-2007 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:      Key definitions used in central repository
-*
-*/
-
-
-
-
-
-
-#ifndef UPNPAPPLICATIONCRKEYS_H
-#define UPNPAPPLICATIONCRKEYS_H
-
-#include <e32std.h>
-
-/**
- * Software Installer settings
- *
- */
-const TUid KCRUidUPnPApplication = {0x20009cae};
-
-/**
- * KUPnPAppAccessPointSetting
- * Defines the used access point setting for UPnP.
- *
- */
-const TUint32 KUPnPAppAccessPointSetting = 0x00000001;
-
-/**
- * KUPnPAppWapId
- * Defines the iap wap id for Home Network application.
- *
- */
-const TUint32 KUPnPAppWapId = 0x00000002;
-
-/**
- * KUPnPAppFirstStart
- * Defines if this is the first start of the home network
- */
-const TUint32 KUPnPAppFirstStart = 0x00000003;
-
-/**
- * KUPnPAppMediaServerIcon
- * Defines if the icon is set to mediaserver
- */
-const TUint32 KUPnPAppMediaServerIcon = 0x00000004;
-
-
-#endif  // UPNPAPPLICATIONCRKEYS_H
-// End of file
+/*
+* Copyright (c) 2006-2007 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:      Key definitions used in central repository
+*
+*/
+
+
+
+
+
+
+#ifndef UPNPAPPLICATIONCRKEYS_H
+#define UPNPAPPLICATIONCRKEYS_H
+
+#include <e32std.h>
+
+/**
+ * Common upnp settings
+ *
+ */
+const TUid KCRUidUPnPApplication = {0x20009cae};
+
+/**
+ * KUPnPAppAccessPointSetting
+ * Defines the used access point setting for UPnP.
+ *
+ */
+const TUint32 KUPnPAppAccessPointSetting = 0x00000001;
+
+/**
+ * KUPnPAppWapId
+ * Defines the iap wap id for Home Network application.
+ *
+ */
+const TUint32 KUPnPAppWapId = 0x00000002;
+
+/**
+ * KUPnPAppFirstStart
+ * Defines if this is the first start of the home network
+ */
+const TUint32 KUPnPAppFirstStart = 0x00000003;
+
+/**
+ * KUPnPAppMediaServerIcon
+ * Defines if the icon is set to mediaserver
+ */
+const TUint32 KUPnPAppMediaServerIcon = 0x00000004;
+
+
+#endif  // UPNPAPPLICATIONCRKEYS_H
+// End of file
--- a/upnpsettings/upnpsettingsengine/inc/upnpsettingsengine.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsettings/upnpsettingsengine/inc/upnpsettingsengine.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,288 +1,290 @@
-/*
-* Copyright (c) 2006-2008 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:      Settings Engine class definition
- *
-*/
-
-
-
-
-
-
-#ifndef __UPNPSETTINGSENGINE_H__
-#define __UPNPSETTINGSENGINE_H__
-
-// INCLUDE FILES
-
-#include <e32base.h>    // CBase
-#include <e32std.h>     // TBuf
-
-// CONSTANTS
-const TInt KMaxFriendlyNameLength( 64 );
-
-// FORWARD DECLARATIONS
-class CRepository;
-class CUpnpSettings;
-class CUpnpMediaServerSettings;
-
-// CLASS DECLARATION
-/**
- *  Settings engine class for UPnP Home Connect Application
- *  @lib upnpapplicationengine.lib
- *  @since S60 3.1
- */
-class CUPnPSettingsEngine : public CBase
-    {
-public: // Constructors and destructor
-
-    /**
-     * Two-phased constructor.
-     */
-    IMPORT_C static CUPnPSettingsEngine* NewL();
-
-    /**
-     * Two-phased constructor.
-     */
-    IMPORT_C static CUPnPSettingsEngine* NewLC();
-
-    /**
-     * Destructor.
-     */
-    IMPORT_C virtual ~CUPnPSettingsEngine();
-        
-        
-public: // new functions
-
-    /**
-     * Sets friendly name
-     * @since S60 3.1
-     * @param aFriendlyName, reference containing the new friendly name
-     * @return TInt,  indicates the success of the call
-     */
-    IMPORT_C TInt SetLocalFriendlyName( 
-        const TDesC8& aFriendlyName ) const;
-
-    /**
-     * Gets friendly name
-     * @since S60 3.1
-     * @param aFriendlyName, reference where name is updated
-     * @return TInt, indicates the success of the call
-     */
-    IMPORT_C TInt GetLocalFriendlyName( 
-        TDes8& aFriendlyName ) const;
-
-
-    /**
-     * Sets selected Access point
-     * @since S60 3.1
-     * @param aIAP, the IAP id
-     * @return TInt, TInt indicates the success of the call
-     */
-    IMPORT_C TInt SetAccessPoint( const TInt aIAP );
-        
-        
-    /**
-     * Gets Access Point information
-     * @since S60 3.1
-     * @param aIAP, reference where IAP id is put
-     * @return TInt, indicates the success of the call
-     */
-    IMPORT_C TInt GetAccessPoint( TInt& aIAP );
-        
-        
-    /**
-     * Sets selected Access point setting
-     * @since S60 3.1
-     * @param aIAPSetting, the IAP setting
-     * @return TInt, TInt indicates the success of the call
-     */
-    IMPORT_C TInt SetAccessPointSetting( const TInt aIAPSetting );
-        
-        
-    /**
-     * Gets Access Point setting
-     * @since S60 3.1
-     * @param aIAPSetting, reference to access point setting
-     * @return TInt, indicates the success of the call
-     */
-    IMPORT_C TInt GetAccessPointSetting( TInt& aIAPSetting );
-        
-        
-    /**
-     * Sets selected wap access point id
-     * @since S60 3.1
-     * @param aWapId, the wap access point id
-     * @return TInt, TInt indicates the success of the call
-     */
-    IMPORT_C TInt SetWapId( const TInt aWapId );
-        
-        
-    /**
-     * Gets selected wap access point id
-     * @since S60 3.1
-     * @param aWapId, reference to wap access point id
-     * @return TInt, TInt indicates the success of the call
-     */
-    IMPORT_C TInt GetWapId( TInt& aWapId );
-
-    /**
-     * Gets information if this is the first start of home network
-     * @since S60 3.1
-     * @param aFirstStart, reference to first start information
-     * @return TInt, TInt indicates the success of the call
-     */
-    IMPORT_C TInt GetFirstStart( TInt& aFirstStart );
-
-    /**
-     * Sets information if this is the first start of home network
-     * @since S60 3.1
-     * @param const aFirstStart, the new first start value
-     * @return TInt, TInt indicates the success of the call
-     */
-    IMPORT_C TInt SetFirstStart( const TInt aFirstStart );
-        
-    /**
-     * Sets the mandatory manufacturer settings to media server
-     * @since S60 3.1
-     * @return TInt, TInt indicates the success of the call
-     */
-    IMPORT_C TInt SetManufacturerParamsL() const;
-
-    /**
-     * Gets the drive for the copy operation
-     * @since S60 3.2
-     * @param aDrive, reference to copy location drive
-     */
-    IMPORT_C void GetCopyLocationDriveL( TDriveNumber& aDrive ) const;
-
-    /**
-     * Gets the location for the copy operation
-     * @since S60 3.2
-     * @param aLocation, path for copy location
-     * @param aIsPhoneMemory, tells if used location is internal phone memory
-     */
-    IMPORT_C void GetCopyLocationL( TDes& aLocation, 
-                                    TBool& aIsPhoneMemory ) const;
-
-    /**
-     * Sets the location of the copy operation
-     * @since S60 3.2
-     * @param aDrive The drive number of the new location 
-     * as defined in TDriveNumber.
-     * @return TInt, TInt indicates the success of the call
-     */
-    IMPORT_C TInt SetCopyLocationL( const TDriveNumber aDrive ) const;
-
-    /**
-     * Get the name of the current IAP if it is set and is not always ask
-     * @since S60 5.1
-     * @param aIapId, iap id
-     * @return HBufC, iap name. Ownership is transferred to the caller
-     * if IAP is set to None
-     */
-    IMPORT_C static HBufC* GetCurrentIapNameL( TInt aIapId );
-    
-    /**
-     * Static helper method to validate iap by id.
-     * 
-     * @since S60 5.1
-     * @param aIapId, Id of the iap to be validated.
-     * @return ETrue if given iap id is valid. EFalse otherwise.
-     */
-    IMPORT_C static TBool IsAccessPointValidL( TInt aIapId );
-        
-    /**
-     * Static helper method to retrieve info of access points into given
-     * arrays.
-     * 
-     * @since S60 5.1
-     * @param aNameArray,  array contains the iap names
-     * @param aIapIdArr, Array for iap ids.
-     */
-    IMPORT_C static void GetWLANAccessPointsL( CDesCArray* aNameArray,
-                                               RArray<TInt64>& aIapIdArr );
-    
-    /**
-     * Static helper method to create the iap editing window
-     * arrays.
-     * 
-     * @since S60 5.1
-     * @param none
-     */        
-    IMPORT_C static void CreateAccessPointL();
-    
-private:
-
-    /**
-     * C++ default constructor.
-     */
-    CUPnPSettingsEngine();
-
-    /**
-     * By default Symbian 2nd phase constructor is private.
-     */
-    void ConstructL();
-
-    /**
-     * Reads device model, it is in form "Nokia xxxx"
-     * Note: Does not return correct value in subcon R&D builds
-     * @since S60 3.1
-     * @param aModel Device model
-     * @return TInt, TInt indicates the success of the call
-     */
-    TInt ReadDeviceModelL( TDes8& aModel ) const;
-
-    /**
-     * Gets friendly name, internal version
-     * @since S60 3.1
-     * @param aFriendlyName, reference where name is updated
-     * @return TInt, indicates the success of the call
-     */
-    TInt GetLocalFriendlyNameL( 
-        TDes8& aFriendlyName ) const;
-
-    /**
-     * Initializes a property if property has not yet been set
-     * @since S60 3.1
-     * @param aSettings, MediaServer settings 
-     * @param aKey, Propery's id
-     * @param aValue, New propery's value
-     */
-    void InitializePropertyL( 
-        CUpnpMediaServerSettings& aSettings, 
-        TInt aKey, 
-        const TDesC8& aValue ) const;
-    
-    /**
-     * Helper method to validate wlan access points.
-     * 
-     * @since S60 5.1
-     * @param aIapId, Id of the iap to be validated.
-     * @return ETrue if given iap is found from the comms db and
-     * id is valid. EFalse otherwise.
-     */
-    static TBool IsWLANAccessPointValidL( TUint32 aIapId );
-
-private:    // data
-
-    // Central Repository
-    CRepository*                    iRepository;
-    // Repository for upnp settings
-    CUpnpSettings*                  iUpnpRepository;
-    
-    };
-
-#endif  // __UPNPSETTINGSENGINE_H__
-
-// End of file
+/*
+* Copyright (c) 2006-2008 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:      Settings Engine class definition
+ *
+*/
+
+
+
+
+
+
+#ifndef __UPNPSETTINGSENGINE_H__
+#define __UPNPSETTINGSENGINE_H__
+
+// INCLUDE FILES
+
+#include <e32base.h>    // CBase
+#include <e32std.h>     // TBuf
+#include <f32file.h>
+#include <badesca.h>
+
+// CONSTANTS
+const TInt KMaxFriendlyNameLength( 64 );
+
+// FORWARD DECLARATIONS
+class CRepository;
+class CUpnpSettings;
+class CUpnpMediaServerSettings;
+
+// CLASS DECLARATION
+/**
+ *  Settings engine class for UPnP Home Connect Application
+ *  @lib upnpapplicationengine.lib
+ *  @since S60 3.1
+ */
+class CUPnPSettingsEngine : public CBase
+    {
+public: // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     */
+    IMPORT_C static CUPnPSettingsEngine* NewL();
+
+    /**
+     * Two-phased constructor.
+     */
+    IMPORT_C static CUPnPSettingsEngine* NewLC();
+
+    /**
+     * Destructor.
+     */
+    IMPORT_C virtual ~CUPnPSettingsEngine();
+        
+        
+public: // new functions
+
+    /**
+     * Sets friendly name
+     * @since S60 3.1
+     * @param aFriendlyName, reference containing the new friendly name
+     * @return TInt,  indicates the success of the call
+     */
+    IMPORT_C TInt SetLocalFriendlyName( 
+        const TDesC8& aFriendlyName ) const;
+
+    /**
+     * Gets friendly name
+     * @since S60 3.1
+     * @param aFriendlyName, reference where name is updated
+     * @return TInt, indicates the success of the call
+     */
+    IMPORT_C TInt GetLocalFriendlyName( 
+        TDes8& aFriendlyName ) const;
+
+
+    /**
+     * Sets selected Access point
+     * @since S60 3.1
+     * @param aIAP, the IAP id
+     * @return TInt, TInt indicates the success of the call
+     */
+    IMPORT_C TInt SetAccessPoint( const TInt aIAP );
+        
+        
+    /**
+     * Gets Access Point information
+     * @since S60 3.1
+     * @param aIAP, reference where IAP id is put
+     * @return TInt, indicates the success of the call
+     */
+    IMPORT_C TInt GetAccessPoint( TInt& aIAP );
+        
+        
+    /**
+     * Sets selected Access point setting
+     * @since S60 3.1
+     * @param aIAPSetting, the IAP setting
+     * @return TInt, TInt indicates the success of the call
+     */
+    IMPORT_C TInt SetAccessPointSetting( const TInt aIAPSetting );
+        
+        
+    /**
+     * Gets Access Point setting
+     * @since S60 3.1
+     * @param aIAPSetting, reference to access point setting
+     * @return TInt, indicates the success of the call
+     */
+    IMPORT_C TInt GetAccessPointSetting( TInt& aIAPSetting );
+        
+        
+    /**
+     * Sets selected wap access point id
+     * @since S60 3.1
+     * @param aWapId, the wap access point id
+     * @return TInt, TInt indicates the success of the call
+     */
+    IMPORT_C TInt SetWapId( const TInt aWapId );
+        
+        
+    /**
+     * Gets selected wap access point id
+     * @since S60 3.1
+     * @param aWapId, reference to wap access point id
+     * @return TInt, TInt indicates the success of the call
+     */
+    IMPORT_C TInt GetWapId( TInt& aWapId );
+
+    /**
+     * Gets information if this is the first start of home network
+     * @since S60 3.1
+     * @param aFirstStart, reference to first start information
+     * @return TInt, TInt indicates the success of the call
+     */
+    IMPORT_C TInt GetFirstStart( TInt& aFirstStart );
+
+    /**
+     * Sets information if this is the first start of home network
+     * @since S60 3.1
+     * @param const aFirstStart, the new first start value
+     * @return TInt, TInt indicates the success of the call
+     */
+    IMPORT_C TInt SetFirstStart( const TInt aFirstStart );
+        
+    /**
+     * Sets the mandatory manufacturer settings to media server
+     * @since S60 3.1
+     * @return TInt, TInt indicates the success of the call
+     */
+    IMPORT_C TInt SetManufacturerParamsL() const;
+
+    /**
+     * Gets the drive for the copy operation
+     * @since S60 3.2
+     * @param aDrive, reference to copy location drive
+     */
+    IMPORT_C void GetCopyLocationDriveL( TDriveNumber& aDrive ) const;
+
+    /**
+     * Gets the location for the copy operation
+     * @since S60 3.2
+     * @param aLocation, path for copy location
+     * @param aIsPhoneMemory, tells if used location is internal phone memory
+     */
+    IMPORT_C void GetCopyLocationL( TDes& aLocation, 
+                                    TBool& aIsPhoneMemory ) const;
+
+    /**
+     * Sets the location of the copy operation
+     * @since S60 3.2
+     * @param aDrive The drive number of the new location 
+     * as defined in TDriveNumber.
+     * @return TInt, TInt indicates the success of the call
+     */
+    IMPORT_C TInt SetCopyLocationL( const TDriveNumber aDrive ) const;
+
+    /**
+     * Get the name of the current IAP if it is set and is not always ask
+     * @since S60 5.1
+     * @param aIapId, iap id
+     * @return HBufC, iap name. Ownership is transferred to the caller
+     * if IAP is set to None
+     */
+    IMPORT_C static HBufC* GetCurrentIapNameL( TInt aIapId );
+    
+    /**
+     * Static helper method to validate iap by id.
+     * 
+     * @since S60 5.1
+     * @param aIapId, Id of the iap to be validated.
+     * @return ETrue if given iap id is valid. EFalse otherwise.
+     */
+    IMPORT_C static TBool IsAccessPointValidL( TInt aIapId );
+        
+    /**
+     * Static helper method to retrieve info of access points into given
+     * arrays.
+     * 
+     * @since S60 5.1
+     * @param aNameArray,  array contains the iap names
+     * @param aIapIdArr, Array for iap ids.
+     */
+    IMPORT_C static void GetWLANAccessPointsL( CDesCArray* aNameArray,
+                                               RArray<TInt64>& aIapIdArr );
+    
+    /**
+     * Static helper method to create the iap editing window
+     * arrays.
+     * 
+     * @since S60 5.1
+     * @param none
+     */        
+    IMPORT_C static void CreateAccessPointL();
+    
+private:
+
+    /**
+     * C++ default constructor.
+     */
+    CUPnPSettingsEngine();
+
+    /**
+     * By default Symbian 2nd phase constructor is private.
+     */
+    void ConstructL();
+
+    /**
+     * Reads device model, it is in form "Nokia xxxx"
+     * Note: Does not return correct value in subcon R&D builds
+     * @since S60 3.1
+     * @param aModel Device model
+     * @return TInt, TInt indicates the success of the call
+     */
+    TInt ReadDeviceModelL( TDes8& aModel ) const;
+
+    /**
+     * Gets friendly name, internal version
+     * @since S60 3.1
+     * @param aFriendlyName, reference where name is updated
+     * @return TInt, indicates the success of the call
+     */
+    TInt GetLocalFriendlyNameL( 
+        TDes8& aFriendlyName ) const;
+
+    /**
+     * Initializes a property if property has not yet been set
+     * @since S60 3.1
+     * @param aSettings, MediaServer settings 
+     * @param aKey, Propery's id
+     * @param aValue, New propery's value
+     */
+    void InitializePropertyL( 
+        CUpnpMediaServerSettings& aSettings, 
+        TInt aKey, 
+        const TDesC8& aValue ) const;
+    
+    /**
+     * Helper method to validate wlan access points.
+     * 
+     * @since S60 5.1
+     * @param aIapId, Id of the iap to be validated.
+     * @return ETrue if given iap is found from the comms db and
+     * id is valid. EFalse otherwise.
+     */
+    static TBool IsWLANAccessPointValidL( TUint32 aIapId );
+
+private:    // data
+
+    // Central Repository
+    CRepository*                    iRepository;
+    // Repository for upnp settings
+    CUpnpSettings*                  iUpnpRepository;
+    
+    };
+
+#endif  // __UPNPSETTINGSENGINE_H__
+
+// End of file
--- a/upnpsettings/upnpsettingsengine/src/upnpsettingsengine.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsettings/upnpsettingsengine/src/upnpsettingsengine.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,754 +1,759 @@
-/*
-* Copyright (c) 2005-2008 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:      UPnP settings engine class implementation
-*
-*/
-
-
-
-
-
-
-
-//  Include Files
-
-#include <centralrepository.h>
-#include <s32file.h>
-#include <upnpstring.h>
-#include <pathinfo.h> //PathInfo
-#include <upnpmediaserversettings.h>
-
-#include <cmmanager.h>   // RCmManager
-#include <cmconnectionmethoddef.h>
-#include <commdb.h> // CCommsDatabase
-#include <cdbcols.h>
-#include <WlanCdbCols.h>  // WLAN_SERVICE
-#include <wlanmgmtcommon.h>
-
-#include "upnpsettingsengine.h"
-#include "upnpsettingsengine.hrh"
-#include "upnpapplicationcrkeys.h"
-
-#include "upnpsettings.h"
-
-_LIT( KComponentLogfile, "upnpsettingsengine.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-_LIT8( KManufacturerName, "Nokia");
-_LIT( KDummyIAP, "DummyIAP");
-
-// upload directory
-_LIT( KUploadDirectoryCDrive, "\\data\\Download\\Media\\" );
-_LIT( KUploadDirectory, "\\Download\\Media\\" );
-_LIT( KModelFile, "\\resource\\versions\\model.txt" );
-_LIT8( KModel, "Nokia X" );
-_LIT8( KManufacturerUrl, "http://www.nokia.com");
-_LIT8( KModelUrl, "http://www.nseries.com");
-const TInt KMaxNameLength = 128;
-const TUint KUidWlanBearerType = 0x10281BB1;
-
-// ============================ MEMBER FUNCTIONS ============================
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::CUPnPSettingsEngine
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// --------------------------------------------------------------------------
-//
-CUPnPSettingsEngine::CUPnPSettingsEngine()
-    {
-    __LOG("CUPnPSettingsEngine::CUPnPSettingsEngine()");
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::NewLC
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUPnPSettingsEngine* CUPnPSettingsEngine::NewLC()
-    {
-    __LOG("CUPnPSettingsEngine::NewLC()");
-
-    CUPnPSettingsEngine* self = new (ELeave) CUPnPSettingsEngine;
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::NewL
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUPnPSettingsEngine* CUPnPSettingsEngine::NewL()
-    {
-    __LOG("CUPnPSettingsEngine::NewL()");
-
-    CUPnPSettingsEngine* self = CUPnPSettingsEngine::NewLC();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::ConstructL
-// Symbian 2nd phase constructor can leave.
-// --------------------------------------------------------------------------
-//
-void CUPnPSettingsEngine::ConstructL()
-    {
-    iRepository = CRepository::NewL( KCRUidUPnPApplication );
-    iUpnpRepository = CUpnpSettings::NewL(KCRUidUPnPStack);
-
-    //set model, ManufacturerUrl, and ModelUrl into UpnpMediaServerSettings
-    SetManufacturerParamsL();
-    }
-
-
-// Destructor
-EXPORT_C CUPnPSettingsEngine::~CUPnPSettingsEngine()
-    {
-    __LOG("CUPnPSettingsEngine::~CUPnPSettingsEngine()");
-
-    delete iRepository;
-    iRepository = NULL;
-    delete iUpnpRepository;
-    iUpnpRepository = NULL;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::SetLocalFriendlyName
-// Sets friendly name to Central Repository
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::SetLocalFriendlyName(
-    const TDesC8& aFriendlyName ) const
-    {
-    __LOG("CUPnPSettingsEngine::SetLocalFriendlyName()");
-
-    TBuf8<KMaxNameLength> name;
-    name.Copy(aFriendlyName);
-    TInt err( KErrNone );
-    TRAP_IGNORE(
-        CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL();
-        CleanupStack::PushL(settings);
-        err = settings->SetL( UpnpMediaServerSettings::EFriendlyName, name);
-        CleanupStack::PopAndDestroy(settings);
-        );
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::GetLocalFriendlyName
-// Gets friendly name from Central Repository.
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::GetLocalFriendlyName(
-    TDes8& aFriendlyName ) const
-    {
-    __LOG("CUPnPSettingsEngine::GetLocalFriendlyName()");
-    TInt err( KErrNone );
-    TRAP(err, err = GetLocalFriendlyNameL( aFriendlyName ) );
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::GetLocalFriendlyNameL
-// Gets friendly name from Central Repository.
-// --------------------------------------------------------------------------
-//
-TInt CUPnPSettingsEngine::GetLocalFriendlyNameL(
-    TDes8& aFriendlyName ) const
-    {
-    __LOG("CUPnPSettingsEngine::GetLocalFriendlyNameL()");
-    
-    CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL();
-    CleanupStack::PushL( settings );
-    HBufC8 *tmp = settings->GetL( UpnpMediaServerSettings::EFriendlyName );
-    
-    //check if there is any name for the device
-    if ( !tmp->Length() )
-        {
-        //no name available, try to get the device model name as the 
-        //device name
-        
-        // Read device model
-        delete tmp; tmp = NULL;
-        
-        //string ownership transferred
-        tmp = settings->GetL( UpnpMediaServerSettings::
-                              EModelName );
-                              
-        if ( tmp->Length() )
-            {
-            //if device model name is available
-            aFriendlyName.Copy( *tmp );
-            }
-        else
-            {
-            // final try if reading model name fails, use manufacturer name
-            // as device name
-            aFriendlyName.Copy( KManufacturerName );
-            }
-        }
-    else
-        {
-        aFriendlyName.Copy( *tmp );
-        }
-    delete tmp; tmp = NULL;
-    CleanupStack::PopAndDestroy( settings );
-    return KErrNone;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::SetAccessPoint
-// Sets IAP to Central Repository
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::SetAccessPoint( const TInt aIAP )
-    {
-    TInt value = aIAP; // remove constness
-    return iUpnpRepository->Set(CUpnpSettings::KUPnPStackIapId, value );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::GetAccessPoint
-// Gets IAP from Central Repository.
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::GetAccessPoint( TInt& aIAP )
-    {
-    return iUpnpRepository->Get(CUpnpSettings::KUPnPStackIapId, aIAP );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::SetAccessPointSetting
-// Sets IAP setting to Central Repository
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::SetAccessPointSetting(
-    const TInt aIAPSetting )
-    {
-    return iRepository->Set( KUPnPAppAccessPointSetting, aIAPSetting );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::GetAccessPointSetting
-// Gets IAP setting from Central Repository.
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::GetAccessPointSetting( TInt& aIAPSetting )
-    {
-    return iRepository->Get( KUPnPAppAccessPointSetting, aIAPSetting );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::SetWapId
-// Sets iap wap id to Central Repository
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::SetWapId( const TInt aWapId )
-    {
-    return iRepository->Set( KUPnPAppWapId, aWapId );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::GetWapId
-// Gets iap wap id from Central Repository
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::GetWapId( TInt& aWapId )
-    {
-    return iRepository->Get( KUPnPAppWapId, aWapId );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::GetFirstStart
-// Gets information if this is the first start of home network
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::GetFirstStart( TInt& aFirstStart )
-    {
-    TInt err ( iRepository->Get( KUPnPAppFirstStart, aFirstStart ));
-    if ( aFirstStart )
-        {
-        TRAP_IGNORE(
-        RFs fs;
-        err = fs.Connect();
-        CleanupClosePushL( fs );
-        TVolumeInfo volumeInfo;
-        TDriveUnit driveUnit;
-        TInt err = fs.Volume(volumeInfo, EDriveE);
-        if( err == KErrNone && volumeInfo.iFree > 0)
-            {
-            driveUnit = TDriveUnit( PathInfo::MemoryCardRootPath() );
-            }
-        else
-            {
-            driveUnit = TDriveUnit( PathInfo::PhoneMemoryRootPath() );
-            }
-
-        CleanupStack::PopAndDestroy( &fs );
-        SetCopyLocationL( (TDriveNumber)((TInt)driveUnit) ));
-        }
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::SetFirstStart
-// Sets information if this is the first start of home network
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::SetFirstStart( const TInt aFirstStart )
-    {
-    return iRepository->Set( KUPnPAppFirstStart, aFirstStart );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::SetManufacturerParamsL
-// Sets the mandatory manufacturer settings
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::SetManufacturerParamsL() const
-    {
-    __LOG("CUPnPSettingsEngine::SetManufacturerParamsL()");
-    CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL();
-    CleanupStack::PushL( settings );
-
-    // Manufacturer
-    InitializePropertyL( *settings, 
-                         UpnpMediaServerSettings::EManufacturer, 
-                         KManufacturerName );
-
-    // Model name
-    HBufC8* model = HBufC8::NewLC( KMaxFileName );
-    TPtr8 modelPtr( model->Des() );
-    TInt err = ReadDeviceModelL( modelPtr );
-    if( err )
-        {
-        model->Des().Copy( KModel );
-        }
-    InitializePropertyL( *settings, 
-                         UpnpMediaServerSettings::EModelName, 
-                         *model );
-    // Friendly name
-    InitializePropertyL( *settings, 
-                         UpnpMediaServerSettings::EFriendlyName, 
-                         *model );
-    CleanupStack::PopAndDestroy( model );
-
-    // Manufacturer url
-    InitializePropertyL( *settings, 
-                         UpnpMediaServerSettings::EManufacturerUrl, 
-                         KManufacturerUrl );
-
-    // Model url
-    InitializePropertyL( *settings, 
-                         UpnpMediaServerSettings::EModelUrl, 
-                         KModelUrl );
-
-    CleanupStack::PopAndDestroy( settings );
-    return KErrNone;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::ReadDeviceModelL
-// Get device model
-// --------------------------------------------------------------------------
-//
-TInt CUPnPSettingsEngine::ReadDeviceModelL( TDes8& aModel ) const
-    {
-    __LOG("CUPnPSettingsEngine::ReadDeviceModel()");
-    RFs fs;
-    RFile file;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL( fs );
-    
-    HBufC*path = HBufC::NewLC( KMaxFileName );
-    TParse parse;
-    parse.Set( PathInfo::RomRootPath(), NULL, NULL );
-    TPtrC romDrive = parse.Drive();
-    
-    path->Des().Append( romDrive );
-    path->Des().Append( KModelFile() );
-    
-    TInt error ( file.Open(fs, *path, EFileRead ));
-    if ( !error )
-        {
-        CleanupClosePushL( file );
-
-        TFileText txtFile;
-        txtFile.Set( file );
-        HBufC* readBuf = HBufC::NewLC( KMaxFileName );
-        txtFile.Seek( ESeekStart );
-        TPtr bufPtr( readBuf->Des() );
-        error = txtFile.Read( bufPtr ); // read one line
-        if ( !error )
-            {
-            HBufC8* bufbuf = UpnpString::FromUnicodeL( *readBuf );
-            CleanupStack::PushL( bufbuf );
-
-            aModel = *bufbuf;
-            CleanupStack::PopAndDestroy( bufbuf );
-            }
-        CleanupStack::PopAndDestroy( readBuf );
-        CleanupStack::PopAndDestroy( &file ); // Close file
-        }
-    CleanupStack::PopAndDestroy( path );    
-    CleanupStack::PopAndDestroy( &fs );
-
-    return error;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::GetCopyLocationDriveL
-// Gets the drive of the location for copied files
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUPnPSettingsEngine::GetCopyLocationDriveL( 
-    TDriveNumber& aDrive )
-    const
-    {
-    __LOG("CUPnPSettingsEngine::GetCopyLocationDriveL()");
-
-    HBufC* location = HBufC::NewL(KMaxFileName);
-    CleanupStack::PushL( location );
-    TBool isPhoneMem( EFalse );
-    TPtr locationPtr( location->Des() );
-    GetCopyLocationL( locationPtr, isPhoneMem );
-
-    TDriveUnit driveUnit = TDriveUnit( locationPtr );
-
-    aDrive = (TDriveNumber)((TInt)driveUnit);
-
-    CleanupStack::PopAndDestroy( location );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::GetCopyLocationL
-// Gets the location for copied files
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUPnPSettingsEngine::GetCopyLocationL( TDes& aLocation,
-                                                    TBool& aIsPhoneMemory )
-    const
-    {
-    __LOG("CUPnPSettingsEngine::GetCopyLocationL()");
-
-    // Get instance of Server Settings object
-    CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL();
-    CleanupStack::PushL( settings );
-
-    // Get the location setting from ServerSettings
-    settings->Get( UpnpMediaServerSettings::EUploadDirectory, aLocation );
-
-    // Check to see if drive is ready.
-    TVolumeInfo volInfo;
-    TDriveUnit driveUnit = TDriveUnit( aLocation );
-    RFs fileServer;
-
-    User::LeaveIfError( fileServer.Connect() );
-    CleanupClosePushL( fileServer );
-    TInt error = fileServer.Volume( volInfo, driveUnit );
-    CleanupStack::PopAndDestroy( &fileServer );
-
-    // check if memory is present
-    // Revert to phone memory if location is not available
-    // If the location is full no need to change the location. User will be
-    // informed that memory is full and the location should be changed
-    if( error == KErrNone )
-        {
-        TDriveUnit driveUnit = TDriveUnit( aLocation );    
-        if( driveUnit == EDriveC )
-            {
-            aIsPhoneMemory = ETrue;
-            }
-        else
-            {
-            aIsPhoneMemory = EFalse;
-            }
-        }
-    else
-        {
-        SetCopyLocationL( EDriveC );
-        aIsPhoneMemory = ETrue;
-        }
-
-    CleanupStack::PopAndDestroy( settings );
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::SetCopyLocationL
-// Sets the location for copied files
-// --------------------------------------------------------------------------
-//
-EXPORT_C TInt CUPnPSettingsEngine::SetCopyLocationL( 
-    const TDriveNumber aDrive )
-    const
-    {
-    __LOG("CUPnPSettingsEngine::SetCopyLocationL()");
-    TInt err( KErrNone );
-
-    HBufC* path = HBufC::NewL( KMaxFileName );
-    CleanupStack::PushL( path );
-
-    CUpnpMediaServerSettings* settings =
-        CUpnpMediaServerSettings::NewL();
-    CleanupStack::PushL( settings );
-
-    TDriveUnit driveUnit = TDriveUnit( aDrive );
-    path->Des().Append( driveUnit.Name() );
-    if( aDrive == EDriveC )
-        {
-        path->Des().Append( KUploadDirectoryCDrive );
-        }
-    else
-        {
-        path->Des().Append( KUploadDirectory );
-        }
-
-    err = settings->Set( UpnpMediaServerSettings::EUploadDirectory, *path );
-
-    CleanupStack::PopAndDestroy( settings );
-    CleanupStack::PopAndDestroy( path );
-
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::GetCurrentIapNameL
-// Get iap name
-// --------------------------------------------------------------------------
-//
-EXPORT_C HBufC* CUPnPSettingsEngine::GetCurrentIapNameL( TInt aIapId )
-    {
-    __LOG("CUPnPSettingsEngine::GetCurrentIapNameL() begin");
-    __LOG("read iap");
-    
-    HBufC* name = NULL;
-    if( aIapId > EUPnPSettingsEngineIAPIdAlwaysAsk )
-        {
-        name = HBufC::NewLC( KMaxFileName );
-        TPtr namePtr( name->Des() );
-        CCommsDatabase* db = CCommsDatabase::NewL();
-        CleanupStack::PushL( db );
-        CCommsDbTableView* iapView = db->OpenViewMatchingUintLC(
-            TPtrC(IAP),
-            TPtrC(COMMDB_ID),
-            aIapId );
-        if( iapView )
-            {
-            TInt err = KErrNotFound;
-            err = iapView->GotoFirstRecord();
-            if ( !err )
-                {
-                iapView->ReadTextL(TPtrC(COMMDB_NAME), namePtr );
-                }
-            CleanupStack::PopAndDestroy( iapView );
-            }
-        CleanupStack::PopAndDestroy( db );
-        CleanupStack::Pop( name );
-        }
-    
-    if( !name )
-        {
-        User::LeaveIfError( KErrNotFound );
-        }
-    
-    __LOG("CUPnPSettingsEngine::GetCurrentIapNameL() end");
-    return name;
-    }
-
-//---------------------------------------------------------------------------
-// CUPnPSettingsEngine::IsAccessPointValidL
-// Checks if the given access point is valid.
-//---------------------------------------------------------------------------
-//
-EXPORT_C TBool CUPnPSettingsEngine::IsAccessPointValidL( TInt aIapId )
-    {
-    if ( aIapId == EUPnPSettingsEngineIAPIdAlwaysAsk )
-        {
-        // IAP is always ask. Returns true automatically.
-        return ETrue;
-        }
-    else if ( aIapId > EUPnPSettingsEngineIAPIdAlwaysAsk )
-        {
-        // Verifies that IAP exists in the comms db and it is valid.
-        return IsWLANAccessPointValidL( aIapId );
-        }
-    else
-        {
-        // IAP is NONE or some bogus value. Not valid.
-        return EFalse;
-        }
-    }
-
-// -------------------------------------------------------------
-// CUPnPSettingsEngine::GetWLANAccessPointsL
-// Get wlan access points from commsdb
-// -------------------------------------------------------------
-//
-EXPORT_C void CUPnPSettingsEngine::GetWLANAccessPointsL(
-                                    CDesCArray* aNameArray,
-                                    RArray<TInt64>& aIapIdArr )
-    {
-    __LOG("CUPnPSettingsEngine::GetWLANAccessPointsL() begin");
-#ifdef __arm
-    TUint32 bearerType;
-#endif
-
-    RCmManager cmm;
-    cmm.OpenL();
-    CleanupClosePushL ( cmm );
-
-    RArray<TUint32> iapIdArr;    
-    CleanupClosePushL ( iapIdArr );
-
-    //get all the connections, exclude easy wlan
-    cmm.ConnectionMethodL( iapIdArr, EFalse, EFalse, EFalse );
-
-    __LOG1(" total %d", iapIdArr.Count() );
-
-    //Get the iap names
-    for(TInt i = 0; i < iapIdArr.Count(); i++ )
-        {
-#ifdef __arm
-
-        bearerType = cmm.GetConnectionMethodInfoIntL(
-                               iapIdArr[i], CMManager::ECmBearerType );
-
-        __LOG1(" bearerType %d", bearerType);
-
-        if( bearerType == KUidWlanBearerType )
-            {
-#endif
-            __LOG1(" i: %d", i);
-            aIapIdArr.AppendL( iapIdArr[i] );
-
-            if( aNameArray )
-                {
-                HBufC* name = NULL;
-                __LOG(" name ");
-
-                // This can leave in WINSCW env, so catch and handle the
-                // exception
-                TRAPD( getConnectionMethodErr,
-                       name = cmm.GetConnectionMethodInfoStringL(
-                                   iapIdArr[i], CMManager::ECmName );
-                );
-
-                if( getConnectionMethodErr == KErrNone )
-                    {
-                    __LOG16( *name );
-                    CleanupStack::PushL( name );
-                    __LOG(" append name ");
-                    aNameArray->AppendL( *name ); //ownership not transferred
-                    CleanupStack::PopAndDestroy( name );
-                    }
-                else
-                    {
-                    // If failed to get the connection method info string,
-                    // use a dummy IAP name
-                    __LOG( " Failed to get IAP name! Using a dummy name. ");
-                    aNameArray->AppendL( KDummyIAP );
-                    }
-                }
-#ifdef __arm
-            }
-#endif
-
-        }
-
-    CleanupStack::PopAndDestroy( &iapIdArr );
-    CleanupStack::PopAndDestroy( &cmm );
-
-    __LOG1(" aIapIdArr count %d", aIapIdArr.Count() );  
-    __LOG("CUPnPSettingsEngine::GetWLANAccessPointsL() end");
-
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::CreateAccessPointL
-// Create AP modifying window
-// --------------------------------------------------------------------------
-//
-EXPORT_C void CUPnPSettingsEngine::CreateAccessPointL()
-    {
-    }
-    
-//---------------------------------------------------------------------------
-// CUPnPSettingsEngine::IsWLANAccessPointValidL
-// Checks if the given access point is valid.
-//---------------------------------------------------------------------------
-//
-TBool CUPnPSettingsEngine::IsWLANAccessPointValidL( TUint32 aIapId )
-    {
-    
-    TBool ret = EFalse;
-    
-    RArray<TInt64> newArray;
-    CleanupClosePushL( newArray );
-    
-    GetWLANAccessPointsL( NULL, newArray );
-    
-    for(TInt i = 0; i < newArray.Count(); i++ )
-        {
-        if( aIapId == newArray[i] )
-            {
-            ret = ETrue;
-            i = newArray.Count(); //quit the loop
-            }
-        }
-    CleanupStack::PopAndDestroy( &newArray ); 
-    
-    return ret;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPSettingsEngine::InitializePropertyL
-// Initializes a property if property has not yet been set
-// --------------------------------------------------------------------------
-//
-void CUPnPSettingsEngine::InitializePropertyL( 
-    CUpnpMediaServerSettings& aSettings, 
-    TInt aKey, 
-    const TDesC8& aValue ) const
-    {
-    HBufC8* currentValue( NULL );
-    TRAPD( err, currentValue = aSettings.GetL( aKey ) );
-    if( !err )
-        {
-        TInt currentLength = currentValue->Length();
-        delete currentValue;
-        currentValue = NULL;
-        if( !currentLength )
-            {
-            User::LeaveIfError( aSettings.SetL( aKey, aValue ) );
-            }
-        }
-    else if( err == KErrNotFound )
-        {
-        User::LeaveIfError( aSettings.SetL( aKey, aValue ) );
-        }
-    else
-        {
-        User::Leave( err );
-        }
-    }
-    
-// End of file
+/*
+* Copyright (c) 2005-2008 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:      UPnP settings engine class implementation
+*
+*/
+
+
+
+
+
+
+
+//  Include Files
+
+#include <centralrepository.h>
+#include <s32file.h>
+#include <upnpstring.h>
+#include <pathinfo.h> //PathInfo
+#include <upnpmediaserversettings.h>
+
+#include <cmsettingsui.h> // CCmSettingsUi
+#include <cmmanager.h>   // RCmManager
+#include <cmconnectionmethoddef.h>
+#include <commdb.h> // CCommsDatabase
+#include <cdbcols.h>
+#include <WlanCdbCols.h>  // WLAN_SERVICE
+#include <wlanmgmtcommon.h>
+
+#include "upnpsettingsengine.h"
+#include "upnpsettingsengine.hrh"
+#include "upnpapplicationcrkeys.h"
+
+#include "upnpsettings.h"
+
+_LIT( KComponentLogfile, "upnpsettingsengine.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+_LIT8( KManufacturerName, "Nokia");
+_LIT( KDummyIAP, "DummyIAP");
+
+// upload directory
+_LIT( KUploadDirectoryCDrive, "\\data\\Download\\Media\\" );
+_LIT( KUploadDirectory, "\\Download\\Media\\" );
+_LIT( KModelFile, "\\resource\\versions\\model.txt" );
+_LIT8( KModel, "Nokia X" );
+_LIT8( KManufacturerUrl, "http://www.nokia.com");
+_LIT8( KModelUrl, "http://www.nseries.com");
+const TInt KMaxNameLength = 128;
+const TUint KUidWlanBearerType = 0x10281BB1;
+
+// ============================ MEMBER FUNCTIONS ============================
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::CUPnPSettingsEngine
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// --------------------------------------------------------------------------
+//
+CUPnPSettingsEngine::CUPnPSettingsEngine()
+    {
+    __LOG("CUPnPSettingsEngine::CUPnPSettingsEngine()");
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::NewLC
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUPnPSettingsEngine* CUPnPSettingsEngine::NewLC()
+    {
+    __LOG("CUPnPSettingsEngine::NewLC()");
+
+    CUPnPSettingsEngine* self = new (ELeave) CUPnPSettingsEngine;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::NewL
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUPnPSettingsEngine* CUPnPSettingsEngine::NewL()
+    {
+    __LOG("CUPnPSettingsEngine::NewL()");
+
+    CUPnPSettingsEngine* self = CUPnPSettingsEngine::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::ConstructL
+// Symbian 2nd phase constructor can leave.
+// --------------------------------------------------------------------------
+//
+void CUPnPSettingsEngine::ConstructL()
+    {
+    iRepository = CRepository::NewL( KCRUidUPnPApplication );
+    iUpnpRepository = CUpnpSettings::NewL(KCRUidUPnPStack);
+
+    //set model, ManufacturerUrl, and ModelUrl into UpnpMediaServerSettings
+    SetManufacturerParamsL();
+    }
+
+
+// Destructor
+EXPORT_C CUPnPSettingsEngine::~CUPnPSettingsEngine()
+    {
+    __LOG("CUPnPSettingsEngine::~CUPnPSettingsEngine()");
+
+    delete iRepository;
+    iRepository = NULL;
+    delete iUpnpRepository;
+    iUpnpRepository = NULL;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::SetLocalFriendlyName
+// Sets friendly name to Central Repository
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::SetLocalFriendlyName(
+    const TDesC8& aFriendlyName ) const
+    {
+    __LOG("CUPnPSettingsEngine::SetLocalFriendlyName()");
+
+    TBuf8<KMaxNameLength> name;
+    name.Copy(aFriendlyName);
+    TInt err( KErrNone );
+    TRAP_IGNORE(
+        CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL();
+        CleanupStack::PushL(settings);
+        err = settings->SetL( UpnpMediaServerSettings::EFriendlyName, name);
+        CleanupStack::PopAndDestroy(settings);
+        );
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::GetLocalFriendlyName
+// Gets friendly name from Central Repository.
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::GetLocalFriendlyName(
+    TDes8& aFriendlyName ) const
+    {
+    __LOG("CUPnPSettingsEngine::GetLocalFriendlyName()");
+    TInt err( KErrNone );
+    TRAP(err, err = GetLocalFriendlyNameL( aFriendlyName ) );
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::GetLocalFriendlyNameL
+// Gets friendly name from Central Repository.
+// --------------------------------------------------------------------------
+//
+TInt CUPnPSettingsEngine::GetLocalFriendlyNameL(
+    TDes8& aFriendlyName ) const
+    {
+    __LOG("CUPnPSettingsEngine::GetLocalFriendlyNameL()");
+    
+    CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL();
+    CleanupStack::PushL( settings );
+    HBufC8 *tmp = settings->GetL( UpnpMediaServerSettings::EFriendlyName );
+    
+    //check if there is any name for the device
+    if ( !tmp->Length() )
+        {
+        //no name available, try to get the device model name as the 
+        //device name
+        
+        // Read device model
+        delete tmp; tmp = NULL;
+        
+        //string ownership transferred
+        tmp = settings->GetL( UpnpMediaServerSettings::
+                              EModelName );
+                              
+        if ( tmp->Length() )
+            {
+            //if device model name is available
+            aFriendlyName.Copy( *tmp );
+            }
+        else
+            {
+            // final try if reading model name fails, use manufacturer name
+            // as device name
+            aFriendlyName.Copy( KManufacturerName );
+            }
+        }
+    else
+        {
+        aFriendlyName.Copy( *tmp );
+        }
+    delete tmp; tmp = NULL;
+    CleanupStack::PopAndDestroy( settings );
+    return KErrNone;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::SetAccessPoint
+// Sets IAP to Central Repository
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::SetAccessPoint( const TInt aIAP )
+    {
+    TInt value = aIAP; // remove constness
+    return iUpnpRepository->Set(CUpnpSettings::KUPnPStackIapId, value );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::GetAccessPoint
+// Gets IAP from Central Repository.
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::GetAccessPoint( TInt& aIAP )
+    {
+    return iUpnpRepository->Get(CUpnpSettings::KUPnPStackIapId, aIAP );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::SetAccessPointSetting
+// Sets IAP setting to Central Repository
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::SetAccessPointSetting(
+    const TInt aIAPSetting )
+    {
+    return iRepository->Set( KUPnPAppAccessPointSetting, aIAPSetting );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::GetAccessPointSetting
+// Gets IAP setting from Central Repository.
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::GetAccessPointSetting( TInt& aIAPSetting )
+    {
+    return iRepository->Get( KUPnPAppAccessPointSetting, aIAPSetting );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::SetWapId
+// Sets iap wap id to Central Repository
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::SetWapId( const TInt aWapId )
+    {
+    return iRepository->Set( KUPnPAppWapId, aWapId );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::GetWapId
+// Gets iap wap id from Central Repository
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::GetWapId( TInt& aWapId )
+    {
+    return iRepository->Get( KUPnPAppWapId, aWapId );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::GetFirstStart
+// Gets information if this is the first start of home network
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::GetFirstStart( TInt& aFirstStart )
+    {
+    TInt err ( iRepository->Get( KUPnPAppFirstStart, aFirstStart ));
+    if ( aFirstStart )
+        {
+        TRAP_IGNORE(
+        RFs fs;
+        err = fs.Connect();
+        CleanupClosePushL( fs );
+        TVolumeInfo volumeInfo;
+        TDriveUnit driveUnit;
+        TInt err = fs.Volume(volumeInfo, EDriveE);
+        if( err == KErrNone && volumeInfo.iFree > 0)
+            {
+            driveUnit = TDriveUnit( PathInfo::MemoryCardRootPath() );
+            }
+        else
+            {
+            driveUnit = TDriveUnit( PathInfo::PhoneMemoryRootPath() );
+            }
+
+        CleanupStack::PopAndDestroy( &fs );
+        SetCopyLocationL( (TDriveNumber)((TInt)driveUnit) ));
+        }
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::SetFirstStart
+// Sets information if this is the first start of home network
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::SetFirstStart( const TInt aFirstStart )
+    {
+    return iRepository->Set( KUPnPAppFirstStart, aFirstStart );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::SetManufacturerParamsL
+// Sets the mandatory manufacturer settings
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::SetManufacturerParamsL() const
+    {
+    __LOG("CUPnPSettingsEngine::SetManufacturerParamsL()");
+    CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL();
+    CleanupStack::PushL( settings );
+
+    // Manufacturer
+    InitializePropertyL( *settings, 
+                         UpnpMediaServerSettings::EManufacturer, 
+                         KManufacturerName );
+
+    // Model name
+    HBufC8* model = HBufC8::NewLC( KMaxFileName );
+    TPtr8 modelPtr( model->Des() );
+    TInt err = ReadDeviceModelL( modelPtr );
+    if( err )
+        {
+        model->Des().Copy( KModel );
+        }
+    InitializePropertyL( *settings, 
+                         UpnpMediaServerSettings::EModelName, 
+                         *model );
+    // Friendly name
+    InitializePropertyL( *settings, 
+                         UpnpMediaServerSettings::EFriendlyName, 
+                         *model );
+    CleanupStack::PopAndDestroy( model );
+
+    // Manufacturer url
+    InitializePropertyL( *settings, 
+                         UpnpMediaServerSettings::EManufacturerUrl, 
+                         KManufacturerUrl );
+
+    // Model url
+    InitializePropertyL( *settings, 
+                         UpnpMediaServerSettings::EModelUrl, 
+                         KModelUrl );
+
+    CleanupStack::PopAndDestroy( settings );
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::ReadDeviceModelL
+// Get device model
+// --------------------------------------------------------------------------
+//
+TInt CUPnPSettingsEngine::ReadDeviceModelL( TDes8& aModel ) const
+    {
+    __LOG("CUPnPSettingsEngine::ReadDeviceModel()");
+    RFs fs;
+    RFile file;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    
+    HBufC*path = HBufC::NewLC( KMaxFileName );
+    TParse parse;
+    parse.Set( PathInfo::RomRootPath(), NULL, NULL );
+    TPtrC romDrive = parse.Drive();
+    
+    path->Des().Append( romDrive );
+    path->Des().Append( KModelFile() );
+    
+    TInt error ( file.Open(fs, *path, EFileRead ));
+    if ( !error )
+        {
+        CleanupClosePushL( file );
+
+        TFileText txtFile;
+        txtFile.Set( file );
+        HBufC* readBuf = HBufC::NewLC( KMaxFileName );
+        txtFile.Seek( ESeekStart );
+        TPtr bufPtr( readBuf->Des() );
+        error = txtFile.Read( bufPtr ); // read one line
+        if ( !error )
+            {
+            HBufC8* bufbuf = UpnpString::FromUnicodeL( *readBuf );
+            CleanupStack::PushL( bufbuf );
+
+            aModel = *bufbuf;
+            CleanupStack::PopAndDestroy( bufbuf );
+            }
+        CleanupStack::PopAndDestroy( readBuf );
+        CleanupStack::PopAndDestroy( &file ); // Close file
+        }
+    CleanupStack::PopAndDestroy( path );    
+    CleanupStack::PopAndDestroy( &fs );
+
+    return error;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::GetCopyLocationDriveL
+// Gets the drive of the location for copied files
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUPnPSettingsEngine::GetCopyLocationDriveL( 
+    TDriveNumber& aDrive )
+    const
+    {
+    __LOG("CUPnPSettingsEngine::GetCopyLocationDriveL()");
+
+    HBufC* location = HBufC::NewL(KMaxFileName);
+    CleanupStack::PushL( location );
+    TBool isPhoneMem( EFalse );
+    TPtr locationPtr( location->Des() );
+    GetCopyLocationL( locationPtr, isPhoneMem );
+
+    TDriveUnit driveUnit = TDriveUnit( locationPtr );
+
+    aDrive = (TDriveNumber)((TInt)driveUnit);
+
+    CleanupStack::PopAndDestroy( location );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::GetCopyLocationL
+// Gets the location for copied files
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUPnPSettingsEngine::GetCopyLocationL( TDes& aLocation,
+                                                    TBool& aIsPhoneMemory )
+    const
+    {
+    __LOG("CUPnPSettingsEngine::GetCopyLocationL()");
+
+    // Get instance of Server Settings object
+    CUpnpMediaServerSettings* settings = CUpnpMediaServerSettings::NewL();
+    CleanupStack::PushL( settings );
+
+    // Get the location setting from ServerSettings
+    settings->Get( UpnpMediaServerSettings::EUploadDirectory, aLocation );
+
+    // Check to see if drive is ready.
+    TVolumeInfo volInfo;
+    TDriveUnit driveUnit = TDriveUnit( aLocation );
+    RFs fileServer;
+
+    User::LeaveIfError( fileServer.Connect() );
+    CleanupClosePushL( fileServer );
+    TInt error = fileServer.Volume( volInfo, driveUnit );
+    CleanupStack::PopAndDestroy( &fileServer );
+
+    // check if memory is present
+    // Revert to phone memory if location is not available
+    // If the location is full no need to change the location. User will be
+    // informed that memory is full and the location should be changed
+    if( error == KErrNone )
+        {
+        TDriveUnit driveUnit = TDriveUnit( aLocation );    
+        if( driveUnit == EDriveC )
+            {
+            aIsPhoneMemory = ETrue;
+            }
+        else
+            {
+            aIsPhoneMemory = EFalse;
+            }
+        }
+    else
+        {
+        SetCopyLocationL( EDriveC );
+        aIsPhoneMemory = ETrue;
+        }
+
+    CleanupStack::PopAndDestroy( settings );
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::SetCopyLocationL
+// Sets the location for copied files
+// --------------------------------------------------------------------------
+//
+EXPORT_C TInt CUPnPSettingsEngine::SetCopyLocationL( 
+    const TDriveNumber aDrive )
+    const
+    {
+    __LOG("CUPnPSettingsEngine::SetCopyLocationL()");
+    TInt err( KErrNone );
+
+    HBufC* path = HBufC::NewL( KMaxFileName );
+    CleanupStack::PushL( path );
+
+    CUpnpMediaServerSettings* settings =
+        CUpnpMediaServerSettings::NewL();
+    CleanupStack::PushL( settings );
+
+    TDriveUnit driveUnit = TDriveUnit( aDrive );
+    path->Des().Append( driveUnit.Name() );
+    if( aDrive == EDriveC )
+        {
+        path->Des().Append( KUploadDirectoryCDrive );
+        }
+    else
+        {
+        path->Des().Append( KUploadDirectory );
+        }
+
+    err = settings->Set( UpnpMediaServerSettings::EUploadDirectory, *path );
+
+    CleanupStack::PopAndDestroy( settings );
+    CleanupStack::PopAndDestroy( path );
+
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::GetCurrentIapNameL
+// Get iap name
+// --------------------------------------------------------------------------
+//
+EXPORT_C HBufC* CUPnPSettingsEngine::GetCurrentIapNameL( TInt aIapId )
+    {
+    __LOG("CUPnPSettingsEngine::GetCurrentIapNameL() begin");
+    __LOG("read iap");
+    
+    HBufC* name = NULL;
+    if( aIapId > EUPnPSettingsEngineIAPIdAlwaysAsk )
+        {
+        name = HBufC::NewLC( KMaxFileName );
+        TPtr namePtr( name->Des() );
+        CCommsDatabase* db = CCommsDatabase::NewL();
+        CleanupStack::PushL( db );
+        CCommsDbTableView* iapView = db->OpenViewMatchingUintLC(
+            TPtrC(IAP),
+            TPtrC(COMMDB_ID),
+            aIapId );
+        if( iapView )
+            {
+            TInt err = KErrNotFound;
+            err = iapView->GotoFirstRecord();
+            if ( !err )
+                {
+                iapView->ReadTextL(TPtrC(COMMDB_NAME), namePtr );
+                }
+            CleanupStack::PopAndDestroy( iapView );
+            }
+        CleanupStack::PopAndDestroy( db );
+        CleanupStack::Pop( name );
+        }
+    
+    if( !name )
+        {
+        User::LeaveIfError( KErrNotFound );
+        }
+    
+    __LOG("CUPnPSettingsEngine::GetCurrentIapNameL() end");
+    return name;
+    }
+
+//---------------------------------------------------------------------------
+// CUPnPSettingsEngine::IsAccessPointValidL
+// Checks if the given access point is valid.
+//---------------------------------------------------------------------------
+//
+EXPORT_C TBool CUPnPSettingsEngine::IsAccessPointValidL( TInt aIapId )
+    {
+    if ( aIapId == EUPnPSettingsEngineIAPIdAlwaysAsk )
+        {
+        // IAP is always ask. Returns true automatically.
+        return ETrue;
+        }
+    else if ( aIapId > EUPnPSettingsEngineIAPIdAlwaysAsk )
+        {
+        // Verifies that IAP exists in the comms db and it is valid.
+        return IsWLANAccessPointValidL( aIapId );
+        }
+    else
+        {
+        // IAP is NONE or some bogus value. Not valid.
+        return EFalse;
+        }
+    }
+
+// -------------------------------------------------------------
+// CUPnPSettingsEngine::GetWLANAccessPointsL
+// Get wlan access points from commsdb
+// -------------------------------------------------------------
+//
+EXPORT_C void CUPnPSettingsEngine::GetWLANAccessPointsL(
+                                    CDesCArray* aNameArray,
+                                    RArray<TInt64>& aIapIdArr )
+    {
+    __LOG("CUPnPSettingsEngine::GetWLANAccessPointsL() begin");
+#ifdef __arm
+    TUint32 bearerType;
+#endif
+
+    RCmManager cmm;
+    cmm.OpenL();
+    CleanupClosePushL ( cmm );
+
+    RArray<TUint32> iapIdArr;    
+    CleanupClosePushL ( iapIdArr );
+
+    //get all the connections, exclude easy wlan
+    cmm.ConnectionMethodL( iapIdArr, EFalse, EFalse, EFalse );
+
+    __LOG1(" total %d", iapIdArr.Count() );
+
+    //Get the iap names
+    for(TInt i = 0; i < iapIdArr.Count(); i++ )
+        {
+#ifdef __arm
+
+        bearerType = cmm.GetConnectionMethodInfoIntL(
+                               iapIdArr[i], CMManager::ECmBearerType );
+
+        __LOG1(" bearerType %d", bearerType);
+
+        if( bearerType == KUidWlanBearerType )
+            {
+#endif
+            __LOG1(" i: %d", i);
+            aIapIdArr.AppendL( iapIdArr[i] );
+
+            if( aNameArray )
+                {
+                HBufC* name = NULL;
+                __LOG(" name ");
+
+                // This can leave in WINSCW env, so catch and handle the
+                // exception
+                TRAPD( getConnectionMethodErr,
+                       name = cmm.GetConnectionMethodInfoStringL(
+                                   iapIdArr[i], CMManager::ECmName );
+                );
+
+                if( getConnectionMethodErr == KErrNone )
+                    {
+                    __LOG16( *name );
+                    CleanupStack::PushL( name );
+                    __LOG(" append name ");
+                    aNameArray->AppendL( *name ); //ownership not transferred
+                    CleanupStack::PopAndDestroy( name );
+                    }
+                else
+                    {
+                    // If failed to get the connection method info string,
+                    // use a dummy IAP name
+                    __LOG( " Failed to get IAP name! Using a dummy name. ");
+                    aNameArray->AppendL( KDummyIAP );
+                    }
+                }
+#ifdef __arm
+            }
+#endif
+
+        }
+
+    CleanupStack::PopAndDestroy( &iapIdArr );
+    CleanupStack::PopAndDestroy( &cmm );
+
+    __LOG1(" aIapIdArr count %d", aIapIdArr.Count() );  
+    __LOG("CUPnPSettingsEngine::GetWLANAccessPointsL() end");
+
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::CreateAccessPointL
+// Create AP modifying window
+// --------------------------------------------------------------------------
+//
+EXPORT_C void CUPnPSettingsEngine::CreateAccessPointL()
+    {
+    CCmSettingsUi* settings = CCmSettingsUi::NewL();    
+    CleanupStack::PushL( settings );
+    settings->RunSettingsL();
+    CleanupStack::PopAndDestroy( settings );
+    }
+    
+//---------------------------------------------------------------------------
+// CUPnPSettingsEngine::IsWLANAccessPointValidL
+// Checks if the given access point is valid.
+//---------------------------------------------------------------------------
+//
+TBool CUPnPSettingsEngine::IsWLANAccessPointValidL( TUint32 aIapId )
+    {
+    
+    TBool ret = EFalse;
+    
+    RArray<TInt64> newArray;
+    CleanupClosePushL( newArray );
+    
+    GetWLANAccessPointsL( NULL, newArray );
+    
+    for(TInt i = 0; i < newArray.Count(); i++ )
+        {
+        if( aIapId == newArray[i] )
+            {
+            ret = ETrue;
+            i = newArray.Count(); //quit the loop
+            }
+        }
+    CleanupStack::PopAndDestroy( &newArray ); 
+    
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPSettingsEngine::InitializePropertyL
+// Initializes a property if property has not yet been set
+// --------------------------------------------------------------------------
+//
+void CUPnPSettingsEngine::InitializePropertyL( 
+    CUpnpMediaServerSettings& aSettings, 
+    TInt aKey, 
+    const TDesC8& aValue ) const
+    {
+    HBufC8* currentValue( NULL );
+    TRAPD( err, currentValue = aSettings.GetL( aKey ) );
+    if( !err )
+        {
+        TInt currentLength = currentValue->Length();
+        delete currentValue;
+        currentValue = NULL;
+        if( !currentLength )
+            {
+            User::LeaveIfError( aSettings.SetL( aKey, aValue ) );
+            }
+        }
+    else if( err == KErrNotFound )
+        {
+        User::LeaveIfError( aSettings.SetL( aKey, aValue ) );
+        }
+    else
+        {
+        User::Leave( err );
+        }
+    }
+    
+// End of file
--- a/upnpsharing/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,42 +1,45 @@
-/*
-* Copyright (c) 2008 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:      Build information file for upnpsharing
-*
-*/
-
-// For compatibility with S60 3.2 and IAD branch
-#include "../../group/upnpplatformvar.hrh"
-
-PRJ_PLATFORMS
-
-PRJ_EXPORTS
-
-PRJ_MMPFILES
-
-// The DLNA profiler
-#include "../upnpdlnaprofiler/group/bld.inf"
-
-// upnp security
-#include "../upnpsecurity/group/bld.inf"
-
-// content server and server client
-#include "../upnpcontentserver/group/bld.inf"
-
-// content server API
-#include "../applicationengine/group/bld.inf"
-
-// Exports for upnpsharing
-#include "../rom/bld.inf"
-
-// end of file
+/*
+* Copyright (c) 2008 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:      Build information file for upnpsharing
+*
+*/
+
+// For compatibility with S60 3.2 and IAD branch
+#include "../../group/upnpplatformvar.hrh"
+
+PRJ_PLATFORMS
+
+PRJ_EXPORTS
+
+// LOC files
+UPNP_LOC_EXPORT(upnpsharing.loc)
+
+PRJ_MMPFILES
+
+    // The DLNA profiler
+    #include "../upnpdlnaprofiler/group/bld.inf"
+
+    // upnp security
+    #include "../upnpsecurity/group/bld.inf"
+
+    // upnpsharingalgorithm
+    #include "../upnpsharingalgorithm/group/bld.inf"
+
+    // content server and server client
+    #include "../upnpcontentserver/group/bld.inf"
+
+    // gstreamer wrapper
+    #include "../upnpgstwrapper/group/bld.inf"
+
+// End of file
--- a/upnpsharing/loc/upnpsharing.loc	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/loc/upnpsharing.loc	Mon Nov 01 12:37:49 2010 +0200
@@ -1,33 +1,81 @@
-/*
-* Copyright (c) 2008 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:      Localisation file for upnpsharing subsystem.
-*
-*/
-
-
-
-
-
-
-// LOCALISATION STRINGS
-
-
-//d:Confirmation query when remote Upnp device wants to connect to us.
-//l:popup_note_window/opt2
-//r:2.0
-//
-#define qtn_iupnp_incoming_device   "Accept connection from Home Media?"
-
-
-// End of File
+/*
+* Copyright (c) 2008 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:      Localisation file for upnpsharing subsystem.
+*
+*/
+
+// --------------------------------------------------------------------------
+// UpnpSecurity
+// --------------------------------------------------------------------------
+
+//d:Confirmation query when remote Upnp device wants to connect to us.
+//l:popup_note_window/opt2
+//r:2.0
+//
+#define qtn_iupnp_incoming_device   "Accept connection from Home Media?"
+
+
+// --------------------------------------------------------------------------
+// UpnpSharingAlgorithm
+// --------------------------------------------------------------------------
+
+//d:Media root container name for music items
+//l:(Not an UI component. Max length 256 chars.)
+//r:5.2
+// 
+#define qtn_iupnp_share_music                        "Music"
+
+//d:Media root container name for image items
+//l:(Not an UI component. Max length 256 chars.)
+//r:5.2
+//
+#define qtn_iupnp_share_images                       "Images"
+
+//d:Media root container name for video items
+//l:(Not an UI component. Max length 256 chars.)
+//r:5.2
+//
+#define qtn_iupnp_share_videos                       "Videos"
+
+//d:Default container name for media items
+//l:(Not an UI component. Max length 256 chars.)
+//r:5.2
+//
+#define qtn_iupnp_share_all                          "All"
+
+//d:Container for "by date" reference items
+//l:(Not an UI component. Max length 256 chars.)
+//r:5.2
+// 
+#define qtn_iupnp_share_by_date                      "By Date"
+
+//d:Container for "by album" reference items
+//l:(Not an UI component. Max length 256 chars.)
+//r:5.2
+// 
+#define qtn_iupnp_share_by_album                     "By Album"
+
+//d:Container for "by artist" reference items
+//l:(Not an UI component. Max length 256 chars.)
+//r:5.2
+// 
+#define qtn_iupnp_share_by_artist                    "By Artist"
+
+//d:Container for "by genre" reference items
+//l:(Not an UI component. Max length 256 chars.)
+//r:5.2
+// 
+#define qtn_iupnp_share_by_genre                     "By Genre"
+
+// End of File
--- a/upnpsharing/upnpcontentserver/group/bld.inf	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/group/bld.inf	Mon Nov 01 12:37:49 2010 +0200
@@ -1,39 +1,40 @@
-/*
-* Copyright (c) 2006-2007 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:      Project definition file for project upnpcontentserver
-*
-*/
-
-
-
-
-
-PRJ_EXPORTS
-
-// Central repository default keys
-../cenrep/20007564.txt  /epoc32/release/winscw/udeb/z/private/10202be9/20007564.txt
-../cenrep/20007564.txt  /epoc32/release/winscw/urel/z/private/10202be9/20007564.txt
-../cenrep/20007564.txt  /epoc32/release/armv5/udeb/z/private/10202be9/20007564.txt
-../cenrep/20007564.txt  /epoc32/release/armv5/urel/z/private/10202be9/20007564.txt
-../conf/upnpcontentserver.confml              APP_LAYER_CONFML(upnpcontentserver.confml)
-../conf/upnpcontentserver_20007564.crml       APP_LAYER_CRML(upnpcontentserver_20007564.crml)
-
-../inc/upnpcontentservercrkeys.h    |../../../inc/upnpcontentservercrkeys.h
-../inc/upnpcontentserverdefs.h      |../../../inc/upnpcontentserverdefs.h
-../inc/upnpcontentserverclient.h    |../../../inc/upnpcontentserverclient.h
-
-PRJ_MMPFILES
-upnpcontentserver.mmp
-upnpcontentserverclient.mmp
-
+/*
+* Copyright (c) 2006-2007 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:      Project definition file for project upnpcontentserver
+*
+*/
+
+PRJ_EXPORTS
+
+// Central repository default keys
+../cenrep/20007564.cre  /epoc32/release/winscw/udeb/z/private/10202be9/20007564.cre
+../cenrep/20007564.cre  /epoc32/release/winscw/urel/z/private/10202be9/20007564.cre
+../cenrep/20007564.cre  /epoc32/release/armv5/udeb/z/private/10202be9/20007564.cre
+../cenrep/20007564.cre  /epoc32/release/armv5/urel/z/private/10202be9/20007564.cre
+../cenrep/20007564.txt  /epoc32/release/winscw/udeb/z/private/10202be9/20007564.txt
+../cenrep/20007564.txt  /epoc32/release/winscw/urel/z/private/10202be9/20007564.txt
+../cenrep/20007564.txt  /epoc32/release/armv5/udeb/z/private/10202be9/20007564.txt
+../cenrep/20007564.txt  /epoc32/release/armv5/urel/z/private/10202be9/20007564.txt
+../conf/upnpcontentserver.confml              APP_LAYER_CONFML(upnpcontentserver.confml)
+../conf/upnpcontentserver_20007564.crml       APP_LAYER_CRML(upnpcontentserver_20007564.crml)
+
+../inc/upnpcontentservercrkeys.h    |../../../inc/upnpcontentservercrkeys.h
+../inc/upnpcontentserverdefs.h      |../../../inc/upnpcontentserverdefs.h
+../inc/upnpcontentserverclient.h    |../../../inc/upnpcontentserverclient.h
+
+PRJ_MMPFILES
+upnpcontentserver.mmp
+upnpcontentserverclient.mmp
+
+// End of file
--- a/upnpsharing/upnpcontentserver/group/upnpcontentserver.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/group/upnpcontentserver.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,90 +1,87 @@
-/*
-* Copyright (c) 2006-2007 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:      Project definition file for project upnpcontentserver
-*
-*/
-
-
-
-
-
-
-#include "../../../group/upnpplatformvar.hrh"
-#include <data_caging_paths.hrh>
-#include "defaultcaps.hrh"
-
-CAPABILITY CAP_SERVER
-VENDORID VID_DEFAULT
-TARGETTYPE exe
-TARGET upnpcontentserver.exe
-
-UID 0x1000008d 0x20007564
-
-// SIS installation + IAD support
-VERSION 10.1
-paged
-
-EPOCSTACKSIZE 0x8000
-EPOCHEAPSIZE   0x20000 0x1000000 // min size 128kB, max size 16mb
-
-MW_LAYER_SYSTEMINCLUDE
-
-USERINCLUDE ../inc
-USERINCLUDE ../../../inc
-
-SOURCEPATH ../src
-
-SOURCE upnpcontentserver.cpp
-SOURCE upnpcontentserversession.cpp
-SOURCE upnpcontentserverhandler.cpp
-SOURCE upnpcontentsharingao.cpp
-SOURCE upnpsharingrequest.cpp
-SOURCE upnpcontainercheckerao.cpp
-SOURCE upnpunsharerao.cpp
-
-// From old applicationengine
-SOURCE upnpcontentmetadatautility.cpp
-SOURCE upnpcustomgrouper.cpp
-SOURCE upnppostfilter.cpp
-SOURCE upnpselectionreader.cpp
-SOURCE upnpselectionwriter.cpp
-
-LIBRARY euser.lib 
-LIBRARY bafl.lib 
-LIBRARY estor.lib 
-LIBRARY ws32.lib 
-LIBRARY efsrv.lib 
-LIBRARY PlatformEnv.lib
-LIBRARY centralrepository.lib
-// Content listing framework (metadata)
-LIBRARY contentlistingframework.lib
-// CUpnpElement etc..
-LIBRARY upnpavobjects.lib
-// CUpnpFileSharing
-LIBRARY avmediaserverclient.lib
-LIBRARY upnpserviceframework.lib
-
-// UpnpString..
-LIBRARY upnpipserversutils.lib
-
-// upnputilities
-LIBRARY upnputilities.lib
-LIBRARY upnpavcontrollerhelper.lib
-
-LIBRARY dlnaprofiler.lib
-LIBRARY upnpmusicadapter.lib
-
-DEBUGLIBRARY    flogger.lib
-
-// End of file
+/*
+* Copyright (c) 2006-2007 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:      Project definition file for project upnpcontentserver
+*
+*/
+
+
+
+
+
+
+#include "../../../group/upnpplatformvar.hrh"
+#include <data_caging_paths.hrh>
+#include "defaultcaps.hrh"
+
+CAPABILITY CAP_SERVER
+VENDORID VID_DEFAULT
+TARGETTYPE exe
+TARGET upnpcontentserver.exe
+
+UID 0x1000008d 0x20007564
+
+// SIS installation + IAD support
+VERSION 10.1
+paged
+
+EPOCSTACKSIZE 0x8000
+EPOCHEAPSIZE   0x20000 0x1000000 // min size 128kB, max size 16mb
+
+MW_LAYER_SYSTEMINCLUDE
+
+USERINCLUDE ../inc
+USERINCLUDE ../../../inc
+
+SOURCEPATH ../src
+
+SOURCE upnpcontentserver.cpp
+SOURCE upnpcontentserversession.cpp
+SOURCE upnpsharingrequest.cpp 
+SOURCE upnpcontentmetadatautility.cpp  
+SOURCE upnpselectionreader.cpp 
+SOURCE upnpselectionwriter.cpp 
+SOURCE upnpcontentserverhandler.cpp 
+SOURCE upnpcontentsharerao.cpp
+
+LIBRARY euser.lib 
+LIBRARY bafl.lib 
+LIBRARY estor.lib 
+LIBRARY ws32.lib 
+LIBRARY efsrv.lib 
+LIBRARY PlatformEnv.lib
+LIBRARY centralrepository.lib
+LIBRARY inetprotutil.lib            // for EscapeUtils
+// Content listing framework (metadata)
+LIBRARY contentlistingframework.lib
+// CUpnpElement etc..
+LIBRARY upnpavobjects.lib
+// CUpnpFileSharing
+LIBRARY avmediaserverclient.lib
+LIBRARY upnpserviceframework.lib
+LIBRARY upnpsharingalgorithm.lib
+
+// UpnpString..
+LIBRARY upnpipserversutils.lib
+
+// upnputilities
+LIBRARY upnputilities.lib
+LIBRARY upnpconnmon.lib
+LIBRARY upnpavcontrollerhelper.lib
+
+LIBRARY dlnaprofiler.lib
+LIBRARY upnpmusicadapter.lib
+
+DEBUGLIBRARY    flogger.lib
+
+// End of file
--- a/upnpsharing/upnpcontentserver/inc/upnpcontentmetadatautility.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/inc/upnpcontentmetadatautility.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,271 +1,151 @@
-/*
-* Copyright (c) 2006-2007 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:      Metadata utility class definition
- *
-*/
-
-
-
-
-
-
-#ifndef __UPNPCONTENTMETADATAUTILITY_H__
-#define __UPNPCONTENTMETADATAUTILITY_H__
-
-
-// INCLUDES
-// System
-#include <e32base.h>
-#include <MCLFOperationObserver.h>
-#include <MCLFChangedItemObserver.h>
-#include <MCLFItem.h>
-#include <badesca.h>
-
-// upnp stack api
-#include <upnpitem.h>
-
-// upnpframework / avcontroller helper api
-#include "upnpconstantdefs.h" // for upnp-specific stuff
-
-// homeconnect internal
-#include "upnpcontentserverdefs.h"
-#include "upnpcontentserverhandler.h"
-
-
-// CONSTANTS
-const TInt KMaxRefreshCount = 3;
-
-// FORWARD DECLARATIONS
-class MCLFContentListingEngine;
-class MCLFItemListModel;
-class CUpnpCustomGrouper;
-class CUpnpPostFilter;
-class MUpnpMetadataObserver;
-class CUPnPMetaDataUtility;
-
-
-// CLASS DECLARATION
-
-/**
- *  Class to collect files from phone to share.
- *  This class collects the media files for Upnp content server to share
- *  The files are obtained using Content Listing Framework.
- *
- *  @since S60 3.1
- */
-class CUpnpContentMetadataUtility : public CBase,
-                                public MCLFOperationObserver
-    {
-public:  // Constructors and destructor
-
-    /**
-     * Two-phased constructor.
-     */
-    static CUpnpContentMetadataUtility* NewL();
-
-    /**
-     * Destructor.
-     */
-    virtual ~CUpnpContentMetadataUtility();
-
-public: // New functions
-
-    /**
-     * Updates metadata for the item
-     * @since S60 3.1
-     * @param aMediaType Media type of oitem to be updated
-     * @param aItem pointer to item
-     * @param aFileName Reference to item filename
-     * @return ETrue if the item was found from this model
-     */
-    TBool UpdateMetadataL( const TUpnpMediaType& aMediaType,
-                           CUpnpItem* aItem,
-                           const TDesC& aFileName );
-
-    /**
-     * Returns music model
-     * @since S60 3.1
-     * @return MCLFItemListModel reference to model
-     */
-    const MCLFItemListModel& MusicFiles() const;
-
-    /**
-     * Returns image model
-     * @since S60 3.1
-     * @return MCLFItemListModel reference to model
-     */
-    const MCLFItemListModel& ImageFiles() const;
-
-
-    /**
-     * Returns video model
-     * @since S60 3.1
-     * @return MCLFItemListModel reference to model
-     */
-    const MCLFItemListModel& VideoFiles() const;
-
-
-    /**
-     * Returns collection model
-     * @since S60 3.1
-     * @return MCLFItemListModel reference to model
-     */
-    const MCLFItemListModel& Collections() const;
-
-
-    /**
-     * Collects items from selected collection to the model
-     * @since S60 3.1
-     * @param aNameOfCollection, collection name
-     */
-    void CollectionItemsL( const TDesC& aNameOfCollection );
-
-
-    /**
-     * Extract files from descriptor to the array
-     * @since S60 3.1
-     * @param aFileArray, file name array
-     * @param aFiles, file name descriptor
-     */
-    void GetCollectionFileNamesL( CDesCArray& aFileArray,
-                                  const TDesC& aFiles ) const;
-
-    /**
-     * Returns true if refresh is still ongoing
-     * @since S60 3.1
-     * @return Status of the refresh operation
-     */
-    TBool RefreshOngoing() const;
-
-    /**
-     * Clears all postfilters
-     * @since S60 3.1
-     *
-     */
-    void ClearPostFiltersL();
-
-    /**
-     * Creates UPnP item from CLF Item
-     * @since S60 3.1
-     * @param aCLFItem reference to original item
-     * @param aParentId Parent id of the item
-     * @return CUpnpItem new item allocation
-     */
-    CUpnpItem* CreateItemL( const MCLFItem& aCLFItem,
-                            const TDesC8&  aParentId ) const;
-
-    /**
-     * Creates UPnP item from CLF Item
-     * @since S60 3.1
-     * @param aFullFilenme Filename of the item
-     * @param aParentId Parent id of the item
-     * @return CUpnpItem new item allocation
-     */
-    CUpnpItem* CreateItemL(
-        const TDesC& aFullFilename,
-        const TDesC8& aParentId ) const;
-
-    /**
-     * Sets the callback for informing about refresh state
-     * @since S60 3.1
-     * @param aHandler pointer to observer
-     */
-    void SetCallback( MUpnpMetadataObserver* aObserver );
-
-
-protected: // From MCLFOperationObserver
-
-    /**
-     * Abstract method to get list model operation events. This method is
-     * called when an event is received.
-     * @since S60 3.1
-     * @param aOperationEvent Operation event code of the event
-     * @param aError System wide error code if the operation did not
-     *        succeed.
-     */
-    void HandleOperationEventL( TCLFOperationEvent aOperationEvent,
-                                TInt aError );
-
-protected:  // From MCLFChangedItemObserver
-
-    /**
-     * From MCLFChangedItemObserver Method to handle changed item event.
-     * @since S60 3.1
-     * @param aItemIDArray List of changed item IDs
-     */
-    void HandleItemChangeL( const TArray<TCLFItemId>& aItemIDArray );
-
-    /**
-     * From MCLFChangedItemObserver Method is used to handle errors in
-     * changed item event.
-     * @since S60 3.1
-     * @param aError System wide error code.
-     */
-    void HandleError( TInt aError );
-
-
-private:
-
-    /**
-     * C++ default constructor.
-     */
-    CUpnpContentMetadataUtility();
-
-    /**
-     * By default Symbian 2nd phase constructor is private.
-     */
-    void ConstructL();
-
-private:    // Data
-    // Content listing engine (owned)
-    MCLFContentListingEngine* iEngine;
-
-    // Content listing model for music (owned)
-    MCLFItemListModel* iMusicModel;
-
-    // Content listing model for images (owned)
-    MCLFItemListModel* iImageModel;
-
-    // Content listing model for videos (owned)
-    MCLFItemListModel* iVideoModel;
-
-    // Content listing model for collections (owned)
-    MCLFItemListModel* iCollectionModel;
-
-    // Custom grouper for collection grouping (owned)
-    CUpnpCustomGrouper* iCustomGrouper;
-
-    // Status to indicate if refresh operation is ongoing
-    TBool iRefreshOngoing;
-
-    // Keeps count of refreshed models
-    TInt iRefreshCounter;
-
-    // Post filter for filtering (owned)
-    CUpnpPostFilter* iPostFilter;
-
-    // Callback interface
-    // not owned
-    MUpnpMetadataObserver* iHandler;
-
-    // The index maintained during the multiple CLF operations
-    TInt iClfIndex;
-    
-    // Utility class for CLF
-    CUPnPMetaDataUtility* iMetaDataUtility; // owned
-    };
-
-#endif      // __UPNPCONTENTMETADATAUTILITY_H__
-
-// End of File
+/*
+* Copyright (c) 2006-2007 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:      Metadata utility class definition
+ *
+*/
+
+
+
+
+
+
+#ifndef __UPNPCONTENTMETADATAUTILITY_H__
+#define __UPNPCONTENTMETADATAUTILITY_H__
+
+
+// INCLUDES
+// System
+#include <e32base.h>
+#include <MCLFOperationObserver.h>
+#include <MCLFItem.h>
+#include <badesca.h>
+// Internal
+#include "upnpconstantdefs.h" // for upnp-specific stuff
+#include "upnpcontentserverdefs.h"
+#include "upnpcontentserverhandler.h"
+
+// FORWARD DECLARATIONS
+class MCLFContentListingEngine;
+class MCLFItemListModel;
+class TClfMediaType;
+
+using namespace UpnpContentServer;
+
+// CLASS DECLARATION
+
+/**
+ *  Class to collect files from phone to share.
+ *  This class collects the media files for Upnp content server to share
+ *  The files are obtained using Content Listing Framework.
+ *
+ *  @since S60 3.1
+ */
+class CUpnpContentMetadataUtility : public CBase,
+                                public MCLFOperationObserver
+    {
+    
+public:  // Constructors and destructor
+
+    /**
+     * Two-phased constructor.
+     */
+    static CUpnpContentMetadataUtility* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUpnpContentMetadataUtility();
+
+public: // New functions
+
+    /**
+     * Returns music model
+     * @since S60 5.2
+     * @return MCLFItemListModel reference to model
+     */
+    const MCLFItemListModel* MusicFiles();
+
+    /**
+     * Returns image model
+     * @since S60 5.2
+     * @return MCLFItemListModel reference to model
+     */
+    const MCLFItemListModel* ImageFiles();
+
+    /**
+     * Returns video model
+     * @since S60 5.2
+     * @return MCLFItemListModel reference to model
+     */
+    const MCLFItemListModel* VideoFiles();
+
+protected: // From MCLFOperationObserver
+
+    /**
+     * Abstract method to get list model operation events. This method is
+     * called when an event is received.
+     * @since S60 3.1
+     * @param aOperationEvent Operation event code of the event
+     * @param aError System wide error code if the operation did not
+     *        succeed.
+     */
+    void HandleOperationEventL( TCLFOperationEvent aOperationEvent,
+                                TInt aError );
+
+private:
+
+    /**
+     * C++ default constructor.
+     */
+    CUpnpContentMetadataUtility();
+
+    /**
+     * By default Symbian 2nd phase constructor is private.
+     */
+    void ConstructL();
+    
+    /**
+     * Refreshes the selected model information
+     * @since S60 5.2
+     * @param aCLFMediaType CLF media type
+     */
+    void RefreshModelL( TCLFMediaType aCLFMediaType );
+
+    /**
+     * Wait for refresh operation to complete
+     * @since S60 5.2
+     */
+    void WaitForRefreshToComplete();
+
+private:    // Data
+    // Content listing engine (owned)
+    MCLFContentListingEngine* iEngine;
+
+    // Content listing model for music (owned)
+    MCLFItemListModel* iMusicModel;
+
+    // Content listing model for images (owned)
+    MCLFItemListModel* iImageModel;
+
+    // Content listing model for videos (owned)
+    MCLFItemListModel* iVideoModel;
+
+    // Waiter for Refresh processes (owned)
+    CActiveSchedulerWait* iWait;
+
+    };
+
+#endif      // __UPNPCONTENTMETADATAUTILITY_H__
+
+// End of File
--- a/upnpsharing/upnpcontentserver/inc/upnpcontentserver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/inc/upnpcontentserver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,193 +1,193 @@
-/*
-* Copyright (c) 2006-2007 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:      Header for upnpcontentserver 
-*
-*/
-
-
-
-
-
-
-#ifndef __UPNPCONTENTSERVER_H__
-#define __UPNPCONTENTSERVER_H__
-
-// INCLUDES
-#include <e32base.h>
-#include "upnpconnectionmonitorobserver.h"
-#include "upnpconnectionmonitor.h"
-#include "upnpcontentserverhandler.h"
-#include "upnpcontentserversession.h"
-
-// FORWARD DECLARATIONS
-class CUPnPPeriodic;
-
-// Server shutdown delay in microseconds (2.5s)
-const TInt KShutdownTimeout = 2500000;
-
-// FORWARD DECLARATIONS
-class CUpnpContentServerSession;
-
-/**
-*  A server class to initialize server.
-*
-*  @since S60 3.1
-*/
-class CUpnpContentServer : public CPolicyServer,
-                           public MUPnPConnectionMonitorObserver
-    {
-public:
-    /**
-    * A Method to initialize the CleanupStack and the ActiveScheduler.
-    * Creates an instance of CUpnpContentServer.
-    * @param None.
-    * @return KErrNone, if successful, otherwise one of the other system-wide
-    *         error codes.
-    */
-    static TInt LaunchServerL();
-
-    /**
-    * 2-phased constructor.
-    */
-    static CUpnpContentServer* NewL();
-
-    /**
-    * C++ destructor.
-    */
-    virtual ~CUpnpContentServer();
-
-    /**
-     * Returns pointer CUpnpContentserverHandler instanse
-     * @since S60 3.1
-     */
-    CUpnpContentServerHandler* Handler() const;
- 
-    /**
-     * Decrements session counter
-     * @since S60 3.1
-     */
-    void RemoveSession();
-
-    /**
-     * Decrements session counter
-     * @since S60 3.1
-     */
-    void AddSession();
-
-    /**
-     * Indicates if server can be stopped
-     * @since S60 3.1
-     * @ return ETrue if there is no other session open
-     */
-    TBool CanStop() const;
-
-    /**
-     * Stop the server with delay
-     * @since S60 3.1
-     */
-    void Stop();
-
-    /**
-     * Perform the shutdown of the server
-     * @return KErrNone
-     */
-    static TInt Shutdown( TAny* aPtr );
-
-    /**
-     * Start the connection monitor if not yet started
-     * Register for connection lost events
-     * @since S60 3.1
-     */
-    TInt RequestConnectionLostL( const TInt aIapId );
-
-    /**
-     * Stop the connection monitor if only session
-     * unregister the session from connection monitoring
-     * @since S60 3.1
-     */
-    void CancelConnectionLostL();
-
-public:
-    /**
-    * From CServer2, creates a new session.
-    */
-    CSession2* NewSessionL( const TVersion& aVersion, 
-                            const RMessage2& aMessage ) const;
-
-protected:
-    /**
-     * From CServer2, handle possible leaves
-     */
-    TInt RunError( TInt aError );
-
-private:
-    /**
-    * C++ constructor.
-    */
-    CUpnpContentServer();
-
-    /**
-    * 2nd phase constructor.
-    */
-    void ConstructL( );
-
-private:
-    /**
-     * From MUPnPConnectionMonitorObserver
-     * Inform all sessions that connection has been lost
-     * @since S60 3.1
-     */
-    void ConnectionLost();
-
-
-private:
-
-    /** 
-     * Server has an object container index which 
-     * creates an object container for each session
-     * owned
-     */
-    CObjectConIx* iContainerIndex;
-
-    /**
-     * Pointer to handler
-     * owned
-     */
-    CUpnpContentServerHandler* iHandler;
-
-    /**
-     * Session count
-     */
-    TInt iSessionCount;
-
-    /**
-     * Connection monitor handle
-     */
-    CUPnPConnectionMonitor* iConMon;
-
-    /**
-     * Id of the active IAP
-     */
-    TInt iActiveIapId;
-
-    /**
-     * Delayer for the server shutdown
-     */
-    CUPnPPeriodic* iIdle;
-
-    };
-
-
-#endif // __UPNPCONTENTSERVER_H__
-
+/*
+* Copyright (c) 2006-2007 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:      Header for upnpcontentserver 
+*
+*/
+
+
+
+
+
+
+#ifndef __UPNPCONTENTSERVER_H__
+#define __UPNPCONTENTSERVER_H__
+
+// INCLUDES
+#include <e32base.h>
+#include "upnpconnectionmonitorobserver.h"
+#include "upnpconnectionmonitor.h"
+#include "upnpcontentserverhandler.h"
+#include "upnpcontentserversession.h"
+
+// FORWARD DECLARATIONS
+class CUPnPPeriodic;
+
+// Server shutdown delay in microseconds (2.5s)
+const TInt KShutdownTimeout = 2500000;
+
+// FORWARD DECLARATIONS
+class CUpnpContentServerSession;
+
+/**
+*  A server class to initialize server.
+*
+*  @since S60 3.1
+*/
+class CUpnpContentServer : public CPolicyServer,
+                           public MUPnPConnectionMonitorObserver
+    {
+public:
+    /**
+    * A Method to initialize the CleanupStack and the ActiveScheduler.
+    * Creates an instance of CUpnpContentServer.
+    * @param None.
+    * @return KErrNone, if successful, otherwise one of the other system-wide
+    *         error codes.
+    */
+    static TInt LaunchServerL();
+
+    /**
+    * 2-phased constructor.
+    */
+    static CUpnpContentServer* NewL();
+
+    /**
+    * C++ destructor.
+    */
+    virtual ~CUpnpContentServer();
+
+    /**
+     * Returns pointer CUpnpContentserverHandler instanse
+     * @since S60 3.1
+     */
+    CUpnpContentServerHandler* Handler() const;
+ 
+    /**
+     * Decrements session counter
+     * @since S60 3.1
+     */
+    void RemoveSession();
+
+    /**
+     * Decrements session counter
+     * @since S60 3.1
+     */
+    void AddSession();
+
+    /**
+     * Indicates if server can be stopped
+     * @since S60 3.1
+     * @ return ETrue if there is no other session open
+     */
+    TBool CanStop() const;
+
+    /**
+     * Stop the server with delay
+     * @since S60 3.1
+     */
+    void Stop();
+
+    /**
+     * Perform the shutdown of the server
+     * @return KErrNone
+     */
+    static TInt Shutdown( TAny* aPtr );
+
+    /**
+     * Start the connection monitor if not yet started
+     * Register for connection lost events
+     * @since S60 3.1
+     */
+    TInt RequestConnectionLostL( const TInt aIapId );
+
+    /**
+     * Stop the connection monitor if only session
+     * unregister the session from connection monitoring
+     * @since S60 3.1
+     */
+    void CancelConnectionLostL();
+
+public:
+    /**
+    * From CServer2, creates a new session.
+    */
+    CSession2* NewSessionL( const TVersion& aVersion, 
+                            const RMessage2& aMessage ) const;
+
+protected:
+    /**
+     * From CServer2, handle possible leaves
+     */
+    TInt RunError( TInt aError );
+
+private:
+    /**
+    * C++ constructor.
+    */
+    CUpnpContentServer();
+
+    /**
+    * 2nd phase constructor.
+    */
+    void ConstructL( );
+
+private:
+    /**
+     * From MUPnPConnectionMonitorObserver
+     * Inform all sessions that connection has been lost
+     * @since S60 3.1
+     */
+    void ConnectionLost( TBool aUserOriented );
+
+
+private:
+
+    /** 
+     * Server has an object container index which 
+     * creates an object container for each session
+     * owned
+     */
+    CObjectConIx* iContainerIndex;
+
+    /**
+     * Pointer to handler
+     * owned
+     */
+    CUpnpContentServerHandler* iHandler;
+
+    /**
+     * Session count
+     */
+    TInt iSessionCount;
+
+    /**
+     * Connection monitor handle
+     */
+    CUPnPConnectionMonitor* iConMon;
+
+    /**
+     * Id of the active IAP
+     */
+    TInt iActiveIapId;
+
+    /**
+     * Delayer for the server shutdown
+     */
+    CUPnPPeriodic* iIdle;
+
+    };
+
+
+#endif // __UPNPCONTENTSERVER_H__
+
--- a/upnpsharing/upnpcontentserver/inc/upnpcontentserverhandler.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/inc/upnpcontentserverhandler.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,379 +1,445 @@
-/*
-* Copyright (c) 2006-2007 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:      The header of content server main scheduler class
- *
-*/
-
-
-
-
-
-#ifndef __UPNPCONTENTSERVERHANDLER_H__
-#define __UPNPCONTENTSERVERHANDLER_H__
-
-// INCLUDES
-#include <e32base.h>
-#include <e32property.h>
-
-#include "upnpcontentserverdefs.h"
-#include "upnpcontentserverclient.h"
-#include "upnpcontentsharingao.h"
-#include "upnpcontentsharingobserver.h"
-#include "upnpsharingcallback.h"
-#include "upnpsharingrequest.h"
-
-#include "upnpmetadataobserver.h"
-#include "upnpcontainercheckerao.h"
-#include "upnpunsharerao.h"
-
-// FORWARD DECLARATIONS
-
-class CUpnpSelectionReader;
-class CUpnpContentMetadataUtility;
-class CUpnpContentSharingAo;
-class CUpnpSharingRequest;
-class CUpnpContentServer;
-class CUPnPPeriodic;
-
-
-/**
- *  A class to schedule the active objects in server
- *
- *  @since S60 3.1
- */
-class CUpnpContentServerHandler : public CBase,
-                                  public MUpnpSharingCallback,
-                                  public MUpnpMetadataObserver
-    {
-    /**
-     * Indicates internal state of the CUpnpContentServerHandler
-     */
-    enum THandlerState
-        {
-        ESchedulingSharing,
-        EWaitingUploads,
-        EProcessingUploads,
-        ENotActive
-        };
-
-    /**
-     * Indicates which active object is running
-     */
-    enum TSharingPhase
-        {
-        ESharingInActive,
-        ECheckDefaults,
-        EUnshare,
-        EShare
-        };
-
-public:
-
-    /**
-     * 2-phased constructor.
-     */
-    static CUpnpContentServerHandler* NewL( CUpnpContentServer* aServer );
-
-    /**
-     * C++ destructor.
-     */
-    virtual ~CUpnpContentServerHandler();
-
-    /**
-     * Sets the observer to session class
-     * @since S60 3.1
-     * @param aObserver Pointer to observer in session class
-     */
-    void SetContentSharingObserverL( MUpnpContentSharingObserver* aObserver );
-
-    /**
-     * Start the media server upload listener, leave if error
-     * @since S60 3.1
-     */
-    void StartUploadListenerL();
-
-    /**
-     * Stop the media server upload listener, leave if error
-     * @since S60 3.1
-     */
-    void StopUploadListenerL();
-
-    /**
-     * Get the strings for the UI
-     * @since S60 3.1
-     * @param aContainerType Type of the content requested
-     */
-    void GetSelectionContentL( const TInt& aContainerType );
-
-    /**
-     * Get the selected items for the UI
-     * @since S60 3.1
-     * @param aMarkedItems Array of previous sharing selections
-     * @param aType Type of selections to request
-     */
-    void GetSelectionIndexesL( RArray<TInt>& aMarkedItems,
-                               const TInt aType );
-
-    /**
-     * Start sharing
-     * @since S60 3.1
-     * @param aMarkedItems The new sharing selections
-     * @param aType Type of sharing selections
-     */
-    void ChangeShareContentL( const RArray<TInt>& aMarkedItems,
-                              const TInt aType );
-
-    /**
-     * First read the selections then refresh.
-     * Leaves with KErrServerBusy if sharing is ongoing
-     * @since S60 3.1
-     * @param aType Type of refresh requested
-     */
-    void RefreshShareContentL(
-        TInt aType );
-
-    /**
-     * Determines if it is possible to stop the server
-     * @since S60 3.1
-     */
-    TBool CanStop() const;
-
-    /**
-     * Callback from metadatautility to inform that refresh is completed
-     * @since S60 3.1
-     */
-    void RefreshDoneL();
-
-    /**
-     * Switch media server offline, change internal states accordingly
-     * @since S60 3.1
-     */
-    TBool ConnectionLostL();
-
-    // from MUpnpSharingCallback
-    //
-
-    /**
-     * The CUpnpContentSharingAo uses this to indicate it has done sharing
-     * @since S60 3.1
-     * @param aErr Error code
-     * @param aType Type of sharing completed
-     */
-    void CompleteSharingOperationL(
-        const TInt& aErr, const TInt& aType );
-    /**
-     * Cancel the current sharing operation
-     * @since S60 3.1
-     * @param aErr Error code
-     */
-    void CancelSharingOperationL(
-        const TInt& aErr );
-
-    /**
-     * Update the progress PubSub key
-     * @since S60 3.1
-     * @param aProgress Progress to update
-     */
-    void SetProgressL(
-        const TInt& aProgress );
-
-    /**
-     * Cancel the current sharing operation
-     * @since S60 3.1
-     * @param aErr Error code
-     */
-    void ValidateDefaultContainersL();
-
-
-
-
-private:
-    /**
-     * C++ constructor.
-     * @since S60 3.1
-     */
-    CUpnpContentServerHandler( CUpnpContentServer* aServer );
-
-    /**
-     * The main sharing loop
-     * @since S60 3.1
-     */
-    void DoShareL( );
-
-    /**
-     * Cleanup  resources, also state variables are cleaned
-     * @since S60 3.1
-     */
-    void Cleanup();
-
-    /**
-     * 2nd phase constructor.
-     * @since S60 3.1
-     */
-    void ConstructL();
-
-    /**
-     * Get id of the default container determined by aType
-     * @since S60 3.1
-     * @param aType Determines which container id is returned
-     */
-    TInt GetContainerId( const TInt aType ) const;
-
-    /**
-     * Fill the progress info for aType
-     * @since S60 3.1
-     * @param aArr Array to store progress information
-     * @param aType Determines which container id is returned
-     */
-    void FillProgressInfoL(
-        RArray<TUpnpProgressInfo>& aArr,
-        const TInt aType );
-
-    /**
-     * Set the values of the iImageVideoSharingReq or iMusicSharingReq
-     * depending of aType
-     * @since S60 3.1
-     * @param aMarkedItems The new sharing selections
-     * @param aType Type of sharing selections
-     */
-    void SetSharingRequestL(
-        const RArray<TInt>& aMarkedItems,
-        const TInt aType );
-
-    /**
-     * Handle errors from active objects
-     * @since S60 3.1
-     * @param aError Error code
-     */
-    void HandleError( TInt aError );
-
-    /**
-     * Perform CLF refresh in background
-     * @param aPtr Pointer to CUpnpContentServerHandler instance
-     * @return EFalse
-     */
-    static TInt RefreshClfL( TAny* aPtr );
-    
-    
-private:
-    /**
-     * Pointer to server process, used for stopping it
-     * Not owned
-     */
-    CUpnpContentServer* iServer;
-
-    /**
-     * Pointer to CLF interface
-     * owned
-     */
-    CUpnpContentMetadataUtility* iMetadata;
-
-    /**
-     * The sharing engine
-     * owned
-     */
-    CUpnpContentSharingAo* iAo;
-
-    /**
-     * Pointer to corresponding session observer for returning results
-     * not owned
-     */
-    MUpnpContentSharingObserver* iContentSharingObserver;
-
-    /**
-     * Gets the albums/playlists to UI
-     * owned
-     */
-    CUpnpSelectionReader* iReader;
-
-    /**
-     * Used to wait CLF refresh
-     */
-    CActiveSchedulerWait iWait;
-
-    /**
-     * Handlers current state
-     */
-    TInt iHandlerState;
-
-    /**
-     * Currently processed request index
-     */
-    TInt iBufferPosition;
-
-    /**
-     * The buffer for image and video sharing requests
-     * owned
-     */
-    CUpnpSharingRequest* iVisualSharingReq;
-
-    /**
-     * The buffer for music sharing requests
-     * owned
-     */
-    CUpnpSharingRequest* iMusicSharingReq;
-
-    /**
-     * The buffer for any sharing request which is not yet scheduled to run
-     * owned
-     */
-    CUpnpSharingRequest* iPendingSharingReq;
-
-    /**
-     * Ongoing sharing operation. See TSharingPhase
-     */
-    TInt iSharingPhase;
-
-    /**
-     * Active object checking the file structure of the media server
-     */
-    CUpnpContainerCheckerAo* iContainerChecker;
-
-    /**
-     * Active object handling the unsharing of items and containers
-     */
-    CUpnpUnsharerAo* iUnsharer;
-
-    /**
-     * Storage for ids of default containers
-     */
-    RArray<TInt> iDefaultContainerIds;
-
-    /**
-     * MediaServer Handle
-     * Owned
-     */
-    RUpnpMediaServerClient* iMediaServer;
-
-    /**
-     * Error code, reset after transferred to client
-     */
-    TInt iErrorToClient;
-
-    /**
-    * Flag to indicate if the iContainerChecker is created in
-    * staring sharing context
-    */
-    TBool iStartupCleaning;
-
-    /**
-     * The Publish subscribe key to deliver progress infromation about sharing
-     */
-    RProperty iProgressProperty;
-
-    CUPnPPeriodic* iIdle;
-    
-    };
-
-#endif // __UPNPCONTENTSERVERHANDLER_H__
+/*
+* Copyright (c) 2006-2007 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:      The header of content server main scheduler class
+ *
+*/
+
+
+
+
+
+#ifndef __UPNPCONTENTSERVERHANDLER_H__
+#define __UPNPCONTENTSERVERHANDLER_H__
+
+// INCLUDES
+#include <e32base.h>
+#include <e32property.h>
+
+#include "upnpcontentserverdefs.h"
+#include "upnpcontentserverclient.h"
+#include "upnpcontentsharingobserver.h"
+#include "upnpsharingcallback.h"
+#include "upnpsharingrequest.h"
+#include "upnpmediaserverclient.h"
+#include "upnpcontentsharerao.h"
+
+// FORWARD DECLARATIONS
+class CUpnpSelectionReader;
+class CUpnpContentMetadataUtility;
+class CUpnpSharingRequest;
+class CUpnpContentServer;
+class CUpnpCdsLiteObjectArray;
+
+
+/**
+ * Helper class for storing pending request
+ */
+class TUpnpPendingSharingRequest
+    {
+public:
+
+    /**
+     * Kind of operation this information is related to
+     * images&videos or playlists
+     */
+    TInt iMediaType;
+
+    /**
+     * Array containing requested sharing items.
+     */
+    RArray<TInt> iMarkedItems;
+
+    };
+
+/**
+ *  A class to schedule the active objects in server
+ *
+ *  @since S60 3.1
+ */
+class CUpnpContentServerHandler : public CBase,
+                                  public MUpnpSharingCallback
+    {
+
+public:
+
+    /**
+     * 2-phased constructor.
+     */
+    static CUpnpContentServerHandler* NewL(
+        CUpnpContentServer* aServer );
+
+    /**
+     * Perform initialization of the handler
+     * @since S60 5.2
+     */
+    void InitializeL();
+
+    /**
+     * C++ destructor.
+     */
+    virtual ~CUpnpContentServerHandler();
+
+    /**
+     * Sets the observer to session class
+     * @since S60 3.1
+     * @param aObserver Pointer to observer in session class
+     */
+    void SetContentSharingObserverL( 
+        MUpnpContentSharingObserver* aObserver );
+
+    /**
+     * Start the media server upload listener, leave if error
+     * @since S60 3.1
+     */
+    void StartUploadListenerL();
+
+    /**
+     * Stop the media server upload listener, leave if error
+     * @since S60 3.1
+     */
+    void StopUploadListenerL();
+
+    /**
+     * Get the strings for the UI
+     * @since S60 3.1
+     * @param aContainerType Type of the content requested
+     */
+    void GetSelectionContentL( const TInt& aContainerType );
+
+    /**
+     * Get the selected items for the UI
+     * @since S60 3.1
+     * @param aMarkedItems Array of previous sharing selections
+     * @param aType Type of selections to request
+     */
+    void GetSelectionIndexesL( RArray<TInt>& aMarkedItems,
+                               const TInt aType );
+
+    /**
+     * Start sharing
+     * @since S60 3.1
+     * @param aMarkedItems The new sharing selections
+     * @param aType Type of sharing selections
+     */
+    void ChangeShareContentL( const RArray<TInt>& aMarkedItems,
+                              const TInt aType );
+
+    /**
+     * First read the selections then refresh.
+     * Leaves with KErrServerBusy if sharing is ongoing
+     * @since S60 3.1
+     * @param aType Type of refresh requested
+     */
+    void RefreshShareContentL(
+        TInt aType );
+
+    /**
+     * Determines if it is possible to stop the server
+     * @since S60 3.1
+     */
+    TBool CanStop() const;
+
+    /**
+     * Switch media server offline, change internal states accordingly
+     * @since S60 3.1
+     */
+    TBool ConnectionLostL();
+
+    // from MUpnpSharingCallback
+    //
+
+    /**
+     * The CUpnpContentSharingAo uses this to indicate it has done sharing
+     * @since S60 3.1
+     * @param aErr Error code
+     * @param aType Type of sharing completed
+     */
+    void CompleteSharingOperationL(
+        const TInt& aErr, const TInt& aType );
+    /**
+     * Cancel the current sharing operation
+     * @since S60 3.1
+     * @param aErr Error code
+     */
+    void CancelSharingOperationL(
+        const TInt& aErr );
+
+    /**
+     * Update the progress PubSub key
+     * @since S60 3.1
+     * @param aProgress Progress to update
+     */
+    void SetProgressL(
+        const TInt& aProgress );
+
+private:
+    /**
+     * C++ constructor.
+     * @since S60 3.1
+     */
+    CUpnpContentServerHandler( CUpnpContentServer* aServer );
+
+    /**
+     * The main sharing loop
+     * @since S60 5.2
+     */
+    void DoShare( );
+
+    /**
+     * Cleanup  resources, also state variables are cleaned
+     * @since S60 3.1
+     */
+    void Cleanup();
+
+    /**
+     * 2nd phase constructor.
+     * @since S60 3.1
+     */
+    void ConstructL();
+
+    /**
+     * Get id of the default container determined by aType
+     * @since S60 3.1
+     * @param aType Determines which container id is returned
+     */
+    TInt GetContainerId( const TInt aType ) const;
+
+    /**
+     * Set the values of the iImageVideoSharingReq or iMusicSharingReq
+     * depending of aType
+     * @since S60 3.1
+     * @param aMarkedItems The new sharing selections
+     * @param aType Type of sharing selections
+     * @param aPendingRequest Pending request or not
+     */
+    void SetSharingRequestL(
+        const RArray<TInt>& aMarkedItems,
+        const TInt aType );
+
+    /**
+     * Handle errors from active objects
+     * @since S60 3.1
+     * @param aError Error code
+     */
+    void HandleError( TInt aError );
+    
+    /**
+     * Get filenames of currently selected playlists/albums
+     * @since S60 5.2
+     * @param aMarkedItems The new sharing selections
+     * @param aType Type of sharing selections (EImageAndVideo 
+     * or EPlaylist)
+     * @param aSharingType Type of sharing (EShareNone, EShareAll,
+     * EShareMany)
+     * @param aFilenames Array containing filenames
+     * @param aClfIds Array containing collection ids
+     */
+    void GetSelectionFilenamesL( const RArray<TInt>& aMarkedItems,
+        const TInt aType,
+        const TInt aSharingType,
+        CDesCArray& aFilenames,
+        CDesCArray& aClfIds );
+
+    /**
+     * Get filenames of all image and video files
+     * @since S60 5.2
+     * @param aFilenames Array containing filenames
+     */
+    void GetAllImageAndVideoFilenamesL(
+        CDesCArray& aFilenames );
+
+    /**
+     * Get filenames of all music files
+     * @since S60 5.2
+     * @param aFilenames Array containing filenames
+     */
+    void GetAllMusicFilenamesL(
+        CDesCArray& aFilenames );
+
+    /**
+     * Get filenames of currently selected albums
+     * @since S60 5.2
+     * @param aMarkedItems The new sharing selections
+     * @param aFilenames Array containing filenames
+     * @param aClfIds Array containing collection ids
+     */
+    void GetSelectedImgAndVideoFilenamesL(
+        const RArray<TInt>& aMarkedItems,
+        CDesCArray& aFilenames,
+        CDesCArray& aClfIds );
+
+    /**
+     * Get filenames of currently selected playlists
+     * @since S60 5.2
+     * @param aMarkedItems The new sharing selections
+     * @param aFilenames Array containing filenames
+     * @param aClfIds Array containing playlist ids
+     */
+    void GetSelectedMusicFilenamesL(
+        const RArray<TInt>& aMarkedItems,
+        CDesCArray& aFilenames,
+        CDesCArray& aClfIds );
+    
+    /**
+     * Resolves files to be shared and unshared lists
+     * @since S60 5.2
+     * @param aClfFilePaths Array containing clf file paths
+     * @param aCdsObjects Array containing cds objects
+     * @param aToBeSharedFiles Array containing files to be shared
+     * @param aToBeUnsharedSharedFiles Array containing files to be unshared
+     * @param aType Type of sharing selections (EImageAndVideo 
+     * or EPlaylist
+     */
+    void CompareCdsToClfL( 
+        CDesCArray& aClfFilePaths, 
+        CUpnpCdsLiteObjectArray& aCdsObjects,
+        RArray<TFileName>& aToBeSharedFiles,
+        RArray<TFileName>& aToBeUnsharedSharedFiles,
+        const UpnpContentServer::TUpnpMediaType aType );
+    
+    /**
+     * Creates sharing request
+     * @since S60 5.2
+     * @param aType Type of sharing selections (EImageAndVideo 
+     * or EPlaylist)
+     * @param aSharingType Type of sharing (EShareNone, EShareAll,
+     * EShareMany)
+     */
+    void CreateSharingRequestL(
+        TInt aType, 
+        TInt aSharingType );
+
+    /**
+     * Sets sharing request information
+     * @since S60 5.2
+     * @param aType Type of sharing selections (EImageAndVideo 
+     * or EPlaylist)
+     * @param aShareArray Array containing filenames to be shared
+     * @param aUnshareArray Array containing filenames to be unshared
+     * @param aClfIds Array containing collection ids
+     */
+    void SetSharingRequestInfo(
+        TInt aType, 
+        RArray<TFileName>* aShareArray,
+        RArray<TFileName>* aUnshareArray,
+        CDesCArray* aClfIds );
+
+    /**
+     * Resets the pending request info
+     * @since S60 5.2
+     */
+    void ResetPendingRequestInfo();
+
+    /**
+     * Saves the pending request info
+     * @since S60 5.2
+     * @param aMarkedItems The new sharing selections
+     * @param aType Type of sharing selections (EImageAndVideo 
+     * or EPlaylist)
+     */
+    void SavePendingRequestInfoL(
+        const RArray<TInt>& aMarkedItems,
+        const TInt aType );
+        
+    /**
+     * Resolves the wanted sharing type based on the marked items
+     * @since S60 5.2
+     * @param aMarkedItems The new sharing selections
+     * @return  Sharing type (EShareNone, EShareAll, EShareMany)
+     */
+    TInt SharingType( const RArray<TInt>& aMarkedItems );
+    
+private:
+    /**
+     * Pointer to server process, used for stopping it
+     * Not owned
+     */
+    CUpnpContentServer* iServer;
+
+    /**
+     * Pointer to CLF interface
+     * owned
+     */
+    CUpnpContentMetadataUtility* iMetadata;
+
+    /**
+     * The sharing engine
+     * owned
+     */
+    CUpnpContentSharerAo* iAo;
+
+    /**
+     * Pointer to corresponding session observer for returning results
+     * not owned
+     */
+    MUpnpContentSharingObserver* iContentSharingObserver;
+
+    /**
+     * Gets the albums/playlists to UI
+     * owned
+     */
+    CUpnpSelectionReader* iReader;
+
+    /**
+     * Currently processed media type, KErrNotFound if no sharing 
+     * ongoing
+     */
+    TInt iOngoingSharingType;
+
+    /**
+     * The buffer for image and video sharing requests
+     * owned
+     */
+    CUpnpSharingRequest* iVisualSharingReq;
+
+    /**
+     * The buffer for music sharing requests
+     * owned
+     */
+    CUpnpSharingRequest* iMusicSharingReq;
+
+    /**
+     * The array for any sharing request which is not yet scheduled 
+     * to run.
+     */
+    TUpnpPendingSharingRequest iPendingSharingReqInfo;
+
+    /**
+     * MediaServer Handle
+     * Owned
+     */
+    RUpnpMediaServerClient* iMediaServer;
+
+    /**
+     * Error code, reset after transferred to client
+     */
+    TInt iErrorToClient;
+
+    /**
+     * The Publish subscribe key to deliver progress infromation about 
+     * sharing
+     */
+    RProperty iProgressProperty;
+
+    /**
+     * Sharing algorithm for handling sharing and unsharing operations
+     * Owned
+     */
+    MUpnpSharingAlgorithm* iSharingAlgorithm;
+    
+    };
+
+#endif // __UPNPCONTENTSERVERHANDLER_H__
+
+// End of file
--- a/upnpsharing/upnpcontentserver/inc/upnpselectionreader.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/inc/upnpselectionreader.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,260 +1,271 @@
-/*
-* Copyright (c) 2005-2007 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:      CUpnpSelectionReader class definition
- *
-*/
-
-
-
-
-
-
-#ifndef UPNPSELECTIONREADER_H
-#define UPNPSELECTIONREADER_H
-
-// INCLUDES
-
-#include "upnpcontentmetadatautility.h"
-#include "upnpcontentserverdefs.h"
-
-// FORWARD DECLARATIONS
-class CUpnpContentMetadataUtility;
-
-// CLASS DECLARATION
-
-/**
- * CUpnpSelectionReader class
- * Reads the selections user has made
- * @since S60 3.1
- */
-class CUpnpSelectionReader: public CBase
-    {
-public:
-    /**
-     * Two-phased constructor.
-     * @since S60 3.1
-     * @param aUtility Pointer to CLF interface
-     */
-    IMPORT_C static CUpnpSelectionReader* NewL(
-        CUpnpContentMetadataUtility* aUtility );
-
-    /**
-     * Destructor.
-     */
-    virtual ~CUpnpSelectionReader();
-
-    /**
-     * Fetch collections from Media Gallery
-     * @param aSettingsTextArray, The array of collection names
-     * @since S60 3.1
-     */
-    IMPORT_C void FetchCollectionsL( CDesCArray* aSettingsTextArray );
-
-    /**
-     * Fetch playlists from Media Gallery
-     * @param aSettingsTextArray, The array of playlist names
-     * @since S60 3.1
-     */
-    IMPORT_C void FetchPlaylistsL( CDesCArray* aSettingsTextArray );
-
-    /**
-     * Checks if item is alredy shared
-     * @param aItemName, Name of the item
-     * @param aIdArray, Array of Ids to search from
-     * @return TBool, True is shared, false otherwise
-     * @since S60 3.1
-     */
-    IMPORT_C TBool IsItemShared(const TDesC& aItemName,
-                                const CDesCArray& aIDArray ) const;
-
-    /**
-     * Gets the indexes of users previous selections relative to the available
-     * playlists or albums
-     * @since S60 3.1
-     * @param aSelections, Array of selections
-     * @param aType, Selections type needed
-     */
-    IMPORT_C void GetSelectionIndexesL(
-        RArray<TInt>& aSelections,
-        const TUpnpMediaType& aType );
-
-    /**
-     * Gets the sharing state of Images and videos
-     * @since S60 3.1
-     * @param aShareAllState, The variable to store the state
-     * @return Status of the operation
-     */
-    TInt GetVisualSharingStateL( TInt& aShareAllState );
-
-    /**
-     * Gets the sharing state of music
-     * @since S60 3.1
-     * @param aShareAllState, The variable to store the state
-     * @return Status of the operation
-     */
-    TInt GetMusicSharingStateL( TInt& aShareAllState );
-
-    /**
-     * Get the number of shared containers
-     * @since S60 3.1
-     * @return number of shared containers
-     */
-    TInt GetContainerCount() const;
-
-    /**
-     * Get the playlist ids
-     * @since S60 3.1
-     * @param aPlaylistIds Array containing the playlist ids
-     * @return error code
-     */
-    TInt PlayListIdsL( CDesCArray& aPlaylistIds,
-        CDesCArray& aPlaylistNames );
-
-    /**
-     * Get the collection ids
-     * @since S60 3.1
-     * @param aCollectionIds Array containing the collection ids
-     * @return error code
-     */
-    TInt CollectionIdsL( CDesCArray& aCollectionIds, 
-        CDesCArray& aCollectionNames );
-
-    /**
-     * Set the metadata utility pointer
-     * @since S60 3.1
-     * @param aMetaData Pointer to CUpnpContentMetadataUtility instance
-     */
-    void SetMetadata( CUpnpContentMetadataUtility*
-                      aMetaData );
-
-protected:  // New functions
-    /**
-     * Two-phased constructor.
-     * @since S60 3.1
-     * @param aUtility Pointer to CLF interface
-     */
-    void ConstructL(
-        CUpnpContentMetadataUtility* aUtility);
-
-    /**
-     * Searches playlist files
-     * @since S60 3.1
-     */
-    TBool SearchPlaylistFilesL();
-
-    /**
-     * Searches collections
-     * @since S60 3.1
-     */
-    TBool SearchCollectionsL();
-
-    /**
-     * Saves sharing state to central repository
-     * @since S60 3.1
-     * @return TInt, error code
-     */
-    TInt SaveSharingState();
-
-
-private:
-    /**
-     * C++ default constructor.
-     */
-    CUpnpSelectionReader();
-
-    /**
-     * Reads container IDs from file
-     * @since S60 3.1
-     * @param aArray, array where desciptors are read
-     * @param aContainerType, type of container
-     * @return TInt, error code
-     */
-    TInt ReadSharedContainerIDsL(
-        CDesCArray* aArray,
-        const TUpnpMediaType& aContainerType ) const;
-
-
-private: //data
-
-    /**
-     *  Mediatype selected from listbox
-     */
-    TUpnpMediaType                            iMediaType;
-
-    /**
-     * Pointer to CLF interface
-     * not owned
-     */
-    CUpnpContentMetadataUtility*         iMetadataUtility;
-
-    /**
-     * Selection value for images and videos
-     */
-    TInt iVisualSharingSelection;
-
-    /**
-     * Selection value for playlists
-     */
-    TInt iMusicSharingSelection;
-
-    /** 
-     * selected image and video indexes
-     * owned
-     */
-    RArray<TInt>*            iSelectedImages;
-
-    /**
-     * selected music indexes
-     * owned
-     */
-    RArray<TInt>*            iSelectedMusic;
-
-    /** 
-     * array for playlists
-     * owned
-     */
-    CDesCArrayFlat*                 iPlIdArray;
-
-    /** 
-     * array for collection Ids
-     * owned
-     */
-    CDesCArrayFlat*                 iCollIdArray;
-
-    /**
-     * array for image and video containers shown in ui
-     * owned
-     */
-    CDesCArrayFlat*                 iImageContainers;
-
-    /**
-     * array for playlists shown in ui
-     * owned
-     */
-    CDesCArrayFlat*                 iPlaylistNames;
-
-    /**
-     * array for collections shown in ui
-     * owned
-     */
-    CDesCArrayFlat* iCollectionNames;
-
-    /**
-     * number of ui items
-     */
-    TInt iContainerCount;
-
-    };
-#endif
-// End of File
+/*
+* Copyright (c) 2005-2007 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:      CUpnpSelectionReader class definition
+ *
+*/
+
+
+
+
+
+
+#ifndef UPNPSELECTIONREADER_H
+#define UPNPSELECTIONREADER_H
+
+// INCLUDES
+#include <badesca.h> 
+#include "upnpcontentserverdefs.h"
+
+using namespace UpnpContentServer;
+
+// CLASS DECLARATION
+
+/**
+ * CUpnpSelectionReader class
+ * Reads the selections user has made
+ * @since S60 3.1
+ */
+class CUpnpSelectionReader: public CBase
+    {
+public:
+    /**
+     * Two-phased constructor.
+     * @since S60 3.1
+     */
+    IMPORT_C static CUpnpSelectionReader* NewL();
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUpnpSelectionReader();
+
+    /**
+     * Fetch collections from Media Gallery
+     * @param aSettingsTextArray, The array of collection names
+     * @since S60 3.1
+     */
+    IMPORT_C void FetchCollectionsL( CDesCArray* aSettingsTextArray );
+
+    /**
+     * Fetch playlists from Media Gallery
+     * @param aSettingsTextArray, The array of playlist names
+     * @since S60 3.1
+     */
+    IMPORT_C void FetchPlaylistsL( CDesCArray* aSettingsTextArray );
+
+    /**
+     * Checks if item is alredy shared
+     * @param aItemName, Name of the item
+     * @param aIdArray, Array of Ids to search from
+     * @return TBool, True is shared, false otherwise
+     * @since S60 3.1
+     */
+    IMPORT_C TBool IsItemShared(const TDesC& aItemName,
+                                const CDesCArray& aIDArray ) const;
+
+    /**
+     * Gets the indexes of users previous selections relative to the available
+     * playlists or albums
+     * @since S60 3.1
+     * @param aSelections, Array of selections
+     * @param aType, Selections type needed
+     */
+    IMPORT_C void GetSelectionIndexesL(
+        RArray<TInt>& aSelections,
+        const TUpnpMediaType& aType );
+
+    /**
+     * Gets the sharing state of Images and videos
+     * @since S60 3.1
+     * @param aShareAllState, The variable to store the state
+     * @return Status of the operation
+     */
+    TInt GetVisualSharingStateL( TInt& aShareAllState );
+
+    /**
+     * Gets the sharing state of music
+     * @since S60 3.1
+     * @param aShareAllState, The variable to store the state
+     * @return Status of the operation
+     */
+    TInt GetMusicSharingStateL( TInt& aShareAllState );
+
+    /**
+     * Get the number of shared containers
+     * @since S60 3.1
+     * @return number of shared containers
+     */
+    TInt GetContainerCount() const;
+
+    /**
+     * Get the playlist ids
+     * @since S60 3.1
+     * @param aPlaylistIds Array containing the playlist ids
+     * @return error code
+     */
+    TInt PlayListIdsL( CDesCArray& aPlaylistIds,
+        CDesCArray& aPlaylistNames );
+
+    /**
+     * Get the collection ids
+     * @since S60 3.1
+     * @param aCollectionIds Array containing the collection ids
+     * @return error code
+     */
+    TInt CollectionIdsL( CDesCArray& aCollectionIds, 
+        CDesCArray& aCollectionNames );
+
+    /**
+     * Get the collection content. Filenames includes also path.
+     * @since S60 5.2
+     * @param aSelectionIndex Selected index
+     * @param aFilenames Array containing filenames of the collection
+     * @return Collection id (if not found, empty string is returned)
+     */
+    TPtrC GetCollectionItemsL( const TInt aSelectionIndex, 
+        CDesCArray& aFilenames );
+    /**
+     * Get the playlist content. Filenames includes also path.
+     * @since S60 5.2
+     * @param aSelectionIndex Selected index
+     * @param aFilenames Array containing filenames of the playlist
+     * @return Playlist id (if not found, empty string is returned)
+     */
+    TPtrC GetPlaylistItemsL( const TInt aSelectionIndex, 
+        CDesCArray& aFilenames );
+
+    /**
+     * Get the playlist content. Filenames includes also path.
+     * @since S60 5.2
+     * @param aType Mediatype (EImageAndVideo or EPlaylist)
+     * @param aClfId Album/Playlist id in the clf structure
+     * @return Selection index (if not found, KErrNotFound is returned)
+     */
+    TInt GetSelectionIndexL( const TUpnpMediaType& aType,
+            TPtrC aClfId );
+
+protected:  // New functions
+    /**
+     * Two-phased constructor.
+     * @since S60 3.1
+     */
+    void ConstructL();
+
+    /**
+     * Searches playlist files
+     * @since S60 3.1
+     */
+    TBool SearchPlaylistFilesL();
+
+    /**
+     * Searches collections
+     * @since S60 3.1
+     */
+    TBool SearchCollectionsL();
+
+    /**
+     * Saves sharing state to central repository
+     * @since S60 3.1
+     * @return TInt, error code
+     */
+    TInt SaveSharingState();
+
+
+private:
+    /**
+     * C++ default constructor.
+     */
+    CUpnpSelectionReader();
+
+    /**
+     * Reads container IDs from file
+     * @since S60 3.1
+     * @param aArray, array where desciptors are read
+     * @param aContainerType, type of container
+     * @return TInt, error code
+     */
+    TInt ReadSharedContainerIDsL(
+        CDesCArray* aArray,
+        const TUpnpMediaType& aContainerType ) const;
+
+
+private: //data
+
+    /**
+     *  Mediatype selected from listbox
+     */
+    TUpnpMediaType iMediaType;
+
+    /**
+     * Selection value for images and videos
+     */
+    TInt iVisualSharingSelection;
+
+    /**
+     * Selection value for playlists
+     */
+    TInt iMusicSharingSelection;
+
+    /** 
+     * selected image and video indexes
+     * owned
+     */
+    RArray<TInt>* iSelectedImages;
+
+    /**
+     * selected music indexes
+     * owned
+     */
+    RArray<TInt>* iSelectedMusic;
+
+    /** 
+     * array for playlists
+     * owned
+     */
+    CDesCArrayFlat* iPlIdArray;
+
+    /** 
+     * array for collection Ids
+     * owned
+     */
+    CDesCArrayFlat* iCollIdArray;
+
+    /**
+     * array for image and video containers shown in ui
+     * owned
+     */
+    CDesCArrayFlat* iImageContainers;
+
+    /**
+     * array for playlists shown in ui
+     * owned
+     */
+    CDesCArrayFlat* iPlaylistNames;
+
+    /**
+     * array for collections shown in ui
+     * owned
+     */
+    CDesCArrayFlat* iCollectionNames;
+
+    /**
+     * number of ui items
+     */
+    TInt iContainerCount;
+
+    };
+
+#endif // UPNPSELECTIONREADER_H
+
+// End of File
--- a/upnpsharing/upnpcontentserver/inc/upnpselectionwriter.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/inc/upnpselectionwriter.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,130 +1,118 @@
-/*
-* Copyright (c) 2005-2007 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:      CUpnpSelectionWriter class definition
- *
-*/
-
-
-
-
-
-
-#ifndef UPNPSELECTIONWRITER_H
-#define UPNPSELECTIONWRITER_H
-
-// INCLUDES
-
-#include <badesca.h>    // for CDesCArray
-#include <centralrepository.h>
-#include "upnpcontentserverdefs.h"
-
-
-using namespace UpnpContentServer;
-
-// CLASS DECLARATION
-
-/**
- * CUpnpSelectionWriter utility class
- * @since S60 3.1
- */
-class CUpnpSelectionWriter: public CBase
-    {
-public: // Constructors and destructor
-    /**
-     * Two-phased constructor.
-     * @since S60 3.1
-     * @param aMediaType Type of selections currently active
-     */
-    static CUpnpSelectionWriter* NewL(
-        TUpnpMediaType aMediaType );
-
-    /**
-     * Destructor.
-     */
-    virtual ~CUpnpSelectionWriter();
-
-    /**
-     * Append identifier of the container which is shared next
-     * @since S60 3.1
-     * @param aNewObject, name of the object
-     */
-    void AppendItemL( const TPtrC aNewObject );
-
-    /**
-     * Append index of succesfully shared container
-     * @since S60 3.1
-     * @param aIndex, Index of the container
-     */
-    void AppendStatusL( const TInt aIndex );
-
-    /**
-     * Saves sharing state to central repository and updates shared albums
-     * @since S60 3.1
-     * @param aShareAllSelection, The selections type in UI( Share all \
-/ None / Many )
-     * @return TInt, error code
-     */
-    TInt SaveSharingStateL( TInt aShareAllSelection );
-
-private:  // New functions
-    /**
-     * 2nd phase constructor.
-     * @since S60 3.1
-     * @param aMediaType Type of selections currently active
-     */
-    void ConstructL( TUpnpMediaType aMediaType );
-
-    /**
-     * Save the containers to file
-     * @since S60 3.1
-     */
-    TInt StoreSharedContainerIDsL() const;
-
-    /**
-     * C++ default constructor.
-     * @since S60 3.1
-     */
-    CUpnpSelectionWriter();
-
-private: //data
-    /**
-     * Mediatype selected from listbox
-     */
-    TInt                            iMediaType;
-
-    /**
-     * selection type
-     */
-    TInt                            iShareAllSelection;
-
-    /**
-     * array of succesfully shared containers.
-     */
-    RArray<TInt>           iOkItems;
-
-    /**
-     * array for albums/playlist
-     * owned
-     */
-    CDesCArrayFlat*                 iFileArray;
-
-    /**
-     * Pointer to Central repository
-     * owned
-     */
-    CRepository*                    iRepository;
-    };
-
-#endif
-// End of File
+/*
+* Copyright (c) 2005-2007 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:      CUpnpSelectionWriter class definition
+ *
+*/
+
+
+
+
+
+
+#ifndef UPNPSELECTIONWRITER_H
+#define UPNPSELECTIONWRITER_H
+
+// INCLUDES
+
+#include <badesca.h>    // for CDesCArray
+#include <centralrepository.h>
+#include "upnpcontentserverdefs.h"
+
+
+using namespace UpnpContentServer;
+
+// CLASS DECLARATION
+
+/**
+ * CUpnpSelectionWriter utility class
+ * @since S60 3.1
+ */
+class CUpnpSelectionWriter: public CBase
+    {
+public: // Constructors and destructor
+    /**
+     * Two-phased constructor.
+     * @since S60 3.1
+     * @param aMediaType Type of selections currently active
+     */
+    static CUpnpSelectionWriter* NewL(
+        TUpnpMediaType aMediaType );
+
+    /**
+     * Destructor.
+     */
+    virtual ~CUpnpSelectionWriter();
+
+    /**
+     * Append identifier of the container which is shared next
+     * @since S60 3.1
+     * @param aNewObject, name of the object
+     */
+    void AppendItemL( const TPtrC aNewObject );
+
+    /**
+     * Saves sharing state to central repository and updates shared albums
+     * @since S60 3.1
+     * @param aShareAllSelection, The selections type in UI( Share all \
+/ None / Many )
+     * @return TInt, error code
+     */
+    TInt SaveSharingStateL( TInt aShareAllSelection );
+
+private:  // New functions
+    /**
+     * 2nd phase constructor.
+     * @since S60 3.1
+     * @param aMediaType Type of selections currently active
+     */
+    void ConstructL( TUpnpMediaType aMediaType );
+
+    /**
+     * Save the containers to file
+     * @since S60 3.1
+     */
+    TInt StoreSharedContainerIDsL() const;
+
+    /**
+     * C++ default constructor.
+     * @since S60 3.1
+     */
+    CUpnpSelectionWriter();
+
+private: //data
+    /**
+     * Mediatype selected from listbox
+     */
+    TInt                            iMediaType;
+
+    /**
+     * selection type
+     */
+    TInt                            iShareAllSelection;
+
+    /**
+     * array for albums/playlist
+     * owned
+     */
+    CDesCArrayFlat*                 iFileArray;
+
+    /**
+     * Pointer to Central repository
+     * owned
+     */
+    CRepository*                    iRepository;
+    };
+
+#endif
+// End of File
--- a/upnpsharing/upnpcontentserver/inc/upnpsharingcallback.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/inc/upnpsharingcallback.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,80 +1,81 @@
-/*
-* Copyright (c) 2006-2007 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:      Callback for filesharing related async operations
-*
-*/
-
-
-
-
-
-
-#ifndef __UPNPSHARINGCALLBACK_H__
-#define __UPNPSHARINGCALLBACK_H__
-
-// INCLUDE FILES
-#include <e32base.h>
-#include <badesca.h>
-
-
-/**
- * Callback class for informing about completion of unsharing, sharing and
- * container checking.
- * @since S60 3.1
- */
-class MUpnpSharingCallback
-    {
-public:
-    /**
-     * Enumeration for stop type
-     */
-    enum TSharingStopType
-        {
-        ESharingNoStop,
-        ESharingFullStop,
-        ESharingPause
-        };
-
-    /**
-     * Completes the asynchronous sharing / unsharing / container checking
-     * Normal completion
-     * @since S60 3.1
-     */
-    virtual void CompleteSharingOperationL(
-        const TInt& aErr, const TInt& aType ) = 0;
-
-    /**
-     * Completes the asynchronous sharing / unsharing / container checking
-     * Error/cancel situation
-     * @since S60 3.1
-     */
-    virtual void CancelSharingOperationL(
-        const TInt& aErr ) = 0;
-
-    /**
-     * Sets the progress of operation
-     * @since S60 3.1
-     */
-    virtual void SetProgressL(
-        const TInt& aProgress ) = 0;
-
-    /**
-     * Virtual destructor
-     */
-    virtual ~MUpnpSharingCallback() {};
-    };
-
-#endif //__UPNPSHARINGCALLBACK_H__
-
-// End of File
+/*
+* Copyright (c) 2006-2007 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:      Callback for filesharing related async operations
+*
+*/
+
+
+
+
+
+
+#ifndef __UPNPSHARINGCALLBACK_H__
+#define __UPNPSHARINGCALLBACK_H__
+
+// INCLUDE FILES
+#include <e32base.h>
+#include <badesca.h>
+
+#include "upnpcontentserverdefs.h"
+
+/**
+ * Callback class for informing about completion of unsharing, sharing and
+ * container checking.
+ * @since S60 3.1
+ */
+class MUpnpSharingCallback
+    {
+public:
+    /**
+     * Enumeration for stop type
+     */
+    enum TSharingStopType
+        {
+        ESharingNoStop,
+        ESharingFullStop,
+        ESharingPause
+        };
+
+    /**
+     * Completes the asynchronous sharing / unsharing / container checking
+     * Normal completion
+     * @since S60 3.1
+     */
+    virtual void CompleteSharingOperationL(
+        const TInt& aErr, const TInt& aType ) = 0;
+
+    /**
+     * Completes the asynchronous sharing / unsharing / container checking
+     * Error/cancel situation
+     * @since S60 3.1
+     */
+    virtual void CancelSharingOperationL(
+        const TInt& aErr ) = 0;
+
+    /**
+     * Sets the progress of operation
+     * @since S60 3.1
+     */
+    virtual void SetProgressL(
+        const TInt& aProgress ) = 0;
+
+    /**
+     * Virtual destructor
+     */
+    virtual ~MUpnpSharingCallback() {};
+    };
+
+#endif //__UPNPSHARINGCALLBACK_H__
+
+// End of File
--- a/upnpsharing/upnpcontentserver/inc/upnpsharingrequest.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/inc/upnpsharingrequest.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,108 +1,129 @@
-/*
-* Copyright (c) 2006-2007 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:      CUpnpSharingRequest class definition
- *
-*/
-
-
-
-
-
-#ifndef __UPNPSHARINGREQUEST_H__
-#define __UPNPSHARINGREQUEST_H__
-
-// Include Files
-#include <e32base.h>
-#include <e32def.h> //CArrayFix
-#include <badesca.h> //CDesCArray
-
-
-/**
- * Helper class to store information about ongoing/pending sharing request
- * @since S60 3.1
- */
-class CUpnpSharingRequest : public CBase
-    {
-public :
-
-    /**
-     * 2 phased contructor
-     * @since S60 3.1
-     * @param aKind Type of sharing request( images&videos or music )
-     * @param aArr Indexes of selection relative to albums or playlists
-     * @param aNameArray Names of containers to share
-     */
-    static CUpnpSharingRequest* NewL(
-        TInt aKind,
-        const RArray<TInt>& aArr,
-        CDesCArray* aIdArray = NULL,
-        CDesCArray* aNameArray = NULL );
-
-    /**
-     * 2nd phase constructor.
-     * @since S60 3.1
-     * @param aArr Indexes of selection relative to albums or playlists
-     * @param aNameArray Names of containers to share
-     */
-    void ConstructL( const RArray<TInt>& aArr,
-                    CDesCArray* aIdArray,
-                    CDesCArray* aNameArray );
-
-    /**
-     * Constructor
-     * @since S60 3.1
-     * @param aKind Type of sharing request( images&videos or music )
-     */
-    CUpnpSharingRequest( TInt aKind );
-
-    /**
-     * Destructor
-     */
-    virtual ~CUpnpSharingRequest();
-
-public :
-    /**
-     * Determines the type of sharing:
-     * images&videos or music
-     */
-    TInt iKind;
-
-    /**
-     * The number of items in selection
-     */
-    TInt iItemCount;
-
-    /**
-     * The progress of sharing if it is ongoing
-     */
-    TInt iProgress;
-
-    /**
-     * Selections for the sharing request
-     */
-    RArray<TInt> iSelections;
-
-    /**
-     * Array for object IDs
-     */
-    CDesCArray* iObjectIds;
-    
-    /**
-     * Array for object names
-     */
-    CDesCArray* iObjectNames;
-    };
-
-
-#endif // __UPNPSHARINGREQUEST_H__
+/*
+* Copyright (c) 2006-2007 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:      CUpnpSharingRequest class definition
+ *
+*/
+
+
+
+
+
+#ifndef __UPNPSHARINGREQUEST_H__
+#define __UPNPSHARINGREQUEST_H__
+
+// Include Files
+#include <e32base.h>
+#include <badesca.h>
+
+#include "upnpcontentserverdefs.h" //TUpnpMediaType
+
+/**
+ * Helper class to store information about ongoing/pending sharing request
+ * @since S60 3.1
+ */
+class CUpnpSharingRequest : public CBase
+    {
+public :
+
+    /**
+     * 2 phased contructor
+     * @since S60 5.2
+     * @param aMediaType Type of sharing request (EImageAndVideo or EPlaylist)
+     * @param aSharingType Type of sharing request (EShareNone, EShareAll, 
+     *         EShareMany)
+     */
+    static CUpnpSharingRequest* NewL( 
+            UpnpContentServer::TUpnpMediaType aMediaType, 
+            TInt aSharingType );
+
+    /**
+     * Sets the share, unshare and clfids arrays
+     * @since S60 5.2
+     * @param aShareArr Files to be shared
+     * @param aUnshareArr Files to be unshared
+     * @param aClfIds Indexes of selection relative to albums or playlists
+     */
+    void SetSharingRequestInfo( 
+            RArray<TFileName>* aShareArr,
+            RArray<TFileName>* aUnshareArr,
+            CDesCArray* aClfIds );
+
+    /**
+     * Destructor
+     */
+    virtual ~CUpnpSharingRequest();
+
+private:
+
+    /**
+     * 2nd phase constructor.
+     * @since S60 5.2
+     */
+    void ConstructL() {};
+
+    /**
+     * Constructor
+     * @since S60 5.2
+     * @param aMediaType Type of sharing request (EImageAndVideo or EPlaylist)
+     * @param aSharingType Type of sharing request (EShareNone, EShareAll, 
+     *         EShareMany)
+     */
+    CUpnpSharingRequest( 
+            UpnpContentServer::TUpnpMediaType aMediaType,
+            TInt aSharingType );
+
+public :
+// (These member variables are used without getters or setters in 
+// contentserver, which is why they are public. CUpnpSharingRequest is
+// only a data storage)
+
+    /**
+     * Determines the type of sharing:
+     * images&videos or music
+     */
+    UpnpContentServer::TUpnpMediaType iMediaType;
+
+    /**
+     * Type of sharing request( EShareNone, EShareAll, EShareMany )
+     */
+    TInt iSharingType;
+
+    /**
+     * The progress of sharing if it is ongoing
+     */
+    TInt iProgress;
+
+    /**
+     * Files to be shared
+     * owned
+     */
+    RArray<TFileName>* iShareArr;
+      
+    /**
+     * Files to be unshared
+     * owned
+     */
+    RArray<TFileName>* iUnshareArr;   
+  
+    /**
+     * Ids of selection relative to albums or playlists
+     * owned
+     */
+    CDesCArray* iClfIds;
+  
+    };
+
+#endif // __UPNPSHARINGREQUEST_H__
+
+// End of file
--- a/upnpsharing/upnpcontentserver/src/upnpcontentmetadatautility.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/src/upnpcontentmetadatautility.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,727 +1,275 @@
-/*
-* Copyright (c) 2006-2007 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:      CUpnpContentMetadataUtility class implementation
- *
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-// System
-#include <e32base.h>
-#include <MCLFContentListingEngine.h>
-#include <ContentListingFactory.h>
-#include <MCLFItemListModel.h>
-#include <CLFContentListing.hrh>
-#include <MCLFItem.h>
-#include <f32file.h>
-
-// upnp stack api
-#include <upnpitem.h>
-#include <upnpcontainer.h>
-#include <upnpstring.h>
-
-// upnpframework / avcontroller helper api
-#include "upnpfileutility.h"
-
-// upnpframework / internal api's
-#include "upnpcommonutils.h"
-#include "upnpmetadatautility.h"
-
-#include "upnpdlnaprofiler.h"
-#include "upnpcdsreselementutility.h"
-
-// homeconnect internal
-#include "upnpcontentmetadatautility.h"
-#include "upnpcustomgrouper.h"
-#include "upnppostfilter.h"
-
-#include "upnpcontentserverdefs.h"
-
-_LIT( KComponentLogfile, "contentserver.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-_LIT( KUPnPFileListSeparator, "\t" );
-const TInt KMediaTypeArrGranularity(1);
-
-using namespace UpnpContentServer;
-
-// ============================ MEMBER FUNCTIONS ============================
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::CUpnpContentMetadataUtility()
-// Default constructor
-// --------------------------------------------------------------------------
-//
-CUpnpContentMetadataUtility::CUpnpContentMetadataUtility()
-    : iRefreshOngoing( ETrue )
-    {
-    }
-
-void CUpnpContentMetadataUtility::ConstructL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    // Create Content Listing Engine and a list model
-    iEngine = ContentListingFactory::NewContentListingEngineLC();
-    CleanupStack::Pop();   // iEngine
-    iMusicModel = iEngine->CreateListModelLC( *this );
-    CleanupStack::Pop();    // iMusicModel
-
-    iImageModel = iEngine->CreateListModelLC( *this );
-    CleanupStack::Pop();    // iImageModel
-
-    iVideoModel = iEngine->CreateListModelLC( *this );
-    CleanupStack::Pop();    // iVideoModel
-
-    iCollectionModel = iEngine->CreateListModelLC( *this );
-    CleanupStack::Pop();    // iCollectionModel
-    // Set music media type filter to CLF
-    RArray<TInt> musicArray( KMediaTypeArrGranularity );
-
-    CleanupClosePushL( musicArray );
-    musicArray.AppendL( ECLFMediaTypeMusic );
-    iMusicModel->SetWantedMediaTypesL( musicArray.Array() );
-    CleanupStack::PopAndDestroy( &musicArray );
-
-    // Set image media type filter to CLF
-    RArray<TInt> imageArray( KMediaTypeArrGranularity );
-
-    CleanupClosePushL( imageArray );
-    imageArray.AppendL( ECLFMediaTypeImage );
-    iImageModel->SetWantedMediaTypesL( imageArray.Array() );
-    CleanupStack::PopAndDestroy( &imageArray );
-
-    // Set video media type filter to CLF
-    RArray<TInt> videoArray( KMediaTypeArrGranularity );
-    CleanupClosePushL( videoArray );
-    videoArray.AppendL( ECLFMediaTypeVideo );
-    iVideoModel->SetWantedMediaTypesL( videoArray.Array() );
-    CleanupStack::PopAndDestroy( &videoArray );
-
-    // Set Collection media type filter to CLF
-    RArray<TInt> collectionArray( KMediaTypeArrGranularity );
-
-    CleanupClosePushL( collectionArray );
-    collectionArray.AppendL( ECLFMediaTypeCollection );
-    iCollectionModel->SetWantedMediaTypesL( collectionArray.Array() );
-    CleanupStack::PopAndDestroy( &collectionArray );
-
-    // Group items by collection name
-    iCustomGrouper = CUpnpCustomGrouper::NewL( ECLFFieldIdCollectionName );
-    iCollectionModel->SetCustomGrouper( iCustomGrouper );
-
-    // Start to refresh the music files (HandleOperationEventL
-    // callback comes when finished)
-    iMusicModel->RefreshL();
-    
-    // Create metadata utility
-    iMetaDataUtility = CUPnPMetaDataUtility::NewL();
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::NewL()
-// 2 phased constructor
-// --------------------------------------------------------------------------
-//
-CUpnpContentMetadataUtility* CUpnpContentMetadataUtility::NewL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CUpnpContentMetadataUtility* self
-        = new( ELeave ) CUpnpContentMetadataUtility;
-
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    CleanupStack::Pop();
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::~CUpnpContentMetadataUtility()
-// Default destructor
-// --------------------------------------------------------------------------
-//
-CUpnpContentMetadataUtility::~CUpnpContentMetadataUtility()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    delete iMusicModel;
-    delete iImageModel;
-    delete iVideoModel;
-    delete iCollectionModel;
-    delete iPostFilter;
-    delete iCustomGrouper;
-    delete iEngine;
-    delete iMetaDataUtility;
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::HandleOperationEventL
-// Callback implementation for MCLFOperationObserver
-// --------------------------------------------------------------------------
-//
-void CUpnpContentMetadataUtility::HandleOperationEventL(
-    TCLFOperationEvent aOperationEvent,
-    TInt /*aError*/ )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    // Waiting is stopped when an event for refresh completion is received
-    if( aOperationEvent == ECLFRefreshComplete )
-
-        {
-        switch ( iRefreshCounter )
-            {
-        case 0 :
-            {
-            iVideoModel->RefreshL();
-            break;
-            }
-        case 1 :
-            {
-            iImageModel->RefreshL();
-            break;
-            }
-        case 2 :
-            {
-            iCollectionModel->RefreshL();
-            break;
-            }
-        case 3 :
-            {
-
-            iRefreshOngoing = EFalse;
-            iRefreshCounter = 0;
-            if ( iHandler )
-                {
-                iHandler->RefreshDoneL();
-                }
-            __LOG("CUpnpContentMetadataUtility::HandleOperationEventL: \
-Refresh done");
-            break;
-
-            }
-        default :
-            {
-            __LOG("CUpnpContentMetadataUtility::HandleOperationEventL: \
-default: error");
-            break;
-            }
-
-            }
-        if ( iRefreshOngoing )
-            {
-            iRefreshCounter++;
-            }
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::HandleItemChangeL
-// CLF content is changed --> model needs to be refreshed
-// --------------------------------------------------------------------------
-//
-void CUpnpContentMetadataUtility::HandleItemChangeL(
-    const TArray<TCLFItemId>& /*aItemIDArray*/ )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    // Start to refresh the music files (HandleOperationEventL
-    // callback comes when finished)
-    iRefreshOngoing = ETrue;
-    iMusicModel->RefreshL();
-    iImageModel->RefreshL();
-    iVideoModel->RefreshL();
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::HandleError
-// Method is used to handle errors in changed item event.
-// --------------------------------------------------------------------------
-//
-void CUpnpContentMetadataUtility::HandleError( TInt /*aError*/ )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::MusicFiles
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-const MCLFItemListModel& CUpnpContentMetadataUtility::MusicFiles() const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    return *iMusicModel;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::ImageFiles
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-const MCLFItemListModel& CUpnpContentMetadataUtility::ImageFiles() const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    return *iImageModel;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::VideoFiles
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-const MCLFItemListModel& CUpnpContentMetadataUtility::VideoFiles() const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    return *iVideoModel;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::Collections
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-const MCLFItemListModel& CUpnpContentMetadataUtility::Collections() const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    return *iCollectionModel;
-    }
-
-
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::GetCollectionFileNamesL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentMetadataUtility::GetCollectionFileNamesL( 
-    CDesCArray& aFileArray,
-    const TDesC& aFiles ) const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    TInt collectionLength( aFiles.Length() );
-    TInt position( 0 );
-    TInt dataPos( 0 );
-    do
-        {
-        // Put filenames from ":" separeted row to aFileArray
-        TPtrC data( aFiles.Right( collectionLength - position ) );
-        dataPos = data.Find( KUPnPFileListSeparator );
-        if( dataPos > 0 )
-            {
-            ++position; // skip KUPnPFileListSeparator
-            position += dataPos;
-            aFileArray.AppendL( data.Left( dataPos ) );
-            }
-        } while ( dataPos > 0 );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::CollectionItemsL()
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentMetadataUtility::CollectionItemsL( 
-    const TDesC& aNameOfCollection )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    __LOG1( "CUpnpContentMetadataUtility: collection: %S",
-                  &aNameOfCollection );
-
-    //clear previous filtering
-    iCollectionModel->SetPostFilter( NULL );
-
-    // Delete old post filter if any
-
-    delete iPostFilter;
-    iPostFilter = NULL;
-
-    // Create and activate a post filter for collection filtering
-    // so that the model will contain only files
-    // from selected collection
-    iPostFilter = CUpnpPostFilter::NewL( ECLFFieldIdCollectionName,
-                                            aNameOfCollection, EFalse );
-    iCollectionModel->SetPostFilter( iPostFilter );
-
-    iCollectionModel->RefreshL( ECLFRefreshPostFilter );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::CreateItemL
-// Create the item with mandatory fields
-// --------------------------------------------------------------------------
-//
-CUpnpItem* CUpnpContentMetadataUtility::CreateItemL(
-    const MCLFItem& aCLFItem,
-    const TDesC8& aParentId ) const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    TPtrC fullFileName;
-    TInt err( aCLFItem.GetField( ECLFFieldIdFileNameAndPath,
-                                 fullFileName ));
-    
-    TInt32 filesize( 0 );
-    TInt err1( aCLFItem.GetField( ECLFFieldIdFileSize, filesize ) );    
- 
-    CUpnpItem* newItem( NULL );
-    
-    if ( !err && !err1 && filesize )
-        {
-        newItem = CreateItemL( fullFileName, aParentId );
-        }
-    else
-        {
-        __LOG8_1( "MCLFItem ECLFFieldIdFileNameAndPath err= %d", err );
-        __LOG8_1( "MCLFItem ECLFFieldIdFileSize err= %d", err1 );
-        }
-    
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return newItem;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::CreateItemL
-// Update the basic fields, based on list of filenames
-// --------------------------------------------------------------------------
-//
-CUpnpItem* CUpnpContentMetadataUtility::CreateItemL(
-    const TDesC& aFullFilename,
-    const TDesC8& aParentId
-    ) const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    CUpnpItem* newItem( NULL );
-    
-    TFileName path( aFullFilename );
-    TBool isProtected( EFalse );
-    TRAPD( err, 
-           isProtected = UPnPFileUtility::IsFileProtectedL( path ) );
-
-    if ( !isProtected && !err )
-        {
-        // title
-        HBufC8* itemName( NULL );
-        iMetaDataUtility->LoadTitleL( path );
-        if( iMetaDataUtility->Title().Length() > 0 )
-            {
-            itemName = UpnpString::FromUnicodeL( 
-                    iMetaDataUtility->Title() );
-            }
-        else
-            {
-            // If does not find the title, using filename instead
-            TParse fileParser;
-            fileParser.Set( path, NULL, NULL );
-            itemName = UpnpString::FromUnicodeL( fileParser.Name() );
-            }
-        
-        if ( itemName )
-            {
-            CleanupStack::PushL( itemName );
-            
-            newItem = CUpnpItem::NewL();
-            CleanupStack::PushL( newItem );            
-            newItem->SetTitleL( *itemName );            
-            newItem->SetObjectClassL( KClassItem );
-            newItem->SetParentIdL( aParentId );
-            CleanupStack::Pop( newItem );
-
-            CleanupStack::PopAndDestroy( itemName );
-            }
-        }
-    else
-        {
-        __LOG8_1( "UPnPFileUtility::IsFileProtectedL err= %d", err );
-        }
-    
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return newItem;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::RefreshOngoing() const
-// Used to check if refresh is ongoing.
-// --------------------------------------------------------------------------
-//
-
-TBool CUpnpContentMetadataUtility::RefreshOngoing() const
-    {
-    return iRefreshOngoing;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::UpdateMetaDataL
-// Updates meta data for the item
-// --------------------------------------------------------------------------
-//
-TBool CUpnpContentMetadataUtility::UpdateMetadataL(
-    const TUpnpMediaType& aMediaType, 
-    CUpnpItem* aItem, 
-    const TDesC& aFileName )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    // 1st use correct model according to item type
-    MCLFItemListModel* model = NULL;
-    switch( aMediaType )
-        {
-    case EMusicFile :
-        {
-        model = iMusicModel;
-        break;
-        }
-    case EVideoFile :
-        {
-        model = iVideoModel;
-        break;
-        }
-    case EPhotoFile :
-        {
-        model = iImageModel;
-        break;
-        }
-    default:
-        {
-        break;
-        }
-        }
-    // Then find the CLF item and update data from it
-    TBool found = EFalse;
-    TBool end = EFalse;
-    TInt beginLoop = iClfIndex;
-
-    // increment. If passed item count, start from beginning.
-        iClfIndex = 0;
-        beginLoop = -1;
-
-    while ( model->ItemCount() && 
-            !found && 
-            !end )
-        {
-        // Get the item
-        const MCLFItem& myItem = model->Item( iClfIndex );
-        TPtrC fileName;
-        TInt error = myItem.GetField( ECLFFieldIdFileNameAndPath,
-                                      fileName );
-
-        // if there was no error and file name matched
-        if ( !error && aFileName.CompareF( fileName ) == 0 )
-            {
-            found = ETrue;
-
-            // Get the mediatype
-            TInt32 mediaType;
-            TInt errorType = myItem.GetField( ECLFFieldIdMediaType,
-                                              mediaType );
-            // If it is music file, fill the meta data for it
-            if ( !errorType && mediaType == ECLFMediaTypeMusic )
-                {
-                // Get title, artist, album & genre tag info of the item
-                // Test update the class as it is in 1.x
-                aItem->SetObjectClassL( 
-                    KClassAudioMusicTrack );
-
-                TPtrC songArtist;
-                TInt errorArtist( myItem.GetField( ECLFFieldIdArtist,
-                                                   songArtist ) );
-                if ( !errorArtist )
-                    {
-                    CUpnpElement* elArtist = CUpnpElement::NewL( 
-                        KElementArtist );
-                    CleanupStack::PushL( elArtist );
-                    HBufC8* artist = UpnpString::FromUnicodeL( 
-                        songArtist );
-                    CleanupStack::PushL( artist );
-                    elArtist->SetValueL( *artist );
-                    // UPnP stack needs filepath
-                    elArtist->SetFilePathL( aFileName );
-                    CleanupStack::PopAndDestroy( artist );
-                    aItem->AddElementL( elArtist ); // transfer own..
-                    CleanupStack::Pop( elArtist );
-                    }
-                TPtrC songAlbum;
-                TInt errorAlbum( myItem.GetField( ECLFFieldIdAlbum,
-                                                  songAlbum ) );
-                if ( !errorAlbum )
-                    {
-                    CUpnpElement* elAlbum = CUpnpElement::NewL( 
-                        KElementAlbum );
-                    CleanupStack::PushL( elAlbum );
-                    HBufC8* album = UpnpString::FromUnicodeL( songAlbum );
-
-                    CleanupStack::PushL( album );
-                    elAlbum->SetValueL( *album );
-                    // UPnP stack needs filepath
-                    elAlbum->SetFilePathL( aFileName );
-                    CleanupStack::PopAndDestroy( album );
-                    aItem->AddElementL( elAlbum ); // transfer own..
-                    CleanupStack::Pop( elAlbum );
-                    }
-                TPtrC songGenre;
-                TInt errorGenre( myItem.GetField( ECLFFieldIdGenre,
-                                                  songGenre ) );
-                if ( !errorGenre )
-                    {
-                    CUpnpElement* elGenre = CUpnpElement::NewL( 
-                        KElementGenre );
-                    CleanupStack::PushL( elGenre );
-                    HBufC8* genre = UpnpString::FromUnicodeL( songGenre );
-
-                    CleanupStack::PushL( genre );
-                    elGenre->SetValueL( *genre );
-                    // UPnP stack needs filepath
-                    elGenre->SetFilePathL( aFileName );
-                    CleanupStack::PopAndDestroy( genre );
-                    aItem->AddElementL( elGenre ); // transfer own..
-                    CleanupStack::Pop( elGenre );
-
-                    }
-                }
-            else if ( !errorType && mediaType == ECLFMediaTypeImage )
-                {
-                // Just set correct object class
-                aItem->SetObjectClassL( KImageItemObjectClass );
-                }
-            else if ( !errorType && mediaType == ECLFMediaTypeVideo )
-                {
-                // Just set correct object class
-                aItem->SetObjectClassL( KVideoItemObjectClass );
-                }
-
-            // Below this happens to ALL media types
-            TTime dateTime;
-            TInt errorDate( myItem.GetField( ECLFFieldIdFileDate,
-                                             dateTime ) );
-
-        if ( !errorDate )
-                {
-                HBufC* date = NULL;
-                TRAP( errorDate, date = 
-                    UPnPCommonUtils::TTimeToUPnPDateL(dateTime));
-                
-                
-                if(date && errorDate == KErrNone)
-                    {
-                    CleanupStack::PushL( date );
-                    
-                    CUpnpElement* elDate = CUpnpElement::NewL( 
-                    KElementDate );
-                    CleanupStack::PushL( elDate );
-                
-                    
-                    HBufC8* date8 = UpnpString::FromUnicodeL( *date );
-                    CleanupStack::PushL( date8 );
-                    elDate->SetValueL( *date8 );
-              
-                    CleanupStack::PopAndDestroy( date8 );
-                    
-                    elDate->SetFilePathL( aFileName );
-                    aItem->AddElementL( elDate ); // transfer own..
-                
-                    CleanupStack::Pop( elDate );
-                    CleanupStack::Pop( date );
-                    }
-                    
-               
-                if(date)
-                    {
-                    delete date; 
-                    date = NULL;
-                    }
-                }
-
-            }
-        else
-            {
-            // The item was not found
-            if ( iClfIndex != beginLoop )
-                {
-                if ( ++iClfIndex >= model->ItemCount() )
-                    {
-                    iClfIndex = 0;
-                    end = ETrue;
-                    }
-                }
-            else
-                {
-                end = ETrue;
-                __LOG("end=ETRue");
-                }
-            }
-        } // while
-    if( found )
-        {
-        __LOG("CUpnpContentMetadataUtility:: item found");
-        }
-    else
-        {
-        __LOG("CUpnpContentMetadataUtility:: item not found");
-        }
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return found;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::ClearPostFiltersL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-void CUpnpContentMetadataUtility::ClearPostFiltersL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    //clear previous filtering
-    iCollectionModel->SetPostFilter( NULL );
-
-    // Delete old post filter if any
-
-    delete iPostFilter;
-    iPostFilter = NULL;
-    
-    iCollectionModel->RefreshL( ECLFRefreshPostFilter );
-
-   // Set the default postfilter
-    iPostFilter = CUpnpPostFilter::NewL( ECLFFieldIdCollectionName,
-                                         KNullDesC, ETrue );
-    iCollectionModel->SetPostFilter( iPostFilter );
-
-    iCollectionModel->RefreshL( ECLFRefreshPostFilter );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentMetadataUtility::SetCallback
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-void CUpnpContentMetadataUtility::SetCallback( 
-    MUpnpMetadataObserver* aObserver )
-    {
-    iHandler = aObserver;
-
-    }
-
-//  End of File
+/*
+* Copyright (c) 2006-2007 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:      CUpnpContentMetadataUtility class implementation
+ *
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+// System
+#include <e32base.h>
+#include <MCLFContentListingEngine.h>
+#include <ContentListingFactory.h>
+#include <MCLFItemListModel.h>
+#include <CLFContentListing.hrh>
+#include <MCLFItem.h>
+#include <f32file.h>
+// Internal
+#include "upnpcontentmetadatautility.h"
+#include "upnpcontentserverdefs.h"
+
+_LIT( KComponentLogfile, "contentserver.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+const TInt KMediaTypeArrGranularity(1);
+
+using namespace UpnpContentServer;
+
+// ============================ MEMBER FUNCTIONS ============================
+// --------------------------------------------------------------------------
+// CUpnpContentMetadataUtility::CUpnpContentMetadataUtility()
+// Default constructor
+// --------------------------------------------------------------------------
+//
+CUpnpContentMetadataUtility::CUpnpContentMetadataUtility()
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentMetadataUtility::ConstructL()
+// ConstructL
+// --------------------------------------------------------------------------
+//
+void CUpnpContentMetadataUtility::ConstructL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    
+    // Create iWait
+    iWait = new (ELeave) CActiveSchedulerWait;
+    
+    // Create Content Listing Engine 
+    iEngine = ContentListingFactory::NewContentListingEngineLC();
+    CleanupStack::Pop(); // iEngine
+
+    // Create list models
+    iMusicModel = iEngine->CreateListModelLC( *this );
+    CleanupStack::Pop(); // iMusicModel
+    iImageModel = iEngine->CreateListModelLC( *this );
+    CleanupStack::Pop(); // iImageModel
+    iVideoModel = iEngine->CreateListModelLC( *this );
+    CleanupStack::Pop(); // iVideoModel
+
+    // Set music media type filter to CLF
+    RArray<TInt> musicArray( KMediaTypeArrGranularity );
+    CleanupClosePushL( musicArray );
+    musicArray.AppendL( ECLFMediaTypeMusic );
+    iMusicModel->SetWantedMediaTypesL( musicArray.Array() );
+    CleanupStack::PopAndDestroy( &musicArray );
+
+    // Set image media type filter to CLF
+    RArray<TInt> imageArray( KMediaTypeArrGranularity );
+    CleanupClosePushL( imageArray );
+    imageArray.AppendL( ECLFMediaTypeImage );
+    iImageModel->SetWantedMediaTypesL( imageArray.Array() );
+    CleanupStack::PopAndDestroy( &imageArray );
+
+    // Set video media type filter to CLF
+    RArray<TInt> videoArray( KMediaTypeArrGranularity );
+    CleanupClosePushL( videoArray );
+    videoArray.AppendL( ECLFMediaTypeVideo );
+    iVideoModel->SetWantedMediaTypesL( videoArray.Array() );
+    CleanupStack::PopAndDestroy( &videoArray );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentMetadataUtility::NewL()
+// 2 phased constructor
+// --------------------------------------------------------------------------
+//
+CUpnpContentMetadataUtility* CUpnpContentMetadataUtility::NewL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    CUpnpContentMetadataUtility* self
+        = new( ELeave ) CUpnpContentMetadataUtility;
+
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentMetadataUtility::~CUpnpContentMetadataUtility()
+// Default destructor
+// --------------------------------------------------------------------------
+//
+CUpnpContentMetadataUtility::~CUpnpContentMetadataUtility()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    delete iMusicModel;
+    delete iImageModel;
+    delete iVideoModel;
+    delete iEngine;
+    delete iWait;
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentMetadataUtility::HandleOperationEventL
+// Callback implementation for MCLFOperationObserver
+// --------------------------------------------------------------------------
+//
+void CUpnpContentMetadataUtility::HandleOperationEventL(
+    TCLFOperationEvent aOperationEvent,
+    TInt /*aError*/ )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    // Waiting is stopped when an event for refresh completion is received
+    if( aOperationEvent == ECLFRefreshComplete )
+        {
+        // stop iWait
+        if ( iWait->IsStarted() )
+            {
+            iWait->AsyncStop();
+            }
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentMetadataUtility::MusicFiles
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+const MCLFItemListModel* CUpnpContentMetadataUtility::MusicFiles()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    MCLFItemListModel* ret = iMusicModel;
+    TRAPD( err, RefreshModelL( ECLFMediaTypeMusic ) );
+    if ( !err )
+        {
+        WaitForRefreshToComplete();
+        }
+    else
+        {
+        ret = NULL;
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentMetadataUtility::ImageFiles
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+const MCLFItemListModel* CUpnpContentMetadataUtility::ImageFiles()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    MCLFItemListModel* ret = iImageModel;
+    TRAPD( err, RefreshModelL( ECLFMediaTypeImage ) );
+    if ( !err )
+        {
+        WaitForRefreshToComplete();
+        }
+    else
+        {
+        ret = NULL;
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentMetadataUtility::VideoFiles
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+const MCLFItemListModel* CUpnpContentMetadataUtility::VideoFiles()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    MCLFItemListModel* ret = iVideoModel;
+    TRAPD( err, RefreshModelL( ECLFMediaTypeVideo ) );
+    if ( !err )
+        {
+        WaitForRefreshToComplete();
+        }
+    else
+        {
+        ret = NULL;
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return ret;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpContentMetadataUtility::RefreshModelL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+void CUpnpContentMetadataUtility::RefreshModelL( 
+    TCLFMediaType aCLFMediaType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    switch ( aCLFMediaType )
+        {
+        case ECLFMediaTypeImage:
+            {
+            iImageModel->RefreshL();
+            break;
+            }
+        case ECLFMediaTypeVideo:
+            {
+            iVideoModel->RefreshL();
+            break;
+            }
+        case ECLFMediaTypeMusic:
+            {
+            iMusicModel->RefreshL();
+            break;
+            }
+        default:
+            {
+            User::Leave( KErrNotSupported );
+            break;
+            }
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentMetadataUtility::WaitForRefreshToComplete
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+void CUpnpContentMetadataUtility::WaitForRefreshToComplete()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    
+    // start iWait
+    if ( !iWait->IsStarted() )
+        {
+        iWait->Start();
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+    
+//  End of File
--- a/upnpsharing/upnpcontentserver/src/upnpcontentserver.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/src/upnpcontentserver.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,394 +1,391 @@
-/*
-* Copyright (c) 2006-2007 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:      CUpnpContentServer class implamentation
- *
-*/
-
-
-
-
-
-#include <e32debug.h>
-#include <w32std.h>
-
-#include "upnpcontentserver.h"
-#include "upnpcontentserversession.h"
-#include "upnpcontentserverdefs.h"
-#include "upnpcontentserverhandler.h"
-#include "upnpperiodic.h"
-
-_LIT( KComponentLogfile, "contentserver.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-_LIT( KUpnpContentServerString, "Upnp content server");
-
-using namespace UpnpContentServer;
-
-// --------------------------------------------------------------------------
-// Server's policy
-// --------------------------------------------------------------------------
-
-//Total number of ranges
-static const TUint KContentServerRangeCount = 1;
-
-//Definition of the ranges of IPC numbers
-static const TInt contentServerRanges[KContentServerRangeCount] =
-        {
-        0
-        };
-
-//Policy to implement for each of the above ranges
-static const TUint8 contentServerElementsIndex[KContentServerRangeCount] =
-        {
-        0, //applies to 0th range
-        };
-
-//Specific capability checks
-static const CPolicyServer::TPolicyElement contentServerElements[] =
-        {
-        {_INIT_SECURITY_POLICY_C3(ECapabilityReadUserData,
-                                  ECapabilityWriteUserData,
-                                  ECapabilityNetworkServices),
-                                  CPolicyServer::EFailClient}
-                                  //policy "0",
-                                  //fail call if all capabilities not present
-        };
-
-//Package all the above together into a policy
-static const CPolicyServer::TPolicy KUpnpContentServerPolicy =
-        {
-        CPolicyServer::EAlwaysPass, //all connect attempts should pass
-        KContentServerRangeCount,
-        contentServerRanges,
-        contentServerElementsIndex,
-        contentServerElements
-        };
-
-// --------------------------------------------------------------------------
-// E32Main
-// main function called by E32
-// --------------------------------------------------------------------------
-//
-GLDEF_C TInt E32Main()
-    {
-    TRAPD( ret, CUpnpContentServer::LaunchServerL() );
-    return ret;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::LaunchServer
-// Initializes the process and creates an instance of CUpnpContentServer.
-// --------------------------------------------------------------------------
-//
-TInt CUpnpContentServer::LaunchServerL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    // Check server not already started
-    TFindServer findHostServer( KUpnpContentServer );
-
-    TInt err( KErrNone );
-    TFullName name;
-    if ( findHostServer.Next(name) == KErrNone )
-        { // found server already
-        __LOG1( "Error: %d", __LINE__ );
-        err = KErrGeneral;
-        }
-    if ( !err )
-        {
-        User::RenameThread( KUpnpContentServer );
-
-        // Create cleanup stack.
-        CTrapCleanup* cleanup = CTrapCleanup::New();
-
-        // Construct and install active scheduler.
-        CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
-        CActiveScheduler::Install( scheduler );
-
-        // Construct server.
-        CUpnpContentServer* server = NULL;
-        TRAPD( err, server = CUpnpContentServer::NewL() );
-        if ( err )
-            {
-            __LOG1( "Error: %d", err );
-            }
-        RProcess::Rendezvous( err );
-
-        __LOG("CUpnpContentServer::LaunchServer, Start CActiveScheduler");
-        // Start handling requests.
-        CActiveScheduler::Start();
-
-        delete server;
-        __LOG("CUpnpContentServer::LaunchServer, Server deleted.");
-        delete scheduler;
-        delete cleanup;
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::NewL
-// 2-phased constructor.
-// --------------------------------------------------------------------------
-//
-CUpnpContentServer* CUpnpContentServer::NewL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CUpnpContentServer* self = new (ELeave) CUpnpContentServer();
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    self->StartL( KUpnpContentServer );
-    CleanupStack::Pop(); // self
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::CUpnpContentServer()
-// C++ constructor.
-// --------------------------------------------------------------------------
-//
-CUpnpContentServer::CUpnpContentServer()
-    : CPolicyServer( EPriorityStandard, KUpnpContentServerPolicy,
-                     ESharableSessions )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::ConstructL
-// 2nd phase constructor.
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServer::ConstructL()
-    {
-    iHandler = CUpnpContentServerHandler::NewL( this );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::~CUpnpContentServer()
-// C++ destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpContentServer::~CUpnpContentServer()
-    {
-    delete iHandler;
-    delete iContainerIndex;
-    delete iConMon;
-    delete iIdle;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::Handler
-// Returns pointer to CUpnpContentServerHandler
-// --------------------------------------------------------------------------
-//
-CUpnpContentServerHandler* CUpnpContentServer::Handler() const
-    {
-    return iHandler;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::NewContainerL
-// Deletes  objcet container
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServer::RemoveSession( )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iSessionCount--;
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::NewContainerL
-// Deletes  objcet container
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServer::AddSession()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iSessionCount++;
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::CanStop
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TBool CUpnpContentServer::CanStop() const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TBool ret( EFalse );
-    if ( iSessionCount < 1 && !iConMon )
-        {
-        ret = ETrue;
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return ret;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::Stop
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServer::Stop()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-  /*  if ( iIdle )
-        {
-        iIdle->Cancel();
-        }
-    else
-        {
-        TRAPD( err, iIdle = CUPnPPeriodic::NewL( CActive::EPriorityIdle ) );
-        __ASSERT( err == KErrNone, __FILE__, __LINE__  );
-        }
-
-    iIdle->Start( KShutdownTimeout, 
-                  KShutdownTimeout, 
-                  TCallBack( Shutdown, this ) );*/
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::Shutdown
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TInt CUpnpContentServer::Shutdown( TAny* aPtr )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CUpnpContentServer* server = static_cast<CUpnpContentServer*>(aPtr);
-    delete server->iIdle;
-    server->iIdle = NULL;
-    CActiveScheduler::Stop();
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return KErrNone;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::RequestConnectionLostL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TInt CUpnpContentServer::RequestConnectionLostL(
-    const TInt aIapId )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    if ( iHandler )
-        {
-        iHandler->ValidateDefaultContainersL();
-        }
-    TInt err( KErrNone );
-    if ( !iConMon )
-        {
-        iConMon = CUPnPConnectionMonitor::NewL( *this, aIapId );
-        iActiveIapId = aIapId;
-        }
-    else if ( iActiveIapId != aIapId )
-        {
-        err = KErrInUse;
-        }
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::CancelConnectionLostL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServer::CancelConnectionLostL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    // Stop connection monitoring
-    delete iConMon;
-    iConMon = NULL;
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::ConnectionLost
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServer::ConnectionLost()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    TRAP_IGNORE( iHandler->ConnectionLostL() );
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::RunError
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TInt CUpnpContentServer::RunError( TInt aError )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    if ( aError )
-        {
-        __LOG1( "Error: %d", aError );
-        }
-    if ( aError == KErrBadDescriptor )
-        {
-        Message().Panic( KUpnpContentServerString, aError );
-        }
-    else
-        {
-        Message().Complete( aError );
-        }
-    ReStart();
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return KErrNone;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServer::NewSessionL
-// from CServer2, creates a new session.
-// --------------------------------------------------------------------------
-//
-CSession2* CUpnpContentServer::NewSessionL(
-    const TVersion& aVersion,
-    const RMessage2& /*aMessage*/ ) const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    if ( iIdle )
-        {
-        iIdle->Cancel();
-        }
-    
-    TVersion v( KUpnpContentServerVersionMajor,
-                KUpnpContentServerVersionMinor,
-                0 );
-    if( !User::QueryVersionSupported(v,aVersion) )
-        {
-        User::Leave(KErrNotSupported);
-        }
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return CUpnpContentServerSession::NewL( (CUpnpContentServer*)this );
-    }
-
-// End of file
+/*
+* Copyright (c) 2006-2007 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:      CUpnpContentServer class implamentation
+ *
+*/
+
+
+
+
+
+#include <e32debug.h>
+#include <w32std.h>
+
+#include "upnpcontentserver.h"
+#include "upnpcontentserversession.h"
+#include "upnpcontentserverdefs.h"
+#include "upnpcontentserverhandler.h"
+#include "upnpperiodic.h"
+
+_LIT( KComponentLogfile, "contentserver.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+_LIT( KUpnpContentServerString, "Upnp content server");
+
+using namespace UpnpContentServer;
+
+// --------------------------------------------------------------------------
+// Server's policy
+// --------------------------------------------------------------------------
+
+//Total number of ranges
+static const TUint KContentServerRangeCount = 1;
+
+//Definition of the ranges of IPC numbers
+static const TInt contentServerRanges[KContentServerRangeCount] =
+        {
+        0
+        };
+
+//Policy to implement for each of the above ranges
+static const TUint8 contentServerElementsIndex[KContentServerRangeCount] =
+        {
+        0, //applies to 0th range
+        };
+
+//Specific capability checks
+static const CPolicyServer::TPolicyElement contentServerElements[] =
+        {
+        {_INIT_SECURITY_POLICY_C3(ECapabilityReadUserData,
+                                  ECapabilityWriteUserData,
+                                  ECapabilityNetworkServices),
+                                  CPolicyServer::EFailClient}
+                                  //policy "0",
+                                  //fail call if all capabilities not present
+        };
+
+//Package all the above together into a policy
+static const CPolicyServer::TPolicy KUpnpContentServerPolicy =
+        {
+        CPolicyServer::EAlwaysPass, //all connect attempts should pass
+        KContentServerRangeCount,
+        contentServerRanges,
+        contentServerElementsIndex,
+        contentServerElements
+        };
+
+// --------------------------------------------------------------------------
+// E32Main
+// main function called by E32
+// --------------------------------------------------------------------------
+//
+GLDEF_C TInt E32Main()
+    {
+    TRAPD( ret, CUpnpContentServer::LaunchServerL() );
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::LaunchServer
+// Initializes the process and creates an instance of CUpnpContentServer.
+// --------------------------------------------------------------------------
+//
+TInt CUpnpContentServer::LaunchServerL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    // Check server not already started
+    TFindServer findHostServer( KUpnpContentServer );
+
+    TInt err( KErrNone );
+    TFullName name;
+    if ( findHostServer.Next(name) == KErrNone )
+        { // found server already
+        __LOG1( "Error: %d", __LINE__ );
+        err = KErrGeneral;
+        }
+    if ( !err )
+        {
+        User::RenameThread( KUpnpContentServer );
+
+        // Create cleanup stack.
+        CTrapCleanup* cleanup = CTrapCleanup::New();
+
+        // Construct and install active scheduler.
+        CActiveScheduler* scheduler = new (ELeave) CActiveScheduler;
+        CActiveScheduler::Install( scheduler );
+
+        // Construct server.
+        CUpnpContentServer* server = NULL;
+        TRAPD( err, server = CUpnpContentServer::NewL() );
+        if ( err )
+            {
+            __LOG1( "Error: %d", err );
+            }
+        RProcess::Rendezvous( err );
+
+        __LOG("CUpnpContentServer::LaunchServer, Start CActiveScheduler");
+        // Start handling requests.
+        CActiveScheduler::Start();
+
+        delete server;
+        __LOG("CUpnpContentServer::LaunchServer, Server deleted.");
+        delete scheduler;
+        delete cleanup;
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::NewL
+// 2-phased constructor.
+// --------------------------------------------------------------------------
+//
+CUpnpContentServer* CUpnpContentServer::NewL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    CUpnpContentServer* self = new (ELeave) CUpnpContentServer();
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    self->StartL( KUpnpContentServer );
+    CleanupStack::Pop(); // self
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::CUpnpContentServer()
+// C++ constructor.
+// --------------------------------------------------------------------------
+//
+CUpnpContentServer::CUpnpContentServer()
+    : CPolicyServer( EPriorityStandard, KUpnpContentServerPolicy,
+                     ESharableSessions )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::ConstructL
+// 2nd phase constructor.
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServer::ConstructL()
+    {
+    iHandler = CUpnpContentServerHandler::NewL( this );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::~CUpnpContentServer()
+// C++ destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpContentServer::~CUpnpContentServer()
+    {
+    delete iHandler;
+    delete iContainerIndex;
+    delete iConMon;
+    delete iIdle;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::Handler
+// Returns pointer to CUpnpContentServerHandler
+// --------------------------------------------------------------------------
+//
+CUpnpContentServerHandler* CUpnpContentServer::Handler() const
+    {
+    return iHandler;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::NewContainerL
+// Deletes  objcet container
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServer::RemoveSession( )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    iSessionCount--;
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::NewContainerL
+// Deletes  objcet container
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServer::AddSession()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    iSessionCount++;
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::CanStop
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TBool CUpnpContentServer::CanStop() const
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TBool ret( EFalse );
+    if ( iSessionCount < 1 && !iConMon )
+        {
+        ret = ETrue;
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::Stop
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServer::Stop()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    if ( iIdle )
+        {
+        iIdle->Cancel();
+        }
+    else
+        {
+        TRAPD( err, iIdle = CUPnPPeriodic::NewL( CActive::EPriorityIdle ) );
+        __ASSERT( err == KErrNone, __FILE__, __LINE__  );
+        }
+
+    iIdle->Start( KShutdownTimeout, 
+                  KShutdownTimeout, 
+                  TCallBack( Shutdown, this ) );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::Shutdown
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TInt CUpnpContentServer::Shutdown( TAny* aPtr )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    CUpnpContentServer* server = static_cast<CUpnpContentServer*>(aPtr);
+    delete server->iIdle;
+    server->iIdle = NULL;
+    CActiveScheduler::Stop();
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::RequestConnectionLostL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TInt CUpnpContentServer::RequestConnectionLostL(
+    const TInt aIapId )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TInt err( KErrNone );
+    if ( !iConMon )
+        {
+        iConMon = CUPnPConnectionMonitor::NewL( aIapId );
+        iConMon->SetObserver( *this );
+        iActiveIapId = aIapId;
+        }
+    else if ( iActiveIapId != aIapId )
+        {
+        err = KErrInUse;
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::CancelConnectionLostL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServer::CancelConnectionLostL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    // Stop connection monitoring
+    delete iConMon;
+    iConMon = NULL;
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::ConnectionLost
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServer::ConnectionLost( TBool /*aUserOriented*/ )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    TRAP_IGNORE( iHandler->ConnectionLostL() );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::RunError
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TInt CUpnpContentServer::RunError( TInt aError )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    if ( aError )
+        {
+        __LOG1( "Error: %d", aError );
+        }
+    if ( aError == KErrBadDescriptor )
+        {
+        Message().Panic( KUpnpContentServerString, aError );
+        }
+    else
+        {
+        Message().Complete( aError );
+        }
+    ReStart();
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return KErrNone;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServer::NewSessionL
+// from CServer2, creates a new session.
+// --------------------------------------------------------------------------
+//
+CSession2* CUpnpContentServer::NewSessionL(
+    const TVersion& aVersion,
+    const RMessage2& /*aMessage*/ ) const
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    if ( iIdle )
+        {
+        iIdle->Cancel();
+        }
+    
+    TVersion v( KUpnpContentServerVersionMajor,
+                KUpnpContentServerVersionMinor,
+                0 );
+    if( !User::QueryVersionSupported(v,aVersion) )
+        {
+        User::Leave(KErrNotSupported);
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return CUpnpContentServerSession::NewL( (CUpnpContentServer*)this );
+    }
+
+// End of file
--- a/upnpsharing/upnpcontentserver/src/upnpcontentserverclient.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/src/upnpcontentserverclient.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,447 +1,447 @@
-/*
-* Copyright (c) 2006-2007 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:      RUpnpContentServerClient class implementation
-*
-*/
-
-
-
-
-
-
-// INCLUDES
-#include <f32file.h>
-#include <s32mem.h>
-
-#include "upnpcontentserverclient.h"
-
-_LIT( KComponentLogfile, "contentserver.txt");
-#include "upnplog.h"
-
-// CONSTANTS 
-const TInt KDefaultBufferSize( 512 ); //default size for any receice buffer
-const TInt KContentBufferSize( 10*1024 ); //size for media content buffer
-
-using namespace UpnpContentServer;
-
-//---------------------------------------------------------------------------
-// LaunchServer
-// Launches the server
-//---------------------------------------------------------------------------
-//
-TInt LaunchServer()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TInt res = KErrNone;
-
-    // DLL launch
-    RProcess server;
-    res = server.Create( KUpnpContentServerNameAndDir, 
-                         KNullDesC );
-
-    // Loading failed.
-    if ( res == KErrNone )
-        {
-        server.SetPriority( EPriorityLow );
-        TRequestStatus status;
-        server.Rendezvous(status);
-
-        if ( status != KRequestPending)
-            {
-            server.Kill(0);     // abort startup
-            server.Close();
-            res = KErrGeneral;
-            }
-        if( !res )
-            {
-            server.Resume();    // Logon OK - start the server.
-
-            User::WaitForRequest(status);
-            server.Close();
-            res = status.Int();
-            }
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return res;
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::RUpnpContentServerClient
-// C++ Constructor
-// --------------------------------------------------------------------------
-//
-EXPORT_C RUpnpContentServerClient::RUpnpContentServerClient()
-    : iSendBufferPtr( NULL, 0 ),
-      iSendBuffer( NULL ),
-      iReceiveBufferPtr( NULL, 0 ),
-      iReceiveBuffer( NULL ),
-      iContentBufferPtr( NULL, 0 ),
-      iContentBuffer( NULL )
-    {
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::OpenL
-// Creates connection to server
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::OpenL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TVersion version( KUpnpContentServerVersionMajor,
-                      KUpnpContentServerVersionMinor,
-                      0 );
-
-    TInt res = CreateSession( KUpnpContentServer, version,
-                              KDefaultMessageSlots );
-    if ( res != KErrNone )
-        {
-        __LOG1( "Error: %d", res );
-        res = LaunchServer();
-        if ( res != KErrNone )
-            {
-            __LOG1( "Error: %d", res );
-            }
-        User::LeaveIfError( res );
-        res = CreateSession( KUpnpContentServer, version,
-                             KDefaultMessageSlots );
-        if ( res != KErrNone )
-            {
-            __LOG1( "Error: %d", res );
-            }
-        ShareAuto();
-        }
-    User::LeaveIfError( res );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::Close
-// close connection to server
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::Close()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    // close session
-    delete iSendBuffer;
-    iSendBuffer = NULL;
-    delete iReceiveBuffer;
-    iReceiveBuffer = NULL;
-    delete iContentBuffer;
-    iContentBuffer = NULL;
-    RSessionBase::Close();
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::StartUploadListenerL
-// Starts the media server upload listener
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::StartUploadListenerL( )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    User::Leave( KErrNotSupported );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::StopUploadListenerL
-// Stops the media server upload listener
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::StopUploadListenerL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    User::Leave( KErrNotSupported );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::GetSelectionContentL
-// Gets the names of existed albums/playlists
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::GetSelectionContentL(
-    UpnpContentServer::TUpnpMediaType aType,
-    TRequestStatus& aStatus )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
- /*   delete iSendBuffer;
-    iSendBuffer = NULL;
-    iSendBuffer = CBufFlat::NewL( KTintSize );
-
-    // Need to externalize a data to buffer to send it with IPC
-    RBufWriteStream sendstream;
-    sendstream.Open( *iSendBuffer );
-    CleanupClosePushL( sendstream );
-    sendstream.WriteInt32L( aType );
-    iSendBufferPtr.Set( iSendBuffer->Ptr(0) );
-
-    // Prepare receive buffers
-    delete iContentBuffer;
-    iContentBuffer = NULL;
-    iContentBuffer = HBufC8::NewL( KContentBufferSize );
-    iContentBufferPtr.Set( iContentBuffer->Des() );
-
-    SendReceive( ERequestSelectionContent,
-                 TIpcArgs( &iSendBufferPtr, &iContentBufferPtr ), 
-                 aStatus );
-    CleanupStack::PopAndDestroy( &sendstream );*/
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::GetSelectionContentResultL
-// Ask the result of GetSelectionContentL call
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::GetSelectionContentResultL(
-    CDesCArray& aIDArray )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    if ( !iContentBuffer )
-        {
-        User::Leave( KErrNotReady );
-        }
-
-    RDesReadStream stream;
-    stream.Open( iContentBufferPtr );
-    CleanupClosePushL( stream );
-    // leaves -25 if empty stream
-    TInt itemCount( 0 );
-    TRAP_IGNORE( itemCount = stream.ReadUint32L() );
-
-    for ( TInt i(0); i < itemCount; i++ )
-        {
-        const TInt desLen( static_cast<TInt>( stream.ReadUint32L() ));
-        TBuf<KMaxFileName> item;
-        stream.ReadL( item, desLen );
-        aIDArray.AppendL( item );
-        }
-
-    CleanupStack::PopAndDestroy( &stream );
-    delete iContentBuffer;
-    iContentBuffer = NULL;
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::ChangeSharedContentL
-// Sends the selected indexes to server and starts sharing
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::ChangeSharedContentL(
-    UpnpContentServer::TUpnpMediaType aType,
-    const CArrayFix<TInt>& aMarkedItems,
-    TRequestStatus& aStatus )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    TInt objectCount( aMarkedItems.Count() );
-    if ( objectCount < 1 )
-        {
-        __LOG1( "Error: %d", __LINE__ );
-        User::Leave( KErrArgument );
-        }
-
-    delete iSendBuffer;
-    iSendBuffer = NULL;
-    // Calculate correct size for send buffer on basis of the amount
-    // of items user has selected
-    iSendBuffer = CBufFlat::NewL( objectCount * KTintSize + 2*KTintSize );
-
-    // Need to externalize a data to buffer to send it with IPC
-    RBufWriteStream stream;
-    stream.Open( *iSendBuffer );
-    CleanupClosePushL( stream );
-    stream.WriteInt32L( aType );
-    stream.WriteInt32L( objectCount );
-    for( TInt i(0); i< objectCount; i++ )
-        {
-        stream.WriteInt32L( aMarkedItems[ i ] );
-        }
-    iSendBufferPtr.Set( iSendBuffer->Ptr(0) );
-
-    SendReceive( EChangeShareContent,
-                 TIpcArgs( &iSendBufferPtr ),
-                 aStatus );   
-    CleanupStack::PopAndDestroy( &stream );
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::RefreshSharedContentL
-// Refresh the shared content
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::RefreshSharedContentL(
-    UpnpContentServer::TUpnpMediaType aType,
-    TRequestStatus& aStatus )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
- /*   delete iSendBuffer;
-    iSendBuffer = NULL;
-    iSendBuffer = CBufFlat::NewL( KTintSize );
-
-    // Need to externalize a data to buffer to send it with IPC
-    RBufWriteStream stream;
-    stream.Open( *iSendBuffer );
-    CleanupClosePushL( stream );
-    stream.WriteInt32L( aType );
-    iSendBufferPtr.Set( iSendBuffer->Ptr(0) );
-
-    SendReceive( ERefreshShareContent,
-                 TIpcArgs( &iSendBufferPtr ),
-                 aStatus );
-    CleanupStack::PopAndDestroy( &stream );*/
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::GetSelectionIndexesL
-// Gets the users previous selections as list of selected indexes
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::GetSelectionIndexesL(
-    UpnpContentServer::TUpnpMediaType aType,
-    TRequestStatus& aStatus )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-  /*  delete iSendBuffer;
-    iSendBuffer = NULL;
-    iSendBuffer = CBufFlat::NewL( KTintSize );
-
-    // Need to externalize a data to buffer to send it with IPC
-    RBufWriteStream sendstream;
-    sendstream.Open( *iSendBuffer );
-    CleanupClosePushL( sendstream );
-    sendstream.WriteInt32L( aType );
-    iSendBufferPtr.Set( iSendBuffer->Ptr(0) );
-
-    // Prepare receive buffers
-    PrepareReceiveBuffersL( KDefaultBufferSize );
-
-    SendReceive( EGetSelectionIndexes,
-                 TIpcArgs( &iSendBufferPtr, &iReceiveBufferPtr ),
-                 aStatus );
-    CleanupStack::PopAndDestroy( &sendstream );*/
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::GetSelectionIndexesResultL
-// Ask the result of GetSelectionIndexesL call
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::GetSelectionIndexesResultL(
-    CArrayFix<TInt>& aMarkedItems )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    if ( !iReceiveBuffer )
-        {
-        User::Leave( KErrNotReady );
-        }
-
-    RDesReadStream stream;
-    stream.Open( iReceiveBufferPtr );
-    CleanupClosePushL( stream );
-
-    // leaves -25 if empty stream
-    TInt itemCount( 0 );
-    TRAP_IGNORE( itemCount = stream.ReadUint32L() );
-
-    for ( TInt i(0); i < itemCount; i++ )
-        {
-        const TInt val = static_cast<TInt>( stream.ReadUint32L() );
-        aMarkedItems.AppendL( val );
-        }
-
-    CleanupStack::PopAndDestroy( &stream );
-    delete iReceiveBuffer;
-    iReceiveBuffer = NULL;
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::StartConnectionMonitorL
-// Start connection monitor in content server
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::StartConnectionMonitorL( 
-    TInt aIapId,
-    TRequestStatus& aStatus )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-   /* delete iSendBuffer;
-    iSendBuffer = NULL;
-    iSendBuffer = CBufFlat::NewL( KTintSize );
-
-    // Need to externalize a data to buffer to send it with IPC
-    RBufWriteStream sendstream;
-    sendstream.Open( *iSendBuffer );
-    CleanupClosePushL( sendstream );
-    sendstream.WriteInt32L( aIapId );
-    iSendBufferPtr.Set( iSendBuffer->Ptr(0) );
-
-    SendReceive( EStartConnectionMonitor,
-                 TIpcArgs( &iSendBufferPtr ),
-                 aStatus );
-    CleanupStack::PopAndDestroy( &sendstream );*/
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::StopConnectionMonitorL
-// Stop connection monitor in content server
-// --------------------------------------------------------------------------
-//
-EXPORT_C void RUpnpContentServerClient::StopConnectionMonitorL( 
-    TRequestStatus& aStatus )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    SendReceive( EStopConnectionMonitor, aStatus );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// RUpnpContentServerClient::PrepareReceiveBuffers
-// Prepares the receive buffers
-// --------------------------------------------------------------------------
-//
-void RUpnpContentServerClient::PrepareReceiveBuffersL( TInt aSize )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    delete iReceiveBuffer;
-    iReceiveBuffer = NULL;
-    iReceiveBuffer = HBufC8::NewL( aSize );
-    iReceiveBufferPtr.Set( iReceiveBuffer->Des() );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-//End of File
+/*
+* Copyright (c) 2006-2007 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:      RUpnpContentServerClient class implementation
+*
+*/
+
+
+
+
+
+
+// INCLUDES
+#include <f32file.h>
+#include <s32mem.h>
+
+#include "upnpcontentserverclient.h"
+
+_LIT( KComponentLogfile, "contentserver.txt");
+#include "upnplog.h"
+
+// CONSTANTS 
+const TInt KDefaultBufferSize( 512 ); //default size for any receice buffer
+const TInt KContentBufferSize( 10*1024 ); //size for media content buffer
+
+using namespace UpnpContentServer;
+
+//---------------------------------------------------------------------------
+// LaunchServer
+// Launches the server
+//---------------------------------------------------------------------------
+//
+TInt LaunchServer()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TInt res = KErrNone;
+
+    // DLL launch
+    RProcess server;
+    res = server.Create( KUpnpContentServerNameAndDir, 
+                         KNullDesC );
+
+    // Loading failed.
+    if ( res == KErrNone )
+        {
+        server.SetPriority( EPriorityLow );
+        TRequestStatus status;
+        server.Rendezvous(status);
+
+        if ( status != KRequestPending)
+            {
+            server.Kill(0);     // abort startup
+            server.Close();
+            res = KErrGeneral;
+            }
+        if( !res )
+            {
+            server.Resume();    // Logon OK - start the server.
+
+            User::WaitForRequest(status);
+            server.Close();
+            res = status.Int();
+            }
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return res;
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::RUpnpContentServerClient
+// C++ Constructor
+// --------------------------------------------------------------------------
+//
+EXPORT_C RUpnpContentServerClient::RUpnpContentServerClient()
+    : iSendBufferPtr( NULL, 0 ),
+      iSendBuffer( NULL ),
+      iReceiveBufferPtr( NULL, 0 ),
+      iReceiveBuffer( NULL ),
+      iContentBufferPtr( NULL, 0 ),
+      iContentBuffer( NULL )
+    {
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::OpenL
+// Creates connection to server
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::OpenL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TVersion version( KUpnpContentServerVersionMajor,
+                      KUpnpContentServerVersionMinor,
+                      0 );
+
+    TInt res = CreateSession( KUpnpContentServer, version,
+                              KDefaultMessageSlots );
+    if ( res != KErrNone )
+        {
+        __LOG1( "Error: %d", res );
+        res = LaunchServer();
+        if ( res != KErrNone )
+            {
+            __LOG1( "Error: %d", res );
+            }
+        User::LeaveIfError( res );
+        res = CreateSession( KUpnpContentServer, version,
+                             KDefaultMessageSlots );
+        if ( res != KErrNone )
+            {
+            __LOG1( "Error: %d", res );
+            }
+        ShareAuto();
+        }
+    User::LeaveIfError( res );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::Close
+// close connection to server
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::Close()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    // close session
+    delete iSendBuffer;
+    iSendBuffer = NULL;
+    delete iReceiveBuffer;
+    iReceiveBuffer = NULL;
+    delete iContentBuffer;
+    iContentBuffer = NULL;
+    RSessionBase::Close();
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::StartUploadListenerL
+// Starts the media server upload listener
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::StartUploadListenerL( )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    User::Leave( KErrNotSupported );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::StopUploadListenerL
+// Stops the media server upload listener
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::StopUploadListenerL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    User::Leave( KErrNotSupported );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::GetSelectionContentL
+// Gets the names of existed albums/playlists
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::GetSelectionContentL(
+    UpnpContentServer::TUpnpMediaType aType,
+    TRequestStatus& aStatus )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    delete iSendBuffer;
+    iSendBuffer = NULL;
+    iSendBuffer = CBufFlat::NewL( KTintSize );
+
+    // Need to externalize a data to buffer to send it with IPC
+    RBufWriteStream sendstream;
+    sendstream.Open( *iSendBuffer );
+    CleanupClosePushL( sendstream );
+    sendstream.WriteInt32L( aType );
+    iSendBufferPtr.Set( iSendBuffer->Ptr(0) );
+
+    // Prepare receive buffers
+    delete iContentBuffer;
+    iContentBuffer = NULL;
+    iContentBuffer = HBufC8::NewL( KContentBufferSize );
+    iContentBufferPtr.Set( iContentBuffer->Des() );
+
+    SendReceive( ERequestSelectionContent,
+                 TIpcArgs( &iSendBufferPtr, &iContentBufferPtr ), 
+                 aStatus );
+    CleanupStack::PopAndDestroy( &sendstream );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::GetSelectionContentResultL
+// Ask the result of GetSelectionContentL call
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::GetSelectionContentResultL(
+    CDesCArray& aIDArray )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    if ( !iContentBuffer )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    RDesReadStream stream;
+    stream.Open( iContentBufferPtr );
+    CleanupClosePushL( stream );
+    // leaves -25 if empty stream
+    TInt itemCount( 0 );
+    TRAP_IGNORE( itemCount = stream.ReadUint32L() );
+
+    for ( TInt i(0); i < itemCount; i++ )
+        {
+        const TInt desLen( static_cast<TInt>( stream.ReadUint32L() ));
+        TBuf<KMaxFileName> item;
+        stream.ReadL( item, desLen );
+        aIDArray.AppendL( item );
+        }
+
+    CleanupStack::PopAndDestroy( &stream );
+    delete iContentBuffer;
+    iContentBuffer = NULL;
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::ChangeSharedContentL
+// Sends the selected indexes to server and starts sharing
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::ChangeSharedContentL(
+    UpnpContentServer::TUpnpMediaType aType,
+    const CArrayFix<TInt>& aMarkedItems,
+    TRequestStatus& aStatus )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    TInt objectCount( aMarkedItems.Count() );
+    if ( objectCount < 1 )
+        {
+        __LOG1( "Error: %d", __LINE__ );
+        User::Leave( KErrArgument );
+        }
+
+    delete iSendBuffer;
+    iSendBuffer = NULL;
+    // Calculate correct size for send buffer on basis of the amount
+    // of items user has selected
+    iSendBuffer = CBufFlat::NewL( objectCount * KTintSize + 2*KTintSize );
+
+    // Need to externalize a data to buffer to send it with IPC
+    RBufWriteStream stream;
+    stream.Open( *iSendBuffer );
+    CleanupClosePushL( stream );
+    stream.WriteInt32L( aType );
+    stream.WriteInt32L( objectCount );
+    for( TInt i(0); i< objectCount; i++ )
+        {
+        stream.WriteInt32L( aMarkedItems[ i ] );
+        }
+    iSendBufferPtr.Set( iSendBuffer->Ptr(0) );
+
+    SendReceive( EChangeShareContent,
+                 TIpcArgs( &iSendBufferPtr ),
+                 aStatus );   
+    CleanupStack::PopAndDestroy( &stream );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::RefreshSharedContentL
+// Refresh the shared content
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::RefreshSharedContentL(
+    UpnpContentServer::TUpnpMediaType aType,
+    TRequestStatus& aStatus )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    delete iSendBuffer;
+    iSendBuffer = NULL;
+    iSendBuffer = CBufFlat::NewL( KTintSize );
+
+    // Need to externalize a data to buffer to send it with IPC
+    RBufWriteStream stream;
+    stream.Open( *iSendBuffer );
+    CleanupClosePushL( stream );
+    stream.WriteInt32L( aType );
+    iSendBufferPtr.Set( iSendBuffer->Ptr(0) );
+
+    SendReceive( ERefreshShareContent,
+                 TIpcArgs( &iSendBufferPtr ),
+                 aStatus );
+    CleanupStack::PopAndDestroy( &stream );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::GetSelectionIndexesL
+// Gets the users previous selections as list of selected indexes
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::GetSelectionIndexesL(
+    UpnpContentServer::TUpnpMediaType aType,
+    TRequestStatus& aStatus )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    delete iSendBuffer;
+    iSendBuffer = NULL;
+    iSendBuffer = CBufFlat::NewL( KTintSize );
+
+    // Need to externalize a data to buffer to send it with IPC
+    RBufWriteStream sendstream;
+    sendstream.Open( *iSendBuffer );
+    CleanupClosePushL( sendstream );
+    sendstream.WriteInt32L( aType );
+    iSendBufferPtr.Set( iSendBuffer->Ptr(0) );
+
+    // Prepare receive buffers
+    PrepareReceiveBuffersL( KDefaultBufferSize );
+
+    SendReceive( EGetSelectionIndexes,
+                 TIpcArgs( &iSendBufferPtr, &iReceiveBufferPtr ),
+                 aStatus );
+    CleanupStack::PopAndDestroy( &sendstream );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::GetSelectionIndexesResultL
+// Ask the result of GetSelectionIndexesL call
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::GetSelectionIndexesResultL(
+    CArrayFix<TInt>& aMarkedItems )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    if ( !iReceiveBuffer )
+        {
+        User::Leave( KErrNotReady );
+        }
+
+    RDesReadStream stream;
+    stream.Open( iReceiveBufferPtr );
+    CleanupClosePushL( stream );
+
+    // leaves -25 if empty stream
+    TInt itemCount( 0 );
+    TRAP_IGNORE( itemCount = stream.ReadUint32L() );
+
+    for ( TInt i(0); i < itemCount; i++ )
+        {
+        const TInt val = static_cast<TInt>( stream.ReadUint32L() );
+        aMarkedItems.AppendL( val );
+        }
+
+    CleanupStack::PopAndDestroy( &stream );
+    delete iReceiveBuffer;
+    iReceiveBuffer = NULL;
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::StartConnectionMonitorL
+// Start connection monitor in content server
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::StartConnectionMonitorL( 
+    TInt aIapId,
+    TRequestStatus& aStatus )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    delete iSendBuffer;
+    iSendBuffer = NULL;
+    iSendBuffer = CBufFlat::NewL( KTintSize );
+
+    // Need to externalize a data to buffer to send it with IPC
+    RBufWriteStream sendstream;
+    sendstream.Open( *iSendBuffer );
+    CleanupClosePushL( sendstream );
+    sendstream.WriteInt32L( aIapId );
+    iSendBufferPtr.Set( iSendBuffer->Ptr(0) );
+
+    SendReceive( EStartConnectionMonitor,
+                 TIpcArgs( &iSendBufferPtr ),
+                 aStatus );
+    CleanupStack::PopAndDestroy( &sendstream );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::StopConnectionMonitorL
+// Stop connection monitor in content server
+// --------------------------------------------------------------------------
+//
+EXPORT_C void RUpnpContentServerClient::StopConnectionMonitorL( 
+    TRequestStatus& aStatus )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    SendReceive( EStopConnectionMonitor, aStatus );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// RUpnpContentServerClient::PrepareReceiveBuffers
+// Prepares the receive buffers
+// --------------------------------------------------------------------------
+//
+void RUpnpContentServerClient::PrepareReceiveBuffersL( TInt aSize )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    delete iReceiveBuffer;
+    iReceiveBuffer = NULL;
+    iReceiveBuffer = HBufC8::NewL( aSize );
+    iReceiveBufferPtr.Set( iReceiveBuffer->Des() );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+//End of File
--- a/upnpsharing/upnpcontentserver/src/upnpcontentserverhandler.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/src/upnpcontentserverhandler.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,1093 +1,1296 @@
-/*
-* Copyright (c) 2006-2007 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:      Content sharing servers main scheduler function
- *
-*/
-
-
-
-
-
-#include <e32debug.h>
-#include <e32property.h>
-#include "upnpcommonutils.h"
-#include "upnpcontentserverdefs.h"
-#include "upnpcontentserverhandler.h"
-#include "upnpselectionreader.h"
-#include "upnpcontentserverclient.h"
-#include "upnpcontainercheckerao.h"
-#include "upnpcontentserver.h"
-#include "upnpperiodic.h"
-
-_LIT( KComponentLogfile, "contentserver.txt");
-#include "upnplog.h"
-
-// CONSTANTS
-const TInt KNoProgress = 0;
-const TInt KMaxProgress = 100;
-const TInt KRequestBufferSize = 2;
-
-
-using namespace UpnpContentServer;
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::NewL
-// 2-phased constructor.
-// --------------------------------------------------------------------------
-//
-CUpnpContentServerHandler* CUpnpContentServerHandler::NewL(
-    CUpnpContentServer* aServer )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CUpnpContentServerHandler* self =
-        new (ELeave) CUpnpContentServerHandler( aServer );
-    CleanupStack::PushL(self);
-    self->ConstructL();
-    CleanupStack::Pop(); // self
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::CUpnpContentServerHandler()
-// C++ constructor.
-// --------------------------------------------------------------------------
-//
-CUpnpContentServerHandler::CUpnpContentServerHandler(
-    CUpnpContentServer* aServer ) :
-    iServer( aServer ),
-    iContentSharingObserver( NULL ),
-    iDefaultContainerIds( 3 )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iHandlerState = ENotActive;
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::ConstructL
-// 2nd phase constructor.
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::ConstructL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
- /*   static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
-    static _LIT_SECURITY_POLICY_S0(KThisProcessPolicy,
-                                   KUpnpContentServerCat.iUid );
-
-    // define progress property to be a byte array, allocating mem
-    TInt err = iProgressProperty.Define( KUpnpContentServerCat,
-                                         ESharingProgress,
-                                         RProperty::EByteArray,
-                                         KAllowAllPolicy,
-                                         KThisProcessPolicy,
-                                         sizeof( TUpnpProgress ) );
-    if ( err != KErrNone )
-        {
-        __LOG1( "Error: %d", err );
-        }
-    if ( err!=KErrAlreadyExists )
-        {
-        User::LeaveIfError( err );
-        }
-
-    iIdle = CUPnPPeriodic::NewL( CActive::EPriorityIdle );
-    TCallBack cb( RefreshClfL, this );
-    const TInt KRefreshDelay( 500000 );
-    iIdle->Start( KRefreshDelay, KRefreshDelay, cb );
-    iReader = CUpnpSelectionReader::NewL( NULL ); // metadata set later
-    SetProgressL( KNoProgress );*/
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::RefreshClfL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TInt CUpnpContentServerHandler::RefreshClfL( TAny* aPtr )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CUpnpContentServerHandler* handler( NULL );
-    handler = static_cast<CUpnpContentServerHandler*>( aPtr );
-    handler->iMetadata = CUpnpContentMetadataUtility::NewL();
-    handler->iMetadata->SetCallback( handler );
-    handler->iReader->SetMetadata( handler->iMetadata );
-
-    handler->iIdle->Cancel();
-    delete handler->iIdle;
-    handler->iIdle = NULL;
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return KErrNone;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::~CUpnpContentServerHandler()
-// C++ destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpContentServerHandler::~CUpnpContentServerHandler()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    delete iAo;
-    delete iUnsharer;
-    delete iContainerChecker;
-    delete iMetadata;
-    delete iReader;
-    delete iMediaServer;
-
-    if ( iWait.IsStarted() )
-        {
-        iWait.AsyncStop();
-        }
-    iDefaultContainerIds.Close();
-    delete iPendingSharingReq;
-    delete iMusicSharingReq;
-    delete iVisualSharingReq;
-    iProgressProperty.Delete( KUpnpContentServerCat, ESharingProgress );
-    iProgressProperty.Close();
-    iServer = NULL;
-    if ( iIdle )
-        {
-        iIdle->Cancel();
-        delete iIdle;
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::SetContentSharingObserverL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::SetContentSharingObserverL(
-    MUpnpContentSharingObserver* aObserver )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iContentSharingObserver = aObserver; // can be NULL
-    if( iContentSharingObserver )
-        {
-        SetProgressL( KNoProgress );
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::GetSelectionContentL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::GetSelectionContentL(
-    const TInt& aContainerType )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    // There might be many containers -> 10 is OK for granularity
-    CDesCArray* containers = new ( ELeave ) CDesCArrayFlat( 10 );
-    CleanupStack::PushL( containers );
-    if ( iMetadata->RefreshOngoing() )
-        {
-        if ( !iWait.IsStarted() )
-            {
-            iWait.Start();
-            }
-        else
-            {
-            __LOG1( "Error: %d", __LINE__ );
-            }
-        }
-
-    switch ( aContainerType )
-        {
-    case EImageAndVideo :
-        {
-        iReader->FetchCollectionsL( containers );
-        }
-        break;
-    case EPlaylist :
-        {
-        iReader->FetchPlaylistsL( containers );
-        }
-        break;
-    default :
-        {
-        CleanupStack::PopAndDestroy( containers );
-        __LOG1( "Error: %d", __LINE__ );
-        }
-        break;
-        }
-    if ( iContentSharingObserver )
-        {
-        iContentSharingObserver->CompleteSelectionContentL( *containers );
-        }
-
-    CleanupStack::PopAndDestroy( containers );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::GetSelectionIndexesL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::GetSelectionIndexesL(
-    RArray<TInt>& aMarkedItems,
-    const TInt aType )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CUpnpSharingRequest* sharingReq( NULL );
-    switch ( aType )
-        {
-    case EImageAndVideo :
-        {
-        if ( iVisualSharingReq )
-            {
-            sharingReq = iVisualSharingReq;
-            }
-        }
-        break;
-    case EPlaylist :
-        {
-        if ( iMusicSharingReq )
-            {
-            sharingReq = iMusicSharingReq;
-            }
-        }
-        break;
-    default :
-        {
-        __LOG1( "Error: %d", __LINE__ );
-        }
-        break;
-        }
-    if ( sharingReq )
-        {
-        // There is sharing ongoing, return the buffered selections
-        for( TInt i(0); i < sharingReq->iSelections.Count(); i++ )
-            {
-            aMarkedItems.AppendL( sharingReq->iSelections[ i ] );
-            }
-        }
-    else
-        {
-        if ( !iReader )
-            {
-            __LOG1( "Error: %d", __LINE__ );
-            iReader = CUpnpSelectionReader::NewL( iMetadata );
-            }
-        iReader->GetSelectionIndexesL( aMarkedItems, (TUpnpMediaType)aType );
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::ChangeShareContentL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::ChangeShareContentL(
-    const RArray<TInt>& aMarkedItems,
-    const TInt aType )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    for( TInt e(0); e<aMarkedItems.Count();e++)
-        {
-        __LOG2("CUpnpContentServerHandler: received index[%d] = %d",
-            e, aMarkedItems[e] );
-        }
-
-    switch ( iHandlerState )
-        {
-    case ESchedulingSharing :
-        {
-        if ( aType == iBufferPosition )
-            {
-            if ( iSharingPhase != EShare )
-                {
-                SetSharingRequestL( aMarkedItems, aType );
-                }
-            else // iSharingPhase == EShare
-                {
-                // sanity checks
-                delete iUnsharer;
-                iUnsharer = NULL;
-                delete iContainerChecker;
-                iContainerChecker = NULL;
-
-                if ( iAo )
-                    {
-                    // iAo cannot be deleted here, request stop instead
-                    iAo->RequestStop(
-                        MUpnpSharingCallback::ESharingFullStop );
-                    }
-                // Get playlist Ids
-                CDesCArray* ids = new (ELeave) CDesCArrayFlat(4);
-                CleanupStack::PushL( ids );
-                CDesCArray* names = new (ELeave) CDesCArrayFlat(4);
-                CleanupStack::PushL( names );
-                if ( aType == EImageAndVideo )
-                    {
-                    iReader->CollectionIdsL( *ids, *names );
-                    }
-                else
-                    {
-                    iReader->PlayListIdsL( *ids, *names );
-                    }
-                // pendingSharingReq will be handled from callback
-                delete iPendingSharingReq;
-                iPendingSharingReq = NULL;
-                iPendingSharingReq = CUpnpSharingRequest::NewL( aType,
-                                                                aMarkedItems,
-                                                                ids,
-                                                                names );
-                CleanupStack::Pop( names ); // ownership transferred
-                CleanupStack::Pop( ids ); // ownership transferred
-                }
-            }
-        else
-            {
-            SetSharingRequestL( aMarkedItems, aType );
-            }
-        }
-        break;
-    case ENotActive :
-        {
-
-        delete iMetadata;
-        iMetadata = NULL;
-        iMetadata = CUpnpContentMetadataUtility::NewL();
-        iMetadata->SetCallback( this );
-        iReader->SetMetadata( iMetadata );
-
-
-        if ( iMetadata->RefreshOngoing() )
-            {
-            __LOG("CUpnpContentServerHandler: Waiting refresh 3");
-            iWait.Start();
-            }
-        SetSharingRequestL( aMarkedItems, aType );
-
-        iBufferPosition = aType;
-        // Start sharing
-        iHandlerState = ESchedulingSharing;
-
-        iSharingPhase = ECheckDefaults;
-        // start the sharing
-        DoShareL();
-
-        }
-        break;
-    default :
-        {
-        __LOG1( "Error: %d", __LINE__ );
-        }
-        break;
-
-        }
-    SetProgressL( KNoProgress );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::RefreshShareContentL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::RefreshShareContentL(
-    TInt aType )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    if ( ( aType == EImageAndVideo && iVisualSharingReq ) ||
-         ( aType == EPlaylist && iMusicSharingReq ) )
-        {
-        // no refresh available if sharing is ongoing
-        __LOG1( "Error: %d", __LINE__ );
-        User::Leave( KErrServerBusy );
-        }
-
-    if ( iMetadata->RefreshOngoing() )
-        {
-        __LOG("CUpnpContentServerHandler: Waiting refresh 1");
-        iWait.Start();
-        }
-
-    delete iReader;
-    iReader = NULL;
-    iReader = CUpnpSelectionReader::NewL( iMetadata );
-
-    RArray<TInt> selectedItems;
-    CleanupClosePushL( selectedItems );
-    CDesCArray* containers = new ( ELeave ) CDesCArrayFlat( 10 );
-    CleanupStack::PushL( containers );
-    iReader->FetchCollectionsL( containers );
-    GetSelectionIndexesL( selectedItems, aType );
-    CDesCArray* ids = new (ELeave) CDesCArrayFlat(4);
-    CleanupStack::PushL( ids );
-    CDesCArray* names = new (ELeave) CDesCArrayFlat(4);
-    CleanupStack::PushL( names );
-    iReader->CollectionIdsL( *ids, *names );
-
-    if ( aType == EImageAndVideo )
-        {
-        iVisualSharingReq = CUpnpSharingRequest::NewL( aType,
-                                                       selectedItems,
-                                                       ids,
-                                                       names );
-        }
-    else if ( aType == EPlaylist )
-        {
-        iMusicSharingReq = CUpnpSharingRequest::NewL( aType,
-                                                      selectedItems,
-                                                      ids,
-                                                      names );
-        }
-    else
-        {
-        User::Leave( KErrArgument );
-        }
-
-    CleanupStack::Pop( names ); // ownership transferred
-    CleanupStack::Pop( ids ); // ownership transferred
-    ChangeShareContentL( selectedItems, aType );
-
-    selectedItems.Reset();
-    containers->Reset();
-
-    CleanupStack::PopAndDestroy( containers );
-    CleanupStack::PopAndDestroy( &selectedItems );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::FillProgressInfoL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::FillProgressInfoL(
-    RArray<TUpnpProgressInfo>& aArr,
-    const TInt aType )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CUpnpSharingRequest* sharingReq( NULL );
-    if( iPendingSharingReq && iPendingSharingReq->iKind == aType )
-        {
-        sharingReq = iPendingSharingReq;
-        }
-    else
-        {
-        if ( aType == EImageAndVideo )
-            {
-            sharingReq = iVisualSharingReq;
-            }
-        else if ( aType == EPlaylist )
-            {
-            sharingReq = iMusicSharingReq;
-            }
-        }
-    TUpnpProgressInfo progress;
-    progress.iProgressKind = UpnpContentServer::TUpnpMediaType( aType );
-    if ( sharingReq )
-        {
-        progress.iProgressType = TUpnpProgressInfo::ESharingProgress;
-        if ( iBufferPosition == aType &&
-             iHandlerState == ESchedulingSharing &&
-             ( iAo || iUnsharer || iContainerChecker ))
-            {
-            // sharing ongoing for images
-            TInt prog ( 0 );
-            TInt progRel( 0 );
-            if ( iAo && iSharingPhase == EShare )
-                {
-                prog = iAo->SharingProgress(
-                    (TUpnpMediaType&)progress.iProgressKind );
-                progRel = ( prog * KMaxProgress ) / sharingReq->iItemCount;      
-                }
-            if ( iUnsharer &&  iSharingPhase == EUnshare  )
-                {
-                prog = iUnsharer->UnSharingProgress();
-                TInt itemNum = iUnsharer->TotalItemsForUnShare();
-                if( itemNum > 0 )
-                    {     
-                    progRel = ( prog * KMaxProgress ) / itemNum;          
-                    }
-                }   
-
-            // check that progress is between 0 and 100 %
-            if ( progRel < 0 )
-                {
-                progRel = KNoProgress;
-                __LOG1( "Error: %d", __LINE__ );
-                }
-            else if ( progRel > KMaxProgress )
-                {
-                progRel = KMaxProgress;
-                __LOG1( "Error: %d", __LINE__ );
-                }
-            progress.iProgress = progRel;
-            }
-        else
-            {
-            // buffer is pending
-            progress.iProgressType = TUpnpProgressInfo::ESharingProgress;
-            progress.iProgress = KNoProgress;
-            }
-        }
-    else
-        {
-        progress.iProgressType = TUpnpProgressInfo::EVisualStatus;
-        TInt state( EShareNone );
-
-        if ( aType == EImageAndVideo )
-            {
-            iReader->GetVisualSharingStateL( state );
-            }
-        else
-            {
-            iReader->GetMusicSharingStateL( state );
-            }
-
-        progress.iProgress = state;
-        }
-    aArr.AppendL( progress );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::CanStop
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TBool CUpnpContentServerHandler::CanStop() const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TBool ret( EFalse );
-    if ( !( iVisualSharingReq || iMusicSharingReq  ) )
-        {
-        __LOG("CUpnpContentServerHandler: CanStop(): 1");
-        ret = ETrue;
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return ret;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::RefreshDoneL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::RefreshDoneL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    iMetadata->SetCallback( this );
-    if ( iWait.IsStarted() )
-        {
-        iWait.AsyncStop();
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::CompleteSharingOperationL
-// This should be called from active objects owned by handler
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::CompleteSharingOperationL(
-    const TInt& aErr, const TInt& aType )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    if ( aErr != KErrNone )
-        {
-        __LOG1( "Error: %d", aErr );
-        }
-    if ( iWait.IsStarted() )
-        {
-        iWait.AsyncStop();
-        }
-    else if ( iStartupCleaning )
-        {
-        iStartupCleaning = EFalse;
-        }
-
-    else if ( aErr && aErr != KErrCancel )
-        {
-        // Cancel is handled below
-        HandleError( aErr );
-        }
-    else
-        {
-        if ( iSharingPhase == ECheckDefaults )
-            {
-            iHandlerState = ESchedulingSharing;
-            iSharingPhase = EUnshare;
-            }
-        else if ( iSharingPhase == EUnshare )
-            {
-            iHandlerState = ESchedulingSharing;
-            iSharingPhase = EShare;
-
-            }
-        else if ( iSharingPhase == EShare )
-            {
-            switch ( aType )
-                {
-            case EImageAndVideo :
-                {
-                delete iVisualSharingReq;
-                iVisualSharingReq = NULL;
-                SetProgressL( KNoProgress );
-                }
-                break;
-            case EPlaylist :
-                {
-                delete iMusicSharingReq;
-                iMusicSharingReq = NULL;
-                SetProgressL( KNoProgress );
-                }
-                break;
-            default :
-                {
-                __LOG1( "Error: %d", __LINE__ );
-                }
-                break;
-                }
-            if ( aType != iBufferPosition )
-                {
-                __LOG1( "Error: %d", __LINE__ );
-                }
-
-            if ( aErr == KErrNone )
-                {
-                iErrorToClient = aErr;
-                iBufferPosition = (iBufferPosition + 1)%KRequestBufferSize;
-                SetProgressL( KNoProgress );
-                }
-            else
-                {
-                if ( iPendingSharingReq )
-                    {
-                    if ( iPendingSharingReq->iKind == EImageAndVideo )
-                        {
-                        delete iVisualSharingReq;
-                        iVisualSharingReq = NULL;
-                        iVisualSharingReq = iPendingSharingReq;
-                        }
-                    else
-                        {
-                        delete iMusicSharingReq;
-                        iMusicSharingReq = NULL;
-                        iMusicSharingReq = iPendingSharingReq;
-                        }
-                    iPendingSharingReq = NULL;
-                    }
-                }
-
-            iDefaultContainerIds.Reset();
-            if ( ! ( iVisualSharingReq || iMusicSharingReq ))
-                {
-                iHandlerState = ENotActive;
-                iSharingPhase = ESharingInActive;
-                if ( CanStop() && iServer && !iContentSharingObserver )
-                    {
-                    // client application is exited, no sharing ongoing
-                    // -> stop the server
-                    iServer->Stop();
-                    }
-                }
-            else
-                {
-                iSharingPhase = ECheckDefaults;
-                iHandlerState = ESchedulingSharing;
-                }
-            }
-        else
-            {
-            __LOG1( "Error: %d", __LINE__ );
-            }
-
-        if ( iHandlerState != ENotActive )
-            {
-            DoShareL();
-            }
-
-        }
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::CancelSharingOperationL
-// This should be called from active objects owned by handler
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::CancelSharingOperationL(
-    const TInt& /*aErr*/ )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::SetProgressL
-// This should be called from active objects owned by handler
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::SetProgressL(
-    const TInt& aProgress )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CUpnpSharingRequest* sharingReq( NULL );
-    if( iPendingSharingReq && iPendingSharingReq->iKind == iBufferPosition )
-        {
-        sharingReq = iPendingSharingReq;
-        }
-    else
-        {
-        if ( iBufferPosition == EPlaylist )
-            {
-            sharingReq = iMusicSharingReq;
-            }
-        else if ( iBufferPosition == EImageAndVideo )
-            {
-            sharingReq = iVisualSharingReq;
-            }
-        }
-
-    if ( sharingReq )
-        {
-        sharingReq->iProgress = aProgress;
-        }
-
-    TProgressInfos progressArr;
-    CleanupClosePushL( progressArr );
-
-    FillProgressInfoL( progressArr, EImageAndVideo );
-    FillProgressInfoL( progressArr, EPlaylist );
-
-    TUpnpProgress finalProg;
-    finalProg.iError = iErrorToClient;
-    iErrorToClient = KErrNone;
-    finalProg.iImageVideoProgress = progressArr[ 0 ];
-    finalProg.iMusicProgress = progressArr[ 1 ];
-
-    TPckgBuf<TUpnpProgress> progressBuf( finalProg );
-
-    TInt err = iProgressProperty.Set( KUpnpContentServerCat,
-                                      ESharingProgress,
-                                      progressBuf  );
-    if ( err != KErrNone )
-        {
-        __LOG1( "Error: %d", err );
-        }
-    CleanupStack::PopAndDestroy( &progressArr );
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::DoShareL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::DoShareL( )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TInt err( KErrNone );
-
-    iHandlerState = ESchedulingSharing;
-
-    if ( iSharingPhase == ECheckDefaults )
-        {
-        iDefaultContainerIds.Reset();
-        delete iContainerChecker;
-        iContainerChecker = NULL;
-        iContainerChecker = new (ELeave) CUpnpContainerCheckerAo( this );
-        iContainerChecker->ValidateContainerStructureL(
-            &iDefaultContainerIds );
-        }
-    else if ( iSharingPhase == EUnshare )
-        {
-        delete iContainerChecker;
-        iContainerChecker = NULL;
-        delete iUnsharer;
-        iUnsharer = NULL;
-        iUnsharer = new ( ELeave ) CUpnpUnsharerAo(
-            this,
-            CActive::EPriorityStandard );
-        TInt id = GetContainerId( iBufferPosition );
-        if ( id == KErrNotFound )
-            {
-            User::Leave( KErrCorrupt );
-            }
-        iUnsharer->EmptyContainer( id );
-        }
-    else if ( iSharingPhase == EShare )
-        {
-        delete iUnsharer;
-        iUnsharer = NULL;
-        delete iAo;
-        iAo = NULL;
-        iAo = CUpnpContentSharingAo::NewL( this, iMetadata );
-        TInt id = GetContainerId( iBufferPosition );
-        if ( id == KErrNotFound )
-            {
-            User::Leave( KErrCorrupt );
-            }
-        // iBufferPosition is updated in CompleteSharingOperationL
-        switch( iBufferPosition )
-            {
-        case EImageAndVideo :
-            {
-            TRAP( err, iAo->InitializeL( ( TUpnpMediaType )
-                                         iVisualSharingReq->iKind,
-                                         iVisualSharingReq->iSelections,
-                                         *iVisualSharingReq->iObjectIds,
-                                         *iVisualSharingReq->iObjectNames,
-                                         id ));
-            // always show something in progress dialog -> add 1
-            TRAP( err, iVisualSharingReq->iItemCount =
-                  iAo->SelectionObjectCountL(
-                      ( TUpnpMediaType )iBufferPosition ) +1 );
-            iAo->ShareFiles(); // start sharing
-            }
-            break;
-        case EPlaylist :
-            {
-            TRAP( err, iAo->InitializeL( ( TUpnpMediaType )
-                                         iMusicSharingReq->iKind,
-                                         iMusicSharingReq->iSelections,
-                                         *iMusicSharingReq->iObjectIds,
-                                         *iMusicSharingReq->iObjectNames,
-                                         id ));
-            // always show something in progress dialog -> add 1
-            TRAP( err, iMusicSharingReq->iItemCount =
-                  iAo->SelectionObjectCountL(
-                      ( TUpnpMediaType )iBufferPosition ) +1);
-            iAo->ShareFiles(); // start sharing
-            }
-            break;
-        default:
-            {
-            __LOG1( "Error: %d", __LINE__ );
-            }
-            break;
-            }
-        }
-    else
-        {
-        __LOG1( "Error: %d", __LINE__ );
-        }
-
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::Cleanup
-// Cleanup depending on state
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::Cleanup()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    if( iSharingPhase == EShare )
-        {
-        if( iAo )
-            {
-            iAo->RequestStop(
-                MUpnpSharingCallback::ESharingFullStop );
-            }
-        }
-    delete iContainerChecker;
-    iContainerChecker = NULL;
-    delete iUnsharer;
-    iUnsharer = NULL;
-
-    delete iVisualSharingReq;
-    iVisualSharingReq = NULL;
-    delete iMusicSharingReq;
-    iMusicSharingReq = NULL;
-    delete iPendingSharingReq;
-    iPendingSharingReq = NULL;
-
-    // reset state variables
-    iHandlerState = ENotActive;
-    iSharingPhase = ESharingInActive;
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::GetContainerId
-// get id from list
-// --------------------------------------------------------------------------
-//
-TInt CUpnpContentServerHandler::GetContainerId( const TInt aType ) const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TInt id( KErrNotFound );
-    if ( aType == EImageAndVideo )
-        {
-        id = iDefaultContainerIds[
-            CUpnpContainerCheckerAo::EImageAndVideo ];
-        }
-    else if ( aType == EPlaylist )
-        {
-        id = iDefaultContainerIds[ CUpnpContainerCheckerAo::EMusic ];
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return id;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::ConnectionLost
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TBool CUpnpContentServerHandler::ConnectionLostL( )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TBool ret( EFalse );
-    if ( iHandlerState != ENotActive )
-        {
-        if ( iSharingPhase == EShare )
-            {
-            __LOG("iSharingPhase == EShare");
-            ret = ETrue;
-            iAo->RequestStop( MUpnpSharingCallback::ESharingPause );
-            }
-        else if ( iSharingPhase == ECheckDefaults )
-            {
-            __LOG("iSharingPhase == ECheckDefaults");
-            iContainerChecker->RequestStop(
-                MUpnpSharingCallback::ESharingPause );
-            }
-        else if ( iSharingPhase == EUnshare )
-            {
-            __LOG("iSharingPhase == EUnshare");
-            iUnsharer->RequestStop( MUpnpSharingCallback::ESharingPause );
-            }
-
-        }
-    else
-        {
-        __LOG("else ");
-        iMediaServer = new (ELeave) RUpnpMediaServerClient();
-        TInt err( iMediaServer->Connect() );
-        TInt stat( RUpnpMediaServerClient::EStopped );
-        if ( !err )
-            {
-            err = iMediaServer->Status( stat );
-            if ( !err && stat == RUpnpMediaServerClient::EStartedOnline )
-                {
-                iMediaServer->Stop( RUpnpMediaServerClient::EStopSilent );
-                iMediaServer->Close();
-                delete iMediaServer;
-                iMediaServer = NULL;
-                }
-            }
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return ret;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::SetSharingRequestL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::SetSharingRequestL(
-    const RArray<TInt>& aMarkedItems,
-    const TInt aType )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CDesCArray* ids = new (ELeave) CDesCArrayFlat(4);
-    CleanupStack::PushL( ids );
-    CDesCArray* names = new (ELeave) CDesCArrayFlat(4);
-    CleanupStack::PushL( names );
-    if ( aType == EImageAndVideo )
-        {
-        iReader->CollectionIdsL( *ids, *names );
-        delete iVisualSharingReq;
-        iVisualSharingReq = NULL;
-        iVisualSharingReq = CUpnpSharingRequest::NewL( aType,
-                                                       aMarkedItems,
-                                                       ids,
-                                                       names );
-        }
-    else
-        {
-        iReader->PlayListIdsL( *ids, *names );
-        delete iMusicSharingReq;
-        iMusicSharingReq = NULL;
-        iMusicSharingReq = CUpnpSharingRequest::NewL( aType,
-                                                      aMarkedItems,
-                                                      ids,
-                                                      names );
-        }
-    CleanupStack::Pop( names ); // ownership transferred
-    CleanupStack::Pop( ids ); // ownership transferred
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::ValidateDefaultContainersL
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerHandler::ValidateDefaultContainersL( )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    if ( iSharingPhase != ECheckDefaults )
-        {
-        iStartupCleaning = ETrue;
-        delete iContainerChecker;
-        iContainerChecker = NULL;
-        iContainerChecker = new (ELeave) CUpnpContainerCheckerAo( this );
-        iContainerChecker->SetPriority( CActive::EPriorityUserInput );
-        iContainerChecker->ValidateContainerStructureL(
-            NULL );
-
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerHandler::HandleError
-// ( other items are commented in header )
-// --------------------------------------------------------------------------
-//
-
-void CUpnpContentServerHandler::HandleError( TInt aError )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    if( iHandlerState != ENotActive )
-        {
-        Cleanup();
-        iHandlerState = ENotActive;
-        iSharingPhase = ECheckDefaults;
-        iErrorToClient = aError;
-        TRAP_IGNORE( SetProgressL( KNoProgress ) );
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// End of file
+/*
+* Copyright (c) 2006-2007 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:      Content sharing servers main scheduler function
+ *
+*/
+
+
+
+
+
+#include <e32debug.h>
+#include <e32property.h>
+#include "upnpsharingalgorithmfactory.h"
+#include "upnpcdsliteobject.h"
+#include "upnpcdsliteobjectarray.h"
+#include <mclfitemlistmodel.h>
+#include <escapeutils.h>            // ConvertFromUnicodeToUtf8L
+
+#include "upnpcommonutils.h"
+#include "upnpcontentserverdefs.h"
+#include "upnpcontentserverhandler.h"
+#include "upnpselectionreader.h"
+#include "upnpcontentserverclient.h"
+#include "upnpcontentserver.h"
+#include "upnpcontentmetadatautility.h"
+
+_LIT( KComponentLogfile, "contentserver.txt");
+#include "upnplog.h"
+
+// CONSTANTS
+const TInt KNoProgress = -1;
+const TInt KZeroProgress = 0;
+const TInt KArrayGranularity = 10;
+
+_LIT8( KAudio, "audio" );
+_LIT8( KVideo, "video" );
+_LIT8( KImage, "image" );
+
+using namespace UpnpContentServer;
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::NewL
+// 2-phased constructor.
+// --------------------------------------------------------------------------
+//
+CUpnpContentServerHandler* CUpnpContentServerHandler::NewL(
+    CUpnpContentServer* aServer )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    CUpnpContentServerHandler* self =
+        new (ELeave) CUpnpContentServerHandler( aServer );
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(); // self
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::CUpnpContentServerHandler()
+// C++ constructor.
+// --------------------------------------------------------------------------
+//
+CUpnpContentServerHandler::CUpnpContentServerHandler(
+    CUpnpContentServer* aServer ) :
+    iServer( aServer ),
+    iContentSharingObserver( NULL ),
+    iOngoingSharingType( KErrNotFound ),
+    iErrorToClient( KErrNone ),
+    iSharingAlgorithm( NULL )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    ResetPendingRequestInfo();
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::ConstructL
+// 2nd phase constructor.
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::ConstructL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    static _LIT_SECURITY_POLICY_PASS(KAllowAllPolicy);
+    static _LIT_SECURITY_POLICY_S0(KThisProcessPolicy,
+                                   KUpnpContentServerCat.iUid );
+
+    // define progress property to be a byte array, allocating mem
+    TInt err = iProgressProperty.Define( KUpnpContentServerCat,
+                                         ESharingProgress,
+                                         RProperty::EByteArray,
+                                         KAllowAllPolicy,
+                                         KThisProcessPolicy,
+                                         sizeof( TUpnpProgress ) );
+    if ( err != KErrNone )
+        {
+        __LOG1( "Error: %d", err );
+        }
+    if ( err!=KErrAlreadyExists )
+        {
+        User::LeaveIfError( err );
+        }
+
+    // Create selection reader
+    iReader = CUpnpSelectionReader::NewL();
+
+    // reset progress information
+    SetProgressL( KNoProgress );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::InitializeL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::InitializeL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Create MUpnpSharingAlgorithm
+    if ( !iSharingAlgorithm )
+        {
+        iSharingAlgorithm = 
+                CUPnPSharingAlgorithmFactory::NewSharingApiL();
+        }
+    // Create CUpnpContentSharerAo
+    if ( !iAo )
+        {
+        iAo = CUpnpContentSharerAo::NewL( this, iSharingAlgorithm );
+        }
+    // Create CUpnpContentMetadataUtility
+    if ( !iMetadata )
+        {
+        iMetadata = CUpnpContentMetadataUtility::NewL();
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::~CUpnpContentServerHandler()
+// C++ destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpContentServerHandler::~CUpnpContentServerHandler()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    if ( iSharingAlgorithm )
+        {
+        iSharingAlgorithm->Close();
+        }
+    
+    delete iAo;
+    delete iMetadata;
+    delete iReader;
+    delete iMediaServer;
+
+    iPendingSharingReqInfo.iMarkedItems.Close();
+    delete iMusicSharingReq;
+    delete iVisualSharingReq;
+    iProgressProperty.Delete( KUpnpContentServerCat, ESharingProgress );
+    iProgressProperty.Close();
+    iServer = NULL;
+        
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::SetContentSharingObserverL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::SetContentSharingObserverL(
+    MUpnpContentSharingObserver* aObserver )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    iContentSharingObserver = aObserver; // can be NULL
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::GetSelectionContentL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::GetSelectionContentL(
+    const TInt& aContainerType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    // There might be many containers -> 10 is OK for granularity
+    CDesCArray* containers = 
+        new ( ELeave ) CDesCArrayFlat( KArrayGranularity );
+    CleanupStack::PushL( containers );
+
+    switch ( aContainerType )
+        {
+        case EImageAndVideo :
+            {
+            iReader->FetchCollectionsL( containers );
+            break;
+            }
+        case EPlaylist :
+            {
+            iReader->FetchPlaylistsL( containers );
+            break;
+            }
+        default :
+            {
+            CleanupStack::PopAndDestroy( containers );
+            __LOG1( "Error: %d", __LINE__ );
+            break;
+            }
+        }
+    if ( iContentSharingObserver )
+        {
+        iContentSharingObserver->CompleteSelectionContentL( *containers );
+        }
+
+    CleanupStack::PopAndDestroy( containers );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::GetSelectionIndexesL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::GetSelectionIndexesL(
+    RArray<TInt>& aMarkedItems,
+    const TInt aType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    CUpnpSharingRequest* sharingReq( NULL );
+    switch ( aType )
+        {
+        case EImageAndVideo :
+            {
+            if ( iVisualSharingReq )
+                {
+                sharingReq = iVisualSharingReq;
+                }
+            break;
+            }
+        case EPlaylist :
+            {
+            if ( iMusicSharingReq )
+                {
+                sharingReq = iMusicSharingReq;
+                }
+            break;
+            }
+        default :
+            {
+            __LOG1( "Error: %d", __LINE__ );
+            break;
+            }
+        }
+    
+    if ( sharingReq && 
+        sharingReq->iClfIds && 
+        sharingReq->iSharingType == EShareMany )
+        {
+        // There is sharing ongoing, return the buffered selections
+        for( TInt i(0); i < sharingReq->iClfIds->MdcaCount(); i++ )
+            {
+            TInt index = iReader->GetSelectionIndexL( 
+                    (TUpnpMediaType)aType, 
+                    sharingReq->iClfIds->MdcaPoint( i ) );
+            if ( index != KErrNotFound )
+                {
+                aMarkedItems.AppendL( index );
+                }
+            }
+        }
+    else
+        {
+        if ( !iReader )
+            {
+            __LOG1( "Error: %d", __LINE__ );
+            iReader = CUpnpSelectionReader::NewL();
+            }
+        iReader->GetSelectionIndexesL( aMarkedItems, (TUpnpMediaType)aType );
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::ChangeShareContentL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::ChangeShareContentL(
+    const RArray<TInt>& aMarkedItems,
+    const TInt aType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    for( TInt e(0); e<aMarkedItems.Count();e++)
+        {
+        __LOG2("CUpnpContentServerHandler: received index[%d] = %d",
+            e, aMarkedItems[e] );
+        }    
+    
+    if ( iOngoingSharingType != KErrNotFound )
+        {
+        // sharing process ongoing, check that if selection is changed
+        // to ongoing sharing type
+        if ( aType == iOngoingSharingType && iAo->SharingOngoing() )
+            {
+            // save pending request info
+            SavePendingRequestInfoL( aMarkedItems, aType );
+            // cancel Ao and create new sharing request in callback
+            iAo->StopSharing();
+            }
+        else
+            {
+            SetSharingRequestL( aMarkedItems, aType );
+            }
+        }
+    else
+        {
+        // Not active, ie. no sharing ongoing        
+        SetSharingRequestL( aMarkedItems, aType );
+        iOngoingSharingType = aType;
+
+        // start the sharing
+        DoShare();
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::RefreshShareContentL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::RefreshShareContentL(
+    TInt aType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    if ( ( aType == EImageAndVideo && iVisualSharingReq ) ||
+         ( aType == EPlaylist && iMusicSharingReq ) )
+        {
+        // no refresh available if sharing is ongoing
+        __LOG1( "Error: %d", __LINE__ );
+        User::Leave( KErrServerBusy );
+        }
+
+    delete iReader;
+    iReader = NULL;
+    iReader = CUpnpSelectionReader::NewL();
+
+    if ( aType == EImageAndVideo )
+        {
+        RArray<TInt> markedItems;
+        CleanupClosePushL( markedItems );
+        
+        // Get selected indexes and create new sharing request
+        GetSelectionIndexesL( markedItems, aType );
+        SetSharingRequestL( markedItems, aType );
+
+        CleanupStack::PopAndDestroy( &markedItems );
+        }
+    else if ( aType == EPlaylist )
+        {
+        RArray<TInt> markedItems;
+        CleanupClosePushL( markedItems );
+        
+        // Get selected indexes and create new sharing request
+        GetSelectionIndexesL( markedItems, aType );
+        SetSharingRequestL( markedItems, aType );
+        
+        CleanupStack::PopAndDestroy( &markedItems );
+        }
+    else
+        {
+        User::Leave( KErrArgument );
+        }
+
+    // if no refreshes ongoing, start sharing
+    if ( iOngoingSharingType == KErrNotFound )
+        {
+        iOngoingSharingType = aType;
+        DoShare();
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::CanStop
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TBool CUpnpContentServerHandler::CanStop() const
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TBool ret( EFalse );
+    if ( !( iVisualSharingReq || iMusicSharingReq  ) )
+        {
+        __LOG("CUpnpContentServerHandler: CanStop(): 1");
+        ret = ETrue;
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::CompleteSharingOperationL
+// This should be called from active objects owned by handler
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::CompleteSharingOperationL(
+    const TInt& aErr, const TInt& aType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    switch ( aErr )
+        {
+        case KErrNone:
+            {
+            iErrorToClient = KErrNone;
+            if ( aType == EImageAndVideo )
+                {
+                // Reset sharing request object 
+                delete iVisualSharingReq;
+                iVisualSharingReq = NULL;
+                
+                // If there is pending music request, process it next 
+                if ( iMusicSharingReq )
+                    {
+                    iOngoingSharingType = EPlaylist;
+                    DoShare();
+                    }
+                else
+                    {
+                    iOngoingSharingType = KErrNotFound;
+                    }
+                }
+            else if ( aType == EPlaylist )
+                {
+                // Reset sharing request object 
+                delete iMusicSharingReq;
+                iMusicSharingReq = NULL;
+                
+                // If there is pending music request, process it next 
+                if ( iVisualSharingReq )
+                    {
+                    iOngoingSharingType = EImageAndVideo;
+                    DoShare();
+                    }
+                else
+                    {
+                    iOngoingSharingType = KErrNotFound;
+                    }
+                }
+            else 
+                {
+                iOngoingSharingType = KErrNotFound;
+                }
+            break;
+            }
+        case KErrCancel:
+            {
+            // User reselected currently ongoing sharing, handle it next
+            if ( iPendingSharingReqInfo.iMarkedItems.Count() )
+                {
+                // create sharing request from pending info
+                TRAPD( 
+                    err, 
+                    SetSharingRequestL( 
+                        iPendingSharingReqInfo.iMarkedItems,
+                        iPendingSharingReqInfo.iMediaType ) 
+                    );
+                if ( err )
+                    {
+                    HandleError( err );
+                    }
+                else
+                    {
+                    // no errors, reset the pending request info and start 
+                    // sharing
+                    ResetPendingRequestInfo();
+                    DoShare();
+                    }
+                }
+            else
+                {
+                iOngoingSharingType = KErrNotFound;
+                }
+            break;
+            }
+        default:
+            {
+            __LOG1( "CompleteSharingOperationL: %d", aErr );
+            HandleError( aErr );
+            break;
+            }
+        }
+    
+    if ( iOngoingSharingType == KErrNotFound )
+        {
+        // Reset the progress info to no progress.
+        TRAP_IGNORE( 
+            SetProgressL( KNoProgress )
+            );
+        if ( CanStop() && iServer && !iContentSharingObserver )
+            {
+            // client application is exited, no sharing ongoing
+            // -> stop the server
+            iServer->Stop();
+            }
+        }
+    
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::CancelSharingOperationL
+// This should be called from active objects owned by handler
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::CancelSharingOperationL(
+    const TInt& /*aErr*/ )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::SetProgressL
+// This should be called from active objects owned by handler
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::SetProgressL( const TInt& aProgress )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    
+    // Initilialize music sharing progress information
+    TUpnpProgressInfo playlistProg;
+    playlistProg.iProgress = KZeroProgress;
+    playlistProg.iProgressKind = EPlaylist;
+    playlistProg.iProgressType = TUpnpProgressInfo::EVisualStatus;
+    
+    // Set music sharing progress information
+    if ( iMusicSharingReq && aProgress != KNoProgress )
+        {
+        playlistProg.iProgressType = TUpnpProgressInfo::ESharingProgress;
+        if ( iOngoingSharingType == EPlaylist )
+            {
+            playlistProg.iProgress = aProgress;
+            }
+        }
+    else
+        {
+        TInt state( EShareNone );
+        iReader->GetMusicSharingStateL( state );
+        playlistProg.iProgress = state;
+        }
+    
+    // Initilialize visual sharing progress information
+    TUpnpProgressInfo visualProg;
+    visualProg.iProgress = KZeroProgress;
+    visualProg.iProgressKind = EImageAndVideo;
+    visualProg.iProgressType = TUpnpProgressInfo::EVisualStatus;
+    
+    // Set visual sharing progress information
+    if ( iVisualSharingReq && aProgress != KNoProgress )
+        {
+        visualProg.iProgressType = TUpnpProgressInfo::ESharingProgress;
+        if ( iOngoingSharingType == EImageAndVideo)
+            {
+            visualProg.iProgress = aProgress;
+            }
+        }
+    else
+        {
+        TInt state( EShareNone );
+        iReader->GetVisualSharingStateL( state );
+        visualProg.iProgress = state;
+        }
+
+    // Create total progress
+    TUpnpProgress totalProg;
+    totalProg.iError = iErrorToClient;
+    iErrorToClient = KErrNone;
+    
+    totalProg.iImageVideoProgress = visualProg;
+    totalProg.iMusicProgress = playlistProg;
+
+    // Set the progress property so that Ui updates itself
+    TPckgBuf<TUpnpProgress> progressBuf( totalProg );
+    TInt err = iProgressProperty.Set( KUpnpContentServerCat,
+                                      ESharingProgress,
+                                      progressBuf  );
+    if ( err != KErrNone )
+        {
+        __LOG1( "Error: %d", err );
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::DoShare
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::DoShare()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    switch( iOngoingSharingType )
+        {
+        case EImageAndVideo :
+            {
+            // start sharing and put progress
+            iAo->StartSharing( iVisualSharingReq );
+            break;
+            }
+        case EPlaylist :
+            {
+            // start sharing and put progress
+            iAo->StartSharing( iMusicSharingReq );
+            break;
+            }
+        default:
+            {
+            __LOG1( "Error: %d", __LINE__ );
+            break;
+            }
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::Cleanup
+// Cleanup depending on state
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::Cleanup()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    if( iAo->SharingOngoing() )
+        {
+        iAo->StopSharing();
+        }
+
+    delete iVisualSharingReq;
+    iVisualSharingReq = NULL;
+    delete iMusicSharingReq;
+    iMusicSharingReq = NULL;
+    ResetPendingRequestInfo();
+
+    // reset state variables
+    iOngoingSharingType = KErrNotFound;
+    
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::ConnectionLost
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TBool CUpnpContentServerHandler::ConnectionLostL( )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TBool ret( EFalse );
+
+    if ( iOngoingSharingType != KErrNotFound )
+        {
+        ret = ETrue;
+        if ( iAo->SharingOngoing() )
+            {
+            iAo->StopSharing();
+            }
+        }
+    else
+        {
+        TInt err( iMediaServer->Connect() );
+        TInt stat( RUpnpMediaServerClient::EStopped );
+        if ( !err )
+            {
+            err = iMediaServer->Status( stat );
+            if ( !err && stat == RUpnpMediaServerClient::EStartedOnline )
+                {
+                iMediaServer->Stop( RUpnpMediaServerClient::EStopSilent );
+                iMediaServer->Close();
+                delete iMediaServer;
+                iMediaServer = NULL;
+                }
+            }
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return ret;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::SetSharingRequestL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerHandler::SetSharingRequestL(
+    const RArray<TInt>& aMarkedItems,
+    const TInt aType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Create sharing request
+    CreateSharingRequestL( aType, SharingType( aMarkedItems ) );
+
+    // Get user selected filenames to be shared
+    CDesCArray* filenamesToBeShared = 
+        new (ELeave) CDesCArrayFlat( KArrayGranularity );
+    CleanupStack::PushL( filenamesToBeShared );
+    CDesCArray* clfIds =
+        new (ELeave) CDesCArrayFlat( KArrayGranularity );
+    CleanupStack::PushL( clfIds );
+
+    GetSelectionFilenamesL( 
+            aMarkedItems, 
+            aType, 
+            SharingType( aMarkedItems ), 
+            *filenamesToBeShared,
+            *clfIds );
+
+    // Get currently shared filenames
+    CUpnpCdsLiteObjectArray& currentlySharedContent = 
+        iSharingAlgorithm->ReadSharedContent();
+        
+    // Compare and create unshare/share arrays
+    RArray<TFileName>* shareArr = new ( ELeave ) RArray<TFileName>;
+    CleanupStack::PushL( shareArr );
+    RArray<TFileName>* unshareArr = new ( ELeave ) RArray<TFileName>;
+    CleanupStack::PushL( unshareArr );
+
+    CompareCdsToClfL( 
+            *filenamesToBeShared, 
+            currentlySharedContent,
+            *shareArr,
+            *unshareArr,
+            (TUpnpMediaType)aType );    
+    
+    // Set sharing request information arrays:
+    // shareArr, unshareArr and clfIds ownership transferred.
+    SetSharingRequestInfo( 
+        aType, 
+        shareArr, 
+        unshareArr, 
+        clfIds );
+
+    // cleanup
+    CleanupStack::Pop( unshareArr ); // ownership transferred to shar.request
+    CleanupStack::Pop( shareArr );   // ownership transferred to shar.request
+    CleanupStack::Pop( clfIds );     // ownership transferred to shar.request
+    CleanupStack::PopAndDestroy( filenamesToBeShared );
+    
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::HandleError
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::HandleError( TInt aError )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    
+    // cleanup if some error occurred while sharing
+    if( iOngoingSharingType != KErrNotFound )
+        {
+        Cleanup();
+        iErrorToClient = aError;
+        // reset progress information
+        TRAP_IGNORE( SetProgressL( KNoProgress ) );
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::GetSelectionFilenamesL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::GetSelectionFilenamesL(
+    const RArray<TInt>& aMarkedItems,
+    const TInt aType,
+    const TInt aSharingType,
+    CDesCArray& aFilenames,
+    CDesCArray& aClfIds )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Collect all the necessary filenames and clfIds depending on 
+    // the user selection.
+    switch ( aSharingType )
+        {
+        case EShareAll:
+            {
+            // All files of the selected playlists/albums should be 
+            // shared
+            if ( aType == EImageAndVideo )
+                {
+                GetAllImageAndVideoFilenamesL( aFilenames );
+                }
+            else if ( aType == EPlaylist )
+                {
+                GetAllMusicFilenamesL( aFilenames );
+                }
+            break;
+            }
+        case EShareMany:
+            {
+            // Selected some of the playlists/albums
+            if ( aType == EImageAndVideo )
+                {
+                GetSelectedImgAndVideoFilenamesL( 
+                    aMarkedItems, 
+                    aFilenames,
+                    aClfIds );
+                }
+            else if ( aType == EPlaylist )
+                {
+                GetSelectedMusicFilenamesL( 
+                    aMarkedItems,
+                    aFilenames,
+                    aClfIds );
+                }
+            break;
+            }
+        case EShareNone:
+            {
+            // No selections, do nothing
+            break;
+            }
+        default:
+            {
+            // do nothing
+            break;
+            }
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::GetAllImageAndVideoFilenamesL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::GetAllImageAndVideoFilenamesL(
+    CDesCArray& aFilenames )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Fetch all the image files
+    const MCLFItemListModel* imageFiles = iMetadata->ImageFiles();
+    if ( imageFiles )
+        {
+        TInt imageCount = imageFiles->ItemCount();
+        __LOG1( "CUpnpContentServerHandler::GetAllImageAndVideoFilenamesL \
+                    imageCount=%d", imageCount );
+                    
+        // Append all image files to aFilenames
+        for ( TInt i=0; i < imageCount; i++ )
+            {
+            // get the filename from clf item
+            TPtrC fullFilename;
+            imageFiles->Item(i).GetField( 
+                ECLFFieldIdFileNameAndPath,
+                fullFilename );
+            aFilenames.AppendL( fullFilename );
+            }    
+        }
+        
+    // Fetch all the video files
+    const MCLFItemListModel* videoFiles = iMetadata->VideoFiles();
+    if ( videoFiles )
+        {
+        TInt videoCount = videoFiles->ItemCount();
+        __LOG1( "CUpnpContentServerHandler::GetAllImageAndVideoFilenamesL \
+                    videoCount=%d", videoCount );
+                    
+        // Append all video files to aFilenames
+        for ( TInt i=0; i < videoCount; i++ )
+            {
+            // get the filename from clf item
+            TPtrC fullFilename;
+            videoFiles->Item(i).GetField( 
+                ECLFFieldIdFileNameAndPath,
+                fullFilename );
+            aFilenames.AppendL( fullFilename );
+            }
+        }
+        
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::GetAllMusicFilenamesL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::GetAllMusicFilenamesL(
+    CDesCArray& aFilenames )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Fetch all the music files...
+    const MCLFItemListModel* musicFiles = iMetadata->MusicFiles();
+    if ( musicFiles )
+        {
+        TInt musicCount = musicFiles->ItemCount();
+        __LOG1( "CUpnpContentServerHandler::GetAllMusicFilenamesL \
+                    musicCount=%d", musicCount );
+                    
+        // Append all music files to aFilenames
+        for ( TInt i=0; i < musicCount; i++ )
+            {
+            // get the filename from clf item
+            TPtrC fullFilename;
+            musicFiles->Item(i).GetField( 
+                ECLFFieldIdFileNameAndPath,
+                fullFilename );
+            aFilenames.AppendL( fullFilename );
+            }
+        }
+        
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::GetSelectedImgAndVideoFilenamesL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::GetSelectedImgAndVideoFilenamesL(
+    const RArray<TInt>& aMarkedItems,
+    CDesCArray& aFilenames,
+    CDesCArray& aClfIds )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Go though all the selected collections and fetch collection ids and 
+    // items.
+    TInt markedCount = aMarkedItems.Count();
+    for ( TInt i=0; i < markedCount; i++ )
+        {
+        CDesCArray* collFilenames = 
+            new (ELeave) CDesCArrayFlat( KArrayGranularity );
+        CleanupStack::PushL( collFilenames );
+
+        // find out collection id and items
+        TPtrC collId = iReader->GetCollectionItemsL( 
+                            aMarkedItems[i], 
+                            *collFilenames );        
+        if ( collId.Length() )
+            {
+            // collection id found, append it to aClfIds
+            aClfIds.AppendL( collId );
+
+            // append all collection items to aFilenames
+            TInt collFileCount = collFilenames->Count();
+            for (TInt j=0; j < collFileCount; j++ )
+                {
+                aFilenames.AppendL( collFilenames->MdcaPoint( j ) );
+                }
+            }
+        CleanupStack::PopAndDestroy( collFilenames );
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::GetSelectedMusicFilenamesL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::GetSelectedMusicFilenamesL(
+    const RArray<TInt>& aMarkedItems,
+    CDesCArray& aFilenames,
+    CDesCArray& aClfIds )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    
+    // Go though all the selected playlists and fetch playlist ids and 
+    // items.
+    TInt markedCount = aMarkedItems.Count();
+    for ( TInt i=0; i < markedCount; i++ )
+        {
+        CDesCArray* plFilenames = 
+            new (ELeave) CDesCArrayFlat( KArrayGranularity );
+        CleanupStack::PushL( plFilenames );
+
+        // find out playlist id and items
+        TPtrC plId = iReader->GetPlaylistItemsL( 
+                            aMarkedItems[i],
+                            *plFilenames );
+        
+        if ( plId.Length() )
+            {
+            // playlist id found, append it to aClfIds
+            aClfIds.AppendL( plId );
+
+            // append all playlist items to aFilenames
+            TInt plFileCount = plFilenames->Count();
+            for (TInt j=0; j < plFileCount; j++ )
+                {
+                aFilenames.AppendL( plFilenames->MdcaPoint( j ) );
+                }            
+            }
+
+        CleanupStack::PopAndDestroy( plFilenames );
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::CompareCdsToClfL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::CompareCdsToClfL( 
+    CDesCArray& aClfFilePaths, 
+    CUpnpCdsLiteObjectArray& aCdsObjects,
+    RArray<TFileName>& aToBeSharedFiles,
+    RArray<TFileName>& aToBeUnsharedSharedFiles,
+    const TUpnpMediaType aType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    
+    // See if files in the clffilenames can be found from cds structure.
+    // if they cna they are already shared. In they can't they need to be 
+    // added to the list of "to be shared" items.
+    for (TInt i(0); i<aClfFilePaths.MdcaCount(); i++)
+        {        
+        RBuf8 fileName;
+        CleanupClosePushL( fileName );
+        fileName.CreateMaxL( aClfFilePaths.MdcaPoint(i).Length() );
+        fileName.Copy( aClfFilePaths.MdcaPoint(i) );
+        if(  KErrNotFound == aCdsObjects.FindByName( fileName ))
+            {
+            // Not found cds-structure, so needs to be added to 
+            // toBeSharedFiles.
+            aToBeSharedFiles.AppendL( aClfFilePaths.MdcaPoint(i) );
+            }
+        else
+            {
+            // Shared already
+            }    
+        CleanupStack::PopAndDestroy( &fileName );
+        }
+    
+    // See if items in cds structure can be found from clffilenames. If 
+    // they are found they need to be shared. If they are not found they 
+    // need to be added to the list of "to be unshared" items.
+    for ( TInt j( 0 ); j<aCdsObjects.Count(); j++ )
+        {
+        CUpnpCdsLiteObject& cdsObject = aCdsObjects.ObjectAtL( j );
+        // resolve filetype in cds
+        const TDesC8& itemType = cdsObject.ObjectClass(); 
+        
+        // compare only right type
+        if ( cdsObject.Type() == CUpnpCdsLiteObject::EItem && 
+            ( ( ( itemType.Find( KVideo ) != KErrNotFound || 
+                itemType.Find( KImage ) != KErrNotFound ) &&
+                aType == EImageAndVideo ) || 
+            ( itemType.Find( KAudio ) != KErrNotFound && 
+                aType == EPlaylist ) ) )
+            {
+            // get filename
+            HBufC* fileName = EscapeUtils::ConvertToUnicodeFromUtf8L( 
+                cdsObject.Name() );
+            CleanupStack::PushL( fileName );
+            
+            TInt clfCount = aClfFilePaths.Count();
+            TInt clfIndex( KErrNotFound );
+            aClfFilePaths.Find( *fileName, clfIndex );
+            if ( clfCount < 1 || clfIndex >= clfCount )
+                {
+                // Must not be shared so add to the toBeUnsharedSharedFiles.
+                aToBeUnsharedSharedFiles.AppendL( *fileName );
+                }            
+            else
+                {
+                // Sharing wanted to that item
+                }
+            CleanupStack::PopAndDestroy( fileName );
+            }
+        }
+        
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::CreateSharingRequestL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::CreateSharingRequestL(
+    TInt aType, 
+    TInt aSharingType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // flag for indicating is it needed to set progress property
+    TBool setProgress( EFalse );
+    
+    // Create the appropriate request depending on the sharing type.    
+    if ( aType == EImageAndVideo )
+        {
+        // if music sharing is not ongoing, set progress
+        if ( !iMusicSharingReq || iOngoingSharingType != EPlaylist )
+            {
+            setProgress = ETrue;
+            }
+        else
+            {
+            // force AO to set progress as soon as possible
+            iAo->ForceSetProgress();
+            }
+            
+        // create image and video request 
+        delete iVisualSharingReq;
+        iVisualSharingReq = NULL;
+        iVisualSharingReq = CUpnpSharingRequest::NewL(
+                                                    (TUpnpMediaType)aType, 
+                                                    aSharingType );
+        if ( setProgress )
+            {
+            // set progress so that ui updates itself
+            SetProgressL( KZeroProgress );
+            }
+        }
+    else if ( aType == EPlaylist )
+        {
+        // if visual sharing is not ongoing, set progress
+        if ( !iVisualSharingReq || iOngoingSharingType != EImageAndVideo )
+            {
+            setProgress = ETrue;
+            }
+        else
+            {
+            // force AO to set progress as soon as possible
+            iAo->ForceSetProgress();
+            }
+            
+        // create music request 
+        delete iMusicSharingReq;
+        iMusicSharingReq = NULL;
+        iMusicSharingReq = CUpnpSharingRequest::NewL(
+                                                    (TUpnpMediaType)aType, 
+                                                    aSharingType );
+        if ( setProgress )
+            {
+            // set progress so that ui updates itself
+            SetProgressL( KZeroProgress );
+            }
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::SetSharingRequestInfo
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::SetSharingRequestInfo(
+    TInt aType, 
+    RArray<TFileName>* aShareArray,
+    RArray<TFileName>* aUnshareArray,
+    CDesCArray* aClfIds )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Sets the appropriate sharing request information arrays.
+    // aShareArray, UnshareArray and aClfIds ownership transferred.
+    if ( aType == EImageAndVideo && iVisualSharingReq )
+        {
+        // image and video request 
+        iVisualSharingReq->SetSharingRequestInfo(
+            aShareArray,
+            aUnshareArray,
+            aClfIds );
+        }
+    else if ( aType == EPlaylist && iMusicSharingReq )
+        {
+        // music request 
+        iMusicSharingReq->SetSharingRequestInfo(
+            aShareArray,
+            aUnshareArray,
+            aClfIds );
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::ResetPendingRequestInfo
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::ResetPendingRequestInfo()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Reset iPendingSharingReqInfo object
+    iPendingSharingReqInfo.iMediaType = KErrNotFound;
+    iPendingSharingReqInfo.iMarkedItems.Reset();
+    
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::SavePendingRequestInfoL
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+void CUpnpContentServerHandler::SavePendingRequestInfoL(
+    const RArray<TInt>& aMarkedItems,
+    const TInt aType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // reset pending request object
+    ResetPendingRequestInfo();
+    
+    // Fill info of pending sharing request
+    iPendingSharingReqInfo.iMediaType = aType;
+    for ( TInt i = 0; i < aMarkedItems.Count(); i++ )
+        {
+        iPendingSharingReqInfo.iMarkedItems.AppendL( aMarkedItems[i] );
+        }
+    
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerHandler::ResolveSharingType
+// ( other items are commented in header )
+// --------------------------------------------------------------------------
+//
+
+TInt CUpnpContentServerHandler::SharingType( 
+    const RArray<TInt>& aMarkedItems )
+    {
+    // Resolve sharing type
+    TInt sharingType( EShareMany );
+    if ( aMarkedItems.Find(0) != KErrNotFound )
+        {
+        // share nothing marked
+        sharingType = EShareNone;
+        }
+    else if ( aMarkedItems.Find(1) != KErrNotFound )
+        {
+        // share all marked
+        sharingType = EShareAll;
+        }
+    return sharingType;
+    }
+    
+// End of file
--- a/upnpsharing/upnpcontentserver/src/upnpcontentserversession.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/src/upnpcontentserversession.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,438 +1,440 @@
-/*
-* Copyright (c) 2006-2007 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:      CUpnpContentServerSession class implementation
-*
-*/
-
-
-
-
-
-#include <e32debug.h>
-#include <e32def.h> //CArrayFix
-#include <s32mem.h> //RDesReadStream
-#include "upnpcontentserverdefs.h"
-#include "upnpcontentserversession.h"
-#include "upnpcontentserverclient.h"
-
-_LIT( KComponentLogfile, "contentserver.txt");
-#include "upnplog.h"
-
-using namespace UpnpContentServer;
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::NewL
-// 2-phased constructor.
-// --------------------------------------------------------------------------
-//
-CUpnpContentServerSession* CUpnpContentServerSession::NewL(
-    CUpnpContentServer* aServer )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CUpnpContentServerSession* self =
-        new (ELeave) CUpnpContentServerSession();
-    CleanupStack::PushL( self );
-    self->ConstructL( aServer );
-    CleanupStack::Pop( self );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::CUpnpContentServerSession
-// C++ constructor.
-// --------------------------------------------------------------------------
-//
-CUpnpContentServerSession::CUpnpContentServerSession( )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// void CUpnpContentServerSession::ConstructL
-// 2nd phase constructor.
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::ConstructL( CUpnpContentServer* aServer )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    if ( !aServer )
-        {
-        User::Leave( KErrArgument );
-        }
-    iServer = aServer;
-    iHandler = iServer->Handler();
-    iServer->AddSession();
-    if ( iHandler )
-        {
-        iHandler->SetContentSharingObserverL( this );
-        }
-    else
-        {
-        User::Leave( KErrBadHandle );
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::~CUpnpContentServerSession
-// C++ destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpContentServerSession::~CUpnpContentServerSession()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    // Sharing is off, client is disconnected, no sharing operation is ongoing
-    // -> close the server
-    if( iServer && iHandler )
-        {
-        iServer->RemoveSession();
-        if ( iHandler->CanStop() && iServer->CanStop() )
-            {
-            iServer->Stop();
-            __LOG("CUpnpContentServerSession::~CUpnpContentServerSession, \
-CActiveScheduler stopped");
-            }
-        TRAP_IGNORE( iHandler->SetContentSharingObserverL( NULL ) )
-        }
-    delete iResultBuffer;
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::ServiceL
-// From CSession2, passes the request forward to DispatchMessageL.
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::ServiceL( const RMessage2& aMessage )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TRAPD(err,DispatchMessageL(aMessage));
-    if ( err != KErrNone )
-        {
-        __LOG1( "Error: %d", err );
-        aMessage.Complete( err );
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::DispatchMessageL
-// Handles the request from client.
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::DispatchMessageL( const RMessage2& aMessage )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iHandler->SetContentSharingObserverL( this );
-    switch( aMessage.Function() )
-        {
-    case ERequestSelectionContent :
-        {
-        GetSelectionContentL( aMessage );
-        // completed separately
-        }
-        break;
-    case EGetSelectionIndexes :
-        {
-        GetSelectionIndexesL( aMessage );
-        aMessage.Complete( KErrNone );
-        }
-        break;
-    case EChangeShareContent :
-        {
-        ChangeShareContentL( aMessage );
-        aMessage.Complete( KErrNone );
-        }
-        break;
-    case ERefreshShareContent :
-        {
-        RefreshShareContentL( aMessage );
-        aMessage.Complete( KErrNone );
-        }
-        break;
-    case ERequestProgressInfo :
-        {
-        RequestProgressInfoL( aMessage );
-        aMessage.Complete( KErrNone );
-        }
-        break;
-    case EStartConnectionMonitor :
-        {
-        StartConnectionMonitorL( aMessage );
-        aMessage.Complete( KErrNone );
-        }
-        break;
-    case EStopConnectionMonitor :
-        {
-        StopConnectionMonitorL();
-        aMessage.Complete( KErrNone );
-        }
-        break;
-
-    default:
-        {
-        aMessage.Complete( KErrArgument );
-        }
-        break;
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::GetSelectionContentL
-// asynchronous
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::GetSelectionContentL(
-    const RMessage2& aMessage )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    TInt len( aMessage.GetDesLength(0) );
-
-    HBufC8* buffer = HBufC8::NewLC( len );
-    TPtr8 ptr( buffer->Des() );
-    aMessage.ReadL( 0, ptr );
-    RDesReadStream stream;
-    stream.Open( ptr );
-    CleanupClosePushL( stream );
-
-    TInt mediaType( stream.ReadInt32L() );
-    iSelectionContentMsg = aMessage;
-
-    // call to server
-    iHandler->GetSelectionContentL( mediaType );
-
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buffer );
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::GetSelectionIndexesL
-// synchronous
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::GetSelectionIndexesL(
-    const RMessage2& aMessage )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    TInt len( aMessage.GetDesLength(0) );
-
-    RArray<TInt>* selections = new ( ELeave )
-        RArray<TInt>( 5 );
-    CleanupClosePushL( *selections );
-    HBufC8* buffer = HBufC8::NewLC( len );
-    TPtr8 ptr( buffer->Des() );
-    aMessage.ReadL( 0, ptr );
-    RDesReadStream stream;
-    stream.Open( ptr );
-    CleanupClosePushL( stream );
-
-    TInt mediaType( stream.ReadInt32L() );
-    // call to server
-    iHandler->GetSelectionIndexesL( *selections, mediaType );
-
-    TInt objectCount( selections->Count() );
-
-    delete iResultBuffer;
-    iResultBuffer = NULL;
-
-    iResultBuffer = CBufFlat::NewL( KTintSize + KTintSize*objectCount );
-    RBufWriteStream wstream;
-    wstream.Open( *iResultBuffer );
-    CleanupClosePushL( wstream );
-
-    // append count and ints
-    wstream.WriteInt32L( objectCount );
-    for( TInt i(0); i < objectCount; i++ )
-        {
-        wstream.WriteInt32L( selections->operator[]( i ) );
-        }
-
-    // Write result back to client
-    aMessage.WriteL( 1, iResultBuffer->Ptr(0) );
-
-    CleanupStack::PopAndDestroy( &wstream );
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buffer );
-    CleanupStack::PopAndDestroy( selections );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::ChangeShareContentL
-// Handles the async request from client.
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::ChangeShareContentL(
-    const RMessage2& aMessage )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    TInt len( aMessage.GetDesLength(0) );
-    RArray<TInt> selections( len );
-    CleanupClosePushL( selections );
-    HBufC8* buffer = HBufC8::NewLC( len );
-    TPtr8 ptr( buffer->Des() );
-    aMessage.ReadL( 0, ptr );
-    RDesReadStream stream;
-    stream.Open( ptr );
-    CleanupClosePushL( stream );
-
-    TInt mediaType( stream.ReadInt32L() );
-    TInt objCount( stream.ReadInt32L() );
-
-    // loop the TInt from stream
-    for( TInt i(0); i< objCount; i++)
-        {
-        selections.AppendL( stream.ReadInt32L() );
-        }
-
-    iHandler->ChangeShareContentL( selections,  mediaType );
-    
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buffer );
-    CleanupStack::PopAndDestroy( &selections );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::RequestProgressInfoL
-// synchronous
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::RequestProgressInfoL(
-    const RMessage2& /*aMessage*/ )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    // The progress should be read using pubsub
-    // This call will be removed in upnpfw 2.1
-    User::Leave( KErrNotSupported );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::RefreshShareContentL
-// asynchronous
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::RefreshShareContentL(
-    const RMessage2& aMessage )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TInt len( aMessage.GetDesLength(0) );
-    HBufC8* buffer = HBufC8::NewLC( len );
-    TPtr8 ptr( buffer->Des() );
-    aMessage.ReadL( 0, ptr );
-    RDesReadStream stream;
-    stream.Open( ptr );
-    CleanupClosePushL( stream );
-
-    TInt mediaType( stream.ReadInt32L() );
-
-    // The sharing and refresh cannot be used simultaneously
-    // Using the same place to store message for completion
-    //
-    iChangeShareContentMsg = aMessage;
-    // call to handler.
-    iHandler->RefreshShareContentL( mediaType );
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buffer );
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::CompleteSelectionContentL
-// Completes the async GetSelectionContentL call
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::CompleteSelectionContentL(
-    const CDesCArray& aMarkedItems )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    TInt objectCount( aMarkedItems.MdcaCount() );
-
-    delete iResultBuffer;
-    iResultBuffer = NULL;
-
-    iResultBuffer = CBufFlat::NewL( KTintSize + KTintSize*objectCount );
-    RBufWriteStream wstream;
-    wstream.Open( *iResultBuffer );
-    CleanupClosePushL( wstream );
-
-    // append count
-    wstream.WriteInt32L( objectCount );
-    // append descriptors
-    for( TInt i(0); i<objectCount; i++ )
-        {
-        wstream.WriteInt32L( aMarkedItems[ i ].Length() );
-        wstream.WriteL( aMarkedItems[ i ] );
-        }
-
-    // Write result back to client
-    iSelectionContentMsg.WriteL( 1, iResultBuffer->Ptr(0) );
-    iSelectionContentMsg.Complete( KErrNone );
-    CleanupStack::PopAndDestroy( &wstream );
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::StartConnectionMonitorL
-// synchronous
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::StartConnectionMonitorL(
-    const RMessage2& aMessage )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TInt len( aMessage.GetDesLength(0) );
-    HBufC8* buffer = HBufC8::NewLC( len );
-    TPtr8 ptr( buffer->Des() );
-    aMessage.ReadL( 0, ptr );
-    RDesReadStream stream;
-    stream.Open( ptr );
-    CleanupClosePushL( stream );
-
-    TInt iapId( stream.ReadInt32L() );
-
-    // call to server
-    iServer->RequestConnectionLostL( iapId );
-    CleanupStack::PopAndDestroy( &stream );
-    CleanupStack::PopAndDestroy( buffer );
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpContentServerSession::StopConnectionMonitorL
-// cancel connection lost
-// --------------------------------------------------------------------------
-//
-void CUpnpContentServerSession::StopConnectionMonitorL( )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iServer->CancelConnectionLostL();
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// End of file
+/*
+* Copyright (c) 2006-2007 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:      CUpnpContentServerSession class implementation
+*
+*/
+
+
+
+
+
+#include <e32debug.h>
+#include <e32def.h> //CArrayFix
+#include <s32mem.h> //RDesReadStream
+#include "upnpcontentserverdefs.h"
+#include "upnpcontentserversession.h"
+#include "upnpcontentserverclient.h"
+
+_LIT( KComponentLogfile, "contentserver.txt");
+#include "upnplog.h"
+
+using namespace UpnpContentServer;
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::NewL
+// 2-phased constructor.
+// --------------------------------------------------------------------------
+//
+CUpnpContentServerSession* CUpnpContentServerSession::NewL(
+    CUpnpContentServer* aServer )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    CUpnpContentServerSession* self =
+        new (ELeave) CUpnpContentServerSession();
+    CleanupStack::PushL( self );
+    self->ConstructL( aServer );
+    CleanupStack::Pop( self );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::CUpnpContentServerSession
+// C++ constructor.
+// --------------------------------------------------------------------------
+//
+CUpnpContentServerSession::CUpnpContentServerSession( )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// void CUpnpContentServerSession::ConstructL
+// 2nd phase constructor.
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::ConstructL( CUpnpContentServer* aServer )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    if ( !aServer )
+        {
+        User::Leave( KErrArgument );
+        }
+    iServer = aServer;
+    iHandler = iServer->Handler();
+    iServer->AddSession();
+    if ( iHandler )
+        {
+        iHandler->SetContentSharingObserverL( this );
+        }
+    else
+        {
+        User::Leave( KErrBadHandle );
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::~CUpnpContentServerSession
+// C++ destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpContentServerSession::~CUpnpContentServerSession()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Sharing is off, client is disconnected, no sharing operation is ongoing
+    // -> close the server
+    if( iServer && iHandler )
+        {
+        iServer->RemoveSession();
+        if ( iHandler->CanStop() && iServer->CanStop() )
+            {
+            iServer->Stop();
+            __LOG("CUpnpContentServerSession::~CUpnpContentServerSession, \
+CActiveScheduler stopped");
+            }
+        TRAP_IGNORE( iHandler->SetContentSharingObserverL( NULL ) )
+        }
+    delete iResultBuffer;
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::ServiceL
+// From CSession2, passes the request forward to DispatchMessageL.
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::ServiceL( const RMessage2& aMessage )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TRAPD(err,DispatchMessageL(aMessage));
+    if ( err != KErrNone )
+        {
+        __LOG1( "Error: %d", err );
+        aMessage.Complete( err );
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::DispatchMessageL
+// Handles the request from client.
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::DispatchMessageL( const RMessage2& aMessage )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    iHandler->InitializeL();
+    iHandler->SetContentSharingObserverL( this );
+    
+    switch( aMessage.Function() )
+        {
+    case ERequestSelectionContent :
+        {
+        GetSelectionContentL( aMessage );
+        // completed separately
+        }
+        break;
+    case EGetSelectionIndexes :
+        {
+        GetSelectionIndexesL( aMessage );
+        aMessage.Complete( KErrNone );
+        }
+        break;
+    case EChangeShareContent :
+        {
+        ChangeShareContentL( aMessage );
+        aMessage.Complete( KErrNone );
+        }
+        break;
+    case ERefreshShareContent :
+        {
+        RefreshShareContentL( aMessage );
+        aMessage.Complete( KErrNone );
+        }
+        break;
+    case ERequestProgressInfo :
+        {
+        RequestProgressInfoL( aMessage );
+        aMessage.Complete( KErrNone );
+        }
+        break;
+    case EStartConnectionMonitor :
+        {
+        StartConnectionMonitorL( aMessage );
+        aMessage.Complete( KErrNone );
+        }
+        break;
+    case EStopConnectionMonitor :
+        {
+        StopConnectionMonitorL();
+        aMessage.Complete( KErrNone );
+        }
+        break;
+
+    default:
+        {
+        aMessage.Complete( KErrArgument );
+        }
+        break;
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::GetSelectionContentL
+// asynchronous
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::GetSelectionContentL(
+    const RMessage2& aMessage )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    TInt len( aMessage.GetDesLength(0) );
+
+    HBufC8* buffer = HBufC8::NewLC( len );
+    TPtr8 ptr( buffer->Des() );
+    aMessage.ReadL( 0, ptr );
+    RDesReadStream stream;
+    stream.Open( ptr );
+    CleanupClosePushL( stream );
+
+    TInt mediaType( stream.ReadInt32L() );
+    iSelectionContentMsg = aMessage;
+
+    // call to server
+    iHandler->GetSelectionContentL( mediaType );
+
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buffer );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::GetSelectionIndexesL
+// synchronous
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::GetSelectionIndexesL(
+    const RMessage2& aMessage )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    TInt len( aMessage.GetDesLength(0) );
+
+    RArray<TInt>* selections = new ( ELeave )
+        RArray<TInt>( 5 );
+    CleanupClosePushL( *selections );
+    HBufC8* buffer = HBufC8::NewLC( len );
+    TPtr8 ptr( buffer->Des() );
+    aMessage.ReadL( 0, ptr );
+    RDesReadStream stream;
+    stream.Open( ptr );
+    CleanupClosePushL( stream );
+
+    TInt mediaType( stream.ReadInt32L() );
+    // call to server
+    iHandler->GetSelectionIndexesL( *selections, mediaType );
+
+    TInt objectCount( selections->Count() );
+
+    delete iResultBuffer;
+    iResultBuffer = NULL;
+
+    iResultBuffer = CBufFlat::NewL( KTintSize + KTintSize*objectCount );
+    RBufWriteStream wstream;
+    wstream.Open( *iResultBuffer );
+    CleanupClosePushL( wstream );
+
+    // append count and ints
+    wstream.WriteInt32L( objectCount );
+    for( TInt i(0); i < objectCount; i++ )
+        {
+        wstream.WriteInt32L( selections->operator[]( i ) );
+        }
+
+    // Write result back to client
+    aMessage.WriteL( 1, iResultBuffer->Ptr(0) );
+
+    CleanupStack::PopAndDestroy( &wstream );
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buffer );
+    CleanupStack::PopAndDestroy( selections );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::ChangeShareContentL
+// Handles the async request from client.
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::ChangeShareContentL(
+    const RMessage2& aMessage )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    TInt len( aMessage.GetDesLength(0) );
+    RArray<TInt> selections( len );
+    CleanupClosePushL( selections );
+    HBufC8* buffer = HBufC8::NewLC( len );
+    TPtr8 ptr( buffer->Des() );
+    aMessage.ReadL( 0, ptr );
+    RDesReadStream stream;
+    stream.Open( ptr );
+    CleanupClosePushL( stream );
+
+    TInt mediaType( stream.ReadInt32L() );
+    TInt objCount( stream.ReadInt32L() );
+
+    // loop the TInt from stream
+    for( TInt i(0); i< objCount; i++)
+        {
+        selections.AppendL( stream.ReadInt32L() );
+        }
+
+    iHandler->ChangeShareContentL( selections,  mediaType );
+    
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buffer );
+    CleanupStack::PopAndDestroy( &selections );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::RequestProgressInfoL
+// synchronous
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::RequestProgressInfoL(
+    const RMessage2& /*aMessage*/ )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    // The progress should be read using pubsub
+    // This call will be removed in upnpfw 2.1
+    User::Leave( KErrNotSupported );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::RefreshShareContentL
+// asynchronous
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::RefreshShareContentL(
+    const RMessage2& aMessage )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TInt len( aMessage.GetDesLength(0) );
+    HBufC8* buffer = HBufC8::NewLC( len );
+    TPtr8 ptr( buffer->Des() );
+    aMessage.ReadL( 0, ptr );
+    RDesReadStream stream;
+    stream.Open( ptr );
+    CleanupClosePushL( stream );
+
+    TInt mediaType( stream.ReadInt32L() );
+
+    // The sharing and refresh cannot be used simultaneously
+    // Using the same place to store message for completion
+    //
+    iChangeShareContentMsg = aMessage;
+    // call to handler.
+    iHandler->RefreshShareContentL( mediaType );
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buffer );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::CompleteSelectionContentL
+// Completes the async GetSelectionContentL call
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::CompleteSelectionContentL(
+    const CDesCArray& aMarkedItems )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    TInt objectCount( aMarkedItems.MdcaCount() );
+
+    delete iResultBuffer;
+    iResultBuffer = NULL;
+
+    iResultBuffer = CBufFlat::NewL( KTintSize + KTintSize*objectCount );
+    RBufWriteStream wstream;
+    wstream.Open( *iResultBuffer );
+    CleanupClosePushL( wstream );
+
+    // append count
+    wstream.WriteInt32L( objectCount );
+    // append descriptors
+    for( TInt i(0); i<objectCount; i++ )
+        {
+        wstream.WriteInt32L( aMarkedItems[ i ].Length() );
+        wstream.WriteL( aMarkedItems[ i ] );
+        }
+
+    // Write result back to client
+    iSelectionContentMsg.WriteL( 1, iResultBuffer->Ptr(0) );
+    iSelectionContentMsg.Complete( KErrNone );
+    CleanupStack::PopAndDestroy( &wstream );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::StartConnectionMonitorL
+// synchronous
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::StartConnectionMonitorL(
+    const RMessage2& aMessage )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TInt len( aMessage.GetDesLength(0) );
+    HBufC8* buffer = HBufC8::NewLC( len );
+    TPtr8 ptr( buffer->Des() );
+    aMessage.ReadL( 0, ptr );
+    RDesReadStream stream;
+    stream.Open( ptr );
+    CleanupClosePushL( stream );
+
+    TInt iapId( stream.ReadInt32L() );
+
+    // call to server
+    iServer->RequestConnectionLostL( iapId );
+    CleanupStack::PopAndDestroy( &stream );
+    CleanupStack::PopAndDestroy( buffer );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpContentServerSession::StopConnectionMonitorL
+// cancel connection lost
+// --------------------------------------------------------------------------
+//
+void CUpnpContentServerSession::StopConnectionMonitorL( )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    iServer->CancelConnectionLostL();
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// End of file
--- a/upnpsharing/upnpcontentserver/src/upnpselectionreader.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/src/upnpselectionreader.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,668 +1,766 @@
-/*
-* Copyright (c) 2005-2007 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:      CUpnpSelectionReader class implementation
-*
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-
-#include <upnpstring.h>
-#include <s32file.h>
-#include <centralrepository.h>
-// #include <clfcontentlistingextended.hrh>
-
-#include <MCLFItemListModel.h>
-#include <MCLFItem.h>
-#include "upnpcontentservercrkeys.h"
-#include "upnpselectionreader.h"
-#include "upnpcontentmetadatautility.h"
-#include "upnpcontentserverdefs.h"
-
-_LIT( KComponentLogfile, "contentserver.txt");
-#include "upnplog.h"
-
-//CONSTANTS
-// Format string for listbox items
-_LIT(KItemFormatString, "1\t%S");
-const TInt KDefaultStringArrGranularity( 10 );
-const TInt KDefaultSelectionGranularity( 2 );
-
-const TInt KShareNoneIndex = 0;
-const TInt KShareAllIndex = 1;
-const TInt KPredefinedSelections = 2; // Share none and share all
-
-using namespace UpnpContentServer;
-
-// ================= MEMBER FUNCTIONS =======================
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::NewL
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpSelectionReader* CUpnpSelectionReader::NewL(
-                        CUpnpContentMetadataUtility* aUtility )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CUpnpSelectionReader* self =
-        new(ELeave) CUpnpSelectionReader();
-
-    CleanupStack::PushL(self);
-    self->ConstructL( aUtility );
-    CleanupStack::Pop(self);
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::ConstructL
-// Symbian 2nd phase constructor can leave.
-// --------------------------------------------------------------------------
-//
-void CUpnpSelectionReader::ConstructL(
-                        CUpnpContentMetadataUtility* aUtility  )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    iMetadataUtility = aUtility;
-
-    iPlIdArray = new (ELeave) CDesCArrayFlat( KDefaultStringArrGranularity );
-    iCollIdArray = new (ELeave) 
-        CDesCArrayFlat( KDefaultStringArrGranularity );
-
-    iPlaylistNames = new (ELeave) 
-        CDesCArrayFlat( KDefaultStringArrGranularity );
-    iCollectionNames = new (ELeave) 
-        CDesCArrayFlat( KDefaultStringArrGranularity );
-
-    iSelectedImages  = new (ELeave) RArray<TInt>( 
-        KDefaultSelectionGranularity);
-    iSelectedMusic  = new (ELeave) RArray<TInt>( 
-        KDefaultSelectionGranularity);
-
-    GetVisualSharingStateL( iVisualSharingSelection );
-    GetMusicSharingStateL( iMusicSharingSelection );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::CUpnpSelectionReader
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// --------------------------------------------------------------------------
-//
-CUpnpSelectionReader::CUpnpSelectionReader()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iImageContainers = NULL;
-    iPlaylistNames = NULL;
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::~CUpnpSelectionReader
-// C++ default destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpSelectionReader::~CUpnpSelectionReader()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    iMetadataUtility = NULL;
-
-    if ( iSelectedImages )
-        {
-        iSelectedImages->Close();
-        }
-
-    delete iSelectedImages;
-
-    if ( iSelectedMusic )
-        {
-        iSelectedMusic->Close();
-        }
-
-    delete iSelectedMusic;
-    delete iPlIdArray;
-    delete iCollIdArray;
-    delete iPlaylistNames;
-    delete iImageContainers;
-    delete iCollectionNames;
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::IsItemSharedL()
-// Checks if album is shared earlier
-// --------------------------------------------------------------------------
-//
-TBool CUpnpSelectionReader::IsItemShared(
-            const TDesC& aItemName,
-            const CDesCArray& aIDArray ) const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TInt pos;
-    TBool retVal = !aIDArray.Find( aItemName, pos );
-
-    __LOG1( "CUpnpSelectionReader::IsItemSharedL returns %d",
-        retVal );
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return retVal;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::FetchCollectionsL()
-// Fetch albums from Media Gallery for the listbox
-// --------------------------------------------------------------------------
-//
-void CUpnpSelectionReader::FetchCollectionsL( CDesCArray* 
-                                              aSettingsTextArray )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-/*    if ( !aSettingsTextArray )
-        {
-        User::Leave( KErrGeneral );
-        }
-    // This is for IsItemSharedL
-    iMediaType = EImageAndVideo;
-
-    if( iSelectedImages )
-        {
-        iSelectedImages->Reset();
-        }
-    if( iCollIdArray )
-        {
-        iCollIdArray->Reset();
-        }
-    if( iCollectionNames )
-        {
-        iCollectionNames->Reset();
-        }
-
-    // Read shared albums
-    CDesCArray* sharedStuff = new (ELeave) CDesCArrayFlat( 
-        KDefaultStringArrGranularity );
-    CleanupStack::PushL( sharedStuff );
-
-    ReadSharedContainerIDsL( sharedStuff,
-                             EImageAndVideo );
-
-    // fill iCollIdArray
-    SearchCollectionsL();
-
-    // cycle trough albums to collect names to the listbox
-    for (TInt index = 0; index < iCollIdArray->MdcaCount(); index++)
-        {
-        HBufC16* albumName = HBufC16::NewL(KMaxFileName);
-        CleanupStack::PushL( albumName );
-
-        // create item string for listbox (icon + album name)
-        TPtrC16 collectionName = iCollectionNames->MdcaPoint( index );
-        albumName->Des().Format( KItemFormatString, &collectionName ); 
-
-        // append album name to the listbox
-        aSettingsTextArray->AppendL( albumName->Des() );
-
-        // check if album is shared earlier
-        if ( IsItemShared( iCollIdArray->MdcaPoint( index ), *sharedStuff ) )
-            {
-            //Index can't be '0' or '1' because there are predefined 
-            //selections such as "share nothing" and "share all" first.
-            iSelectedImages->AppendL( index + KPredefinedSelections );
-            }
-
-
-        CleanupStack::PopAndDestroy( albumName );
-        albumName = NULL;
-        }
-
-    GetVisualSharingStateL( iVisualSharingSelection );
-
-    if ( iVisualSharingSelection == EShareAll )
-       {
-        iSelectedImages->Reset();
-        // if all albums were shared mark only "share all"
-        iSelectedImages->AppendL( KShareAllIndex );
-        }
-    else if ( iVisualSharingSelection == EShareNone )
-        {
-        iSelectedImages->Reset();
-        // if no albums were shared mark only "share nothing"
-        iSelectedImages->AppendL( KShareNoneIndex );
-        }
-
-    iContainerCount = aSettingsTextArray->MdcaCount();
-
-    CleanupStack::PopAndDestroy( sharedStuff );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );*/
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::FetchPlaylistsL()
-// Fetch playlists from Media Gallery for the listbox.
-// --------------------------------------------------------------------------
-//
-void CUpnpSelectionReader::FetchPlaylistsL( CDesCArray* aSettingsTextArray )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
- /*   if ( !aSettingsTextArray )
-        {
-        User::Leave( KErrGeneral );
-        }
-
-    // This is for IsItemSharedL
-    iMediaType = EPlaylist;
-
-    if ( iSelectedMusic )
-        {
-        iSelectedMusic->Reset();
-        }
-
-    if ( iPlIdArray )
-        {
-        iPlIdArray->Reset();
-        }
-
-    if( iPlaylistNames )
-        {
-        iPlaylistNames->Reset();
-        }
-
-    // container where items will be added
-    CDesCArray* sharedStuff = new (ELeave) CDesCArrayFlat( 
-        KDefaultStringArrGranularity );
-    CleanupStack::PushL( sharedStuff );
-
-    // Read previously shared playlist ids for calculating indexes
-    ReadSharedContainerIDsL( sharedStuff,
-                             EPlaylist );
-
-    // search .m3u files put them to iPlIdArray
-    SearchPlaylistFilesL();
-
-    for ( TInt fileIndex = 0; 
-          fileIndex < iPlIdArray->MdcaCount(); fileIndex++ )
-        {
-        HBufC16* listboxItem = HBufC16::NewL(KMaxFileName);
-        CleanupStack::PushL(listboxItem);
-
-        TPtrC itemName( iPlaylistNames->MdcaPoint( fileIndex ) );
-
-        TBuf<KMaxFileName> nameBuf;
-        nameBuf.Copy( itemName );
-        listboxItem->Des().Format(KItemFormatString, &nameBuf );
-        aSettingsTextArray->AppendL( listboxItem->Des() );
-
-        if ( IsItemShared( iPlIdArray->MdcaPoint( fileIndex ),
-                           *sharedStuff ) )
-            {
-            //Index can't be '0' or '1' because there are predefined 
-            //selections such as "share nothing" and "share all" first.
-            iSelectedMusic->AppendL( fileIndex + KPredefinedSelections );
-            }
-
-        CleanupStack::PopAndDestroy( listboxItem );
-        listboxItem = NULL;
-        }
-
-    GetMusicSharingStateL( iMusicSharingSelection );
-
-    if ( iMusicSharingSelection == EShareAll )
-        {
-        iSelectedMusic->Reset();
-        // if all albums were shared mark only "share all"
-        iSelectedMusic->AppendL( KShareAllIndex );
-        }
-    else if ( iMusicSharingSelection == EShareNone )
-        {
-        iSelectedMusic->Reset();
-        // if no albums were shared mark only "share nothing"
-        iSelectedMusic->AppendL( KShareNoneIndex );
-        }
-    iContainerCount = aSettingsTextArray->MdcaCount();
-    CleanupStack::PopAndDestroy( sharedStuff );*/
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::SearchPlaylistFilesL()
-// Search playlist files
-// --------------------------------------------------------------------------
-//
-TBool CUpnpSelectionReader::SearchPlaylistFilesL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    CUPnPPlaylistServices* playlists = CUPnPPlaylistServices::NewL();
-    CleanupStack::PushL( playlists );
-    
-    playlists->ListPlaylistsL( *iPlIdArray, *iPlaylistNames );
-    // for debugging
-
-#ifdef _DEBUG
-    __LOG("CUpnpSelectionReader: Checking playlist validity.");
-    for ( TInt i(0); i<iPlIdArray->MdcaCount(); i++ )
-        {
-        TBool valid(EFalse);
-        TRAPD( err, valid = playlists->IsValidPlaylistL( 
-                   iPlaylistNames->MdcaPoint(i) ));
-        if ( !err )
-            {
-            TPtrC id( iPlIdArray->MdcaPoint(i) );
-            __LOG3("Playlist[%d] %S IsValid: %d",
-                i, &id, valid );
-            }
-        }
-#endif
-    CleanupStack::PopAndDestroy( playlists );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return ETrue;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::SearchCollectionsL
-// fill iCollIdArray
-// --------------------------------------------------------------------------
-//
-TBool CUpnpSelectionReader::SearchCollectionsL()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    CUPnPAlbumServices* albums = CUPnPAlbumServices::NewL();
-    CleanupStack::PushL( albums );
-    
-    albums->ListAlbumsL( *iCollIdArray, *iCollectionNames );
-
-#ifdef _DEBUG
-    __LOG("CUpnpSelectionReader: Checking album validity.");
-    for ( TInt i(0); i<iCollIdArray->MdcaCount(); i++ )
-        {
-        TBool valid(EFalse);
-        TRAPD( err, valid = albums->IsValidAlbumL( 
-                   iCollectionNames->MdcaPoint(i) ));
-        if ( !err )
-            {
-            TPtrC id( iCollIdArray->MdcaPoint(i) );
-            __LOG3("Album[%d] %S IsValid: %d",
-                i, &id, valid );
-            }
-        }
-#endif
-    CleanupStack::PopAndDestroy( albums );
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return ETrue;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileSharingEngine::ReadSharedContainerIDsL
-// Reads shared container IDs from file
-// --------------------------------------------------------------------------
-//
-TInt CUpnpSelectionReader::ReadSharedContainerIDsL(
-    CDesCArray* aArray,
-    const TUpnpMediaType& aContainerType ) const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    // Leave if NULL
-    if ( !aArray )
-        {
-        User::Leave(KErrArgument);
-        }
-
-    RFs fs;
-    RFile file;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL(fs);
-
-    TInt error = KErrNone;
-
-    if ( aContainerType == EImageAndVideo )
-        {
-        error = file.Open(fs, KVisualFile, EFileRead );
-        }
-    else if ( aContainerType == EPlaylist )
-        {
-        error = file.Open(fs, KMusicFile, EFileRead );
-        }
-    else
-        {
-        // Not valid container type
-        error = KErrNotFound;
-        }
-
-    if ( error == KErrNone )
-        {
-        CleanupClosePushL( file );
-        RFileReadStream readStream( file );
-        CleanupClosePushL( readStream );
-
-        HBufC* collectionName = HBufC::NewL(KMaxFileName);
-        CleanupStack::PushL( collectionName );
-        TPtr collection = collectionName->Des();
-
-        do
-            {
-            TRAPD(err, readStream >> collection); //leaves when eof
-            if (err)
-                {
-                error = err;
-                }
-            else
-                {
-                aArray->AppendL(collection);
-                }
-
-            }  while(error == KErrNone); // end of file
-
-        CleanupStack::PopAndDestroy( collectionName );
-        CleanupStack::PopAndDestroy( &readStream ); // Close readStream
-        CleanupStack::PopAndDestroy( &file ); // Close file
-        }
-
-     CleanupStack::PopAndDestroy( &fs );
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return error;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUPnPFileSharingEngine::GetSelectionIndexesL
-// Reads shared container IDs from file
-// --------------------------------------------------------------------------
-//
-void CUpnpSelectionReader::GetSelectionIndexesL(
-    RArray<TInt>& aSelections,
-    const TUpnpMediaType& aType )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    RArray<TInt>* list( NULL );
-    if ( aType == EImageAndVideo )
-        {
-        if ( !iSelectedImages )
-            {
-
-            iImageContainers->Reset();
-            FetchCollectionsL( iImageContainers );
-            iImageContainers->Reset();
-            }
-        else if ( !iImageContainers )
-            {
-            iImageContainers = new (ELeave) CDesCArrayFlat( 
-                KDefaultStringArrGranularity );
-            FetchCollectionsL( iImageContainers );
-            }
-        else 
-            {
-            FetchCollectionsL( iImageContainers );
-            }
-            
-        list = iSelectedImages;
-        }
-    else
-        {
-        if ( !iSelectedMusic )
-            {
-            iPlaylistNames->Reset();
-            FetchPlaylistsL( iPlaylistNames );
-            iPlaylistNames->Reset();
-            }
-        else if ( iPlaylistNames )
-            {
-            iPlaylistNames = new (ELeave) 
-                CDesCArrayFlat( KDefaultStringArrGranularity );
-            FetchPlaylistsL( iPlaylistNames );
-            }
-        else 
-            {
-            FetchPlaylistsL( iPlaylistNames );
-            }
-        
-        list = iSelectedMusic;
-        }
-
-    for ( TInt i(0); i< list->Count(); i++ )
-        {
-        aSelections.AppendL( list->operator[]( i ) );
-        }
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::GetVisualSharingStateL
-// (other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TInt CUpnpSelectionReader::GetVisualSharingStateL( TInt& aShareAllState )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CRepository* rep = CRepository::NewL( KCrUidUpnpContentserver );
-    CleanupStack::PushL( rep );
-    TInt err( rep->Get( KUPnPAppShareAllVisualFiles, aShareAllState ));
-    CleanupStack::PopAndDestroy( rep );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::GetMusicSharingStateL
-// (other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TInt CUpnpSelectionReader::GetMusicSharingStateL( TInt& aShareAllState )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    CRepository* rep = CRepository::NewL( KCrUidUpnpContentserver );
-    CleanupStack::PushL( rep );
-    TInt err( rep->Get( KUPnPAppShareAllMusicFiles, aShareAllState ));
-    CleanupStack::PopAndDestroy( rep );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::GetContainerCount
-// (other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TInt CUpnpSelectionReader::GetContainerCount() const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return iContainerCount;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::PlayListIdsL
-// (other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TInt CUpnpSelectionReader::PlayListIdsL( CDesCArray& aPlaylistIds, 
-                                        CDesCArray& aPlaylistNames )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TInt err( KErrNone );
-    if ( iPlIdArray && iPlaylistNames )
-        {
-        for ( TInt i(0); i < iPlIdArray->MdcaCount(); i++ )
-            {
-            aPlaylistIds.AppendL( iPlIdArray->MdcaPoint( i ) );
-            aPlaylistNames.AppendL( iPlaylistNames->MdcaPoint( i ) );
-            }
-        }
-    else
-        {
-        err = KErrGeneral;
-        }
-    
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::CollectionIdsL
-// (other items are commented in header )
-// --------------------------------------------------------------------------
-//
-TInt CUpnpSelectionReader::CollectionIdsL( CDesCArray& aCollectionIds,
-                                             CDesCArray& aCollectionNames )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    TInt err( KErrNone );
-    if ( iCollIdArray && iCollectionNames )
-        {
-        for ( TInt i(0); i < iCollIdArray->MdcaCount(); i++ )
-            {
-            aCollectionIds.AppendL( iCollIdArray->MdcaPoint( i ) );
-            aCollectionNames.AppendL( iCollectionNames->MdcaPoint( i ) );
-            }
-        }
-    else
-        {
-        err = KErrGeneral;
-        }
-    
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return err;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionReader::SetMetadata
-// (other items are commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpSelectionReader::SetMetadata( CUpnpContentMetadataUtility*
-    aMetaData )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iMetadataUtility = aMetaData;
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// End of file
+/*
+* Copyright (c) 2005-2007 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:      CUpnpSelectionReader class implementation
+*
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+
+#include <upnpstring.h>
+#include <s32file.h>
+#include <centralrepository.h>
+// #include <clfcontentlistingextended.hrh>
+
+#include <MCLFItemListModel.h>
+#include <MCLFItem.h>
+#include "upnpcontentservercrkeys.h"
+#include "upnpselectionreader.h"
+#include "upnpcontentserverdefs.h"
+#include "upnpplaylistservices.h"
+#include "upnpalbumservices.h"
+
+_LIT( KComponentLogfile, "contentserver.txt");
+#include "upnplog.h"
+
+//CONSTANTS
+// Format string for listbox items
+_LIT(KItemFormatString, "1\t%S");
+const TInt KDefaultStringArrGranularity( 10 );
+const TInt KDefaultSelectionGranularity( 2 );
+
+const TInt KShareNoneIndex = 0;
+const TInt KShareAllIndex = 1;
+const TInt KPredefinedSelections = 2; // Share none and share all
+const TInt KUiSelectionOffset = 2;
+
+using namespace UpnpContentServer;
+
+// ================= MEMBER FUNCTIONS =======================
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::NewL
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpSelectionReader* CUpnpSelectionReader::NewL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    CUpnpSelectionReader* self =
+        new(ELeave) CUpnpSelectionReader();
+
+    CleanupStack::PushL(self);
+    self->ConstructL();
+    CleanupStack::Pop(self);
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::ConstructL
+// Symbian 2nd phase constructor can leave.
+// --------------------------------------------------------------------------
+//
+void CUpnpSelectionReader::ConstructL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    iPlIdArray = new (ELeave) CDesCArrayFlat( KDefaultStringArrGranularity );
+    iCollIdArray = new (ELeave) 
+        CDesCArrayFlat( KDefaultStringArrGranularity );
+
+    iPlaylistNames = new (ELeave) 
+        CDesCArrayFlat( KDefaultStringArrGranularity );
+    iCollectionNames = new (ELeave) 
+        CDesCArrayFlat( KDefaultStringArrGranularity );
+
+    iSelectedImages  = new (ELeave) RArray<TInt>( 
+        KDefaultSelectionGranularity);
+    iSelectedMusic  = new (ELeave) RArray<TInt>( 
+        KDefaultSelectionGranularity);
+
+    GetVisualSharingStateL( iVisualSharingSelection );
+    GetMusicSharingStateL( iMusicSharingSelection );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::CUpnpSelectionReader
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// --------------------------------------------------------------------------
+//
+CUpnpSelectionReader::CUpnpSelectionReader()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    iImageContainers = NULL;
+    iPlaylistNames = NULL;
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::~CUpnpSelectionReader
+// C++ default destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpSelectionReader::~CUpnpSelectionReader()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    if ( iSelectedImages )
+        {
+        iSelectedImages->Close();
+        }
+
+    delete iSelectedImages;
+
+    if ( iSelectedMusic )
+        {
+        iSelectedMusic->Close();
+        }
+
+    delete iSelectedMusic;
+    delete iPlIdArray;
+    delete iCollIdArray;
+    delete iPlaylistNames;
+    delete iImageContainers;
+    delete iCollectionNames;
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::IsItemSharedL()
+// Checks if album is shared earlier
+// --------------------------------------------------------------------------
+//
+TBool CUpnpSelectionReader::IsItemShared(
+            const TDesC& aItemName,
+            const CDesCArray& aIDArray ) const
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TInt pos;
+    TBool retVal = !aIDArray.Find( aItemName, pos );
+
+    __LOG1( "CUpnpSelectionReader::IsItemSharedL returns %d",
+        retVal );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return retVal;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::FetchCollectionsL()
+// Fetch albums from Media Gallery for the listbox
+// --------------------------------------------------------------------------
+//
+void CUpnpSelectionReader::FetchCollectionsL( CDesCArray* 
+                                              aSettingsTextArray )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    if ( !aSettingsTextArray )
+        {
+        User::Leave( KErrGeneral );
+        }
+    // This is for IsItemSharedL
+    iMediaType = EImageAndVideo;
+
+    if( iSelectedImages )
+        {
+        iSelectedImages->Reset();
+        }
+    if( iCollIdArray )
+        {
+        iCollIdArray->Reset();
+        }
+    if( iCollectionNames )
+        {
+        iCollectionNames->Reset();
+        }
+
+    // Read shared albums
+    CDesCArray* sharedStuff = new (ELeave) CDesCArrayFlat( 
+        KDefaultStringArrGranularity );
+    CleanupStack::PushL( sharedStuff );
+
+    ReadSharedContainerIDsL( sharedStuff,
+                             EImageAndVideo );
+
+    // fill iCollIdArray
+    SearchCollectionsL();
+
+    // cycle trough albums to collect names to the listbox
+    for (TInt index = 0; index < iCollIdArray->MdcaCount(); index++)
+        {
+        HBufC16* albumName = HBufC16::NewL(KMaxFileName);
+        CleanupStack::PushL( albumName );
+
+        // create item string for listbox (icon + album name)
+        TPtrC16 collectionName = iCollectionNames->MdcaPoint( index );
+        albumName->Des().Format( KItemFormatString, &collectionName ); 
+
+        // append album name to the listbox
+        aSettingsTextArray->AppendL( albumName->Des() );
+
+        // check if album is shared earlier
+        if ( IsItemShared( iCollIdArray->MdcaPoint( index ), *sharedStuff ) )
+            {
+            //Index can't be '0' or '1' because there are predefined 
+            //selections such as "share nothing" and "share all" first.
+            iSelectedImages->AppendL( index + KPredefinedSelections );
+            }
+
+
+        CleanupStack::PopAndDestroy( albumName );
+        albumName = NULL;
+        }
+
+    GetVisualSharingStateL( iVisualSharingSelection );
+
+    if ( iVisualSharingSelection == EShareAll )
+       {
+        iSelectedImages->Reset();
+        // if all albums were shared mark only "share all"
+        iSelectedImages->AppendL( KShareAllIndex );
+        }
+    else if ( iVisualSharingSelection == EShareNone )
+        {
+        iSelectedImages->Reset();
+        // if no albums were shared mark only "share nothing"
+        iSelectedImages->AppendL( KShareNoneIndex );
+        }
+
+    iContainerCount = aSettingsTextArray->MdcaCount();
+
+    CleanupStack::PopAndDestroy( sharedStuff );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::FetchPlaylistsL()
+// Fetch playlists from Media Gallery for the listbox.
+// --------------------------------------------------------------------------
+//
+void CUpnpSelectionReader::FetchPlaylistsL( CDesCArray* aSettingsTextArray )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    if ( !aSettingsTextArray )
+        {
+        User::Leave( KErrGeneral );
+        }
+
+    // This is for IsItemSharedL
+    iMediaType = EPlaylist;
+
+    if ( iSelectedMusic )
+        {
+        iSelectedMusic->Reset();
+        }
+
+    if ( iPlIdArray )
+        {
+        iPlIdArray->Reset();
+        }
+
+    if( iPlaylistNames )
+        {
+        iPlaylistNames->Reset();
+        }
+
+    // container where items will be added
+    CDesCArray* sharedStuff = new (ELeave) CDesCArrayFlat( 
+        KDefaultStringArrGranularity );
+    CleanupStack::PushL( sharedStuff );
+
+    // Read previously shared playlist ids for calculating indexes
+    ReadSharedContainerIDsL( sharedStuff,
+                             EPlaylist );
+
+    // search .m3u files put them to iPlIdArray
+    SearchPlaylistFilesL();
+
+    for ( TInt fileIndex = 0; 
+          fileIndex < iPlIdArray->MdcaCount(); fileIndex++ )
+        {
+        HBufC16* listboxItem = HBufC16::NewL(KMaxFileName);
+        CleanupStack::PushL(listboxItem);
+
+        TPtrC itemName( iPlaylistNames->MdcaPoint( fileIndex ) );
+
+        TBuf<KMaxFileName> nameBuf;
+        nameBuf.Copy( itemName );
+        listboxItem->Des().Format(KItemFormatString, &nameBuf );
+        aSettingsTextArray->AppendL( listboxItem->Des() );
+
+        if ( IsItemShared( iPlIdArray->MdcaPoint( fileIndex ),
+                           *sharedStuff ) )
+            {
+            //Index can't be '0' or '1' because there are predefined 
+            //selections such as "share nothing" and "share all" first.
+            iSelectedMusic->AppendL( fileIndex + KPredefinedSelections );
+            }
+
+        CleanupStack::PopAndDestroy( listboxItem );
+        listboxItem = NULL;
+        }
+
+    GetMusicSharingStateL( iMusicSharingSelection );
+
+    if ( iMusicSharingSelection == EShareAll )
+        {
+        iSelectedMusic->Reset();
+        // if all albums were shared mark only "share all"
+        iSelectedMusic->AppendL( KShareAllIndex );
+        }
+    else if ( iMusicSharingSelection == EShareNone )
+        {
+        iSelectedMusic->Reset();
+        // if no albums were shared mark only "share nothing"
+        iSelectedMusic->AppendL( KShareNoneIndex );
+        }
+    iContainerCount = aSettingsTextArray->MdcaCount();
+    CleanupStack::PopAndDestroy( sharedStuff );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::SearchPlaylistFilesL()
+// Search playlist files
+// --------------------------------------------------------------------------
+//
+TBool CUpnpSelectionReader::SearchPlaylistFilesL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    CUPnPPlaylistServices* playlists = CUPnPPlaylistServices::NewL();
+    CleanupStack::PushL( playlists );
+    
+    playlists->ListPlaylistsL( *iPlIdArray, *iPlaylistNames );
+    // for debugging
+
+#ifdef _DEBUG
+    __LOG("CUpnpSelectionReader: Checking playlist validity.");
+    for ( TInt i(0); i<iPlIdArray->MdcaCount(); i++ )
+        {
+        TBool valid(EFalse);
+        TRAPD( err, valid = playlists->IsValidPlaylistL( 
+                   iPlaylistNames->MdcaPoint(i) ));
+        if ( !err )
+            {
+            TPtrC id( iPlIdArray->MdcaPoint(i) );
+            __LOG3("Playlist[%d] %S IsValid: %d",
+                i, &id, valid );
+            }
+        }
+#endif
+    CleanupStack::PopAndDestroy( playlists );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return ETrue;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::SearchCollectionsL
+// fill iCollIdArray
+// --------------------------------------------------------------------------
+//
+TBool CUpnpSelectionReader::SearchCollectionsL()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    CUPnPAlbumServices* albums = CUPnPAlbumServices::NewL();
+    CleanupStack::PushL( albums );
+    
+    albums->ListAlbumsL( *iCollIdArray, *iCollectionNames );
+
+#ifdef _DEBUG
+    __LOG("CUpnpSelectionReader: Checking album validity.");
+    for ( TInt i(0); i<iCollIdArray->MdcaCount(); i++ )
+        {
+        TBool valid(EFalse);
+        TRAPD( err, valid = albums->IsValidAlbumL( 
+                   iCollectionNames->MdcaPoint(i) ));
+        if ( !err )
+            {
+            TPtrC id( iCollIdArray->MdcaPoint(i) );
+            __LOG3("Album[%d] %S IsValid: %d",
+                i, &id, valid );
+            }
+        }
+#endif
+    CleanupStack::PopAndDestroy( albums );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return ETrue;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileSharingEngine::ReadSharedContainerIDsL
+// Reads shared container IDs from file
+// --------------------------------------------------------------------------
+//
+TInt CUpnpSelectionReader::ReadSharedContainerIDsL(
+    CDesCArray* aArray,
+    const TUpnpMediaType& aContainerType ) const
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Leave if NULL
+    if ( !aArray )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    RFs fs;
+    RFile file;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+
+    TInt error = KErrNone;
+
+    if ( aContainerType == EImageAndVideo )
+        {
+        error = file.Open(fs, KVisualFile, EFileRead );
+        }
+    else if ( aContainerType == EPlaylist )
+        {
+        error = file.Open(fs, KMusicFile, EFileRead );
+        }
+    else
+        {
+        // Not valid container type
+        error = KErrNotFound;
+        }
+
+    if ( error == KErrNone )
+        {
+        CleanupClosePushL( file );
+        RFileReadStream readStream( file );
+        CleanupClosePushL( readStream );
+
+        HBufC* collectionName = HBufC::NewL(KMaxFileName);
+        CleanupStack::PushL( collectionName );
+        TPtr collection = collectionName->Des();
+
+        do
+            {
+            TRAPD(err, readStream >> collection); //leaves when eof
+            if (err)
+                {
+                error = err;
+                }
+            else
+                {
+                aArray->AppendL(collection);
+                }
+
+            }  while(error == KErrNone); // end of file
+
+        CleanupStack::PopAndDestroy( collectionName );
+        CleanupStack::PopAndDestroy( &readStream ); // Close readStream
+        CleanupStack::PopAndDestroy( &file ); // Close file
+        }
+
+     CleanupStack::PopAndDestroy( &fs );
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return error;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUPnPFileSharingEngine::GetSelectionIndexesL
+// Reads shared container IDs from file
+// --------------------------------------------------------------------------
+//
+void CUpnpSelectionReader::GetSelectionIndexesL(
+    RArray<TInt>& aSelections,
+    const TUpnpMediaType& aType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    RArray<TInt>* list( NULL );
+    if ( aType == EImageAndVideo )
+        {
+        if ( !iSelectedImages )
+            {
+            iImageContainers->Reset();
+            FetchCollectionsL( iImageContainers );
+            iImageContainers->Reset();
+            }
+        else if ( !iImageContainers )
+            {
+            iImageContainers = new (ELeave) CDesCArrayFlat( 
+                KDefaultStringArrGranularity );
+            FetchCollectionsL( iImageContainers );
+            }
+        else 
+            {
+            FetchCollectionsL( iImageContainers );
+            }
+            
+        list = iSelectedImages;
+        }
+    else
+        {
+        if ( !iSelectedMusic )
+            {
+            iPlaylistNames->Reset();
+            FetchPlaylistsL( iPlaylistNames );
+            iPlaylistNames->Reset();
+            }
+        else if ( iPlaylistNames )
+            {
+            iPlaylistNames = new (ELeave) 
+                CDesCArrayFlat( KDefaultStringArrGranularity );
+            FetchPlaylistsL( iPlaylistNames );
+            }
+        else 
+            {
+            FetchPlaylistsL( iPlaylistNames );
+            }
+        
+        list = iSelectedMusic;
+        }
+
+    for ( TInt i(0); i< list->Count(); i++ )
+        {
+        aSelections.AppendL( list->operator[]( i ) );
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::GetVisualSharingStateL
+// (other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TInt CUpnpSelectionReader::GetVisualSharingStateL( TInt& aShareAllState )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    CRepository* rep = CRepository::NewL( KCrUidUpnpContentserver );
+    CleanupStack::PushL( rep );
+    TInt err( rep->Get( KUPnPAppShareAllVisualFiles, aShareAllState ));
+    CleanupStack::PopAndDestroy( rep );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::GetMusicSharingStateL
+// (other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TInt CUpnpSelectionReader::GetMusicSharingStateL( TInt& aShareAllState )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    CRepository* rep = CRepository::NewL( KCrUidUpnpContentserver );
+    CleanupStack::PushL( rep );
+    TInt err( rep->Get( KUPnPAppShareAllMusicFiles, aShareAllState ));
+    CleanupStack::PopAndDestroy( rep );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::GetContainerCount
+// (other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TInt CUpnpSelectionReader::GetContainerCount() const
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return iContainerCount;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::PlayListIdsL
+// (other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TInt CUpnpSelectionReader::PlayListIdsL( CDesCArray& aPlaylistIds, 
+                                        CDesCArray& aPlaylistNames )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TInt err( KErrNone );
+    if ( iPlIdArray && iPlaylistNames )
+        {
+        for ( TInt i(0); i < iPlIdArray->MdcaCount(); i++ )
+            {
+            aPlaylistIds.AppendL( iPlIdArray->MdcaPoint( i ) );
+            aPlaylistNames.AppendL( iPlaylistNames->MdcaPoint( i ) );
+            }
+        }
+    else
+        {
+        err = KErrGeneral;
+        }
+    
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::CollectionIdsL
+// (other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TInt CUpnpSelectionReader::CollectionIdsL( CDesCArray& aCollectionIds,
+                                             CDesCArray& aCollectionNames )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TInt err( KErrNone );
+    if ( iCollIdArray && iCollectionNames )
+        {
+        for ( TInt i(0); i < iCollIdArray->MdcaCount(); i++ )
+            {
+            aCollectionIds.AppendL( iCollIdArray->MdcaPoint( i ) );
+            aCollectionNames.AppendL( iCollectionNames->MdcaPoint( i ) );
+            }
+        }
+    else
+        {
+        err = KErrGeneral;
+        }
+    
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return err;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::GetCollectionItemsL
+// (other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TPtrC CUpnpSelectionReader::GetCollectionItemsL( const TInt aSelectionIndex, 
+    CDesCArray& aFilenames )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TPtrC collId;
+    TInt index = aSelectionIndex - KUiSelectionOffset;
+    if ( index < 0 || index >= iCollIdArray->Count() )
+        {
+        // index is not valid
+        collId.Set( KNullDesC );
+        }
+    else
+        {
+        // Find out collection id
+        collId.Set( iCollIdArray->MdcaPoint( index ) );
+        
+        // Fetch collection items
+        CUPnPAlbumServices* albums = CUPnPAlbumServices::NewL();
+        CleanupStack::PushL( albums );
+        albums->OpenAlbumL( collId, aFilenames );
+        TInt count = aFilenames.Count();
+        CleanupStack::PopAndDestroy( albums );        
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return collId;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionReader::GetPlaylistItemsL
+// (other items are commented in header )
+// --------------------------------------------------------------------------
+//
+TPtrC CUpnpSelectionReader::GetPlaylistItemsL( const TInt aSelectionIndex, 
+    CDesCArray& aFilenames )    
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TPtrC plId;
+    TInt index = aSelectionIndex - KUiSelectionOffset;    
+    if ( index < 0 || index >= iPlIdArray->Count() )    
+        {
+        // index is not valid
+        plId.Set( KNullDesC );
+        }
+    else
+        {
+        // Find out playlist id
+        plId.Set( iPlIdArray->MdcaPoint( index ) );
+
+        // Fetch playlist items
+        CUPnPPlaylistServices* playlists = CUPnPPlaylistServices::NewL();
+        CleanupStack::PushL( playlists );
+        playlists->OpenPlaylistL( iPlIdArray->MdcaPoint( index ), aFilenames );
+        CleanupStack::PopAndDestroy( playlists );        
+        }
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return plId;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileSharingEngine::GetSelectionIndexesL
+// Reads shared container IDs from file
+// --------------------------------------------------------------------------
+//
+TInt CUpnpSelectionReader::GetSelectionIndexL(
+    const TUpnpMediaType& aType,
+    TPtrC aClfId )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    TInt selectionIndex( KErrNotFound );
+
+    // image and video
+    if ( aType == EImageAndVideo && iCollIdArray->Count() )
+        {
+        iCollIdArray->Find( aClfId, selectionIndex );
+        if ( selectionIndex >= iCollIdArray->Count() )
+            {
+            // not found in iCollIdArray
+            selectionIndex = KErrNotFound;
+            }
+        else
+            {
+            selectionIndex = 
+                selectionIndex + KUiSelectionOffset;
+            }
+        }
+    // music
+    else if ( aType == EPlaylist && iPlIdArray->Count() )
+        {
+        iPlIdArray->Find( aClfId, selectionIndex );
+        if ( selectionIndex >= iPlIdArray->Count() )
+            {
+            // not found in iPlIdArray
+            selectionIndex = KErrNotFound;
+            }
+        else
+            {
+            selectionIndex = 
+                selectionIndex + KUiSelectionOffset;
+            }
+        }
+    else
+        {
+        // invalid type or the array is empty
+        selectionIndex = KErrNotFound;
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    // return selection index taking into count Ui offset
+    return selectionIndex;
+    }
+
+// End of file
--- a/upnpsharing/upnpcontentserver/src/upnpselectionwriter.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/src/upnpselectionwriter.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,254 +1,235 @@
-/*
-* Copyright (c) 2005-2007 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:      CUpnpSelectionWriter class implementation
- *
-*/
-
-
-
-
-
-
-// INCLUDE FILES
-
-#include <upnpstring.h>
-#include <centralrepository.h>
-#include <s32file.h>
-
-#include "upnpselectionwriter.h"
-#include "upnpcontentservercrkeys.h"
-#include "upnpcontentserverdefs.h"
-
-_LIT( KComponentLogfile, "contentserver.txt");
-#include "upnplog.h"
-
-using namespace UpnpContentServer;
-
-// ================= MEMBER FUNCTIONS =======================
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionWriter::NewL
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-CUpnpSelectionWriter* CUpnpSelectionWriter::NewL(
-    TUpnpMediaType aMediaType )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    CUpnpSelectionWriter* self =
-        new(ELeave) CUpnpSelectionWriter();
-
-    CleanupStack::PushL(self);
-    self->ConstructL( aMediaType );
-    CleanupStack::Pop(self);
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionWriter::ConstructL
-// Symbian 2nd phase constructor can leave.
-// --------------------------------------------------------------------------
-//
-void CUpnpSelectionWriter::ConstructL(
-    TUpnpMediaType aMediaType )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iMediaType = aMediaType;
-
-    iFileArray = new (ELeave) CDesCArrayFlat(4);
-    iOkItems.Reset();
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionWriter::CUpnpSelectionWriter
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// --------------------------------------------------------------------------
-//
-CUpnpSelectionWriter::CUpnpSelectionWriter()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionWriter::CUpnpSelectionWriter
-// C++ default destructor.
-// --------------------------------------------------------------------------
-//
-CUpnpSelectionWriter::~CUpnpSelectionWriter()
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    delete iFileArray;
-    iOkItems.Reset();
-    delete iRepository;
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionWriter::AppendItemL
-// ( other items were commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpSelectionWriter::AppendItemL( const TPtrC aNewObject)
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iFileArray->AppendL( aNewObject  );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionWriter::AppendStatusL
-// ( other items were commented in header )
-// --------------------------------------------------------------------------
-//
-void CUpnpSelectionWriter::AppendStatusL( TInt aIndex )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-    iOkItems.AppendL( aIndex  );
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSelectionWriter::SaveSharingState
-// Saves sharing state to central repository
-// --------------------------------------------------------------------------
-//
-TInt CUpnpSelectionWriter::SaveSharingStateL( TInt aShareAllSelection )
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    TInt status = KErrNone;
-    iRepository = CRepository::NewL( KCrUidUpnpContentserver );
-    switch ( iMediaType )
-        {
-    case EImageAndVideo:
-        {
-        if (aShareAllSelection == EShareAll ||
-            aShareAllSelection == EShareNone ||
-            aShareAllSelection == EShareMany )
-            {
-            status = iRepository->Set( KUPnPAppShareAllVisualFiles,
-                                       aShareAllSelection);
-            }
-        break;
-        }
-    case EPlaylist:
-        {
-        if (aShareAllSelection == EShareAll ||
-            aShareAllSelection == EShareNone ||
-            aShareAllSelection == EShareMany )
-            {
-            status = iRepository->Set( KUPnPAppShareAllMusicFiles,
-                                       aShareAllSelection);
-            }
-        break;
-        }
-    default:
-        {
-        __LOG( "SaveSharingStateL - default");
-        break;
-        }
-        }
-
-    delete iRepository;
-    iRepository = NULL;
-
-    // Store the item array
-    if ( aShareAllSelection == EShareMany )
-        {
-        StoreSharedContainerIDsL();
-        }
-
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return status;
-    }
-
-// --------------------------------------------------------------------------
-// CUPnPFileSharingEngine::StoreSharedContainerIDsL
-// Creates main containers and starts sharing them
-// --------------------------------------------------------------------------
-//
-TInt CUpnpSelectionWriter::StoreSharedContainerIDsL() const
-    {
-    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
-
-    // Leave if aIdArray = NULL
-    if ( !iFileArray )
-        {
-        User::Leave(KErrArgument);
-        }
-
-    RFs fs;
-    RFile file;
-    User::LeaveIfError( fs.Connect() );
-    CleanupClosePushL(fs);
-
-    TFileName directory;
-
-    // Get private directory path
-    fs.SessionPath(directory);
-
-    // Try to create directory
-    TInt error = fs.MkDir(directory);
-    // it's ok if directory already exists
-    if (!(error != KErrNone && error != KErrAlreadyExists))
-        {
-
-        // Add file name
-        if ( iMediaType == EImageAndVideo )
-            {
-            directory.Append( KVisualFile );
-            }
-        else if ( iMediaType == EPlaylist )
-            {
-            directory.Append( KMusicFile );
-            }
-
-        error = file.Replace(fs, directory, EFileWrite );
-        if ( !error )
-            {
-            CleanupClosePushL( file );
-            RFileWriteStream writeStream(file);
-            CleanupClosePushL( writeStream );
-
-            for (TInt index = 0; index < iFileArray->Count(); index++)
-                {
-                // check that sharing of the container was succesful
-                if ( iOkItems.Find( index ) != KErrNotFound )
-                    {
-                    // Write identifiers to the file
-                    writeStream << iFileArray->MdcaPoint(index);
-                    }
-                }
-
-            // Clean up
-            CleanupStack::PopAndDestroy(&writeStream); // Close writeStream
-            CleanupStack::PopAndDestroy(&file); // Close file
-            }
-        }
-    CleanupStack::PopAndDestroy(&fs);
-    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
-    return error;
-    }
-
-// End of file
+/*
+* Copyright (c) 2005-2007 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:      CUpnpSelectionWriter class implementation
+ *
+*/
+
+
+
+
+
+
+// INCLUDE FILES
+
+#include <upnpstring.h>
+#include <centralrepository.h>
+#include <s32file.h>
+
+#include "upnpselectionwriter.h"
+#include "upnpcontentservercrkeys.h"
+#include "upnpcontentserverdefs.h"
+
+_LIT( KComponentLogfile, "contentserver.txt");
+#include "upnplog.h"
+
+using namespace UpnpContentServer;
+
+// ================= MEMBER FUNCTIONS =======================
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionWriter::NewL
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+//
+CUpnpSelectionWriter* CUpnpSelectionWriter::NewL(
+    TUpnpMediaType aMediaType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    CUpnpSelectionWriter* self =
+        new(ELeave) CUpnpSelectionWriter();
+
+    CleanupStack::PushL(self);
+    self->ConstructL( aMediaType );
+    CleanupStack::Pop(self);
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionWriter::ConstructL
+// Symbian 2nd phase constructor can leave.
+// --------------------------------------------------------------------------
+//
+void CUpnpSelectionWriter::ConstructL(
+    TUpnpMediaType aMediaType )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    iMediaType = aMediaType;
+
+    iFileArray = new (ELeave) CDesCArrayFlat(4);
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionWriter::CUpnpSelectionWriter
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// --------------------------------------------------------------------------
+//
+CUpnpSelectionWriter::CUpnpSelectionWriter()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionWriter::CUpnpSelectionWriter
+// C++ default destructor.
+// --------------------------------------------------------------------------
+//
+CUpnpSelectionWriter::~CUpnpSelectionWriter()
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    delete iFileArray;
+    delete iRepository;
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionWriter::AppendItemL
+// ( other items were commented in header )
+// --------------------------------------------------------------------------
+//
+void CUpnpSelectionWriter::AppendItemL( const TPtrC aNewObject)
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+    iFileArray->AppendL( aNewObject  );
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSelectionWriter::SaveSharingState
+// Saves sharing state to central repository
+// --------------------------------------------------------------------------
+//
+TInt CUpnpSelectionWriter::SaveSharingStateL( TInt aShareAllSelection )
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    TInt status = KErrNone;
+    iRepository = CRepository::NewL( KCrUidUpnpContentserver );
+    switch ( iMediaType )
+        {
+    case EImageAndVideo:
+        {
+        if (aShareAllSelection == EShareAll ||
+            aShareAllSelection == EShareNone ||
+            aShareAllSelection == EShareMany )
+            {
+            status = iRepository->Set( KUPnPAppShareAllVisualFiles,
+                                       aShareAllSelection);
+            }
+        break;
+        }
+    case EPlaylist:
+        {
+        if (aShareAllSelection == EShareAll ||
+            aShareAllSelection == EShareNone ||
+            aShareAllSelection == EShareMany )
+            {
+            status = iRepository->Set( KUPnPAppShareAllMusicFiles,
+                                       aShareAllSelection);
+            }
+        break;
+        }
+    default:
+        {
+        __LOG( "SaveSharingStateL - default");
+        break;
+        }
+        }
+
+    delete iRepository;
+    iRepository = NULL;
+
+    // Store the item array
+    if ( aShareAllSelection == EShareMany )
+        {
+        StoreSharedContainerIDsL();
+        }
+
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return status;
+    }
+
+// --------------------------------------------------------------------------
+// CUPnPFileSharingEngine::StoreSharedContainerIDsL
+// Creates main containers and starts sharing them
+// --------------------------------------------------------------------------
+//
+TInt CUpnpSelectionWriter::StoreSharedContainerIDsL() const
+    {
+    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
+
+    // Leave if aIdArray = NULL
+    if ( !iFileArray )
+        {
+        User::Leave(KErrArgument);
+        }
+
+    RFs fs;
+    RFile file;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL(fs);
+
+    TFileName directory;
+
+    // Get private directory path
+    fs.SessionPath(directory);
+
+    // Try to create directory
+    TInt error = fs.MkDir(directory);
+    // it's ok if directory already exists
+    if (!(error != KErrNone && error != KErrAlreadyExists))
+        {
+
+        // Add file name
+        if ( iMediaType == EImageAndVideo )
+            {
+            directory.Append( KVisualFile );
+            }
+        else if ( iMediaType == EPlaylist )
+            {
+            directory.Append( KMusicFile );
+            }
+
+        error = file.Replace(fs, directory, EFileWrite );
+        if ( !error )
+            {
+            CleanupClosePushL( file );
+            RFileWriteStream writeStream(file);
+            CleanupClosePushL( writeStream );
+
+            for (TInt index = 0; index < iFileArray->Count(); index++)
+                {
+                writeStream << iFileArray->MdcaPoint(index);
+                }
+
+            // Clean up
+            CleanupStack::PopAndDestroy(&writeStream); // Close writeStream
+            CleanupStack::PopAndDestroy(&file); // Close file
+            }
+        }
+    CleanupStack::PopAndDestroy(&fs);
+    __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
+    return error;
+    }
+
+// End of file
--- a/upnpsharing/upnpcontentserver/src/upnpsharingrequest.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpcontentserver/src/upnpsharingrequest.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,96 +1,101 @@
-/*
-* Copyright (c) 2006-2007 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:      CUpnpSharingRequest class implementation
-*
-*/
-
-
-
-
-
-
-
-// INCLUDE FILES
-#include "upnpsharingrequest.h"
-#include "upnpcontentserverdefs.h"
-
-const TInt KDefaultItemCount = 2^32; //4294967296
-
-using namespace UpnpContentServer;
-
-// ============================ MEMBER FUNCTIONS =============================
-
-// --------------------------------------------------------------------------
-// CUpnpSharingRequest::CUpnpSharingRequest
-// C++ default constructor can NOT contain any code, that
-// might leave.
-// --------------------------------------------------------------------------
-//
-
-CUpnpSharingRequest::CUpnpSharingRequest( TInt aKind )
-    {
-    iKind = aKind;
-    iItemCount = KDefaultItemCount;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSharingRequest::ConstructL
-// Symbian 2nd phase constructor can leave.
-// --------------------------------------------------------------------------
-//
-void CUpnpSharingRequest::ConstructL( const RArray<TInt>& aArr, 
-                                      CDesCArray* aIdArray,
-                                      CDesCArray* aNameArray )
-    {
-    for ( TInt i(0); i<aArr.Count();i++ )
-        {
-        iSelections.AppendL( aArr[ i ] );
-        }
-    iObjectIds = aIdArray; // transfer ownership
-    iObjectNames = aNameArray;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSharingRequest::NewL
-// Two-phased constructor.
-// --------------------------------------------------------------------------
-//
-CUpnpSharingRequest* CUpnpSharingRequest::NewL(
-    TInt aKind,
-    const RArray<TInt>& aArr,
-    CDesCArray* aIdArray,
-    CDesCArray* aNameArray )
-    {
-    CUpnpSharingRequest* self = new (ELeave) CUpnpSharingRequest( aKind );
-    CleanupStack::PushL( self );
-    self->ConstructL( aArr,
-                      aIdArray,
-                      aNameArray );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpSharingRequest::NewL
-// Destructor
-// --------------------------------------------------------------------------
-// 
-CUpnpSharingRequest::~CUpnpSharingRequest()
-    {
-    iSelections.Close();
-    delete iObjectIds;
-    }
-
-
-//  End of File
+/*
+* Copyright (c) 2006-2007 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:      CUpnpSharingRequest class implementation
+*
+*/
+
+// INCLUDE FILES
+#include "upnpsharingrequest.h"
+#include "upnpcontentserverdefs.h"
+
+
+using namespace UpnpContentServer;
+
+// ============================ MEMBER FUNCTIONS =============================
+
+// --------------------------------------------------------------------------
+// CUpnpSharingRequest::CUpnpSharingRequest
+// C++ default constructor can NOT contain any code, that
+// might leave.
+// --------------------------------------------------------------------------
+//
+
+CUpnpSharingRequest::CUpnpSharingRequest( 
+    TUpnpMediaType aMediaType, 
+    TInt aSharingType ) :
+    iMediaType( aMediaType ),
+    iSharingType( aSharingType )
+    {
+    // empty
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSharingRequest::NewL
+// Two-phased constructor.
+// --------------------------------------------------------------------------
+//
+CUpnpSharingRequest* CUpnpSharingRequest::NewL( 
+    TUpnpMediaType aMediaType, 
+    TInt aSharingType )
+    {
+    CUpnpSharingRequest* self = 
+        new (ELeave) CUpnpSharingRequest( aMediaType, aSharingType );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSharingRequest::SetSharingRequestInfoL
+// Sets sharing request information arrays
+// --------------------------------------------------------------------------
+// 
+void CUpnpSharingRequest::SetSharingRequestInfo( 
+    RArray<TFileName>* aShareArr,
+    RArray<TFileName>* aUnshareArr,
+    CDesCArray* aClfIds )
+    {
+    // take ownership of the arrays
+    iShareArr = aShareArr;
+    iUnshareArr = aUnshareArr;
+    iClfIds = aClfIds;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpSharingRequest::~CUpnpSharingRequest
+// Destructor
+// --------------------------------------------------------------------------
+// 
+CUpnpSharingRequest::~CUpnpSharingRequest()
+    {
+    // Destructor
+    if ( iShareArr )
+        {
+        iShareArr->Close();
+        delete iShareArr;
+        }
+    if ( iUnshareArr )
+        {
+        iUnshareArr->Close();
+        delete iUnshareArr;
+        }
+    if ( iClfIds )
+        {
+        delete iClfIds;
+        }
+    }
+
+
+//  End of File
--- a/upnpsharing/upnpdlnaprofiler/group/dlnaprofiler.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpdlnaprofiler/group/dlnaprofiler.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,68 +1,70 @@
-/*
-* Copyright (c) 2006-2007 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:      Project definition file for project DlnaProfiler
-*
-*/
-
-
-
-
-
-
-#include "../../../group/upnpplatformvar.hrh"
-#include <data_caging_paths.hrh>
-#include "../../../inc/upnpframeworkfeatures_mmp.hrh"
-
-TARGET                  dlnaprofiler.dll
-TARGETTYPE              DLL
-UID                     0x1000008d 0x20007560
-
-CAPABILITY              CAP_GENERAL_DLL
-VENDORID                VID_DEFAULT
-
-// SIS installation + IAD support
-VERSION 10.1
-paged
-
-SOURCEPATH              ../src
-SOURCE                  upnpdlnaprofiler.cpp
-SOURCE                  upnpaudiosolverbase.cpp
-SOURCE                  upnpavsolverbase.cpp
-SOURCE                  upnpimagesolverbase.cpp
-SOURCE                  upnpresresolver.cpp
-SOURCE                  upnpresparameters.cpp
-
-USERINCLUDE             ../inc
-USERINCLUDE             ../../../inc
-
-MW_LAYER_SYSTEMINCLUDE
-
-
-LIBRARY                 euser.lib
-LIBRARY                 efsrv.lib
-LIBRARY                 apgrfx.lib 
-LIBRARY                 mediaclientaudio.lib
-LIBRARY                 apmime.lib
-LIBRARY                 imageconversion.lib // CImageDecoder
-LIBRARY                 bafl.lib // CDesC16ArrayFlat
-LIBRARY                 3gpmp4lib.lib
-LIBRARY                 inetprotutil.lib // EscapeUtils::ConvertFromUnicodeToUtf8L
-
-// From UPnP Stack
-LIBRARY                 upnpavobjects.lib // CUpnpDlnaProtocolInfo for S60 3.1. Not needed in S60 3.2 platform.
-LIBRARY                 upnpipserversutils.lib // CUpnpDlnaProtocolInfo for S60 3.2. Not needed in S60 3.1 platform.
-
-DEBUGLIBRARY            flogger.lib
-
-// End of file
+/*
+* Copyright (c) 2006-2007 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:      Project definition file for project DlnaProfiler
+*
+*/
+
+
+
+
+
+
+#include "../../../group/upnpplatformvar.hrh"
+#include <data_caging_paths.hrh>
+#include "../../../inc/upnpframeworkfeatures_mmp.hrh"
+
+TARGET                  dlnaprofiler.dll
+TARGETTYPE              DLL
+UID                     0x1000008d 0x20007560
+
+CAPABILITY              CAP_GENERAL_DLL
+VENDORID                VID_DEFAULT
+
+// SIS installation + IAD support
+VERSION 10.1
+paged
+
+SOURCEPATH              ../src
+SOURCE                  upnpdlnaprofiler.cpp
+SOURCE                  upnpaudiosolverbase.cpp
+SOURCE                  upnpavsolverbase.cpp
+SOURCE                  upnpimagesolverbase.cpp
+SOURCE                  upnpresresolver.cpp
+SOURCE                  upnpresparameters.cpp
+
+USERINCLUDE             ../inc
+USERINCLUDE             ../../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+
+LIBRARY                 euser.lib
+LIBRARY                 efsrv.lib
+LIBRARY                 apgrfx.lib 
+LIBRARY                 mediaclientaudio.lib
+LIBRARY                 apmime.lib
+LIBRARY                 imageconversion.lib // CImageDecoder
+LIBRARY                 bafl.lib // CDesC16ArrayFlat
+LIBRARY                 3gpmp4lib.lib
+LIBRARY                 inetprotutil.lib // EscapeUtils::ConvertFromUnicodeToUtf8L
+
+// From UPnP Stack
+LIBRARY                 upnpipserversutils.lib // CUpnpDlnaProtocolInfo for S60 3.2. Not needed in S60 3.1 platform.
+
+// dlnasrv
+LIBRARY                 upnpavobjects.lib // CUpnpDlnaProtocolInfo for S60 3.1. Not needed in S60 3.2 platform.
+
+DEBUGLIBRARY            flogger.lib
+
+// End of file
--- a/upnpsharing/upnpdlnaprofiler/inc/upnpavsolverbase.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpdlnaprofiler/inc/upnpavsolverbase.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,145 +1,145 @@
-/*
-* Copyright (c) 2006-2007 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:      Base DLNA profile resolver class for av files.
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPAVSOLVERBASE_H
-#define C_UPNPAVSOLVERBASE_H
-
-
-// system includes
-#include <3gplibrary/mp4lib.h>
-
-// user includes
-#include "upnpprofiler.h"
-
-// forward declarations
-class CVideoRecorderUtility;
-
-// constants
-const TInt TMP4DecoderSpecificInfoSize = 16;
-
-// NONE
-
-/**
- *  Av file DLNA profile base resolver class.
- *
- *  This class is the base class for resolving DLNA profile of av files.
- *  It contains methods for querying the profiles supported by this solver 
- *  and for resolving a DLNA profile of a given av file.
- *
- *
- *  @lib dlnaprofiler.lib
- *  @since S60 v3.1
- */
-NONSHARABLE_CLASS( CUpnpAvSolverBase ) : public CBase,
-                                         public MUpnpProfiler
-    {
-
-public:
-
-    static CUpnpAvSolverBase* NewL();
-
-    static CUpnpAvSolverBase* NewLC();
-
-    virtual ~CUpnpAvSolverBase();
-
-// from base class MUpnpProfiler
-
-    /**
-     * From MUpnpProfiler.
-     * SupportedProfilesL returns DLNA profiles that are currently supported.
-     *
-     * @since S60 v3.1
-     * @param aProfiles Descriptor array where supported DLNA profiles are 
-     *                  added.
-     * @return TInt Error code, KErrNone if successfull.
-     */
-    TInt SupportedProfilesL( CDesC16ArrayFlat* aProfiles ) const;
-
-    /**
-     * From MUpnpProfiler.
-     * ProfileForFileL is for resolving a DLNA profile of a given file.
-     * Besides of file name, also mime type of the file is passed as a 
-     * parameter in order to avoid re-opening of the file.
-     *
-     * @since S60 v3.1
-     * @param aFileName Filename of the file which is to be resolved.
-     * @param aMimeType Mime type of the file which is to be resolved.
-     * @param aFile Handle to opened file specified by aFilename
-     * @return DLNA profile of the file as a HBufC*, 
-     *         NULL if could not be resolved
-     */
-    HBufC* ProfileForFileL( const TDesC& aFilename, 
-                            const TDesC8& aMimetype,
-                            RFile& aFile );
-
-
-private:
-
-    CUpnpAvSolverBase();
-
-    void ConstructL();
-
-    /**
-     * GetVideoFileInformationL
-     *
-     * @since S60 v3.1
-     * @param aFileName Filename of the file which is to be resolved.
-     * @return Error code. KErrNone if successfull.
-     */
-    TInt GetVideoFileInformationL( RFile& aFile );
-
-    /**
-     * A generic data container to be used in parsing different
-     * MPEG4 codec headers
-     */
-    class TMP4DecoderSpecificInfo
-        {
-        public:
-            TUint32 iData[TMP4DecoderSpecificInfoSize];
-        };
-
-
-private: // data
-
-    // Type of video codec within the AV file
-    mp4_u32 iVideoType;
-
-    // Video resolution X size
-    mp4_u32 iVideoResolutionX;
-
-    // Video resolution Y size
-    mp4_u32 iVideoResolutionY;
-
-    mp4_double iVideoFramerate;
-
-    // Type of audio codec within the AV file
-    mp4_u32 iAudioType;
-
-    // stream bitrate
-    mp4_u32 iStreamAverageBitrate;
-
-    // codec-specific details
-    TMP4DecoderSpecificInfo iCodecInfo;
-
-    };
-
-#endif // C_UPNPAVSOLVERBASE_H
+/*
+* Copyright (c) 2006-2007 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:      Base DLNA profile resolver class for av files.
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPAVSOLVERBASE_H
+#define C_UPNPAVSOLVERBASE_H
+
+
+// system includes
+#include <3gplibrary/mp4lib.h>
+
+// user includes
+#include "upnpprofiler.h"
+
+// forward declarations
+class CVideoRecorderUtility;
+
+// constants
+const TInt TMP4DecoderSpecificInfoSize = 17;
+
+// NONE
+
+/**
+ *  Av file DLNA profile base resolver class.
+ *
+ *  This class is the base class for resolving DLNA profile of av files.
+ *  It contains methods for querying the profiles supported by this solver 
+ *  and for resolving a DLNA profile of a given av file.
+ *
+ *
+ *  @lib dlnaprofiler.lib
+ *  @since S60 v3.1
+ */
+NONSHARABLE_CLASS( CUpnpAvSolverBase ) : public CBase,
+                                         public MUpnpProfiler
+    {
+
+public:
+
+    static CUpnpAvSolverBase* NewL();
+
+    static CUpnpAvSolverBase* NewLC();
+
+    virtual ~CUpnpAvSolverBase();
+
+// from base class MUpnpProfiler
+
+    /**
+     * From MUpnpProfiler.
+     * SupportedProfilesL returns DLNA profiles that are currently supported.
+     *
+     * @since S60 v3.1
+     * @param aProfiles Descriptor array where supported DLNA profiles are 
+     *                  added.
+     * @return TInt Error code, KErrNone if successfull.
+     */
+    TInt SupportedProfilesL( CDesC16ArrayFlat* aProfiles ) const;
+
+    /**
+     * From MUpnpProfiler.
+     * ProfileForFileL is for resolving a DLNA profile of a given file.
+     * Besides of file name, also mime type of the file is passed as a 
+     * parameter in order to avoid re-opening of the file.
+     *
+     * @since S60 v3.1
+     * @param aFileName Filename of the file which is to be resolved.
+     * @param aMimeType Mime type of the file which is to be resolved.
+     * @param aFile Handle to opened file specified by aFilename
+     * @return DLNA profile of the file as a HBufC*, 
+     *         NULL if could not be resolved
+     */
+    HBufC* ProfileForFileL( const TDesC& aFilename, 
+                            const TDesC8& aMimetype,
+                            RFile& aFile );
+
+
+private:
+
+    CUpnpAvSolverBase();
+
+    void ConstructL();
+
+    /**
+     * GetVideoFileInformationL
+     *
+     * @since S60 v3.1
+     * @param aFileName Filename of the file which is to be resolved.
+     * @return Error code. KErrNone if successfull.
+     */
+    TInt GetVideoFileInformationL( RFile& aFile );
+
+    /**
+     * A generic data container to be used in parsing different
+     * MPEG4 codec headers
+     */
+    class TMP4DecoderSpecificInfo
+        {
+        public:
+            TUint32 iData[TMP4DecoderSpecificInfoSize];
+        };
+
+
+private: // data
+
+    // Type of video codec within the AV file
+    mp4_u32 iVideoType;
+
+    // Video resolution X size
+    mp4_u32 iVideoResolutionX;
+
+    // Video resolution Y size
+    mp4_u32 iVideoResolutionY;
+
+    mp4_double iVideoFramerate;
+
+    // Type of audio codec within the AV file
+    mp4_u32 iAudioType;
+
+    // stream bitrate
+    mp4_u32 iStreamAverageBitrate;
+
+    // codec-specific details
+    TMP4DecoderSpecificInfo iCodecInfo;
+
+    };
+
+#endif // C_UPNPAVSOLVERBASE_H
--- a/upnpsharing/upnpdlnaprofiler/inc/upnpresresolver.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpdlnaprofiler/inc/upnpresresolver.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,164 +1,186 @@
-/*
-* Copyright (c) 2006-2007 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:      Header file of CUpnpResResolver class. CUpnpResResolver is 
-*                a class used for resolving res field attributes for a given 
-*                file.
-*
-*/
-
-
-
-
-
-
-#ifndef C_UPNPRESRESOLVER_H
-#define C_UPNPRESRESOLVER_H
-
-// system includes
-#include <e32base.h>
-#include <mdaaudiosampleplayer.h> // CMdaAudioPlayerUtility
-
-// user includes
-// NONE
-
-// forward declarations
-class RFile;
-class CUpnpResParameters;
-
-// data types
-// NONE
-
-// constants
-// NONE
-
-/**
- *  CUpnpResResolver is a class for resolving res field attributes for a 
- *  given file.
- *
- *  CUpnpResResolver class can be used to resolve a res field attributes for 
- *  a media file (image, AV, video). Attributes resolved for media files are:
- *     - Protocolinfo for all files.
- *     - Resolution and size for images.
- *     - Duration and size for videos.
- *     - Duration and size for music.
- *
- *  @lib dlnaprofiler.lib
- *  @since S60 v3.1
- */
-class CUpnpResResolver: public CBase, 
-                        public MMdaAudioPlayerCallback
-    {
-public:
-
-    IMPORT_C static CUpnpResResolver* NewL();
-
-    IMPORT_C static CUpnpResResolver* NewLC();
-
-    virtual ~CUpnpResResolver();
-
-    /**
-     * GetResParametersL resolves parameters that will be needed in 
-     * res-element attributes.
-     *
-     * @since S60 v3.1
-     * @param const TDesC& File for which to obtain res parameters.
-     * @return CUpnpResParameters* Parameters needed for res-element.
-     */  
-    IMPORT_C CUpnpResParameters* GetResParametersL( const TDesC& aFilename );
-    
-private:
-
-    CUpnpResResolver();
-
-    void ConstructL();
-
-    /**
-     * GetMimetypeL returns the mime type of the file.
-     *
-     * @since S60 v3.1
-     * @param RFile& File for which to obtain mime.
-     * @return HBufC8* Mime type of the file.
-     */  
-    HBufC8* GetMimetypeL( RFile& aFile );
-    
-    /**
-     * GetAudioDurationL obtains the duration of a audio file.
-     * After call the duration is in iDuration member variable.
-     *
-     * @since S60 v3.1
-     * @param const TDesC& The audio file for which to obtain duration.
-     */  
-    void GetAudioDurationL( const TDesC& aFilename );
-
-    /**
-     * GetVideoDurationL obtains the duration of a video file.
-     * After call the duration is in iDuration member variable.
-     *
-     * @since S60 v3.1
-     * @param RFile& The video file for which to obtain duration.
-     */  
-    void GetVideoDurationL( RFile& aFile );
-
-    /**
-     * GetFileSizeL returns the size of file in bytes.
-     *
-     * @since S60 v3.1
-     * @param RFile& The file for which to obtain size
-     * @return TInt File size.
-     */  
-    TInt GetFileSizeL( RFile& aFile );
-
-    /**
-     * GetImageResolutionL returns the resolution of the image.
-     *
-     * @since S60 v3.1
-     * @param RFile& File for which to obtain resolution.
-     * @param const TDesC8& Mime type of the file.
-     * @return TSize The resolution of the image. 
-     */  
-    TSize GetImageResolutionL( RFile& aFile, const TDesC8& aMimetype );
-
-// from base class MMdaAudioPlayerCallback
-
-    /**
-     * From MMdaAudioPlayerCallback.
-     * MapcPlayComplete 
-     *
-     * @since S60 v3.1
-     * @param aError error code
-     */
-    void MapcPlayComplete( TInt aError );
-
-    /**
-     * From MMdaAudioPlayerCallback.
-     * MapcInitComplete 
-     *
-     * @since S60 v3.1
-     * @param aError error code
-     * @param aDuration duration of the file
-     */
-    void MapcInitComplete( TInt aError, 
-                           const TTimeIntervalMicroSeconds& aDuration );
-           
-private: // data
-    // attributes related to CMdaAudioPlayerUtility usage
-    CActiveSchedulerWait*       iWait; // owned
-    CMdaAudioPlayerUtility*     iAudioplayer; // owned. 
-    
-    // duration of the media file (video or audio)
-    TTimeIntervalMicroSeconds   iDuration;
-    };
-
-
-#endif // C_UPNPRESRESOLVER_H
+/*
+* Copyright (c) 2006-2007 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:      Header file of CUpnpResResolver class. CUpnpResResolver is 
+*                a class used for resolving res field attributes for a given 
+*                file.
+*
+*/
+
+
+
+
+
+
+#ifndef C_UPNPRESRESOLVER_H
+#define C_UPNPRESRESOLVER_H
+
+// system includes
+#include <e32base.h>
+#include <mdaaudiosampleplayer.h> // CMdaAudioPlayerUtility
+
+// user includes
+// NONE
+
+// forward declarations
+class RFile;
+class CUpnpResParameters;
+
+// data types
+// NONE
+
+// constants
+// NONE
+
+/**
+ *  CUpnpResResolver is a class for resolving res field attributes for a 
+ *  given file.
+ *
+ *  CUpnpResResolver class can be used to resolve a res field attributes for 
+ *  a media file (image, AV, video). Attributes resolved for media files are:
+ *     - Protocolinfo for all files.
+ *     - Resolution and size for images.
+ *     - Duration and size for videos.
+ *     - Duration and size for music.
+ *
+ *  @lib dlnaprofiler.lib
+ *  @since S60 v3.1
+ */
+class CUpnpResResolver: public CBase, 
+                        public MMdaAudioPlayerCallback
+    {
+public:
+
+    IMPORT_C static CUpnpResResolver* NewL();
+
+    IMPORT_C static CUpnpResResolver* NewLC();
+
+    virtual ~CUpnpResResolver();
+
+    /**
+     * GetResParametersL resolves parameters that will be needed in 
+     * res-element attributes.
+     *
+     * @since S60 v3.1
+     * @param const TDesC& File for which to obtain res parameters.
+     * @return CUpnpResParameters* Parameters needed for res-element.
+     */  
+    IMPORT_C CUpnpResParameters* GetResParametersL( const TDesC& aFilename );
+    
+private:
+
+    CUpnpResResolver();
+
+    void ConstructL();
+
+    /**
+     * GetMimetypeL returns the mime type of the file.
+     *
+     * @since S60 v3.1
+     * @param RFile& File for which to obtain mime.
+     * @return HBufC8* Mime type of the file.
+     */  
+    HBufC8* GetMimetypeL( RFile& aFile );
+    
+    /**
+     * GetAudioDurationL obtains the duration of a audio file.
+     * After call the duration is in iDuration member variable.
+     *
+     * @since S60 v3.1
+     * @param const TDesC& The audio file for which to obtain duration.
+     */  
+    void GetAudioDurationL( const TDesC& aFilename );
+
+    /**
+     * GetVideoDurationL obtains the duration of a video file.
+     * After call the duration is in iDuration member variable.
+     *
+     * @since S60 v3.1
+     * @param RFile& The video file for which to obtain duration.
+     */  
+    void GetVideoDurationL( RFile& aFile );
+
+    /**
+     * GetFileSizeL returns the size of file in bytes.
+     *
+     * @since S60 v3.1
+     * @param RFile& The file for which to obtain size
+     * @return TInt File size.
+     */  
+    TInt GetFileSizeL( RFile& aFile );
+
+    /**
+     * GetImageResolutionL returns the resolution of the image.
+     *
+     * @since S60 v3.1
+     * @param RFile& File for which to obtain resolution.
+     * @param const TDesC8& Mime type of the file.
+     * @return TSize The resolution of the image. 
+     */  
+    TSize GetImageResolutionL( RFile& aFile, const TDesC8& aMimetype );
+
+// from base class MMdaAudioPlayerCallback (used from audio resolving thread)
+
+    /**
+     * From MMdaAudioPlayerCallback.
+     * MapcPlayComplete 
+     *
+     * @since S60 v3.1
+     * @param aError error code
+     */
+    void MapcPlayComplete( TInt aError );
+
+    /**
+     * From MMdaAudioPlayerCallback.
+     * MapcInitComplete 
+     *
+     * @since S60 v3.1
+     * @param aError error code
+     * @param aDuration duration of the file
+     */
+    void MapcInitComplete( TInt aError, 
+                           const TTimeIntervalMicroSeconds& aDuration );
+    
+// audio resolving thread    
+    
+    /**
+     * Thread function for audio resolving thread.
+     * 
+     * @param aSelf Pointer to CUpnpResResolver class instance.
+     * @return Possible return values:
+     *  KErrNone: Thread exited ok.
+     *  Otherwise system wide error code.
+     */
+    static TInt ThreadFunction( TAny* aSelf );
+
+    /**
+     * Resolves audio duration from iAVFile.
+     * 
+     * @param None.
+     * @return None.
+     */
+    void ResolveAudioDurationL();
+           
+private: // data    
+    // duration of the media file (video or audio)
+    TTimeIntervalMicroSeconds iDuration;
+    
+    // current audio/video file
+    HBufC* iAVFile;
+    
+    // semaphore for keeping sync between main thread and audio resolving thread
+    RSemaphore iSemaphore;
+    };
+
+
+#endif // C_UPNPRESRESOLVER_H
--- a/upnpsharing/upnpdlnaprofiler/src/upnpaudiosolverbase.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpdlnaprofiler/src/upnpaudiosolverbase.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,429 +1,430 @@
-/*
-* Copyright (c) 2006-2007 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:      Implementation of base DLNA profile resolver class for audio 
-*                files.
-*
-*/
-
-
-
-
-
-
-// system includes
-// NONE
-
-// includes
-#include <mdaaudiosampleeditor.h> // CMdaAudioConvertUtility
-#include <badesca.h> // CDesC16ArrayFlat
-#include "upnpaudiosolverbase.h"
-
-_LIT( KComponentLogfile, "dlnaprofiler.txt");
-#include "upnplog.h"
-
-// constants
-_LIT( KTargetAudioFile, "c:\\unnecessary.txt" );
-
-// audio mime types
-_LIT8( KAudioMpeg, "audio/mpeg" );
-_LIT8( KAudio3gpp, "audio/3gpp" );
-_LIT8( KAudioMp4, "audio/mp4" );
-_LIT8( KAudioL16, "audio/L16" );
-_LIT8( KAudioAdts, "audio/vnd.dlna.adts" );
-_LIT8( KAudioWma, "audio/x-ms-wma" );
-
-// audio profiles
-_LIT( KLpcm, "LPCM" );
-_LIT( KMp3, "MP3" );
-_LIT( KAac_iso, "AAC_ISO" );
-_LIT( KAac_iso_320, "AAC_ISO_320" );
-_LIT( KAac_mult5_iso, "AAC_MULT5_ISO" );
-_LIT( KWmabase, "WMABASE" );
-_LIT( KWmafull, "WMAFULL" );
-_LIT( KWmapro, "WMAPRO" );
-
-const TInt KAac_iso_320_max_bitrate = 320000;
-const TInt KAac_iso_max_samplerate = 48000;
-const TInt KAac_iso_max_bitrate = 576000;
-
-const TInt KWmabase_max_bitrate = 192999;
-const TInt KWmafull_max_bitrate = 385000;
-const TInt KWmapro_max_bitrate = 1500000;
-
-const TInt KWmabase_max_samplerate = 48000;
-const TInt KWmafull_max_samplerate = 48000;
-const TInt KWmapro_max_samplerate = 96000;
-
-const TInt KTwo_Channels = 2;
-const TInt KSix_Channels = 6;
-const TInt KEight_Channels = 8;
-
-// ======== LOCAL FUNCTIONS ========
-// NONE
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUpnpAudioSolverBase C++ constructor
-// --------------------------------------------------------------------------
-//
-CUpnpAudioSolverBase::CUpnpAudioSolverBase()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase Constructor" );
-    }
-
-// --------------------------------------------------------------------------
-// CUpnpAudioSolverBase::ConstructL
-// --------------------------------------------------------------------------
-//
-void CUpnpAudioSolverBase::ConstructL()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::ConstructL" );
-    iWait = new( ELeave ) CActiveSchedulerWait;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpAudioSolverBase::NewL
-// --------------------------------------------------------------------------
-//
-CUpnpAudioSolverBase* CUpnpAudioSolverBase::NewL()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::NewL" );
-    CUpnpAudioSolverBase* self = CUpnpAudioSolverBase::NewLC();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpAudioSolverBase::NewLC
-// --------------------------------------------------------------------------
-//
-CUpnpAudioSolverBase* CUpnpAudioSolverBase::NewLC()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::NewLC" );
-    CUpnpAudioSolverBase* self = new( ELeave ) CUpnpAudioSolverBase;
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpAudioSolverBase destructor
-// --------------------------------------------------------------------------
-//
-CUpnpAudioSolverBase::~CUpnpAudioSolverBase()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::Destructor" );
-    delete iAudioconverter;
-    delete iWait;
-    }
-
-// --------------------------------------------------------------------------
-// From class MUpnpProfiler.
-// SupportedProfilesL returns DLNA profiles that are currently supported.
-// --------------------------------------------------------------------------
-//
-TInt CUpnpAudioSolverBase::SupportedProfilesL( 
-                                          CDesC16ArrayFlat* aProfiles ) const
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
-SupportedProfilesL" );
-    TInt retval = KErrNone;
-    
-    if ( !aProfiles ) 
-        {
-        // Invalid parameter
-        retval = KErrArgument;
-        }
-    else 
-        {
-        // append all new profiles recognized by this solver
-        // do not allow duplicates
-        TInt tempPos = KErrNotFound;
-        
-        if ( aProfiles->Find( KLpcm(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KLpcm() );
-            }
-        if ( aProfiles->Find( KMp3(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KMp3() );
-            }
-        if ( aProfiles->Find( KAac_iso(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KAac_iso() );
-            }
-        if ( aProfiles->Find( KAac_iso_320(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KAac_iso_320() );
-            }
-        if ( aProfiles->Find( KAac_mult5_iso(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KAac_mult5_iso() );
-            }
-        if ( aProfiles->Find( KWmabase(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KWmabase() );
-            }
-        if ( aProfiles->Find( KWmafull(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KWmafull() );
-            }
-        if ( aProfiles->Find( KWmapro(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KWmapro() );
-            }
-        }
-        
-    return retval;
-    }
-    
-// --------------------------------------------------------------------------
-// From class MUpnpProfiler.
-// ProfileForFileL is for resolving a DLNA profile of a given file. Besides 
-// of file name, also mime type of the file is passed as a parameter in 
-// order to avoid re-opening the file.
-// --------------------------------------------------------------------------
-//
-HBufC* CUpnpAudioSolverBase::ProfileForFileL( const TDesC& aFilename,
-                                              const TDesC8& aMimetype, 
-                                              RFile& /*aFile*/ ) 
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::ProfileForFileL" );
-    HBufC* retval = NULL;
-    
-    if ( aMimetype.Compare( KAudioMpeg() ) == 0 ) 
-        {
-        // Note that MP3X profile is currently not supported.
-        retval = HBufC::NewL( KMp3().Length() );
-        retval->Des().Append( KMp3() );
-        }
-    else if ( aMimetype.Compare( KAudioMp4() ) == 0 ) 
-        {
-        // obtain bitrate and channel count information from the file
-        GetAudioFileInformationL( aFilename );
-
-        retval = DetermineMp4ProfileL();
-        }
-    else if ( aMimetype.Compare( KAudio3gpp() ) == 0 ) 
-        {
-        // obtain bitrate and channel count information from the file
-        GetAudioFileInformationL( aFilename );
-        
-        retval = Determine3GppProfileL();
-        }
-    else if ( aMimetype.Left( KAudioL16().Length() ).Compare( 
-                                                     KAudioL16() ) == 0 ) 
-        {
-        retval = HBufC::NewL( KLpcm().Length() );
-        retval->Des().Append( KLpcm() );
-        }
-    else if ( aMimetype.Compare( KAudioWma() ) == 0 ) 
-        {
-        // obtain bitrate and channel count information from the file
-        GetAudioFileInformationL( aFilename );
-
-        retval = DetermineWmaProfileL();
-        }
-    else if ( aMimetype.Compare( KAudioAdts() ) == 0 ) 
-        {
-        // no audio/vnd.dlna.adts profiles currently supported
-        // obtain bitrate and channel count information from the file
-        //GetAudioFileInformationL( aFilename );
-        //retval = DetermineAdtsProfileL();
-        }
-        
-    return retval;
-    }
-
-// --------------------------------------------------------------------------
-// From class MMdaObjectStateChangeObserver.
-// MoscoStateChangeEvent callback is called after a call to 
-// CMdaAudioConvertUtility::OpenL has completed.
-// --------------------------------------------------------------------------
-//
-void CUpnpAudioSolverBase::MoscoStateChangeEvent( CBase */*aObject*/, 
-                                                  TInt /*aPreviousState*/, 
-                                                  TInt /*aCurrentState*/, 
-                                                  TInt aErrorCode ) 
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
-MoscoStateChangeEvent" );
-    if( KErrNone == aErrorCode )
-        {
-            // get bit rate and channel count of the file. Trap because this 
-            // method may not leave. TRAP_IGNORE because there is nothing we
-            // can do in case of leave.
-            TRAP_IGNORE( iBitrate = iAudioconverter->SourceBitRateL() );
-            TRAP_IGNORE( iChannelCount = 
-                            iAudioconverter->SourceNumberOfChannelsL() );
-            TRAP_IGNORE( iSampleRate = 
-                            iAudioconverter->SourceSampleRateL() );
-        }
-        
-    // continue execution in ProfileForFileL-method by stopping 
-    // ActiveSchedulerWait
-    iWait->AsyncStop();
-    }
-
-// --------------------------------------------------------------------------
-// GetAudioFileInformationL is for resolving audio file attributes by using 
-// CMdaAudioConvertUtility. 
-// --------------------------------------------------------------------------
-//
-TInt CUpnpAudioSolverBase::GetAudioFileInformationL( const TDesC& aFilename )
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
-GetAudioFileInformationL" );
-    TInt retval = KErrNone;
-    
-    // create audioconverter if it does not exist
-    if ( !iAudioconverter ) 
-        {
-        iAudioconverter = CMdaAudioConvertUtility::NewL( *this );
-        }
-    
-    // Create iWait if it does not exist. Create it here rather than after 
-    // OpenL-call so that there will be no problems if somehow OpenL calls 
-    // MoscoStateChangeEvent-callback before iWait is created and started.
-    if ( !iWait ) 
-        {
-        iWait = new( ELeave ) CActiveSchedulerWait;
-        }
-
-    // Open file specified in aFilename. This is an asynchronic operation. 
-    // Calls MoscoStateChangeEvent callback after completed.
-    TMdaFileClipLocation sinkFile( KTargetAudioFile() );
-    TMdaRawAudioClipFormat  sinkformat;
-    iAudioconverter->OpenL( aFilename, &sinkFile, &sinkformat );
-
-    // start CActiveSchedulerWait which is completed in MoscoStateChangeEvent
-    iWait->Start();
-
-    // openL + MoscoStateChangeEvent callback executed now
-    delete iAudioconverter;
-    iAudioconverter = NULL;
-    delete iWait;
-    iWait = NULL;
-
-    // delete temporary file
-    RFs fs;
-    User::LeaveIfError( fs.Connect() );
-    User::LeaveIfError( fs.Delete( KTargetAudioFile() ) );
-    fs.Close();
-    
-    return retval;
-    }
-
-// --------------------------------------------------------------------------
-// Determine3GppProfileL is for determining profile for 3gpp audio files
-// --------------------------------------------------------------------------
-//
-HBufC* CUpnpAudioSolverBase::Determine3GppProfileL() const
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
-Determine3GppProfileL" );
-    HBufC* retval = NULL;
-    
-    if ( iBitrate <= KAac_iso_320_max_bitrate && 
-         iSampleRate <= KAac_iso_max_samplerate && 
-         iChannelCount <= KTwo_Channels ) 
-        {
-        retval = HBufC::NewL( KAac_iso_320().Length() );
-        retval->Des().Append( KAac_iso_320() );
-        }
-    else if ( iSampleRate <= KAac_iso_max_samplerate && 
-              iChannelCount <= KTwo_Channels )
-        {
-        retval = HBufC::NewL( KAac_iso().Length() );
-        retval->Des().Append( KAac_iso() ); 
-        }
-    else if ( iSampleRate <= KAac_iso_max_samplerate && 
-              iChannelCount <= KSix_Channels )
-        {
-        retval = HBufC::NewL( KAac_mult5_iso().Length() );
-        retval->Des().Append( KAac_mult5_iso() ); 
-        }    
-    
-    return retval;
-    }
-
-
-
-// --------------------------------------------------------------------------
-// DetermineWmaProfileL is for determining profile for wma files
-// --------------------------------------------------------------------------
-//
-HBufC* CUpnpAudioSolverBase::DetermineWmaProfileL() const
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
-DetermineWmaProfileL" );
-    HBufC* retval = NULL;
-
-    if ( iBitrate <= KWmabase_max_bitrate && 
-         iSampleRate <= KWmabase_max_samplerate && 
-         iChannelCount <= KTwo_Channels )
-        {
-        retval = HBufC::NewL( KWmabase().Length() );
-        retval->Des().Append( KWmabase() );   
-        }
-    else if ( iBitrate <= KWmafull_max_bitrate && 
-              iSampleRate <= KWmafull_max_samplerate && 
-              iChannelCount <= KTwo_Channels ) 
-        {
-        retval = HBufC::NewL( KWmafull().Length() );
-        retval->Des().Append( KWmafull() );
-        }
-    else if ( iBitrate <= KWmapro_max_bitrate && 
-              iSampleRate <= KWmapro_max_samplerate && 
-              iChannelCount <= KEight_Channels ) 
-        {
-        retval = HBufC::NewL( KWmapro().Length() );
-        retval->Des().Append( KWmapro() );
-        }
-        
-    return retval;
-}
-
-// --------------------------------------------------------------------------
-// DetermineMp4ProfileL is for determining profile for mp4 audio files
-// --------------------------------------------------------------------------
-//
-HBufC* CUpnpAudioSolverBase::DetermineMp4ProfileL() const
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
-DetermineMp4ProfileL" );
-    HBufC* retval = NULL;
-    
-    if ( iBitrate <= KAac_iso_320_max_bitrate && 
-         iChannelCount <= KTwo_Channels ) 
-        {
-        retval = HBufC::NewL( KAac_iso_320().Length() );
-        retval->Des().Append( KAac_iso_320() );            
-        }
-    else if ( iBitrate <= KAac_iso_max_bitrate && 
-              iChannelCount <= KTwo_Channels )
-        {
-        retval = HBufC::NewL( KAac_iso().Length() );
-        retval->Des().Append( KAac_iso() ); 
-        }
-        
-    return retval;
-}
-
-
-// end of file
+/*
+* Copyright (c) 2006-2007 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:      Implementation of base DLNA profile resolver class for audio 
+*                files.
+*
+*/
+
+
+
+
+
+
+// system includes
+// NONE
+
+// includes
+#include <mdaaudiosampleeditor.h> // CMdaAudioConvertUtility
+#include <badesca.h> // CDesC16ArrayFlat
+#include "upnpaudiosolverbase.h"
+
+_LIT( KComponentLogfile, "dlnaprofiler.txt");
+#include "upnplog.h"
+
+// constants
+_LIT( KTargetAudioFile, "c:\\unnecessary.txt" );
+
+// audio mime types
+_LIT8( KAudioMpeg, "audio/mpeg" );
+_LIT8( KAudio3gpp, "audio/3gpp" );
+_LIT8( KAudioMp4, "audio/mp4" );
+_LIT8( KAudioL16, "audio/L16" );
+_LIT8( KAudioAdts, "audio/vnd.dlna.adts" );
+_LIT8( KAudioWma, "audio/x-ms-wma" );
+
+// audio profiles
+_LIT( KLpcm, "LPCM" );
+_LIT( KMp3, "MP3" );
+_LIT( KAac_iso, "AAC_ISO" );
+_LIT( KAac_iso_320, "AAC_ISO_320" );
+_LIT( KAac_mult5_iso, "AAC_MULT5_ISO" );
+_LIT( KWmabase, "WMABASE" );
+_LIT( KWmafull, "WMAFULL" );
+_LIT( KWmapro, "WMAPRO" );
+
+const TInt KAac_iso_320_max_bitrate = 320000;
+const TInt KAac_iso_max_samplerate = 48000;
+const TInt KAac_iso_max_bitrate = 576000;
+
+const TInt KWmabase_max_bitrate = 192999;
+const TInt KWmafull_max_bitrate = 385000;
+const TInt KWmapro_max_bitrate = 1500000;
+
+const TInt KWmabase_max_samplerate = 48000;
+const TInt KWmafull_max_samplerate = 48000;
+const TInt KWmapro_max_samplerate = 96000;
+
+const TInt KTwo_Channels = 2;
+const TInt KSix_Channels = 6;
+const TInt KEight_Channels = 8;
+
+// ======== LOCAL FUNCTIONS ========
+// NONE
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUpnpAudioSolverBase C++ constructor
+// --------------------------------------------------------------------------
+//
+CUpnpAudioSolverBase::CUpnpAudioSolverBase()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase Constructor" );
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpAudioSolverBase::ConstructL
+// --------------------------------------------------------------------------
+//
+void CUpnpAudioSolverBase::ConstructL()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::ConstructL" );
+    iWait = new( ELeave ) CActiveSchedulerWait;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpAudioSolverBase::NewL
+// --------------------------------------------------------------------------
+//
+CUpnpAudioSolverBase* CUpnpAudioSolverBase::NewL()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::NewL" );
+    CUpnpAudioSolverBase* self = CUpnpAudioSolverBase::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpAudioSolverBase::NewLC
+// --------------------------------------------------------------------------
+//
+CUpnpAudioSolverBase* CUpnpAudioSolverBase::NewLC()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::NewLC" );
+    CUpnpAudioSolverBase* self = new( ELeave ) CUpnpAudioSolverBase;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpAudioSolverBase destructor
+// --------------------------------------------------------------------------
+//
+CUpnpAudioSolverBase::~CUpnpAudioSolverBase()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::Destructor" );
+    delete iAudioconverter;
+    delete iWait;
+    }
+
+// --------------------------------------------------------------------------
+// From class MUpnpProfiler.
+// SupportedProfilesL returns DLNA profiles that are currently supported.
+// --------------------------------------------------------------------------
+//
+TInt CUpnpAudioSolverBase::SupportedProfilesL( 
+                                          CDesC16ArrayFlat* aProfiles ) const
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
+SupportedProfilesL" );
+    TInt retval = KErrNone;
+    
+    if ( !aProfiles ) 
+        {
+        // Invalid parameter
+        retval = KErrArgument;
+        }
+    else 
+        {
+        // append all new profiles recognized by this solver
+        // do not allow duplicates
+        TInt tempPos = KErrNotFound;
+        
+        if ( aProfiles->Find( KLpcm(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KLpcm() );
+            }
+        if ( aProfiles->Find( KMp3(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KMp3() );
+            }
+        if ( aProfiles->Find( KAac_iso(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KAac_iso() );
+            }
+        if ( aProfiles->Find( KAac_iso_320(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KAac_iso_320() );
+            }
+        if ( aProfiles->Find( KAac_mult5_iso(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KAac_mult5_iso() );
+            }
+        if ( aProfiles->Find( KWmabase(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KWmabase() );
+            }
+        if ( aProfiles->Find( KWmafull(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KWmafull() );
+            }
+        if ( aProfiles->Find( KWmapro(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KWmapro() );
+            }
+        }
+        
+    return retval;
+    }
+    
+// --------------------------------------------------------------------------
+// From class MUpnpProfiler.
+// ProfileForFileL is for resolving a DLNA profile of a given file. Besides 
+// of file name, also mime type of the file is passed as a parameter in 
+// order to avoid re-opening the file.
+// --------------------------------------------------------------------------
+//
+HBufC* CUpnpAudioSolverBase::ProfileForFileL( const TDesC& aFilename,
+                                              const TDesC8& aMimetype, 
+                                              RFile& /*aFile*/ ) 
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::ProfileForFileL" );
+    HBufC* retval = NULL;
+    
+    if ( aMimetype.Compare( KAudioMpeg() ) == 0 ) 
+        {
+        // Note that MP3X profile is currently not supported.
+        retval = HBufC::NewL( KMp3().Length() );
+        retval->Des().Append( KMp3() );
+        }
+    else if ( aMimetype.Compare( KAudioMp4() ) == 0 ) 
+        {
+        // obtain bitrate and channel count information from the file
+        GetAudioFileInformationL( aFilename );
+
+        retval = DetermineMp4ProfileL();
+        }
+    else if ( aMimetype.Compare( KAudio3gpp() ) == 0 ) 
+        {
+        // obtain bitrate and channel count information from the file
+        GetAudioFileInformationL( aFilename );
+        
+        retval = Determine3GppProfileL();
+        }
+    else if ( aMimetype.Left( KAudioL16().Length() ).Compare( 
+                                                     KAudioL16() ) == 0 ) 
+        {
+        retval = HBufC::NewL( KLpcm().Length() );
+        retval->Des().Append( KLpcm() );
+        }
+    else if ( aMimetype.Compare( KAudioWma() ) == 0 ) 
+        {
+        // obtain bitrate and channel count information from the file
+        GetAudioFileInformationL( aFilename );
+
+        retval = DetermineWmaProfileL();
+        }
+    else if ( aMimetype.Compare( KAudioAdts() ) == 0 ) 
+        {
+        // no audio/vnd.dlna.adts profiles currently supported
+        // obtain bitrate and channel count information from the file
+        //GetAudioFileInformationL( aFilename );
+        //retval = DetermineAdtsProfileL();
+        }
+        
+    return retval;
+    }
+
+// --------------------------------------------------------------------------
+// From class MMdaObjectStateChangeObserver.
+// MoscoStateChangeEvent callback is called after a call to 
+// CMdaAudioConvertUtility::OpenL has completed.
+// --------------------------------------------------------------------------
+//
+void CUpnpAudioSolverBase::MoscoStateChangeEvent( CBase */*aObject*/, 
+                                                  TInt /*aPreviousState*/, 
+                                                  TInt /*aCurrentState*/, 
+                                                  TInt aErrorCode ) 
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
+MoscoStateChangeEvent" );
+    if( KErrNone == aErrorCode )
+        {
+            // get bit rate and channel count of the file. Trap because this 
+            // method may not leave. TRAP_IGNORE because there is nothing we
+            // can do in case of leave.
+            TRAP_IGNORE( iBitrate = iAudioconverter->SourceBitRateL() );
+            TRAP_IGNORE( iChannelCount = 
+                            iAudioconverter->SourceNumberOfChannelsL() );
+            TRAP_IGNORE( iSampleRate = 
+                            iAudioconverter->SourceSampleRateL() );
+        }
+        
+    // continue execution in ProfileForFileL-method by stopping 
+    // ActiveSchedulerWait
+    iWait->AsyncStop();
+    }
+
+// --------------------------------------------------------------------------
+// GetAudioFileInformationL is for resolving audio file attributes by using 
+// CMdaAudioConvertUtility. 
+// --------------------------------------------------------------------------
+//
+TInt CUpnpAudioSolverBase::GetAudioFileInformationL( const TDesC& aFilename )
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
+GetAudioFileInformationL" );
+    TInt retval = KErrNone;
+    
+    // create audioconverter if it does not exist
+    if ( !iAudioconverter ) 
+        {
+        iAudioconverter = CMdaAudioConvertUtility::NewL( *this );
+        }
+    
+    // Create iWait if it does not exist. Create it here rather than after 
+    // OpenL-call so that there will be no problems if somehow OpenL calls 
+    // MoscoStateChangeEvent-callback before iWait is created and started.
+    if ( !iWait ) 
+        {
+        iWait = new( ELeave ) CActiveSchedulerWait;
+        }
+
+    // Open file specified in aFilename. This is an asynchronic operation. 
+    // Calls MoscoStateChangeEvent callback after completed.
+    TMdaFileClipLocation sinkFile( KTargetAudioFile() );
+    TMdaRawAudioClipFormat  sinkformat;
+    iAudioconverter->OpenL( aFilename, &sinkFile, &sinkformat );
+
+    // start CActiveSchedulerWait which is completed in MoscoStateChangeEvent
+    iWait->Start();
+
+    // openL + MoscoStateChangeEvent callback executed now
+    delete iAudioconverter;
+    iAudioconverter = NULL;
+    delete iWait;
+    iWait = NULL;
+
+    // delete temporary file
+    RFs fs;
+    User::LeaveIfError( fs.Connect() );
+    CleanupClosePushL( fs );
+    User::LeaveIfError( fs.Delete( KTargetAudioFile() ) );
+    CleanupStack::PopAndDestroy( &fs );
+    
+    return retval;
+    }
+
+// --------------------------------------------------------------------------
+// Determine3GppProfileL is for determining profile for 3gpp audio files
+// --------------------------------------------------------------------------
+//
+HBufC* CUpnpAudioSolverBase::Determine3GppProfileL() const
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
+Determine3GppProfileL" );
+    HBufC* retval = NULL;
+    
+    if ( iBitrate <= KAac_iso_320_max_bitrate && 
+         iSampleRate <= KAac_iso_max_samplerate && 
+         iChannelCount <= KTwo_Channels ) 
+        {
+        retval = HBufC::NewL( KAac_iso_320().Length() );
+        retval->Des().Append( KAac_iso_320() );
+        }
+    else if ( iSampleRate <= KAac_iso_max_samplerate && 
+              iChannelCount <= KTwo_Channels )
+        {
+        retval = HBufC::NewL( KAac_iso().Length() );
+        retval->Des().Append( KAac_iso() ); 
+        }
+    else if ( iSampleRate <= KAac_iso_max_samplerate && 
+              iChannelCount <= KSix_Channels )
+        {
+        retval = HBufC::NewL( KAac_mult5_iso().Length() );
+        retval->Des().Append( KAac_mult5_iso() ); 
+        }    
+    
+    return retval;
+    }
+
+
+
+// --------------------------------------------------------------------------
+// DetermineWmaProfileL is for determining profile for wma files
+// --------------------------------------------------------------------------
+//
+HBufC* CUpnpAudioSolverBase::DetermineWmaProfileL() const
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
+DetermineWmaProfileL" );
+    HBufC* retval = NULL;
+
+    if ( iBitrate <= KWmabase_max_bitrate && 
+         iSampleRate <= KWmabase_max_samplerate && 
+         iChannelCount <= KTwo_Channels )
+        {
+        retval = HBufC::NewL( KWmabase().Length() );
+        retval->Des().Append( KWmabase() );   
+        }
+    else if ( iBitrate <= KWmafull_max_bitrate && 
+              iSampleRate <= KWmafull_max_samplerate && 
+              iChannelCount <= KTwo_Channels ) 
+        {
+        retval = HBufC::NewL( KWmafull().Length() );
+        retval->Des().Append( KWmafull() );
+        }
+    else if ( iBitrate <= KWmapro_max_bitrate && 
+              iSampleRate <= KWmapro_max_samplerate && 
+              iChannelCount <= KEight_Channels ) 
+        {
+        retval = HBufC::NewL( KWmapro().Length() );
+        retval->Des().Append( KWmapro() );
+        }
+        
+    return retval;
+}
+
+// --------------------------------------------------------------------------
+// DetermineMp4ProfileL is for determining profile for mp4 audio files
+// --------------------------------------------------------------------------
+//
+HBufC* CUpnpAudioSolverBase::DetermineMp4ProfileL() const
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAudioSolverBase::\
+DetermineMp4ProfileL" );
+    HBufC* retval = NULL;
+    
+    if ( iBitrate <= KAac_iso_320_max_bitrate && 
+         iChannelCount <= KTwo_Channels ) 
+        {
+        retval = HBufC::NewL( KAac_iso_320().Length() );
+        retval->Des().Append( KAac_iso_320() );            
+        }
+    else if ( iBitrate <= KAac_iso_max_bitrate && 
+              iChannelCount <= KTwo_Channels )
+        {
+        retval = HBufC::NewL( KAac_iso().Length() );
+        retval->Des().Append( KAac_iso() ); 
+        }
+        
+    return retval;
+}
+
+
+// end of file
--- a/upnpsharing/upnpdlnaprofiler/src/upnpavsolverbase.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpdlnaprofiler/src/upnpavsolverbase.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,448 +1,492 @@
-/*
-* Copyright (c) 2006-2007 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:      Implementation of base DLNA profile resolver class for av 
-*                files.
-*
-*/
-
-
-
-
-
-
-// includes
-#include <badesca.h> // CDesC16ArrayFlat
-#include <3gplibrary/mp4lib.h>
-#include "upnpavsolverbase.h"
-
-_LIT( KComponentLogfile, "dlnaprofiler.txt");
-#include "upnplog.h"
-
-// constants
-_LIT8( KVideoMp4, "video/mp4" );
-
-_LIT( KMpeg4_p2_mp4_sp_l2_aac,      "MPEG4_P2_MP4_SP_L2_AAC" );
-_LIT( KMpeg4_p2_mp4_sp_aac,         "MPEG4_P2_MP4_SP_AAC" );
-_LIT( KMpeg4_p2_mp4_sp_vga_aac,     "MPEG4_P2_MP4_SP_VGA_AAC" );
-_LIT( KMpeg4_p2_mp4_sp_l5_aac,      "MPEG4_P2_MP4_SP_L5_AAC" );
-
-_LIT( KAvc_mp4_bl_cif15_aac,        "AVC_MP4_BL_CIF15_AAC" );
-_LIT( KAvc_mp4_bl_cif15_aac_520,    "AVC_MP4_BL_CIF15_AAC_520" );
-
-const TUint32 KSimpleProfileLevel2 = 0x02;
-const TUint32 KSimpleProfileLevel3 = 0x03;
-const TUint32 KSimpleProfileLevel4 = 0x04;
-const TUint32 KSimpleProfileLevel5 = 0x05;
-
-
-const mp4_u32 KMaxXResolutionCif = 352;
-const mp4_u32 KMaxYResolutionCif = 288;
-const mp4_u32 KMaxXResolutionVga = 640;
-const mp4_u32 KMaxYResolutionVga = 480;
-
-//const TInt  KBitrateAverageToMaxFactor = 20;
-//const mp4_u32 KMaxBitrateCif520 = 520;
-//const mp4_u32 KMaxBitrateCif = 384;
-//const TUint32 KAdvancedSimpleProfileLevel1 = 0x91;
-//const TUint32 KAdvancedSimpleProfileLevel2 = 0x92;
-//const TUint32 KAdvancedSimpleProfileLevel3 = 0x93;
-//const TUint32 KAdvancedSimpleProfileLevel4 = 0x94;
-//const TUint32 KAvcBaseline1_2 = 12;
-
-/*
-===========================================================================
-Codec-specific details are explained here
-(for the part that is currently required by upnp framework)
-
-MPEG4 part2
-------------
-see ISO/IEC 14496-2, chapter 6.2.2 and annex G
-(http://akuvian.org/src/x264/ISO-IEC-14496-2_2001_MPEG4_Visual.pdf.gz)
-
-32 bit: visual_object_sequence_start_code (not interesting)
-8 bit: profile_and_level_indication, where:
-   0x02 = simple profile, level 2
-   0x03 = simple profile, level 3
-
-   0x04 = simple profile, level 4a
-   0x05 = simple profile, level 5
-   
-   0x91 = advanced simple profile, level 1
-   0x92 = advanced simple profile, level 2
-   0x93 = advanced simple profile, level 3
-   0x94 = advanced simple profile, level 4
-   
-...
-
-MPEG4 part 10 (AVC)
--------------------
-see ISO/IEC 14496-15, chapter 5.2.4.1.1
-(http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=43178)
-
-8 bit: version (not interesting)
-8 bit: AVC profile indication, where
-   0x42 = AVC baseline
-   0x4D = AVC main
-   0x58 = AVC extended
-8 bit: compatibility flags (not interesting)
-8 bit: AVC level indication, where
-   10 = baseline level 1.0
-   11 = baseline level 1.1
-   12 = baseline level 1.2
-   13 = baseline level 1.3
-   20 = baseline level 2.0
-   21 = baseline level 2.1
-   22 = baseline level 2.2
-   30 = baseline level 3.0
-...
-
-===========================================================================
-*/
-
-
-// --------------------------------------------------------------------------
-// CUpnpAvSolverBase C++ constructor
-// --------------------------------------------------------------------------
-//
-CUpnpAvSolverBase::CUpnpAvSolverBase()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase constructor" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpAvSolverBase::ConstructL
-// --------------------------------------------------------------------------
-//
-void CUpnpAvSolverBase::ConstructL()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::ConstructL" );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpAvSolverBase::NewL
-// --------------------------------------------------------------------------
-//
-CUpnpAvSolverBase* CUpnpAvSolverBase::NewL()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::NewL" );
-    CUpnpAvSolverBase* self = CUpnpAvSolverBase::NewLC();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpAvSolverBase::NewLC
-// --------------------------------------------------------------------------
-//
-CUpnpAvSolverBase* CUpnpAvSolverBase::NewLC()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::NewLC" );
-    CUpnpAvSolverBase* self = new( ELeave ) CUpnpAvSolverBase;
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpAvSolverBase destructor
-// --------------------------------------------------------------------------
-//
-CUpnpAvSolverBase::~CUpnpAvSolverBase()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase destructor" );
-    }
-
-// --------------------------------------------------------------------------
-// From class MUpnpProfiler.
-// SupportedProfilesL returns DLNA profiles that are currently supported.
-// --------------------------------------------------------------------------
-//
-TInt CUpnpAvSolverBase::SupportedProfilesL( 
-                                        CDesC16ArrayFlat* aProfiles ) const
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::SupportedProfilesL" );
-    TInt retval = KErrNone;
-    
-        if ( !aProfiles ) 
-        {
-        // Invalid parameter
-        retval = KErrArgument;
-        }
-    else 
-        {
-        // append all new profiles recognized by this solver
-        // do not allow duplicates
-        TInt tempPos = KErrNotFound;
-
-        if ( aProfiles->Find( KMpeg4_p2_mp4_sp_l2_aac(), 
-                              tempPos, 
-                              ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KMpeg4_p2_mp4_sp_l2_aac() );
-            }
-        if ( aProfiles->Find( KMpeg4_p2_mp4_sp_aac(), 
-                              tempPos, 
-                              ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KMpeg4_p2_mp4_sp_aac() );
-            }
-        if ( aProfiles->Find( KMpeg4_p2_mp4_sp_vga_aac(), 
-                              tempPos, 
-                              ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KMpeg4_p2_mp4_sp_vga_aac() );
-            }
-        if ( aProfiles->Find( KMpeg4_p2_mp4_sp_l5_aac(), 
-                              tempPos, 
-                              ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KMpeg4_p2_mp4_sp_l5_aac() );
-            }
-        if ( aProfiles->Find( KAvc_mp4_bl_cif15_aac(), 
-                              tempPos, 
-                              ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KAvc_mp4_bl_cif15_aac() );
-            }
-        if ( aProfiles->Find( KAvc_mp4_bl_cif15_aac_520(), 
-                              tempPos, 
-                              ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KAvc_mp4_bl_cif15_aac_520() );
-            }
-        }
-
-    return retval;
-    }
-    
-// --------------------------------------------------------------------------
-// From class MUpnpProfiler.
-// ProfileForFileL is for resolving a DLNA profile of a given file. Besides 
-// of file name, also mime type of the file is passed as a parameter in order
-// to avoid re-opening the file.
-// --------------------------------------------------------------------------
-//
-HBufC* CUpnpAvSolverBase::ProfileForFileL( const TDesC& /*aFilename*/,
-                                           const TDesC8& aMimetype, 
-                                           RFile& aFile )
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::\
-ProfileForFileL" );
-    HBufC* retval = NULL;
-
-
-    
-    if ( aMimetype.Compare( KVideoMp4() ) == 0 ) 
-        {
-        GetVideoFileInformationL( aFile );
-
-
-
-        if ( iVideoType == MP4_TYPE_MPEG4_VIDEO &&
-             iAudioType == MP4_TYPE_MPEG4_AUDIO )
-            {
-            // MPEG4 level 2
-
-            TUint32 level = iCodecInfo.iData[1] & 0x000000FF;
-            
-            __LOG1( "[CUpnpAvSolverBase] CUpnpAvSolverBase::\
-            GetVideoFileInformationL level %d", level );
-
-            if ( level == KSimpleProfileLevel2 )
-                {
-                // Simple profile level 2
-                retval = HBufC::NewL( KMpeg4_p2_mp4_sp_l2_aac().Length() );
-                retval->Des().Append( KMpeg4_p2_mp4_sp_l2_aac() ); 
-                }
-            else if ( level == KSimpleProfileLevel3 )
-                {
-                // Simple profile level 3
-                if ( iVideoResolutionX <= KMaxXResolutionCif &&
-                    iVideoResolutionY <= KMaxYResolutionCif )
-                    {
-                    // resolution below CIF standard
-                    retval = HBufC::NewL( KMpeg4_p2_mp4_sp_aac().Length() );
-                    retval->Des().Append( KMpeg4_p2_mp4_sp_aac() ); 
-                    }
-                else if ( iVideoResolutionX <= KMaxXResolutionVga &&
-                    iVideoResolutionY <= KMaxYResolutionVga )
-                    {
-                    // resolution below VGA standard
-                    retval = HBufC::NewL(
-                        KMpeg4_p2_mp4_sp_vga_aac().Length() );
-                    retval->Des().Append( KMpeg4_p2_mp4_sp_vga_aac() ); 
-                    }
-                }
-
-            else if ( level == KSimpleProfileLevel4 )
-                {
-                // Simple profile level 4a
-                retval = HBufC::NewL( KMpeg4_p2_mp4_sp_vga_aac().Length() );
-                retval->Des().Append( KMpeg4_p2_mp4_sp_vga_aac() ); 
-                }
-            
-            else if ( level == KSimpleProfileLevel5 )
-                {
-                // Simple profile level 5
-                retval = HBufC::NewL( KMpeg4_p2_mp4_sp_l5_aac().Length() );
-                retval->Des().Append( KMpeg4_p2_mp4_sp_l5_aac() ); 
-                }                
-                
-/*
-
-Not needed yet:
-
-            else if ( level == KAdvancedSimpleProfileLevel1 ||
-                level == KAdvancedSimpleProfileLevel2 ||
-                level == KAdvancedSimpleProfileLevel3 ||
-                level == KAdvancedSimpleProfileLevel4 )
-                {
-                // Advanced simple profile (levels 1-4)
-                retval = HBufC::NewL( KMpeg4_p2_mp4_sp_l5_aac().Length() );
-                retval->Des().Append( KMpeg4_p2_mp4_sp_l5_aac() ); 
-                }
-*/
-                
-            }
-            
-
-/*
-  Temporary solution, based on AVC video resolution. 
-  iLevel should be used instead, see above Mp4 P2.
-*/
-        else if ( iVideoType == MP4_TYPE_AVC_PROFILE_BASELINE &&
-            iAudioType == MP4_TYPE_MPEG4_AUDIO )
-            {
-            // MPEG4 part 10 (AVC)
-            
-            	if (iVideoResolutionX <= KMaxXResolutionCif && 
-            		iVideoResolutionY <= KMaxYResolutionCif )
-            	{
-                    retval = HBufC::NewL( KAvc_mp4_bl_cif15_aac_520().Length() );
-                    retval->Des().Append( KAvc_mp4_bl_cif15_aac_520() );            		
-            	}
-        	
-            }
-            
-            
-
-        }
-           
-    return retval;
-    }
-
-
-// --------------------------------------------------------------------------
-// GetVideoFileInformationL is for resolving audio file attributes by using 
-// CMdaAudioConvertUtility. 
-// --------------------------------------------------------------------------
-//
-TInt CUpnpAvSolverBase::GetVideoFileInformationL( RFile& aFile )
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::\
-GetVideoFileInformationL" );
-    TInt retval = KErrNone;
-
-    // video description
-    mp4_u32 videolength;
-    mp4_u32 videotimescale;
-    // audio params
-    mp4_u32 audiolength = 0;
-    mp4_u8 audioframes = 0;
-    mp4_u32 audiotimescale = 0;
-    mp4_u32 audiobitrate = 0;
-    // stream params
-    mp4_u32 streamsize = 0;
-
-    // reset old values 
-    iStreamAverageBitrate = 0;
-
-    MP4Handle myMp4Handle;
-    
-    // try open mp4 file handle
-    MP4Err openerr = MP4ParseOpenFileHandle( &myMp4Handle, &aFile );
-    if ( openerr == MP4_OK )
-        {
-        MP4Err requesterr = MP4ParseRequestVideoDescription(
-                                            myMp4Handle,
-                                            &videolength,
-                                            &iVideoFramerate,
-                                            &iVideoType,
-                                            &iVideoResolutionX,
-                                            &iVideoResolutionY,
-                                            &videotimescale );
-        if ( requesterr != MP4_OK )
-            {
-            MP4ParseClose( myMp4Handle );
-            User::Leave( KErrGeneral );
-            }
-
-
-        requesterr = MP4ParseRequestAudioDescription( 
-                                            myMp4Handle, 
-                                            &audiolength, 
-                                            &iAudioType,
-                                            &audioframes, 
-                                            &audiotimescale, 
-                                            &audiobitrate );
-        if ( requesterr != MP4_OK )
-            {
-            MP4ParseClose( myMp4Handle );
-            User::Leave( KErrGeneral );
-            }
-
-        requesterr = MP4ParseRequestStreamDescription(
-                                            myMp4Handle, 
-                                            &streamsize, 
-                                            &iStreamAverageBitrate );
-
-
-        if ( requesterr != MP4_OK )
-            {
-            MP4ParseClose( myMp4Handle );
-            User::Leave( KErrGeneral );
-            }
-
-        TMP4DecoderSpecificInfo iDecoderInfo;
-        mp4_u32 decoderInfoSize;
-
-        requesterr = MP4ParseReadVideoDecoderSpecificInfo(
-                                            myMp4Handle,
-                                            (mp4_u8*)&iDecoderInfo,
-                                            sizeof( iDecoderInfo ),
-                                            &decoderInfoSize );
-       
-
-		iCodecInfo = iDecoderInfo;
-        // close mp4 file handle
-        MP4Err closeerr = MP4ParseClose( myMp4Handle );
-        if ( closeerr ) 
-            {
-            User::Leave( KErrGeneral );
-            }
-        }
-    else 
-        {
-        // can not open file
-        User::Leave( KErrBadHandle );
-        }
-    
-    return retval;
-    }
-
-    
-// end of file
+/*
+* Copyright (c) 2006-2007 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:      Implementation of base DLNA profile resolver class for av 
+*                files.
+*
+*/
+
+
+
+
+
+
+// includes
+#include <badesca.h> // CDesC16ArrayFlat
+#include <3gplibrary/mp4lib.h> 
+#include "upnpavsolverbase.h"
+
+_LIT( KComponentLogfile, "dlnaprofiler.txt");
+#include "upnplog.h"
+
+// constants
+_LIT8( KVideoMp4, "video/mp4" );
+
+_LIT( KMpeg4_p2_mp4_sp_l2_aac,      "MPEG4_P2_MP4_SP_L2_AAC" );
+_LIT( KMpeg4_p2_mp4_sp_aac,         "MPEG4_P2_MP4_SP_AAC" );
+_LIT( KMpeg4_p2_mp4_sp_vga_aac,     "MPEG4_P2_MP4_SP_VGA_AAC" );
+_LIT( KMpeg4_p2_mp4_asp_l4_so_aac,  "MPEG4_P2_MP4_ASP_L4_SO_AAC" );
+_LIT( KMpeg4_p2_mp4_sp_l5_aac,      "MPEG4_P2_MP4_SP_L5_AAC" );
+
+_LIT( KAvc_mp4_bl_cif15_aac,        "AVC_MP4_BL_CIF15_AAC" );
+_LIT( KAvc_mp4_bl_cif15_aac_520,    "AVC_MP4_BL_CIF15_AAC_520" );
+
+_LIT( KAvc_mp4_mp_hd_720p_aac,      "AVC_MP4_MP_HD_720p_AAC" );
+_LIT( KAvc_mp4_hp_hd_aac,           "AVC_MP4_HP_HD_AAC" );
+
+_LIT( KAvc_mp4_bl_l31_hd_aac,       "AVC_MP4_BL_L31_HD_AAC" );
+
+const TUint32 KSimpleProfileLevel2 = 0x02;
+const TUint32 KSimpleProfileLevel3 = 0x03;
+const TUint32 KSimpleProfileLevel4 = 0x04;
+const TUint32 KSimpleProfileLevel5 = 0x05;
+
+
+const mp4_u32 KMaxXResolutionCif = 352;
+const mp4_u32 KMaxYResolutionCif = 288;
+const mp4_u32 KMaxXResolutionVga = 640;
+const mp4_u32 KMaxYResolutionVga = 480;
+
+const TUint32 KAvcLevel31 = 31;
+const TUint32 KAvcLevel40 = 40;
+
+//const TInt  KBitrateAverageToMaxFactor = 20;
+//const mp4_u32 KMaxBitrateCif520 = 520;
+//const mp4_u32 KMaxBitrateCif = 384;
+//const TUint32 KAdvancedSimpleProfileLevel1 = 0x91;
+//const TUint32 KAdvancedSimpleProfileLevel2 = 0x92;
+//const TUint32 KAdvancedSimpleProfileLevel3 = 0x93;
+//const TUint32 KAdvancedSimpleProfileLevel4 = 0x94;
+//const TUint32 KAvcBaseline1_2 = 12;
+
+/*
+===========================================================================
+Codec-specific details are explained here
+(for the part that is currently required by upnp framework)
+
+MPEG4 part2
+------------
+see ISO/IEC 14496-2, chapter 6.2.2 and annex G
+(http://akuvian.org/src/x264/ISO-IEC-14496-2_2001_MPEG4_Visual.pdf.gz)
+
+32 bit: visual_object_sequence_start_code (not interesting)
+8 bit: profile_and_level_indication, where:
+   0x02 = simple profile, level 2
+   0x03 = simple profile, level 3
+
+   0x04 = simple profile, level 4a
+   0x05 = simple profile, level 5
+   
+   0x91 = advanced simple profile, level 1
+   0x92 = advanced simple profile, level 2
+   0x93 = advanced simple profile, level 3
+   0x94 = advanced simple profile, level 4
+   
+...
+
+MPEG4 part 10 (AVC)
+-------------------
+see ISO/IEC 14496-15, chapter 5.2.4.1.1
+(http://www.iso.org/iso/iso_catalogue/catalogue_tc/catalogue_detail.htm?csnumber=43178)
+
+8 bit: version (not interesting)
+8 bit: AVC profile indication, where
+   0x42 = AVC baseline
+   0x4D = AVC main
+   0x58 = AVC extended
+8 bit: compatibility flags (not interesting)
+8 bit: AVC level indication, where
+   10 = baseline level 1.0
+   11 = baseline level 1.1
+   12 = baseline level 1.2
+   13 = baseline level 1.3
+   20 = baseline level 2.0
+   21 = baseline level 2.1
+   22 = baseline level 2.2
+   30 = baseline level 3.0
+...
+
+===========================================================================
+*/
+
+
+// --------------------------------------------------------------------------
+// CUpnpAvSolverBase C++ constructor
+// --------------------------------------------------------------------------
+//
+CUpnpAvSolverBase::CUpnpAvSolverBase()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase constructor" );
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpAvSolverBase::ConstructL
+// --------------------------------------------------------------------------
+//
+void CUpnpAvSolverBase::ConstructL()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::ConstructL" );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpAvSolverBase::NewL
+// --------------------------------------------------------------------------
+//
+CUpnpAvSolverBase* CUpnpAvSolverBase::NewL()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::NewL" );
+    CUpnpAvSolverBase* self = CUpnpAvSolverBase::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpAvSolverBase::NewLC
+// --------------------------------------------------------------------------
+//
+CUpnpAvSolverBase* CUpnpAvSolverBase::NewLC()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::NewLC" );
+    CUpnpAvSolverBase* self = new( ELeave ) CUpnpAvSolverBase;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpAvSolverBase destructor
+// --------------------------------------------------------------------------
+//
+CUpnpAvSolverBase::~CUpnpAvSolverBase()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase destructor" );
+    }
+
+// --------------------------------------------------------------------------
+// From class MUpnpProfiler.
+// SupportedProfilesL returns DLNA profiles that are currently supported.
+// --------------------------------------------------------------------------
+//
+TInt CUpnpAvSolverBase::SupportedProfilesL( 
+                                        CDesC16ArrayFlat* aProfiles ) const
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::SupportedProfilesL" );
+    TInt retval = KErrNone;
+    
+        if ( !aProfiles ) 
+        {
+        // Invalid parameter
+        retval = KErrArgument;
+        }
+    else 
+        {
+        // append all new profiles recognized by this solver
+        // do not allow duplicates
+        TInt tempPos = KErrNotFound;
+
+        if ( aProfiles->Find( KMpeg4_p2_mp4_sp_l2_aac(), 
+                              tempPos, 
+                              ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KMpeg4_p2_mp4_sp_l2_aac() );
+            }
+        if ( aProfiles->Find( KMpeg4_p2_mp4_sp_aac(), 
+                              tempPos, 
+                              ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KMpeg4_p2_mp4_sp_aac() );
+            }
+        if ( aProfiles->Find( KMpeg4_p2_mp4_sp_vga_aac(), 
+                              tempPos, 
+                              ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KMpeg4_p2_mp4_sp_vga_aac() );
+            }
+        if ( aProfiles->Find( KMpeg4_p2_mp4_asp_l4_so_aac(), 
+                              tempPos, 
+                              ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KMpeg4_p2_mp4_asp_l4_so_aac() );
+            }
+        if ( aProfiles->Find( KMpeg4_p2_mp4_sp_l5_aac(), 
+                              tempPos, 
+                              ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KMpeg4_p2_mp4_sp_l5_aac() );
+            }
+        if ( aProfiles->Find( KAvc_mp4_bl_cif15_aac(), 
+                              tempPos, 
+                              ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KAvc_mp4_bl_cif15_aac() );
+            }
+        if ( aProfiles->Find( KAvc_mp4_bl_cif15_aac_520(), 
+                              tempPos, 
+                              ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KAvc_mp4_bl_cif15_aac_520() );
+            }
+        if ( aProfiles->Find( KAvc_mp4_mp_hd_720p_aac(), 
+                              tempPos, 
+                              ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KAvc_mp4_mp_hd_720p_aac() );
+            }
+        if ( aProfiles->Find( KAvc_mp4_hp_hd_aac(), 
+                              tempPos, 
+                              ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KAvc_mp4_hp_hd_aac() );
+            }
+        if ( aProfiles->Find( KAvc_mp4_bl_l31_hd_aac(), 
+                              tempPos, 
+                              ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KAvc_mp4_bl_l31_hd_aac() );
+            }
+        }
+
+    return retval;
+    }
+    
+// --------------------------------------------------------------------------
+// From class MUpnpProfiler.
+// ProfileForFileL is for resolving a DLNA profile of a given file. Besides 
+// of file name, also mime type of the file is passed as a parameter in order
+// to avoid re-opening the file.
+// --------------------------------------------------------------------------
+//
+HBufC* CUpnpAvSolverBase::ProfileForFileL( const TDesC& /*aFilename*/,
+                                           const TDesC8& aMimetype, 
+                                           RFile& aFile )
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::ProfileForFileL" );
+    HBufC* retval = NULL;
+
+    if ( aMimetype.Compare( KVideoMp4() ) == 0 ) 
+        {
+        GetVideoFileInformationL( aFile );
+
+        __LOG2( "[UPnPDlnaProfiler] CUpnpAvSolverBase::ProfileForFileL: Video type = 0x%x, Audio type = 0x%x",
+            iVideoType, iAudioType );
+
+        if ( iVideoType == MP4_TYPE_MPEG4_VIDEO &&
+             iAudioType == MP4_TYPE_MPEG4_AUDIO )
+            {
+            // MPEG4 level 2
+
+            TUint32 level = iCodecInfo.iData[1] & 0x000000FF;
+            
+            __LOG1( "[CUpnpAvSolverBase] CUpnpAvSolverBase::\
+            GetVideoFileInformationL level %d", level );
+
+            if ( level == KSimpleProfileLevel2 )
+                {
+                // Simple profile level 2
+                retval = KMpeg4_p2_mp4_sp_l2_aac().AllocL(); 
+                }
+            else if ( level == KSimpleProfileLevel3 )
+                {
+                // Simple profile level 3
+                if ( iVideoResolutionX <= KMaxXResolutionCif &&
+                    iVideoResolutionY <= KMaxYResolutionCif )
+                    {
+                    // resolution below CIF standard
+                    retval = KMpeg4_p2_mp4_sp_aac().AllocL(); 
+                    }
+                else if ( iVideoResolutionX <= KMaxXResolutionVga &&
+                    iVideoResolutionY <= KMaxYResolutionVga )
+                    {
+                    // resolution below VGA standard
+                    retval = KMpeg4_p2_mp4_sp_vga_aac().AllocL(); 
+                    }
+                }
+
+            else if ( level == KSimpleProfileLevel4 )
+                {
+                // Simple profile level 4a
+                retval = KMpeg4_p2_mp4_asp_l4_so_aac().AllocL();
+                }
+            
+            else if ( level == KSimpleProfileLevel5 )
+                {
+                // Simple profile level 5
+                retval = KMpeg4_p2_mp4_sp_l5_aac().AllocL();
+                }                
+                
+/*
+
+Not needed yet:
+
+            else if ( level == KAdvancedSimpleProfileLevel1 ||
+                level == KAdvancedSimpleProfileLevel2 ||
+                level == KAdvancedSimpleProfileLevel3 ||
+                level == KAdvancedSimpleProfileLevel4 )
+                {
+                // Advanced simple profile (levels 1-4)
+                retval = HBufC::NewL( KMpeg4_p2_mp4_sp_l5_aac().Length() );
+                retval->Des().Append( KMpeg4_p2_mp4_sp_l5_aac() ); 
+                }
+*/
+                
+            }
+            
+
+/*
+  Temporary solution, based on AVC video resolution. 
+  iLevel should be used instead, see above Mp4 P2.
+*/
+        else if ( iVideoType == MP4_TYPE_AVC_PROFILE_BASELINE &&
+            iAudioType == MP4_TYPE_MPEG4_AUDIO )
+            {
+            // MPEG4 part 10 (AVC)
+            
+            	if (iVideoResolutionX <= KMaxXResolutionCif && 
+            		iVideoResolutionY <= KMaxYResolutionCif )
+            	{
+            	    retval = KAvc_mp4_bl_cif15_aac_520().AllocL();            		
+            	}
+            	else
+            	{
+                    TUint32 level = (iCodecInfo.iData[0] & 0xFF000000) >> 24;
+                    
+                    __LOG1( "[UPnPDlnaProfiler] CUpnpAvSolverBase::ProfileForFileL: Level = %d", level );
+                    
+                    if ( level == KAvcLevel31 )
+                    {
+                        retval = KAvc_mp4_bl_l31_hd_aac().AllocL();
+                    }
+            	}
+            }
+            
+        else if ( iVideoType == MP4_TYPE_AVC_PROFILE_MAIN && 
+                iAudioType == MP4_TYPE_MPEG4_AUDIO )
+            {
+            TUint32 level = (iCodecInfo.iData[0] & 0xFF000000) >> 24;
+            
+            if ( level == KAvcLevel31 )
+                {
+                retval = KAvc_mp4_mp_hd_720p_aac().AllocL();
+                }
+            }
+        }           
+    return retval;
+    }
+
+
+// --------------------------------------------------------------------------
+// GetVideoFileInformationL is for resolving audio file attributes by using 
+// CMdaAudioConvertUtility. 
+// --------------------------------------------------------------------------
+//
+TInt CUpnpAvSolverBase::GetVideoFileInformationL( RFile& aFile )
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpAvSolverBase::GetVideoFileInformationL" );
+	
+    TInt retval = KErrNone;
+
+    // video description
+    mp4_u32 videolength;
+    mp4_u32 videotimescale;
+    // audio params
+    mp4_u32 audiolength = 0;
+    mp4_u8 audioframes = 0;
+    mp4_u32 audiotimescale = 0;
+    mp4_u32 audiobitrate = 0;
+    // stream params
+    mp4_u32 streamsize = 0;
+
+    // reset old values 
+    iStreamAverageBitrate = 0;
+
+    MP4Handle myMp4Handle;
+    
+    // try open mp4 file handle
+    MP4Err openerr = MP4ParseOpenFileHandle( &myMp4Handle, &aFile );
+    if ( openerr == MP4_OK )
+        {
+        MP4Err requesterr = MP4ParseRequestVideoDescription(
+                                            myMp4Handle,
+                                            &videolength,
+                                            &iVideoFramerate,
+                                            &iVideoType,
+                                            &iVideoResolutionX,
+                                            &iVideoResolutionY,
+                                            &videotimescale );
+        if ( requesterr != MP4_OK )
+            {
+            MP4ParseClose( myMp4Handle );
+            User::Leave( KErrGeneral );
+            }
+
+        requesterr = MP4ParseRequestAudioDescription( 
+                                            myMp4Handle, 
+                                            &audiolength, 
+                                            &iAudioType,
+                                            &audioframes, 
+                                            &audiotimescale, 
+                                            &audiobitrate );
+        if ( requesterr != MP4_OK )
+            {
+            MP4ParseClose( myMp4Handle );
+            User::Leave( KErrGeneral );
+            }
+
+        requesterr = MP4ParseRequestStreamDescription(
+                                            myMp4Handle, 
+                                            &streamsize, 
+                                            &iStreamAverageBitrate );
+
+
+        if ( requesterr != MP4_OK )
+            {
+            MP4ParseClose( myMp4Handle );
+            User::Leave( KErrGeneral );
+            }
+
+        TMP4DecoderSpecificInfo iDecoderInfo;
+        mp4_u32 decoderInfoSize;
+
+        requesterr = MP4ParseReadVideoDecoderSpecificInfo(
+                                            myMp4Handle,
+                                            (mp4_u8*)&iDecoderInfo,
+                                            sizeof( iDecoderInfo ),
+                                            &decoderInfoSize );
+        if ( requesterr != MP4_OK )
+            {
+            MP4ParseClose( myMp4Handle );
+            User::Leave( KErrGeneral );
+            }
+
+		iCodecInfo = iDecoderInfo;
+        // close mp4 file handle
+        MP4Err closeerr = MP4ParseClose( myMp4Handle );
+        if ( closeerr ) 
+            {
+            User::Leave( KErrGeneral );
+            }
+        }
+    else 
+        {
+        // can not open file
+        User::Leave( KErrBadHandle );
+        }
+    
+    return retval;
+    }
+
+    
+// end of file
--- a/upnpsharing/upnpdlnaprofiler/src/upnpimagesolverbase.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpdlnaprofiler/src/upnpimagesolverbase.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,262 +1,270 @@
-/*
-* Copyright (c) 2006-2007 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:      Implementation of base DLNA profile resolver class for image 
-*                files.
-*
-*/
-
-
-
-
-
-
-// system includes
-#include <imageconversion.h>
-#include <caf/caftypes.h> // ContentAccess
-#include <badesca.h> // CDesC16ArrayFlat
-
-// user includes
-#include "upnpimagesolverbase.h"
-
-_LIT( KComponentLogfile, "dlnaprofiler.txt");
-#include "upnplog.h"
-
-// constants
-_LIT8( KImageJpeg, "image/jpeg" );
-_LIT( KJpeg_sm, "JPEG_SM" );
-_LIT( KJpeg_med, "JPEG_MED" );
-_LIT( KJpeg_lrg, "JPEG_LRG" );
-
-_LIT( KJpeg_tn, "JPEG_TN" );
-_LIT( KJpeg_lrg_ico, "JPEG_LRG_ICO" );
-_LIT( KJpeg_sm_ico, "JPEG_SM_ICO" );
-
-_LIT8( KImagePng, "image/png" );
-_LIT( KPngLrg, "PNG_LRG" );
-
-
-const TInt KJpeg_smico_max_width = 48;
-const TInt KJpeg_smico_max_height = 48;
-const TInt KJpeg_lrgico_max_width = 120;
-const TInt KJpeg_lrgico_max_height = 120;
-const TInt KJpeg_sm_max_width = 640;
-const TInt KJpeg_sm_max_height = 480;
-const TInt KJpeg_med_max_width = 1024;
-const TInt KJpeg_med_max_height = 768;
-const TInt KJpeg_lrg_max_width = 4096;
-const TInt KJpeg_lrg_max_height = 4096;
-const TInt KPng_lrg_max_width = 4096;
-const TInt KPng_lrg_max_height = 4096;
-
-// ======== LOCAL FUNCTIONS ========
-// NONE
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUpnpImageSolverBase C++ constructor
-// --------------------------------------------------------------------------
-//
-CUpnpImageSolverBase::CUpnpImageSolverBase()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase constructor" );
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpImageSolverBase::ConstructL
-// --------------------------------------------------------------------------
-//
-void CUpnpImageSolverBase::ConstructL()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase::ConstructL" );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpImageSolverBase::NewL
-// --------------------------------------------------------------------------
-//
-CUpnpImageSolverBase* CUpnpImageSolverBase::NewL()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase::NewL" );
-    CUpnpImageSolverBase* self = CUpnpImageSolverBase::NewLC();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpImageSolverBase::NewLC
-// --------------------------------------------------------------------------
-//
-CUpnpImageSolverBase* CUpnpImageSolverBase::NewLC()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase::NewLC" );
-    CUpnpImageSolverBase* self = new( ELeave ) CUpnpImageSolverBase;
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpImageSolverBase destructor
-// --------------------------------------------------------------------------
-//
-CUpnpImageSolverBase::~CUpnpImageSolverBase()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase destructor" );
-    }
-
-// --------------------------------------------------------------------------
-// From class MUpnpProfiler.
-// SupportedProfilesL returns DLNA profiles that are currently supported.
-// --------------------------------------------------------------------------
-//
-TInt CUpnpImageSolverBase::SupportedProfilesL( 
-                                        CDesC16ArrayFlat* aProfiles ) const
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase::\
-SupportedProfilesL" );
-    TInt retval = KErrNone;
-    
-    if ( !aProfiles ) 
-        {
-        // Invalid parameter
-        retval = KErrArgument;
-        }
-    else 
-        {
-        // append all new profiles recognized by this solver
-        // do not allow duplicates
-        TInt tempPos = KErrNotFound;
-        
-        if ( aProfiles->Find( KJpeg_sm(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KJpeg_sm() );
-            }
-        if ( aProfiles->Find( KJpeg_med(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KJpeg_med() );
-            }
-        if ( aProfiles->Find( KJpeg_lrg(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KJpeg_lrg() );
-            }
-        if ( aProfiles->Find( KPngLrg(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KPngLrg() );
-            }
-        if ( aProfiles->Find( KJpeg_tn(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KJpeg_tn() );
-            }            
-        if ( aProfiles->Find( KJpeg_lrg_ico(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KJpeg_lrg_ico() );
-            }            
-        if ( aProfiles->Find( KJpeg_sm_ico(), tempPos, ECmpFolded ) ) 
-            {
-            aProfiles->AppendL( KJpeg_sm_ico() );
-            }            
-
-
-        }    
-
-    return retval;
-    }
-    
-// --------------------------------------------------------------------------
-// From class MUpnpProfiler.
-// ProfileForFileL is for resolving a DLNA profile of a given file. Besides 
-// of file name, also mime type of the file is passed as a parameter in order 
-// to avoid re-opening the file.
-// --------------------------------------------------------------------------
-//
-HBufC* CUpnpImageSolverBase::ProfileForFileL( const TDesC& /*aFilename*/, 
-                                              const TDesC8& aMimetype, 
-                                              RFile& aFile )
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase::ProfileForFileL" );
-    HBufC* retval = NULL;
-       
-
-    CImageDecoder* imageDecoder = CImageDecoder::FileNewL(
-                                                    aFile,
-                                                    aMimetype,
-                                                    ContentAccess::EPeek );
-    
-    CleanupStack::PushL( imageDecoder );
-
-    TSize imageResolution = imageDecoder->FrameInfo().iOverallSizeInPixels;
-
-    if ( aMimetype.Compare( KImageJpeg() ) == 0 ) 
-        {        
-        // assuming here that thumbnails are not supported and that we do 
-        // not use device icons or at least we do not resolve DLNA profile 
-        // of device icons with this component.
-
-        if ( imageResolution.iWidth <= KJpeg_smico_max_width && 
-             imageResolution.iHeight <= KJpeg_smico_max_height ) 
-            {
-            retval = HBufC::NewL( KJpeg_sm_ico().Length() );
-            retval->Des().Append( KJpeg_sm_ico() );
-            }
-        else if ( imageResolution.iWidth <= KJpeg_lrgico_max_width && 
-             imageResolution.iHeight <= KJpeg_lrgico_max_height ) 
-            {
-            retval = HBufC::NewL( KJpeg_lrg_ico().Length() );
-            retval->Des().Append( KJpeg_lrg_ico() );
-            }
-        else if ( imageResolution.iWidth <= KJpeg_sm_max_width && 
-             imageResolution.iHeight <= KJpeg_sm_max_height ) 
-            {
-            retval = HBufC::NewL( KJpeg_sm().Length() );
-            retval->Des().Append( KJpeg_sm() );
-            }
-        else if ( imageResolution.iWidth <= KJpeg_med_max_width && 
-                  imageResolution.iHeight <= KJpeg_med_max_height )
-            {
-            retval = HBufC::NewL( KJpeg_med().Length() );
-            retval->Des().Append( KJpeg_med() );
-            }
-        else if ( imageResolution.iWidth <= KJpeg_lrg_max_width && 
-                  imageResolution.iHeight <= KJpeg_lrg_max_height )
-            {
-            retval = HBufC::NewL( KJpeg_lrg().Length() );
-            retval->Des().Append( KJpeg_lrg() );
-            }
-
-        }
-    else if ( aMimetype.Compare( KImagePng() ) == 0 ) 
-        {
-        // assuming here that thumbnails are not supported and that we do 
-        // not use device icons or at least we do not resolve DLNA profile 
-        // of device icons with this component. This leads to profiling all
-        // png-files as PNG_LRG in case their size is less than 4096x4096.
-        if ( imageResolution.iWidth <= KPng_lrg_max_width && 
-             imageResolution.iHeight <= KPng_lrg_max_height )
-            {
-            retval = HBufC::NewL( KPngLrg().Length() );
-            retval->Des().Append( KPngLrg() );
-            }
-        }
-        
-    // clean up
-    CleanupStack::PopAndDestroy( imageDecoder );
-      
-    return retval;
-    }
-
-// end of file
+/*
+* Copyright (c) 2006-2007 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:      Implementation of base DLNA profile resolver class for image 
+*                files.
+*
+*/
+
+
+
+
+
+
+// system includes
+#include <imageconversion.h>
+#include <caf/caftypes.h> // ContentAccess
+#include <badesca.h> // CDesC16ArrayFlat
+
+// user includes
+#include "upnpimagesolverbase.h"
+
+_LIT( KComponentLogfile, "dlnaprofiler.txt");
+#include "upnplog.h"
+
+// constants
+_LIT8( KImageJpeg, "image/jpeg" );
+_LIT( KJpeg_sm, "JPEG_SM" );
+_LIT( KJpeg_med, "JPEG_MED" );
+_LIT( KJpeg_lrg, "JPEG_LRG" );
+
+_LIT( KJpeg_tn, "JPEG_TN" );
+_LIT( KJpeg_lrg_ico, "JPEG_LRG_ICO" );
+_LIT( KJpeg_sm_ico, "JPEG_SM_ICO" );
+
+_LIT8( KImagePng, "image/png" );
+_LIT( KPngLrg, "PNG_LRG" );
+
+
+const TInt KJpeg_smico_max_width = 48;
+const TInt KJpeg_smico_max_height = 48;
+const TInt KJpeg_lrgico_max_width = 120;
+const TInt KJpeg_lrgico_max_height = 120;
+const TInt KJpeg_tn_max_width = 160;
+const TInt KJpeg_tn_max_height = 160;
+const TInt KJpeg_sm_max_width = 640;
+const TInt KJpeg_sm_max_height = 480;
+const TInt KJpeg_med_max_width = 1024;
+const TInt KJpeg_med_max_height = 768;
+const TInt KJpeg_lrg_max_width = 4096;
+const TInt KJpeg_lrg_max_height = 4096;
+const TInt KPng_lrg_max_width = 4096;
+const TInt KPng_lrg_max_height = 4096;
+
+// ======== LOCAL FUNCTIONS ========
+// NONE
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUpnpImageSolverBase C++ constructor
+// --------------------------------------------------------------------------
+//
+CUpnpImageSolverBase::CUpnpImageSolverBase()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase constructor" );
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpImageSolverBase::ConstructL
+// --------------------------------------------------------------------------
+//
+void CUpnpImageSolverBase::ConstructL()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase::ConstructL" );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpImageSolverBase::NewL
+// --------------------------------------------------------------------------
+//
+CUpnpImageSolverBase* CUpnpImageSolverBase::NewL()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase::NewL" );
+    CUpnpImageSolverBase* self = CUpnpImageSolverBase::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpImageSolverBase::NewLC
+// --------------------------------------------------------------------------
+//
+CUpnpImageSolverBase* CUpnpImageSolverBase::NewLC()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase::NewLC" );
+    CUpnpImageSolverBase* self = new( ELeave ) CUpnpImageSolverBase;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpImageSolverBase destructor
+// --------------------------------------------------------------------------
+//
+CUpnpImageSolverBase::~CUpnpImageSolverBase()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase destructor" );
+    }
+
+// --------------------------------------------------------------------------
+// From class MUpnpProfiler.
+// SupportedProfilesL returns DLNA profiles that are currently supported.
+// --------------------------------------------------------------------------
+//
+TInt CUpnpImageSolverBase::SupportedProfilesL( 
+                                        CDesC16ArrayFlat* aProfiles ) const
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase::\
+SupportedProfilesL" );
+    TInt retval = KErrNone;
+    
+    if ( !aProfiles ) 
+        {
+        // Invalid parameter
+        retval = KErrArgument;
+        }
+    else 
+        {
+        // append all new profiles recognized by this solver
+        // do not allow duplicates
+        TInt tempPos = KErrNotFound;
+        
+        if ( aProfiles->Find( KJpeg_sm(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KJpeg_sm() );
+            }
+        if ( aProfiles->Find( KJpeg_med(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KJpeg_med() );
+            }
+        if ( aProfiles->Find( KJpeg_lrg(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KJpeg_lrg() );
+            }
+        if ( aProfiles->Find( KPngLrg(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KPngLrg() );
+            }
+        if ( aProfiles->Find( KJpeg_tn(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KJpeg_tn() );
+            }            
+        if ( aProfiles->Find( KJpeg_lrg_ico(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KJpeg_lrg_ico() );
+            }            
+        if ( aProfiles->Find( KJpeg_sm_ico(), tempPos, ECmpFolded ) ) 
+            {
+            aProfiles->AppendL( KJpeg_sm_ico() );
+            }            
+
+
+        }    
+
+    return retval;
+    }
+    
+// --------------------------------------------------------------------------
+// From class MUpnpProfiler.
+// ProfileForFileL is for resolving a DLNA profile of a given file. Besides 
+// of file name, also mime type of the file is passed as a parameter in order 
+// to avoid re-opening the file.
+// --------------------------------------------------------------------------
+//
+HBufC* CUpnpImageSolverBase::ProfileForFileL( const TDesC& /*aFilename*/, 
+                                              const TDesC8& aMimetype, 
+                                              RFile& aFile )
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpImageSolverBase::ProfileForFileL" );
+    HBufC* retval = NULL;
+       
+
+    CImageDecoder* imageDecoder = CImageDecoder::FileNewL(
+                                                    aFile,
+                                                    aMimetype,
+                                                    ContentAccess::EPeek );
+    
+    CleanupStack::PushL( imageDecoder );
+
+    TSize imageResolution = imageDecoder->FrameInfo().iOverallSizeInPixels;
+
+    if ( aMimetype.Compare( KImageJpeg() ) == 0 ) 
+        {        
+        // assuming here that thumbnails are not supported and that we do 
+        // not use device icons or at least we do not resolve DLNA profile 
+        // of device icons with this component.
+
+        if ( imageResolution.iWidth <= KJpeg_smico_max_width && 
+             imageResolution.iHeight <= KJpeg_smico_max_height ) 
+            {
+            retval = HBufC::NewL( KJpeg_sm_ico().Length() );
+            retval->Des().Append( KJpeg_sm_ico() );
+            }
+        else if ( imageResolution.iWidth <= KJpeg_lrgico_max_width && 
+             imageResolution.iHeight <= KJpeg_lrgico_max_height ) 
+            {
+            retval = HBufC::NewL( KJpeg_lrg_ico().Length() );
+            retval->Des().Append( KJpeg_lrg_ico() );
+            }
+        else if ( imageResolution.iWidth <= KJpeg_tn_max_width && 
+             imageResolution.iHeight <= KJpeg_tn_max_height ) 
+            {
+            retval = HBufC::NewL( KJpeg_tn().Length() );
+            retval->Des().Append( KJpeg_tn() );
+            }
+        else if ( imageResolution.iWidth <= KJpeg_sm_max_width && 
+             imageResolution.iHeight <= KJpeg_sm_max_height ) 
+            {
+            retval = HBufC::NewL( KJpeg_sm().Length() );
+            retval->Des().Append( KJpeg_sm() );
+            }
+        else if ( imageResolution.iWidth <= KJpeg_med_max_width && 
+                  imageResolution.iHeight <= KJpeg_med_max_height )
+            {
+            retval = HBufC::NewL( KJpeg_med().Length() );
+            retval->Des().Append( KJpeg_med() );
+            }
+        else if ( imageResolution.iWidth <= KJpeg_lrg_max_width && 
+                  imageResolution.iHeight <= KJpeg_lrg_max_height )
+            {
+            retval = HBufC::NewL( KJpeg_lrg().Length() );
+            retval->Des().Append( KJpeg_lrg() );
+            }
+
+        }
+    else if ( aMimetype.Compare( KImagePng() ) == 0 ) 
+        {
+        // assuming here that thumbnails are not supported and that we do 
+        // not use device icons or at least we do not resolve DLNA profile 
+        // of device icons with this component. This leads to profiling all
+        // png-files as PNG_LRG in case their size is less than 4096x4096.
+        if ( imageResolution.iWidth <= KPng_lrg_max_width && 
+             imageResolution.iHeight <= KPng_lrg_max_height )
+            {
+            retval = HBufC::NewL( KPngLrg().Length() );
+            retval->Des().Append( KPngLrg() );
+            }
+        }
+        
+    // clean up
+    CleanupStack::PopAndDestroy( imageDecoder );
+      
+    return retval;
+    }
+
+// end of file
--- a/upnpsharing/upnpdlnaprofiler/src/upnpresresolver.cpp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpdlnaprofiler/src/upnpresresolver.cpp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,440 +1,511 @@
-/*
-* Copyright (c) 2006-2007 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:      Implementation file of CUpnpResResolver class. 
-*                CUpnpResResolver is a class used for resolving res field 
-*                attributes for a given file.
-*
-*/
-
-
-
-
-
-
-// system includes
-#include <f32file.h> // RFile
-#include <apgcli.h> // RApaLsSession
-#include <upnpdlnaprotocolinfo.h> // CUpnpDlnaProtocolInfo
-#include <imageconversion.h> // CImageDecoder
-#include <caf/caftypes.h> // ContentAccess
-#include <3gplibrary/mp4lib.h> // MP4ParseRequestAudioDescription
-#include <escapeutils.h> // EscapeUtils::ConvertFromUnicodeToUtf8L
-
-// user includes
-#include "upnpresresolver.h"
-#include "upnpdlnaprofiler.h"
-#include "upnpresparameters.h"
-
-_LIT( KComponentLogfile, "dlnaprofiler.txt");
-#include "upnplog.h"
-
-// constants
-_LIT8( KHttpGet8, "http-get" );
-_LIT8( KStar8, "*" );
-
-const TInt KMicrosecondsInSecond = 1000000;
-const TInt KMilliSecondsInSecond = 1000;
-
-// ======== LOCAL FUNCTIONS ========
-// NONE
-
-// ======== MEMBER FUNCTIONS ========
-
-// --------------------------------------------------------------------------
-// CUpnpResResolver C++ constructor
-// --------------------------------------------------------------------------
-//
-CUpnpResResolver::CUpnpResResolver() : iDuration(0)
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver constructor" );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpResResolver::ConstructL
-// --------------------------------------------------------------------------
-//
-void CUpnpResResolver::ConstructL()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::ConstructL" );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpResResolver::NewL
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpResResolver* CUpnpResResolver::NewL()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::NewL" );
-    CUpnpResResolver* self = CUpnpResResolver::NewLC();
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpResResolver::NewLC
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpResResolver* CUpnpResResolver::NewLC()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::NewLC" );
-    CUpnpResResolver* self = new( ELeave ) CUpnpResResolver;
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpResResolver destructor
-// --------------------------------------------------------------------------
-//
-CUpnpResResolver::~CUpnpResResolver()
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver destructor" );
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpResResolver::GetResParametersL
-// --------------------------------------------------------------------------
-//
-EXPORT_C CUpnpResParameters* CUpnpResResolver::GetResParametersL( 
-                                                    const TDesC& aFilename ) 
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetResParametersL" );
-    // check that aFileName is reasonable
-    if ( aFilename.Length() <= 0 ) 
-        {
-        User::Leave( KErrArgument );
-        }
-    
-    // Create object that will be returned.
-    CUpnpResParameters* retval = CUpnpResParameters::NewLC();
-
-    // try to open file specified by aFileName
-    RFs fsSession;
-    User::LeaveIfError( fsSession.Connect() ); // connect session
-    CleanupClosePushL( fsSession );
-    // without calling ShareProtected() RApaLsSession::RecognizeData 
-    // does not work (leaves with KErrBadHandle).
-    fsSession.ShareProtected();
-
-    RFile file;
-    User::LeaveIfError( file.Open( fsSession, 
-                                   aFilename, 
-                                   EFileShareReadersOrWriters|EFileRead ) );
-    CleanupClosePushL( file );
-    
-    // Obtain mimetype of the file
-    HBufC8* mimetype = GetMimetypeL( file );
-    CleanupStack::PushL( mimetype );
-    retval->SetMimetypeL( *mimetype );
-
-    // Obtain file size
-    TInt filesize = GetFileSizeL( file );
-    retval->SetFileSize( filesize );
-
-    // Obtain duration for video&audio files and resolution for images.
-    TSize imageResolution( KErrNotFound, KErrNotFound );
-    if ( mimetype->Left( KMimeStartLength ).Compare( KVideo() ) == 0 ) 
-        {
-        GetVideoDurationL( file );
-        retval->SetDurationInSeconds( iDuration.Int64() );
-        }
-    else if ( mimetype->Left( KMimeStartLength ).Compare( KAudio() ) == 0 ) 
-        {
-        GetAudioDurationL( aFilename );
-        retval->SetDurationInSeconds( 
-                                iDuration.Int64() / KMicrosecondsInSecond );
-        }
-    else if ( mimetype->Left( KMimeStartLength ).Compare( KImage() ) == 0 ) 
-        {
-        TRAPD( err, imageResolution = GetImageResolutionL( file, 
-                                                           *mimetype ) );
-        if ( !err ) 
-            {
-            retval->SetResolution( imageResolution );
-            }
-        }
-
-    // Construct CUpnpDlnaProtocolInfo object.
-    CUpnpDlnaProtocolInfo* protocolInfo = CUpnpDlnaProtocolInfo::NewL(); 
-    CleanupStack::PushL( protocolInfo ); 
-    protocolInfo->SetFirstFieldL( KHttpGet8() ); 
-    protocolInfo->SetSecondFieldL( KStar8() ); 
-    protocolInfo->SetThirdFieldL( *mimetype ); 
-        
-    // Obtain DLNA Profile ID
-    CUpnpDlnaProfiler* profiler = CUpnpDlnaProfiler::NewLC();
-    HBufC* PnParameter = NULL;
-    TRAPD( profileErr, 
-           PnParameter = profiler->ProfileForFileL( aFilename,
-                                                    file,
-                                                    *retval ) );
-    CleanupStack::PopAndDestroy( profiler );
-    
-    if ( PnParameter && !profileErr ) 
-        {
-        // Set DLNA Profile name (PN parameter)
-        CleanupStack::PushL( PnParameter );
-        HBufC8* profileName8bit = 
-            EscapeUtils::ConvertFromUnicodeToUtf8L( *PnParameter );
-        CleanupStack::PushL( profileName8bit );
-        protocolInfo->SetPnParameterL( *profileName8bit );
-        CleanupStack::PopAndDestroy( profileName8bit );
-
-        // OP parameter is always the same in our CDS.
-        protocolInfo->SetOpParameterL( 
-                                   UpnpDlnaProtocolInfo::KDEFAULT_DLNA_OP ); 
-
-        // Set Flags according to file type.
-        if ( mimetype->Left( KMimeStartLength ).Compare( KVideo() ) == 0 ) 
-            {
-            protocolInfo->SetFlagsParameterL( 
-                           UpnpDlnaProtocolInfo::KDEFAULT_DLNA_FLAGS_AV );
-            }
-        else if 
-           ( mimetype->Left( KMimeStartLength ).Compare( KAudio() ) == 0 ) 
-            {
-            protocolInfo->SetFlagsParameterL( 
-                           UpnpDlnaProtocolInfo::KDEFAULT_DLNA_FLAGS_AUDIO );
-            }
-        else if 
-           ( mimetype->Left( KMimeStartLength ).Compare( KImage() ) == 0 ) 
-            {
-            protocolInfo->SetFlagsParameterL( 
-                           UpnpDlnaProtocolInfo::KDEFAULT_DLNA_FLAGS_IMAGE );
-            }
-                            
-        CleanupStack::PopAndDestroy( PnParameter );
-        }
-
-    retval->SetProtocolInfoL( protocolInfo->ProtocolInfoL() );
-
-    // clean up
-    CleanupStack::PopAndDestroy( protocolInfo );
-    CleanupStack::PopAndDestroy( mimetype );
-    CleanupStack::PopAndDestroy( &file );
-    CleanupStack::PopAndDestroy( &fsSession );
-    CleanupStack::Pop( retval );
-    return retval;
-
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpResResolver::GetMimetypeL
-// --------------------------------------------------------------------------
-//
-HBufC8* CUpnpResResolver::GetMimetypeL( RFile& aFile ) 
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetMimetypeL" );
-    HBufC8* retval = NULL;
-    // Create an AppArc server session for mime type recognition 
-    RApaLsSession sess;
-    User::LeaveIfError( sess.Connect() );
-    CleanupClosePushL( sess );
-
-    // Try to get mime type from AppArc server
-    TDataRecognitionResult mimeResult;
-    User::LeaveIfError( sess.RecognizeData( aFile, mimeResult ) );
-    
-    // close session handle
-    CleanupStack::PopAndDestroy( &sess );
-
-    // Data recognition done. Check results.
-    retval = mimeResult.iDataType.Des8().AllocL();
-    return retval;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpResResolver::GetVideoDurationL
-// --------------------------------------------------------------------------
-//
-void CUpnpResResolver::GetVideoDurationL( RFile& aFile )  
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetVideoDurationL" );
-    mp4_u32 videolength = 0;  
-    mp4_double framerate = 0; 
-    mp4_u32 videotype = 0;    
-    mp4_u32 videowidth = 0;   
-    mp4_u32 videoheight = 0;  
-    mp4_u32 timescale = 0; 
-
-    MP4Handle myMp4Handle;
-    
-    // try open mp4 file handle
-    MP4Err openerr = MP4ParseOpenFileHandle( &myMp4Handle, &aFile );
-    switch ( openerr )
-        {
-        case MP4_OK :
-        	{
-        	// obtain necessary information from file
-            MP4Err requesterr = MP4ParseRequestVideoDescription( 
-                                                myMp4Handle, 
-                                                &videolength,   
-                                                &framerate,     
-                                                &videotype,     
-                                                &videowidth,    
-                                                &videoheight,   
-                                                &timescale );
-               
-            // close mp4 file handle
-            MP4Err closeerr = MP4ParseClose( myMp4Handle );
-            if ( closeerr || requesterr ) 
-                {
-                User::Leave( KErrGeneral );
-                }
-        	}
-        	break;
-        case MP4_ERROR :
-        	{
-        	User::Leave( KErrGeneral );
-        	}
-        	break;
-        case MP4_OUT_OF_MEMORY :
-        	{
-        	User::Leave( KErrNoMemory );
-        	}
-        	break;
-        case MP4_FILE_ERROR :
-        	{
-        	User::Leave( KErrAccessDenied );
-        	}
-        	break;
-        default :
-            User::Leave( KErrGeneral );
-            break;
-        }
-    // videolength in milliseconds
-    iDuration = videolength/KMilliSecondsInSecond;
-    }
-    
-// --------------------------------------------------------------------------
-// CUpnpResResolver::GetAudioDurationL
-// --------------------------------------------------------------------------
-//
-void CUpnpResResolver::GetAudioDurationL( const TDesC& aFilename ) 
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetAudioDurationL" );
-
-    // create audioplayer if it does not exist
-    if ( !iAudioplayer ) 
-        {
-        iAudioplayer = CMdaAudioPlayerUtility::NewL( *this );
-        }
-
-    // Create iWait if it does not exist. Create it here rather than after 
-    // OpenL-call so that there will be no problems if somehow OpenFileL 
-    // calls MapcInitComplete-callback before iWait is created and started.
-    if ( !iWait ) 
-        {
-        iWait = new( ELeave ) CActiveSchedulerWait;
-        }
-
-    // Open file specified in aFilename. This is an asynchronic operation. 
-    // Calls MapcInitComplete callback after completed.
-    iAudioplayer->OpenFileL( aFilename );
-    
-    // start CActiveSchedulerWait which is completed in MapcInitComplete
-    iWait->Start();
-
-    // clean up
-    delete iAudioplayer;
-    iAudioplayer = NULL;
-    
-    delete iWait;
-    iWait = NULL;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpResResolver::GetFileSizeL
-// --------------------------------------------------------------------------
-//
-TInt CUpnpResResolver::GetFileSizeL( RFile& aFile ) 
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetFileSizeL" );
-    TInt retval = KErrNone;
-    User::LeaveIfError( aFile.Size( retval ) );
-    return retval;
-    }
-
-
-// --------------------------------------------------------------------------
-// CUpnpResResolver::GetImageResolutionL
-// --------------------------------------------------------------------------
-//  
-TSize CUpnpResResolver::GetImageResolutionL( RFile& aFile, 
-                                             const TDesC8& aMimetype )
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetImageResolutionL" );
-    CImageDecoder* imageDecoder = NULL;
-    TRAPD( createError, imageDecoder = CImageDecoder::FileNewL(
-                                                    aFile,
-                                                    aMimetype, 
-                                                    ContentAccess::EPeek ) );
-
-    if ( createError ) 
-        {
-        __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetImageResolutionL \
-CreateError" );
-        User::Leave( createError );
-        }
-                                                              
-    CleanupStack::PushL( imageDecoder );
-    TSize imageResolution = imageDecoder->FrameInfo().iOverallSizeInPixels;
-    CleanupStack::PopAndDestroy( imageDecoder );
-    
-    return imageResolution;
-    }
-    
-// --------------------------------------------------------------------------
-// From class MMdaAudioPlayerCallback.
-// MapcPlayComplete callback (not used)
-// --------------------------------------------------------------------------
-//
-void CUpnpResResolver::MapcPlayComplete( TInt /*aError*/ ) 
-    {
-    //this callback is not needed
-    }
-
-// --------------------------------------------------------------------------
-// From class MMdaAudioPlayerCallback.
-// MapcInitComplete callback is called after a call to 
-// CMdaAudioConvertUtility::OpenL has completed.
-// --------------------------------------------------------------------------
-//
-void CUpnpResResolver::MapcInitComplete( 
-                                TInt aError, 
-                                const TTimeIntervalMicroSeconds& aDuration ) 
-    {
-    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::MapcInitComplete" );
- 
-    // if opening was successful, save duration to member variable
-    if( KErrNone == aError )
-        {
-        iDuration = aDuration;
-        }
-
-    // continue execution in GetAudioDurationL-method by stopping 
-    // ActiveSchedulerWait
-    iWait->AsyncStop();
-    }
-
-// end of file
+/*
+* Copyright (c) 2006-2007 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:      Implementation file of CUpnpResResolver class. 
+*                CUpnpResResolver is a class used for resolving res field 
+*                attributes for a given file.
+*
+*/
+
+
+
+
+
+
+// system includes
+#include <f32file.h> // RFile
+#include <apgcli.h> // RApaLsSession
+#include <upnpdlnaprotocolinfo.h> // CUpnpDlnaProtocolInfo
+#include <imageconversion.h> // CImageDecoder
+#include <caf/caftypes.h> // ContentAccess
+#include <3gplibrary/mp4lib.h>  // MP4ParseRequestAudioDescription
+#include <escapeutils.h> // EscapeUtils::ConvertFromUnicodeToUtf8L
+
+// user includes
+#include "upnpresresolver.h"
+#include "upnpdlnaprofiler.h"
+#include "upnpresparameters.h"
+
+_LIT( KComponentLogfile, "dlnaprofiler.txt");
+#include "upnplog.h"
+
+// constants
+_LIT8( KHttpGet8, "http-get" );
+_LIT8( KStar8, "*" );
+
+const TInt KMicrosecondsInSecond = 1000000;
+const TInt KMilliSecondsInSecond = 1000;
+
+// ======== LOCAL FUNCTIONS ========
+// NONE
+
+// ======== MEMBER FUNCTIONS ========
+
+// --------------------------------------------------------------------------
+// CUpnpResResolver C++ constructor
+// --------------------------------------------------------------------------
+//
+CUpnpResResolver::CUpnpResResolver() : iDuration(0)
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver constructor" );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpResResolver::ConstructL
+// --------------------------------------------------------------------------
+//
+void CUpnpResResolver::ConstructL()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::ConstructL" );
+    
+    // open semaphore
+    User::LeaveIfError( iSemaphore.CreateLocal( 0 ) );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpResResolver::NewL
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpResResolver* CUpnpResResolver::NewL()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::NewL" );
+    CUpnpResResolver* self = CUpnpResResolver::NewLC();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpResResolver::NewLC
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpResResolver* CUpnpResResolver::NewLC()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::NewLC" );
+    CUpnpResResolver* self = new( ELeave ) CUpnpResResolver;
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    return self;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpResResolver destructor
+// --------------------------------------------------------------------------
+//
+CUpnpResResolver::~CUpnpResResolver()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver destructor" );
+    
+    iSemaphore.Close();
+    delete iAVFile;
+    }
+
+// --------------------------------------------------------------------------
+// CUpnpResResolver::GetResParametersL
+// --------------------------------------------------------------------------
+//
+EXPORT_C CUpnpResParameters* CUpnpResResolver::GetResParametersL(
+    const TDesC& aFilename ) 
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetResParametersL" );
+    // check that aFileName is reasonable
+    if ( aFilename.Length() <= 0 ) 
+        {
+        User::Leave( KErrArgument );
+        }
+    
+    // Create object that will be returned.
+    CUpnpResParameters* retval = CUpnpResParameters::NewLC();
+
+    // try to open file specified by aFileName
+    RFs fsSession;
+    User::LeaveIfError( fsSession.Connect() ); // connect session
+    CleanupClosePushL( fsSession );
+    // without calling ShareProtected() RApaLsSession::RecognizeData 
+    // does not work (leaves with KErrBadHandle).
+    fsSession.ShareProtected();
+
+    RFile file;
+    User::LeaveIfError( file.Open( fsSession, 
+                                   aFilename, 
+                                   EFileShareReadersOrWriters|EFileRead ) );
+    CleanupClosePushL( file );
+    
+    // Obtain mimetype of the file
+    HBufC8* mimetype = GetMimetypeL( file );
+    CleanupStack::PushL( mimetype );
+    retval->SetMimetypeL( *mimetype );
+
+    // Obtain file size
+    TInt filesize = GetFileSizeL( file );
+    retval->SetFileSize( filesize );
+
+    // Obtain duration for video&audio files and resolution for images.
+    TSize imageResolution( KErrNotFound, KErrNotFound );
+    if ( mimetype->Left( KMimeStartLength ).Compare( KVideo() ) == 0 ) 
+        {
+        GetVideoDurationL( file );
+        retval->SetDurationInSeconds( iDuration.Int64() );
+        }
+    else if ( mimetype->Left( KMimeStartLength ).Compare( KAudio() ) == 0 ) 
+        {
+        GetAudioDurationL( aFilename );
+        retval->SetDurationInSeconds( 
+                                iDuration.Int64() / KMicrosecondsInSecond );
+        }
+    else if ( mimetype->Left( KMimeStartLength ).Compare( KImage() ) == 0 ) 
+        {
+        TRAPD( err, imageResolution = GetImageResolutionL( file, 
+                                                           *mimetype ) );
+        if ( !err ) 
+            {
+            retval->SetResolution( imageResolution );
+            }
+        }
+
+    // Construct CUpnpDlnaProtocolInfo object.
+    CUpnpDlnaProtocolInfo* protocolInfo = CUpnpDlnaProtocolInfo::NewL(); 
+    CleanupStack::PushL( protocolInfo ); 
+    protocolInfo->SetFirstFieldL( KHttpGet8() ); 
+    protocolInfo->SetSecondFieldL( KStar8() ); 
+    protocolInfo->SetThirdFieldL( *mimetype ); 
+        
+    // Obtain DLNA Profile ID
+    CUpnpDlnaProfiler* profiler = CUpnpDlnaProfiler::NewLC();
+    HBufC* PnParameter = NULL;
+    TRAPD( profileErr, 
+           PnParameter = profiler->ProfileForFileL( aFilename,
+                                                    file,
+                                                    *retval ) );
+    CleanupStack::PopAndDestroy( profiler );
+    
+    if ( PnParameter && !profileErr ) 
+        {
+        // Set DLNA Profile name (PN parameter)
+        CleanupStack::PushL( PnParameter );
+        HBufC8* profileName8bit = 
+            EscapeUtils::ConvertFromUnicodeToUtf8L( *PnParameter );
+        CleanupStack::PushL( profileName8bit );
+        protocolInfo->SetPnParameterL( *profileName8bit );
+        CleanupStack::PopAndDestroy( profileName8bit );
+
+        // OP parameter is always the same in our CDS.
+        protocolInfo->SetOpParameterL( 
+                                   UpnpDlnaProtocolInfo::KDEFAULT_DLNA_OP ); 
+
+        // Set Flags according to file type.
+        if ( mimetype->Left( KMimeStartLength ).Compare( KVideo() ) == 0 ) 
+            {
+            protocolInfo->SetFlagsParameterL( 
+                           UpnpDlnaProtocolInfo::KDEFAULT_DLNA_FLAGS_AV );
+            }
+        else if 
+           ( mimetype->Left( KMimeStartLength ).Compare( KAudio() ) == 0 ) 
+            {
+            protocolInfo->SetFlagsParameterL( 
+                           UpnpDlnaProtocolInfo::KDEFAULT_DLNA_FLAGS_AUDIO );
+            }
+        else if 
+           ( mimetype->Left( KMimeStartLength ).Compare( KImage() ) == 0 ) 
+            {
+            protocolInfo->SetFlagsParameterL( 
+                           UpnpDlnaProtocolInfo::KDEFAULT_DLNA_FLAGS_IMAGE );
+            }
+                            
+        CleanupStack::PopAndDestroy( PnParameter );
+        }
+
+    retval->SetProtocolInfoL( protocolInfo->ProtocolInfoL() );
+
+    // clean up
+    CleanupStack::PopAndDestroy( protocolInfo );
+    CleanupStack::PopAndDestroy( mimetype );
+    CleanupStack::PopAndDestroy( &file );
+    CleanupStack::PopAndDestroy( &fsSession );
+    CleanupStack::Pop( retval );
+    return retval;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpResResolver::GetMimetypeL
+// --------------------------------------------------------------------------
+//
+HBufC8* CUpnpResResolver::GetMimetypeL( RFile& aFile ) 
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetMimetypeL" );
+    HBufC8* retval = NULL;
+    // Create an AppArc server session for mime type recognition 
+    RApaLsSession sess;
+    User::LeaveIfError( sess.Connect() );
+    CleanupClosePushL( sess );
+
+    // Try to get mime type from AppArc server
+    TDataRecognitionResult mimeResult;
+    User::LeaveIfError( sess.RecognizeData( aFile, mimeResult ) );
+    
+    // close session handle
+    CleanupStack::PopAndDestroy( &sess );
+   
+    if( mimeResult.iDataType.Des8().Length() == 0 )
+        {
+        User::Leave( KErrGeneral );
+        }
+    
+    // Data recognition done. Check results.
+    retval = mimeResult.iDataType.Des8().AllocL();
+    return retval;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpResResolver::GetVideoDurationL
+// --------------------------------------------------------------------------
+//
+void CUpnpResResolver::GetVideoDurationL( RFile& aFile )  
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetVideoDurationL" );
+    mp4_u32 videolength = 0;  
+    mp4_double framerate = 0; 
+    mp4_u32 videotype = 0;    
+    mp4_u32 videowidth = 0;   
+    mp4_u32 videoheight = 0;  
+    mp4_u32 timescale = 0; 
+
+    MP4Handle myMp4Handle;
+    
+    // try open mp4 file handle
+    MP4Err openerr = MP4ParseOpenFileHandle( &myMp4Handle, &aFile );
+    switch ( openerr )
+        {
+        case MP4_OK :
+        	{
+        	// obtain necessary information from file
+            MP4Err requesterr = MP4ParseRequestVideoDescription( 
+                                                myMp4Handle, 
+                                                &videolength,   
+                                                &framerate,     
+                                                &videotype,     
+                                                &videowidth,    
+                                                &videoheight,   
+                                                &timescale );
+               
+            // close mp4 file handle
+            MP4Err closeerr = MP4ParseClose( myMp4Handle );
+            if ( closeerr || requesterr ) 
+                {
+                User::Leave( KErrGeneral );
+                }
+        	}
+        	break;
+        case MP4_ERROR :
+        	{
+        	User::Leave( KErrGeneral );
+        	}
+        	break;
+        case MP4_OUT_OF_MEMORY :
+        	{
+        	User::Leave( KErrNoMemory );
+        	}
+        	break;
+        case MP4_FILE_ERROR :
+        	{
+        	User::Leave( KErrAccessDenied );
+        	}
+        	break;
+        default :
+            User::Leave( KErrGeneral );
+            break;
+        }
+    // videolength in milliseconds
+    iDuration = videolength/KMilliSecondsInSecond;
+    }
+    
+// --------------------------------------------------------------------------
+// CUpnpResResolver::GetAudioDurationL
+// --------------------------------------------------------------------------
+//
+void CUpnpResResolver::GetAudioDurationL( const TDesC& aFilename ) 
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetAudioDurationL" );
+
+    TInt err = KErrNone;
+
+    // store current av file
+    HBufC* avFile = aFilename.AllocL();
+    delete iAVFile;
+    iAVFile = avFile;
+    
+    // create audio resolving thread
+    RThread thread;
+    User::LeaveIfError( thread.Create(
+        KNullDesC, ThreadFunction, KDefaultStackSize, &User::Allocator(), this ) );
+    
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetAudioDurationL: Created audio resolving thread" );
+    
+    // start thread and wait until it has finished
+    thread.Resume();
+    iSemaphore.Wait();
+    
+    // check return value and close thread
+    err = thread.ExitReason();
+    thread.Close();
+    
+    __LOG1( "[UPnPDlnaProfiler] CUpnpResResolver::GetAudioDurationL: Finished audio resolving thread with code (%d)", err );
+
+    // leave if could not resolve audio duration
+    User::LeaveIfError( err );
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpResResolver::GetFileSizeL
+// --------------------------------------------------------------------------
+//
+TInt CUpnpResResolver::GetFileSizeL( RFile& aFile ) 
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetFileSizeL" );
+    TInt retval = KErrNone;
+    User::LeaveIfError( aFile.Size( retval ) );
+    return retval;
+    }
+
+
+// --------------------------------------------------------------------------
+// CUpnpResResolver::GetImageResolutionL
+// --------------------------------------------------------------------------
+//  
+TSize CUpnpResResolver::GetImageResolutionL( RFile& aFile,
+    const TDesC8& aMimetype )
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetImageResolutionL" );
+    CImageDecoder* imageDecoder = NULL;
+    TRAPD( createError, imageDecoder = CImageDecoder::FileNewL(
+                                                    aFile,
+                                                    aMimetype, 
+                                                    ContentAccess::EPeek ) );
+
+    if ( createError ) 
+        {
+        __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::GetImageResolutionL \
+CreateError" );
+        User::Leave( createError );
+        }
+                                                              
+    CleanupStack::PushL( imageDecoder );
+    TSize imageResolution = imageDecoder->FrameInfo().iOverallSizeInPixels;
+    CleanupStack::PopAndDestroy( imageDecoder );
+    
+    return imageResolution;
+    }
+    
+// --------------------------------------------------------------------------
+// From class MMdaAudioPlayerCallback.
+// MapcPlayComplete callback (not used)
+// --------------------------------------------------------------------------
+//
+void CUpnpResResolver::MapcPlayComplete( TInt /*aError*/ ) 
+    {
+    // not used.
+    }
+
+// --------------------------------------------------------------------------
+// From class MMdaAudioPlayerCallback.
+// MapcInitComplete callback is called after a call to 
+// CMdaAudioConvertUtility::OpenL has completed.
+// --------------------------------------------------------------------------
+//
+void CUpnpResResolver::MapcInitComplete( TInt aError,
+    const TTimeIntervalMicroSeconds& aDuration ) 
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::MapcInitComplete" );
+ 
+    // if opening was successful, save duration to member variable
+    if( KErrNone == aError )
+        {
+        iDuration = aDuration;
+        }
+    
+    // stop scheduler for audio resolving thread
+    CActiveScheduler::Stop();
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpResResolver::ThreadFunction
+// -----------------------------------------------------------------------------
+//
+TInt CUpnpResResolver::ThreadFunction( TAny* aSelf )
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::ThreadFunction" );
+    
+    TInt err = KErrNone;
+    
+    CUpnpResResolver* self = static_cast<CUpnpResResolver*>( aSelf );
+    
+    // create cleanup stack
+    CTrapCleanup* cleanupStack = CTrapCleanup::New();
+    if( cleanupStack )
+        {
+        // execute thread function
+        TRAP( err, self->ResolveAudioDurationL() );
+        
+        // cleanup
+        delete cleanupStack;
+        }
+
+    // reset scheduler for this thread
+    CActiveScheduler::Install( NULL );
+    
+    // signal main thread so that it can continue
+    self->iSemaphore.Signal();
+    
+    return err;
+    }
+
+// -----------------------------------------------------------------------------
+// CUpnpResResolver::ResolveAudioDurationL
+// -----------------------------------------------------------------------------
+//
+void CUpnpResResolver::ResolveAudioDurationL()
+    {
+    __LOG( "[UPnPDlnaProfiler] CUpnpResResolver::ResolveAudioDurationL" );
+    
+    CActiveScheduler* scheduler = new( ELeave ) CActiveScheduler;
+    if( scheduler )
+        {        
+        CleanupStack::PushL( scheduler );
+        
+        // install the new scheduler in use for this thread
+        CActiveScheduler::Install( scheduler );
+        
+        // create audio player utility
+        CMdaAudioPlayerUtility* audioPlayerUtility =
+            CMdaAudioPlayerUtility::NewL( *this );
+        CleanupStack::PushL( audioPlayerUtility );
+        
+        // open file and wait until the audio clip initialization is ready
+        audioPlayerUtility->OpenFileL( *iAVFile );
+        
+        // start scheduler
+        CActiveScheduler::Start();
+        
+        // cleanup
+        CleanupStack::PopAndDestroy( audioPlayerUtility );
+        CleanupStack::PopAndDestroy( scheduler );
+        }
+    }
+
+// end of file
--- a/upnpsharing/upnpsecurity/group/upnpsecuritymanagerplugin.mmp	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpsecurity/group/upnpsecuritymanagerplugin.mmp	Mon Nov 01 12:37:49 2010 +0200
@@ -1,66 +1,66 @@
-/*
-* Copyright (c) 2006-2007 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: Project definition file for UpnpSecurityManager implement.
-*
-*/
-
-#include "upnpsecurityuids.h"
-#include <data_caging_paths.hrh>
-#include <platform_paths.hrh>
-#include <bldvariant.hrh>
-
-
-// Build target
-TARGET          upnpsecuritymanagerplugin.dll
-CAPABILITY      CAP_ECOM_PLUGIN
-VENDORID        VID_DEFAULT
-TARGETTYPE      PLUGIN
-UID             KGenericPluginUid2 KUpnpSecurityManagerPluginDllUid
-
-// SIS installation + IAD support
-VERSION 10.1
-paged
-
-START RESOURCE  ../data/101F977E.rss
-TARGET          upnpsecuritymanagerplugin.rsc
-TARGETPATH      resource/plugins
-END
-
-// Include paths
-USERINCLUDE     .
-USERINCLUDE     ../inc
-USERINCLUDE     ../../../inc
-
-MW_LAYER_SYSTEMINCLUDE
-
-// Sources
-SOURCEPATH      ../src
-SOURCE          upnpsecuritymanagerplugin.cpp
-SOURCE          upnpsecuritymanagerpluginproxy.cpp
-
-// Libraries
-LIBRARY         euser.lib
-
-// Upnp stack
-LIBRARY         upnpserviceframework.lib
-LIBRARY         upnpipserversutils.lib
-LIBRARY         avmediaserverclient.lib
-
-// Upnp security
-LIBRARY         upnpsecurity.lib
-
-// Logging
-DEBUGLIBRARY    flogger.lib
-
-// End of file
+/*
+* Copyright (c) 2006-2007 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: Project definition file for UpnpSecurityManager implement.
+*
+*/
+
+#include "upnpsecurityuids.h"
+#include <data_caging_paths.hrh>
+#include <platform_paths.hrh>
+#include <bldvariant.hrh>
+
+
+// Build target
+TARGET          upnpsecuritymanagerplugin.dll
+CAPABILITY      CAP_ECOM_PLUGIN
+VENDORID        VID_DEFAULT
+TARGETTYPE      PLUGIN
+UID             KGenericPluginUid2 KUpnpSecurityManagerPluginDllUid
+
+// SIS installation + IAD support
+VERSION 10.1
+paged
+
+START RESOURCE  ../data/101F977E.rss
+TARGET          upnpsecuritymanagerplugin.rsc
+TARGETPATH      resource/plugins
+END
+
+// Include paths
+USERINCLUDE     .
+USERINCLUDE     ../inc
+USERINCLUDE     ../../../inc
+
+MW_LAYER_SYSTEMINCLUDE
+
+// Sources
+SOURCEPATH      ../src
+SOURCE          upnpsecuritymanagerplugin.cpp
+SOURCE          upnpsecuritymanagerpluginproxy.cpp
+
+// Libraries
+LIBRARY         euser.lib
+
+// Upnp stack
+LIBRARY         upnpserviceframework.lib
+LIBRARY         upnpipserversutils.lib
+
+// dlnasrv
+LIBRARY         avmediaserverclient.lib
+LIBRARY         upnpsecurity.lib
+
+// Logging
+DEBUGLIBRARY    flogger.lib
+
+// End of file
--- a/upnpsharing/upnpsecurity/inc/server/upnpauthorizationnote.h	Fri Sep 17 08:31:21 2010 +0300
+++ b/upnpsharing/upnpsecurity/inc/server/upnpauthorizationnote.h	Mon Nov 01 12:37:49 2010 +0200
@@ -1,96 +1,97 @@
-/** @file
- * Copyright (c) 2009 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 : Authorization query dialog
- *
- */
-
-#ifndef UPNPAUTHORISATIONNOTE_H
-#define UPNPAUTHORISATIONNOTE_H
-
-// INCLUDES
-#include <e32base.h>	// For CActive, link against: euser.lib
-#include "upnpnotifytimer.h"
-
-// FORWARD DECLARATIONS
-class CAknGlobalNote;
-// CONSTANTS
-#define KResourcePath KDC_RESOURCE_FILES_DIR
-_LIT( KResourceFileName, "upnpnotifier.rsc" );
-const TInt KAuthorizationNoteTimeout = 15;
-
-// CLASS DECLARATION
-
-/**
- * Observer of CUpnpAuthorizationNote results
- */
-class MUpnpAuthorizationNoteObserver
-    {
-public:
-
-    /**
-     * A callback function.
-     * @param aAuthorized The result of authorization.
-     */
-    virtual void NoteResponseL( TBool aAuthorized ) = 0;
-    };
-
-/**
- * Active wrapper of CAknGlobalNote YES/NO query dialog
- */
-class CUpnpAuthorizationNote : public CActive,
-        public MUpnpNotifyTimerObserver
-    {
-public:
-    /**
-     * Destructor.
-     */
-    ~CUpnpAuthorizationNote();
-
-    /**
-     * A two-phased constructor functions.
-     */
-    static CUpnpAuthorizationNote* NewL();
-    static CUpnpAuthorizationNote* NewLC();
-
-    /** 
-     * Creates CAknGlobalNote dialog and performs
-     * ShowNoteL() on it. The dialog is destroyed after user 
-     * confirmation or 15 second timeout.
-     *
-     * @param aObserver ShowNoteL results observer
-     */
-    void ShowNoteL( MUpnpAuthorizationNoteObserver* aObserver );
-private:
-    // from MUpnpNotifyTimerObserver
-    virtual void TimerEventL( CUpnpNotifyTimer* aTimer );
-    // from CActive
-    void RunL();
-    void DoCancel();
-    TInt RunError( TInt aError );
-    // other
-    CUpnpAuthorizationNote();
-    void ConstructL();
-    void CancelNoteL();
-    void GetResourceFilePathLC( RBuf& aPath );
-    void ReadAuthorisationStringL( const TDesC& aFilename );
-private:
-    CUpnpNotifyTimer* iTimer;
-    MUpnpAuthorizationNoteObserver* iObserver;
-    CAknGlobalNote* iNote;
-    TInt iNoteId;
-    HBufC* iAuthorizationString;
-    };
-
-#endif // UPNPAUTHORISATIONNOTE_H
-// End of File
+/** @file
+ * Copyright (c) 2009 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 : Authorization query dialog
+ *
+ */
+
+#ifndef UPNPAUTHORISATIONNOTE_H
+#define UPNPAUTHORISATIONNOTE_H
+
+// INCLUDES
+#include <e32base.h>	// For CActive, link against: euser.lib
+#include "upnpnotifytimer.h"
+
+// FORWARD DECLARATIONS
+class CAknGlobalNote;
+// CONSTANTS
+#define KResourcePath KDC_RESOURCE_FILES_DIR
+_LIT( KResourceFileName, "upnpnotifier.rsc" );
+const TInt KAuthorizationNoteTimeout = 15;
+
+// CLASS DECLARATION
+
+/**
+ * Observer of CUpnpAuthorizationNote results
+ */
+class MUpnpAuthorizationNoteObserver
+    {
+public:
+
+    /**
+     * A callback function.
+     * @param aAuthorized The result of authorization.
+     */
+    virtual void NoteResponseL( TBool aAuthorized ) = 0;
+    };
+
+/**
+ * Active wrapper of CAknGlobalNote YES/NO query dialog
+ */
+class CUpnpAuthorizationNote : public CActive,
+        public MUpnpNotifyTimerObserver
+    {
+    friend class CUpnpAuthorizationNoteTest;
+public:
+    /**
+     * Destructor.
+     */
+    ~CUpnpAuthorizationNote();
+
+    /**
+     * A two-phased constructor functions.
+     */
+    static CUpnpAuthorizationNote* NewL();
+    static CUpnpAuthorizationNote* NewLC();
+
+    /** 
+     * Creates CAknGlobalNote dialog and performs
+     * ShowNoteL() on it. The dialog is destroyed after user 
+     * confirmation or 15 second timeout.
+     *
+     * @param aObserver ShowNoteL results observer
+     */
+    void ShowNoteL( MUpnpAuthorizationNoteObserver* aObserver );
+private:
+    // from MUpnpNotifyTimerObserver
+    virtual void TimerEventL( CUpnpNotifyTimer* aTimer );
+    // from CActive
+    void RunL();
+    void DoCancel();
+    TInt RunError( TInt aError );
+    // other
+    CUpnpAuthorizationNote();
+    void ConstructL();
+    void CancelNoteL();
+    void GetResourceFilePathLC( RBuf& aPath );
+    void ReadAuthorisationStringL( const TDesC& aFilename );
+private:
+    CUpnpNotifyTimer* iTimer;
+    MUpnpAuthorizationNoteObserver* iObserver;
+    CAknGlobalNote* iNote;
+    TInt iNoteId;
+    HBufC* iAuthorizationString;
+    };
+
+#endif // UPNPAUTHORISATIONNOTE_H
+// End of File