ReactOS 0.4.16-dev-736-g28b802b
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 ()
 
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 (BOOL Modal)
 
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
 
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 463 of file loaddlg.cpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
WM_ISCANCELLED 
WM_SETSTATUS 
WM_GETINSTANCE 
WM_GETNEXT 

Definition at line 469 of file loaddlg.cpp.

469 {
470 WM_ISCANCELLED = WM_APP, // Return BOOL
471 WM_SETSTATUS, // wParam DownloadStatus
472 WM_GETINSTANCE, // Return CDownloadManager*
473 WM_GETNEXT, // Return DownloadInfo* or NULL
474 };
#define WM_APP
Definition: eventvwr.h:73

Constructor & Destructor Documentation

◆ CDownloadManager()

CDownloadManager::CDownloadManager ( )
inline

Definition at line 476 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 560 of file loaddlg.cpp.

561{
562 const UINT count = m_List.GetSize(), start = count;
563 for (UINT i = 0; i < count; ++i)
564 {
565 if (Info.Equal(m_List[i]))
566 return; // Already in the list
567 }
568 m_List.Add(Info);
569 if (m_hDlg)
571}
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:336
ATL::CSimpleArray< DownloadInfo > m_List
Definition: loaddlg.cpp:542
CDowloadingAppsListView m_ListView
Definition: loaddlg.cpp:543
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 498 of file loaddlg.cpp.

499 {
501 if (!p)
502 return FALSE;
503 Obj.Attach(p);
504 return TRUE;
505 }
static CDownloadManager * CreateInstanceHelper(BOOL Modal)
Definition: loaddlg.cpp:479
#define TRUE
Definition: types.h:120
GLfloat GLfloat p
Definition: glext.h:8902

Referenced by DownloadApplicationsDB(), and DownloadListOfApplications().

◆ CreateInstanceHelper()

static CDownloadManager * CDownloadManager::CreateInstanceHelper ( BOOL  Modal)
inlinestatic

Definition at line 479 of file loaddlg.cpp.

480 {
481 if (!Modal)
482 {
484 if (pExisting)
485 {
486 pExisting->AddRef();
487 return pExisting;
488 }
489 }
491 if (FAILED(ShellObjectCreator(obj)))
492 return NULL;
493 obj->m_bModal = Modal;
494 return obj.Detach();
495 }
static CDownloadManager * FindInstance()
Definition: loaddlg.cpp:508
ULONG AddRef()
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by CreateInstance().

◆ DlgProc()

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

Definition at line 583 of file loaddlg.cpp.

584{
586 if (!pThis)
587 {
588 if (uMsg != WM_INITDIALOG)
589 return FALSE;
591 pThis = (CDownloadManager*)lParam;
592 }
593 return pThis->RealDlgProc(hDlg, uMsg, wParam, lParam);
594}
INT_PTR RealDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: loaddlg.cpp:597
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define DWLP_USER
Definition: winuser.h:875
#define GetWindowLongPtrW
Definition: winuser.h:4832
#define WM_INITDIALOG
Definition: winuser.h:1742
#define SetWindowLongPtrW
Definition: winuser.h:5358

◆ FindInstance()

static CDownloadManager * CDownloadManager::FindInstance ( )
inlinestatic

Definition at line 508 of file loaddlg.cpp.

509 {
510 if (g_hDownloadWnd)
512 return NULL;
513 }
HWND g_hDownloadWnd
Definition: loaddlg.cpp:461
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by CreateInstanceHelper().

◆ IsCancelled()

BOOL CDownloadManager::IsCancelled ( )
inline

Definition at line 516 of file loaddlg.cpp.

517 {
519 }
BOOL WINAPI IsWindow(_In_opt_ HWND)

Referenced by PerformDownloadAndInstall().

◆ PerformDownloadAndInstall()

void CDownloadManager::PerformDownloadAndInstall ( const DownloadInfo Info)

Definition at line 716 of file loaddlg.cpp.

