Exemplo n.º 1
0
void CPPgNotify::OnBnClickedBtnBrowseWav()
{
    CString strWavPath;
    GetDlgItemText(IDC_EDIT_TBN_WAVFILE, strWavPath);
    CString buffer;
    if (DialogBrowseFile(buffer, _T("Audio-Wav (*.wav)|*.wav||"), strWavPath)) {
        SetDlgItemText(IDC_EDIT_TBN_WAVFILE, buffer);
        SetModified();
    }
}
Exemplo n.º 2
0
void CPPgWebServer::OnBnClickedTmplbrowse()
{
	CString strTempl;
	GetDlgItemText(IDC_TMPLPATH, strTempl);
	CString buffer;
	buffer=GetResString(IDS_WS_RELOAD_TMPL)+_T("(*.tmpl)|*.tmpl||");
    if (DialogBrowseFile(buffer, _T("Template ")+buffer, strTempl)){
		GetDlgItem(IDC_TMPLPATH)->SetWindowText(buffer);
		SetModified();
	}
}
Exemplo n.º 3
0
void CIPFilterDlg::OnBnClickedAppend()
{
	CString strFilePath;			  // Do NOT localize that string
	if (DialogBrowseFile(strFilePath, _T("All IP Filter Files (*ipfilter.dat;*ip.prefix;*.p2b;*.p2p;*.p2p.txt;*.zip;*.gz;*.rar)|*ipfilter.dat;*ip.prefix;*.p2b;*.p2p;*.p2p.txt;*.zip;*.gz;*.rar|eMule IP Filter Files (*ipfilter.dat;*ip.prefix)|*ipfilter.dat;*ip.prefix|Peer Guardian Files (*.p2b;*.p2p;*.p2p.txt)|*.p2b;*.p2p;*.p2p.txt|Text Files (*.txt)|*.txt|ZIP Files (*.zip;*.gz)|*.zip;*.gz|RAR Files (*.rar)|*.rar|All Files (*.*)|*.*||")))
	{
		CWaitCursor curWait;

		TCHAR szExt[_MAX_EXT];
		_tsplitpath(strFilePath, NULL, NULL, NULL, szExt);
		_tcslwr(szExt);
		bool bIsArchiveFile = _tcscmp(szExt, _T(".zip"))==0 || _tcscmp(szExt, _T(".rar"))==0 || _tcscmp(szExt, _T(".gz"))==0;
		bool bExtractedArchive = false;

		CString strTempUnzipFilePath;
		if (_tcscmp(szExt, _T(".zip")) == 0)
		{
			CZIPFile zip;
			if (zip.Open(strFilePath))
			{
				CZIPFile::File* zfile = zip.GetFile(_T("guarding.p2p"));
				if (zfile == NULL)
					zfile = zip.GetFile(_T("ipfilter.dat"));
				if (zfile)
				{
					_tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp"));
					strTempUnzipFilePath.ReleaseBuffer();
					if (zfile->Extract(strTempUnzipFilePath))
					{
						strFilePath = strTempUnzipFilePath;
						bExtractedArchive = true;
					}
					else
					{
						CString strError;
						strError.Format(_T("Failed to extract IP filter file from ZIP file \"%s\"."), strFilePath);
						AfxMessageBox(strError, MB_ICONERROR);
					}
				}
				else
				{
					CString strError;
					strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" or \"ipfilter.dat\" in ZIP file \"%s\"."), strFilePath);
					AfxMessageBox(strError, MB_ICONERROR);
				}
				zip.Close();
			}
			else
			{
				CString strError;
				strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?"), strFilePath);
				AfxMessageBox(strError, MB_ICONERROR);
			}
		}
		else if (_tcscmp(szExt, _T(".rar")) == 0)
		{
			CRARFile rar;
			if (rar.Open(strFilePath))
			{
				CString strFile;
				if (rar.GetNextFile(strFile)
					&& (strFile.CompareNoCase(_T("ipfilter.dat")) == 0 || strFile.CompareNoCase(_T("guarding.p2p")) == 0))
				{
					_tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp"));
					strTempUnzipFilePath.ReleaseBuffer();
					if (rar.Extract(strTempUnzipFilePath))
					{
						strFilePath = strTempUnzipFilePath;
						bExtractedArchive = true;
					}
					else
					{
						CString strError;
						strError.Format(_T("Failed to extract IP filter file from RAR file \"%s\"."), strFilePath);
						AfxMessageBox(strError, MB_ICONERROR);
					}
				}
				else
				{
					CString strError;
					strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" or \"ipfilter.dat\" in RAR file \"%s\"."), strFilePath);
					AfxMessageBox(strError, MB_ICONERROR);
				}
				rar.Close();
			}
			else
			{
				CString strError;
				strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?\r\n\r\nDownload latest version of UNRAR.DLL from http://www.rarlab.com and copy UNRAR.DLL into eMule installation folder."), strFilePath);
				AfxMessageBox(strError, MB_ICONERROR);
			}
		}
		else if (_tcscmp(szExt, _T(".gz")) == 0)
		{
			CGZIPFile gz;
			if (gz.Open(strFilePath))
			{
				_tmakepathlimit(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetMuleDirectory(EMULE_CONFIGDIR), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp"));
				strTempUnzipFilePath.ReleaseBuffer();

				// add filename and extension of uncompressed file to temporary file
				CString strUncompressedFileName = gz.GetUncompressedFileName();
				if (!strUncompressedFileName.IsEmpty())
				{
					strTempUnzipFilePath += _T('.');
					strTempUnzipFilePath += strUncompressedFileName;
				}

				if (gz.Extract(strTempUnzipFilePath))
				{
					strFilePath = strTempUnzipFilePath;
					bExtractedArchive = true;
				}
				gz.Close();
			}
			else
			{
				CString strError;
				strError.Format(_T("Failed to open file \"%s\".\r\n\r\nInvalid file format?"), strFilePath);
				AfxMessageBox(strError, MB_ICONERROR);
			}
		}

		if ((!bIsArchiveFile || bExtractedArchive) && theApp.ipfilter->AddFromFile(strFilePath, true))
		{
			if (thePrefs.GetFilterServerByIP())
				theApp.emuledlg->serverwnd->serverlistctrl.RemoveAllFilteredServers();
			InitIPFilters();
			m_ipfilter.Update(-1);
		}

		if (!strTempUnzipFilePath.IsEmpty())
			VERIFY( _tremove(strTempUnzipFilePath) == 0);
	}
}
Exemplo n.º 4
0
void CIPFilterDlg::OnBnClickedAppend()
{
	CString strFilePath;
	if (DialogBrowseFile(strFilePath, GetResString(IDS_IPFILTERFILES)))
	{
		CWaitCursor curWait;
		CString strTempUnzipFilePath;
		CZIPFile zip;
		if (zip.Open(strFilePath))
		{
			CZIPFile::File* zfile = zip.GetFile(_T("guarding.p2p"));
			if (zfile)
			{
				_tmakepath(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetConfigDir(), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp"));
				strTempUnzipFilePath.ReleaseBuffer();
				if (zfile->Extract(strTempUnzipFilePath))
					strFilePath = strTempUnzipFilePath;
				else
				{
					CString strError;
					strError.Format(_T("Failed to extract IP filter file \"guarding.p2p\" from ZIP file \"%s\"."), strFilePath);
					AfxMessageBox(strError);
				}
			}
			else
			{
				CString strError;
				strError.Format(_T("Failed to find IP filter file \"guarding.p2p\" in ZIP file \"%s\"."), strFilePath);
				AfxMessageBox(strError);
			}
			zip.Close();
		}
		else
		{
			CGZIPFile gz;
			if (gz.Open(strFilePath))
			{
				_tmakepath(strTempUnzipFilePath.GetBuffer(MAX_PATH), NULL, thePrefs.GetConfigDir(), DFLT_IPFILTER_FILENAME, _T(".unzip.tmp"));
				strTempUnzipFilePath.ReleaseBuffer();

				// add filename and extension of uncompressed file to temporary file
				CString strUncompressedFileName = gz.GetUncompressedFileName();
				if (!strUncompressedFileName.IsEmpty())
				{
					strTempUnzipFilePath += _T('.');
					strTempUnzipFilePath += strUncompressedFileName;
				}

				if (gz.Extract(strTempUnzipFilePath))
					strFilePath = strTempUnzipFilePath;
			}
			gz.Close();
		}

		if (theApp.ipfilter->AddFromFile(strFilePath, true))
		{
			InitIPFilters();
			m_ipfilter.Update(-1);
		}

		if (!strTempUnzipFilePath.IsEmpty())
			_tremove(strTempUnzipFilePath);
	}
}