ReactOS  0.4.14-dev-52-g6116262
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 DWORD 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< DownloadInfoAppsToInstallList
 
static CDowloadingAppsListView DownloadsListView
 
static CDownloaderProgress ProgressBar
 
static BOOL bCancelled
 

Detailed Description

Definition at line 342 of file loaddlg.cpp.

Member Function Documentation

◆ Add()

VOID CDownloadManager::Add ( DownloadInfo  info)
static

Definition at line 364 of file loaddlg.cpp.

365 {
367 }
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
static ATL::CSimpleArray< DownloadInfo > AppsToInstallList
Definition: loaddlg.cpp:344

Referenced by DownloadListOfApplications().

◆ Download()

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

Definition at line 369 of file loaddlg.cpp.

370 {
372  AppsToInstallList.Add(DLInfo);
373  LaunchDownloadDialog(bIsModal);
374 }
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
static VOID LaunchDownloadDialog(BOOL)
Definition: loaddlg.cpp:848
static ATL::CSimpleArray< DownloadInfo > AppsToInstallList
Definition: loaddlg.cpp:344

Referenced by DownloadApplication(), and DownloadApplicationsDB().

◆ DownloadDlgProc()

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

Definition at line 376 of file loaddlg.cpp.

377 {
378  static WCHAR szCaption[MAX_PATH];
379 
380  switch (uMsg)
381  {
382  case WM_INITDIALOG:
383  {
384  HICON hIconSm, hIconBg;
385  ATL::CStringW szTempCaption;
386 
387  bCancelled = FALSE;
388 
391 
392  if (hIconBg && hIconSm)
393  {
394  SendMessageW(Dlg, WM_SETICON, ICON_BIG, (LPARAM) hIconBg);
395  SendMessageW(Dlg, WM_SETICON, ICON_SMALL, (LPARAM) hIconSm);
396  }
397 
398  SetWindowLongW(Dlg, GWLP_USERDATA, 0);
400  if (Item)
401  {
402  // initialize the default values for our nifty progress bar
403  // and subclass it so that it learns to print a status text
407  }
408 
409  // Add a ListView
410  HWND hListView = DownloadsListView.Create(Dlg);
411  if (!hListView)
412  {
413  return FALSE;
414  }
416 
417  // Get a dlg string for later use
418  GetWindowTextW(Dlg, szCaption, _countof(szCaption));
419 
420  // Hide a placeholder from displaying
421  szTempCaption = szCaption;
422  szTempCaption.Replace(L"%ls", L"");
423  SetWindowText(Dlg, szTempCaption.GetString());
424 
425  ShowWindow(Dlg, SW_SHOW);
426 
427  // Start download process
428  DownloadParam *param = new DownloadParam(Dlg, AppsToInstallList, szCaption);
429  DWORD ThreadId;
430  HANDLE Thread = CreateThread(NULL, 0, ThreadFunc, (LPVOID) param, 0, &ThreadId);
431 
432  if (!Thread)
433  {
434  return FALSE;
435  }
436 
439  return TRUE;
440  }
441 
442  case WM_COMMAND:
443  if (wParam == IDCANCEL)
444  {
445  bCancelled = TRUE;
446  PostMessageW(Dlg, WM_CLOSE, 0, 0);
447  }
448  return FALSE;
449 
450  case WM_CLOSE:
451  EndDialog(Dlg, 0);
452  //DestroyWindow(Dlg);
453  return TRUE;
454 
455  default:
456  return FALSE;
457  }
458 }
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
static BOOL bCancelled
Definition: loaddlg.cpp:347
#define _countof(array)
Definition: fontsub.cpp:30
#define MAKELPARAM(l, h)
Definition: winuser.h:3947
#define PBM_SETPOS
Definition: commctrl.h:2156
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
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:2155
BOOL SubclassWindow(HWND hWnd)
Definition: atlwin.h:1482
LONG WINAPI SetWindowLongW(_In_ HWND, _In_ int, _In_ LONG)
#define GWLP_USERDATA
Definition: treelist.c:63
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:136
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
static CDowloadingAppsListView DownloadsListView
Definition: loaddlg.cpp:345
#define SW_SHOW
Definition: winuser.h:769
VOID LoadList(ATL::CSimpleArray< DownloadInfo > arrInfo)
Definition: loaddlg.cpp:239
#define GCLP_HICONSM
Definition: winuser.h:670
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WM_CLOSE
Definition: winuser.h:1603
GLfloat param
Definition: glext.h:5796
#define MAX_PATH
Definition: compat.h:26
PCXSTR GetString() const
Definition: atlsimpstr.h:361
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_opt_ PFILE_OBJECT _In_opt_ PETHREAD Thread
Definition: fltkernel.h:2653
#define IDC_DOWNLOAD_PROGRESS
Definition: resource.h:40
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:1722
static ATL::CSimpleArray< DownloadInfo > AppsToInstallList
Definition: loaddlg.cpp:344
int Replace(PCXSTR pszOld, PCXSTR pszNew)
Definition: cstringt.h:696
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1408
HWND Create(HWND hwndParent)
Definition: loaddlg.cpp:225
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static DWORD WINAPI ThreadFunc(LPVOID Context)
Definition: loaddlg.cpp:498
#define SetWindowText
Definition: winuser.h:5758
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:1048
#define IDCANCEL
Definition: winuser.h:825
#define WM_INITDIALOG
Definition: winuser.h:1721
#define GetClassLongPtrW
Definition: winuser.h:4465
#define ICON_BIG
Definition: tnclass.cpp:51
static CDownloaderProgress ProgressBar
Definition: loaddlg.cpp:346

