1 #pragma once 2 3 #include <atlstr.h> 4 #include <atlpath.h> 5 #include <atlsimpcoll.h> 6 7 8 enum LicenseType 9 { 10 LICENSE_NONE, 11 LICENSE_OPENSOURCE = 1, 12 LICENSE_FREEWARE = 2, 13 LICENSE_TRIAL = 3, 14 LICENSE_MIN = LICENSE_NONE, 15 LICENSE_MAX = LICENSE_TRIAL 16 }; 17 18 inline BOOL 19 IsKnownLicenseType(INT x) 20 { 21 return (x > LICENSE_NONE && x <= LICENSE_MAX); 22 } 23 24 enum AppsCategories 25 { 26 ENUM_ALL_AVAILABLE, 27 ENUM_CAT_AUDIO, 28 ENUM_CAT_VIDEO, 29 ENUM_CAT_GRAPHICS, 30 ENUM_CAT_GAMES, 31 ENUM_CAT_INTERNET, 32 ENUM_CAT_OFFICE, 33 ENUM_CAT_DEVEL, 34 ENUM_CAT_EDU, 35 ENUM_CAT_ENGINEER, 36 ENUM_CAT_FINANCE, 37 ENUM_CAT_SCIENCE, 38 ENUM_CAT_TOOLS, 39 ENUM_CAT_DRIVERS, 40 ENUM_CAT_LIBS, 41 ENUM_CAT_THEMES, 42 ENUM_CAT_OTHER, 43 ENUM_CAT_SELECTED, 44 ENUM_ALL_INSTALLED = 30, 45 ENUM_INSTALLED_APPLICATIONS, 46 ENUM_UPDATES, 47 ENUM_INVALID, 48 ENUM_INSTALLED_MIN = ENUM_ALL_INSTALLED, 49 ENUM_INSTALLED_MAX = ENUM_UPDATES, 50 ENUM_AVAILABLE_MIN = ENUM_ALL_AVAILABLE, 51 ENUM_AVAILABLE_MAX = ENUM_CAT_SELECTED, 52 }; 53 54 inline BOOL 55 IsAvailableEnum(INT x) 56 { 57 return (x >= ENUM_AVAILABLE_MIN && x <= ENUM_AVAILABLE_MAX); 58 } 59 60 inline BOOL 61 IsInstalledEnum(INT x) 62 { 63 return (x >= ENUM_INSTALLED_MIN && x <= ENUM_INSTALLED_MAX); 64 } 65 66 class CAppRichEdit; 67 68 class CAppInfo 69 { 70 public: 71 CAppInfo(const CStringW &Identifier, AppsCategories Category); 72 virtual ~CAppInfo(); 73 74 const CStringW szIdentifier; // PkgName or KeyName 75 const AppsCategories iCategory; 76 77 CStringW szDisplayIcon; 78 CStringW szDisplayName; 79 CStringW szDisplayVersion; 80 CStringW szComments; 81 82 virtual BOOL 83 Valid() const = 0; 84 virtual BOOL 85 CanModify() = 0; 86 virtual BOOL 87 RetrieveIcon(CStringW &Path) const = 0; 88 virtual BOOL 89 RetrieveScreenshot(CStringW &Path) = 0; 90 virtual VOID 91 ShowAppInfo(CAppRichEdit *RichEdit) = 0; 92 virtual VOID 93 GetDownloadInfo(CStringW &Url, CStringW &Sha1, ULONG &SizeInBytes) const = 0; 94 virtual VOID 95 GetDisplayInfo(CStringW &License, CStringW &Size, CStringW &UrlSite, CStringW &UrlDownload) = 0; 96 virtual BOOL 97 UninstallApplication(BOOL bModify) = 0; 98 }; 99 100 class CAvailableApplicationInfo : public CAppInfo 101 { 102 class CConfigParser *m_Parser; 103 CSimpleArray<CStringW> m_szScrnshotLocation; 104 bool m_ScrnshotRetrieved; 105 CStringW m_szUrlDownload; 106 CStringW m_szSize; 107 CStringW m_szUrlSite; 108 CSimpleArray<LCID> m_LanguageLCIDs; 109 bool m_LanguagesLoaded; 110 111 VOID 112 InsertVersionInfo(CAppRichEdit *RichEdit); 113 VOID 114 InsertLanguageInfo(CAppRichEdit *RichEdit); 115 VOID 116 RetrieveLanguages(); 117 CStringW 118 LicenseString(); 119 120 public: 121 CAvailableApplicationInfo( 122 CConfigParser *Parser, 123 const CStringW &PkgName, 124 AppsCategories Category, 125 const CPathW &BasePath); 126 ~CAvailableApplicationInfo(); 127 128 virtual BOOL 129 Valid() const override; 130 virtual BOOL 131 CanModify() override; 132 virtual BOOL 133 RetrieveIcon(CStringW &Path) const override; 134 virtual BOOL 135 RetrieveScreenshot(CStringW &Path) override; 136 virtual VOID 137 ShowAppInfo(CAppRichEdit *RichEdit) override; 138 virtual VOID 139 GetDownloadInfo(CStringW &Url, CStringW &Sha1, ULONG &SizeInBytes) const override; 140 virtual VOID 141 GetDisplayInfo(CStringW &License, CStringW &Size, CStringW &UrlSite, CStringW &UrlDownload) override; 142 virtual BOOL 143 UninstallApplication(BOOL bModify) override; 144 }; 145 146 class CInstalledApplicationInfo : public CAppInfo 147 { 148 CRegKey m_hKey; 149 CStringW m_szInstallDate; 150 CStringW m_szUninstallString; 151 CStringW m_szModifyString; 152 153 BOOL 154 GetApplicationRegString(LPCWSTR lpKeyName, CStringW &String); 155 BOOL 156 GetApplicationRegDword(LPCWSTR lpKeyName, DWORD *lpValue); 157 VOID 158 AddApplicationRegString(CAppRichEdit *RichEdit, UINT StringID, const CStringW &String, DWORD TextFlags); 159 160 VOID 161 RetrieveInstallDate(); 162 VOID 163 RetrieveUninstallStrings(); 164 165 public: 166 const int iKeyIndex; 167 CInstalledApplicationInfo(HKEY Key, const CStringW &KeyName, AppsCategories Category, int KeyIndex); 168 ~CInstalledApplicationInfo(); 169 170 virtual BOOL 171 Valid() const override; 172 virtual BOOL 173 CanModify() override; 174 virtual BOOL 175 RetrieveIcon(CStringW &Path) const override; 176 virtual BOOL 177 RetrieveScreenshot(CStringW &Path) override; 178 virtual VOID 179 ShowAppInfo(CAppRichEdit *RichEdit) override; 180 virtual VOID 181 GetDownloadInfo(CStringW &Url, CStringW &Sha1, ULONG &SizeInBytes) const override; 182 virtual VOID 183 GetDisplayInfo(CStringW &License, CStringW &Size, CStringW &UrlSite, CStringW &UrlDownload) override; 184 virtual BOOL 185 UninstallApplication(BOOL bModify) override; 186 }; 187