contentstorage/casrv/cawidgetscanner/inc/cawidgetscannerparser.h
changeset 103 b99b84bcd2d1
parent 73 4bc7b118b3df
child 104 9b022b1f357c
--- a/contentstorage/casrv/cawidgetscanner/inc/cawidgetscannerparser.h	Fri Jun 11 13:58:37 2010 +0300
+++ b/contentstorage/casrv/cawidgetscanner/inc/cawidgetscannerparser.h	Wed Jun 23 18:33:40 2010 +0300
@@ -21,17 +21,19 @@
 
 //  INCLUDES
 #include <e32base.h>
-#include <xmlengdomimplementation.h>
-#include <xmlengelement.h>
+#include <xml/dom/xmlengdomimplementation.h>
 #include <badesca.h>
 #include <f32file.h>
 #include "cawidgetdescription.h"
+#include "castorage_global.h"
 
 // CONSTANTS
 
 // FORWARD DECLARATIONS
+
 class CDir;
-
+CA_STORAGE_TEST_CLASS( T_CaWidgetScanner )
+class TXmlEngElement;
 /**
  *  Widget Parser
  *
@@ -58,124 +60,8 @@
      * WidgetsL
      * @return array containing widgets description
      */
-    RWidgetArray& WidgetsScanL( );
-
-private:
-
-    /**
-     * Looks for manifests on a drive
-     * @param aDriveLetter drive letter
-     */
-    void ScanOnDriveL( );
-
-    /**
-     * Parses all manifest files in a directory
-     * @param aDriveLetter drive letter
-     * @param aDirectoryName directory name
-     */
-    void ParseDirectoryL( const TDesC& aDirectoryName );
-
-    /**
-    * Parse manifest file
-    * @param aFilePath full file path to manifest file
-    * @param aPackageUid descriptor containing package uid
-    */
-    void ParseManifestFileL( const TDesC& aFilePath,
-        const TDesC& aPackageUid);
-
-    /**
-    * Parse a widget, store parsed object in an internal array
-    * @param aFilePath full file path to manifest file
-    * @param aElement widget element
-    * @param aPackageUid descriptor containing package uid
-    */
-    void ParseWidgetL( const TDesC& aFilePath,
-            TXmlEngElement aElement, const TDesC& aPackageUid );
-
-    /**
-     * Gets all directories from import folder
-     * @param aDriveLetter drive letter
-     * @return directories
-     */
-    CDir* GetDirectoriesLC( );
-
-    /**
-     * Returns import path
-     * @param aDriveLetter drive letter
-     * @return import path
-     */
-    HBufC* FullPathLC( );
-
-    /**
-     * Returns manifest directory path
-     * @param aDriveLetter drive letter
-     * @param aDirectoryName directory name
-     * @return manifest directory path
-     */
-    HBufC* GetManifestDirectoryPathLC( const TDesC& aDirectoryName );
-
-    /**
-     * Sets widgets URI
-     * @param aElement xml element
-     * @param aWidget widget to set value
-     */
-    void SetUriL( TXmlEngElement & aElement, CCaWidgetDescription * aWidget );
-
-    /**
-     * Sets widgets library and path created from library
-     * @param aElement xml element
-     * @param aPackageUid package uid
-     * @param aWidget widget to set value
-     */
-    void SetLibraryL( TXmlEngElement & aElement, const TDesC & aPackageUid,
-            CCaWidgetDescription * aWidget );
-
-    /**
-     * Sets widgets title
-     * @param aElement xml element
-     * @param aWidget widget to set value
-     */
-    void SetTitleL( TXmlEngElement & aElement, 
-            CCaWidgetDescription * aWidget );
-
-    /**
-     * Sets widgets description
-     * @param aElement xml element
-     * @param aWidget widget to set value
-     */
-    void SetDescriptionL( TXmlEngElement & aElement,
-            CCaWidgetDescription * aWidget );
-
-    /**
-     * Sets widgets visibility
-     * @param aElement xml element
-     * @param aWidget widget to set value
-     */
-    void SetVisibilityL( TXmlEngElement & aElement,
-            CCaWidgetDescription * aWidget );
-
-    /**
-     * Sets icons URI
-     * @param aElement xml element
-     * @param aPackageUid package uid
-     * @param aWidget widget to set value
-     */
-    void SetIconUriL( TXmlEngElement & aElement, const TDesC & aPackageUid,
-            CCaWidgetDescription * aWidget );
-
-    /**
-     * Sets widgets mmc id
-     * @param aWidget widget to set value
-     */
-    void SetMmcIdL( CCaWidgetDescription * aWidget );
+    RWidgetArray& WidgetsScanL( const RWidgetArray& aWidgets  );
     
-    void ParseUriL(TXmlEngElement & aElement);
-    void ParseTitleL(TXmlEngElement & aElement);
-    void ParseIconL(TXmlEngElement & aElement,  const TDesC & aPackageUid);
-    void ParseDescriptionL(TXmlEngElement & aElement);
-    void ParseHiddenL(TXmlEngElement & aElement);
-    void ParseServiceXmlL(TXmlEngElement & aElement);
-
 private:
 
     /**
@@ -188,13 +74,162 @@
      */
     void ConstructL( );
 
