ReactOS  0.4.15-dev-3203-gacde1e0
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 360 of file loaddlg.cpp.

Member Function Documentation

◆ Add()

VOID CDownloadManager::Add ( DownloadInfo  info)
static

Definition at line 384 of file loaddlg.cpp.

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

Referenced by DownloadListOfApplications().

◆ Download()

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

Definition at line 389 of file loaddlg.cpp.

390 {
392  AppsDownloadList.Add(DLInfo);
393  LaunchDownloadDialog(bIsModal);
394 }
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
static VOID LaunchDownloadDialog(BOOL)
Definition: loaddlg.cpp:995
static ATL::CSimpleArray< DownloadInfo > AppsDownloadList
Definition: loaddlg.cpp:362

Referenced by DownloadApplication(), and DownloadApplicationsDB().

◆ DownloadDlgProc()

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

Definition at line 396 of file loaddlg.cpp.

397 {
398  static WCHAR szCaption[MAX_PATH];
399 
400  switch (uMsg)
401  {
402  case WM_INITDIALOG:
403  {
404  HICON hIconSm, hIconBg;
405  ATL::CStringW szTempCaption;
406 
407  bCancelled = FALSE;
408 
411 
412  if (hIconBg && hIconSm)
413  {
414  SendMessageW(Dlg, WM_SETICON, ICON_BIG, (LPARAM) hIconBg);
415  SendMessageW(Dlg, WM_SETICON, ICON_SMALL, (LPARAM) hIconSm);
416  }
417 
420  if (Item)
421  {
422  // initialize the default values for our nifty progress bar
423  // and subclass it so that it learns to print a status text
427  }
428 
429  // Add a ListView
430  HWND hListView = DownloadsListView.Create(Dlg);
431  if (!hListView)
432  {
433  return FALSE;
434  }
436 
437  // Get a dlg string for later use
438  GetWindowTextW(Dlg, szCaption, _countof(szCaption));
439 
440  // Hide a placeholder from displaying
441  szTempCaption = szCaption;
442  szTempCaption.Replace(L"%ls", L"");
443  SetWindowText(Dlg, szTempCaption.GetString());
444 
445  ShowWindow(Dlg, SW_SHOW);
446 
447  // Start download process
448  DownloadParam *param = new DownloadParam(Dlg, AppsDownloadList, szCaption);
449  unsigned int ThreadId;
450  HANDLE Thread = (HANDLE)_beginthreadex(NULL, 0, ThreadFunc, (void *) param, 0, &ThreadId);
451 
452  if (!Thread)
453  {
454  return FALSE;
455  }
456 
459  return TRUE;
460  }
461 
462  case WM_COMMAND:
463  if (wParam == IDCANCEL)
464  {
465  bCancelled = TRUE;
466  PostMessageW(Dlg, WM_CLOSE, 0, 0);
467  }
468  return FALSE;
469 
470  case WM_CLOSE:
472  {
473  ::EndDialog(Dlg, 0);
474  }
475  else
476  {
477  ::DestroyWindow(Dlg);
478  }
479  return TRUE;
480 
481  default:
482  return FALSE;
483  }
484 }
static HICON
Definition: imagelist.c:84
#define CloseHandle
Definition: compat.h:598
#define TRUE
Definition: types.h:120
static BOOL bCancelled
Definition: loaddlg.cpp:365
static unsigned int WINAPI ThreadFunc(LPVOID Context)
Definition: loaddlg.cpp:550
#define MAKELPARAM(l, h)
Definition: winuser.h:3984
#define PBM_SETPOS
Definition: commctrl.h:2184
static ATL::CSimpleArray< DownloadInfo > AppsDownloadList
Definition: loaddlg.cpp:362
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)
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
BOOL SubclassWindow(HWND hWnd)
Definition: atlwin.h:1486
#define FALSE
Definition: types.h:117
#define GWLP_USERDATA
Definition: treelist.c:63
LONG_PTR LPARAM
Definition: windef.h:208
static CDowloadingAppsListView DownloadsListView
Definition: loaddlg.cpp:363
#define SW_SHOW
Definition: winuser.h:769
VOID LoadList(ATL::CSimpleArray< DownloadInfo > arrInfo)
Definition: loaddlg.cpp:259
#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:1604
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
static const WCHAR L[]
Definition: oid.c:1250
#define GCLP_HICON
Definition: winuser.h:669
#define WM_COMMAND
Definition: winuser.h:1723
int Replace(PCXSTR pszOld, PCXSTR pszNew)
Definition: cstringt.h:811
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
HWND Create(HWND hwndParent)
Definition: loaddlg.cpp:245
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SetWindowText
Definition: winuser.h:5833
#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:1051
#define SetWindowLongPtrW
Definition: winuser.h:5322
#define IDCANCEL
Definition: winuser.h:825
static BOOL bModal
Definition: loaddlg.cpp:366
#define WM_INITDIALOG
Definition: winuser.h:1722
#define GetClassLongPtrW
Definition: winuser.h:4540
#define ICON_BIG
Definition: tnclass.cpp:51
static CDownloaderProgress ProgressBar
Definition: loaddlg.cpp:364

