smartinstaller/adm/inc/ADMPackageInfo.h
branchADM
changeset 48 364021cecc90
equal deleted inserted replaced
47:3f419852be07 48:364021cecc90
       
     1 /*
       
     2 * Copyright (c) 2009-2010 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: 
       
    15 *     Declares the various classes required to maintain the Package Info and Dependency Tree for ADM application.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef __PACKAGEINFO_H__
       
    22 #define __PACKAGEINFO_H__
       
    23 
       
    24 const TInt NOT_VISITED = 0;
       
    25 const TInt BEING_VISITED = 1;
       
    26 const TInt DONE_VISITED = 2;
       
    27 
       
    28 // Forward Declaration
       
    29 class CXmlParser;
       
    30 class CPackageInfo;
       
    31 class CADMAppUi;
       
    32 class RFileLogger;
       
    33 
       
    34 class Edge : public CBase
       
    35 {
       
    36 public:
       
    37 	static Edge* NewL(CPackageInfo *aVtx1, CPackageInfo *aVtx2);
       
    38 	static Edge* NewLC(CPackageInfo *aVtx1, CPackageInfo *aVtx2);
       
    39 	~Edge(){}
       
    40 
       
    41 	inline CPackageInfo *GetVertexOrg() const;
       
    42 	inline CPackageInfo *GetVertexDst() const;
       
    43 
       
    44 private:
       
    45 	void ConstructL();
       
    46 	Edge(CPackageInfo *aVtx1, CPackageInfo *aVtx2);
       
    47 
       
    48 private:
       
    49 	friend class CPackageInfo;
       
    50 
       
    51 	CPackageInfo *iVertexOrg;
       
    52 	CPackageInfo *iVertexDst;
       
    53 	TDblQueLink iEdgeDlink;
       
    54 };
       
    55 
       
    56 enum PackageStatus
       
    57 	{
       
    58 	EPackageStatusUnknown,
       
    59 	EPackageInstalled,
       
    60 	EPackageToBeFetched,
       
    61 	EPackageToBeUpgraded,
       
    62 	EPackageFetchedInstalled,
       
    63 	EPackageRootToBeInstalled,
       
    64 	EPackageRootInstalled
       
    65 	//EPackageToBeInstalled,
       
    66 	//EPackageInstallationFailed
       
    67 	};
       
    68 
       
    69 
       
    70 // Class for storing Depfile data
       
    71 class CPackageInfo: public CBase
       
    72 	{
       
    73 public:
       
    74 	static CPackageInfo* NewL();
       
    75 	static CPackageInfo* NewLC();
       
    76 	~CPackageInfo();
       
    77 
       
    78 	// Sort Order By Drive Priority
       
    79 	static const TLinearOrder<CPackageInfo> KSortOrderByDrivePriority;
       
    80 
       
    81 	//Comparator Function for sort by name
       
    82 	static TInt CompareByDrivePriority( const CPackageInfo& aPackageOne,const CPackageInfo& aPackageTwo );
       
    83 
       
    84 	void AddEdgeL(CPackageInfo* aDest);
       
    85 	void VisitL(CDepTree *aDepTree);
       
    86 	void SetDepFileNameL(const TDesC& aName);
       
    87 	void SetChangesFileNameL();
       
    88 	void SetSisFileNameL(const TDesC& aName);
       
    89 	HBufC8* GetDownloadUrlL();
       
    90 
       
    91 	inline HBufC8* GetURL() const
       
    92 		{
       
    93 		return iUrl;
       
    94 		};
       
    95 
       
    96 	inline HBufC* GetChangesFileName() const
       
    97 		{
       
    98 		return iChangesFileName;
       
    99 		}
       
   100 
       
   101 	inline HBufC* GetDepFileName() const
       
   102 		{
       
   103 		return iDepFileName;
       
   104 		}
       
   105 
       
   106 	inline HBufC* GetPackageName() const
       
   107 		{
       
   108 		return iPackageName;
       
   109 		};
       
   110 
       
   111 	inline HBufC* GetSisPackageName() const
       
   112 		{
       
   113 		return iSisPackageName;
       
   114 		};
       
   115 
       
   116 	inline PackageStatus GetPackageStatus() const
       
   117 		{
       
   118 		return iPackageStatus;
       
   119 		}
       
   120 
       
   121 	inline TUint32 GetPackageUid() const
       
   122 		{
       
   123 		return iPackageUid;
       
   124 		}
       
   125 
       
   126 	inline void SetPackageStatus(const PackageStatus& aStatus)
       
   127 		{
       
   128 		iPackageStatus = aStatus;
       
   129 		}
       
   130 
       
   131 	inline TUint32 GetDownloadSize() const
       
   132 		{
       
   133 		return iDownloadSize;
       
   134 		}
       
   135 
       
   136 	inline TUint32 GetInstallSize() const
       
   137 		{
       
   138 		return iInstalledSize;
       
   139 		}
       
   140 
       
   141 	inline TVersion GetPackageVersion() const
       
   142 		{
       
   143 		return iVersion;
       
   144 		}
       
   145 
       
   146 	inline TUint32 GetDrivePriority() const
       
   147 		{
       
   148 		return iDrivePriority;
       
   149 		}
       
   150 	inline void SetInstallDrive(const TChar aDrive)
       
   151 		{
       
   152 		iInstallDrive = aDrive;
       
   153 		}
       
   154 	inline TChar GetInstallDrive() const
       
   155 		{
       
   156 		return iInstallDrive;
       
   157 		}
       
   158 
       
   159 	inline TChar GetMandatoryInstallDrive() const
       
   160 		{
       
   161 		return iMandatoryInstallDrive;
       
   162 		}
       
   163 
       
   164 private:
       
   165 	void ConstructL();
       
   166 	CPackageInfo();
       
   167 
       
   168 private:
       
   169 	friend class CXmlParser;
       
   170 	friend class CDepTree;
       
   171 	friend class CSisParser;
       
   172 
       
   173 	// Mandatory fields
       
   174 	TUint32 iPackageUid;
       
   175 	TVersion iDepVersion;
       
   176 
       
   177 	// Optional Fields
       
   178 	HBufC* iPackageName;
       
   179 	HBufC* iVendor;
       
   180 	HBufC* iDateOfSubmission;//the input was a separate day,month, year format. This should've been converted into a string??
       
   181 	HBufC* iDateOfModification;//the input was a separate day,month, year format. This should've been converted into a string??
       
   182 
       
   183 	TUint32 iDownloadSize;
       
   184 	TUint32 iInstalledSize;
       
   185 
       
   186 	TVersion iVersion;
       
   187 	HBufC8* iUrl;
       
   188 	HBufC8* iDownloadUrl;
       
   189 
       
   190 	HBufC* iDepFileName;
       
   191 	//HBufC8 iDepUrl;
       
   192 
       
   193 	HBufC* iChangesFileName;
       
   194 	HBufC* iSisPackageName;
       
   195 	PackageStatus iPackageStatus;
       
   196 
       
   197 	TUint32 iDrivePriority; //priority to set as 'C' drive (for now)
       
   198 	TChar iInstallDrive; //drive in which the package needs to be installed
       
   199 	TChar iMandatoryInstallDrive; //mandatory drive specified in the changes file of the package.
       
   200 	//This is for Edges management in a package
       
   201 	TUint32 iVisited;
       
   202 
       
   203 	TDblQue<Edge>     iEdgeDlinkHdr;
       
   204 	TDblQueIter<Edge> iEdgeDlinkIter;
       
   205 
       
   206 	//This is the link for added packages connection
       
   207 	TDblQueLink iPackageDlink;
       
   208 	};
       
   209 
       
   210 
       
   211 class CDepTree: public CBase
       
   212 	{
       
   213 #ifdef USE_LOGFILE
       
   214 public:
       
   215 	static CDepTree* NewL(RFileLogger& aLogger, const TDesC& aDownloadPath);
       
   216 	static CDepTree* NewLC(RFileLogger& aLogger, const TDesC& aDownloadPath);
       
   217 private:
       
   218 	CDepTree(RFileLogger& aLogger);
       
   219 
       
   220 private:
       
   221 	RFileLogger& iLog; ///< Not owned
       
   222 #else
       
   223 
       
   224 public:
       
   225 	static CDepTree* NewL(const TDesC& aDownloadPath);
       
   226 	static CDepTree* NewLC(const TDesC& aDownloadPath);
       
   227 private:
       
   228 	CDepTree();
       
   229 #endif
       
   230 
       
   231 public:
       
   232 	~CDepTree();
       
   233 	TBool SetDriveInfo();
       
   234 	void GetDriveListL(RFs& aRFs, RArray<TChar>& aDriveLetters, RArray<TInt64>& aDriveSpaces);
       
   235 
       
   236 	void AddPackageInfo(CPackageInfo *aPackageInfo);
       
   237 	void AddFetchPackageInfo(CPackageInfo *aPackageInfo);
       
   238 	CPackageInfo* LocatePackageInDepTree(const TUint32& aDepPackageUid);
       
   239 	CPackageInfo* GetNextNode();
       
   240 	CPackageInfo* GetFetchNode( TInt nodeLocation);
       
   241 	CPackageInfo* GetNextFetchNode();
       
   242 	CPackageInfo* GetNextSortedNode();
       
   243 	CPackageInfo* GetPreviousFetchNode();
       
   244 	inline void SetMachineId(TUint32 machineId)
       
   245 		{
       
   246 		iMachineId = machineId;
       
   247 		}
       
   248 	inline TUint32 GetMachineId()
       
   249 		{
       
   250 		return iMachineId;
       
   251 		}
       
   252 	inline CPackageInfo* GetCurrentFetchNode() const
       
   253 		{
       
   254 		return iFetchList[iCurrentPackage];
       
   255 		}
       
   256 
       
   257 	inline TInt NodesCount() const
       
   258 		{
       
   259 		return iFetchList.Count();
       
   260 		}
       
   261 
       
   262 	inline TInt CountDownloadNodes() const
       
   263 		{
       
   264 		// -1 is because iSortedlist contains also the root package
       
   265 		// which is not actually downloaded
       
   266 		if (iSortedList.Count() > 0)
       
   267 			return iSortedList.Count() - 1;
       
   268 		else
       
   269 			return 0;
       
   270 		}
       
   271 
       
   272 	inline TUint32 GetTotalDownloadSize() const
       
   273 		{
       
   274 		return iTotalDownloadSize;
       
   275 		}
       
   276 
       
   277 	inline TUint32 GetMaxDownloadSize() const
       
   278 		{
       
   279 		return iMaxDownloadSize;
       
   280 		}
       
   281 
       
   282 	TBool ConstructFetchListL();
       
   283 	TBool IsDepTreeEmpty() const;
       
   284 	TBool IsCyclePresent() const;
       
   285 	TPtrC GetDownloadPath() const;
       
   286 	CPackageInfo* GetRootNode();
       
   287 	void RemoveDownloadedFiles(RFs& aRfs);
       
   288 	void DeleteFile(RFs& aRfs, const TDesC& aFileName, const TDesC& aFilePath );
       
   289 
       
   290 private:
       
   291 	void ConstructL(const TDesC& aDownloadPath);
       
   292 
       
   293 private:
       
   294 	friend class CPackageInfo;
       
   295 
       
   296 	HBufC* iDownloadPath;
       
   297 	RPointerArray<CPackageInfo> iFetchList; //Fetch list - the order in which the packages need to be fetched.
       
   298 	//Cannot sort Fetchlist, as that would collapse the fetch order.
       
   299 	RPointerArray<CPackageInfo> iSortedList; //The sorted fetch list based on drive priority
       
   300 
       
   301 	TInt iCurrentPackage;
       
   302 	TInt iSortedPackage;
       
   303 	TBool iCyclePresent;
       
   304 
       
   305 	// This is for added Packages in a Dep Tree
       
   306 	TDblQue<CPackageInfo> iPackageDlinkHdr;
       
   307 	// This is used for traversal of the tree to get the next pkg to be updated
       
   308 	TDblQueIter<CPackageInfo> iPackageDlinkFetchIter;
       
   309 	//Include the device info.
       
   310 
       
   311 	TUint32 iTotalDownloadSize;
       
   312 	TUint32 iMaxDownloadSize;
       
   313 	TUint32 iMachineId;
       
   314 	TChar iDownloadDrive; //drive in which the package needs to be downloaded
       
   315 	};
       
   316 
       
   317 #endif //__PACKAGEINFO_H__