ReactOS 0.4.16-dev-1946-g52006dd
CDownloadManager Class Reference
Inheritance diagram for CDownloadManager:
Collaboration diagram for CDownloadManager:

Public Types

enum  { WM_ISCANCELLED = WM_APP , WM_SETSTATUS , WM_GETINSTANCE , WM_GETNEXT }
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 

Public Member Functions

 CDownloadManager ()
 
BOOL IsCancelled ()
 
BOOL IsSilentDialog ()
 
void StartWorkerThread ()
 
void Add (const DownloadInfo &Info)
 
void Show ()
 
INT_PTR RealDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
void UpdateProgress (ULONG ulProgress, ULONG ulProgressMax)
 
void PerformDownloadAndInstall (const DownloadInfo &Info)
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 

Static Public Member Functions

static CDownloadManagerCreateInstanceHelper (UINT Flags)
 
static BOOL CreateInstance (BOOL Modal, CComPtr< CDownloadManager > &Obj)
 
static CDownloadManagerFindInstance ()
 
static INT_PTR CALLBACK DlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static unsigned int CALLBACK ThreadFunc (void *ThreadParam)
 
- Static Public Member Functions inherited from ATL::CComCoClass< CDownloadManager, &CLSID_NULL >
static LPCTSTR WINAPI GetObjectDescription ()
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 

Protected Attributes

HWND m_hDlg
 
UINT m_Threads
 
UINT m_Index
 
BOOL m_bCancelled
 
BOOL m_bModal
 
UINT m_fDaf = 0
 
WCHAR m_szCaptionFmt [100]
 
ATL::CSimpleArray< DownloadInfom_List
 
CDowloadingAppsListView m_ListView
 
CDownloaderProgress m_ProgressBar
 

Additional Inherited Members

- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 469 of file loaddlg.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
WM_ISCANCELLED 
WM_SETSTATUS 
WM_GETINSTANCE 
WM_GETNEXT 

Definition at line 475 of file loaddlg.cpp.

475 {
476 WM_ISCANCELLED = WM_APP, // Return BOOL
477 WM_SETSTATUS, // wParam DownloadStatus
478 WM_GETINSTANCE, // Return CDownloadManager*
479 WM_GETNEXT, // Return DownloadInfo* or NULL
480 };
#define WM_APP
Definition: eventvwr.h:73

Constructor & Destructor Documentation

◆ CDownloadManager()

CDownloadManager::CDownloadManager ( )
inline

Definition at line 482 of file loaddlg.cpp.

#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117

Member Function Documentation

◆ Add()

void CDownloadManager::Add ( const DownloadInfo Info)

Definition at line 574 of file loaddlg.cpp.

575{
576 const UINT count = m_List.GetSize(), start = count;
577 for (UINT i = 0; i < count; ++i)
578 {
579 if (Info.Equal(m_List[i]))
580 return; // Already in the list
581 }
582 m_List.Add(Info);
583 if (m_hDlg)
585}
int GetSize() const
Definition: atlsimpcoll.h:104
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
VOID LoadList(ATL::CSimpleArray< DownloadInfo > arrInfo, UINT Start=0)
Definition: loaddlg.cpp:342
ATL::CSimpleArray< DownloadInfo > m_List
Definition: loaddlg.cpp:556
CDowloadingAppsListView m_ListView
Definition: loaddlg.cpp:557
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

◆ CreateInstance()

static BOOL CDownloadManager::CreateInstance ( BOOL  Modal,
CComPtr< CDownloadManager > &  Obj 
)
inlinestatic

Definition at line 505 of file loaddlg.cpp.

506 {
508 if (!p)
509 return FALSE;
510 Obj.Attach(p);
511 return TRUE;
512 }
static CDownloadManager * CreateInstanceHelper(UINT Flags)
Definition: loaddlg.cpp:485
#define TRUE
Definition: types.h:120
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by DownloadApplicationsDB(), and DownloadListOfApplications().

◆ CreateInstanceHelper()

static CDownloadManager * CDownloadManager::CreateInstanceHelper ( UINT  Flags)
inlinestatic

Definition at line 485 of file loaddlg.cpp.

486 {
487 if (!(Flags & DAF_MODAL))
488 {
490 if (pExisting)
491 {
492 pExisting->AddRef();
493 return pExisting;
494 }
495 }
497 if (FAILED(ShellObjectCreator(obj)))
498 return NULL;
499 obj->m_fDaf = Flags;
500 obj->m_bModal = !!(Flags & DAF_MODAL);
501 return obj.Detach();
502 }
static CDownloadManager * FindInstance()
Definition: loaddlg.cpp:515
ULONG AddRef()
#define FAILED(hr)
Definition: intsafe.h:51
@ DAF_MODAL
Definition: dialogs.h:14
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by CreateInstance().