Referenced by LaunchDownloadDialog().

◆ LaunchDownloadDialog()

VOID CDownloadManager::LaunchDownloadDialog ( BOOL  bIsModal)
static

Definition at line 995 of file loaddlg.cpp.

996 {
997  CDownloadManager::bModal = bIsModal;
998  if (bIsModal)
999  {
1000  DialogBoxW(hInst,
1002  hMainWnd,
1003  DownloadDlgProc);
1004  }
1005  else
1006  {
1009  hMainWnd,
1010  DownloadDlgProc);
1011  }
1012 }
#define IDD_DOWNLOAD_DIALOG
Definition: resource.h:65
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4375
static INT_PTR CALLBACK DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: loaddlg.cpp:396
HWND hMainWnd
Definition: magnifier.c:32
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4257
HINSTANCE hInst
Definition: dxdiag.c:13
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
static BOOL bModal
Definition: loaddlg.cpp:366

Referenced by Download(), and DownloadListOfApplications().

◆ ThreadFunc()

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

Definition at line 550 of file loaddlg.cpp.

551 {
553  PWSTR p, q;
554 
555  HWND hDlg = static_cast<DownloadParam*>(param)->Dialog;
556  HWND Item;
557  INT iAppId;
558 
559  ULONG dwContentLen, dwBytesWritten, dwBytesRead, dwStatus;
560  ULONG dwCurrentBytesRead = 0;
561  ULONG dwStatusLen = sizeof(dwStatus);
562 
563  BOOL bTempfile = FALSE;
564 
565  HINTERNET hOpen = NULL;
566  HINTERNET hFile = NULL;
568 
569  unsigned char lpBuffer[4096];
570  LPCWSTR lpszAgent = L"RApps/1.1";
571  URL_COMPONENTSW urlComponents;
572  size_t urlLength, filenameLength;
573 
574  const ATL::CSimpleArray<DownloadInfo> &InfoArray = static_cast<DownloadParam*>(param)->AppInfo;
575  LPCWSTR szCaption = static_cast<DownloadParam*>(param)->szCaption;
576  ATL::CStringW szNewCaption;
577 
579 
580  if (InfoArray.GetSize() <= 0)
581  {
583  goto end;
584  }
585 
586  for (iAppId = 0; iAppId < InfoArray.GetSize(); ++iAppId)
587  {
588  // Reset progress bar
589  if (!IsWindow(hDlg)) break;
591  if (Item)
592  {
596  }
597 
598  // is this URL an update package for RAPPS? if so store it in a different place
599  if (InfoArray[iAppId].DLType != DLTYPE_APPLICATION)
600  {
602  {
604  goto end;
605  }
606  }
607  else
608  {
610  }
611 
612  // Change caption to show the currently downloaded app
613  switch(InfoArray[iAppId].DLType)
614  {
615  case DLTYPE_APPLICATION:
616  szNewCaption.Format(szCaption, InfoArray[iAppId].szName.GetString());
617  break;
618  case DLTYPE_DBUPDATE:
619  szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_DOWNLOAD_DISP);
620  break;
622  szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_UNOFFICIAL_DOWNLOAD_DISP);
623  break;
624  }
625 
626  if (!IsWindow(hDlg)) goto end;
627  SetWindowTextW(hDlg, szNewCaption.GetString());
628 
629  // build the path for the download
630  p = wcsrchr(InfoArray[iAppId].szUrl.GetString(), L'/');
631  q = wcsrchr(InfoArray[iAppId].szUrl.GetString(), L'?');
632 
633  // do we have a final slash separator?
634  if (!p)
635  {
637  goto end;
638  }
639 
640  // prepare the tentative length of the filename, maybe we've to remove part of it later on
641  filenameLength = wcslen(p) * sizeof(WCHAR);
642 
643  /* do we have query arguments in the target URL after the filename? account for them
644  (e.g. https://example.org/myfile.exe?no_adware_plz) */
645  if (q && q > p && (q - p) > 0)
646  filenameLength -= wcslen(q - 1) * sizeof(WCHAR);
647 
648  // is the path valid? can we access it?
649  if (GetFileAttributesW(Path.GetString()) == INVALID_FILE_ATTRIBUTES)
650  {
651  if (!CreateDirectoryW(Path.GetString(), NULL))
652  {
654  goto end;
655  }
656  }
657 
658  // append a \ to the provided file system path, and the filename portion from the URL after that
659 
660  PathAddBackslashW(Path.GetBuffer(MAX_PATH));
661  switch (InfoArray[iAppId].DLType)
662  {
663  case DLTYPE_DBUPDATE:
666  break;
667  case DLTYPE_APPLICATION:
668  PathAppendW(Path.GetBuffer(), (LPWSTR)(p + 1)); // use the filename retrieved from URL
669  break;
670  }
671  Path.ReleaseBuffer();
672 
673  if ((InfoArray[iAppId].DLType == DLTYPE_APPLICATION) && InfoArray[iAppId].szSHA1[0] && GetFileAttributesW(Path.GetString()) != INVALID_FILE_ATTRIBUTES)
674  {
675  // only open it in case of total correctness
676  if (VerifyInteg(InfoArray[iAppId].szSHA1.GetString(), Path))
677  goto run;
678  }
679 
680  // Add the download URL
681  if (!IsWindow(hDlg)) goto end;
682  SetDlgItemTextW(hDlg, IDC_DOWNLOAD_STATUS, InfoArray[iAppId].szUrl.GetString());
683 
685 
686  // download it
688  bTempfile = TRUE;
689 
690  /* FIXME: this should just be using the system-wide proxy settings */
691  switch (SettingsInfo.Proxy)
692  {
693  case 0: // preconfig
694  default:
695  hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
696  break;
697  case 1: // direct (no proxy)
698  hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
699  break;
700  case 2: // use proxy
702  break;
703  }
704 
705  if (!hOpen)
706  {
708  goto end;
709  }
710 
711  dwStatusLen = sizeof(dwStatus);
712 
713  memset(&urlComponents, 0, sizeof(urlComponents));
714  urlComponents.dwStructSize = sizeof(urlComponents);
715 
716  urlLength = InfoArray[iAppId].szUrl.GetLength();
717  urlComponents.dwSchemeLength = urlLength + 1;
718  urlComponents.lpszScheme = (LPWSTR) malloc(urlComponents.dwSchemeLength * sizeof(WCHAR));
719 
720  if (!InternetCrackUrlW(InfoArray[iAppId].szUrl, urlLength + 1, ICU_DECODE | ICU_ESCAPE, &urlComponents))
721  {
723  goto end;
724  }
725 
726  dwContentLen = 0;
727 
728  if (urlComponents.nScheme == INTERNET_SCHEME_HTTP ||
729  urlComponents.nScheme == INTERNET_SCHEME_HTTPS)
730  {
731  hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL, 0,
732  dwUrlConnectFlags,
733  0);
734  if (!hFile)
735  {
737  {
738  /* Workaround for CORE-17377 */
740  }
741  goto end;
742  }
743 
744  // query connection
746  {
748  goto end;
749  }
750 
751  if (dwStatus != HTTP_STATUS_OK)
752  {
754  goto end;
755  }
756 
757  // query content length
759  }
760  else if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
761  {
762  // force passive mode on FTP
763  hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl, NULL, 0,
764  dwUrlConnectFlags | INTERNET_FLAG_PASSIVE,
765  0);
766  if (!hFile)
767  {
769  {
770  /* Workaround for CORE-17377 */
772  }
773  goto end;
774  }
775 
776  dwContentLen = FtpGetFileSize(hFile, &dwStatus);
777  }
778  else if (urlComponents.nScheme == INTERNET_SCHEME_FILE)
779  {
780  // Add support for the file scheme so testing locally is simpler
781  WCHAR LocalFilePath[MAX_PATH];
782  DWORD cchPath = _countof(LocalFilePath);
783  // Ideally we would use PathCreateFromUrlAlloc here, but that is not exported (yet)
784  HRESULT hr = PathCreateFromUrlW(InfoArray[iAppId].szUrl, LocalFilePath, &cchPath, 0);
785  if (SUCCEEDED(hr))
786  {
787  if (CopyFileW(LocalFilePath, Path, FALSE))
788  {
789  goto run;
790  }
791  else
792  {
794  goto end;
795  }
796  }
797  else
798  {
800  goto end;
801  }
802  }
803 
804  if (!dwContentLen)
805  {
806  // Someone was nice enough to add this, let's use it
807  if (InfoArray[iAppId].SizeInBytes)
808  {
809  dwContentLen = InfoArray[iAppId].SizeInBytes;
810  }
811  else
812  {
813  // content-length is not known, enable marquee mode
815  }
816  }
817 
818  free(urlComponents.lpszScheme);
819 
820 #ifdef USE_CERT_PINNING
821  // are we using HTTPS to download the RAPPS update package? check if the certificate is original
822  if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) &&
823  (InfoArray[iAppId].DLType == DLTYPE_DBUPDATE))
824  {
825  CLocalPtr<char> subjectName, issuerName;
826  CStringA szMsgText;
827  bool bAskQuestion = false;
828  if (!CertGetSubjectAndIssuer(hFile, subjectName, issuerName))
829  {
830  szMsgText.LoadStringW(IDS_UNABLE_TO_QUERY_CERT);
831  bAskQuestion = true;
832  }
833  else
834  {
835  if (strcmp(subjectName, CERT_SUBJECT_INFO) ||
836  (strcmp(issuerName, CERT_ISSUER_INFO_OLD) &&
837  strcmp(issuerName, CERT_ISSUER_INFO_NEW)))
838  {
839  szMsgText.Format(IDS_MISMATCH_CERT_INFO, (char*)subjectName, (const char*)issuerName);
840  bAskQuestion = true;
841  }
842  }
843 
844  if (bAskQuestion)
845  {
846  if (MessageBoxA(hMainWnd, szMsgText.GetString(), NULL, MB_YESNO | MB_ICONERROR) != IDYES)
847  {
848  goto end;
849  }
850  }
851  }
852 #endif
853 
855 
856  if (hOut == INVALID_HANDLE_VALUE)
857  {
859  goto end;
860  }
861 
862  dwCurrentBytesRead = 0;
863  do
864  {
865  if (!InternetReadFile(hFile, lpBuffer, _countof(lpBuffer), &dwBytesRead))
866  {
868  goto end;
869  }
870 
871  if (!WriteFile(hOut, &lpBuffer[0], dwBytesRead, &dwBytesWritten, NULL))
872  {
874  goto end;
875  }
876 
877  dwCurrentBytesRead += dwBytesRead;
878  if (!IsWindow(hDlg)) goto end;
879  UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString());
880  } while (dwBytesRead && !bCancelled);
881 
882  CloseHandle(hOut);
883  hOut = INVALID_HANDLE_VALUE;
884 
885  if (bCancelled)
886  {
887  DPRINT1("Operation cancelled\n");
888  goto end;
889  }
890 
891  if (!dwContentLen)
892  {
893  // set progress bar to 100%
895 
896  dwContentLen = dwCurrentBytesRead;
897  if (!IsWindow(hDlg)) goto end;
898  UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString());
899  }
900 
901  /* if this thing isn't a RAPPS update and it has a SHA-1 checksum
902  verify its integrity by using the native advapi32.A_SHA1 functions */
903  if ((InfoArray[iAppId].DLType == DLTYPE_APPLICATION) && InfoArray[iAppId].szSHA1[0] != 0)
904  {
905  ATL::CStringW szMsgText;
906 
907  // change a few strings in the download dialog to reflect the verification process
908  if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_TITLE))
909  {
910  DPRINT1("Unable to load string\n");
911  goto end;
912  }
913 
914  if (!IsWindow(hDlg)) goto end;
915  SetWindowTextW(hDlg, szMsgText.GetString());
917 
918  // this may take a while, depending on the file size
919  if (!VerifyInteg(InfoArray[iAppId].szSHA1.GetString(), Path.GetString()))
920  {
921  if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_FAIL))
922  {
923  DPRINT1("Unable to load string\n");
924  goto end;
925  }
926 
927  if (!IsWindow(hDlg)) goto end;
928  MessageBoxW(hDlg, szMsgText.GetString(), NULL, MB_OK | MB_ICONERROR);
929  goto end;
930  }
931  }
932 
933 run:
935 
936  // run it
937  if (InfoArray[iAppId].DLType == DLTYPE_APPLICATION)
938  {
939  SHELLEXECUTEINFOW shExInfo = {0};
940  shExInfo.cbSize = sizeof(shExInfo);
941  shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
942  shExInfo.lpVerb = L"open";
943  shExInfo.lpFile = Path.GetString();
944  shExInfo.lpParameters = L"";
945  shExInfo.nShow = SW_SHOW;
946 
947  /* FIXME: Do we want to log installer status? */
948  WriteLogMessage(EVENTLOG_SUCCESS, MSG_SUCCESS_INSTALL, InfoArray[iAppId].szName);
949 
950  if (ShellExecuteExW(&shExInfo))
951  {
952  //reflect installation progress in the titlebar
953  //TODO: make a separate string with a placeholder to include app name?
955  if (!IsWindow(hDlg)) goto end;
956  SetWindowTextW(hDlg, szMsgText.GetString());
957 
959 
960  //TODO: issue an install operation separately so that the apps could be downloaded in the background
962  CloseHandle(shExInfo.hProcess);
963  }
964  else
965  {
967  }
968  }
969 
970 end:
971  if (hOut != INVALID_HANDLE_VALUE)
972  CloseHandle(hOut);
973 
974  if (hFile)
976  InternetCloseHandle(hOpen);
977 
978  if (bTempfile)
979  {
980  if (bCancelled || (SettingsInfo.bDelInstaller && (InfoArray[iAppId].DLType == DLTYPE_APPLICATION)))
981  DeleteFileW(Path.GetString());
982  }
983 
984  if (!IsWindow(hDlg)) return 0;
986  }
987 
988  delete static_cast<DownloadParam*>(param);
989  if (!IsWindow(hDlg)) return 0;
990  SendMessageW(hDlg, WM_CLOSE, 0, 0);
991  return 0;
992 }
#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
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:218
#define CloseHandle
Definition: compat.h:598
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:365
#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:526
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
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)
#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
int WINAPI MessageBoxA(_In_opt_ HWND, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_ UINT)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
VOID MessageBox_LoadString(HWND hMainWnd, INT StringID)
Definition: loaddlg.cpp:350
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
LONG_PTR LPARAM
Definition: windef.h:208
static CDowloadingAppsListView DownloadsListView
Definition: loaddlg.cpp:363
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2263
BOOL UrlHasBeenCopied
Definition: loaddlg.cpp:486
#define SW_SHOW
Definition: winuser.h:769
#define WM_SETTEXT
Definition: winuser.h:1600
#define ICU_ESCAPE
Definition: winhttp.h:48
VOID SetDownloadStatus(INT ItemIndex, DownloadStatus Status)
Definition: loaddlg.cpp:267
#define EVENTLOG_SUCCESS
Definition: winnt_old.h:2753
BOOL WriteLogMessage(WORD wType, DWORD dwEventID, LPCWSTR lpMsg)
Definition: misc.cpp:248
LPWSTR lpszScheme
Definition: wininet.h:212
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:20
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
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:1604
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:180
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#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:488
#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
static const WCHAR L[]
Definition: oid.c:1250
#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:219
#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:600
Definition: misc.h:55
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
static const WCHAR szName[]
Definition: msipriv.h:1194
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:1051
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
static CDownloaderProgress ProgressBar
Definition: loaddlg.cpp:364
#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 488 of file loaddlg.cpp.

