BOOL CWPDS_GeneralPage::OnApply() 
{
	if (FALSE == WriteAuthorization ())
		return FALSE;

	vmsDownloadsGroupSmartPtr pGroup = m_wndGroups.GetSelectedGroup ();

	if (pGroup->nId != m_wpds->pDLGroup->nId)
	{
		m_wpds->pDLGroup = pGroup;
		if (m_wpds->m_ppoOwner)
			m_wpds->m_ppoOwner->setDirty();
		for (int i = 0; i < m_wpd->GetDownloadCount (); i++) {
			m_wpd->GetDownload (i)->pGroup = pGroup;
			m_wpd->GetDownload (i)->setDirty();
		}

		_pwndDownloads->OnDownloadsGroupChanged ();
	}
	
	return CPropertyPage::OnApply();
}
Пример #2
0
void CSpiderAddPageDlg::OnOK() 
{
	

	fsWPDSettings *wpds = m_wpd->GetWDPS ();

	GetDlgItemText (IDC_URL, m_strUrl);

	if (FALSE == WriteAuthorization ())
		return;

	BOOL bAddSlash;
	if (FALSE == IsOkUrl (m_strUrl, m_wpd->GetWDPS ()->strHTMLExts, &bAddSlash))
	{
		WrongURL ();
		return;
	}

	if (bAddSlash)
		m_strUrl += '/';

	CString strOutFolder;

	GetDlgItemText (IDC_OUTFOLDER, strOutFolder);

	if (FALSE == CCreateDownloadDlg::_CheckFolderName (this, IDC_OUTFOLDER))
		return;

	fsPathToGoodPath ((LPSTR)(LPCSTR)strOutFolder);

	if (strOutFolder.GetLength () == 0)
	{
		MessageBox (LS (L_ENTERFLRNAME), LS (L_INPERR), MB_ICONEXCLAMATION);
		GetDlgItem (IDC_OUTFOLDER)->SetFocus ();
		return;
	}

	_LastFolders.AddRecord (strOutFolder);
	_LastUrlFiles.AddRecord (m_strUrl);

	if (strOutFolder [strOutFolder.GetLength () - 1] != '\\' && 
		strOutFolder [strOutFolder.GetLength () - 1] != '/')
		strOutFolder += '\\';

        if (_App.NewGrp_SelectWay () == NGSW_USE_ALWAYS_SAME_GROUP_WITH_OUTFOLDER_AUTO_UPDATE)
	{
		vmsDownloadsGroupSmartPtr pGrp = _DldsGrps.FindGroup (_App.NewDL_GroupId ());
		if (pGrp != NULL)
			pGrp->strOutFolder = strOutFolder;
	}  

	wpds->pDLGroup = m_wndGroups.GetSelectedGroup ();

	wpds->strFolderSaveTo = strOutFolder;

	wpds->iDepth = GetDlgItemInt (IDC_DEPTH);

	wpds->dwFlags = 0;

	if (IsDlgButtonChecked (IDC_KEEP) == BST_CHECKED)
		wpds->dwFlags |= WPDF_KEEPFOLDERSTRUCTURE;

	if (IsDlgButtonChecked (IDC_DONTSTOREPAGES) == BST_CHECKED)
	{
		wpds->bDownloadStyles = FALSE;
		wpds->dwFlags |= WPDF_DONTSTOREPAGES;
	}

	if (IsDlgButtonChecked (IDC_DELCOMPLETED) == BST_CHECKED)
		wpds->dwFlags |= WPDF_DELCOMPLETEDDLDS;

	_App.Spider_Flags (wpds->dwFlags);

	m_wndGroups.RememberSelectedGroup ();
	_App.Last_Autostart (m_iAutostart);  

	if (wpds->strUserName.GetLength () != 0)
	{
		fsURL url;
		url.Crack (m_strUrl);
		fsSiteInfo* site = CCreateDownloadDlg::_SavePassword (url.GetHostName (), 
			fsSchemeToNP (url.GetInternetScheme ()), wpds->strUserName, wpds->strPassword);
		if (site) 
		{
			site->pGroup = wpds->pDLGroup;
			_SitesMgr.SiteUpdated (site);
		}
	}

	_App.OnDlHasBeenCreatedByUser ();
	
	CDialog::OnOK();
}
Пример #3
0
BOOL CDownloadProperties_GeneralPage::OnApply() 
{
	const int size = m_pvDlds->size ();

	if (size == 1)
	{
		CString strNewUrl;
		CString strNewFile;
		GetDlgItemText (IDC_URL, strNewUrl);
		GetDlgItemText (IDC_SAVEAS, strNewFile);
        if (FALSE == CCreateDownloadDlg::_CheckFolderName (this, IDC_SAVEAS))
			return FALSE;

		
		if (strNewUrl != m_strUrl)
		{
			
			{
				fsURL url;
				
				if (url.Crack (strNewUrl) != IR_SUCCESS || 
					 (url.GetInternetScheme () != INTERNET_SCHEME_FILE && *url.GetHostName () == 0))
				{
					MessageBox (LS (L_CHECKURL), LS (L_INPERR), MB_ICONEXCLAMATION);
					((CEdit*) GetDlgItem (IDC_URL))->SetSel (0, -1);
					GetDlgItem (IDC_URL)->SetFocus ();
					return FALSE;
				}

				m_pvDlds->at (0)->pMgr->GetDownloadMgr ()->CreateByUrl (strNewUrl, TRUE);
				if (*m_pvDlds->at (0)->pMgr->GetDownloadMgr ()->GetDNP ()->pszUserName)
					ReadAuthorization ();
			}
		}

		fsDownload_Properties *dp = m_pvDlds->at (0)->pMgr->GetDownloadMgr ()->GetDP ();

		
		if (strNewFile != dp->pszFileName)
		{
			if (FALSE == m_pvDlds->at (0)->pMgr->GetDownloadMgr ()->MoveFile (strNewFile))
			{
				if (GetLastError () == 0)
				{
					
					MessageBox (LS (L_CANTCHANGEFILENAME), LS (L_ERR), MB_ICONERROR);
				}
				else
				{
					CString strErr;
					CHAR szErr [1000];

					fsErrorToStr (szErr, 1000);

					strErr.Format ("%s\n\n%s: %s", LS (L_CANTRENAME), LS (L_ERR), szErr); 
					MessageBox (strErr, LS (L_ERR), MB_ICONERROR);
				}
			}
		}
	}

	_pwndDownloads->UpdateDownload (m_pvDlds->at (0), TRUE);

	vmsDownloadsGroupSmartPtr pGroup = m_wndGroups.GetSelectedGroup ();
	if (pGroup != NULL)
	{
		for (int i = 0; i < size; i++)
		{
			if (m_pvDlds->at (i)->pGroup->nId != pGroup->nId)
			{
				m_pvDlds->at (i)->pGroup->cDownloads--;
				m_pvDlds->at (i)->pGroup = pGroup;
				pGroup->cDownloads++;
				m_pvDlds->at (i)->pMgr->GetDownloadMgr ()->MoveToFolder (pGroup->strOutFolder);
			}
		}

		m_bNeedUpdateTasks = TRUE;
		_pwndDownloads->UpdateNumbersOfDownloadsInGroups ();
	}
	else
		m_bNeedUpdateTasks = FALSE;

	if (m_bCommentModified)
	{
		CString strComment;
		GetDlgItemText (IDC_COMMENT, strComment);

		for (int i = 0; i < size; i++)
		{
			m_pvDlds->at (i)->strComment = strComment;
			_pwndDownloads->UpdateDownload (m_pvDlds->at (i));
		}

		m_bNeedUpdateTasks = TRUE;
	}

	WriteAuthorization ();

	
	
	return CPropertyPage::OnApply();
}