1 /* PROJECT: ReactOS Applications Manager
2 * LICENSE: GPL - See COPYING in the top level directory
3 * FILE: base/applications/rapps/loaddlg.cpp
4 * PURPOSE: Displaying a download dialog
5 * COPYRIGHT: Copyright 2001 John R. Sheets (for CodeWeavers)
6 * Copyright 2004 Mike McCormack (for CodeWeavers)
7 * Copyright 2005 Ge van Geldorp (gvg@reactos.org)
8 * Copyright 2009 Dmitry Chapyshev (dmitry@reactos.org)
9 * Copyright 2015 Ismael Ferreras Morezuelas (swyterzone+ros@gmail.com)
10 * Copyright 2017 Alexander Shaposhnikov (chaez.san@gmail.com)
14 * Based on Wine dlls/shdocvw/shdocvw_main.c
16 * This library is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 2.1 of the License, or (at your option) any later version.
21 * This library is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with this library; if not, write to the Free Software
28 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 #include <shlobj_undoc.h>
34 #include <shlguid_undoc.h>
40 #include <shellutils.h>
49 DLWaiting
= IDS_STATUS_WAITING
,
50 DLDownloading
= IDS_STATUS_DOWNLOADING
,
51 DLWaitingToInstall
= IDS_STATUS_DOWNLOADED
,
52 DLInstalling
= IDS_STATUS_INSTALLING
,
53 DLInstalled
= IDS_STATUS_INSTALLED
,
54 DLFinished
= IDS_STATUS_FINISHED
57 ATL::CStringW
LoadStatusString(DOWNLOAD_STATUS StatusParam
)
59 ATL::CStringW szString
;
60 szString
.LoadStringW(StatusParam
);
64 class CDownloadDialog
:
65 public CComObjectRootEx
<CComMultiThreadModelNoCS
>,
66 public IBindStatusCallback
70 BOOL m_UrlHasBeenCopied
;
75 //DestroyWindow(m_hDialog);
78 HRESULT
Initialize(HWND Dlg
, BOOL
*pbCancelled
)
81 m_pbCancelled
= pbCancelled
;
82 m_UrlHasBeenCopied
= FALSE
;
86 virtual HRESULT STDMETHODCALLTYPE
OnStartBinding(
93 virtual HRESULT STDMETHODCALLTYPE
GetPriority(
99 virtual HRESULT STDMETHODCALLTYPE
OnLowResource(
105 virtual HRESULT STDMETHODCALLTYPE
OnProgress(
109 LPCWSTR szStatusText
)
114 Item
= GetDlgItem(m_hDialog
, IDC_DOWNLOAD_PROGRESS
);
115 if (Item
&& ulProgressMax
)
117 WCHAR szProgress
[100];
118 WCHAR szProgressMax
[100];
119 UINT uiPercentage
= ((ULONGLONG
) ulProgress
* 100) / ulProgressMax
;
121 /* send the current progress to the progress bar */
122 SendMessageW(Item
, PBM_SETPOS
, uiPercentage
, 0);
124 /* format the bits and bytes into pretty and accessible units... */
125 StrFormatByteSizeW(ulProgress
, szProgress
, _countof(szProgress
));
126 StrFormatByteSizeW(ulProgressMax
, szProgressMax
, _countof(szProgressMax
));
128 /* ...and post all of it to our subclassed progress bar text subroutine */
129 ATL::CStringW m_ProgressText
;
130 m_ProgressText
.Format(L
"%u%% \x2014 %ls / %ls",
134 SendMessageW(Item
, WM_SETTEXT
, 0, (LPARAM
) m_ProgressText
.GetString());
137 Item
= GetDlgItem(m_hDialog
, IDC_DOWNLOAD_STATUS
);
138 if (Item
&& szStatusText
&& wcslen(szStatusText
) > 0 && m_UrlHasBeenCopied
== FALSE
)
140 DWORD len
= wcslen(szStatusText
) + 1;
143 /* beautify our url for display purposes */
144 if (!InternetCanonicalizeUrlW(szStatusText
, buf
.GetBuffer(len
), &len
, ICU_DECODE
| ICU_NO_ENCODE
))
146 /* just use the original */
155 /* paste it into our dialog and don't do it again in this instance */
156 SendMessageW(Item
, WM_SETTEXT
, 0, (LPARAM
) buf
.GetString());
157 m_UrlHasBeenCopied
= TRUE
;
161 r
= GetWindowLongPtrW(m_hDialog
, GWLP_USERDATA
);
162 if (0 != r
|| 0 != GetLastError())
164 *m_pbCancelled
= TRUE
;
171 virtual HRESULT STDMETHODCALLTYPE
OnStopBinding(
178 virtual HRESULT STDMETHODCALLTYPE
GetBindInfo(
185 virtual HRESULT STDMETHODCALLTYPE
OnDataAvailable(
188 FORMATETC
*pformatetc
,
194 virtual HRESULT STDMETHODCALLTYPE
OnObjectAvailable(
201 BEGIN_COM_MAP(CDownloadDialog
)
202 COM_INTERFACE_ENTRY_IID(IID_IBindStatusCallback
, IBindStatusCallback
)
206 class CDowloadingAppsListView
207 : public CUiWindow
<CListView
>
210 HWND
Create(HWND hwndParent
)
212 RECT r
= {10, 150, 320, 350};
213 const DWORD style
= WS_CHILD
| WS_VISIBLE
| LVS_REPORT
| LVS_SINGLESEL
214 | LVS_SHOWSELALWAYS
| LVS_NOSORTHEADER
| LVS_NOCOLUMNHEADER
;
216 HWND hwnd
= CListView::Create(hwndParent
, r
, NULL
, style
, WS_EX_CLIENTEDGE
);
218 AddColumn(0, 150, LVCFMT_LEFT
);
219 AddColumn(1, 120, LVCFMT_LEFT
);
224 VOID
LoadList(ATL::CSimpleArray
<PAPPLICATION_INFO
> arrInfo
)
226 for (INT i
= 0; i
< arrInfo
.GetSize(); ++i
)
228 PAPPLICATION_INFO AppInfo
= arrInfo
[i
];
229 AddRow(i
, AppInfo
->szName
.GetString(), DOWNLOAD_STATUS::DLWaiting
);
233 VOID
SetDownloadStatus(INT ItemIndex
, DOWNLOAD_STATUS Status
)
235 HWND hListView
= GetWindow();
236 ATL::CStringW szBuffer
= LoadStatusString(Status
);
237 ListView_SetItemText(hListView
, ItemIndex
, 1, const_cast<LPWSTR
>(szBuffer
.GetString()));
240 BOOL
AddItem(INT ItemIndex
, LPWSTR lpText
)
244 ZeroMemory(&Item
, sizeof(Item
));
246 Item
.mask
= LVIF_TEXT
| LVIF_STATE
;
247 Item
.pszText
= lpText
;
248 Item
.iItem
= ItemIndex
;
250 return InsertItem(&Item
);
253 VOID
AddRow(INT RowIndex
, LPCWSTR szAppName
, const DOWNLOAD_STATUS Status
)
255 ATL::CStringW szStatus
= LoadStatusString(Status
);
257 const_cast<LPWSTR
>(szAppName
));
258 SetDownloadStatus(RowIndex
, Status
);
261 BOOL
AddColumn(INT Index
, INT Width
, INT Format
)
264 ZeroMemory(&Column
, sizeof(Column
));
266 Column
.mask
= LVCF_FMT
| LVCF_WIDTH
| LVCF_SUBITEM
;
267 Column
.iSubItem
= Index
;
271 return (InsertColumn(Index
, &Column
) == -1) ? FALSE
: TRUE
;
276 HRESULT WINAPI
CDownloadDialog_Constructor(HWND Dlg
, BOOL
*pbCancelled
, REFIID riid
, LPVOID
*ppv
)
278 return ShellObjectCreatorInit
<CDownloadDialog
>(Dlg
, pbCancelled
, riid
, ppv
);
281 #ifdef USE_CERT_PINNING
282 static BOOL
CertIsValid(HINTERNET hInternet
, LPWSTR lpszHostName
)
286 DWORD certInfoLength
;
288 INTERNET_CERTIFICATE_INFOW certInfo
;
290 hConnect
= InternetConnectW(hInternet
, lpszHostName
, INTERNET_DEFAULT_HTTPS_PORT
, NULL
, NULL
, INTERNET_SERVICE_HTTP
, INTERNET_FLAG_SECURE
, 0);
293 hRequest
= HttpOpenRequestW(hConnect
, L
"HEAD", NULL
, NULL
, NULL
, NULL
, INTERNET_FLAG_SECURE
, 0);
294 if (hRequest
!= NULL
)
296 Ret
= HttpSendRequestW(hRequest
, L
"", 0, NULL
, 0);
299 certInfoLength
= sizeof(certInfo
);
300 Ret
= InternetQueryOptionW(hRequest
,
301 INTERNET_OPTION_SECURITY_CERTIFICATE_STRUCT
,
306 if (certInfo
.lpszEncryptionAlgName
)
307 LocalFree(certInfo
.lpszEncryptionAlgName
);
308 if (certInfo
.lpszIssuerInfo
)
310 if (strcmp((LPSTR
) certInfo
.lpszIssuerInfo
, CERT_ISSUER_INFO
) != 0)
312 LocalFree(certInfo
.lpszIssuerInfo
);
314 if (certInfo
.lpszProtocolName
)
315 LocalFree(certInfo
.lpszProtocolName
);
316 if (certInfo
.lpszSignatureAlgName
)
317 LocalFree(certInfo
.lpszSignatureAlgName
);
318 if (certInfo
.lpszSubjectInfo
)
320 if (strcmp((LPSTR
) certInfo
.lpszSubjectInfo
, CERT_SUBJECT_INFO
) != 0)
322 LocalFree(certInfo
.lpszSubjectInfo
);
326 InternetCloseHandle(hRequest
);
328 InternetCloseHandle(hConnect
);
335 MessageBox_LoadString(HWND hMainWnd
, INT StringID
)
337 ATL::CString szMsgText
;
338 if (szMsgText
.LoadStringW(hInst
, StringID
))
340 MessageBoxW(hMainWnd
, szMsgText
.GetString(), NULL
, MB_OK
| MB_ICONERROR
);
345 PAPPLICATION_INFO Ñ
DownloadManager::AppInfo
;
346 ATL::CSimpleArray
<PAPPLICATION_INFO
> Ñ
DownloadManager::AppsToInstallList
;
347 CDowloadingAppsListView Ñ
DownloadManager::DownloadsListView
;
348 INT Ñ
DownloadManager::iCurrentApp
;
350 #define DL_START_NEW WM_APP + 1
352 INT_PTR CALLBACK Ñ
DownloadManager::DownloadDlgProc(HWND Dlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
357 static WCHAR szCaption
[MAX_PATH
];
363 HICON hIconSm
, hIconBg
;
365 hIconBg
= (HICON
) GetClassLongW(hMainWnd
, GCLP_HICON
);
366 hIconSm
= (HICON
) GetClassLongW(hMainWnd
, GCLP_HICONSM
);
368 if (hIconBg
&& hIconSm
)
370 SendMessageW(Dlg
, WM_SETICON
, ICON_BIG
, (LPARAM
) hIconBg
);
371 SendMessageW(Dlg
, WM_SETICON
, ICON_SMALL
, (LPARAM
) hIconSm
);
374 SetWindowLongW(Dlg
, GWLP_USERDATA
, 0);
375 Item
= GetDlgItem(Dlg
, IDC_DOWNLOAD_PROGRESS
);
378 // initialize the default values for our nifty progress bar
379 // and subclass it so that it learns to print a status text
380 SendMessageW(Item
, PBM_SETRANGE
, 0, MAKELPARAM(0, 100));
381 SendMessageW(Item
, PBM_SETPOS
, 0, 0);
383 SetWindowSubclass(Item
, DownloadProgressProc
, 0, 0);
385 // Get a dlg string for later use
386 GetWindowTextW(Dlg
, szCaption
, MAX_PATH
);
389 HWND hListView
= DownloadsListView
.Create(Dlg
);
394 DownloadsListView
.LoadList(AppsToInstallList
);
397 ShowWindow(Dlg
, SW_SHOW
);
400 SendMessageW(Dlg
, DL_START_NEW
, 0, 0);
405 if (wParam
== IDCANCEL
)
407 SetWindowLongW(Dlg
, GWLP_USERDATA
, 1);
408 PostMessageW(Dlg
, WM_CLOSE
, 0, 0);
415 // If some downloads left we issue it
416 if (iCurrentApp
< AppsToInstallList
.GetSize())
418 AppInfo
= AppsToInstallList
[iCurrentApp
];
424 ATL::CStringW szNewCaption
;
426 // Reset progress bar
427 Item
= GetDlgItem(Dlg
, IDC_DOWNLOAD_PROGRESS
);
430 SendMessageW(Item
, PBM_SETPOS
, 0, 0);
433 // Change caption to show the currently downloaded app
434 szNewCaption
.Format(szCaption
, AppInfo
->szName
.GetString());
435 SetWindowTextW(Dlg
, szNewCaption
.GetString());
437 // Add a neat placeholder until the download URL is retrieved
438 SetDlgItemTextW(Dlg
, IDC_DOWNLOAD_STATUS
, L
"\x2022 \x2022 \x2022");
439 Thread
= CreateThread(NULL
, 0, ThreadFunc
, Dlg
, 0, &ThreadId
);
449 // No downloads left, closing (fallthrough)
461 LRESULT CALLBACK Ñ
DownloadManager::DownloadProgressProc(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
, UINT_PTR uIdSubclass
, DWORD_PTR dwRefData
)
463 static ATL::CStringW szProgressText
;
471 szProgressText
= (PCWSTR
) lParam
;
480 HDC hDC
= BeginPaint(hWnd
, &ps
), hdcMem
;
484 UINT win_width
, win_height
;
486 GetClientRect(hWnd
, &myRect
);
488 /* grab the progress bar rect size */
489 win_width
= myRect
.right
- myRect
.left
;
490 win_height
= myRect
.bottom
- myRect
.top
;
492 /* create an off-screen DC for double-buffering */
493 hdcMem
= CreateCompatibleDC(hDC
);
494 hbmMem
= CreateCompatibleBitmap(hDC
, win_width
, win_height
);
496 hOld
= SelectObject(hdcMem
, hbmMem
);
498 /* call the original draw code and redirect it to our memory buffer */
499 DefSubclassProc(hWnd
, uMsg
, (WPARAM
) hdcMem
, lParam
);
501 /* draw our nifty progress text over it */
502 SelectFont(hdcMem
, GetStockFont(DEFAULT_GUI_FONT
));
503 DrawShadowText(hdcMem
, szProgressText
.GetString(), szProgressText
.GetLength(),
505 DT_CENTER
| DT_VCENTER
| DT_NOPREFIX
| DT_SINGLELINE
,
506 GetSysColor(COLOR_CAPTIONTEXT
),
507 GetSysColor(COLOR_3DSHADOW
),
510 /* transfer the off-screen DC to the screen */
511 BitBlt(hDC
, 0, 0, win_width
, win_height
, hdcMem
, 0, 0, SRCCOPY
);
513 /* free the off-screen DC */
514 SelectObject(hdcMem
, hOld
);
515 DeleteObject(hbmMem
);
522 /* Raymond Chen says that we should safely unsubclass all the things!
523 (http://blogs.msdn.com/b/oldnewthing/archive/2003/11/11/55653.aspx) */
527 szProgressText
.Empty();
528 RemoveWindowSubclass(hWnd
, DownloadProgressProc
, uIdSubclass
);
532 return DefSubclassProc(hWnd
, uMsg
, wParam
, lParam
);
536 DWORD WINAPI Ñ
DownloadManager::ThreadFunc(LPVOID Context
)
538 CComPtr
<IBindStatusCallback
> dl
;
541 HWND Dlg
= (HWND
) Context
;
543 ULONG dwContentLen
, dwBytesWritten
, dwBytesRead
, dwStatus
;
544 ULONG dwCurrentBytesRead
= 0;
545 ULONG dwStatusLen
= sizeof(dwStatus
);
547 BOOL bCancelled
= FALSE
;
548 BOOL bTempfile
= FALSE
;
551 HINTERNET hOpen
= NULL
;
552 HINTERNET hFile
= NULL
;
553 HANDLE hOut
= INVALID_HANDLE_VALUE
;
555 unsigned char lpBuffer
[4096];
556 LPCWSTR lpszAgent
= L
"RApps/1.0";
557 URL_COMPONENTS urlComponents
;
558 size_t urlLength
, filenameLength
;
560 const INT iAppId
= iCurrentApp
;
561 const PAPPLICATION_INFO pCurrentInfo
= AppInfo
;
564 MessageBox_LoadString(hMainWnd
, IDS_UNABLE_TO_DOWNLOAD
);
568 DownloadsListView
.SetDownloadStatus(iAppId
, DOWNLOAD_STATUS::DLDownloading
);
570 // build the path for the download
571 p
= wcsrchr(pCurrentInfo
->szUrlDownload
.GetString(), L
'/');
572 q
= wcsrchr(pCurrentInfo
->szUrlDownload
.GetString(), L
'?');
574 // do we have a final slash separator?
578 // prepare the tentative length of the filename, maybe we've to remove part of it later on
579 filenameLength
= wcslen(p
) * sizeof(WCHAR
);
581 /* do we have query arguments in the target URL after the filename? account for them
582 (e.g. https://example.org/myfile.exe?no_adware_plz) */
583 if (q
&& q
> p
&& (q
- p
) > 0)
584 filenameLength
-= wcslen(q
- 1) * sizeof(WCHAR
);
586 // is this URL an update package for RAPPS? if so store it in a different place
587 if (pCurrentInfo
->szUrlDownload
== APPLICATION_DATABASE_URL
)
590 if (!GetStorageDirectory(Path
))
595 Path
= SettingsInfo
.szDownloadDir
;
598 // is the path valid? can we access it?
599 if (GetFileAttributesW(Path
.GetString()) == INVALID_FILE_ATTRIBUTES
)
601 if (!CreateDirectoryW(Path
.GetString(), NULL
))
605 // append a \ to the provided file system path, and the filename portion from the URL after that
607 Path
+= (LPWSTR
) (p
+ 1);
609 if (!bCab
&& pCurrentInfo
->szSHA1
[0] && GetFileAttributesW(Path
.GetString()) != INVALID_FILE_ATTRIBUTES
)
611 // only open it in case of total correctness
612 if (VerifyInteg(pCurrentInfo
->szSHA1
, Path
))
618 CDownloadDialog_Constructor(Dlg
, &bCancelled
, IID_PPV_ARG(IBindStatusCallback
, &dl
));
623 /* FIXME: this should just be using the system-wide proxy settings */
624 switch (SettingsInfo
.Proxy
)
627 hOpen
= InternetOpenW(lpszAgent
, INTERNET_OPEN_TYPE_PRECONFIG
, NULL
, NULL
, 0);
629 case 1: // direct (no proxy)
630 hOpen
= InternetOpenW(lpszAgent
, INTERNET_OPEN_TYPE_DIRECT
, NULL
, NULL
, 0);
633 hOpen
= InternetOpenW(lpszAgent
, INTERNET_OPEN_TYPE_PROXY
, SettingsInfo
.szProxyServer
, SettingsInfo
.szNoProxyFor
, 0);
635 default: // preconfig
636 hOpen
= InternetOpenW(lpszAgent
, INTERNET_OPEN_TYPE_PRECONFIG
, NULL
, NULL
, 0);
643 hFile
= InternetOpenUrlW(hOpen
, pCurrentInfo
->szUrlDownload
, NULL
, 0, INTERNET_FLAG_PRAGMA_NOCACHE
| INTERNET_FLAG_KEEP_CONNECTION
, 0);
646 MessageBox_LoadString(hMainWnd
, IDS_UNABLE_TO_DOWNLOAD2
);
650 if (!HttpQueryInfoW(hFile
, HTTP_QUERY_STATUS_CODE
| HTTP_QUERY_FLAG_NUMBER
, &dwStatus
, &dwStatusLen
, NULL
))
653 if (dwStatus
!= HTTP_STATUS_OK
)
655 MessageBox_LoadString(hMainWnd
, IDS_UNABLE_TO_DOWNLOAD
);
659 dwStatusLen
= sizeof(dwStatus
);
661 memset(&urlComponents
, 0, sizeof(urlComponents
));
662 urlComponents
.dwStructSize
= sizeof(urlComponents
);
664 urlLength
= pCurrentInfo
->szUrlDownload
.GetLength();
665 urlComponents
.dwSchemeLength
= urlLength
+ 1;
666 urlComponents
.lpszScheme
= (LPWSTR
) malloc(urlComponents
.dwSchemeLength
* sizeof(WCHAR
));
667 urlComponents
.dwHostNameLength
= urlLength
+ 1;
668 urlComponents
.lpszHostName
= (LPWSTR
) malloc(urlComponents
.dwHostNameLength
* sizeof(WCHAR
));
670 if (!InternetCrackUrlW(pCurrentInfo
->szUrlDownload
, urlLength
+ 1, ICU_DECODE
| ICU_ESCAPE
, &urlComponents
))
673 if (urlComponents
.nScheme
== INTERNET_SCHEME_HTTP
|| urlComponents
.nScheme
== INTERNET_SCHEME_HTTPS
)
674 HttpQueryInfoW(hFile
, HTTP_QUERY_CONTENT_LENGTH
| HTTP_QUERY_FLAG_NUMBER
, &dwContentLen
, &dwStatus
, 0);
676 if (urlComponents
.nScheme
== INTERNET_SCHEME_FTP
)
677 dwContentLen
= FtpGetFileSize(hFile
, &dwStatus
);
679 #ifdef USE_CERT_PINNING
680 // are we using HTTPS to download the RAPPS update package? check if the certificate is original
681 if ((urlComponents
.nScheme
== INTERNET_SCHEME_HTTPS
) &&
682 (wcscmp(pCurrentInfo
->szUrlDownload
, APPLICATION_DATABASE_URL
) == 0) &&
683 (!CertIsValid(hOpen
, urlComponents
.lpszHostName
)))
685 MessageBox_LoadString(hMainWnd
, IDS_CERT_DOES_NOT_MATCH
);
690 free(urlComponents
.lpszScheme
);
691 free(urlComponents
.lpszHostName
);
693 hOut
= CreateFileW(Path
.GetString(), GENERIC_WRITE
, FILE_SHARE_READ
| FILE_SHARE_WRITE
, NULL
, CREATE_ALWAYS
, 0, NULL
);
695 if (hOut
== INVALID_HANDLE_VALUE
)
700 if (!InternetReadFile(hFile
, lpBuffer
, _countof(lpBuffer
), &dwBytesRead
))
702 MessageBox_LoadString(hMainWnd
, IDS_INTERRUPTED_DOWNLOAD
);
706 if (!WriteFile(hOut
, &lpBuffer
[0], dwBytesRead
, &dwBytesWritten
, NULL
))
708 MessageBox_LoadString(hMainWnd
, IDS_UNABLE_TO_WRITE
);
712 dwCurrentBytesRead
+= dwBytesRead
;
713 dl
->OnProgress(dwCurrentBytesRead
, dwContentLen
, 0, pCurrentInfo
->szUrlDownload
);
714 } while (dwBytesRead
&& !bCancelled
);
717 hOut
= INVALID_HANDLE_VALUE
;
722 /* if this thing isn't a RAPPS update and it has a SHA-1 checksum
723 verify its integrity by using the native advapi32.A_SHA1 functions */
724 if (!bCab
&& pCurrentInfo
->szSHA1
[0] != 0)
726 ATL::CStringW szMsgText
;
728 // change a few strings in the download dialog to reflect the verification process
729 if (!szMsgText
.LoadStringW(hInst
, IDS_INTEG_CHECK_TITLE
))
732 SetWindowTextW(Dlg
, szMsgText
.GetString());
733 SendMessageW(GetDlgItem(Dlg
, IDC_DOWNLOAD_STATUS
), WM_SETTEXT
, 0, (LPARAM
) Path
.GetString());
735 // this may take a while, depending on the file size
736 if (!VerifyInteg(pCurrentInfo
->szSHA1
, Path
.GetString()))
738 if (!szMsgText
.LoadStringW(hInst
, IDS_INTEG_CHECK_FAIL
))
741 MessageBoxW(Dlg
, szMsgText
.GetString(), NULL
, MB_OK
| MB_ICONERROR
);
748 DownloadsListView
.SetDownloadStatus(iAppId
, DOWNLOAD_STATUS::DLWaitingToInstall
);
753 SHELLEXECUTEINFOW shExInfo
= {0};
754 shExInfo
.cbSize
= sizeof(shExInfo
);
755 shExInfo
.fMask
= SEE_MASK_NOCLOSEPROCESS
;
756 shExInfo
.lpVerb
= L
"open";
757 shExInfo
.lpFile
= Path
.GetString();
758 shExInfo
.lpParameters
= L
"";
759 shExInfo
.nShow
= SW_SHOW
;
761 if (ShellExecuteExW(&shExInfo
))
763 DownloadsListView
.SetDownloadStatus(iAppId
, DOWNLOAD_STATUS::DLInstalling
);
764 //TODO: issue an install operation separately so that the apps could be downloaded in the background
765 WaitForSingleObject(shExInfo
.hProcess
, INFINITE
);
766 CloseHandle(shExInfo
.hProcess
);
770 MessageBox_LoadString(hMainWnd
, IDS_UNABLE_TO_INSTALL
);
775 if (hOut
!= INVALID_HANDLE_VALUE
)
778 InternetCloseHandle(hFile
);
779 InternetCloseHandle(hOpen
);
783 if (bCancelled
|| (SettingsInfo
.bDelInstaller
&& !bCab
))
784 DeleteFileW(Path
.GetString());
786 DownloadsListView
.SetDownloadStatus(iAppId
, DOWNLOAD_STATUS::DLFinished
);
787 SendMessageW(Dlg
, DL_START_NEW
, 0, 0);
791 BOOL Ñ
DownloadManager::DownloadListOfApplications(const ATL::CSimpleArray
<PAPPLICATION_INFO
>& AppsList
)
793 if (AppsList
.GetSize() == 0)
798 // Initialize shared variables
799 AppsToInstallList
= AppsList
;
801 // Create a dialog and issue a download process
802 LaunchDownloadDialog();
807 BOOL Ñ
DownloadManager::DownloadApplication(PAPPLICATION_INFO pAppInfo
)
814 AppsToInstallList
.RemoveAll();
815 AppsToInstallList
.Add(pAppInfo
);
816 LaunchDownloadDialog();
821 VOID Ñ
DownloadManager::DownloadApplicationsDB(LPCWSTR lpUrl
)
823 APPLICATION_INFO IntInfo
;
824 IntInfo
.szUrlDownload
= lpUrl
;
826 DownloadApplication(&IntInfo
);
829 //TODO: Reuse the dialog
830 VOID Ñ
DownloadManager::LaunchDownloadDialog()
833 MAKEINTRESOURCEW(IDD_DOWNLOAD_DIALOG
),