upnpavcontrolpoint/avcpengine/inc/upnppathresolver.h
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /** @file
       
     2 * Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies  this distribution, and is available 
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CUpnpPathResolver
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_CUPNPPATHRESOLVER_H
       
    21 #define C_CUPNPPATHRESOLVER_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 
       
    26 #include <xml/dom/xmlengdom.h>
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CUpnpPathElement;
       
    30 class CUpnpResolveHandler;
       
    31 class MUpnpResolverObserver;
       
    32 class CUpnpAVCPManager;
       
    33 class TFileInfo;
       
    34 class CUpnpAVCPEngineSession;
       
    35 
       
    36 // CLASS DECLARATION
       
    37 /**
       
    38 * Class responsible for managing path element for one MS.
       
    39 * It helps in translating pathname into id.
       
    40 *
       
    41 *  @since Series 60 3.1
       
    42 */
       
    43 class CUpnpPathResolver : public CBase
       
    44 	{
       
    45 	public:  
       
    46 		/**
       
    47 		* Two-phased constructor.
       
    48 		*/
       
    49 		static CUpnpPathResolver* NewL(CUpnpAVCPManager& aManager,const TDesC8& aUUID);
       
    50 		
       
    51 		/**
       
    52 		* Destructor.
       
    53 		*/
       
    54 		virtual ~CUpnpPathResolver();
       
    55 
       
    56   public: // New functions
       
    57 		/**
       
    58 		*  Return UDN of MS that resolver is related
       
    59 		*/     
       
    60 		const TDesC8& UUID() const;
       
    61 		
       
    62 		/**
       
    63 		* Add new path element into resolver.
       
    64 		* if resolver has element with the same name and ids ignore.
       
    65 		* if resolver has element with the same naem but different id,
       
    66 		*  perform duplicatione mechanism by adding '(inx)' at the end of name, new name is returned.
       
    67 		*
       
    68 		* @param aParentId parent id
       
    69 		* @param aId id
       
    70 		* @param aName name of element
       
    71 		* @param aImportURI importURI of element
       
    72 		* @return approved name, it may be the same as aName if we don't have duplication, ale is followed by index
       
    73 		*/
       
    74 		const TDesC8& AddElementL(const TDesC8& aParentId, const TDesC8& aId, const TDesC8& aName, const TDesC8& aImportURI = KNullDesC8);
       
    75 		
       
    76 		/**
       
    77 		* Gets path element for object with given parent id and name.
       
    78 		* Ownership is not passed to caller.
       
    79 		* 
       
    80 		* @param aParentId parent id 
       
    81 		* @param aName name
       
    82 		* @return NULL if not found, else instance describing path element
       
    83 		*/
       
    84 		CUpnpPathElement* GetElementL(const TDesC8& aParentId, const TDesC8& aName) const;
       
    85 		/**
       
    86 		* Remove given element from cache array (if found in cache it destroys also given instance)
       
    87 		*
       
    88 		* @param aElement param to remove
       
    89 		*/
       
    90 		void RemoveElementD(CUpnpPathElement* aElement);  
       
    91 		/**
       
    92 		* Request for resolving pathname and notify given observer after process will be finished.
       
    93 		*/
       
    94 		void ResolveIdL(const TDesC8& aPath, MUpnpResolverObserver& aObserver);
       
    95 		/**
       
    96 		* Remove instance of resolver's handler from array of active handlers
       
    97 		*/
       
    98 		void RemoveHandler(CUpnpResolveHandler* aHandler);							
       
    99 		/**
       
   100 		Compares if two path resolvers have the UDN
       
   101 		@param aFirst First message to compare.
       
   102 		@param aSecond Second message to compare.
       
   103 		@result ETrue if same session id, EFalse otherwise.
       
   104 		**/
       
   105 		static TBool Match(const CUpnpPathResolver& aElement1, const CUpnpPathResolver& aElement2) ;        
       
   106 		/**
       
   107 		* Notify if event comes from CDS with system id, 
       
   108 		* If system id is changed path elements will be removed
       
   109 		*/
       
   110 		void StateChangedL(const TDesC8& aSystemId);
       
   111 		/**
       
   112 		* Set modification time based on date element from CDS's object.
       
   113 		*
       
   114 		* @param aDateElement XML element with date
       
   115 		* @param aEntry structure to be updated 
       
   116 		*/
       
   117 		void SetModifiedTimeL(TXmlEngElement& aDateElement, TFileInfo& aEntry); 		
       
   118 		/**
       
   119 		* Parse Browse response and updates information about path elements
       
   120 		* If aDirList is defined, update array by parsed path element 
       
   121 		*	(set also file/directory attributes)
       
   122 		* If aObjectId is not equal KNullDesC8, then also try to find resource URI for aObjectId.
       
   123 		*
       
   124 		* @param aResponse response
       
   125 		* @param aDirList array of directory entry elements
       
   126 		* @param aObjectId object id for resource URI
       
   127 		* @param	aResUri	found resource
       
   128 		*/
       
   129 		void ParseBrowseResponseL(const TDesC8& aResponse, RArray<TFileInfo>* aDirList = NULL, 
       
   130 		        const TDesC8& aObjectId = KNullDesC8, HBufC8** aResUri = NULL);
       
   131 		/**
       
   132 		* Parse Browse response and find resourse URI for object with given id.
       
   133 		* 
       
   134 		* @param aResponse response
       
   135 		* @param aId id of object
       
   136 		* @param aResUri parameter to be set with found resoursce URI
       
   137 		* @return ETrue if found, else EFalse
       
   138 		*/
       
   139 		TBool GetResUriL(const TDesC8& aResponse, const TDesC8& aId, HBufC8*& aResUri);
       
   140 		/**
       
   141 		* Parse Browse response and find resourse for object with given id.
       
   142 		* 
       
   143 		* @param aResponse response
       
   144 		* @param aId id of object		
       
   145 		* @return ETrue if found, else EFalse
       
   146 		*/		
       
   147 		TInt GetItemL(const TDesC8& aResponse, const TDesC8& aId);		
       
   148 		
       
   149 		/**
       
   150 		* Parse Browse response of CreateObject
       
   151 		* 
       
   152 		* @param aResponse response				
       
   153 		* @return ETrue if found, else EFalse
       
   154 		*/
       
   155 		TBool BrowseCreateObjectL(const TDesC8& aResponse ) ;
       
   156 		
       
   157 		/**
       
   158 		* Register session that is interested of this resolver
       
   159 		*
       
   160 		* @param aSession session
       
   161 		*/
       
   162 		void RegisterSession(CUpnpAVCPEngineSession* aSession);
       
   163 		/**
       
   164 		* Unregister session that is not interested of this resolver
       
   165 		*
       
   166 		* @param aSession session
       
   167 		* @return number of session still being interested
       
   168 		*/		
       
   169 		TInt UnregisterSession(CUpnpAVCPEngineSession* aSession);
       
   170 		/**
       
   171 		* Lock resolver to not accept resets as a result of state variable changes 
       
   172 		* Reset will be postpone until unlock method is invoked
       
   173 		*
       
   174 		*/
       
   175 		void LockReset();
       
   176 		/**
       
   177 		* Unlock reset.
       
   178 		* If between lock-unlock operation occurs state variable change, 
       
   179 		* it'll reset all entries.
       
   180 		*/
       
   181 		void UnlockReset(); 			
       
   182 	private:
       
   183 
       
   184 		/**
       
   185 		* C++ default constructor.
       
   186 		*/
       
   187 		CUpnpPathResolver(CUpnpAVCPManager& aManager);
       
   188 		
       
   189 		/**
       
   190 		* By default Symbian 2nd phase constructor is private.
       
   191 		*/
       
   192 		void ConstructL(const TDesC8& aUUID);        
       
   193 		/**
       
   194 		* Parse XML given as parameter and return DOM tree
       
   195 		*
       
   196 		* @param aXml buffer with XML
       
   197 		* @return DOM document
       
   198 		*/	
       
   199 		RXmlEngDocument ParseXmlL(const TDesC8& aXml); 	
       
   200 		/**
       
   201 		* Get prefer resource element
       
   202 		*
       
   203 		* @param aElements array of elements
       
   204 		* @return chosen one
       
   205 		*/
       
   206 		TXmlEngElement GetPreferResourceL(const RArray<TXmlEngElement>& aElements); 
       
   207 		/**
       
   208 		* Get first resource element with import URI
       
   209 		*
       
   210 		* @param aElements array of elements
       
   211 		* @param aImportURI if found
       
   212 		* @return chosen one
       
   213 		*/
       
   214 		TXmlEngElement GetResourceWithImportURIL(const RArray<TXmlEngElement>& aElements, TPtrC8& aImportURI); 
       
   215 		
       
   216 	private:    // Data
       
   217 		// last known system id (statevariable of CDS)
       
   218 		TInt iSystemId;
       
   219 		// UDN of MS 
       
   220 		HBufC8* iUUID;
       
   221 		// manager
       
   222 		CUpnpAVCPManager& iManager;
       
   223 		// array of path elements
       
   224 		RPointerArray<CUpnpPathElement> iPathElements;
       
   225 		// array of resolver's handlers
       
   226 		RPointerArray<CUpnpResolveHandler> iResolveHandlers;
       
   227 		// array of session being interested of this resolver
       
   228 		RPointerArray<CUpnpAVCPEngineSession> iAVCPSessions;
       
   229 		// indicate whether path resolver is reseted to remove all entries 
       
   230 		// when state variable changes
       
   231 		TBool iLocked;
       
   232 		// indicate whether entries are up-to-date
       
   233 		TBool iUptodate;
       
   234 		
       
   235 		RXmlEngDOMImplementation iDOMImpl;
       
   236     };
       
   237 
       
   238 #endif      // C_CUPNPPATHRESOLVER_H   
       
   239             
       
   240 // End of File