ReactOS  0.4.15-dev-4934-gfd1e799
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:1001
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 
409  if (hMainWnd)
410  {
413  }
414  if (!hMainWnd || (!hIconBg || !hIconSm))
415  {
416  /* Load the default icon */
418  }
419 
420  if (hIconBg && hIconSm)
421  {
422  SendMessageW(Dlg, WM_SETICON, ICON_BIG, (LPARAM)hIconBg);
423  SendMessageW(Dlg, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);
424  }
425 
427  if (Item)
428  {
429  // initialize the default values for our nifty progress bar
430  // and subclass it so that it learns to print a status text
434  }
435 
436  // Add a ListView
437  HWND hListView = DownloadsListView.Create(Dlg);
438  if (!hListView)
439  {
440  return FALSE;
441  }
443 
444  // Get a dlg string for later use
445  GetWindowTextW(Dlg, szCaption, _countof(szCaption));
446 
447  // Hide a placeholder from displaying
448  szTempCaption = szCaption;
449  szTempCaption.Replace(L"%ls", L"");
450  SetWindowText(Dlg, szTempCaption.GetString());
451 
452  ShowWindow(Dlg, SW_SHOW);
453 
454  // Start download process
455  DownloadParam *param = new DownloadParam(Dlg, AppsDownloadList, szCaption);
456  unsigned int ThreadId;
457  HANDLE Thread = (HANDLE)_beginthreadex(NULL, 0, ThreadFunc, (void *) param, 0, &ThreadId);
458  if (!Thread)
459  {
460  return FALSE;
461  }
462 
465  return TRUE;
466  }
467 
468  case WM_COMMAND:
469  if (wParam == IDCANCEL)
470  {
471  bCancelled = TRUE;
472  PostMessageW(Dlg, WM_CLOSE, 0, 0);
473  }
474  return FALSE;
475 
476  case WM_CLOSE:
478  {
479  ::EndDialog(Dlg, 0);
480  }
481  else
482  {
483  ::DestroyWindow(Dlg);
484  }
485  return TRUE;
486 
487  default:
488  return FALSE;
489  }
490 }
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:556
#define MAKELPARAM(l, h)
Definition: winuser.h:3988
#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
#define L(x)
Definition: ntvdm.h:50
BOOL SubclassWindow(HWND hWnd)
Definition: atlwin.h:1518
#define FALSE
Definition: types.h:117
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:1608
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:1727
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:245
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SetWindowText
Definition: winuser.h:5837
#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:1082
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:366
#define WM_INITDIALOG
Definition: winuser.h:1726
#define GetClassLongPtrW
Definition: winuser.h:4544
#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 1001 of file loaddlg.cpp.

1002 {
1003  CDownloadManager::bModal = bIsModal;
1004  if (bIsModal)
1005  {
1006  DialogBoxW(hInst,
1008  hMainWnd,
1009  DownloadDlgProc);
1010  }
1011  else
1012  {
1015  hMainWnd,
1016  DownloadDlgProc);
1017  }
1018 }
#define IDD_DOWNLOAD_DIALOG
Definition: resource.h:65
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4379
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:4261
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 556 of file loaddlg.cpp.

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

500 {
501  HWND Item;
502 
503  if (!IsWindow(hDlg)) return;
504  ProgressBar.SetProgress(ulProgress, ulProgressMax);
505 
506  if (!IsWindow(hDlg)) return;
508  if (Item && szStatusText && wcslen(szStatusText) > 0 && UrlHasBeenCopied == FALSE)
509  {
510  SIZE_T len = wcslen(szStatusText) + 1;
512  DWORD dummyLen;
513 
514  /* beautify our url for display purposes */
515  if (!InternetCanonicalizeUrlW(szStatusText, buf.GetBuffer(len), &dummyLen, ICU_DECODE | ICU_NO_ENCODE))
516  {
517  /* just use the original */
518  buf.ReleaseBuffer();
519  buf = szStatusText;
520  }
521  else
522  {
523  buf.ReleaseBuffer();
524  }
525 
526  /* paste it into our dialog and don't do it again in this instance */
527  SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) buf.GetString());
529  }
530 }
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:492
#define WM_SETTEXT
Definition: winuser.h:1604
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: