ReactOS 0.4.16-dev-734-g364d6e0
loaddlg.cpp File Reference
#include "rapps.h"
#include <shlobj_undoc.h>
#include <shlguid_undoc.h>
#include <atlbase.h>
#include <atlcom.h>
#include <atlwin.h>
#include <wininet.h>
#include <shellutils.h>
#include <debug.h>
#include <ui/rosctrls.h>
#include <windowsx.h>
#include <shlwapi_undoc.h>
#include <process.h>
#include "rosui.h"
#include "dialogs.h"
#include "misc.h"
#include "unattended.h"
Include dependency graph for loaddlg.cpp:

Go to the source code of this file.

Classes

struct  DownloadInfo
 
class  CDownloaderProgress
 
class  CDowloadingAppsListView
 
class  CDownloadManager
 

Macros

#define FILENAME_VALID_CHAR
 

Enumerations

enum  DownloadType { DLTYPE_APPLICATION , DLTYPE_DBUPDATE , DLTYPE_DBUPDATE_UNOFFICIAL }
 
enum  DownloadStatus {
  DLSTATUS_WAITING = IDS_STATUS_WAITING , DLSTATUS_DOWNLOADING = IDS_STATUS_DOWNLOADING , DLSTATUS_WAITING_INSTALL = IDS_STATUS_DOWNLOADED , DLSTATUS_INSTALLING = IDS_STATUS_INSTALLING ,
  DLSTATUS_INSTALLED = IDS_STATUS_INSTALLED , DLSTATUS_FINISHED = IDS_STATUS_FINISHED
}
 

Functions

CStringW LoadStatusString (DownloadStatus StatusParam)
 
VOID UrlUnescapeAndMakeFileNameValid (CStringW &str)
 
static void SetFriendlyUrl (HWND hWnd, LPCWSTR pszUrl)
 
static VOID MessageBox_LoadString (HWND hOwnerWnd, INT StringID)
 
static BOOL ShowLastError (HWND hWndOwner, BOOL bInetError, DWORD dwLastError)
 
BOOL DownloadListOfApplications (const CAtlList< CAppInfo * > &AppsList, BOOL bIsModal)
 
BOOL DownloadApplication (CAppInfo *pAppInfo)
 
VOID DownloadApplicationsDB (LPCWSTR lpUrl, BOOL IsOfficial)
 

Variables

HWND g_hDownloadWnd = NULL
 

Macro Definition Documentation

◆ FILENAME_VALID_CHAR