Referenced by LaunchDownloadDialog().

◆ LaunchDownloadDialog()

VOID CDownloadManager::LaunchDownloadDialog ( BOOL  bIsModal)
static

Definition at line 848 of file loaddlg.cpp.

849 {
850  if (bIsModal)
851  {
854  hMainWnd,
856  }
857  else
858  {
861  hMainWnd,
863  }
864 }
#define IDD_DOWNLOAD_DIALOG
Definition: resource.h:61
#define DialogBoxW(i, t, p, f)
Definition: winuser.h:4300
static INT_PTR CALLBACK DownloadDlgProc(HWND Dlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: loaddlg.cpp:376
HWND hMainWnd
Definition: magnifier.c:32
#define CreateDialogW(h, n, w, f)
Definition: winuser.h:4182
HINSTANCE hInst
Definition: dxdiag.c:13
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by Download(), and DownloadListOfApplications().

◆ ThreadFunc()

DWORD WINAPI CDownloadManager::ThreadFunc ( LPVOID  Context)
static

Definition at line 498 of file loaddlg.cpp.

499 {
501  PWSTR p, q;
502 
503  HWND hDlg = static_cast<DownloadParam*>(param)->Dialog;
504  HWND Item;
505  INT iAppId;
506 
507  ULONG dwContentLen, dwBytesWritten, dwBytesRead, dwStatus;
508  ULONG dwCurrentBytesRead = 0;
509  ULONG dwStatusLen = sizeof(dwStatus);
510 
511  BOOL bTempfile = FALSE;
512  BOOL bCab = FALSE;
513 
514  HINTERNET hOpen = NULL;
515  HINTERNET hFile = NULL;
517 
518  unsigned char lpBuffer[4096];
519  LPCWSTR lpszAgent = L"RApps/1.0";
520  URL_COMPONENTS urlComponents;
521  size_t urlLength, filenameLength;
522 
523  const ATL::CSimpleArray<DownloadInfo> &InfoArray = static_cast<DownloadParam*>(param)->AppInfo;
524  LPCWSTR szCaption = static_cast<DownloadParam*>(param)->szCaption;
525  ATL::CStringW szNewCaption;
526 
528 
529  if (InfoArray.GetSize() <= 0)
530  {
532  goto end;
533  }
534 
535  for (iAppId = 0; iAppId < InfoArray.GetSize(); ++iAppId)
536  {
537  // Reset progress bar
538  Item = GetDlgItem(hDlg, IDC_DOWNLOAD_PROGRESS);
539  if (Item)
540  {
544  }
545 
546  // is this URL an update package for RAPPS? if so store it in a different place
547  if (InfoArray[iAppId].szUrl == APPLICATION_DATABASE_URL)
548  {
549  bCab = TRUE;
551  goto end;
552  }
553  else
554  {
555  bCab = FALSE;
557  }
558 
559  // Change caption to show the currently downloaded app
560  if (!bCab)
561  {
562  szNewCaption.Format(szCaption, InfoArray[iAppId].szName.GetString());
563  }
564  else
565  {
566  szNewCaption.LoadStringW(IDS_DL_DIALOG_DB_DOWNLOAD_DISP);
567  }
568 
569  SetWindowTextW(hDlg, szNewCaption.GetString());
570 
571  // build the path for the download
572  p = wcsrchr(InfoArray[iAppId].szUrl.GetString(), L'/');
573  q = wcsrchr(InfoArray[iAppId].szUrl.GetString(), L'?');
574 
575  // do we have a final slash separator?
576  if (!p)
577  goto end;
578 
579  // prepare the tentative length of the filename, maybe we've to remove part of it later on
580  filenameLength = wcslen(p) * sizeof(WCHAR);
581 
582  /* do we have query arguments in the target URL after the filename? account for them
583  (e.g. https://example.org/myfile.exe?no_adware_plz) */
584  if (q && q > p && (q - p) > 0)
585  filenameLength -= wcslen(q - 1) * sizeof(WCHAR);
586 
587  // is the path valid? can we access it?
588  if (GetFileAttributesW(Path.GetString()) == INVALID_FILE_ATTRIBUTES)
589  {
590  if (!CreateDirectoryW(Path.GetString(), NULL))
591  goto end;
592  }
593 
594  // append a \ to the provided file system path, and the filename portion from the URL after that
595  Path += L"\\";
596  Path += (LPWSTR) (p + 1);
597 
598  if (!bCab && InfoArray[iAppId].szSHA1[0] && GetFileAttributesW(Path.GetString()) != INVALID_FILE_ATTRIBUTES)
599  {
600  // only open it in case of total correctness
601  if (VerifyInteg(InfoArray[iAppId].szSHA1.GetString(), Path))
602  goto run;
603  }
604 
605  // Add the download URL
606  SetDlgItemTextW(hDlg, IDC_DOWNLOAD_STATUS, InfoArray[iAppId].szUrl.GetString());
607 
609 
610  // download it
612  bTempfile = TRUE;
613 
614  /* FIXME: this should just be using the system-wide proxy settings */
615  switch (SettingsInfo.Proxy)
616  {
617  case 0: // preconfig
618  default:
619  hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
620  break;
621  case 1: // direct (no proxy)
622  hOpen = InternetOpenW(lpszAgent, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
623  break;
624  case 2: // use proxy
626  break;
627  }
628 
629  if (!hOpen)
630  goto end;
631 
632  dwStatusLen = sizeof(dwStatus);
633 
634  memset(&urlComponents, 0, sizeof(urlComponents));
635  urlComponents.dwStructSize = sizeof(urlComponents);
636 
637  urlLength = InfoArray[iAppId].szUrl.GetLength();
638  urlComponents.dwSchemeLength = urlLength + 1;
639  urlComponents.lpszScheme = (LPWSTR) malloc(urlComponents.dwSchemeLength * sizeof(WCHAR));
640  urlComponents.dwHostNameLength = urlLength + 1;
641  urlComponents.lpszHostName = (LPWSTR) malloc(urlComponents.dwHostNameLength * sizeof(WCHAR));
642 
643  if (!InternetCrackUrlW(InfoArray[iAppId].szUrl, urlLength + 1, ICU_DECODE | ICU_ESCAPE, &urlComponents))
644  goto end;
645 
646  dwContentLen = 0;
647 
648  if (urlComponents.nScheme == INTERNET_SCHEME_HTTP || urlComponents.nScheme == INTERNET_SCHEME_HTTPS)
649  {
650  hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL, 0,
651  dwUrlConnectFlags,
652  0);
653  if (!hFile)
654  {
656  goto end;
657  }
658 
659  // query connection
661  goto end;
662 
663  if (dwStatus != HTTP_STATUS_OK)
664  {
666  goto end;
667  }
668 
669  // query content length
671  }
672 
673  if (urlComponents.nScheme == INTERNET_SCHEME_FTP)
674  {
675  // force passive mode on FTP
676  hFile = InternetOpenUrlW(hOpen, InfoArray[iAppId].szUrl.GetString(), NULL, 0,
677  dwUrlConnectFlags | INTERNET_FLAG_PASSIVE,
678  0);
679  if (!hFile)
680  {
682  goto end;
683  }
684 
685  dwContentLen = FtpGetFileSize(hFile, &dwStatus);
686  }
687 
688  if (!dwContentLen)
689  {
690  // content-length is not known, enable marquee mode
692  }
693 
694  free(urlComponents.lpszScheme);
695  free(urlComponents.lpszHostName);
696 
697 #ifdef USE_CERT_PINNING
698  // are we using HTTPS to download the RAPPS update package? check if the certificate is original
699  if ((urlComponents.nScheme == INTERNET_SCHEME_HTTPS) &&
700  (wcscmp(InfoArray[iAppId].szUrl, APPLICATION_DATABASE_URL) == 0))
701  {
702  CLocalPtr subjectName, issuerName;
703  CStringW szMsgText;
704  bool bAskQuestion = false;
705  if (!CertGetSubjectAndIssuer(hFile, subjectName, issuerName))
706  {
707  szMsgText.LoadStringW(IDS_UNABLE_TO_QUERY_CERT);
708  bAskQuestion = true;
709  }
710  else
711  {
712  if (strcmp(subjectName, CERT_SUBJECT_INFO) ||
713  strcmp(issuerName, CERT_ISSUER_INFO))
714  {
715  szMsgText.Format(IDS_MISMATCH_CERT_INFO, (char*)subjectName, (const char*)issuerName);
716  bAskQuestion = true;
717  }
718  }
719 
720  if (bAskQuestion)
721  {
722  if (MessageBoxW(hMainWnd, szMsgText.GetString(), NULL, MB_YESNO | MB_ICONERROR) != IDYES)
723  {
724  goto end;
725  }
726  }
727  }
728 #endif
729 
731 
732  if (hOut == INVALID_HANDLE_VALUE)
733  goto end;
734 
735  dwCurrentBytesRead = 0;
736  do
737  {
738  if (!InternetReadFile(hFile, lpBuffer, _countof(lpBuffer), &dwBytesRead))
739  {
741  goto end;
742  }
743 
744  if (!WriteFile(hOut, &lpBuffer[0], dwBytesRead, &dwBytesWritten, NULL))
745  {
747  goto end;
748  }
749 
750  dwCurrentBytesRead += dwBytesRead;
751  UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString());
752  } while (dwBytesRead && !bCancelled);
753 
754  CloseHandle(hOut);
755  hOut = INVALID_HANDLE_VALUE;
756 
757  if (bCancelled)
758  goto end;
759 
760  if (!dwContentLen)
761  {
762  // set progress bar to 100%
764 
765  dwContentLen = dwCurrentBytesRead;
766  UpdateProgress(hDlg, dwCurrentBytesRead, dwContentLen, 0, InfoArray[iAppId].szUrl.GetString());
767  }
768 
769  /* if this thing isn't a RAPPS update and it has a SHA-1 checksum
770  verify its integrity by using the native advapi32.A_SHA1 functions */
771  if (!bCab && InfoArray[iAppId].szSHA1[0] != 0)
772  {
773  ATL::CStringW szMsgText;
774 
775  // change a few strings in the download dialog to reflect the verification process
776  if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_TITLE))
777  goto end;
778 
779  SetWindowTextW(hDlg, szMsgText.GetString());
781 
782  // this may take a while, depending on the file size
783  if (!VerifyInteg(InfoArray[iAppId].szSHA1.GetString(), Path.GetString()))
784  {
785  if (!szMsgText.LoadStringW(IDS_INTEG_CHECK_FAIL))
786  goto end;
787 
788  MessageBoxW(hDlg, szMsgText.GetString(), NULL, MB_OK | MB_ICONERROR);
789  goto end;
790  }
791  }
792 
793 run:
795 
796  // run it
797  if (!bCab)
798  {
799  SHELLEXECUTEINFOW shExInfo = {0};
800  shExInfo.cbSize = sizeof(shExInfo);
801  shExInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
802  shExInfo.lpVerb = L"open";
803  shExInfo.lpFile = Path.GetString();
804  shExInfo.lpParameters = L"";
805  shExInfo.nShow = SW_SHOW;
806 
807  if (ShellExecuteExW(&shExInfo))
808  {
809  //reflect installation progress in the titlebar
810  //TODO: make a separate string with a placeholder to include app name?
812  SetWindowTextW(hDlg, szMsgText.GetString());
813 
815 
816  //TODO: issue an install operation separately so that the apps could be downloaded in the background
818  CloseHandle(shExInfo.hProcess);
819  }
820  else
821  {
823  }
824  }
825 
826 end:
827  if (hOut != INVALID_HANDLE_VALUE)
828  CloseHandle(hOut);
829 
831  InternetCloseHandle(hOpen);
832 
833  if (bTempfile)
834  {
835  if (bCancelled || (SettingsInfo.bDelInstaller && !bCab))
836  DeleteFileW(Path.GetString());
837  }
838 
840  }
841 
842  delete static_cast<DownloadParam*>(param);
843  SendMessageW(hDlg, WM_CLOSE, 0, 0);
844  return 0;
845 }
#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
DWORD dwHostNameLength
Definition: winhttp.h:470
#define IDS_DL_DIALOG_DB_DOWNLOAD_DISP
Definition: resource.h:207
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define APPLICATION_DATABASE_URL
Definition: defines.h:32
BOOL VerifyInteg(LPCWSTR lpSHA1Hash, LPCWSTR lpFileName)
Definition: integrity.cpp:14
#define IDYES
Definition: winuser.h:829
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
#define SEE_MASK_NOCLOSEPROCESS
Definition: shellapi.h:31
static BYTE subjectName[]
Definition: cert.c:63
uint16_t * PWSTR
Definition: typedefs.h:54
static BOOL bCancelled
Definition: loaddlg.cpp:347
#define _countof(array)
Definition: fontsub.cpp:30
#define free
Definition: debug_ros.c:5
#define IDS_MISMATCH_CERT_INFO
Definition: resource.h:115
#define INTERNET_OPEN_TYPE_PROXY
Definition: wininet.h:523
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define IDS_UNABLE_TO_WRITE
Definition: resource.h:110
void __cdecl Format(UINT nFormatID,...)
Definition: cstringt.h:668
#define PBM_SETPOS
Definition: commctrl.h:2156
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1437
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
GLuint GLuint end
Definition: gl.h:1545
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define IDS_UNABLE_TO_DOWNLOAD
Definition: resource.h:104
int GetSize() const
Definition: atlsimpcoll.h:104
#define INTERNET_FLAG_DONT_CACHE
Definition: wininet.h:67
int32_t INT
Definition: typedefs.h:56
#define FILE_SHARE_READ
Definition: compat.h:125
#define IDC_DOWNLOAD_STATUS
Definition: resource.h:41
WCHAR szDownloadDir[MAX_PATH]
Definition: winmain.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:3608
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
DWORD dwSchemeLength
Definition: winhttp.h:467
VOID MessageBox_LoadString(HWND hMainWnd, INT StringID)
Definition: loaddlg.cpp:332
#define MB_YESNO
Definition: winuser.h:811
DWORD WINAPI FtpGetFileSize(HINTERNET hFile, LPDWORD lpdwFileSizeHigh)
Definition: ftp.c:1754
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define GENERIC_WRITE
Definition: nt_native.h:90
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:173
#define IDS_INTEG_CHECK_FAIL
Definition: resource.h:108
BOOL WINAPI DeleteFileW(IN LPCWSTR lpFileName)
Definition: delete.c:39
smooth NULL
Definition: ftsmooth.c:416
SETTINGS_INFO SettingsInfo
Definition: winmain.cpp:18
LONG_PTR LPARAM
Definition: windef.h:208
_Check_return_ _CRTIMP _CONST_RETURN wchar_t *__cdecl wcsrchr(_In_z_ const wchar_t *_Str, _In_ wchar_t _Ch)
INTERNET_SCHEME nScheme
Definition: winhttp.h:468
static CDowloadingAppsListView DownloadsListView
Definition: loaddlg.cpp:345
BOOL WINAPI DECLSPEC_HOTPATCH ShellExecuteExW(LPSHELLEXECUTEINFOW sei)
Definition: shlexec.cpp:2197
BOOL UrlHasBeenCopied
Definition: loaddlg.cpp:460
#define IDS_UNABLE_TO_INSTALL
Definition: resource.h:113
#define SW_SHOW
Definition: winuser.h:769
#define WM_SETTEXT
Definition: winuser.h:1599
#define IDS_INTERRUPTED_DOWNLOAD
Definition: resource.h:109
#define ICU_ESCAPE
Definition: winhttp.h:48
VOID SetDownloadStatus(INT ItemIndex, DownloadStatus Status)
Definition: loaddlg.cpp:247
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
#define IDS_UNABLE_TO_QUERY_CERT
Definition: resource.h:106
#define WM_CLOSE
Definition: winuser.h:1603
GLfloat param
Definition: glext.h:5796
PCXSTR GetString() const
Definition: atlsimpstr.h:361
VOID SetMarquee(BOOL Enable)
Definition: loaddlg.cpp:109
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HTTP_STATUS_OK
Definition: winhttp.h:240
BOOL GetStorageDirectory(ATL::CStringW &lpDirectory)
Definition: misc.cpp:172
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:105
#define IDC_DOWNLOAD_PROGRESS
Definition: resource.h:40
static VOID UpdateProgress(HWND hDlg, ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR szStatusText)
Definition: loaddlg.cpp:462
#define INTERNET_OPEN_TYPE_DIRECT
Definition: wininet.h:522
HWND hMainWnd
Definition: magnifier.c:32
DWORD dwStructSize
Definition: winhttp.h:465
BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
Definition: http.c:3807
#define IDS_INTEG_CHECK_TITLE
Definition: resource.h:107
static const WCHAR L[]
Definition: oid.c:1250
#define MB_ICONERROR
Definition: winuser.h:781
_In_ HANDLE hFile
Definition: mswsock.h:90
LPWSTR lpszHostName
Definition: winhttp.h:469
#define HTTP_QUERY_STATUS_CODE
Definition: wininet.h:1542
#define INTERNET_FLAG_PASSIVE
Definition: wininet.h:65
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define INTERNET_FLAG_PRAGMA_NOCACHE
Definition: wininet.h:85
#define CREATE_ALWAYS
Definition: disk.h:72
WCHAR szProxyServer[MAX_PATH]
Definition: winmain.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:2175
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define MB_OK
Definition: winuser.h:784
#define HTTP_QUERY_FLAG_NUMBER
Definition: wininet.h:1606
BOOL bDelInstaller
Definition: winmain.h:11
#define CreateFileW
Definition: compat.h:400
BOOL WINAPI InternetCrackUrlW(const WCHAR *lpszUrl, DWORD dwUrlLength, DWORD dwFlags, URL_COMPONENTSW *lpUC)
Definition: internet.c:1645
static const WCHAR szName[]
Definition: msipriv.h:1194
ATL::CStringW LoadStatusString(DownloadStatus StatusParam)
Definition: loaddlg.cpp:65
LRESULT SendMessage(UINT message, WPARAM wParam=0, LPARAM lParam=0)
Definition: atlwin.h:1048
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
WCHAR szNoProxyFor[MAX_PATH]
Definition: winmain.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:1002
#define memset(x, y, z)
Definition: compat.h:39
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
LPWSTR lpszScheme
Definition: winhttp.h:466
static CDownloaderProgress ProgressBar
Definition: loaddlg.cpp:346
#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 462 of file loaddlg.cpp.