◆ DlgProc()

INT_PTR CALLBACK CDownloadManager::DlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 604 of file loaddlg.cpp.

605{
607 if (!pThis)
608 {
609 if (uMsg != WM_INITDIALOG)
610 return FALSE;
612 pThis = (CDownloadManager*)lParam;
613 }
614 return pThis->RealDlgProc(hDlg, uMsg, wParam, lParam);
615}
INT_PTR RealDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: loaddlg.cpp:618
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define DWLP_USER
Definition: winuser.h:883
#define GetWindowLongPtrW
Definition: winuser.h:4931
#define WM_INITDIALOG
Definition: winuser.h:1767
#define SetWindowLongPtrW
Definition: winuser.h:5457

◆ FindInstance()

static CDownloadManager * CDownloadManager::FindInstance ( )
inlinestatic

Definition at line 515 of file loaddlg.cpp.

516 {
519 return NULL;
520 }
HWND g_hDownloadWnd
Definition: loaddlg.cpp:467
BOOL WINAPI IsWindowVisible(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by CreateInstanceHelper().

◆ IsCancelled()

BOOL CDownloadManager::IsCancelled ( )
inline

Definition at line 523 of file loaddlg.cpp.

524 {
526 }
BOOL WINAPI IsWindow(_In_opt_ HWND)

Referenced by PerformDownloadAndInstall().

◆ IsSilentDialog()

BOOL CDownloadManager::IsSilentDialog ( )
inline

Definition at line 529 of file loaddlg.cpp.

530 {
531 return m_fDaf & DAF_SILENT;
532 }
@ DAF_SILENT
Definition: dialogs.h:13

Referenced by RealDlgProc(), and Show().

◆ PerformDownloadAndInstall()

void CDownloadManager::PerformDownloadAndInstall ( const DownloadInfo Info)

Definition at line 739 of file loaddlg.cpp.

740{
741 const HWND hDlg = m_hDlg;
744
746 m_ProgressBar.SendMessageW(PBM_SETPOS, 0, 0);
747 m_ProgressBar.SetProgress(0, Info.SizeInBytes);
748
750 CPathW Path;
751 PCWSTR p;
752
753 ULONG dwContentLen, dwBytesWritten, dwBytesRead, dwStatus, dwStatusLen;
754 ULONG dwCurrentBytesRead = 0;
755 BOOL bTempfile = FALSE, bCancelled = FALSE;
756
757 HINTERNET hOpen = NULL;
760
761
762 LPCWSTR lpszAgent = L"RApps/1.1";
763 const DWORD dwUrlConnectFlags =
765 URL_COMPONENTSW urlComponents;
766 size_t urlLength;
767 unsigned char lpBuffer[4096];
768
769 // Change caption to show the currently downloaded app
770 switch (Info.DLType)
771 {
773 str.Format(m_szCaptionFmt, Info.szName.GetString());
774 break;
775 case DLTYPE_DBUPDATE:
777 break;
780 break;
781 }
782 SetWindowTextW(hDlg, str);
783
784 // is this URL an update package for RAPPS? if so store it in a different place
785 if (Info.DLType != DLTYPE_APPLICATION)
786 {
788 {
790 goto end;
791 }
792 }
793 else
794 {
796 }
797
798 // build the path for the download
799 p = wcsrchr(Info.szUrl.GetString(), L'/');
800
801 // do we have a final slash separator?
802 if (!p)
803 {
805 goto end;
806 }
807
808 // is the path valid? can we access it?
810 {
812 {
814 goto end;
815 }
816 }
817
818 switch (Info.DLType)
819 {
820 case DLTYPE_DBUPDATE:
823 break;
825 {
826 CStringW name = Info.szFileName;
827 if (name.IsEmpty())
828 name = p + 1; // use the filename retrieved from URL
830 Path += name;
831 break;
832 }
833 }
834
835 if ((Info.DLType == DLTYPE_APPLICATION) && Info.szSHA1[0] &&
837 {
838 // only open it in case of total correctness
839 if (VerifyInteg(Info.szSHA1.GetString(), Path))
840 goto run;
841 }
842
843 // Download it
845 /* FIXME: this should just be using the system-wide proxy settings */
846 switch (SettingsInfo.Proxy)
847 {
848 case 0: // preconfig
849 default:
850 hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
851 break;
852 case 1: // direct (no proxy)
853 hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
854 break;
855 case 2: // use proxy
856 hOpen = InternetOpenW(
858 break;
859 }
860
861 if (!hOpen)
862 {
864 goto end;
865 }
866
867 bTempfile = TRUE;
868 dwContentLen = 0;
869 dwStatusLen = sizeof(dwStatus);
870 ZeroMemory(&urlComponents, sizeof(urlComponents));
871 urlComponents.dwStructSize = sizeof(urlComponents);
872
873 urlLength = Info.szUrl.GetLength();
874 urlComponents.dwSchemeLength = urlLength + 1;
875 urlComponents.lpszScheme = (LPWSTR)malloc(urlComponents.dwSchemeLength * sizeof(WCHAR));
876
877 if (!InternetCrackUrlW(Info.szUrl, urlLength + 1, ICU_DECODE | ICU_ESCAPE, &urlComponents))
878 {
880 goto end;
881 }
882
883 if (urlComponents.nScheme == INTERNET_SCHEME_HTTP || urlComponents.nScheme == INTERNET_SCHEME_HTTPS)
884 {
885 hFile = InternetOpenUrlW(hOpen, Info.szUrl, NULL, 0, dwUrlConnectFlags, 0);
886 if (!hFile)
887 {
889 {
890 /* Workaround for CORE-17377 */
892 }
893 goto end;
894 }
895
896 // query connection
898 {
900 goto end;
901 }
902
904 {
906 goto end;
907 }
908
909 // query content length
911 }
912 else if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
913 {
914 // force passive mode on FTP
915 hFile =
916 InternetOpenUrlW(hOpen, Info.szUrl, NULL, 0, dwUrlConnectFlags | INTERNET_FLAG_PASSIVE, 0);
917 if (!hFile)
918 {
920 {
921 /* Workaround for CORE-17377 */
923 }
924 goto end;
925 }
926
927 dwContentLen = FtpGetFileSize(hFile, &dwStatus);
928 }
929 else if (urlComponents.nScheme == INTERNET_SCHEME_FILE)
930 {
931 // Add support for the file scheme so testing locally is simpler
932 WCHAR LocalFilePath[MAX_PATH];
933 DWORD cchPath = _countof(LocalFilePath);
934 // Ideally we would use PathCreateFromUrlAlloc here, but that is not exported (yet)
935 HRESULT hr = PathCreateFromUrlW(Info.szUrl, LocalFilePath, &cchPath, 0);
936 if (SUCCEEDED(hr))
937 {
938 if (CopyFileW(LocalFilePath, Path, FALSE))
939 {
940 goto run;
941 }
942 else
943 {
945 goto end;
946 }
947 }
948 else
949 {
951 goto end;
952 }
953 }
954
955 if (!dwContentLen)
956 {
957 // Someone was nice enough to add this, let's use it
958 if (Info.SizeInBytes)
959 {
960 dwContentLen = Info.SizeInBytes;
961 }
962 else
963 {
964 // content-length is not known, enable marquee mode
966 }
967 }
968
969 free(urlComponents.lpszScheme);
970
971#ifdef USE_CERT_PINNING
972 // are we using HTTPS to download the RAPPS update package? check if the certificate is original
973 if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) && (Info.DLType == DLTYPE_DBUPDATE))
974 {
975 CLocalPtr<char> subjectName, issuerName;
976 CStringA szMsgText;
977 bool bAskQuestion = false;
978 if (!CertGetSubjectAndIssuer(hFile, subjectName, issuerName))
979 {
980 szMsgText.LoadStringW(IDS_UNABLE_TO_QUERY_CERT);
981 bAskQuestion = true;
982 }
983 else if (!IsTrustedPinnedCert(subjectName, issuerName))
984 {
985 szMsgText.Format(IDS_MISMATCH_CERT_INFO, (LPCSTR)subjectName, (LPCSTR)issuerName);
986 bAskQuestion = true;
987 }
988
989 if (bAskQuestion)
990 {
991 if (MessageBoxA(hDlg, szMsgText, NULL, MB_YESNO | MB_ICONERROR) != IDYES)
992 {
993 goto end;
994 }
995 }
996 }
997#endif
998
1000 if (hOut == INVALID_HANDLE_VALUE)
1001 {
1003 goto end;
1004 }
1005
1006 dwCurrentBytesRead = 0;
1007 do
1008 {
1009 bCancelled = IsCancelled();
1010 if (bCancelled)
1011 break;
1012
1013 if (!InternetReadFile(hFile, lpBuffer, _countof(lpBuffer), &dwBytesRead))
1014 {
1016 goto end;
1017 }
1018
1019 if (!WriteFile(hOut, &lpBuffer[0], dwBytesRead, &dwBytesWritten, NULL))
1020 {
1022 goto end;
1023 }
1024
1025 dwCurrentBytesRead += dwBytesRead;
1026 UpdateProgress(dwCurrentBytesRead, dwContentLen);
1027
1028 } while (dwBytesRead);
1029
1030 CloseHandle(hOut);
1031 hOut = INVALID_HANDLE_VALUE;
1032
1033 if (bCancelled)
1034 {
1035 DPRINT1("Operation cancelled\n");
1036 goto end;
1037 }
1038
1039 if (!dwContentLen)
1040 {
1041 // set progress bar to 100%
1043
1044 dwContentLen = dwCurrentBytesRead;
1045 UpdateProgress(dwCurrentBytesRead, dwContentLen);
1046 }
1047
1048 /* if this thing isn't a RAPPS update and it has a SHA-1 checksum
1049 verify its integrity by using the native advapi32.A_SHA1 functions */
1050 if ((Info.DLType == DLTYPE_APPLICATION) && Info.szSHA1[0] != 0)
1051 {
1052 CStringW szMsgText;
1053
1054 // change a few strings in the download dialog to reflect the verification process
1055 if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_TITLE))
1056 {
1057 DPRINT1("Unable to load string\n");
1058 goto end;
1059 }
1060
1061 SetWindowTextW(hDlg, szMsgText);
1063
1064 // this may take a while, depending on the file size
1065 if (!VerifyInteg(Info.szSHA1, Path))
1066 {
1067 if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_FAIL))
1068 {
1069 DPRINT1("Unable to load string\n");
1070 goto end;
1071 }
1072
1073 MessageBoxW(hDlg, szMsgText, NULL, MB_OK | MB_ICONERROR);
1074 goto end;
1075 }
1076 }
1077
1078run:
1080
1081 // run it
1082 if (Info.DLType == DLTYPE_APPLICATION)
1083 {
1084 BOOL bSilentInstall = Info.Flags & DAF_SILENT;
1085 CStringW app, params, tempdir;
1086 SHELLEXECUTEINFOW shExInfo = { sizeof(shExInfo), SEE_MASK_NOCLOSEPROCESS, hDlg };
1087 shExInfo.lpVerb = L"open";
1088 shExInfo.lpFile = Path;
1089 shExInfo.lpParameters = L"";
1090 shExInfo.nShow = SW_SHOW;
1091
1092 if (Info.IType == INSTALLER_GENERATE)
1093 {
1094 params = L"/" CMD_KEY_GENINST + CStringW(bSilentInstall ? L" /S" : L"") +
1095 L" \"" + Info.szPackageName + L"\" \"" + shExInfo.lpFile + L"\"";
1096 shExInfo.lpParameters = params;
1097 shExInfo.lpFile = app.GetBuffer(MAX_PATH);
1098 GetModuleFileNameW(NULL, const_cast<LPWSTR>(shExInfo.lpFile), MAX_PATH);
1099 app.ReleaseBuffer();
1100 }
1101 else if (Info.IType == INSTALLER_EXEINZIP)
1102 {
1103 HRESULT hr = ExtractArchiveForExecution(Path, Info.szPackageName, tempdir, app);
1104 if (FAILED(hr))
1105 {
1106 ShowLastError(hDlg, FALSE, hr);
1107 goto end;
1108 }
1109 shExInfo.lpFile = app;
1110 }
1111
1112 if (bSilentInstall)
1113 {
1114 if (!Info.szSilentInstallArgs.IsEmpty())
1115 {
1116 // The package wants to force specific parameters
1117 shExInfo.lpParameters = Info.szSilentInstallArgs.GetString();
1118 }
1119 else
1120 {
1121 UINT extrainfo = 0;
1122 InstallerType it = Info.IExecType;
1123
1124 if (it == INSTALLER_UNKNOWN || it == INSTALLER_EXEINZIP)
1125 it = GuessInstallerType(shExInfo.lpFile, extrainfo);
1126
1127 if (GetSilentInstallParameters(it, extrainfo, shExInfo.lpFile, params))
1128 {
1129 shExInfo.lpParameters = params;
1130 if (it == INSTALLER_MSI)
1131 shExInfo.lpFile = L"msiexec.exe"; // params contains the .msi path
1132 }
1133 }
1134 }
1135
1136 /* FIXME: Do we want to log installer status? */
1137 WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_INSTALL, Info.szName);
1138
1139 if (ShellExecuteExW(&shExInfo))
1140 {
1141 // reflect installation progress in the titlebar
1142 // TODO: make a separate string with a placeholder to include app name?
1144 SetWindowTextW(hDlg, szMsgText);
1145
1147
1148 // TODO: issue an install operation separately so that the apps could be downloaded in the background
1149 if (shExInfo.hProcess)
1150 {
1152 CloseHandle(shExInfo.hProcess);
1154 }
1155 }
1156 else
1157 {
1159 }
1160
1161 if (!tempdir.IsEmpty())
1162 {
1163 DeleteDirectoryTree(tempdir, hDlg);
1164 }
1165 }
1166
1167end:
1168 if (hOut != INVALID_HANDLE_VALUE)
1169 CloseHandle(hOut);
1170
1171 if (hFile)
1173 InternetCloseHandle(hOpen);
1174
1175 if (bTempfile)
1176 {
1177 if (bCancelled || (SettingsInfo.bDelInstaller && Info.DLType == DLTYPE_APPLICATION))
1178 {
1179 // Don't delete .zip/.cab files so the user can extract from them
1180 if (bCancelled || Info.IType == INSTALLER_GENERATE || Info.IType == INSTALLER_EXEINZIP ||
1182 {
1184 }
1185 }
1186 }
1187
1189}
PRTL_UNICODE_STRING_BUFFER Path
InstallerType
Definition: appinfo.h:82
@ INSTALLER_UNKNOWN
Definition: appinfo.h:83
@ INSTALLER_EXEINZIP
Definition: appinfo.h:84
@ INSTALLER_GENERATE
Definition: appinfo.h:85
@ INSTALLER_MSI
Definition: appinfo.h:86
#define APPLICATION_DATABASE_NAME
Definition: defines.h:41
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:319
BOOL GetStorageDirectory(CStringW &lpDirectory)
Definition: misc.cpp:237
BOOL OpensWithExplorer(PCWSTR Path)
Definition: misc.cpp:162
BOOL GetSilentInstallParameters(InstallerType InstallerType, UINT ExtraInfo, LPCWSTR Installer, CStringW &Parameters)
Definition: misc.cpp:674
BOOL DeleteDirectoryTree(LPCWSTR Dir, HWND hwnd=NULL)
Definition: misc.cpp:513
UINT ClassifyFile(PCWSTR Path)
Definition: misc.cpp:125
InstallerType GuessInstallerType(LPCWSTR Installer, UINT &ExtraInfo)
Definition: misc.cpp:597
#define IDS_UNABLE_TO_DOWNLOAD
Definition: resource.h:115
#define IDS_MISMATCH_CERT_INFO
Definition: resource.h:125
#define IDS_UNABLE_TO_DOWNLOAD2
Definition: resource.h:116
#define IDS_UNABLE_PATH
Definition: resource.h:126
#define IDS_UNABLE_TO_QUERY_CERT
Definition: resource.h:117
#define IDC_DOWNLOAD_STATUS
Definition: resource.h:43
#define IDS_INTEG_CHECK_TITLE
Definition: resource.h:118
#define IDS_DL_DIALOG_DB_DOWNLOAD_DISP
Definition: resource.h:228
#define IDS_INTEG_CHECK_FAIL
Definition: resource.h:119
#define IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP
Definition: resource.h:229
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:21
#define DPRINT1
Definition: precomp.h:8
bool IsEmpty() const noexcept
Definition: atlsimpstr.h:394
void ReleaseBuffer(_In_ int nNewLength=-1)
Definition: atlsimpstr.h:387
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:818
void UpdateProgress(ULONG ulProgress, ULONG ulProgressMax)
Definition: loaddlg.cpp:717
WCHAR m_szCaptionFmt[100]
Definition: loaddlg.cpp:555
CDownloaderProgress m_ProgressBar
Definition: loaddlg.cpp:558
BOOL IsCancelled()
Definition: loaddlg.cpp:523
VOID SetMarquee(BOOL Enable)
Definition: loaddlg.cpp:183
VOID SetProgress(ULONG ulProgress, ULONG ulProgressMax)
Definition: loaddlg.cpp:194
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define CloseHandle
Definition: compat.h:739
#define wcsrchr
Definition: compat.h:16
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define MAX_PATH
Definition: compat.h:34
#define CreateFileW
Definition: compat.h:741
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
DWORD WINAPI GetModuleFileNameW(HINSTANCE hModule, LPWSTR lpFilename, DWORD nSize)
Definition: loader.c:600
HRESULT WINAPI PathCreateFromUrlW(const WCHAR *url, WCHAR *path, DWORD *pcchPath, DWORD dwReserved)
Definition: path.c:3073
DWORD WINAPI FtpGetFileSize(HINTERNET hFile, LPDWORD lpdwFileSizeHigh)
Definition: ftp.c:1757
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3870
BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwFlags, URL_COMPONENTSW *lpUC)
Definition: internet.c:1625
BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer, DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
Definition: internet.c:2154
HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl, LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3722
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1414
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:979
#define L(x)
Definition: resources.c:13
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT ExtractArchiveForExecution(PCWSTR pszArchive, const CStringW &PackageName, CStringW &TempDir, CStringW &App)
Definition: geninst.cpp:850
GLuint GLuint end
Definition: gl.h:1545
GLenum const GLfloat * params
Definition: glext.h:5645
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define HIBYTE(W)
Definition: jmemdos.c:486
static void SetFriendlyUrl(HWND hWnd, LPCWSTR pszUrl)
Definition: loaddlg.cpp:123
VOID UrlUnescapeAndMakeFileNameValid(CStringW &str)
Definition: loaddlg.cpp:107
static VOID MessageBox_LoadString(HWND hOwnerWnd, INT StringID)
Definition: loaddlg.cpp:436
@ DLSTATUS_DOWNLOADING
Definition: loaddlg.cpp:83
@ DLSTATUS_FINISHED
Definition: loaddlg.cpp:87
@ DLSTATUS_WAITING_INSTALL
Definition: loaddlg.cpp:84
@ DLSTATUS_INSTALLING
Definition: loaddlg.cpp:85
static BOOL ShowLastError(HWND hWndOwner, BOOL bInetError, DWORD dwLastError)
Definition: loaddlg.cpp:446
CStringW LoadStatusString(DownloadStatus StatusParam)
Definition: loaddlg.cpp:91
@ DLTYPE_DBUPDATE_UNOFFICIAL
Definition: loaddlg.cpp:77
@ DLTYPE_DBUPDATE
Definition: loaddlg.cpp:76
@ DLTYPE_APPLICATION
Definition: loaddlg.cpp:75
HWND hMainWnd
Definition: magnifier.c:32
#define ZeroMemory
Definition: minwinbase.h:31
LONG_PTR LPARAM
Definition: minwindef.h:175
#define CREATE_ALWAYS
Definition: disk.h:72
static BYTE subjectName[]
Definition: cert.c:35
_In_ HANDLE hFile
Definition: mswsock.h:90
CAtlStringW CStringW
Definition: atlstr.h:130
_Out_ LPWSTR lpBuffer
Definition: netsh.h:68
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define PBM_SETPOS
Definition: commctrl.h:2189
DWORD dwStatus
Definition: mediaobj.idl:95
#define WM_NOTIFY_INSTALLERFINISHED
Definition: rapps.h:20
const WCHAR * str
#define SEE_MASK_NOCLOSEPROCESS
Definition: shellapi.h:33
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2723
HRESULT hr
Definition: shlfolder.c:183
@ PERCEIVED_TYPE_COMPRESSED
Definition: shtypes.idl:177
#define _countof(array)
Definition: sndvol32.h:70
WCHAR szDownloadDir[MAX_PATH]
Definition: settings.h:10
BOOL bDelInstaller
Definition: settings.h:11
WCHAR szNoProxyFor[MAX_PATH]
Definition: settings.h:22
WCHAR szProxyServer[MAX_PATH]
Definition: settings.h:21
DWORD dwStructSize
Definition: wininet.h:211
INTERNET_SCHEME nScheme
Definition: wininet.h:214
LPWSTR lpszScheme
Definition: wininet.h:212
DWORD dwSchemeLength
Definition: wininet.h:213
LPCWSTR lpParameters
Definition: shellapi.h:339
Definition: name.c:39
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t ULONG
Definition: typedefs.h:59
#define CMD_KEY_GENINST
Definition: unattended.h:4
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
SERVICE_STATUS_HANDLE hStatus
Definition: w32time.c:14
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define HTTP_STATUS_OK
Definition: winhttp.h:240
#define INTERNET_SCHEME_FTP
Definition: winhttp.h:44
#define ICU_DECODE
Definition: winhttp.h:291
#define INTERNET_SCHEME_HTTP
Definition: winhttp.h:42
#define INTERNET_SCHEME_HTTPS
Definition: winhttp.h:43
#define ICU_ESCAPE
Definition: winhttp.h:48
#define INTERNET_FLAG_PRAGMA_NOCACHE
Definition: wininet.h:85
#define INTERNET_FLAG_DONT_CACHE
Definition: wininet.h:67
#define INTERNET_FLAG_KEEP_CONNECTION
Definition: wininet.h:72
#define INTERNET_FLAG_PASSIVE
Definition: wininet.h:65
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
#define INTERNET_OPEN_TYPE_DIRECT
Definition: wininet.h:522
@ INTERNET_SCHEME_FILE
Definition: wininet.h:143
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define HTTP_QUERY_STATUS_CODE
Definition: wininet.h:1542
#define INTERNET_OPEN_TYPE_PRECONFIG
Definition: wininet.h:521
#define HTTP_QUERY_CONTENT_LENGTH
Definition: wininet.h:1528
BOOL VerifyInteg(LPCWSTR lpSHA1Hash, LPCWSTR lpFileName)
Definition: integrity.cpp:14
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:3056
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
#define MB_YESNO
Definition: winuser.h:828
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define MB_ICONERROR
Definition: winuser.h:798
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define MB_OK
Definition: winuser.h:801
#define SW_SHOW
Definition: winuser.h:786
#define IDYES
Definition: winuser.h:846
const char * LPCSTR
Definition: xmlstorage.h:183
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by ThreadFunc().