717{
718 const HWND hDlg = m_hDlg;
721
723 m_ProgressBar.SendMessageW(PBM_SETPOS, 0, 0);
724 m_ProgressBar.SetProgress(0, Info.SizeInBytes);
725
727 CPathW Path;
728 PCWSTR p;
729
730 ULONG dwContentLen, dwBytesWritten, dwBytesRead, dwStatus, dwStatusLen;
731 ULONG dwCurrentBytesRead = 0;
732 BOOL bTempfile = FALSE, bCancelled = FALSE;
733
734 HINTERNET hOpen = NULL;
737
738
739 LPCWSTR lpszAgent = L"RApps/1.1";
740 const DWORD dwUrlConnectFlags =
742 URL_COMPONENTSW urlComponents;
743 size_t urlLength;
744 unsigned char lpBuffer[4096];
745
746 // Change caption to show the currently downloaded app
747 switch (Info.DLType)
748 {
750 str.Format(m_szCaptionFmt, Info.szName.GetString());
751 break;
752 case DLTYPE_DBUPDATE:
754 break;
757 break;
758 }
759 SetWindowTextW(hDlg, str);
760
761 // is this URL an update package for RAPPS? if so store it in a different place
762 if (Info.DLType != DLTYPE_APPLICATION)
763 {
765 {
767 goto end;
768 }
769 }
770 else
771 {
773 }
774
775 // build the path for the download
776 p = wcsrchr(Info.szUrl.GetString(), L'/');
777
778 // do we have a final slash separator?
779 if (!p)
780 {
782 goto end;
783 }
784
785 // is the path valid? can we access it?
787 {
789 {
791 goto end;
792 }
793 }
794
795 switch (Info.DLType)
796 {
797 case DLTYPE_DBUPDATE:
800 break;
802 {
803 CStringW name = Info.szFileName;
804 if (name.IsEmpty())
805 name = p + 1; // use the filename retrieved from URL
807 Path += name;
808 break;
809 }
810 }
811
812 if ((Info.DLType == DLTYPE_APPLICATION) && Info.szSHA1[0] &&
814 {
815 // only open it in case of total correctness
816 if (VerifyInteg(Info.szSHA1.GetString(), Path))
817 goto run;
818 }
819
820 // Download it
822 /* FIXME: this should just be using the system-wide proxy settings */
823 switch (SettingsInfo.Proxy)
824 {
825 case 0: // preconfig
826 default:
827 hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
828 break;
829 case 1: // direct (no proxy)
830 hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
831 break;
832 case 2: // use proxy
833 hOpen = InternetOpenW(
835 break;
836 }
837
838 if (!hOpen)
839 {
841 goto end;
842 }
843
844 bTempfile = TRUE;
845 dwContentLen = 0;
846 dwStatusLen = sizeof(dwStatus);
847 ZeroMemory(&urlComponents, sizeof(urlComponents));
848 urlComponents.dwStructSize = sizeof(urlComponents);
849
850 urlLength = Info.szUrl.GetLength();
851 urlComponents.dwSchemeLength = urlLength + 1;
852 urlComponents.lpszScheme = (LPWSTR)malloc(urlComponents.dwSchemeLength * sizeof(WCHAR));
853
854 if (!InternetCrackUrlW(Info.szUrl, urlLength + 1, ICU_DECODE | ICU_ESCAPE, &urlComponents))
855 {
857 goto end;
858 }
859
860 if (urlComponents.nScheme == INTERNET_SCHEME_HTTP || urlComponents.nScheme == INTERNET_SCHEME_HTTPS)
861 {
862 hFile = InternetOpenUrlW(hOpen, Info.szUrl, NULL, 0, dwUrlConnectFlags, 0);
863 if (!hFile)
864 {
866 {
867 /* Workaround for CORE-17377 */
869 }
870 goto end;
871 }
872
873 // query connection
875 {
877 goto end;
878 }
879
881 {
883 goto end;
884 }
885
886 // query content length
888 }
889 else if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
890 {
891 // force passive mode on FTP
892 hFile =
893 InternetOpenUrlW(hOpen, Info.szUrl, NULL, 0, dwUrlConnectFlags | INTERNET_FLAG_PASSIVE, 0);
894 if (!hFile)
895 {
897 {
898 /* Workaround for CORE-17377 */
900 }
901 goto end;
902 }
903
904 dwContentLen = FtpGetFileSize(hFile, &dwStatus);
905 }
906 else if (urlComponents.nScheme == INTERNET_SCHEME_FILE)
907 {
908 // Add support for the file scheme so testing locally is simpler
909 WCHAR LocalFilePath[MAX_PATH];
910 DWORD cchPath = _countof(LocalFilePath);
911 // Ideally we would use PathCreateFromUrlAlloc here, but that is not exported (yet)
912 HRESULT hr = PathCreateFromUrlW(Info.szUrl, LocalFilePath, &cchPath, 0);
913 if (SUCCEEDED(hr))
914 {
915 if (CopyFileW(LocalFilePath, Path, FALSE))
916 {
917 goto run;
918 }
919 else
920 {
922 goto end;
923 }
924 }
925 else
926 {
928 goto end;
929 }
930 }
931
932 if (!dwContentLen)
933 {
934 // Someone was nice enough to add this, let's use it
935 if (Info.SizeInBytes)
936 {
937 dwContentLen = Info.SizeInBytes;
938 }
939 else
940 {
941 // content-length is not known, enable marquee mode
943 }
944 }
945
946 free(urlComponents.lpszScheme);
947
948#ifdef USE_CERT_PINNING
949 // are we using HTTPS to download the RAPPS update package? check if the certificate is original
950 if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) && (Info.DLType == DLTYPE_DBUPDATE))
951 {
952 CLocalPtr<char> subjectName, issuerName;
953 CStringA szMsgText;
954 bool bAskQuestion = false;
955 if (!CertGetSubjectAndIssuer(hFile, subjectName, issuerName))
956 {
957 szMsgText.LoadStringW(IDS_UNABLE_TO_QUERY_CERT);
958 bAskQuestion = true;
959 }
960 else if (!IsTrustedPinnedCert(subjectName, issuerName))
961 {
962 szMsgText.Format(IDS_MISMATCH_CERT_INFO, (LPCSTR)subjectName, (LPCSTR)issuerName);
963 bAskQuestion = true;
964 }
965
966 if (bAskQuestion)
967 {
968 if (MessageBoxA(hDlg, szMsgText, NULL, MB_YESNO | MB_ICONERROR) != IDYES)
969 {
970 goto end;
971 }
972 }
973 }
974#endif
975
977 if (hOut == INVALID_HANDLE_VALUE)
978 {
980 goto end;
981 }
982
983 dwCurrentBytesRead = 0;
984 do
985 {
986 bCancelled = IsCancelled();
987 if (bCancelled)
988 break;
989
990 if (!InternetReadFile(hFile, lpBuffer, _countof(lpBuffer), &dwBytesRead))
991 {
993 goto end;
994 }
995
996 if (!WriteFile(hOut, &lpBuffer[0], dwBytesRead, &dwBytesWritten, NULL))
997 {
999 goto end;
1000 }
1001
1002 dwCurrentBytesRead += dwBytesRead;
1003 UpdateProgress(dwCurrentBytesRead, dwContentLen);
1004
1005 } while (dwBytesRead);
1006
1007 CloseHandle(hOut);
1008 hOut = INVALID_HANDLE_VALUE;
1009
1010 if (bCancelled)
1011 {
1012 DPRINT1("Operation cancelled\n");
1013 goto end;
1014 }
1015
1016 if (!dwContentLen)
1017 {
1018 // set progress bar to 100%
1020
1021 dwContentLen = dwCurrentBytesRead;
1022 UpdateProgress(dwCurrentBytesRead, dwContentLen);
1023 }
1024
1025 /* if this thing isn't a RAPPS update and it has a SHA-1 checksum
1026 verify its integrity by using the native advapi32.A_SHA1 functions */
1027 if ((Info.DLType == DLTYPE_APPLICATION) && Info.szSHA1[0] != 0)
1028 {
1029 CStringW szMsgText;
1030
1031 // change a few strings in the download dialog to reflect the verification process
1032 if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_TITLE))
1033 {
1034 DPRINT1("Unable to load string\n");
1035 goto end;
1036 }
1037
1038 SetWindowTextW(hDlg, szMsgText);
1040
1041 // this may take a while, depending on the file size
1042 if (!VerifyInteg(Info.szSHA1, Path))
1043 {
1044 if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_FAIL))
1045 {
1046 DPRINT1("Unable to load string\n");
1047 goto end;
1048 }
1049
1050 MessageBoxW(hDlg, szMsgText, NULL, MB_OK | MB_ICONERROR);
1051 goto end;
1052 }
1053 }
1054
1055run:
1057
1058 // run it
1059 if (Info.DLType == DLTYPE_APPLICATION)
1060 {
1061 CStringW app, params;
1062 SHELLEXECUTEINFOW shExInfo = {0};
1063 shExInfo.cbSize = sizeof(shExInfo);
1064 shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
1065 shExInfo.lpVerb = L"open";
1066 shExInfo.lpFile = Path;
1067 shExInfo.lpParameters = L"";
1068 shExInfo.nShow = SW_SHOW;
1069
1070 if (Info.IType == INSTALLER_GENERATE)
1071 {
1072 params = L"/" + CStringW(CMD_KEY_GENINST) + L" \"" +
1073 Info.szPackageName + L"\" \"" +
1074 CStringW(shExInfo.lpFile) + L"\"";
1075 shExInfo.lpParameters = params;
1076 shExInfo.lpFile = app.GetBuffer(MAX_PATH);
1077 GetModuleFileNameW(NULL, const_cast<LPWSTR>(shExInfo.lpFile), MAX_PATH);
1078 app.ReleaseBuffer();
1079 }
1080
1081 /* FIXME: Do we want to log installer status? */
1082 WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_INSTALL, Info.szName);
1083
1084 if (ShellExecuteExW(&shExInfo))
1085 {
1086 // reflect installation progress in the titlebar
1087 // TODO: make a separate string with a placeholder to include app name?
1089 SetWindowTextW(hDlg, szMsgText);
1090
1092
1093 // TODO: issue an install operation separately so that the apps could be downloaded in the background
1094 if (shExInfo.hProcess)
1095 {
1097 CloseHandle(shExInfo.hProcess);
1099 }
1100 }
1101 else
1102 {
1104 }
1105 }
1106
1107end:
1108 if (hOut != INVALID_HANDLE_VALUE)
1109 CloseHandle(hOut);
1110
1111 if (hFile)
1113 InternetCloseHandle(hOpen);
1114
1115 if (bTempfile)
1116 {
1117 if (bCancelled || (SettingsInfo.bDelInstaller && Info.DLType == DLTYPE_APPLICATION))
1119 }
1120
1122}
PRTL_UNICODE_STRING_BUFFER Path
@ INSTALLER_GENERATE
Definition: appinfo.h:85
#define APPLICATION_DATABASE_NAME
Definition: defines.h:41
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:254
BOOL GetStorageDirectory(CStringW &lpDirectory)
Definition: misc.cpp:172
#define IDS_UNABLE_TO_DOWNLOAD
Definition: resource.h:114
#define IDS_MISMATCH_CERT_INFO
Definition: resource.h:124
#define IDS_UNABLE_TO_DOWNLOAD2
Definition: resource.h:115
#define IDS_UNABLE_PATH
Definition: resource.h:125
#define IDS_UNABLE_TO_QUERY_CERT
Definition: resource.h:116
#define IDC_DOWNLOAD_STATUS
Definition: resource.h:42
#define IDS_INTEG_CHECK_TITLE
Definition: resource.h:117
#define IDS_DL_DIALOG_DB_DOWNLOAD_DISP
Definition: resource.h:223
#define IDS_INTEG_CHECK_FAIL
Definition: resource.h:118
#define IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP
Definition: resource.h:224
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:21
#define DPRINT1
Definition: precomp.h:8
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:694
WCHAR m_szCaptionFmt[100]
Definition: loaddlg.cpp:541
CDownloaderProgress m_ProgressBar
Definition: loaddlg.cpp:544
BOOL IsCancelled()
Definition: loaddlg.cpp:516
VOID SetMarquee(BOOL Enable)
Definition: loaddlg.cpp:177
VOID SetProgress(ULONG ulProgress, ULONG ulProgressMax)
Definition: loaddlg.cpp:188
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#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(LPCWSTR pszUrl, LPWSTR pszPath, LPDWORD pcchPath, DWORD dwReserved)
Definition: path.c:3361
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 INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint end
Definition: gl.h:1545
GLenum const GLfloat * params
Definition: glext.h:5645
#define SUCCEEDED(hr)
Definition: intsafe.h:50
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:430
@ 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:440
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 CREATE_ALWAYS
Definition: disk.h:72
static BYTE subjectName[]
Definition: cert.c:63
_In_ HANDLE hFile
Definition: mswsock.h:90
CAtlStringW CStringW
Definition: atlstr.h:130
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define GENERIC_WRITE
Definition: nt_native.h:90
#define L(x)
Definition: ntvdm.h:50
#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:31
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2452
HRESULT hr
Definition: shlfolder.c:183
#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:21
WCHAR szProxyServer[MAX_PATH]
Definition: settings.h:20
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:334
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
#define ZeroMemory
Definition: winbase.h:1737
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
LONG_PTR LPARAM
Definition: windef.h:208
#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:2862
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
#define MB_YESNO
Definition: winuser.h:820
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:790
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define MB_OK
Definition: winuser.h:793
#define SW_SHOW
Definition: winuser.h:778
#define IDYES
Definition: winuser.h:838
const char * LPCSTR
Definition: xmlstorage.h:183
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by ThreadFunc().

