00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "CreateDownloadDlg.h"
00009 #include "DownloadsWnd.h"
00010 #include "inetutil.h"
00011 #include "fsDownloadMgr.h"
00012 #include "GroupDlg.h"
00013 #include "DownloadPropertiesSheet.h"
00014 #include "FolderBrowser.h"
00015 #include "ScheduleSheet.h"
00016 #include "system.h"
00017 #include "fsSitesMgr.h"
00018 #include "DownloadsWnd.h"
00019 #include "WaitForConfirmationDlg.h"
00020 #include "DownloadAlrExistsDlg.h"
00021 #include "Dlg_SavePassword.h"
00022 #include "vmsMaliciousDownloadChecker.h"
00023 #include "MyMessageBox.h"
00024 #include "Dlg_Opinions.h"
00025 #include "MyMessageBox.h"
00026
00027 extern CDownloadsWnd *_pwndDownloads;
00028
00029 #ifdef _DEBUG
00030 #define new DEBUG_NEW
00031 #undef THIS_FILE
00032 static char THIS_FILE[] = __FILE__;
00033 #endif
00034
00035 CCreateDownloadDlg::CCreateDownloadDlg(vmsDownloadSmartPtr dld, LPCSTR pszStartUrl, LPCSTR pszComment, LPCSTR pszReferer, CWnd* pParent )
00036 : CDialog(CCreateDownloadDlg::IDD, pParent), m_dld (dld)
00037 {
00038
00039
00040
00041 LOG ("constructing create download dialog...");
00042
00043 m_bScheduled = FALSE;
00044 if (pszStartUrl) m_strUrl = pszStartUrl;
00045 if (pszComment) m_strComment = pszComment;
00046 if (pszReferer) m_strReferer = pszReferer;
00047 m_iAutostart = 0;
00048 m_bThread = FALSE;
00049 m_bNeedExit = FALSE;
00050 m_bSetFocusToOKBtn = false;
00051 m_bPlaceAtTop = false;
00052 m_pszCookies = m_pszPostData = NULL;
00053
00054 LOG ("ok." << nl);
00055 }
00056
00057 void CCreateDownloadDlg::DoDataExchange(CDataExchange* pDX)
00058 {
00059 CDialog::DoDataExchange(pDX);
00060
00061 DDX_Control(pDX, IDC_OUTFOLDER_SETDEFAULT, m_btnOutFolderSetDefault);
00062 DDX_Control(pDX, IDC_DLDTYPE, m_wndDldType);
00063 DDX_Control(pDX, IDC_SETTIME, m_btnSetTime);
00064 DDX_Control(pDX, IDC_CREATEGROUP, m_btnCreateGroup);
00065 DDX_Control(pDX, IDC_CHOOSEFOLDER, m_btnChooseFolder);
00066 DDX_Control (pDX, IDC_GROUPS, m_wndGroups);
00067
00068 }
00069
00070 BEGIN_MESSAGE_MAP(CCreateDownloadDlg, CDialog)
00071
00072 ON_EN_CHANGE(IDC_SAVEAS, OnChangeSaveas)
00073 ON_BN_CLICKED(IDC_USELOGIN, OnAuthorization)
00074 ON_CBN_SELCHANGE(IDC_GROUPS, OnSelchangeGroups)
00075 ON_BN_CLICKED(IDC_STARTNOW, OnStartnow)
00076 ON_BN_CLICKED(IDC_STARTMANUAL, OnStartmanual)
00077 ON_BN_CLICKED(IDC_STARTSCHEDULE, OnStartschedule)
00078 ON_BN_CLICKED(IDC_CREATEGROUP, OnCreategroup)
00079 ON_BN_CLICKED(IDC_ADVANCED, OnAdvanced)
00080 ON_BN_CLICKED(IDC_CHOOSEFOLDER, OnChoosefolder)
00081 ON_BN_CLICKED(IDC_SETTIME, OnSettime)
00082 ON_CBN_EDITCHANGE(IDC_URL, OnEditchangeUrl)
00083 ON_CBN_SELCHANGE(IDC_URL, OnSelchangeUrl)
00084 ON_WM_CONTEXTMENU()
00085 ON_COMMAND(ID_WHATISTHIS, OnWhatisthis)
00086 ON_EN_CHANGE(IDC_USER, OnChangeUser)
00087 ON_EN_CHANGE(IDC_PASSWORD, OnChangePassword)
00088 ON_WM_HELPINFO()
00089 ON_BN_CLICKED(IDC_QSIZE, OnQsize)
00090 ON_BN_CLICKED(IDC_FILEAUTO, OnFileauto)
00091 ON_BN_CLICKED(IDC_MIRRORS, OnMirrors)
00092 ON_CBN_SELCHANGE(IDC_DLDTYPE, OnSelchangeDldtype)
00093 ON_BN_CLICKED(IDC_MALICIOUS, OnMalicious)
00094 ON_BN_CLICKED(IDC_OUTFOLDER_SETDEFAULT, OnOutfolderSetdefault)
00095
00096 END_MESSAGE_MAP()
00097
00098 void CCreateDownloadDlg::OnOK()
00099 {
00100 if (FALSE == ReadDNP ())
00101 return;
00102
00103 CString strOutFolder, strFileName;
00104
00105 int nDldType = m_wndDldType.GetCurSel ();
00106
00107 if (nDldType == 1)
00108 {
00109 char sz [MY_MAX_PATH];
00110 GetTempPath (sizeof (sz), sz);
00111 strOutFolder = sz;
00112 }
00113 else
00114 {
00115 if (FALSE == _CheckFolderName (this, IDC_OUTFOLDER))
00116 return;
00117 GetDlgItemText (IDC_OUTFOLDER, strOutFolder);
00118
00119 if (IsDlgButtonChecked (IDC_FILEAUTO) == BST_UNCHECKED)
00120 {
00121 GetDlgItemText (IDC_SAVEAS, strFileName);
00122 if (FALSE == _CheckFileName (this, IDC_SAVEAS))
00123 return;
00124 _App.NewDL_GenerateNameAutomatically (FALSE);
00125 }
00126 else
00127 _App.NewDL_GenerateNameAutomatically (TRUE);
00128 }
00129
00130 fsPathToGoodPath ((LPSTR)(LPCSTR)strOutFolder);
00131 fsPathToGoodPath ((LPSTR)(LPCSTR)strFileName);
00132
00133 if (strOutFolder.GetLength () == 0)
00134 {
00135 MessageBox (LS (L_ENTERFLRNAME), LS (L_INPERR), MB_ICONEXCLAMATION);
00136 GetDlgItem (IDC_OUTFOLDER)->SetFocus ();
00137 return;
00138 }
00139
00140 if (nDldType != 1)
00141 _LastFolders.AddRecord (strOutFolder);
00142 _LastUrlFiles.AddRecord (m_strUrl);
00143
00144 if (strOutFolder [strOutFolder.GetLength () - 1] != '\\' &&
00145 strOutFolder [strOutFolder.GetLength () - 1] != '/')
00146 strOutFolder += '\\';
00147
00148 if (_App.NewGrp_SelectWay () == NGSW_USE_ALWAYS_SAME_GROUP_WITH_OUTFOLDER_AUTO_UPDATE)
00149 {
00150 vmsDownloadsGroupSmartPtr pGrp = _DldsGrps.FindGroup (_App.NewDL_GroupId ());
00151 if (pGrp != NULL)
00152 pGrp->strOutFolder = strOutFolder;
00153 }
00154
00155 CString strFile = strOutFolder + strFileName;
00156 fsnew (m_dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName, CHAR, strFile.GetLength () + 1);
00157 lstrcpy (m_dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName, strFile);
00158
00159 int ret = _CheckDownloadAlrExists (m_dld);
00160 if (ret)
00161 {
00162 SAFE_DELETE_ARRAY (m_dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName);
00163 if (ret == 1)
00164 EndDialog (ID_DLNOTADDED);
00165 return;
00166 }
00167
00168 m_dld->pGroup = m_wndGroups.GetSelectedGroup ();
00169
00170 GetDlgItemText (IDC_COMMENT, m_dld->strComment);
00171
00172 BOOL bUseZipPreview = _App.NewDL_UseZIPPreview ();
00173 _App.UseZipPreview (bUseZipPreview);
00174
00175 if (bUseZipPreview)
00176 m_dld->pMgr->GetDownloadMgr ()->GetDP ()->dwFlags |= DPF_USEZIPPREVIEW;
00177 else
00178 m_dld->pMgr->GetDownloadMgr ()->GetDP ()->dwFlags &= ~DPF_USEZIPPREVIEW;
00179
00180 if (nDldType == 1)
00181 {
00182 m_dld->pMgr->GetDownloadMgr ()->GetDP ()->dwFlags |= DPF_STARTWHENDONE;
00183 m_dld->dwFlags |= DLD_DELETEWHENDONE | DLD_DELETEFILEATRESTART;
00184 }
00185 else if (nDldType == 2)
00186 m_dld->pMgr->GetDownloadMgr ()->GetDP ()->dwFlags |= DPF_STARTWHENDONE;
00187
00188 m_wndGroups.RememberSelectedGroup ();
00189 _App.Last_Autostart (m_iAutostart);
00190
00191 if (m_bThread)
00192 {
00193 m_bNeedExit = TRUE;
00194 m_dld->pMgr->GetDownloadMgr ()->StopQuering ();
00195 while (m_bThread);
00196 }
00197
00198 _SavePassword (m_dld);
00199
00200 _App.OnDlHasBeenCreatedByUser ();
00201
00202 m_bPlaceAtTop = IsDlgButtonChecked (IDC_PLACEATTOP) == BST_CHECKED;
00203
00204 CDialog::OnOK();
00205 }
00206
00207 BOOL CCreateDownloadDlg::OnInitDialog()
00208 {
00209 CDialog::OnInitDialog();
00210
00211 m_task.hts.enType = HTS_ONCE;
00212 m_task.hts.last.dwHighDateTime = m_task.hts.last.dwLowDateTime = UINT_MAX;
00213 m_task.dwFlags = SCHEDULE_ENABLED;
00214 SYSTEMTIME time;
00215 GetLocalTime (&time);
00216 if (++time.wHour > 23)
00217 time.wHour = 0;
00218 time.wMinute = 0;
00219 SystemTimeToFileTime (&time, &m_task.hts.next);
00220 m_task.uWaitForConfirmation = 0;
00221
00222 m_btnChooseFolder.SetIcon (SICO (IDI_CHOOSEFOLDER));
00223 m_btnCreateGroup.SetIcon (SICO (IDI_CREATEGROUP));
00224 m_btnSetTime.SetIcon (SICO (IDI_SETTIME));
00225 m_btnOutFolderSetDefault.SetIcon (SICO (IDI_SETFOLDERDEFAULT));
00226
00227 if (m_strUrl.GetLength () == 0)
00228 {
00229 LPCSTR pszUrl = _ClipbrdMgr.Text ();
00230 if (pszUrl && *pszUrl)
00231 {
00232 fsURL url;
00233 if (url.Crack (pszUrl) == IR_SUCCESS && *url.GetHostName ())
00234 m_strUrl = pszUrl;
00235 }
00236
00237 if (m_strUrl.GetLength () == 0)
00238 m_strUrl = "http://";
00239 }
00240
00241 SetDlgItemText (IDC_COMMENT, m_strComment);
00242
00243 CString strUser = _App.UserName ();
00244 m_bAuthorization = strUser.GetLength () != 0;
00245 SetDlgItemText (IDC_USER, strUser);
00246 SetDlgItemText (IDC_PASSWORD, _App.UserPassword ());
00247
00248 CheckDlgButton (IDC_USELOGIN, m_bAuthorization ? BST_CHECKED : BST_UNCHECKED);
00249
00250 m_wndGroups.Fill ();
00251
00252 LOG ("filling in history of urls...");
00253
00254 CComboBox *pUrls = (CComboBox*) GetDlgItem (IDC_URL);
00255 for (int i = 0; i < _LastUrlFiles.GetRecordCount (); i++)
00256 pUrls->AddString (_LastUrlFiles.GetRecord (i));
00257
00258 LOG ("ok." << nl);
00259 LOG ("filling in history of folders...");
00260
00261 CComboBox *pDirs = (CComboBox*) GetDlgItem (IDC_OUTFOLDER);
00262 for (i = 0; i < _LastFolders.GetRecordCount (); i++)
00263 pDirs->AddString (_LastFolders.GetRecord (i));
00264
00265 LOG ("ok." << nl);
00266
00267 CheckRadioButton (IDC_STARTNOW, IDC_STARTSCHEDULE, IDC_STARTNOW);
00268 m_dld->bAutoStart = TRUE;
00269
00270 LOG ("initializing download manager...");
00271
00272 if (IR_SUCCESS != m_dld->pMgr->GetDownloadMgr ()->CreateByUrl (m_strUrl, TRUE) && m_strUrl != "http://")
00273 {
00274 m_strUrl = "http://";
00275 m_dld->pMgr->GetDownloadMgr ()->CreateByUrl ("http://", TRUE);
00276 }
00277
00278 LOG ("ok." << nl);
00279
00280 if (m_strReferer != "")
00281 {
00282 SAFE_DELETE_ARRAY (m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszReferer);
00283 m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszReferer = new char [m_strReferer.GetLength () + 1];
00284 strcpy (m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszReferer, m_strReferer);
00285 }
00286
00287 m_bGroupChanged = m_bAuthChanged = FALSE;
00288
00289 fsURL url;
00290 if (IR_SUCCESS == url.Crack (m_strUrl) && *url.GetHostName ())
00291 {
00292 fsURL u;
00293 char szUrl [10000];
00294 DWORD dwLen = 10000;
00295 u.Create (url.GetInternetScheme (), url.GetHostName (), url.GetPort (), NULL, NULL, url.GetPath (), szUrl, &dwLen);
00296 m_strUrl = szUrl;
00297
00298 if (*url.GetUserName ())
00299 m_bAuthChanged = TRUE;
00300 }
00301
00302 Update_User_Password ();
00303
00304 SetDlgItemText (IDC_URL, m_strUrl == "http://url/" ? "http://" : m_strUrl);
00305 ((CEdit*) GetDlgItem (IDC_URL))->SetSel (0, -1);
00306
00307 GetDlgItem (IDC_URL)->SetFocus ();
00308 UrlChanged ();
00309
00310 if (m_bReqTopMostDialog)
00311 {
00312 fsSetForegroundWindow (m_hWnd);
00313 ::SetWindowPos (m_hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
00314 }
00315
00316 ReadAutostart ();
00317
00318 ApplyLanguage ();
00319
00320 m_bGroupChanged = FALSE;
00321
00322 if (m_pGroup == NULL)
00323 m_pGroup = _DldsGrps.FindGroup (_App.NewDL_GroupId ());
00324
00325 if (m_pGroup != NULL && m_wndGroups.SelectGroup (m_pGroup))
00326 {
00327 m_bGroupChanged = TRUE;
00328 OnChangeGroups ();
00329 }
00330
00331 LOG ("applying mirror parameters for download...");
00332
00333 _DldsMgr.Apply_MirrParameters (m_dld);
00334
00335 LOG ("ok." << nl);
00336
00337 m_wndDldType.AddString (LS (L_SAVEFILE));
00338 m_wndDldType.AddString (LS (L_OPENFILE));
00339 m_wndDldType.AddString (LS (L_SAVEFILEANDOPENIT));
00340 m_wndDldType.SetCurSel (0);
00341
00342 CheckDlgButton (IDC_FILEAUTO, _App.NewDL_GenerateNameAutomatically () ? BST_CHECKED : BST_UNCHECKED);
00343 OnFileauto ();
00344
00345 UpdateEnabled ();
00346
00347 LOG ("create download dialog initialized" << nl);
00348
00349 if (m_bSetFocusToOKBtn)
00350 {
00351 GetDlgItem (IDOK)->SetFocus ();
00352 return FALSE;
00353 }
00354
00355 return TRUE;
00356 }
00357
00358 void CCreateDownloadDlg::OnChangeSaveas()
00359 {
00360
00361 }
00362
00363 void CCreateDownloadDlg::UpdateEnabled()
00364 {
00365 LOG ("updating enabled...");
00366
00367 GetDlgItem (IDC__USER)->EnableWindow (m_bAuthorization);
00368 GetDlgItem (IDC_USER)->EnableWindow (m_bAuthorization);
00369 GetDlgItem (IDC__PASSWORD)->EnableWindow (m_bAuthorization);
00370 GetDlgItem (IDC_PASSWORD)->EnableWindow (m_bAuthorization);
00371
00372 int nSel = m_wndDldType.GetCurSel ();
00373 GetDlgItem (IDC__SAVETO)->EnableWindow (nSel != 1);
00374 GetDlgItem (IDC_OUTFOLDER)->EnableWindow (nSel != 1);
00375 GetDlgItem (IDC_CHOOSEFOLDER)->EnableWindow (nSel != 1);
00376 GetDlgItem (IDC_FILEAUTO)->EnableWindow (nSel != 1);
00377
00378 BOOL b = nSel != 1 && IsDlgButtonChecked (IDC_FILEAUTO) == BST_UNCHECKED;
00379 GetDlgItem (IDC__SAVEAS)->EnableWindow (b);
00380 GetDlgItem (IDC_SAVEAS)->EnableWindow (b);
00381
00382 LOG ("ok." << nl);
00383 }
00384
00385 void CCreateDownloadDlg::OnAuthorization()
00386 {
00387 m_bAuthorization = IsDlgButtonChecked (IDC_USELOGIN) == BST_CHECKED;
00388 UpdateEnabled ();
00389 }
00390
00391 void CCreateDownloadDlg::OnSelchangeGroups()
00392 {
00393 OnChangeGroups ();
00394 m_bGroupChanged = TRUE;
00395 }
00396
00397 void CCreateDownloadDlg::OnStartnow()
00398 {
00399 m_dld->bAutoStart = TRUE;
00400 m_bScheduled = FALSE;
00401 m_iAutostart = 0;
00402 }
00403
00404 void CCreateDownloadDlg::OnStartmanual()
00405 {
00406 m_bScheduled = FALSE;
00407 m_dld->bAutoStart = FALSE;
00408 m_iAutostart = 1;
00409 }
00410
00411 void CCreateDownloadDlg::OnStartschedule()
00412 {
00413 m_bScheduled = TRUE;
00414 m_dld->bAutoStart = FALSE;
00415 m_iAutostart = 2;
00416 }
00417
00418 void CCreateDownloadDlg::WrongURL()
00419 {
00420 MessageBox (LS (L_CHECKURL), LS (L_INPERR), MB_ICONEXCLAMATION);
00421 GetDlgItem (IDC_URL)->SetFocus ();
00422 }
00423
00424 void CCreateDownloadDlg::WrongUserName()
00425 {
00426 MessageBox (LS (L_ENTERUSER), LS (L_INPERR), MB_ICONEXCLAMATION);
00427 GetDlgItem (IDC_USER)->SetFocus ();
00428 }
00429
00430 void CCreateDownloadDlg::OnCreategroup()
00431 {
00432 if (m_wndGroups.CreateNewGroup (m_wndGroups.GetSelectedGroup ()))
00433 {
00434 OnChangeGroups ();
00435 }
00436 }
00437
00438 void CCreateDownloadDlg::OnAdvanced()
00439 {
00440 DLDS_LIST v;
00441 v.push_back (m_dld);
00442
00443 GetDlgItemText (IDC_URL, m_strUrl);
00444 fsURL url;
00445 if (url.Crack (m_strUrl) != IR_SUCCESS || *url.GetHostName () == 0 || *url.GetPath () == 0)
00446 {
00447 WrongURL ();
00448 return;
00449 }
00450
00451 if (FALSE == ReadDNP ())
00452 return;
00453
00454 m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->enProtocol = fsSchemeToNP (url.GetInternetScheme ());
00455
00456 CDownloadPropertiesSheet sheet (LS (L_ADVANCED), this);
00457 sheet.Init (&v, DPS_SHP_NOGENERALNOMIRR);
00458 _DlgMgr.OnDoModal (&sheet);
00459 sheet.DoModal ();
00460 _DlgMgr.OnEndDialog (&sheet);
00461 }
00462
00463 BOOL CCreateDownloadDlg::ReadDNP()
00464 {
00465 fsDownload_NetworkProperties *dnp = m_dld->pMgr->GetDownloadMgr ()->GetDNP ();
00466
00467 if (m_bUrlChanged)
00468 {
00469 m_dld->pMgr->GetDownloadMgr ()->GetDownloader ()->DeleteAllSections ();
00470 GetDlgItemText (IDC_URL, m_strUrl);
00471
00472 fsURL url;
00473 if (IR_SUCCESS != url.Crack (m_strUrl))
00474 {
00475 WrongURL ();
00476 return FALSE;
00477 }
00478
00479 if (fsDNP_ApplyUrl (dnp, m_strUrl) != IR_SUCCESS)
00480 {
00481 WrongURL ();
00482 return FALSE;
00483 }
00484 }
00485
00486 m_bAuthorization = IsDlgButtonChecked (IDC_USELOGIN) == BST_CHECKED;
00487
00488 if (m_bAuthorization)
00489 {
00490 CString strUser, strPassword;
00491
00492 GetDlgItemText (IDC_USER, strUser);
00493 GetDlgItemText (IDC_PASSWORD, strPassword);
00494
00495 if (strUser.GetLength () == 0)
00496 {
00497 WrongUserName ();
00498 return FALSE;
00499 }
00500
00501 fsDownload_NetworkProperties *dnp = m_dld->pMgr->GetDownloadMgr ()->GetDNP ();
00502
00503 SAFE_DELETE_ARRAY (dnp->pszUserName);
00504 SAFE_DELETE_ARRAY (dnp->pszPassword);
00505
00506 fsnew (dnp->pszUserName, CHAR, strUser.GetLength ()+1);
00507 fsnew (dnp->pszPassword, CHAR, strPassword.GetLength ()+1);
00508 strcpy (dnp->pszUserName, strUser);
00509 strcpy (dnp->pszPassword, strPassword);
00510 }
00511
00512 m_bUrlChanged = FALSE;
00513 return TRUE;
00514 }
00515
00516 void CCreateDownloadDlg::OnChoosefolder()
00517 {
00518 CString str = "";
00519 GetDlgItemText (IDC_OUTFOLDER, str);
00520
00521 if (str.GetLength () > 3 && (str [str.GetLength () - 1] == '\\' || str [str.GetLength () - 1] == '/'))
00522 str.GetBuffer (0) [str.GetLength () - 1] = 0;
00523
00524 CFolderBrowser *fb = CFolderBrowser::Create (LS (L_CHOOSEOUTFOLDER), str, NULL, this);
00525 if (fb == NULL)
00526 return;
00527
00528 SetDlgItemText (IDC_OUTFOLDER, fb->GetPath ());
00529 GetDlgItem (IDC_OUTFOLDER)->SetFocus ();
00530 }
00531
00532 void CCreateDownloadDlg::OnSettime()
00533 {
00534 CScheduleSheet sheet (LS (L_SCHEDULEDLDS), this);
00535
00536 sheet.Init (&m_task, FALSE);
00537
00538 _DlgMgr.OnDoModal (&sheet);
00539
00540 if (IDOK == sheet.DoModal ())
00541 {
00542 CheckRadioButton (IDC_STARTNOW, IDC_STARTSCHEDULE, IDC_STARTSCHEDULE);
00543 m_bScheduled = TRUE;
00544 m_dld->bAutoStart = FALSE;
00545 m_iAutostart = 2;
00546 }
00547
00548 _DlgMgr.OnEndDialog (&sheet);
00549 GetDlgItem (IDC_STARTSCHEDULE)->SetFocus ();
00550 }
00551
00552 void CCreateDownloadDlg::Update_User_Password()
00553 {
00554 BOOL b = m_bAuthChanged;
00555
00556 LOG ("updating user and password...");
00557
00558 fsDownload_NetworkProperties *dnp = m_dld->pMgr->GetDownloadMgr ()->GetDNP ();
00559 if (*dnp->pszUserName)
00560 {
00561 CheckDlgButton (IDC_USELOGIN, BST_CHECKED);
00562 m_bAuthorization = TRUE;
00563 }
00564 else
00565 {
00566 CheckDlgButton (IDC_USELOGIN, BST_UNCHECKED);
00567 m_bAuthorization = FALSE;
00568 }
00569
00570 SetDlgItemText (IDC_USER, dnp->pszUserName);
00571 SetDlgItemText (IDC_PASSWORD, dnp->pszPassword);
00572
00573 LOG ("ok." << nl);
00574
00575 UpdateEnabled ();
00576
00577 m_bAuthChanged = b;
00578 }
00579
00580 void CCreateDownloadDlg::OnEditchangeUrl()
00581 {
00582 GetDlgItemText (IDC_URL, m_strUrl);
00583 UrlChanged ();
00584 }
00585
00586 void CCreateDownloadDlg::OnSelchangeUrl()
00587 {
00588 CComboBox *pUrl = (CComboBox*) GetDlgItem (IDC_URL);
00589 pUrl->GetLBText (pUrl->GetCurSel (), m_strUrl);
00590 UrlChanged ();
00591 }
00592
00593 void CCreateDownloadDlg::UrlChanged()
00594 {
00595 LOG ("processing new url..." << nl);
00596
00597 CHAR szFile [10000];
00598 *szFile = 0;
00599 fsURL url;
00600
00601 m_bUrlChanged = TRUE;
00602
00603 if (m_dld->dwFlags & (DLD_MALICIOUS_NO | DLD_MALICIOUS_YES))
00604 {
00605 GetDlgItem (IDC_MALICIOUS)->EnableWindow (TRUE);
00606 m_dld->dwFlags &= ~ (DLD_MALICIOUS_NO | DLD_MALICIOUS_YES);
00607 }
00608
00609 if (IR_SUCCESS != url.Crack (m_strUrl))
00610 {
00611 LOG ("bad url" << nl);
00612 return;
00613 }
00614
00615 if (m_bGroupChanged == FALSE)
00616 {
00617 fsFileNameFromUrlPath (url.GetPath (), url.GetInternetScheme () == INTERNET_SCHEME_FTP,
00618 TRUE, szFile, sizeof (szFile));
00619
00620 int len = strlen (szFile);
00621 vmsDownloadsGroupSmartPtr grp;
00622
00623 if (len)
00624 {
00625 for (int i = len-1; i > 0; i--)
00626 if (szFile [i] == '.')
00627 break;
00628
00629 if (i && i < len-1)
00630 {
00631 i++;
00632 CHAR szExt [1000];
00633 strcpy (szExt, szFile + i);
00634 grp = _DldsGrps.FindGroupByExt (szExt);
00635 }
00636 }
00637
00638 if (grp == NULL)
00639 grp = _DldsGrps.FindGroup (GRP_OTHER_ID);
00640
00641 if (grp != NULL)
00642 {
00643 if (m_wndGroups.SelectGroup (grp))
00644 OnChangeGroups();
00645 }
00646 }
00647
00648 LOG ("searching for appropriate records in the Sites Manager..." << nl);
00649
00650 fsSiteInfo *site = _SitesMgr.FindSite2 (url.GetHostName (), fsNPToSiteValidFor (fsSchemeToNP (url.GetInternetScheme ())));
00651 if (site)
00652 {
00653 LOG ("an site was found" << nl);
00654 if (site->strUser != NULL && m_bAuthChanged == FALSE && *url.GetUserName () == 0)
00655 {
00656 LOG ("applying user and password...");
00657 CheckDlgButton (IDC_USELOGIN, BST_CHECKED);
00658 SetDlgItemText (IDC_USER, site->strUser);
00659 if (site->strPassword)
00660 SetDlgItemText (IDC_PASSWORD, site->strPassword);
00661 m_bAuthorization = TRUE;
00662 LOG ("done." << nl);
00663 UpdateEnabled ();
00664 }
00665
00666 if (site->pGroup && m_bGroupChanged == FALSE)
00667 {
00668 m_wndGroups.SelectGroup (site->pGroup);
00669 OnChangeGroups();
00670 }
00671 }
00672 else LOG ("no sites found" << nl);
00673
00674 LOG ("url was processed" << nl);
00675 }
00676
00677 void CCreateDownloadDlg::OnContextMenu(CWnd* , CPoint point)
00678 {
00679 PrepareCHMgr (point);
00680 _CHMgr.ShowMenu ();
00681 }
00682
00683 void CCreateDownloadDlg::OnWhatisthis()
00684 {
00685 _CHMgr.OnWT ();
00686 }
00687
00688 void CCreateDownloadDlg::OnChangeUser()
00689 {
00690 m_bAuthChanged = TRUE;
00691 }
00692
00693 void CCreateDownloadDlg::OnChangePassword()
00694 {
00695 m_bAuthChanged = TRUE;
00696 }
00697
00698 void CCreateDownloadDlg::OnChangeGroups()
00699 {
00700 SetDlgItemText (IDC_OUTFOLDER, m_wndGroups.GetSelectedGroup ()->strOutFolder);
00701 }
00702
00703 void CCreateDownloadDlg::ApplyLanguage()
00704 {
00705 fsDlgLngInfo lnginfo [] = {
00706 fsDlgLngInfo (IDC_USELOGIN, L_AUTHORIZATION),
00707 fsDlgLngInfo (IDC__USER, L_USER),
00708 fsDlgLngInfo (IDC__PASSWORD, L_PASSWORD),
00709 fsDlgLngInfo (IDC__SAVETO, L_SAVETO),
00710 fsDlgLngInfo (IDC__SAVEAS, L_SAVEAS),
00711 fsDlgLngInfo (IDC__START, L_START),
00712 fsDlgLngInfo (IDC_STARTNOW, L_AUTOMATICALLY),
00713 fsDlgLngInfo (IDC_STARTMANUAL, L_MANUALLY),
00714 fsDlgLngInfo (IDC_STARTSCHEDULE, L_SCHEDULE),
00715 fsDlgLngInfo (IDC__GROUP, L_GROUP),
00716 fsDlgLngInfo (IDC_ADVANCED, L_ADVANCED),
00717 fsDlgLngInfo (IDCANCEL, L_CANCEL),
00718 fsDlgLngInfo (IDC_QSIZE, L_QUERYSIZE),
00719 fsDlgLngInfo (IDC_FILEAUTO, L_FILEAUTO),
00720 fsDlgLngInfo (IDC_MIRRORS, L_MIRRORS),
00721
00722 fsDlgLngInfo (IDC__DLDTYPE, L_DLDTYPE),
00723 fsDlgLngInfo (IDC_MALICIOUS, L_IS_MALICIOUS),
00724 fsDlgLngInfo (IDC_PLACEATTOP, L_PLACEDLDATTOP),
00725 };
00726
00727 CString str = LS (L_COMMENT); str += ':';
00728 SetDlgItemText (IDC__COMMENT, str);
00729
00730 _LngMgr.ApplyLanguage (this, lnginfo, sizeof (lnginfo) / sizeof (fsDlgLngInfo), L_NEWDLD);
00731 }
00732
00733 void CCreateDownloadDlg::ReadAutostart()
00734 {
00735 m_iAutostart = _App.Last_Autostart ();
00736
00737 switch (m_iAutostart)
00738 {
00739 case 0:
00740 CheckRadioButton (IDC_STARTNOW, IDC_STARTSCHEDULE, IDC_STARTNOW);
00741 m_dld->bAutoStart = TRUE;
00742 m_bScheduled = FALSE;
00743 break;
00744
00745 case 1:
00746 CheckRadioButton (IDC_STARTNOW, IDC_STARTSCHEDULE, IDC_STARTMANUAL);
00747 m_dld->bAutoStart = FALSE;
00748 m_bScheduled = FALSE;
00749 break;
00750
00751 case 2:
00752 CheckRadioButton (IDC_STARTNOW, IDC_STARTSCHEDULE, IDC_STARTSCHEDULE);
00753 m_dld->bAutoStart = FALSE;
00754 m_bScheduled = TRUE;
00755 break;
00756 }
00757 }
00758
00759 BOOL CCreateDownloadDlg::OnHelpInfo(HELPINFO* pHelpInfo)
00760 {
00761 RECT rc;
00762 CWnd *pItem = GetDlgItem (pHelpInfo->iCtrlId);
00763 if (pItem == NULL)
00764 return TRUE;
00765 pItem->GetWindowRect (&rc);
00766 if (PtInRect (&rc, pHelpInfo->MousePos) == FALSE)
00767 {
00768 pHelpInfo->MousePos.x = rc.left + (rc.right - rc.left) / 2;
00769 pHelpInfo->MousePos.y = rc.top + (rc.bottom - rc.top) / 2;
00770 }
00771 PrepareCHMgr (pHelpInfo->MousePos);
00772 _CHMgr.OnWT ();
00773 return TRUE;
00774 }
00775
00776 void CCreateDownloadDlg::PrepareCHMgr(CPoint point)
00777 {
00778 fsCtrlContextHelp aCH1 [] = {
00779 fsCtrlContextHelp (IDC__URL, LS (L_ADDROFFILE)),
00780 fsCtrlContextHelp (IDC_URL, LS (L_ADDROFFILE)),
00781 fsCtrlContextHelp (IDC__USER, LS (L_USERHERE)),
00782 fsCtrlContextHelp (IDC_USER, LS (L_USERHERE)),
00783 fsCtrlContextHelp (IDC__PASSWORD, LS (L_PWDHERE)),
00784 fsCtrlContextHelp (IDC_PASSWORD, LS (L_PWDHERE)),
00785 fsCtrlContextHelp (IDC_USELOGIN, LS (L_LOGINHERE)),
00786 fsCtrlContextHelp (IDC__GROUP, LS (L_GROUPHERE)),
00787 fsCtrlContextHelp (IDC_GROUPS, LS (L_GROUPHERE)),
00788 fsCtrlContextHelp (IDC_CREATEGROUP, LS (L_CREATEGRP)),
00789 fsCtrlContextHelp (IDC__SAVETO, LS (L_DLDFOLDERHERE)),
00790 fsCtrlContextHelp (IDC_OUTFOLDER, LS (L_DLDFOLDERHERE)),
00791 fsCtrlContextHelp (IDC_CHOOSEFOLDER, LS (L_BROWSEFOR)),
00792 fsCtrlContextHelp (IDC__SAVEAS, LS (L_SAVEASHERE)),
00793 fsCtrlContextHelp (IDC_SAVEAS, LS (L_SAVEASHERE)),
00794 fsCtrlContextHelp (IDC__COMMENT, LS (L_DLDSHORTDESC)),
00795 fsCtrlContextHelp (IDC_COMMENT, LS (L_DLDSHORTDESC)),
00796 fsCtrlContextHelp (IDC_STARTNOW, LS (L_STARTNOWHERE)),
00797 fsCtrlContextHelp (IDC_STARTMANUAL, LS (L_MANUALLYSTARTHERE)),
00798 fsCtrlContextHelp (IDC_STARTSCHEDULE, LS (L_SCHEDULESTARTHERE)),
00799 fsCtrlContextHelp (IDC_SETTIME, LS (L_SETTIMEHERE)),
00800 fsCtrlContextHelp (IDC_ADVANCED, LS (L_ADVANCEDHERE)),
00801 fsCtrlContextHelp (IDOK, LS (L_ACCEPTCHANGES)),
00802 fsCtrlContextHelp (IDCANCEL, LS (L_DONTACCEPTCHANGES)),
00803 fsCtrlContextHelp (IDC_QSIZE, LS (L_QUERYSIZEHERE)),
00804 fsCtrlContextHelp (IDC_FILEAUTO, LS (L_FILEAUTOHERE)),
00805 fsCtrlContextHelp (IDC_MIRRORS, LS (L_MIRRORSHERE)),
00806 fsCtrlContextHelp (IDC_MALICIOUS, LS (L_IS_MALICIOUS_HERE)),
00807 fsCtrlContextHelp (IDC_PLACEATTOP, LS (L_PLACEDLDATTOPHERE)),
00808 };
00809
00810 static fsCtrlContextHelp aCH [sizeof (aCH1) / sizeof (fsCtrlContextHelp)];
00811 CopyMemory (aCH, aCH1, sizeof (aCH));
00812
00813 _CHMgr.PrepareContextMenu (this, point, aCH, sizeof (aCH) / sizeof (fsCtrlContextHelp));
00814 }
00815
00816 void CCreateDownloadDlg::OnQsize()
00817 {
00818 if (FALSE == ReadDNP ())
00819 return;
00820
00821 m_bUrlChanged = FALSE;
00822
00823 m_bThread = TRUE;
00824 DWORD dw;
00825 CloseHandle (CreateThread (NULL, 0, _threadQSize, this, 0, &dw));
00826 SetDlgItemText (IDC_QSIZE, LS (L_QUERINGSIZE));
00827 GetDlgItem (IDC_QSIZE)->EnableWindow (FALSE);
00828 }
00829
00830 DWORD WINAPI CCreateDownloadDlg::_threadQSize(LPVOID lp)
00831 {
00832 CCreateDownloadDlg *pThis = (CCreateDownloadDlg*) lp;
00833
00834 try{
00835
00836 if (pThis->m_pszCookies)
00837 {
00838 SAFE_DELETE_ARRAY (pThis->m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszCookies);
00839 pThis->m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszCookies = new char [lstrlen (pThis->m_pszCookies) + 1];
00840 lstrcpy (pThis->m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszCookies, pThis->m_pszCookies);
00841 }
00842
00843 if (pThis->m_pszPostData)
00844 {
00845 SAFE_DELETE_ARRAY (pThis->m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszPostData);
00846 pThis->m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszPostData = new char [lstrlen (pThis->m_pszPostData) + 1];
00847 lstrcpy (pThis->m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->pszPostData, pThis->m_pszPostData);
00848 }
00849
00850 fsInternetResult ir = pThis->m_dld->pMgr->GetDownloadMgr ()->QuerySize ();
00851
00852 if (ir != IR_SUCCESS)
00853 {
00854 char szMsg [1000];
00855 fsIRToStr (ir, szMsg, sizeof (szMsg));
00856 if (pThis->m_bNeedExit == FALSE)
00857 {
00858 pThis->MessageBox (szMsg, LS (L_ERR), MB_ICONERROR);
00859 pThis->SetDlgItemText (IDC_QSIZE, LS (L_QUERYSIZE));
00860 pThis->GetDlgItem (IDC_QSIZE)->EnableWindow (TRUE);
00861 }
00862 pThis->m_bThread = FALSE;
00863 return 0;
00864 }
00865
00866 CString strSize;
00867 UINT64 uSize = pThis->m_dld->pMgr->GetDownloadMgr ()->GetDownloader ()->GetSSFileSize ();
00868
00869 if (pThis->m_bNeedExit == FALSE)
00870 {
00871 if (uSize == _UI64_MAX)
00872 strSize = LS (L_UNKNOWN);
00873 else
00874 {
00875 if (_pwndDownloads->IsSizesInBytes () == FALSE)
00876 {
00877 char szDim [50];
00878 float fSize;
00879 BytesToXBytes (uSize, &fSize, szDim);
00880 strSize.Format ("%.*g %s", fSize > 999 ? 4 : 3, fSize, szDim);
00881 }
00882 else
00883 strSize = fsBytesToStr (uSize);
00884 }
00885
00886
00887 pThis->SetDlgItemText (IDC_QSIZE, strSize);
00888 pThis->GetDlgItem (IDC_QSIZE)->EnableWindow (TRUE);
00889 }
00890
00891 pThis->m_bThread = FALSE;
00892
00893 }catch (...) {}
00894
00895 return 0;
00896 }
00897
00898 void CCreateDownloadDlg::OnCancel()
00899 {
00900
00901 if (m_bThread)
00902 {
00903 m_bNeedExit = TRUE;
00904 m_dld->pMgr->GetDownloadMgr ()->StopQuering ();
00905 while (m_bThread);
00906 }
00907
00908 CDialog::OnCancel();
00909 }
00910
00911 void CCreateDownloadDlg::OnFileauto()
00912 {
00913 CString str;
00914 GetDlgItemText (IDC_SAVEAS, str);
00915 if (str == "" && IsDlgButtonChecked (IDC_FILEAUTO) == BST_UNCHECKED)
00916 {
00917 fsURL url;
00918 CString strURL;
00919 GetDlgItemText (IDC_URL, strURL);
00920 url.Crack (strURL);
00921 char szFile [MY_MAX_PATH];
00922 fsFileNameFromUrlPath (url.GetPath (), url.GetInternetScheme () == INTERNET_SCHEME_FTP,
00923 TRUE, szFile, sizeof (szFile));
00924 SetDlgItemText (IDC_SAVEAS, szFile);
00925 }
00926
00927 UpdateEnabled ();
00928 }
00929
00930 int CCreateDownloadDlg::_CheckDownloadAlrExists(vmsDownloadSmartPtr dld, BOOL bNeedTopMost, BOOL bShowUI)
00931 {
00932 fsURL url1, url2;
00933
00934 if (dld->pMgr->GetDownloadMgr () == NULL)
00935 return 0;
00936
00937 fsDownload_NetworkProperties* dnp0 = dld->pMgr->GetDownloadMgr ()->GetDNP ();
00938
00939 for (size_t i = 0; i < _DldsMgr.GetCount (); i++)
00940 {
00941 vmsDownloadSmartPtr d = _DldsMgr.GetDownload (i);
00942 if (d->pMgr->GetDownloadMgr () == NULL)
00943 continue;
00944 fsDownload_NetworkProperties* dnp = d->pMgr->GetDownloadMgr ()->GetDNP ();
00945
00946 if (dnp0->enProtocol == dnp->enProtocol &&
00947 dnp0->uServerPort == dnp->uServerPort &&
00948 fsIsServersEqual (dnp0->pszServerName, dnp->pszServerName, FALSE) &&
00949 lstrcmp (dnp0->pszPathName, dnp->pszPathName) == 0 &&
00950 lstrcmp (dnp0->pszUserName, dnp->pszUserName) == 0)
00951 {
00952 UINT nRet = IDCANCEL;
00953
00954 if (bShowUI)
00955 {
00956 CDownloadAlrExistsDlg dlg;
00957
00958 dlg.m_dld = d;
00959 dlg.m_bNeedTopMost = bNeedTopMost;
00960
00961 _DlgMgr.OnDoModal (&dlg);
00962 nRet = dlg.DoModal ();
00963 _DlgMgr.OnEndDialog (&dlg);
00964 }
00965
00966 switch (nRet)
00967 {
00968 case IDC_RESUME:
00969 if (d->pMgr->GetDownloadMgr ()->IsRunning () == FALSE)
00970 {
00971 DLDS_LIST v;
00972 v.push_back (d);
00973 _DldsMgr.StartDownloads (v, TRUE);
00974 }
00975 break;
00976
00977 case IDC_RESTART:
00978 if (dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName && *dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName)
00979 {
00980 if (lstrcmpi (d->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName, dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName))
00981 {
00982 SAFE_DELETE_ARRAY (d->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName);
00983 d->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName = new char [lstrlen (dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName)+1];
00984 lstrcpy (d->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName, dld->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName);
00985 }
00986 }
00987 _pwndDownloads->RestartDownload (d, TRUE);
00988 break;
00989
00990 case IDC_LAUNCH:
00991 if (d->pMgr->GetDownloadMgr ()->IsDone ())
00992 ShellExecute (::GetDesktopWindow (), "open", d->pMgr->GetDownloadMgr ()->GetDP ()->pszFileName,
00993 NULL, NULL, SW_SHOW);
00994 break;
00995
00996 case IDCANCEL:
00997 return 2;
00998 }
00999
01000 return 1;
01001 }
01002
01003 }
01004
01005 return 0;
01006 }
01007
01008 void CCreateDownloadDlg::OnMirrors()
01009 {
01010 DLDS_LIST v;
01011 v.push_back (m_dld);
01012
01013 GetDlgItemText (IDC_URL, m_strUrl);
01014 fsURL url;
01015 if (url.Crack (m_strUrl) != IR_SUCCESS || *url.GetHostName () == 0 || *url.GetPath () == 0)
01016 {
01017 WrongURL ();
01018 return;
01019 }
01020
01021 if (FALSE == ReadDNP ())
01022 return;
01023
01024 m_dld->pMgr->GetDownloadMgr ()->GetDNP ()->enProtocol = fsSchemeToNP (url.GetInternetScheme ());
01025
01026 CDownloadPropertiesSheet sheet (LS (L_MIRRORS), this);
01027 sheet.Init (&v, DPS_SHP_MIRRORS);
01028 _DlgMgr.OnDoModal (&sheet);
01029 sheet.DoModal ();
01030 _DlgMgr.OnEndDialog (&sheet);
01031 }
01032
01033 fsSiteInfo* CCreateDownloadDlg::_SavePassword(LPCSTR pszServer, fsNetworkProtocol np, LPCSTR pszUser, LPCSTR pszPwd)
01034 {
01035 if (pszUser == NULL || *pszUser == 0)
01036 return NULL;
01037
01038 if (_App.SM_KeepPasswords () && _App.SM_PwdsManualAddition () == FALSE)
01039 {
01040 fsSiteInfo *site = _SitesMgr.FindSite2 (pszServer, fsNPToSiteValidFor (np));
01041
01042 if (site == NULL || site->strUser != pszUser || site->strPassword != pszPwd)
01043 {
01044 CDlg_SavePassword dlg;
01045 if (IDOK == _DlgMgr.DoModal (&dlg))
01046 {
01047 if (site)
01048 {
01049 site->strUser = pszUser;
01050 site->strPassword = pszPwd;
01051 site->bTemp = FALSE;
01052 _SitesMgr.SiteUpdated (site);
01053 }
01054 else
01055 {
01056 fsSiteInfo site;
01057 site.strName = pszServer;
01058 site.pGroup = _DldsGrps.FindGroup (GRP_OTHER_ID);
01059 site.dwFtpFlags = FTP_USEPASSIVEMODE;
01060 site.cConnsNow = 0;
01061 site.cMaxConns = UINT_MAX;
01062 site.dwValidFor = fsNPToSiteValidFor (np) | SITE_VALIDFOR_SUBDOMAINS;
01063 site.strUser = pszUser;
01064 site.strPassword = pszPwd;
01065 site.bTemp = FALSE;
01066 int nSite = _SitesMgr.AddSite (site);
01067 return _SitesMgr.GetSite (nSite);
01068 }
01069 }
01070 }
01071 }
01072
01073 return NULL;
01074 }
01075
01076 void CCreateDownloadDlg::OnSelchangeDldtype()
01077 {
01078 UpdateEnabled ();
01079 }
01080
01081 fsSiteInfo* CCreateDownloadDlg::_SavePassword(vmsDownloadSmartPtr dld)
01082 {
01083 fsDownload_NetworkProperties *dnp = dld->pMgr->GetDownloadMgr ()->GetDNP ();
01084 fsSiteInfo* site = _SavePassword (dnp->pszServerName, dnp->enProtocol,
01085 dnp->pszUserName, dnp->pszPassword);
01086 if (site)
01087 {
01088 site->dwFtpFlags = dnp->dwFtpFlags;
01089 site->pGroup = dld->pGroup;
01090 _SitesMgr.SiteUpdated (site);
01091 }
01092
01093 return site;
01094 }
01095
01096 void CCreateDownloadDlg::OnMalicious()
01097 {
01098 GetDlgItemText (IDC_URL, m_strUrl);
01099
01100 vmsMaliciousDownloadChecker mdc;
01101 fsInternetResult ir = mdc.Check (m_strUrl);
01102 if (ir != IR_SUCCESS)
01103 {
01104 char sz [1000];
01105 fsIRToStr (ir, sz, sizeof (sz));
01106 MessageBox (sz, LS (L_ERR), MB_ICONERROR);
01107 return;
01108 }
01109
01110 GetDlgItem (IDC_MALICIOUS)->EnableWindow (FALSE);
01111
01112 int nPerc = MulDiv (mdc.get_MaliciousOpinionCount (), 100, mdc.get_OpinionTotalCount ());
01113 if (nPerc < _App.Community_MalReportsMinPerc ())
01114 {
01115 m_dld->dwFlags |= DLD_MALICIOUS_NO;
01116
01117 if (_App.View_DontShowMalOpinionOKReport () == FALSE)
01118 {
01119 UINT nRet = MyMessageBox (this, LS (L_NO_USERS_MAL_REPS), LS (L_DONE),
01120 LS (L_DONTSHOWTHISWINDOWAGAIN), IDI_INFORMATION);
01121 if (nRet & 0x00010000)
01122 _App.View_DontShowMalOpinionOKReport (TRUE);
01123 }
01124
01125 return;
01126 }
01127
01128 m_dld->dwFlags |= DLD_MALICIOUS_YES;
01129
01130 CString str;
01131 str.Format (LS (L_THEREAREMALOPINIONS), mdc.get_MaliciousOpinionCount (),
01132 mdc.get_OpinionTotalCount (), 2, mdc.get_AverageRating ());
01133 if (IDC_BTN2 == MyMessageBox (this, str, LS (L_WARNING), NULL, IDI_WARNING, LS (L_YES), LS (L_NO)))
01134 return;
01135
01136 CDlg_Opinions dlg;
01137 dlg.m_pszUrl = m_strUrl;
01138 if (IDC_ABORT == _DlgMgr.DoModal (&dlg))
01139 EndDialog (IDCANCEL);
01140 }
01141
01142 void CCreateDownloadDlg::OnOutfolderSetdefault()
01143 {
01144 CString strOutFolder;
01145 GetDlgItemText (IDC_OUTFOLDER, strOutFolder);
01146
01147 _SetDownloadOutputFolderAsDefault (this, strOutFolder, m_wndGroups.GetSelectedGroup ());
01148 }
01149
01150 BOOL CCreateDownloadDlg::_SetDownloadOutputFolderAsDefault(CWnd *pwndParent, LPCSTR pszFolder, vmsDownloadsGroupSmartPtr pGroup)
01151 {
01152 CMyMessageBox dlg (pwndParent);
01153 dlg.m_hIcon = LoadIcon (NULL, IDI_QUESTION);
01154 dlg.m_strBtn1Text = LS (L_YES);
01155 dlg.m_strBtn2Text = LS (L_NO);
01156 dlg.m_strCheckBoxText = LS (L_SETASDEFFORALLGROUPS);
01157
01158 dlg.m_strText.Format (LS (L_OKTOSETFOLDERASDEFFORGRP), pGroup->strName);
01159
01160 dlg.m_strTitle = LS (L_CONFIRMATION);
01161
01162 dlg.m_bChecked = FALSE != _App.View_SetOutputFolderAsDefForAllGrpsChecked ();
01163
01164 if (IDC_BTN1 != _DlgMgr.DoModal (&dlg))
01165 return FALSE;
01166
01167 _App.View_SetOutputFolderAsDefForAllGrpsChecked (dlg.m_bChecked);
01168
01169 CString strFolder;
01170 if (pszFolder [lstrlen (pszFolder) - 1] != '\\' &&
01171 pszFolder [lstrlen (pszFolder) - 1] != '/')
01172 {
01173 strFolder = pszFolder;
01174 strFolder += '\\';
01175 pszFolder = strFolder;
01176 }
01177
01178 if (dlg.m_bChecked)
01179 {
01180 for (size_t i = 0; i < _DldsGrps.GetTotalCount (); i++)
01181 _DldsGrps.GetGroup (i)->strOutFolder = pszFolder;
01182 }
01183 else
01184 {
01185 pGroup->strOutFolder = pszFolder;
01186 }
01187
01188 return TRUE;
01189 }
01190
01191 BOOL CCreateDownloadDlg::_CheckFileName(CDialog *pdlg, UINT nIdCtrl)
01192 {
01193 CString str;
01194 pdlg->GetDlgItemText (nIdCtrl, str);
01195 LPCSTR pszInvChars = "\\/:*?\"<>|";
01196 if (str.FindOneOf (pszInvChars) != -1)
01197 {
01198 pdlg->MessageBox (LS (L_INVFILENAME), LS (L_INPERR), MB_ICONEXCLAMATION);
01199 pdlg->GetDlgItem (nIdCtrl)->SetFocus ();
01200 return FALSE;
01201 }
01202
01203 return TRUE;
01204 }
01205
01206 BOOL CCreateDownloadDlg::_CheckFolderName(CDialog *pdlg, UINT nIdCtrl)
01207 {
01208 CString str;
01209 pdlg->GetDlgItemText (nIdCtrl, str);
01210 LPCSTR pszInvChars = ":*?\"<>|";
01211 if (str.GetLength () > 2 && str [1] == ':')
01212 str.Delete (1);
01213 if (str.FindOneOf (pszInvChars) != -1)
01214 {
01215 pdlg->MessageBox (LS (L_INVFOLDERNAME), LS (L_INPERR), MB_ICONEXCLAMATION);
01216 pdlg->GetDlgItem (nIdCtrl)->SetFocus ();
01217 return FALSE;
01218 }
01219
01220 return TRUE;
01221 }