-private:
-    // Data
+
+    /**
+     * Looks for manifests on a drive
+     * @param aDrive drive to use
+     */
+    void ScanOnDriveL( TChar& aDrive );
+
+    /**
+     * Parses all manifest files in a directory
+     * @param aDirectoryName directory name
+     * @param aDrive drive to use
+     */
+    void ParseDirectoryL( const TDesC& aDirectoryName, TChar& aDrive );
+
+    /**
+    * Parse manifest file
+    * @param aFilePath full file path to manifest file
+    * @param aPackageUid descriptor containing package uid
+    * @param aDrive drive to use
+    */
+    void ParseManifestFileL( const TDesC& aFilePath,
+        const TDesC& aPackageUid, TChar& aDrive );
+
+    /**
+    * Parse a widget, store parsed object in an internal array
+    * @param aFilePath full file path to manifest file
+    * @param aElement widget element
+    * @param aPackageUid descriptor containing package uid
+    * @param aDrive drive to use
+    */
+    void ParseWidgetL( const TDesC& aFilePath,
+            TXmlEngElement& aElement, const TDesC& aPackageUid,
+            TChar& aDrive );
+
+    /**
+     * Gets all directories from import folder
+     * @param aDriveLetter drive letter
+     * @return directories
+     */
+    CDir* GetDirectoriesLC( TChar& aDrive );
+
+    /**
+     * Returns import path
+     * @param aDriveLetter drive letter
+     * @return import path
+     */
+    HBufC* FullPathLC( TChar& aDrive ) const;
+
+    /**
+     * Returns manifest directory path
+     * @param aDriveLetter drive letter
+     * @param aDirectoryName directory name
+     * @param aDrive drive to use
+     * @return manifest directory path
+     */
+    HBufC* GetManifestDirectoryPathLC( const TDesC& aDirectoryName, TChar& aDrive ) const;
+
+    /**
+     * Sets widgets URI
+     * @param aElement xml element
+     * @param aWidget widget to set value
+     */
+    void SetUriL( TXmlEngElement& aElement, CCaWidgetDescription* aWidget );
+
+    /**
+     * Sets widgets library and path created from library
+     * @param aElement xml element
+     * @param aPackageUid package uid
+     * @param aWidget widget to set value
+     */
+    void SetLibraryL( TXmlEngElement& aElement, const TDesC& aPackageUid,
+            CCaWidgetDescription* aWidget, TChar& aDrive );
 
-    /*
-     * Stores current drive letter
+    /**
+     * Sets widgets title
+     * @param aElement xml element
+     * @param aWidget widget to set value
+     */
+    void SetTitleL( TXmlEngElement& aElement, 
+            CCaWidgetDescription* aWidget );
+
+    /**
+     * Sets widgets description
+     * @param aElement xml element
+     * @param aWidget widget to set value
+     */
+    void SetDescriptionL( TXmlEngElement& aElement,
+            CCaWidgetDescription* aWidget );
+
+    /**
+     * Sets widgets visibility
+     * @param aElement xml element
+     * @param aWidget widget to set value
+     */
+    void SetVisibilityL( TXmlEngElement& aElement,
+            CCaWidgetDescription* aWidget );
+
+    /**
+     * Sets icons URI
+     * @param aElement xml element
+     * @param aPackageUid package uid
+     * @param aWidget widget to set value
+     */
+    void SetIconUriL( TXmlEngElement& aElement, const TDesC& aPackageUid,
+            CCaWidgetDescription* aWidget, TChar& aDrive );
+
+    /**
+     * Sets widgets mmc id
+     * @param aWidget widget to set value
      */
-    TChar iCurrentDriveLetter;
+    void SetMmcIdL( CCaWidgetDescription* aWidget, TChar& aDrive );
+    
+    void ParseUriL( TXmlEngElement& aElement,
+            CCaWidgetDescription* aWidgetDescriptor );
+    void ParseTitleL( TXmlEngElement& aElement,
+            CCaWidgetDescription* aWidgetDescriptor );
+    void ParseIconL( TXmlEngElement& aElement,  const TDesC& aPackageUid,
+            CCaWidgetDescription* aWidgetDescriptor, TChar& aDrive );
+    void ParseDescriptionL( TXmlEngElement& aElement,
+            CCaWidgetDescription* aWidgetDescriptor );
+    void ParseHiddenL( TXmlEngElement& aElement,
+            CCaWidgetDescription* aWidgetDescriptor );
+    void ParseServiceXmlL(TXmlEngElement & aElement,
+            CCaWidgetDescription* aWidgetDescriptor );
+    void SetModificationTimeL( const TDesC& aFilePath,
+            CCaWidgetDescription* aWidgetDescriptor );
+    
+    void ParsePreviewImageNameL( TXmlEngElement& aElement, 
+        const TDesC& aPackageUid,
+        CCaWidgetDescription* aWidgetDescriptor,
+        TChar& aDrive );
+
+    /**
+     * @param aElement xml document element.
+     * @return created descriptor with element's text value. Ownership
+     * of the descriptor is passed to the caller.
+     */
+    HBufC *CCaWidgetScannerParser::GetElementTextLC( 
+        const TXmlEngElement& aElement ) const;
+    
+    /**
+     * Parses graphics name value and if the name has a file extension
+     * adds widget root directory path to it.
+     * @param aElement xml document element.
+     * @return created descriptor with graphics name value. Ownership
+     * of the descriptor is passed to the caller.
+     */
+    HBufC* GetThemableGraphicsNameLC(
+            const TXmlEngElement & aElement,
+            const TDesC & aPackageUid,
+            TChar& aDrive ) const;
+
+
+
+private:
+    // Data  
 
     /*
      * File server session.Not Own
@@ -210,13 +245,19 @@
      * Widgets. Own.
      */
     RWidgetArray iWidgets;
+    
+    /*
+     * Widgets. Not own.
+     */
+    RWidgetArray iFetchedWidgets; 
     /*
      * Own.
      */
     RXmlEngDOMImplementation iDomImpl;
     
-    CCaWidgetDescription* iWidgetDescriptor;
-
+    
+    CA_STORAGE_TEST_FRIEND_CLASS( T_CaWidgetScanner )
+    
     };
 
 #endif      // C_WIDGETSCANNERPARSER_H