468 {
469  HWND Item;
470 
471  ProgressBar.SetProgress(ulProgress, ulProgressMax);
472 
473  Item = GetDlgItem(hDlg, IDC_DOWNLOAD_STATUS);
474  if (Item && szStatusText && wcslen(szStatusText) > 0 && UrlHasBeenCopied == FALSE)
475  {
476  SIZE_T len = wcslen(szStatusText) + 1;
478  DWORD dummyLen;
479 
480  /* beautify our url for display purposes */
481  if (!InternetCanonicalizeUrlW(szStatusText, buf.GetBuffer(len), &dummyLen, ICU_DECODE | ICU_NO_ENCODE))
482  {
483  /* just use the original */
484  buf.ReleaseBuffer();
485  buf = szStatusText;
486  }
487  else
488  {
489  buf.ReleaseBuffer();
490  }
491 
492  /* paste it into our dialog and don't do it again in this instance */
493  SendMessageW(Item, WM_SETTEXT, 0, (LPARAM) buf.GetString());
495  }
496 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
VOID SetProgress(ULONG ulProgress, ULONG ulProgressMax)
Definition: loaddlg.cpp:119
BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:2027
#define IDC_DOWNLOAD_STATUS
Definition: resource.h:41
LONG_PTR LPARAM
Definition: windef.h:208
BOOL UrlHasBeenCopied
Definition: loaddlg.cpp:460
#define WM_SETTEXT
Definition: winuser.h:1599
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:78
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define ICU_DECODE
Definition: winhttp.h:291
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static CDownloaderProgress ProgressBar
Definition: loaddlg.cpp:346

Referenced by ThreadFunc().

Member Data Documentation

◆ AppsToInstallList

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

Definition at line 344 of file loaddlg.cpp.

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

◆ bCancelled

BOOL CDownloadManager::bCancelled
staticprivate

Definition at line 347 of file loaddlg.cpp.

Referenced by DownloadDlgProc(), and ThreadFunc().

◆ DownloadsListView

CDowloadingAppsListView CDownloadManager::DownloadsListView
staticprivate

Definition at line 345 of file loaddlg.cpp.

Referenced by DownloadDlgProc(), and ThreadFunc().

◆ ProgressBar

CDownloaderProgress CDownloadManager::ProgressBar
staticprivate

Definition at line 346 of file loaddlg.cpp.

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


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