reactos/base/applications/rapps/include/available.h
He Yang 10c0ff7416
[RAPPS] listview refactor (#2970)
This makes it easier to maintain the listview, and better separates the application list and listview.

* [RAPPS] fix memory leak when cleanup. some renaming are also done
* [RAPPS] move the code adding apps info inside class CAppsListView
* [RAPPS] add table view, create listview and AppInfoDisplay inside it
* [RAPPS] rename INSTALLED_INFO as CInstalledApplicationInfo
now it corresponds with CAvailableApplicationInfo
* [RAPPS] add CInstalledApps
* [RAPPS] optimize the speed when refreshing listview
* [RAPPS] correctly handle Enum for InstalledApps
* [RAPPS] make check all working properly (this also fixes some bugs)
the old version has some bugs when check all items after switching tags in tree-view
* [RAPPS] add handling for wow64
* [RAPPS] use an inline function to replace INSERT_TEXT macro
* [RAPPS] fix the bug that StatusBar won't update when switching tags
* [RAPPS] now TableView always reset bIsAscending in SetDisplayMode
* [RAPPS] rename TableView to ApplicationView
* [RAPPS] now bIsAscending would be reset when switching column in listview
2020-09-06 17:09:20 +02:00

135 lines
3.6 KiB
C++

#pragma once
#include <windef.h>
#include <atlstr.h>
#include <atlsimpcoll.h>
#include <atlcoll.h>
#include "misc.h"
#define MAX_SCRNSHOT_NUM 16
enum LicenseType
{
LICENSE_NONE,
LICENSE_OPENSOURCE,
LICENSE_FREEWARE,
LICENSE_TRIAL,
LICENSE_MIN = LICENSE_NONE,
LICENSE_MAX = LICENSE_TRIAL
};
inline BOOL IsLicenseType(INT x)
{
return (x >= LICENSE_MIN && x <= LICENSE_MAX);
}
struct AvailableStrings
{
ATL::CStringW szPath;
ATL::CStringW szCabPath;
ATL::CStringW szAppsPath;
ATL::CStringW szSearchPath;
ATL::CStringW szCabName;
ATL::CStringW szCabDir;
AvailableStrings();
};
class CAvailableApplicationInfo
{
public:
INT m_Category;
//BOOL m_IsSelected;
LicenseType m_LicenseType;
ATL::CStringW m_szName;
ATL::CStringW m_szRegName;
ATL::CStringW m_szVersion;
ATL::CStringW m_szLicense;
ATL::CStringW m_szDesc;
ATL::CStringW m_szSize;
ATL::CStringW m_szUrlSite;
ATL::CStringW m_szUrlDownload;
ATL::CSimpleArray<LCID> m_LanguageLCIDs;
ATL::CSimpleArray<ATL::CStringW> m_szScrnshotLocation;
ATL::CStringW m_szIconLocation;
ULONG m_SizeBytes;
// Caching mechanism related entries
ATL::CStringW m_sFileName;
FILETIME m_ftCacheStamp;
// Optional integrity checks (SHA-1 digests are 160 bit = 40 characters in hex string form)
ATL::CStringW m_szSHA1;
ATL::CStringW m_szInstalledVersion;
// Create an object from file
CAvailableApplicationInfo(const ATL::CStringW& sFileNameParam, AvailableStrings& m_Strings);
// Load all info from the file
VOID RefreshAppInfo(AvailableStrings& m_Strings);
BOOL HasLanguageInfo() const;
BOOL HasNativeLanguage() const;
BOOL HasEnglishLanguage() const;
BOOL IsInstalled() const;
BOOL HasInstalledVersion() const;
BOOL HasUpdate() const;
BOOL RetrieveScrnshot(UINT Index, ATL::CStringW& ScrnshotLocation) const;
BOOL RetrieveIcon(ATL::CStringW& IconLocation) const;
// Set a timestamp
VOID SetLastWriteTime(FILETIME* ftTime);
private:
BOOL m_IsInstalled;
BOOL m_HasLanguageInfo;
BOOL m_HasInstalledVersion;
CConfigParser* m_Parser;
inline BOOL GetString(LPCWSTR lpKeyName, ATL::CStringW& ReturnedString);
// Lazily load general info from the file
VOID RetrieveGeneralInfo(AvailableStrings& m_Strings);
VOID RetrieveInstalledStatus();
VOID RetrieveInstalledVersion();
VOID RetrieveLanguages();
VOID RetrieveLicenseType();
VOID RetrieveSize();
inline BOOL FindInLanguages(LCID what) const;
};
typedef BOOL(CALLBACK *AVAILENUMPROC)(CAvailableApplicationInfo *Info, BOOL bInitialCheckState, PVOID param);
class CAvailableApps
{
ATL::CAtlList<CAvailableApplicationInfo*> m_InfoList;
ATL::CAtlList< CAvailableApplicationInfo*> m_SelectedList;
public:
static AvailableStrings m_Strings;
CAvailableApps();
static BOOL UpdateAppsDB();
static BOOL ForceUpdateAppsDB();
static VOID DeleteCurrentAppsDB();
VOID FreeCachedEntries();
BOOL Enum(INT EnumType, AVAILENUMPROC lpEnumProc, PVOID param);
BOOL AddSelected(CAvailableApplicationInfo *AvlbInfo);
BOOL RemoveSelected(CAvailableApplicationInfo *AvlbInfo);
VOID RemoveAllSelected();
int GetSelectedCount();
CAvailableApplicationInfo* FindInfo(const ATL::CStringW& szAppName) const;
ATL::CSimpleArray<CAvailableApplicationInfo> FindInfoList(const ATL::CSimpleArray<ATL::CStringW> &arrAppsNames) const;
//ATL::CSimpleArray<CAvailableApplicationInfo> GetSelected() const;
const ATL::CStringW& GetFolderPath() const;
const ATL::CStringW& GetAppPath() const;
const ATL::CStringW& GetCabPath() const;
};