#define FILENAME_VALID_CHAR
Value:
( \
#define PATH_CHAR_CLASS_OTHER_VALID
Definition: path.c:4316
#define PATH_CHAR_CLASS_SPACE
Definition: path.c:4315
#define PATH_CHAR_CLASS_LETTER
Definition: path.c:4308
#define PATH_CHAR_CLASS_SEMICOLON
Definition: path.c:4313
#define PATH_CHAR_CLASS_COMMA
Definition: path.c:4314
#define PATH_CHAR_CLASS_DOT
Definition: path.c:4310

Definition at line 98 of file loaddlg.cpp.

Enumeration Type Documentation

◆ DownloadStatus

Enumerator
DLSTATUS_WAITING 
DLSTATUS_DOWNLOADING 
DLSTATUS_WAITING_INSTALL 
DLSTATUS_INSTALLING 
DLSTATUS_INSTALLED 
DLSTATUS_FINISHED 

Definition at line 80 of file loaddlg.cpp.

81{
88};
#define IDS_STATUS_FINISHED
Definition: resource.h:206
#define IDS_STATUS_WAITING
Definition: resource.h:205
#define IDS_STATUS_INSTALLING
Definition: resource.h:204
#define IDS_STATUS_DOWNLOADED
Definition: resource.h:201
#define IDS_STATUS_DOWNLOADING
Definition: resource.h:203
#define IDS_STATUS_INSTALLED
Definition: resource.h:199
@ DLSTATUS_DOWNLOADING
Definition: loaddlg.cpp:83
@ DLSTATUS_FINISHED
Definition: loaddlg.cpp:87
@ DLSTATUS_WAITING_INSTALL
Definition: loaddlg.cpp:84
@ DLSTATUS_WAITING
Definition: loaddlg.cpp:82
@ DLSTATUS_INSTALLED
Definition: loaddlg.cpp:86
@ DLSTATUS_INSTALLING
Definition: loaddlg.cpp:85

◆ DownloadType

Enumerator
DLTYPE_APPLICATION 
DLTYPE_DBUPDATE 
DLTYPE_DBUPDATE_UNOFFICIAL 

Definition at line 73 of file loaddlg.cpp.

74{
78};
@ DLTYPE_DBUPDATE_UNOFFICIAL
Definition: loaddlg.cpp:77
@ DLTYPE_DBUPDATE
Definition: loaddlg.cpp:76
@ DLTYPE_APPLICATION
Definition: loaddlg.cpp:75

Function Documentation

◆ DownloadApplication()

BOOL DownloadApplication ( CAppInfo pAppInfo)

Definition at line 1144 of file loaddlg.cpp.

1145{
1146 const bool bModal = false;
1147 if (!pAppInfo)
1148 return FALSE;
1149
1151 list.AddTail(pAppInfo);
1152 return DownloadListOfApplications(list, bModal);
1153}
Definition: list.h:37
#define FALSE
Definition: types.h:117
BOOL DownloadListOfApplications(const CAtlList< CAppInfo * > &AppsList, BOOL bIsModal)
Definition: loaddlg.cpp:1125

Referenced by CMainWindow::InstallApplication().

◆ DownloadApplicationsDB()

VOID DownloadApplicationsDB ( LPCWSTR  lpUrl,
BOOL  IsOfficial 
)

Definition at line 1156 of file loaddlg.cpp.

1157{
1158 const bool bModal = true;
1160 if (!CDownloadManager::CreateInstance(bModal, pDM))
1161 return;
1162
1163 DownloadInfo DatabaseDLInfo;
1164 DatabaseDLInfo.szUrl = lpUrl;
1165 DatabaseDLInfo.szName.LoadStringW(IDS_DL_DIALOG_DB_DISP);
1166 DatabaseDLInfo.DLType = IsOfficial ? DLTYPE_DBUPDATE : DLTYPE_DBUPDATE_UNOFFICIAL;
1167
1168 pDM->Add(DatabaseDLInfo);
1169 pDM->Show();
1170}
#define IDS_DL_DIALOG_DB_DISP
Definition: resource.h:222
static BOOL CreateInstance(BOOL Modal, CComPtr< CDownloadManager > &Obj)
Definition: loaddlg.cpp:498
CStringW szName
Definition: loaddlg.cpp:160
DownloadType DLType
Definition: loaddlg.cpp:157
CStringW szUrl
Definition: loaddlg.cpp:159

Referenced by CAppDB::UpdateAvailable().

◆ DownloadListOfApplications()

BOOL DownloadListOfApplications ( const CAtlList< CAppInfo * > &  AppsList,
BOOL  bIsModal 
)

Definition at line 1125 of file loaddlg.cpp.

1126{
1127 if (AppsList.IsEmpty())
1128 return FALSE;
1129
1131 if (!CDownloadManager::CreateInstance(bIsModal, pDM))
1132 return FALSE;
1133
1134 for (POSITION it = AppsList.GetHeadPosition(); it;)
1135 {
1136 const CAppInfo *Info = AppsList.GetNext(it);
1137 pDM->Add(DownloadInfo(*Info));
1138 }
1139 pDM->Show();
1140 return TRUE;
1141}
bool IsEmpty() const
Definition: atlcoll.h:548
POSITION GetHeadPosition() const
Definition: atlcoll.h:554
E & GetNext(_Inout_ POSITION &pos)
Definition: atlcoll.h:566
#define TRUE
Definition: types.h:120
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690

Referenced by DownloadApplication(), HandleInstallCommand(), HandleSetupCommand(), and CMainWindow::OnCommand().

◆ LoadStatusString()

CStringW LoadStatusString ( DownloadStatus  StatusParam)

Definition at line 91 of file loaddlg.cpp.

92{
93 CStringW szString;
94 szString.LoadStringW(StatusParam);
95 return szString;
96}

Referenced by CDowloadingAppsListView::AddRow(), CDownloadManager::PerformDownloadAndInstall(), and CDowloadingAppsListView::SetDownloadStatus().

◆ MessageBox_LoadString()

static VOID MessageBox_LoadString ( HWND  hOwnerWnd,
INT  StringID 
)
inlinestatic

Definition at line 430 of file loaddlg.cpp.

431{
432 CStringW szMsgText;
433 if (szMsgText.LoadStringW(StringID))
434 {
435 MessageBoxW(hOwnerWnd, szMsgText.GetString(), NULL, MB_OK | MB_ICONERROR);
436 }
437}
PXSTR GetString() noexcept
Definition: atlsimpstr.h:367
#define NULL
Definition: types.h:112
int WINAPI MessageBoxW(_In_opt_ HWND hWnd, _In_opt_ LPCWSTR lpText, _In_opt_ LPCWSTR lpCaption, _In_ UINT uType)
#define MB_ICONERROR
Definition: winuser.h:790
#define MB_OK
Definition: winuser.h:793

Referenced by CDownloadManager::PerformDownloadAndInstall().

◆ SetFriendlyUrl()

static void SetFriendlyUrl ( HWND  hWnd,
LPCWSTR  pszUrl 
)
static

Definition at line 123 of file loaddlg.cpp.

124{
126 DWORD cch = (DWORD)(wcslen(pszUrl) + 1);
127 if (InternetCanonicalizeUrlW(pszUrl, buf.GetBuffer(cch), &cch, ICU_DECODE | ICU_NO_ENCODE))
128 {
129 buf.ReleaseBuffer();
130 pszUrl = buf;
131 }
132 SetWindowTextW(hWnd, pszUrl);
133}
HWND hWnd
Definition: settings.c:17
BOOL WINAPI InternetCanonicalizeUrlW(LPCWSTR lpszUrl, LPWSTR lpszBuffer, LPDWORD lpdwBufferLength, DWORD dwFlags)
Definition: internet.c:2004
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static DWORD DWORD void LPSTR DWORD cch
Definition: str.c:202
#define DWORD
Definition: nt_native.h:44
#define ICU_DECODE
Definition: winhttp.h:291
#define ICU_NO_ENCODE
Definition: winhttp.h:290
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)