◆ RealDlgProc()

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

Definition at line 597 of file loaddlg.cpp.

598{
599 switch (uMsg)
600 {
601 case WM_INITDIALOG:
602 {
603 g_Busy++;
604 AddRef();
605 m_hDlg = hDlg;
606 if (!m_bModal)
607 g_hDownloadWnd = hDlg;
608
609 HICON hIconSm, hIconBg;
610 if (hMainWnd)
611 {
614 }
615 if (!hMainWnd || (!hIconBg || !hIconSm))
616 {
618 }
619 SendMessageW(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hIconBg);
620 SendMessageW(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
621
625 buf.Replace(L"%ls", L"");
626 SetWindowTextW(hDlg, buf); // "Downloading..."
627
629 if (hItem)
630 {
631 // initialize the default values for our nifty progress bar
632 // and subclass it so that it learns to print a status text
634 m_ProgressBar.SendMessageW(PBM_SETRANGE, 0, MAKELPARAM(0, 100));
635 m_ProgressBar.SendMessageW(PBM_SETPOS, 0, 0);
636 if (m_List.GetSize() > 0)
637 m_ProgressBar.SetProgress(0, m_List[0].SizeInBytes);
638 }
639
640 if (!m_ListView.Create(hDlg))
641 return FALSE;
643
644 ShowWindow(hDlg, SW_SHOW);
646 return TRUE;
647 }
648
649 case WM_COMMAND:
650 if (LOWORD(wParam) == IDCANCEL)
651 {
653 PostMessageW(hDlg, WM_CLOSE, 0, 0);
654 }
655 return FALSE;
656
657 case WM_CLOSE:
659 if (m_ProgressBar)
661 return m_bModal ? ::EndDialog(hDlg, 0) : ::DestroyWindow(hDlg);
662
663 case WM_DESTROY:
664 if (g_hDownloadWnd == hDlg)
666 g_Busy--;
667 if (hMainWnd)
669 Release();
670 break;
671
672 case WM_ISCANCELLED:
673 return SetDlgMsgResult(hDlg, uMsg, m_bCancelled);
674
675 case WM_SETSTATUS:
677 break;
678
679 case WM_GETINSTANCE:
680 return SetDlgMsgResult(hDlg, uMsg, (INT_PTR)this);
681
682 case WM_GETNEXT:
683 {
684 DownloadInfo *pItem = NULL;
686 pItem = &m_List[m_Index++];
687 return SetDlgMsgResult(hDlg, uMsg, (INT_PTR)pItem);
688 }
689 }
690 return FALSE;
691}
#define IDI_MAIN
Definition: resource.h:4
#define IDC_DOWNLOAD_PROGRESS
Definition: resource.h:41
BOOL SubclassWindow(HWND hWnd)
Definition: atlwin.h:1552
HWND UnsubclassWindow(BOOL bForce=FALSE)
Definition: atlwin.h:1575
HWND Create(HWND hwndParent)
Definition: loaddlg.cpp:316
VOID SetDownloadStatus(INT ItemIndex, DownloadStatus Status)
Definition: loaddlg.cpp:346
void StartWorkerThread()
Definition: loaddlg.cpp:548
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:1394
#define SetDlgMsgResult(hwnd, msg, result)
Definition: windowsx.h:518
#define WM_CLOSE
Definition: winuser.h:1624
#define GCLP_HICONSM
Definition: winuser.h:675
#define MAKELPARAM(l, h)
Definition: winuser.h:4011
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define IDCANCEL
Definition: winuser.h:834
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define GCLP_HICON
Definition: winuser.h:674
#define WM_COMMAND
Definition: winuser.h:1743
#define PostMessage
Definition: winuser.h:5844
#define GetClassLongPtrW
Definition: winuser.h:4567
#define WM_DESTROY
Definition: winuser.h:1612
#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:2161
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by DlgProc().

◆ Show()

void CDownloadManager::Show ( )

Definition at line 574 of file loaddlg.cpp.

575{
576 if (m_bModal)
578 else if (!m_hDlg || !IsWindow(m_hDlg))
580}
#define IDD_DOWNLOAD_DIALOG
Definition: resource.h:65
DLGPROC DlgProc
Definition: desk.c:122
HWND WINAPI CreateDialogParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

◆ StartWorkerThread()

void CDownloadManager::StartWorkerThread ( )

Definition at line 548 of file loaddlg.cpp.

549{
550 AddRef(); // To keep m_List alive in thread
551 unsigned int ThreadId;
552 HANDLE Thread = (HANDLE)_beginthreadex(NULL, 0, ThreadFunc, this, 0, &ThreadId);
553 if (Thread)
554 CloseHandle(Thread);
555 else
556 Release();
557}
static unsigned int CALLBACK ThreadFunc(void *ThreadParam)
Definition: loaddlg.cpp:700
_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 700 of file loaddlg.cpp.

701{
702 CDownloadManager *pThis = (CDownloadManager*)ThreadParam;
703 HWND hDlg = pThis->m_hDlg;
704 for (;;)
705 {
706 DownloadInfo *pItem = (DownloadInfo*)SendMessageW(hDlg, WM_GETNEXT, 0, 0);
707 if (!pItem)
708 break;
709 pThis->PerformDownloadAndInstall(*pItem);
710 }
711 SendMessageW(hDlg, WM_CLOSE, 0, 0);
712 return pThis->Release();
713}
void PerformDownloadAndInstall(const DownloadInfo &Info)
Definition: loaddlg.cpp:716

Referenced by StartWorkerThread().

◆ UpdateProgress()

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

Definition at line 694 of file loaddlg.cpp.

695{
696 m_ProgressBar.SetProgress(ulProgress, ulProgressMax);
697}

Referenced by PerformDownloadAndInstall().

Member Data Documentation

◆ m_bCancelled

BOOL CDownloadManager::m_bCancelled
protected

Definition at line 539 of file loaddlg.cpp.

Referenced by RealDlgProc().

◆ m_bModal

BOOL CDownloadManager::m_bModal
protected

Definition at line 540 of file loaddlg.cpp.

Referenced by RealDlgProc(), and Show().

◆ m_hDlg

HWND CDownloadManager::m_hDlg
protected

Definition at line 536 of file loaddlg.cpp.

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

◆ m_Index

UINT CDownloadManager::m_Index
protected

Definition at line 538 of file loaddlg.cpp.

Referenced by RealDlgProc().

◆ m_List

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

Definition at line 542 of file loaddlg.cpp.

Referenced by Add(), and RealDlgProc().

◆ m_ListView

CDowloadingAppsListView CDownloadManager::m_ListView
protected

Definition at line 543 of file loaddlg.cpp.

Referenced by Add(), and RealDlgProc().

◆ m_ProgressBar

CDownloaderProgress CDownloadManager::m_ProgressBar
protected

Definition at line 544 of file loaddlg.cpp.

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

◆ m_szCaptionFmt

WCHAR CDownloadManager::m_szCaptionFmt[100]
protected

Definition at line 541 of file loaddlg.cpp.

Referenced by PerformDownloadAndInstall(), and RealDlgProc().

◆ m_Threads

UINT CDownloadManager::m_Threads
protected

Definition at line 537 of file loaddlg.cpp.


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