void CCatDialog::OnBnClickedOk() { CString oldpath = m_myCat->strIncomingPath; if (GetDlgItem(IDC_TITLE)->GetWindowTextLength()>0) GetDlgItem(IDC_TITLE)->GetWindowText(m_myCat->strTitle); if (GetDlgItem(IDC_INCOMING)->GetWindowTextLength()>2) GetDlgItem(IDC_INCOMING)->GetWindowText(m_myCat->strIncomingPath); GetDlgItem(IDC_COMMENT)->GetWindowText(m_myCat->strComment); m_myCat->ac_regexpeval= IsDlgButtonChecked(IDC_REGEXPR)>0; MakeFoldername(m_myCat->strIncomingPath); if (!thePrefs.IsShareableDirectory(m_myCat->strIncomingPath)){ m_myCat->strIncomingPath = thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR); MakeFoldername(m_myCat->strIncomingPath); } if (!PathFileExists(m_myCat->strIncomingPath)){ if (!::CreateDirectory(m_myCat->strIncomingPath, 0)){ AfxMessageBox(GetResString(IDS_ERR_BADFOLDER)); m_myCat->strIncomingPath = oldpath; return; } } if (m_myCat->strIncomingPath.CompareNoCase(oldpath)!=0) theApp.sharedfiles->Reload(); m_myCat->color=newcolor; m_myCat->prio=m_prio.GetCurSel(); GetDlgItem(IDC_AUTOCATEXT)->GetWindowText(m_myCat->autocat); GetDlgItemText(IDC_REGEXP,m_myCat->regexp); if (m_myCat->regexp.GetLength()>0) { if (m_pacRegExp && m_pacRegExp->IsBound()){ m_pacRegExp->AddItem(m_myCat->regexp,0); m_myCat->filter=18; } } else if (m_myCat->filter==18) { // deactivate regexp m_myCat->filter=0; } theApp.emuledlg->transferwnd->GetDownloadList()->Invalidate(); OnOK(); }
BOOL CPPgDirectories::OnApply() { bool testtempdirchanged=false; CString testincdirchanged = thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR); CString strIncomingDir; GetDlgItemText(IDC_INCFILES, strIncomingDir); MakeFoldername(strIncomingDir); if (strIncomingDir.IsEmpty()){ strIncomingDir = thePrefs.GetDefaultDirectory(EMULE_INCOMINGDIR, true); // will create the directory here if it doesnt exists SetDlgItemText(IDC_INCFILES, strIncomingDir); } else if (thePrefs.IsInstallationDirectory(strIncomingDir)){ AfxMessageBox(GetResString(IDS_WRN_INCFILE_RESERVED)); return FALSE; } else if (strIncomingDir.CompareNoCase(testincdirchanged) != 0 && strIncomingDir.CompareNoCase(thePrefs.GetDefaultDirectory(EMULE_INCOMINGDIR, false)) != 0){ // if the user chooses a non-default directory which already contains files, inform him that all those files // will be shared CFileFind ff; CString strSearchPath; strSearchPath.Format(_T("%s\\*"),strIncomingDir); bool bEnd = !ff.FindFile(strSearchPath, 0); bool bExistingFile = false; while (!bEnd) { bEnd = !ff.FindNextFile(); if (ff.IsDirectory() || ff.IsDots() || ff.IsSystem() || ff.IsTemporary() || ff.GetLength()==0 || ff.GetLength()>MAX_EMULE_FILE_SIZE) continue; // ignore real LNK files TCHAR szExt[_MAX_EXT]; _tsplitpath(ff.GetFileName(), NULL, NULL, NULL, szExt); if (_tcsicmp(szExt, _T(".lnk")) == 0){ SHFILEINFO info; if (SHGetFileInfo(ff.GetFilePath(), 0, &info, sizeof(info), SHGFI_ATTRIBUTES) && (info.dwAttributes & SFGAO_LINK)){ if (!thePrefs.GetResolveSharedShellLinks()) continue; } } // ignore real THUMBS.DB files -- seems that lot of ppl have 'thumbs.db' files without the 'System' file attribute if (ff.GetFileName().CompareNoCase(_T("thumbs.db")) == 0) continue; bExistingFile = true; break; } if (bExistingFile && AfxMessageBox(GetResString(IDS_WRN_INCFILE_EXISTS), MB_OKCANCEL | MB_ICONINFORMATION) == IDCANCEL) { return FALSE; } } // checking specified tempdir(s) CString strTempDir; GetDlgItemText(IDC_TEMPFILES, strTempDir); if (strTempDir.IsEmpty()){ strTempDir = thePrefs.GetDefaultDirectory(EMULE_TEMPDIR, true); // will create the directory here if it doesnt exists SetDlgItemText(IDC_TEMPFILES, strTempDir); } int curPos=0; CStringArray temptempfolders; CString atmp=strTempDir.Tokenize(_T("|"), curPos); while (!atmp.IsEmpty()) { atmp.Trim(); if (!atmp.IsEmpty()) { if (CompareDirectories(strIncomingDir, atmp)==0){ AfxMessageBox(GetResString(IDS_WRN_INCTEMP_SAME)); return FALSE; } if (thePrefs.IsInstallationDirectory(atmp)){ AfxMessageBox(GetResString(IDS_WRN_TEMPFILES_RESERVED)); return FALSE; } bool doubled=false; for (int i=0;i<temptempfolders.GetCount();i++) // avoid double tempdirs if (temptempfolders.GetAt(i).CompareNoCase(atmp)==0) { doubled=true; break; } if (!doubled) { temptempfolders.Add(atmp); if (thePrefs.tempdir.GetCount()>=temptempfolders.GetCount()) { if( atmp.CompareNoCase(thePrefs.GetTempDir(temptempfolders.GetCount()-1))!=0 ) testtempdirchanged=true; } else testtempdirchanged=true; } } atmp = strTempDir.Tokenize(_T("|"), curPos); } if (temptempfolders.IsEmpty()) temptempfolders.Add(strTempDir = thePrefs.GetDefaultDirectory(EMULE_TEMPDIR, true)); if (temptempfolders.GetCount()!=thePrefs.tempdir.GetCount()) testtempdirchanged=true; // applying tempdirs if (testtempdirchanged) { thePrefs.tempdir.RemoveAll(); for (int i=0;i<temptempfolders.GetCount();i++) { CString toadd=temptempfolders.GetAt(i); MakeFoldername(toadd); if (!PathFileExists(toadd)) CreateDirectory(toadd,NULL); if (PathFileExists(toadd)) thePrefs.tempdir.Add(toadd); } } if (thePrefs.tempdir.IsEmpty()) thePrefs.tempdir.Add(thePrefs.GetDefaultDirectory(EMULE_TEMPDIR, true)); thePrefs.m_strIncomingDir = strIncomingDir; MakeFoldername(thePrefs.m_strIncomingDir); thePrefs.GetCategory(0)->strIncomingPath = thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR); thePrefs.shareddir_list.RemoveAll(); m_ShareSelector.GetSharedDirectories(&thePrefs.shareddir_list); for (int i = 0; i < m_ctlUncPaths.GetItemCount(); i++) thePrefs.shareddir_list.AddTail(m_ctlUncPaths.GetItemText(i, 0)); // check shared directories for reserved folder names POSITION pos = thePrefs.shareddir_list.GetHeadPosition(); while (pos){ POSITION posLast = pos; const CString& rstrDir = thePrefs.shareddir_list.GetNext(pos); if (!thePrefs.IsShareableDirectory(rstrDir)) thePrefs.shareddir_list.RemoveAt(posLast); } if (testtempdirchanged) AfxMessageBox(GetResString(IDS_SETTINGCHANGED_RESTART)); // on changing incoming dir, update incoming dirs of category of the same path if (testincdirchanged.CompareNoCase(thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR)) != 0) { CString oldpath; bool dontaskagain=false; for (int cat=1; cat<=thePrefs.GetCatCount()-1;cat++){ oldpath=CString(thePrefs.GetCatPath(cat)); if (oldpath.Left(testincdirchanged.GetLength()).CompareNoCase(testincdirchanged)==0) { if (!dontaskagain) { dontaskagain=true; if (AfxMessageBox(GetResString(IDS_UPDATECATINCOMINGDIRS),MB_YESNO)==IDNO) break; } thePrefs.GetCategory(cat)->strIncomingPath = thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR) + oldpath.Mid(testincdirchanged.GetLength()); } } } theApp.emuledlg->sharedfileswnd->Reload(); SetModified(0); return CPropertyPage::OnApply(); }
void CCatDialog::OnBnClickedOk() { CString oldpath = m_myCat->strIncomingPath; if (GetDlgItem(IDC_TITLE)->GetWindowTextLength()>0) GetDlgItem(IDC_TITLE)->GetWindowText(m_myCat->strTitle); if (GetDlgItem(IDC_INCOMING)->GetWindowTextLength()>2) GetDlgItem(IDC_INCOMING)->GetWindowText(m_myCat->strIncomingPath); GetDlgItem(IDC_COMMENT)->GetWindowText(m_myCat->strComment); // ==> Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle /* m_myCat->ac_regexpeval= IsDlgButtonChecked(IDC_REGEXPR)>0; */ // <== Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle MakeFoldername(m_myCat->strIncomingPath); // SLUGFILLER: SafeHash remove - removed installation dir unsharing /* if (!thePrefs.IsShareableDirectory(m_myCat->strIncomingPath)){ m_myCat->strIncomingPath = thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR); MakeFoldername(m_myCat->strIncomingPath); } */ // SLUGFILLER: SafeHash remove - removed installation dir unsharing if (!PathFileExists(m_myCat->strIncomingPath)){ if (!::CreateDirectory(m_myCat->strIncomingPath, 0)){ AfxMessageBox(GetResString(IDS_ERR_BADFOLDER)); m_myCat->strIncomingPath = oldpath; return; } } if (m_myCat->strIncomingPath.CompareNoCase(oldpath)!=0) { // Automatic shared files updater [MoNKi] - Stulle // ==> Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle /* theApp.sharedfiles->Reload(); */ theApp.emuledlg->sharedfileswnd->Reload(); // <== Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle // ==> Automatic shared files updater [MoNKi] - Stulle if(thePrefs.GetDirectoryWatcher()) theApp.ResetDirectoryWatcher(); } // <== Automatic shared files updater [MoNKi] - Stulle m_myCat->color=newcolor; m_myCat->prio=m_prio.GetCurSel(); // ==> Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle /* GetDlgItem(IDC_AUTOCATEXT)->GetWindowText(m_myCat->autocat); GetDlgItemText(IDC_REGEXP,m_myCat->regexp); if (m_myCat->regexp.GetLength()>0) { if (m_pacRegExp && m_pacRegExp->IsBound()){ m_pacRegExp->AddItem(m_myCat->regexp,0); m_myCat->filter=18; } } else if (m_myCat->filter==18) { // deactivate regexp m_myCat->filter=0; } */ GetDlgItem(IDC_AUTOCATEXT)->GetWindowText(m_myCat->viewfilters.sAdvancedFilterMask); m_myCat->m_iDlMode = m_comboDlMode.GetCurSel(); CString sBuffer; GetDlgItem(IDC_FS_MIN)->GetWindowText(sBuffer); m_myCat->viewfilters.nFSizeMin = CastXBytesToI(sBuffer); GetDlgItem(IDC_FS_MAX)->GetWindowText(sBuffer); m_myCat->viewfilters.nFSizeMax = CastXBytesToI(sBuffer); GetDlgItem(IDC_RS_MIN)->GetWindowText(sBuffer); m_myCat->viewfilters.nRSizeMin = CastXBytesToI(sBuffer); GetDlgItem(IDC_RS_MAX)->GetWindowText(sBuffer); m_myCat->viewfilters.nRSizeMax = CastXBytesToI(sBuffer); GetDlgItem(IDC_RT_MIN)->GetWindowText(sBuffer); m_myCat->viewfilters.nTimeRemainingMin = (uint32) (60 * _tstoi(sBuffer)); GetDlgItem(IDC_RT_MAX)->GetWindowText(sBuffer); m_myCat->viewfilters.nTimeRemainingMax = (uint32) (60 * _tstoi(sBuffer)); GetDlgItem(IDC_SC_MIN)->GetWindowText(sBuffer); m_myCat->viewfilters.nSourceCountMin = _tstoi(sBuffer); GetDlgItem(IDC_SC_MAX)->GetWindowText(sBuffer); m_myCat->viewfilters.nSourceCountMax = _tstoi(sBuffer); GetDlgItem(IDC_ASC_MIN)->GetWindowText(sBuffer); m_myCat->viewfilters.nAvailSourceCountMin = _tstoi(sBuffer); GetDlgItem(IDC_ASC_MAX)->GetWindowText(sBuffer); m_myCat->viewfilters.nAvailSourceCountMax = _tstoi(sBuffer); m_myCat->selectioncriteria.bFileSize = IsDlgButtonChecked(IDC_CHECK_FS)?true:false; m_myCat->selectioncriteria.bAdvancedFilterMask = IsDlgButtonChecked(IDC_CHECK_MASK)?true:false; m_myCat->bResumeFileOnlyInSameCat = IsDlgButtonChecked(IDC_CHECK_RESUMEFILEONLYINSAMECAT)?true:false; //MORPH - Added by SiRoB, Resume file only in the same category // <== Smart Category Control (SCC) [khaos/SiRoB/Stulle] - Stulle theApp.emuledlg->transferwnd->GetDownloadList()->Invalidate(); OnOK(); }
BOOL CPPgDirectories::OnApply() { bool testtempdirchanged=false; CString testincdirchanged=thePrefs.GetIncomingDir(); CString strIncomingDir; GetDlgItemText(IDC_INCFILES, strIncomingDir); if (strIncomingDir.IsEmpty()){ strIncomingDir = thePrefs.GetAppDir() + _T("incoming"); SetDlgItemText(IDC_INCFILES, strIncomingDir); } if (thePrefs.IsInstallationDirectory(strIncomingDir)){ AfxMessageBox(GetResString(IDS_WRN_INCFILE_RESERVED)); return FALSE; } // checking specified tempdir(s) CString strTempDir; GetDlgItemText(IDC_TEMPFILES, strTempDir); if (strTempDir.IsEmpty()){ strTempDir = thePrefs.GetAppDir() + _T("temp"); SetDlgItemText(IDC_TEMPFILES, strTempDir); } int curPos=0; CStringArray temptempfolders; CString atmp=strTempDir.Tokenize(_T("|"), curPos); while (!atmp.IsEmpty()) { atmp.Trim(); if (!atmp.IsEmpty()) { if (CompareDirectories(strIncomingDir, atmp)==0){ AfxMessageBox(GetResString(IDS_WRN_INCTEMP_SAME)); return FALSE; } if (thePrefs.IsInstallationDirectory(atmp)){ AfxMessageBox(GetResString(IDS_WRN_TEMPFILES_RESERVED)); return FALSE; } bool doubled=false; for (int i=0;i<temptempfolders.GetCount();i++) // avoid double tempdirs if (temptempfolders.GetAt(i).CompareNoCase(atmp)==0) { doubled=true; break; } if (!doubled) { temptempfolders.Add(atmp); if (thePrefs.tempdir.GetCount()>=temptempfolders.GetCount()) { if( atmp.CompareNoCase(thePrefs.GetTempDir(temptempfolders.GetCount()-1))!=0 ) testtempdirchanged=true; } else testtempdirchanged=true; } } atmp = strTempDir.Tokenize(_T("|"), curPos); } if (temptempfolders.IsEmpty()) temptempfolders.Add(strTempDir = thePrefs.GetAppDir() + _T("temp")); if (temptempfolders.GetCount()!=thePrefs.tempdir.GetCount()) testtempdirchanged=true; // applying tempdirs if (testtempdirchanged) { thePrefs.tempdir.RemoveAll(); for (int i=0;i<temptempfolders.GetCount();i++) { CString toadd=temptempfolders.GetAt(i); MakeFoldername( toadd.GetBuffer(MAX_PATH) ); if (!PathFileExists(toadd)) CreateDirectory(toadd,NULL); if (PathFileExists(toadd)) thePrefs.tempdir.Add(toadd); } } // incomingdir _sntprintf(thePrefs.incomingdir, ARRSIZE(thePrefs.incomingdir), _T("%s"), strIncomingDir); MakeFoldername(thePrefs.incomingdir); _stprintf(thePrefs.GetCategory(0)->incomingpath,_T("%s"),thePrefs.incomingdir); thePrefs.shareddir_list.RemoveAll(); m_ShareSelector.GetSharedDirectories(&thePrefs.shareddir_list); for (int i = 0; i < m_ctlUncPaths.GetItemCount(); i++) thePrefs.shareddir_list.AddTail(m_ctlUncPaths.GetItemText(i, 0)); // check shared directories for reserved folder names POSITION pos = thePrefs.shareddir_list.GetHeadPosition(); while (pos){ POSITION posLast = pos; const CString& rstrDir = thePrefs.shareddir_list.GetNext(pos); if (!thePrefs.IsShareableDirectory(rstrDir)) thePrefs.shareddir_list.RemoveAt(posLast); } theApp.emuledlg->sharedfileswnd->Reload(); if (testtempdirchanged) AfxMessageBox(GetResString(IDS_SETTINGCHANGED_RESTART)); // on changing incoming dir, update incoming dirs of category of the same path if (testincdirchanged.CompareNoCase(thePrefs.GetIncomingDir())!=0) { CString oldpath; bool dontaskagain=false; for (int cat=1; cat<=thePrefs.GetCatCount()-1;cat++){ oldpath=CString(thePrefs.GetCatPath(cat)); if (oldpath.Left(testincdirchanged.GetLength()).CompareNoCase(testincdirchanged)==0) { if (!dontaskagain) { dontaskagain=true; if (AfxMessageBox(GetResString(IDS_UPDATECATINCOMINGDIRS),MB_YESNO)==IDNO) break; } _sntprintf(thePrefs.GetCategory(cat)->incomingpath, ARRSIZE(thePrefs.GetCategory(cat)->incomingpath), _T("%s%s"), thePrefs.GetIncomingDir(), oldpath.Mid(testincdirchanged.GetLength())); } } } SetModified(0); return CPropertyPage::OnApply(); }