◆ RealDlgProc()

INT_PTR CDownloadManager::RealDlgProc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 618 of file loaddlg.cpp.

619{
620 switch (uMsg)
621 {
622 case WM_INITDIALOG:
623 {
624 g_Busy++;
625 AddRef();
626 m_hDlg = hDlg;
627 if (!m_bModal)
628 g_hDownloadWnd = hDlg;
629
630 HICON hIconSm, hIconBg;
631 if (hMainWnd)
632 {
635 }
636 if (!hMainWnd || (!hIconBg || !hIconSm))
637 {
639 }
640 SendMessageW(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIconBg);
641 SendMessageW(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
642
646 buf.Replace(L"%ls", L"");
647 SetWindowTextW(hDlg, buf); // "Downloading..."
648
650 if (hItem)
651 {
652 // initialize the default values for our nifty progress bar
653 // and subclass it so that it learns to print a status text
655 m_ProgressBar.SendMessageW(PBM_SETRANGE, 0, MAKELPARAM(0, 100));
656 m_ProgressBar.SendMessageW(PBM_SETPOS, 0, 0);
657 if (m_List.GetSize() > 0)
658 m_ProgressBar.SetProgress(0, m_List[0].SizeInBytes);
659 }
660
661 if (!m_ListView.Create(hDlg))
662 return FALSE;
664
667 return TRUE;
668 }
669
670 case WM_COMMAND:
671 if (LOWORD(wParam) == IDCANCEL)
672 {
674 PostMessageW(hDlg, WM_CLOSE, 0, 0);
675 }
676 return FALSE;
677
678 case WM_CLOSE:
680 if (m_ProgressBar)
682 return m_bModal && !IsSilentDialog() ? ::EndDialog(hDlg, 0) : ::DestroyWindow(hDlg);
683
684 case WM_DESTROY:
685 if (g_hDownloadWnd == hDlg)
687 g_Busy--;
688 if (hMainWnd)
690 if (m_bModal && IsSilentDialog())
692 Release();
693 break;
694
695 case WM_ISCANCELLED:
696 return SetDlgMsgResult(hDlg, uMsg, m_bCancelled);
697
698 case WM_SETSTATUS:
700 break;
701
702 case WM_GETINSTANCE:
703 return SetDlgMsgResult(hDlg, uMsg, (INT_PTR)this);
704
705 case WM_GETNEXT:
706 {
707 DownloadInfo *pItem = NULL;
709 pItem = &m_List[m_Index++];
710 return SetDlgMsgResult(hDlg, uMsg, (INT_PTR)pItem);
711 }
712 }
713 return FALSE;
714}
#define IDI_MAIN
Definition: resource.h:4
#define IDC_DOWNLOAD_PROGRESS
Definition: resource.h:42
BOOL SubclassWindow(HWND hWnd)
Definition: atlwin.h:1552
HWND UnsubclassWindow(BOOL bForce=FALSE)
Definition: atlwin.h:1575
HWND Create(HWND hwndParent)
Definition: loaddlg.cpp:322
VOID SetDownloadStatus(INT ItemIndex, DownloadStatus Status)
Definition: loaddlg.cpp:352
BOOL IsSilentDialog()
Definition: loaddlg.cpp:529
void StartWorkerThread()
Definition: loaddlg.cpp:562
HINSTANCE hInst
Definition: dxdiag.c:13
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
ULONG Release()
DownloadStatus
Definition: loaddlg.cpp:81
static HICON
Definition: imagelist.c:80
HICON hIconSm
Definition: msconfig.c:44
#define LOWORD(l)
Definition: pedump.c:82
#define PBM_SETRANGE
Definition: commctrl.h:2188
#define WM_NOTIFY_OPERATIONCOMPLETED
Definition: rapps.h:19
LONG g_Busy
Definition: winmain.cpp:17
#define ICON_BIG
Definition: tnclass.cpp:51
#define ICON_SMALL
Definition: tnclass.cpp:48
int32_t INT_PTR
Definition: typedefs.h:64
ULONG_PTR SIZE_T
Definition: typedefs.h:80
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1382
#define SetDlgMsgResult(hwnd, msg, result)
Definition: windowsx.h:518
#define SW_HIDE
Definition: winuser.h:779
#define WM_CLOSE
Definition: winuser.h:1649
#define GCLP_HICONSM
Definition: winuser.h:683
#define MAKELPARAM(l, h)
Definition: winuser.h:4110
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDCANCEL
Definition: winuser.h:842
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GCLP_HICON
Definition: winuser.h:682
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define WM_COMMAND
Definition: winuser.h:1768
#define PostMessage
Definition: winuser.h:5943
#define GetClassLongPtrW
Definition: winuser.h:4666
#define WM_DESTROY
Definition: winuser.h:1637
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
BOOL WINAPI DestroyWindow(_In_ HWND)
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2427
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by DlgProc().

◆ Show()

void CDownloadManager::Show ( )

Definition at line 588 of file loaddlg.cpp.

589{
590 HWND hDlg = NULL;
591 const BOOL bSilent = IsSilentDialog(), bModal = m_bModal;
592 if (bModal && !bSilent)
594 else if (!m_hDlg || !IsWindow(m_hDlg))
596
597 // A DialogBox dialog cannot be invisible, it is forced visible after WM_INITDIALOG returns.
598 // We therefore use a modeless dialog when we are both modal and silent.
599 for (MSG msg; bModal && bSilent && hDlg && GetMessageW(&msg, NULL, 0, 0);)
601}
#define msg(x)
Definition: auth_time.c:54
#define IDD_DOWNLOAD_DIALOG
Definition: resource.h:66
DLGPROC DlgProc
Definition: desk.c:122
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
BOOL WINAPI GetMessageW(_Out_ LPMSG, _In_opt_ HWND, _In_ UINT, _In_ UINT)
#define DispatchMessage
Definition: winuser.h:5876
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

◆ StartWorkerThread()

void CDownloadManager::StartWorkerThread ( )

Definition at line 562 of file loaddlg.cpp.

563{
564 AddRef(); // To keep m_List alive in thread
565 unsigned int ThreadId;
566 HANDLE Thread = (HANDLE)_beginthreadex(NULL, 0, ThreadFunc, this, 0, &ThreadId);
567 if (Thread)
568 CloseHandle(Thread);
569 else
570 Release();
571}
static unsigned int CALLBACK ThreadFunc(void *ThreadParam)
Definition: loaddlg.cpp:723
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
PVOID HANDLE
Definition: typedefs.h:73

Referenced by RealDlgProc().

◆ ThreadFunc()

unsigned int CALLBACK CDownloadManager::ThreadFunc ( void ThreadParam)
static

Definition at line 723 of file loaddlg.cpp.

724{
725 CDownloadManager *pThis = (CDownloadManager*)ThreadParam;
726 HWND hDlg = pThis->m_hDlg;
727 for (;;)
728 {
729 DownloadInfo *pItem = (DownloadInfo*)SendMessageW(hDlg, WM_GETNEXT, 0, 0);
730 if (!pItem)
731 break;
732 pThis->PerformDownloadAndInstall(*pItem);
733 }
734 SendMessageW(hDlg, WM_CLOSE, 0, 0);
735 return pThis->Release();
736}
void PerformDownloadAndInstall(const DownloadInfo &Info)
Definition: loaddlg.cpp:739

Referenced by StartWorkerThread().

◆ UpdateProgress()

void CDownloadManager::UpdateProgress ( ULONG  ulProgress,
ULONG  ulProgressMax 
)

Definition at line 717 of file loaddlg.cpp.

718{
719 m_ProgressBar.SetProgress(ulProgress, ulProgressMax);
720}

Referenced by PerformDownloadAndInstall().

Member Data Documentation

◆ m_bCancelled

BOOL CDownloadManager::m_bCancelled
protected

Definition at line 552 of file loaddlg.cpp.

Referenced by RealDlgProc().

◆ m_bModal

BOOL CDownloadManager::m_bModal
protected

Definition at line 553 of file loaddlg.cpp.

Referenced by RealDlgProc(), and Show().

◆ m_fDaf

UINT CDownloadManager::m_fDaf = 0
protected

Definition at line 554 of file loaddlg.cpp.

Referenced by IsSilentDialog().

◆ m_hDlg

HWND CDownloadManager::m_hDlg
protected

Definition at line 549 of file loaddlg.cpp.

Referenced by Add(), IsCancelled(), PerformDownloadAndInstall(), RealDlgProc(), Show(), and ThreadFunc().

◆ m_Index

UINT CDownloadManager::m_Index
protected

Definition at line 551 of file loaddlg.cpp.

Referenced by RealDlgProc().

◆ m_List

ATL::CSimpleArray<DownloadInfo> CDownloadManager::m_List
protected

Definition at line 556 of file loaddlg.cpp.

Referenced by Add(), and RealDlgProc().

◆ m_ListView

CDowloadingAppsListView CDownloadManager::m_ListView
protected

Definition at line 557 of file loaddlg.cpp.

Referenced by Add(), and RealDlgProc().

◆ m_ProgressBar

CDownloaderProgress CDownloadManager::m_ProgressBar
protected

Definition at line 558 of file loaddlg.cpp.

Referenced by PerformDownloadAndInstall(), RealDlgProc(), and UpdateProgress().

◆ m_szCaptionFmt

WCHAR CDownloadManager::m_szCaptionFmt[100]
protected

Definition at line 555 of file loaddlg.cpp.

Referenced by PerformDownloadAndInstall(), and RealDlgProc().

◆ m_Threads

UINT CDownloadManager::m_Threads
protected

Definition at line 550 of file loaddlg.cpp.


The documentation for this class was generated from the following file: