ReactOS  0.4.15-dev-5446-g3f3714b
CDownloadManager Class Reference
Collaboration diagram for CDownloadManager:

Static Public Member Functions

static VOID Add (DownloadInfo info)
 
static VOID Download (const DownloadInfo &DLInfo, BOOL bIsModal=FALSE)
 
static INT_PTR CALLBACK DownloadDlgProc (HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static unsigned int WINAPI ThreadFunc (LPVOID Context)
 
static VOID LaunchDownloadDialog (BOOL)
 

Static Private Member Functions

static VOID UpdateProgress (HWND hDlg, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
 

Static Private Attributes

static ATL::CSimpleArray< DownloadInfoAppsDownloadList
 
static CDowloadingAppsListView DownloadsListView
 
static CDownloaderProgress ProgressBar
 
static BOOL bCancelled = FALSE
 
static BOOL bModal = FALSE
 

Detailed Description

Definition at line 378 of file loaddlg.cpp.

Member Function Documentation

◆ Add()

VOID CDownloadManager::Add ( DownloadInfo  info)
static

Definition at line 402 of file loaddlg.cpp.

403 {
405 }
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
static ATL::CSimpleArray< DownloadInfo > AppsDownloadList
Definition: loaddlg.cpp:380

Referenced by DownloadListOfApplications().

◆ Download()

VOID CDownloadManager::Download ( const DownloadInfo DLInfo,
BOOL  bIsModal = FALSE 
)
static

Definition at line 407 of file loaddlg.cpp.

408 {
410  AppsDownloadList.Add(DLInfo);
411  LaunchDownloadDialog(bIsModal);
412 }
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
static VOID LaunchDownloadDialog(BOOL)
Definition: loaddlg.cpp:1023
static ATL::CSimpleArray< DownloadInfo > AppsDownloadList
Definition: loaddlg.cpp:380

Referenced by DownloadApplication(), and DownloadApplicationsDB().

◆ DownloadDlgProc()

INT_PTR CALLBACK CDownloadManager::DownloadDlgProc ( HWND  Dlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 414 of file loaddlg.cpp.

415 {
416  static WCHAR szCaption[MAX_PATH];
417 
418  switch (uMsg)
419  {
420  case WM_INITDIALOG:
421  {
422  HICON hIconSm, hIconBg;
423  ATL::CStringW szTempCaption;
424 
425  bCancelled = FALSE;
426 
427  if (hMainWnd)
428  {
431  }
432  if (!hMainWnd || (!hIconBg || !hIconSm))
433  {
434  /* Load the default icon */
436  }
437 
438  if (hIconBg && hIconSm)
439  {
440  SendMessageW(Dlg, WM_SETICON, ICON_BIG, (LPARAM)hIconBg);
441  SendMessageW(Dlg, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
442  }
443 
445  if (Item)
446  {
447  // initialize the default values for our nifty progress bar
448  // and subclass it so that it learns to print a status text
452  if (AppsDownloadList.GetSize() > 0)
453  ProgressBar.SetProgress(0, AppsDownloadList[0].SizeInBytes);
454  }
455 
456  // Add a ListView
457  HWND hListView = DownloadsListView.Create(Dlg);
458  if (!hListView)
459  {
460  return FALSE;
461  }
463 
464  // Get a dlg string for later use
465  GetWindowTextW(Dlg, szCaption, _countof(szCaption));
466 
467  // Hide a placeholder from displaying
468  szTempCaption = szCaption;
469  szTempCaption.Replace(L"%ls", L"");
470  SetWindowText(Dlg, szTempCaption.GetString());
471 
472  ShowWindow(Dlg, SW_SHOW);
473 
474  // Start download process
475  DownloadParam *param = new DownloadParam(Dlg, AppsDownloadList, szCaption);
476  unsigned int ThreadId;
477  HANDLE Thread = (HANDLE)_beginthreadex(NULL, 0, ThreadFunc, (void *) param, 0, &ThreadId);
478  if (!Thread)
479  {
480  return FALSE;
481  }
482 
485  return TRUE;
486  }
487 
488  case WM_COMMAND:
489  if (wParam == IDCANCEL)
490  {
491  bCancelled = TRUE;
492  PostMessageW(Dlg, WM_CLOSE, 0, 0);
493  }
494  return FALSE;
495 
496  case WM_CLOSE:
497  if (ProgressBar)
500  {
501  ::EndDialog(Dlg, 0);
502  }
503  else
504  {
505  ::DestroyWindow(Dlg);
506  }
507  return TRUE;
508 
509  default:
510  return FALSE;
511  }
512 }
HWND UnsubclassWindow(BOOL bForce=FALSE)
Definition: atlwin.h:1569
static HICON
Definition: imagelist.c:84
#define CloseHandle
Definition: compat.h:739
#define TRUE
Definition: types.h:120
static BOOL bCancelled
Definition: loaddlg.cpp:383
static unsigned int WINAPI ThreadFunc(LPVOID Context)
Definition: loaddlg.cpp:578
#define MAKELPARAM(l, h)
Definition: winuser.h:3998
VOID SetProgress(ULONG ulProgress, ULONG ulProgressMax)
Definition: loaddlg.cpp:136
#define PBM_SETPOS
Definition: commctrl.h:2184
static ATL::CSimpleArray< DownloadInfo > AppsDownloadList
Definition: loaddlg.cpp:380
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
_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)
int GetSize() const
Definition: atlsimpcoll.h:104
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
WPARAM wParam
Definition: combotst.c:138
#define ICON_SMALL
Definition: tnclass.cpp:48
#define PBM_SETRANGE
Definition: commctrl.h:2183
#define L(x)
Definition: ntvdm.h:50
BOOL SubclassWindow(HWND hWnd)
Definition: atlwin.h:1546
#define FALSE
Definition: types.h:117
LONG_PTR LPARAM
Definition: windef.h:208
static CDowloadingAppsListView DownloadsListView
Definition: loaddlg.cpp:381
#define SW_SHOW
Definition: winuser.h:769
VOID LoadList(ATL::CSimpleArray< DownloadInfo > arrInfo)
Definition: loaddlg.cpp:277
#define GCLP_HICONSM
Definition: winuser.h:670
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
#define WM_CLOSE
Definition: winuser.h:1611
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:34
PCXSTR GetString() const
Definition: atlsimpstr.h:361
PVOID HANDLE
Definition: typedefs.h:73
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2652
#define IDC_DOWNLOAD_PROGRESS
Definition: resource.h:41
HWND hMainWnd
Definition: magnifier.c:32
#define IDI_MAIN
Definition: resource.h:4
#define GCLP_HICON
Definition: winuser.h:669
#define WM_COMMAND
Definition: winuser.h:1730
int Replace(PCXSTR pszOld, PCXSTR pszNew)
Definition: cstringt.h:811
HINSTANCE hInst
Definition: dxdiag.c:13
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
HWND Create(HWND hwndParent)
Definition: loaddlg.cpp:263
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SetWindowText
Definition: winuser.h:5847
#define NULL
Definition: types.h:112
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
HICON hIconSm
Definition: msconfig.c:44
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1110
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2044
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define IDCANCEL
Definition: winuser.h:825
static BOOL bModal
Definition: loaddlg.cpp:384
#define WM_INITDIALOG
Definition: winuser.h:1729
#define GetClassLongPtrW
Definition: winuser.h:4554
#define ICON_BIG
Definition: tnclass.cpp:51
static CDownloaderProgress ProgressBar
Definition: loaddlg.cpp:382

Referenced by LaunchDownloadDialog().

◆ LaunchDownloadDialog()

VOID CDownloadManager::LaunchDownloadDialog ( BOOL  bIsModal)
static

Definition at line 1023 of file loaddlg.cpp.

1024 {
1025  CDownloadManager::bModal = bIsModal;
1026  if (bIsModal)
1027  {
1028  DialogBoxW(hInst,
1030  hMainWnd,
1031  DownloadDlgProc);
1032  }
1033  else
1034  {
1037  hMainWnd,
1038  DownloadDlgProc);
1039  }
1040 }
#define IDD_DOWNLOAD_DIALOG
Definition: resource.h:65
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4389
static INT_PTR CALLBACK DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: loaddlg.cpp:414
HWND hMainWnd
Definition: magnifier.c:32
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4271
HINSTANCE hInst
Definition: dxdiag.c:13
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static BOOL bModal
Definition: loaddlg.cpp:384

Referenced by Download(), and DownloadListOfApplications().

◆ ThreadFunc()

unsigned int WINAPI CDownloadManager::ThreadFunc ( LPVOID  Context)
static

Definition at line 578 of file loaddlg.cpp.

579 {
581  PWSTR p, q;
582 
583  HWND hDlg = static_cast<DownloadParam*>(param)->Dialog;
584  HWND Item;
585  INT iAppId;
586 
587  ULONG dwContentLen, dwBytesWritten, dwBytesRead, dwStatus;
588  ULONG dwCurrentBytesRead = 0;
589  ULONG dwStatusLen = sizeof(dwStatus);
590 
591  BOOL bTempfile = FALSE;
592 
593  HINTERNET hOpen = NULL;
594  HINTERNET hFile = NULL;
596 
597  unsigned char lpBuffer[4096];
598  LPCWSTR lpszAgent = L"RApps/1.1";
599  URL_COMPONENTSW urlComponents;
600  size_t urlLength, filenameLength;
601 
602  const ATL::CSimpleArray<DownloadInfo> &InfoArray = static_cast<DownloadParam*>(param)->AppInfo;
603  LPCWSTR szCaption = static_cast<DownloadParam*>(param)->szCaption;
604  ATL::CStringW szNewCaption;
605 
607 
608  if (InfoArray.GetSize() <= 0)
609  {
611  goto end;
612  }
613 
614  for (iAppId = 0; iAppId < InfoArray.GetSize(); ++iAppId)
615  {
616  // Reset progress bar
617  if (!IsWindow(hDlg)) break;
619  if (Item)
620  {
623  ProgressBar.SetProgress(0, InfoArray[iAppId].SizeInBytes);
624  }
625 
626  // is this URL an update package for RAPPS? if so store it in a different place
627  if (InfoArray[iAppId].DLType != DLTYPE_APPLICATION)
628  {
630  {
632  goto end;
633  }
634  }
635  else
636  {
638  }
639 
640  // Change caption to show the currently downloaded app
641  switch(InfoArray[iAppId].DLType)
642  {
643  case DLTYPE_APPLICATION:
644  szNewCaption.Format(szCaption, InfoArray[iAppId].szName.GetString());
645  break;
646  case DLTYPE_DBUPDATE:
647  szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_DOWNLOAD_DISP);
648  break;
650  szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP);
651  break;
652  }
653 
654  if (!IsWindow(hDlg)) goto end;
655  SetWindowTextW(hDlg, szNewCaption.GetString());
656 
657  // build the path for the download
658  p = wcsrchr(InfoArray[iAppId].szUrl.GetString(), L'/');
659  q = wcsrchr(InfoArray[iAppId].szUrl.GetString(), L'?');
660 
661  // do we have a final slash separator?
662  if (!p)
663  {
665  goto end;
666  }
667 
668  // prepare the tentative length of the filename, maybe we've to remove part of it later on
669  filenameLength = wcslen(p) * sizeof(WCHAR);
670 
671  /* do we have query arguments in the target URL after the filename? account for them
672  (e.g. https://example.org/myfile.exe?no_adware_plz) */
673  if (q && q > p && (q - p) > 0)
674  filenameLength -= wcslen(q - 1) * sizeof(WCHAR);
675 
676  // is the path valid? can we access it?
677  if (GetFileAttributesW(Path.GetString()) == INVALID_FILE_ATTRIBUTES)
678  {
679  if (!CreateDirectoryW(Path.GetString(), NULL))
680  {
682  goto end;
683  }
684  }
685 
686  // append a \ to the provided file system path, and the filename portion from the URL after that
687 
688  PathAddBackslashW(Path.GetBuffer(MAX_PATH));
689  switch (InfoArray[iAppId].DLType)
690  {
691  case DLTYPE_DBUPDATE:
694  break;
695  case DLTYPE_APPLICATION:
696  PathAppendW(Path.GetBuffer(), (LPWSTR)(p + 1)); // use the filename retrieved from URL
697  break;
698  }
699  Path.ReleaseBuffer();
700 
701  if ((InfoArray[iAppId].DLType == DLTYPE_APPLICATION) && InfoArray[iAppId].szSHA1[0] && GetFileAttributesW(Path.GetString()) != INVALID_FILE_ATTRIBUTES)
702  {
703  // only open it in case of total correctness
704  if (VerifyInteg(InfoArray[iAppId].szSHA1.GetString(), Path))
705  goto run;
706  }
707 
708  // Add the download URL
709  if (!IsWindow(hDlg)) goto end;
710  SetDlgItemTextW(hDlg, IDC_DOWNLOAD_STATUS, InfoArray[iAppId].szUrl.GetString());
711 
713 
714  // download it
716  bTempfile = TRUE;
717 
718  /* FIXME: this should just be using the system-wide proxy settings */
719  switch (SettingsInfo.Proxy)
720  {
721  case 0: // preconfig
722  default:
723  hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
724  break;
725  case 1: // direct (no proxy)
726  hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
727  break;
728  case 2: // use proxy
730  break;
731  }
732 
733  if (!hOpen)
734  {
736  goto end;
737  }
738 
739  dwStatusLen = sizeof(dwStatus);
740 
741  memset(&urlComponents, 0, sizeof(urlComponents));
742  urlComponents.dwStructSize = sizeof(urlComponents);
743 
744  urlLength = InfoArray[iAppId].szUrl.GetLength();
745  urlComponents.dwSchemeLength = urlLength + 1;
746  urlComponents.lpszScheme = (LPWSTR) malloc(urlComponents.dwSchemeLength * sizeof(WCHAR));
747 
748  if (!InternetCrackUrlW(InfoArray[iAppId].szUrl, urlLength + 1, ICU_DECODE | ICU_ESCAPE, &urlComponents))
749  {
751  goto end;
752  }
753 
754  dwContentLen = 0;
755 
756  if (urlComponents.nScheme == INTERNET_SCHEME_HTTP ||
757  urlComponents.nScheme == INTERNET_SCHEME_HTTPS)
758  {
759  hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL, 0,
760  dwUrlConnectFlags,
761  0);
762  if (!hFile)
763  {
765  {
766  /* Workaround for CORE-17377 */
768  }
769  goto end;
770  }
771 
772  // query connection
774  {
776  goto end;
777  }
778 
779  if (dwStatus != HTTP_STATUS_OK)
780  {
782  goto end;
783  }
784 
785  // query content length
787  }
788  else if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
789  {
790  // force passive mode on FTP
791  hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl, NULL, 0,
792  dwUrlConnectFlags | INTERNET_FLAG_PASSIVE,
793  0);
794  if (!hFile)
795  {
797  {
798  /* Workaround for CORE-17377 */
800  }
801  goto end;
802  }
803 
804  dwContentLen = FtpGetFileSize(hFile, &dwStatus);
805  }
806  else if (urlComponents.nScheme == INTERNET_SCHEME_FILE)
807  {
808  // Add support for the file scheme so testing locally is simpler
809  WCHAR LocalFilePath[MAX_PATH];
810  DWORD cchPath = _countof(LocalFilePath);
811  // Ideally we would use PathCreateFromUrlAlloc here, but that is not exported (yet)
812  HRESULT hr = PathCreateFromUrlW(InfoArray[iAppId].szUrl, LocalFilePath, &cchPath, 0);
813  if (SUCCEEDED(hr))
814  {
815  if (CopyFileW(LocalFilePath, Path, FALSE))
816  {
817  goto run;
818  }
819  else
820  {
822  goto end;
823  }
824  }
825  else
826  {
828  goto end;
829  }
830  }
831 
832  if (!dwContentLen)
833  {
834  // Someone was nice enough to add this, let's use it
835  if (InfoArray[iAppId].SizeInBytes)
836  {
837  dwContentLen = InfoArray[iAppId].SizeInBytes;
838  }
839  else
840  {
841  // content-length is not known, enable marquee mode
843  }
844  }
845 
846  free(urlComponents.lpszScheme);
847 
848 #ifdef USE_CERT_PINNING
849  // are we using HTTPS to download the RAPPS update package? check if the certificate is original
850  if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) &&
851  (InfoArray[iAppId].DLType == DLTYPE_DBUPDATE))
852  {
853  CLocalPtr<char> subjectName, issuerName;
854  CStringA szMsgText;
855  bool bAskQuestion = false;
856  if (!CertGetSubjectAndIssuer(hFile, subjectName, issuerName))
857  {
858  szMsgText.LoadStringW(IDS_UNABLE_TO_QUERY_CERT);
859  bAskQuestion = true;
860  }
861  else
862  {
863  if (strcmp(subjectName, CERT_SUBJECT_INFO) ||
864  (strcmp(issuerName, CERT_ISSUER_INFO_OLD) &&
865  strcmp(issuerName, CERT_ISSUER_INFO_NEW)))
866  {
867  szMsgText.Format(IDS_MISMATCH_CERT_INFO, (char*)subjectName, (const char*)issuerName);
868  bAskQuestion = true;
869  }
870  }
871 
872  if (bAskQuestion)
873  {
874  if (MessageBoxA(hMainWnd, szMsgText.GetString(), NULL, MB_YESNO | MB_ICONERROR) != IDYES)
875  {
876  goto end;
877  }
878  }
879  }
880 #endif
881 
883 
884  if (hOut == INVALID_HANDLE_VALUE)
885  {
887  goto end;
888  }
889 
890  dwCurrentBytesRead = 0;
891  do
892  {
893  if (!InternetReadFile(hFile, lpBuffer, _countof(lpBuffer), &dwBytesRead))
894  {
896  goto end;
897  }
898 
899  if (!WriteFile(hOut, &lpBuffer[0], dwBytesRead, &dwBytesWritten, NULL))
900  {
902  goto end;
903  }
904 
905  dwCurrentBytesRead += dwBytesRead;
906  if (!IsWindow(hDlg)) goto end;
907  UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString());
908  } while (dwBytesRead && !bCancelled);
909 
910  CloseHandle(hOut);
911  hOut = INVALID_HANDLE_VALUE;
912 
913  if (bCancelled)
914  {
915  DPRINT1("Operation cancelled\n");
916  goto end;
917  }
918 
919  if (!dwContentLen)
920  {
921  // set progress bar to 100%
923 
924  dwContentLen = dwCurrentBytesRead;
925  if (!IsWindow(hDlg)) goto end;
926  UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString());
927  }
928 
929  /* if this thing isn't a RAPPS update and it has a SHA-1 checksum
930  verify its integrity by using the native advapi32.A_SHA1 functions */
931  if ((InfoArray[iAppId].DLType == DLTYPE_APPLICATION) && InfoArray[iAppId].szSHA1[0] != 0)
932  {
933  ATL::CStringW szMsgText;
934 
935  // change a few strings in the download dialog to reflect the verification process
936  if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_TITLE))
937  {
938  DPRINT1("Unable to load string\n");
939  goto end;
940  }
941 
942  if (!IsWindow(hDlg)) goto end;
943  SetWindowTextW(hDlg, szMsgText.GetString());
944  ::SetDlgItemText(hDlg, IDC_DOWNLOAD_STATUS, Path.GetString());
945 
946  // this may take a while, depending on the file size
947  if (!VerifyInteg(InfoArray[iAppId].szSHA1.GetString(), Path.GetString()))
948  {
949  if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_FAIL))
950  {
951  DPRINT1("Unable to load string\n");
952  goto end;
953  }
954 
955  if (!IsWindow(hDlg)) goto end;
956  MessageBoxW(hDlg, szMsgText.GetString(), NULL, MB_OK | MB_ICONERROR);
957  goto end;
958  }
959  }
960 
961 run:
963 
964  // run it
965  if (InfoArray[iAppId].DLType == DLTYPE_APPLICATION)
966  {
967  SHELLEXECUTEINFOW shExInfo = {0};
968  shExInfo.cbSize = sizeof(shExInfo);
969  shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
970  shExInfo.lpVerb = L"open";
971  shExInfo.lpFile = Path.GetString();
972  shExInfo.lpParameters = L"";
973  shExInfo.nShow = SW_SHOW;
974 
975  /* FIXME: Do we want to log installer status? */
976  WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_INSTALL, InfoArray[iAppId].szName);
977 
978  if (ShellExecuteExW(&shExInfo))
979  {
980  //reflect installation progress in the titlebar
981  //TODO: make a separate string with a placeholder to include app name?
983  if (!IsWindow(hDlg)) goto end;
984  SetWindowTextW(hDlg, szMsgText.GetString());
985 
987 
988  //TODO: issue an install operation separately so that the apps could be downloaded in the background
990  CloseHandle(shExInfo.hProcess);
991  }
992  else
993  {
995  }
996  }
997 
998 end:
999  if (hOut != INVALID_HANDLE_VALUE)
1000  CloseHandle(hOut);
1001 
1002  if (hFile)
1004  InternetCloseHandle(hOpen);
1005 
1006  if (bTempfile)
1007  {
1008  if (bCancelled || (SettingsInfo.bDelInstaller && (InfoArray[iAppId].DLType == DLTYPE_APPLICATION)))
1009  DeleteFileW(Path.GetString());
1010  }
1011 
1012  if (!IsWindow(hDlg)) return 0;
1014  }
1015 
1016  delete static_cast<DownloadParam*>(param);
1017  if (!IsWindow(hDlg)) return 0;
1018  SendMessageW(hDlg, WM_CLOSE, 0, 0);
1019  return 0;
1020 }
#define HTTP_QUERY_CONTENT_LENGTH
Definition: wininet.h:1528
BOOL WINAPI CreateDirectoryW(IN LPCWSTR lpPathName, IN LPSECURITY_ATTRIBUTES lpSecurityAttributes)
Definition: dir.c:90
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
static const WCHAR szName[]
Definition: powrprof.c:45
HRESULT WINAPI PathCreateFromUrlW(LPCWSTR pszUrl, LPWSTR pszPath, LPDWORD pcchPath, DWORD dwReserved)
Definition: path.c:3354
#define IDS_DL_DIALOG_DB_DOWNLOAD_DISP
Definition: resource.h:219
#define CloseHandle
Definition: compat.h:739
BOOL VerifyInteg(LPCWSTR lpSHA1Hash, LPCWSTR lpFileName)
Definition: integrity.cpp:13
HRESULT hr
Definition: shlfolder.c:183
#define IDYES
Definition: winuser.h:829
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
BOOL WINAPI IsWindow(_In_opt_ HWND)
DWORD dwStructSize
Definition: wininet.h:211
#define SEE_MASK_NOCLOSEPROCESS
Definition: shellapi.h:31
#define TRUE
Definition: types.h:120
static BYTE subjectName[]
Definition: cert.c:63
uint16_t * PWSTR
Definition: typedefs.h:56
static BOOL bCancelled
Definition: loaddlg.cpp:383
#define free
Definition: debug_ros.c:5
#define IDS_MISMATCH_CERT_INFO
Definition: resource.h:120
BOOL ShowLastError(HWND hWndOwner, BOOL bInetError, DWORD dwLastError)
Definition: loaddlg.cpp:554
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
VOID SetProgress(ULONG ulProgress, ULONG ulProgressMax)
Definition: loaddlg.cpp:136
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:753
#define PBM_SETPOS
Definition: commctrl.h:2184
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1414
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define IDS_UNABLE_TO_DOWNLOAD
Definition: resource.h:109
int GetSize() const
Definition: atlsimpcoll.h:104
#define INTERNET_FLAG_DONT_CACHE
Definition: wininet.h:67
int32_t INT
Definition: typedefs.h:58
#define FILE_SHARE_READ
Definition: compat.h:136
BOOL WINAPI PathAppendW(LPWSTR lpszPath, LPCWSTR lpszAppend)
Definition: path.c:126
#define IDC_DOWNLOAD_STATUS
Definition: resource.h:42
WCHAR szDownloadDir[MAX_PATH]
Definition: settings.h:10
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
HINTERNET WINAPI InternetOpenUrlW(HINTERNET hInternet, LPCWSTR lpszUrl, LPCWSTR lpszHeaders, DWORD dwHeadersLength, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3722
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID MessageBox_LoadString(HWND hMainWnd, INT StringID)
Definition: loaddlg.cpp:368
#define L(x)
Definition: ntvdm.h:50
DWORD dwSchemeLength
Definition: wininet.h:213
#define FALSE
Definition: types.h:117
#define MB_YESNO
Definition: winuser.h:811
DWORD WINAPI FtpGetFileSize(HINTERNET hFile, LPDWORD lpdwFileSizeHigh)
Definition: ftp.c:1757
LPWSTR WINAPI PathAddBackslashW(LPWSTR lpszPath)
Definition: path.c:294
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
if SUCCEEDED(hr)
#define GENERIC_WRITE
Definition: nt_native.h:90
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
#define IDS_INTEG_CHECK_FAIL
Definition: resource.h:113
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
static CDowloadingAppsListView DownloadsListView
Definition: loaddlg.cpp:381
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2335
BOOL UrlHasBeenCopied
Definition: loaddlg.cpp:514
#define SW_SHOW
Definition: winuser.h:769
#define ICU_ESCAPE
Definition: winhttp.h:48
VOID SetDownloadStatus(INT ItemIndex, DownloadStatus Status)
Definition: loaddlg.cpp:285
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:2880
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:226
LPWSTR lpszScheme
Definition: wininet.h:212
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:20
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
BOOL WINAPI CopyFileW(IN LPCWSTR lpExistingFileName, IN LPCWSTR lpNewFileName, IN BOOL bFailIfExists)
Definition: copy.c:439
#define _countof(array)
Definition: sndvol32.h:68
#define IDS_UNABLE_TO_QUERY_CERT
Definition: resource.h:111
#define WM_CLOSE
Definition: winuser.h:1611
INTERNET_SCHEME nScheme
Definition: wininet.h:214
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:34
PCXSTR GetString() const
Definition: atlsimpstr.h:361
VOID SetMarquee(BOOL Enable)
Definition: loaddlg.cpp:126
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
BOOL GetStorageDirectory(ATL::CStringW &lpDirectory)
Definition: misc.cpp:141
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define SetDlgItemText
Definition: winuser.h:5839
#define IDS_UNABLE_TO_DOWNLOAD2
Definition: resource.h:110
#define IDC_DOWNLOAD_PROGRESS
Definition: resource.h:41
GLuint GLuint end
Definition: gl.h:1545
static VOID UpdateProgress(HWND hDlg, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
Definition: loaddlg.cpp:516
#define INTERNET_OPEN_TYPE_DIRECT
Definition: wininet.h:522
HWND hMainWnd
Definition: magnifier.c:32
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3870
#define IDS_INTEG_CHECK_TITLE
Definition: resource.h:112
#define MB_ICONERROR
Definition: winuser.h:781
#define wcsrchr
Definition: compat.h:16
_In_ HANDLE hFile
Definition: mswsock.h:90
#define IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP
Definition: resource.h:220
#define HTTP_QUERY_STATUS_CODE
Definition: wininet.h:1542
#define INTERNET_FLAG_PASSIVE
Definition: wininet.h:65
#define INTERNET_FLAG_PRAGMA_NOCACHE
Definition: wininet.h:85
#define CREATE_ALWAYS
Definition: disk.h:72
WCHAR szProxyServer[MAX_PATH]
Definition: settings.h:20
DWORD dwStatus
Definition: mediaobj.idl:95
PRTL_UNICODE_STRING_BUFFER Path
#define INTERNET_OPEN_TYPE_PRECONFIG
Definition: wininet.h:521
LPCWSTR lpParameters
Definition: shellapi.h:331
BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer, DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
Definition: internet.c:2154
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define NULL
Definition: types.h:112
#define MB_OK
Definition: winuser.h:784
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
BOOL bDelInstaller
Definition: settings.h:11
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
#define DPRINT1
Definition: precomp.h:8
#define CreateFileW
Definition: compat.h:741
Definition: misc.h:45
BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwFlags, URL_COMPONENTSW *lpUC)
Definition: internet.c:1625
#define IDS_UNABLE_PATH
Definition: resource.h:121
ATL::CStringW LoadStatusString(DownloadStatus StatusParam)
Definition: loaddlg.cpp:76
#define APPLICATION_DATABASE_NAME
Definition: defines.h:33
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1110
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
WCHAR szNoProxyFor[MAX_PATH]
Definition: settings.h:21
#define malloc
Definition: debug_ros.c:4
#define ICU_DECODE
Definition: winhttp.h:291
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define INFINITE
Definition: serial.h:102
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:979
#define memset(x, y, z)
Definition: compat.h:39
int WINAPI MessageBoxA(_In_opt_ HWND hWnd, _In_opt_ LPCSTR lpText, _In_opt_ LPCSTR lpCaption, _In_ UINT uType)
static CDownloaderProgress ProgressBar
Definition: loaddlg.cpp:382
#define INTERNET_FLAG_KEEP_CONNECTION
Definition: wininet.h:72

Referenced by DownloadDlgProc().

◆ UpdateProgress()

VOID CDownloadManager::UpdateProgress ( HWND  hDlg,
ULONG  ulProgress,
ULONG  ulProgressMax,
ULONG  ulStatusCode,
LPCWSTR  szStatusText 
)
staticprivate

Definition at line 516 of file loaddlg.cpp.

522 {
523  HWND Item;
524 
525  if (!IsWindow(hDlg)) return;
526  ProgressBar.SetProgress(ulProgress, ulProgressMax);
527 
528  if (!IsWindow(hDlg)) return;
530  if (Item && szStatusText && wcslen(szStatusText) > 0 && UrlHasBeenCopied == FALSE)
531  {
532  SIZE_T len = wcslen(szStatusText) + 1;
534  DWORD dummyLen;
535 
536  /* beautify our url for display purposes */
537  if (!InternetCanonicalizeUrlW(szStatusText, buf.GetBuffer(len), &dummyLen, ICU_DECODE | ICU_NO_ENCODE))
538  {
539  /* just use the original */
540  buf.ReleaseBuffer();
541  buf = szStatusText;
542  }
543  else
544  {
545  buf.ReleaseBuffer();
546  }
547 
548  /* paste it into our dialog and don't do it again in this instance */
549  ::SetWindowText(Item, buf.GetString());
551  }
552 }
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
VOID SetProgress(ULONG ulProgress, ULONG ulProgressMax)
Definition: loaddlg.cpp:136
BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:2004
#define IDC_DOWNLOAD_STATUS
Definition: resource.h:42
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define FALSE
Definition: types.h:117
BOOL UrlHasBeenCopied
Definition: loaddlg.cpp:514
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define ICU_NO_ENCODE
Definition: winhttp.h:290
GLenum GLsizei len
Definition: glext.h:6722
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define SetWindowText
Definition: winuser.h:5847
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_In_ WDFCOLLECTION _In_ WDFOBJECT Item
#define ICU_DECODE
Definition: winhttp.h:291
static CDownloaderProgress ProgressBar
Definition: loaddlg.cpp:382

Referenced by ThreadFunc().

Member Data Documentation

◆ AppsDownloadList

ATL::CSimpleArray< DownloadInfo > CDownloadManager::AppsDownloadList
staticprivate

Definition at line 380 of file loaddlg.cpp.

Referenced by Add(), Download(), and DownloadDlgProc().

◆ bCancelled

BOOL CDownloadManager::bCancelled = FALSE
staticprivate

Definition at line 383 of file loaddlg.cpp.

Referenced by DownloadDlgProc(), and ThreadFunc().

◆ bModal

BOOL CDownloadManager::bModal = FALSE
staticprivate

Definition at line 384 of file loaddlg.cpp.

Referenced by DownloadDlgProc(), and LaunchDownloadDialog().

◆ DownloadsListView

CDowloadingAppsListView CDownloadManager::DownloadsListView
staticprivate

Definition at line 381 of file loaddlg.cpp.

Referenced by DownloadDlgProc(), and ThreadFunc().

◆ ProgressBar

CDownloaderProgress CDownloadManager::ProgressBar
staticprivate

Definition at line 382 of file loaddlg.cpp.

Referenced by DownloadDlgProc(), ThreadFunc(), and UpdateProgress().


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