494 {
495  HWND Item;
496 
497  if (!IsWindow(hDlg)) return;
498  ProgressBar.SetProgress(ulProgress, ulProgressMax);
499 
500  if (!IsWindow(hDlg)) return;
502  if (Item && szStatusText && wcslen(szStatusText) > 0 && UrlHasBeenCopied == FALSE)
503  {
504  SIZE_T len = wcslen(szStatusText) + 1;
506  DWORD dummyLen;
507 
508  /* beautify our url for display purposes */
509  if (!InternetCanonicalizeUrlW(szStatusText, buf.GetBuffer(len), &dummyLen, ICU_DECODE | ICU_NO_ENCODE))
510  {
511  /* just use the original */
512  buf.ReleaseBuffer();
513  buf = szStatusText;
514  }
515  else
516  {
517  buf.ReleaseBuffer();
518  }
519 
520  /* paste it into our dialog and don't do it again in this instance */
521  SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) buf.GetString());
523  }
524 }
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
LONG_PTR LPARAM
Definition: windef.h:208
BOOL UrlHasBeenCopied
Definition: loaddlg.cpp:486
#define WM_SETTEXT
Definition: winuser.h:1600
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
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
_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:364

Referenced by ThreadFunc().

Member Data Documentation

◆ AppsDownloadList

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

Definition at line 362 of file loaddlg.cpp.

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

◆ bCancelled

BOOL CDownloadManager::bCancelled = FALSE
staticprivate

Definition at line 365 of file loaddlg.cpp.

Referenced by DownloadDlgProc(), and ThreadFunc().

◆ bModal

BOOL CDownloadManager::bModal = FALSE
staticprivate

Definition at line 366 of file loaddlg.cpp.

Referenced by DownloadDlgProc(), and LaunchDownloadDialog().

◆ DownloadsListView

CDowloadingAppsListView CDownloadManager::DownloadsListView
staticprivate

Definition at line 363 of file loaddlg.cpp.

Referenced by DownloadDlgProc(), and ThreadFunc().

◆ ProgressBar

CDownloaderProgress CDownloadManager::ProgressBar
staticprivate

Definition at line 364 of file loaddlg.cpp.

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


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