sl@0: /* sl@0: * Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: sl@0: sl@0: #ifndef __RESOLVER_H__ sl@0: #define __RESOLVER_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: namespace ContentAccess sl@0: { sl@0: const TUid KF32AgentImplUid = { 0x101FC2CF }; sl@0: sl@0: class CAgentInfo; sl@0: sl@0: /** sl@0: Used to identify the Content Access Agent who handles a particular file. sl@0: sl@0: CAgentResolver builds an array of CAgentInfo objects. Each CAgentInfo object sl@0: holds metadata related to a particular agent implementation. sl@0: sl@0: This class resolves: sl@0: - Content to the Agent which manages it sl@0: - Supplier mime-types to the agent which imports files with that mime type. sl@0: sl@0: @internalComponent sl@0: @released sl@0: */ sl@0: class CAgentResolver : public CActive sl@0: { sl@0: public: sl@0: /** Constructs a new CAgentResolver and puts it on the cleanup stack sl@0: * @param aDynamicAgentUpdate ETrue if the CAgentResolver should update its list of agents when new agents appear. A CActiveScheduler must already be running when ETrue is supplied sl@0: * @leave KErrCANoAgent If no F32 agent was found sl@0: */ sl@0: IMPORT_C static CAgentResolver* NewLC(const TBool aDynamicAgentUpdate); sl@0: sl@0: /** Constructs a new CAgentResolver sl@0: * @param aDynamicAgentUpdate ETrue if the CAgentResolver should update its list of agents when new agents appear. A CActiveScheduler must already be running when ETrue is supplied sl@0: * @leave KErrCANoAgent If no F32 agent was found sl@0: */ sl@0: IMPORT_C static CAgentResolver* NewL(const TBool aDynamicAgentUpdate); sl@0: virtual ~CAgentResolver(); sl@0: sl@0: /** Finds the agent that handles the given supplier MIME type. sl@0: sl@0: @param aMimeType MIME type from the supplier application. sl@0: @return The CAgentInfo object associated with the agent that handles files with this MIME type. sl@0: sl@0: @leave KErrCANoAgent If no CA agent supports the given MIME type. sl@0: */ sl@0: CAgentInfo& ResolveSupplierMimeL(const TDesC8& aMimeType) const; sl@0: sl@0: /** Finds the agent that handles the given consumer MIME type. sl@0: sl@0: @note Planning to remove this from the CAF API sl@0: sl@0: @param aMimeType MIME type of the file sl@0: @return The CAgentInfo object associated with the agent that handles files with this MIME type. sl@0: */ sl@0: CAgentInfo& ResolveConsumerMime(const TDesC8& aMimeType) const; sl@0: sl@0: /** Finds the agent that handles a file. sl@0: sl@0: @param aFile Handle of the file to be resolved. sl@0: @return The CAgentInfo object associated with the agent that will handle this file. sl@0: */ sl@0: CAgentInfo& ResolveFileL(RFile& aFile) const; sl@0: sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: /** Finds the agent which handles this piece of content. sl@0: @param aHeaderData Header data of WMDRM file or stream content. sl@0: @return CAgentInfo object associated with the agent that will handle WMDRM content. sl@0: */ sl@0: CAgentInfo& ResolveFileL(const TDesC8& aHeaderData); sl@0: sl@0: #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: /** Finds the agent that handles a file and returns the actual URI of the content. sl@0: sl@0: If the aUri is of the form "c:\\private\\agent_name\\" sl@0: it will be translated to the form "c:\\private\\SID\\" in sl@0: aActualUri. Otherwise the aUri is just copied to aActualUri sl@0: sl@0: @param aUri Location of file to be resolved. sl@0: @param aActualUri The actual location of the file sl@0: @param aShareMode The file sharing mode to be used with this file sl@0: @return The CAgentInfo object associated with the agent that will handle this file. sl@0: */ sl@0: CAgentInfo& ResolveFileL(const TDesC& aUri, TDes& aActualUri, TContentShareMode aShareMode = EContentShareReadOnly) const; sl@0: sl@0: /** Find the agent who owns a directory sl@0: sl@0: This function also maps a path from the agent directory name sl@0: to it's actual name in the file system. sl@0: sl@0: ie. For example if an agent "x" has files stored in a private server directory sl@0: "c:\\private\\12345678\\" sl@0: sl@0: The file appear as "c:\\private\\x\\" to applications using CAF. This function sl@0: converts "c:\\private\\x\\" back to "c:\\private\\12345678\\" sl@0: sl@0: @param aPath The path in the form c:\\private\\agent_name\\... sl@0: @param aActualPath The path in the form c:\\private\\SID\\... sl@0: @param aThePrivateDir to ETrue if the directory is just "\\private\\" sl@0: @return The Uid of the agent who owns the directory sl@0: */ sl@0: TUid ResolveDirectory(const TDesC& aPath, TDes& aActualPath, TBool& aThePrivateDir) const; sl@0: sl@0: /** Converts a filename containing the agent SID to the filename containing the agent name. sl@0: @param aFileName The filename in the form "c:\\private\\12345678\\" sl@0: @return A buffer to the new filename in the form "c:\\private\\agent_name\\" sl@0: */ sl@0: HBufC* ConvertAgentFileNameL(const TDesC& aFileName) const; sl@0: sl@0: /** Determines the MIME types of the a file and the mime type of its contents. sl@0: sl@0: This function should only be used by the CAF recogizer DLL. sl@0: sl@0: @param aName The file name/URI to be investigated. sl@0: @param aBuffer A buffer containing bytes from the start of the file. sl@0: @param aFileMimeType If the file is recognized this will be populated with sl@0: the mime type of the file. sl@0: @param aContentMimeType If the file is recognized this will be populated with the mime type of the content object within the file. sl@0: sl@0: @return ETrue if the file is recognized by content access agent sl@0: @return EFalse if the file is not recognized by a content access agent sl@0: */ sl@0: IMPORT_C TBool DoRecognizeL(const TDesC& aName, const TDesC8& aBuffer, TDes8& aFileMimeType, TDes8& aContentMimeType); sl@0: sl@0: /** Gets the preferred buffer size for recognizing files using the RecognizeFile() function. sl@0: sl@0: This function should only be used by the CAF recogizer DLL. sl@0: sl@0: @return The largest preferred buffer nominated by any agent for recognizing files using the the DoRecognize() function. sl@0: */ sl@0: IMPORT_C TInt PreferredBufferSize(); sl@0: sl@0: /** Accessor for the SupplierMimeTypes array. sl@0: * sl@0: * @return An array of supplier MIME type supported by CAF agents. sl@0: */ sl@0: IMPORT_C const RArray& SupplierMimeTypes() const; sl@0: sl@0: /** Accessor for the ConsumerMimeTypes array. sl@0: * sl@0: * @note Planning to remove this from the CAF API sl@0: * sl@0: * @return An array of consumer MIME types supported by CAF agents. sl@0: */ sl@0: IMPORT_C const RArray& ConsumerMimeTypes() const; sl@0: sl@0: #ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: /** This function should only be used by the CAF recogizer DLL. sl@0: sl@0: @param aHeader Header data of WMDRM content. sl@0: @param aFileMimeType If the content is recognized this will be populated with sl@0: the mime type of the content. sl@0: @param aContentMimeType If the content is recognized this will be populated with the mime type of the content. sl@0: sl@0: @return ETrue if the content is recognized by content access agent sl@0: @return EFalse if the content is not recognized by a content access agent sl@0: */ sl@0: IMPORT_C TBool DoRecognizeL(const TDesC8& aHeader, TDes8& aFileMimeType, TDes8& aContentMimeType); sl@0: #endif //#ifdef SYMBIAN_ENABLE_SDP_WMDRM_SUPPORT sl@0: sl@0: /** Find an agent by it's Uid */ sl@0: CAgentInfo& AgentInfoL(const TUid& aUid) const; sl@0: sl@0: /** Find an agent by it's name */ sl@0: CAgentInfo& AgentInfoL(const TDesC& aAgentName) const; sl@0: sl@0: /** Reference an agent in the iAgentInfos array by index */ sl@0: CAgentInfo& AgentInfo(TInt aIndex) const; sl@0: sl@0: /** The number of agents, excluding the F32Agent */ sl@0: TInt AgentInfoCount() const; sl@0: sl@0: /** The default F32 agent */ sl@0: TUid DefaultAgentUid() const; sl@0: sl@0: private: sl@0: // From CActive, used for dynamically updating the list of content access agents sl@0: virtual void DoCancel(); sl@0: virtual void RunL(); sl@0: sl@0: private: sl@0: CAgentResolver(const TBool aDynamicAgentUpdate); sl@0: sl@0: /** Second phase constructor for CAgentResolver sl@0: */ sl@0: void ConstructL(); sl@0: sl@0: sl@0: /** Builds a list of all the Content Access Agents. */ sl@0: void BuildListOfAgentsL(); sl@0: sl@0: /** Add an agent to the list of agents */ sl@0: void AddAgentL(const CImplementationInformation& aImplInfo); sl@0: sl@0: /** Resets the list. */ sl@0: void DestroyListOfAgents(); sl@0: sl@0: /** Is this the F32 Agent sl@0: @param aAgentInfo The agentinfo representing the agent sl@0: @return ETrue if it is the F32Agent, EFalse otherwise sl@0: */ sl@0: TBool IsF32Agent(CAgentInfo& aAgentInfo); sl@0: sl@0: // Cleanup item sl@0: static void CleanImplArray(TAny* aArray); sl@0: sl@0: private: sl@0: const TBool iDynamicAgentUpdate; sl@0: REComSession* iEcomSession; sl@0: sl@0: RArray iSupplierMimeTypes; sl@0: RArray iConsumerMimeTypes; sl@0: sl@0: // Array of agentInfos (not including F32 agent) sl@0: RPointerArray iAgentInfos; sl@0: sl@0: // This points to the agent which handles content if it is not sl@0: // recognised by any other agent (this should be the F32Agent) sl@0: CAgentInfo* iDefaultAgent; sl@0: }; sl@0: sl@0: } // namespace ContentAccess sl@0: #endif /* __RESOLVER_H__ */ sl@0: