Browse Source

- Prepare code for p2p ip filter support

adaptive-webui-19844
Christophe Dumez 17 years ago
parent
commit
b17c8b84d1
  1. 35
      src/options_imp.cpp
  2. 2
      src/options_imp.h

35
src/options_imp.cpp

@ -1037,7 +1037,7 @@ void options_imp::on_browseScanDirButton_clicked() { @@ -1037,7 +1037,7 @@ void options_imp::on_browseScanDirButton_clicked() {
}
void options_imp::on_browseFilterButton_clicked() {
QString ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an ipfilter.dat file"), QDir::homePath());
QString ipfilter = QFileDialog::getOpenFileName(this, tr("Choose an ip filter file"), QDir::homePath(), tr("Filters (*.dat *.p2p *.p2b)"));
if(!ipfilter.isNull()){
textFilterPath->setText(ipfilter);
processFilterFile(ipfilter);
@ -1052,13 +1052,8 @@ void options_imp::on_browseSaveDirButton_clicked(){ @@ -1052,13 +1052,8 @@ void options_imp::on_browseSaveDirButton_clicked(){
}
}
// Process ip filter file
// Supported formats:
// * eMule IP list (DAT): http://wiki.phoenixlabs.org/wiki/DAT_Format
// * PeerGuardian Text (P2P): http://wiki.phoenixlabs.org/wiki/P2P_Format (TODO)
// * PeerGuardian Binary (P2B): http://wiki.phoenixlabs.org/wiki/P2B_Format (TODO)
void options_imp::processFilterFile(QString filePath){
qDebug("Processing filter files");
// Parser for eMule ip filter in DAT format
void options_imp::parseDATFilterFile(QString filePath) {
QFile file(filePath);
QStringList IP;
if (file.exists()){
@ -1123,6 +1118,30 @@ void options_imp::processFilterFile(QString filePath){ @@ -1123,6 +1118,30 @@ void options_imp::processFilterFile(QString filePath){
}
}
// Parser for PeerGuardian ip filter in p2p format
void options_imp::parseP2PFilterFile(QString filePath) {
std::cerr << "p2p file support was not implemented yet\n";
}
// Process ip filter file
// Supported formats:
// * eMule IP list (DAT): http://wiki.phoenixlabs.org/wiki/DAT_Format
// * PeerGuardian Text (P2P): http://wiki.phoenixlabs.org/wiki/P2P_Format (TODO)
// * PeerGuardian Binary (P2B): http://wiki.phoenixlabs.org/wiki/P2B_Format (TODO)
void options_imp::processFilterFile(QString filePath){
qDebug("Processing filter files");
if(filePath.endsWith(".dat", Qt::CaseInsensitive)) {
// eMule DAT file
parseDATFilterFile(filePath);
} else {
if(filePath.endsWith(".p2p", Qt::CaseInsensitive)) {
// PeerGuardian p2p file
parseP2PFilterFile(filePath);
}
// TODO: Add p2b support
}
}
// Return Filter object to apply to BT session
ip_filter options_imp::getFilter() const{
return filter;

2
src/options_imp.h

@ -143,6 +143,8 @@ class options_imp : public QDialog, private Ui::Dialog { @@ -143,6 +143,8 @@ class options_imp : public QDialog, private Ui::Dialog {
void disableSystrayOptions();
void setSystrayOptionsState(int checkBoxValue);
void enableWebUi(bool checkBoxValue);
void parseDATFilterFile(QString filePath);
void parseP2PFilterFile(QString filePath);
public slots:
void setLocale(QString locale);

Loading…
Cancel
Save