Referenced by CDownloadManager::PerformDownloadAndInstall().

◆ ShowLastError()

static BOOL ShowLastError ( HWND  hWndOwner,
BOOL  bInetError,
DWORD  dwLastError 
)
static

Definition at line 440 of file loaddlg.cpp.

441{
442 CLocalPtr<WCHAR> lpMsg;
443
444 if (!FormatMessageW(
447 (bInetError ? GetModuleHandleW(L"wininet.dll") : NULL), dwLastError, LANG_USER_DEFAULT, (LPWSTR)&lpMsg, 0,
448 NULL))
449 {
450 DPRINT1("FormatMessageW unexpected failure (err %d)\n", GetLastError());
451 return FALSE;
452 }
453
454 if (hWndOwner && !IsWindowVisible(hWndOwner))
455 hWndOwner = NULL;
456 MessageBoxW(hWndOwner, lpMsg, NULL, MB_OK | MB_ICONERROR);
457 return TRUE;
458}
#define DPRINT1
Definition: precomp.h:8
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define L(x)
Definition: ntvdm.h:50
#define LANG_USER_DEFAULT
Definition: tnerror.cpp:50
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define FORMAT_MESSAGE_IGNORE_INSERTS
Definition: winbase.h:446
#define FORMAT_MESSAGE_FROM_SYSTEM
Definition: winbase.h:449
#define FORMAT_MESSAGE_ALLOCATE_BUFFER
Definition: winbase.h:445
#define FORMAT_MESSAGE_FROM_HMODULE
Definition: winbase.h:448
BOOL WINAPI IsWindowVisible(_In_ HWND)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by CDownloadManager::PerformDownloadAndInstall().

◆ UrlUnescapeAndMakeFileNameValid()

VOID UrlUnescapeAndMakeFileNameValid ( CStringW str)

Definition at line 107 of file loaddlg.cpp.

108{
110 DWORD cchPath = _countof(szPath);
111 UrlUnescapeW(const_cast<LPWSTR>((LPCWSTR)str), szPath, &cchPath, 0);
112
113 for (PWCHAR pch = szPath; *pch; ++pch)
114 {
116 *pch = L'_';
117 }
118
119 str = szPath;
120}
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI PathIsValidCharW(WCHAR c, DWORD class)
Definition: path.c:4409
HRESULT WINAPI UrlUnescapeW(LPWSTR pszUrl, LPWSTR pszUnescaped, LPDWORD pcchUnescaped, DWORD dwFlags)
Definition: url.c:1367
#define FILENAME_VALID_CHAR
Definition: loaddlg.cpp:98
#define pch(ap)
Definition: match.c:418
LPCWSTR szPath
Definition: env.c:37
const WCHAR * str
#define _countof(array)
Definition: sndvol32.h:70
uint16_t * PWCHAR
Definition: typedefs.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185

Referenced by CDownloadManager::PerformDownloadAndInstall().

Variable Documentation

◆ g_hDownloadWnd

HWND g_hDownloadWnd = NULL

Definition at line 461 of file loaddlg.cpp.

Referenced by CDownloadManager::FindInstance(), and CDownloadManager::RealDlgProc().