Merge pull request #2303 from Gelmir/gattrs

Normalize line endings
This commit is contained in:
sledgehammer999 2014-12-20 19:59:03 +02:00
commit 7b24157ce3
19 changed files with 2646 additions and 2639 deletions

7
.gitattributes vendored Normal file
View file

@ -0,0 +1,7 @@
core.eol=lf
* text eol=lf
*.zip binary
*.png binary
*.ico binary
*.qm binary
*.icns binary

View file

@ -1,9 +1,9 @@
Flag icons - http://www.famfamfam.com
Flag icons - http://www.famfamfam.com
These icons are public domain, and as such are free for any use (attribution appreciated but not required).
Note that these flags are named using the ISO3166-1 alpha-2 country codes where appropriate. A list of codes can be found at http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
If you find these icons useful, please donate via paypal to mjames@gmail.com (or click the donate button available at http://www.famfamfam.com/lab/icons/silk)
Contact: mjames@gmail.com

View file

@ -1,101 +1,101 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include <QDebug>
#include <QFileInfo>
#include <QLocale>
#include <QLibraryInfo>
#include <QSysInfo>
#include "application.h"
#include "preferences.h"
Application::Application(const QString &id, int &argc, char **argv)
#ifndef DISABLE_GUI
: SessionApplication(id, argc, argv)
#else
: QtSingleCoreApplication(id, argc, argv)
#endif
{
#if defined(Q_OS_MACX) && !defined(DISABLE_GUI)
if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) {
// fix Mac OS X 10.9 (mavericks) font issue
// https://bugreports.qt-project.org/browse/QTBUG-32789
QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
}
#endif
setApplicationName("qBittorrent");
initializeTranslation();
#ifndef DISABLE_GUI
setStyleSheet("QStatusBar::item { border-width: 0; }");
setQuitOnLastWindowClosed(false);
#endif
}
void Application::initializeTranslation()
{
Preferences* const pref = Preferences::instance();
// Load translation
QString locale = pref->getLocale();
if (locale.isEmpty()) {
locale = QLocale::system().name();
pref->setLocale(locale);
}
if (qtTranslator_.load(
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QString::fromUtf8("qtbase_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ||
qtTranslator_.load(
#endif
QString::fromUtf8("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
qDebug("Qt %s locale recognized, using translation.", qPrintable(locale));
}
else {
qDebug("Qt %s locale unrecognized, using default (en).", qPrintable(locale));
}
installTranslator(&qtTranslator_);
if (translator_.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}
else {
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
}
installTranslator(&translator_);
#ifndef DISABLE_GUI
if (locale.startsWith("ar") || locale.startsWith("he")) {
qDebug("Right to Left mode");
setLayoutDirection(Qt::RightToLeft);
}
else {
setLayoutDirection(Qt::LeftToRight);
}
#endif
}
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#include <QDebug>
#include <QFileInfo>
#include <QLocale>
#include <QLibraryInfo>
#include <QSysInfo>
#include "application.h"
#include "preferences.h"
Application::Application(const QString &id, int &argc, char **argv)
#ifndef DISABLE_GUI
: SessionApplication(id, argc, argv)
#else
: QtSingleCoreApplication(id, argc, argv)
#endif
{
#if defined(Q_OS_MACX) && !defined(DISABLE_GUI)
if (QSysInfo::MacintoshVersion > QSysInfo::MV_10_8) {
// fix Mac OS X 10.9 (mavericks) font issue
// https://bugreports.qt-project.org/browse/QTBUG-32789
QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
}
#endif
setApplicationName("qBittorrent");
initializeTranslation();
#ifndef DISABLE_GUI
setStyleSheet("QStatusBar::item { border-width: 0; }");
setQuitOnLastWindowClosed(false);
#endif
}
void Application::initializeTranslation()
{
Preferences* const pref = Preferences::instance();
// Load translation
QString locale = pref->getLocale();
if (locale.isEmpty()) {
locale = QLocale::system().name();
pref->setLocale(locale);
}
if (qtTranslator_.load(
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
QString::fromUtf8("qtbase_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath)) ||
qtTranslator_.load(
#endif
QString::fromUtf8("qt_") + locale, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
qDebug("Qt %s locale recognized, using translation.", qPrintable(locale));
}
else {
qDebug("Qt %s locale unrecognized, using default (en).", qPrintable(locale));
}
installTranslator(&qtTranslator_);
if (translator_.load(QString::fromUtf8(":/lang/qbittorrent_") + locale)) {
qDebug("%s locale recognized, using translation.", qPrintable(locale));
}
else {
qDebug("%s locale unrecognized, using default (en).", qPrintable(locale));
}
installTranslator(&translator_);
#ifndef DISABLE_GUI
if (locale.startsWith("ar") || locale.startsWith("he")) {
qDebug("Right to Left mode");
setLayoutDirection(Qt::RightToLeft);
}
else {
setLayoutDirection(Qt::LeftToRight);
}
#endif
}

View file

@ -1,59 +1,59 @@
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#ifndef APPLICATION_H
#define APPLICATION_H
#include <QStringList>
#include <QTranslator>
#ifndef DISABLE_GUI
#include "sessionapplication.h"
#else
#include "qtsinglecoreapplication.h"
#endif
class Application
#ifndef DISABLE_GUI
: public SessionApplication
#else
: public QtSingleCoreApplication
#endif
{
public:
Application(const QString &id, int &argc, char **argv);
private:
QTranslator qtTranslator_;
QTranslator translator_;
void initializeTranslation();
};
#endif // APPLICATION_H
/*
* Bittorrent Client using Qt and libtorrent.
* Copyright (C) 2014 Vladimir Golovnev <glassez@yandex.ru>
* Copyright (C) 2006 Christophe Dumez
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#ifndef APPLICATION_H
#define APPLICATION_H
#include <QStringList>
#include <QTranslator>
#ifndef DISABLE_GUI
#include "sessionapplication.h"
#else
#include "qtsinglecoreapplication.h"
#endif
class Application
#ifndef DISABLE_GUI
: public SessionApplication
#else
: public QtSingleCoreApplication
#endif
{
public:
Application(const QString &id, int &argc, char **argv);
private:
QTranslator qtTranslator_;
QTranslator translator_;
void initializeTranslation();
};
#endif // APPLICATION_H

View file

@ -1,121 +1,121 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2013 Nick Tiskov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : daymansmail@gmail.com
*/
#include <QDesktopWidget>
#include "mainwindow.h"
#include "autoexpandabledialog.h"
#include "ui_autoexpandabledialog.h"
AutoExpandableDialog::AutoExpandableDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AutoExpandableDialog) {
ui->setupUi(this);
}
AutoExpandableDialog::~AutoExpandableDialog() {
delete ui;
}
QString AutoExpandableDialog::getText(QWidget *parent, const QString &title, const QString &label,
QLineEdit::EchoMode mode, const QString &text, bool *ok,
Qt::InputMethodHints inputMethodHints) {
AutoExpandableDialog d(parent);
d.setWindowTitle(title);
d.ui->textLabel->setText(label);
d.ui->textEdit->setText(text);
d.ui->textEdit->setEchoMode(mode);
d.ui->textEdit->setInputMethodHints(inputMethodHints);
bool res = d.exec();
if (ok)
*ok = res;
if (!res)
return QString();
return d.ui->textEdit->text();
}
void AutoExpandableDialog::showEvent(QShowEvent *e) {
// Overriding showEvent is required for consistent UI with fixed size under custom DPI
// Show dialog
QDialog::showEvent(e);
// and resize textbox to fit the text
// NOTE: For some strange reason QFontMetrics gets more accurate
// when called from showEvent. Only 6 symbols off instead of 11 symbols off.
int textW = ui->textEdit->fontMetrics().width(ui->textEdit->text()) + 4;
int screenW = QApplication::desktop()->width() / 4;
int wd = textW;
if (!windowTitle().isEmpty()) {
int _w = fontMetrics().width(windowTitle());
if (_w > wd)
wd = _w;
}
if (!ui->textLabel->text().isEmpty()) {
int _w = ui->textLabel->fontMetrics().width(ui->textLabel->text());
if (_w > wd)
wd = _w;
}
// Now resize the dialog to fit the contents
// Maximum value is whichever is smaller:
// 1. screen width / 4
// 2. max width of text from either of: label, title, textedit
// If the value is less than dialog default size default size is used
wd = textW < screenW ? textW : screenW;
if (wd > width())
resize(width() - ui->horizontalLayout->sizeHint().width() + wd, height());
// Use old dialog behavior: prohibit resizing the dialog
setFixedHeight(height());
// Update geometry: center on screen
QDesktopWidget *desk = QApplication::desktop();
MainWindow *wnd = qobject_cast<MainWindow*>(QApplication::activeWindow());
QPoint p = QCursor::pos();
int screenNum = 0;
if (wnd == 0)
screenNum = desk->screenNumber(p);
else if (!wnd->isHidden())
screenNum = desk->screenNumber(wnd);
else
screenNum = desk->screenNumber(p);
QRect screenRes = desk->screenGeometry(screenNum);
QRect geom = geometry();
geom.moveCenter(QPoint(screenRes.width() / 2, screenRes.height() / 2));
setGeometry(geom);
}
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2013 Nick Tiskov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : daymansmail@gmail.com
*/
#include <QDesktopWidget>
#include "mainwindow.h"
#include "autoexpandabledialog.h"
#include "ui_autoexpandabledialog.h"
AutoExpandableDialog::AutoExpandableDialog(QWidget *parent) : QDialog(parent), ui(new Ui::AutoExpandableDialog) {
ui->setupUi(this);
}
AutoExpandableDialog::~AutoExpandableDialog() {
delete ui;
}
QString AutoExpandableDialog::getText(QWidget *parent, const QString &title, const QString &label,
QLineEdit::EchoMode mode, const QString &text, bool *ok,
Qt::InputMethodHints inputMethodHints) {
AutoExpandableDialog d(parent);
d.setWindowTitle(title);
d.ui->textLabel->setText(label);
d.ui->textEdit->setText(text);
d.ui->textEdit->setEchoMode(mode);
d.ui->textEdit->setInputMethodHints(inputMethodHints);
bool res = d.exec();
if (ok)
*ok = res;
if (!res)
return QString();
return d.ui->textEdit->text();
}
void AutoExpandableDialog::showEvent(QShowEvent *e) {
// Overriding showEvent is required for consistent UI with fixed size under custom DPI
// Show dialog
QDialog::showEvent(e);
// and resize textbox to fit the text
// NOTE: For some strange reason QFontMetrics gets more accurate
// when called from showEvent. Only 6 symbols off instead of 11 symbols off.
int textW = ui->textEdit->fontMetrics().width(ui->textEdit->text()) + 4;
int screenW = QApplication::desktop()->width() / 4;
int wd = textW;
if (!windowTitle().isEmpty()) {
int _w = fontMetrics().width(windowTitle());
if (_w > wd)
wd = _w;
}
if (!ui->textLabel->text().isEmpty()) {
int _w = ui->textLabel->fontMetrics().width(ui->textLabel->text());
if (_w > wd)
wd = _w;
}
// Now resize the dialog to fit the contents
// Maximum value is whichever is smaller:
// 1. screen width / 4
// 2. max width of text from either of: label, title, textedit
// If the value is less than dialog default size default size is used
wd = textW < screenW ? textW : screenW;
if (wd > width())
resize(width() - ui->horizontalLayout->sizeHint().width() + wd, height());
// Use old dialog behavior: prohibit resizing the dialog
setFixedHeight(height());
// Update geometry: center on screen
QDesktopWidget *desk = QApplication::desktop();
MainWindow *wnd = qobject_cast<MainWindow*>(QApplication::activeWindow());
QPoint p = QCursor::pos();
int screenNum = 0;
if (wnd == 0)
screenNum = desk->screenNumber(p);
else if (!wnd->isHidden())
screenNum = desk->screenNumber(wnd);
else
screenNum = desk->screenNumber(p);
QRect screenRes = desk->screenGeometry(screenNum);
QRect geom = geometry();
geom.moveCenter(QPoint(screenRes.width() / 2, screenRes.height() / 2));
setGeometry(geom);
}

View file

@ -1,60 +1,60 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2013 Nick Tiskov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : daymansmail@gmail.com
*/
#ifndef AUTOEXPANDABLEDIALOG_H
#define AUTOEXPANDABLEDIALOG_H
#include <QDialog>
#include <QString>
#include <QLineEdit>
namespace Ui {
class AutoExpandableDialog;
}
class AutoExpandableDialog : public QDialog {
Q_OBJECT
public:
explicit AutoExpandableDialog(QWidget *parent = 0);
~AutoExpandableDialog();
static QString getText(QWidget *parent, const QString& title, const QString& label,
QLineEdit::EchoMode mode = QLineEdit::Normal, const QString & text = QString(),
bool * ok = 0, Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
protected:
void showEvent(QShowEvent *e);
private:
Ui::AutoExpandableDialog *ui;
};
#endif // AUTOEXPANDABLEDIALOG_H
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2013 Nick Tiskov
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : daymansmail@gmail.com
*/
#ifndef AUTOEXPANDABLEDIALOG_H
#define AUTOEXPANDABLEDIALOG_H
#include <QDialog>
#include <QString>
#include <QLineEdit>
namespace Ui {
class AutoExpandableDialog;
}
class AutoExpandableDialog : public QDialog {
Q_OBJECT
public:
explicit AutoExpandableDialog(QWidget *parent = 0);
~AutoExpandableDialog();
static QString getText(QWidget *parent, const QString& title, const QString& label,
QLineEdit::EchoMode mode = QLineEdit::Normal, const QString & text = QString(),
bool * ok = 0, Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
protected:
void showEvent(QShowEvent *e);
private:
Ui::AutoExpandableDialog *ui;
};
#endif // AUTOEXPANDABLEDIALOG_H

View file

@ -1,120 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoExpandableDialog</class>
<widget class="QDialog" name="AutoExpandableDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>222</width>
<height>94</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="textLabel">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="textEdit">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AutoExpandableDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AutoExpandableDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AutoExpandableDialog</class>
<widget class="QDialog" name="AutoExpandableDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>222</width>
<height>94</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string notr="true">Dialog</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="textLabel">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="textEdit">
<property name="toolTip">
<string notr="true"/>
</property>
<property name="text">
<string notr="true"/>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>AutoExpandableDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>AutoExpandableDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View file

@ -1,5 +1,5 @@
<RCC>
<qresource prefix="/geoip">
<file>GeoIP.dat</file>
</qresource>
</RCC>
<RCC>
<qresource prefix="/geoip">
<file>GeoIP.dat</file>
</qresource>
</RCC>

View file

@ -1,4 +1,4 @@
INCLUDEPATH += $$PWD/src
HEADERS += $$PWD/src/lineedit.h
SOURCES += $$PWD/src/lineedit.cpp
RESOURCES += $$PWD/resources/lineeditimages.qrc
INCLUDEPATH += $$PWD/src
HEADERS += $$PWD/src/lineedit.h
SOURCES += $$PWD/src/lineedit.cpp
RESOURCES += $$PWD/resources/lineeditimages.qrc

View file

@ -1,55 +1,55 @@
/****************************************************************************
**
** Copyright (c) 2007 Trolltech ASA <info@trolltech.com>
**
** Use, modification and distribution is allowed without limitation,
** warranty, liability or support of any kind.
**
****************************************************************************/
#include "lineedit.h"
#include <QToolButton>
#include <QStyle>
#include <QtDebug>
LineEdit::LineEdit(QWidget *parent)
: QLineEdit(parent)
{
searchButton = new QToolButton(this);
QPixmap pixmap1(":/lineeditimages/search.png");
searchButton->setIcon(QIcon(pixmap1));
searchButton->setIconSize(pixmap1.size());
searchButton->setCursor(Qt::ArrowCursor);
searchButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
clearButton = new QToolButton(this);
QPixmap pixmap2(":/lineeditimages/clear_left.png");
clearButton->setIcon(QIcon(pixmap2));
clearButton->setIconSize(pixmap2.size());
clearButton->setCursor(Qt::ArrowCursor);
clearButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
clearButton->setToolTip(tr("Clear the text"));
clearButton->hide();
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
setStyleSheet(QString("QLineEdit { padding-right: %1px; padding-left: %2px; }").arg(clearButton->sizeHint().width() + frameWidth + 1).arg(clearButton->sizeHint().width() + frameWidth + 1));
QSize msz = minimumSizeHint();
setMinimumSize(qMax(msz.width(), clearButton->sizeHint().width() + searchButton->sizeHint().width() + frameWidth * 2 + 2),
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
}
void LineEdit::resizeEvent(QResizeEvent *)
{
QSize sz = searchButton->sizeHint();
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
searchButton->move(rect().left() + frameWidth, (rect().bottom() + 2 - sz.height())/2);
sz = clearButton->sizeHint();
clearButton->move(rect().right() - frameWidth - sz.width(),
(rect().bottom() + 2 - sz.height())/2);
}
void LineEdit::updateCloseButton(const QString& text)
{
clearButton->setVisible(!text.isEmpty());
}
/****************************************************************************
**
** Copyright (c) 2007 Trolltech ASA <info@trolltech.com>
**
** Use, modification and distribution is allowed without limitation,
** warranty, liability or support of any kind.
**
****************************************************************************/
#include "lineedit.h"
#include <QToolButton>
#include <QStyle>
#include <QtDebug>
LineEdit::LineEdit(QWidget *parent)
: QLineEdit(parent)
{
searchButton = new QToolButton(this);
QPixmap pixmap1(":/lineeditimages/search.png");
searchButton->setIcon(QIcon(pixmap1));
searchButton->setIconSize(pixmap1.size());
searchButton->setCursor(Qt::ArrowCursor);
searchButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
clearButton = new QToolButton(this);
QPixmap pixmap2(":/lineeditimages/clear_left.png");
clearButton->setIcon(QIcon(pixmap2));
clearButton->setIconSize(pixmap2.size());
clearButton->setCursor(Qt::ArrowCursor);
clearButton->setStyleSheet("QToolButton { border: none; padding: 2px; }");
clearButton->setToolTip(tr("Clear the text"));
clearButton->hide();
connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
connect(this, SIGNAL(textChanged(const QString&)), this, SLOT(updateCloseButton(const QString&)));
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
setStyleSheet(QString("QLineEdit { padding-right: %1px; padding-left: %2px; }").arg(clearButton->sizeHint().width() + frameWidth + 1).arg(clearButton->sizeHint().width() + frameWidth + 1));
QSize msz = minimumSizeHint();
setMinimumSize(qMax(msz.width(), clearButton->sizeHint().width() + searchButton->sizeHint().width() + frameWidth * 2 + 2),
qMax(msz.height(), clearButton->sizeHint().height() + frameWidth * 2 + 2));
}
void LineEdit::resizeEvent(QResizeEvent *)
{
QSize sz = searchButton->sizeHint();
int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
searchButton->move(rect().left() + frameWidth, (rect().bottom() + 2 - sz.height())/2);
sz = clearButton->sizeHint();
clearButton->move(rect().right() - frameWidth - sz.width(),
(rect().bottom() + 2 - sz.height())/2);
}
void LineEdit::updateCloseButton(const QString& text)
{
clearButton->setVisible(!text.isEmpty());
}

View file

@ -1,37 +1,37 @@
/****************************************************************************
**
** Copyright (c) 2007 Trolltech ASA <info@trolltech.com>
**
** Use, modification and distribution is allowed without limitation,
** warranty, liability or support of any kind.
**
****************************************************************************/
#ifndef LINEEDIT_H
#define LINEEDIT_H
#include <QLineEdit>
QT_BEGIN_NAMESPACE
class QToolButton;
QT_END_NAMESPACE
class LineEdit : public QLineEdit
{
Q_OBJECT
public:
LineEdit(QWidget *parent = 0);
protected:
void resizeEvent(QResizeEvent *);
private slots:
void updateCloseButton(const QString &text);
private:
QToolButton *clearButton;
QToolButton *searchButton;
};
#endif // LIENEDIT_H
/****************************************************************************
**
** Copyright (c) 2007 Trolltech ASA <info@trolltech.com>
**
** Use, modification and distribution is allowed without limitation,
** warranty, liability or support of any kind.
**
****************************************************************************/
#ifndef LINEEDIT_H
#define LINEEDIT_H
#include <QLineEdit>
QT_BEGIN_NAMESPACE
class QToolButton;
QT_END_NAMESPACE
class LineEdit : public QLineEdit
{
Q_OBJECT
public:
LineEdit(QWidget *parent = 0);
protected:
void resizeEvent(QResizeEvent *);
private slots:
void updateCloseButton(const QString &text);
private:
QToolButton *clearButton;
QToolButton *searchButton;
};
#endif // LIENEDIT_H

View file

@ -1,487 +1,487 @@
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Copyright (C) 2014 sledgehammer999
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
* Contact : hammered999@gmail.com
*/
#ifndef PREFERENCES_H
#define PREFERENCES_H
#include <QTime>
#include <QDateTime>
#include <QList>
#include <QTimer>
#include <QReadWriteLock>
#include <QNetworkCookie>
#include <QVariant>
#include <libtorrent/version.hpp>
enum scheduler_days { EVERY_DAY, WEEK_DAYS, WEEK_ENDS, MON, TUE, WED, THU, FRI, SAT, SUN };
enum maxRatioAction {PAUSE_ACTION, REMOVE_ACTION};
namespace Proxy {
enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4, SOCKS4=5};
}
namespace TrayIcon {
enum Style { NORMAL = 0, MONO_DARK, MONO_LIGHT };
}
namespace DNS {
enum Service { DYNDNS, NOIP, NONE = -1 };
}
class Preferences : public QObject {
Q_OBJECT
Q_DISABLE_COPY(Preferences)
private:
explicit Preferences();
static Preferences* m_instance;
QHash<QString, QVariant> m_data;
bool dirty;
QTimer timer;
mutable QReadWriteLock lock;
const QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
void setValue(const QString &key, const QVariant &value);
public slots:
void save();
public:
static Preferences* instance();
static void drop();
~Preferences();
// General options
QString getLocale() const;
void setLocale(const QString &locale);
bool useProgramNotification() const;
void useProgramNotification(bool use);
bool deleteTorrentFilesAsDefault() const;
void setDeleteTorrentFilesAsDefault(bool del);
bool confirmOnExit() const;
void setConfirmOnExit(bool confirm);
bool speedInTitleBar() const;
void showSpeedInTitleBar(bool show);
bool useAlternatingRowColors() const;
void setAlternatingRowColors(bool b);
bool useRandomPort() const;
void setRandomPort(bool b);
bool systrayIntegration() const;
void setSystrayIntegration(bool enabled);
bool isToolbarDisplayed() const;
void setToolbarDisplayed(bool displayed);
bool minimizeToTray() const;
void setMinimizeToTray(bool b);
bool closeToTray() const;
void setCloseToTray(bool b);
bool startMinimized() const;
void setStartMinimized(bool b);
bool isSlashScreenDisabled() const;
void setSplashScreenDisabled(bool b);
bool preventFromSuspend() const;
void setPreventFromSuspend(bool b);
#ifdef Q_OS_WIN
bool WinStartup() const;
void setWinStartup(bool b);
#endif
// Downloads
QString getSavePath() const;
void setSavePath(const QString &save_path);
bool isTempPathEnabled() const;
void setTempPathEnabled(bool enabled);
QString getTempPath() const;
void setTempPath(const QString &path);
bool useIncompleteFilesExtension() const;
void useIncompleteFilesExtension(bool enabled);
bool appendTorrentLabel() const;
void setAppendTorrentLabel(bool b);
QString lastLocationPath() const;
void setLastLocationPath(const QString &path);
bool preAllocateAllFiles() const;
void preAllocateAllFiles(bool enabled);
bool useAdditionDialog() const;
void useAdditionDialog(bool b);
bool additionDialogFront() const;
void additionDialogFront(bool b);
bool addTorrentsInPause() const;
void addTorrentsInPause(bool b);
QStringList getScanDirs() const;
void setScanDirs(const QStringList &dirs);
QList<bool> getDownloadInScanDirs() const;
void setDownloadInScanDirs(const QList<bool> &list);
QString getScanDirsLastPath() const;
void setScanDirsLastPath(const QString &path);
bool isTorrentExportEnabled() const;
QString getTorrentExportDir() const;
void setTorrentExportDir(QString path);
bool isFinishedTorrentExportEnabled() const;
QString getFinishedTorrentExportDir() const;
void setFinishedTorrentExportDir(QString path);
bool isMailNotificationEnabled() const;
void setMailNotificationEnabled(bool enabled);
QString getMailNotificationEmail() const;
void setMailNotificationEmail(const QString &mail);
QString getMailNotificationSMTP() const;
void setMailNotificationSMTP(const QString &smtp_server);
bool getMailNotificationSMTPSSL() const;
void setMailNotificationSMTPSSL(bool use);
bool getMailNotificationSMTPAuth() const;
void setMailNotificationSMTPAuth(bool use);
QString getMailNotificationSMTPUsername() const;
void setMailNotificationSMTPUsername(const QString &username);
QString getMailNotificationSMTPPassword() const;
void setMailNotificationSMTPPassword(const QString &password);
int getActionOnDblClOnTorrentDl() const;
void setActionOnDblClOnTorrentDl(int act);
int getActionOnDblClOnTorrentFn() const;
void setActionOnDblClOnTorrentFn(int act);
// Connection options
int getSessionPort() const;
void setSessionPort(int port);
bool isUPnPEnabled() const;
void setUPnPEnabled(bool enabled);
int getGlobalDownloadLimit() const;
void setGlobalDownloadLimit(int limit);
int getGlobalUploadLimit() const;
void setGlobalUploadLimit(int limit);
int getAltGlobalDownloadLimit() const;
void setAltGlobalDownloadLimit(int limit);
int getAltGlobalUploadLimit() const;
void setAltGlobalUploadLimit(int limit);
bool isAltBandwidthEnabled() const;
void setAltBandwidthEnabled(bool enabled);
bool isSchedulerEnabled() const;
void setSchedulerEnabled(bool enabled);
QTime getSchedulerStartTime() const;
void setSchedulerStartTime(const QTime &time);
QTime getSchedulerEndTime() const;
void setSchedulerEndTime(const QTime &time);
scheduler_days getSchedulerDays() const;
void setSchedulerDays(scheduler_days days);
// Proxy options
bool isProxyEnabled() const;
bool isProxyAuthEnabled() const;
void setProxyAuthEnabled(bool enabled);
QString getProxyIp() const;
void setProxyIp(const QString &ip);
unsigned short getProxyPort() const;
void setProxyPort(unsigned short port);
QString getProxyUsername() const;
void setProxyUsername(const QString &username);
QString getProxyPassword() const;
void setProxyPassword(const QString &password);
int getProxyType() const;
void setProxyType(int type);
bool proxyPeerConnections() const;
void setProxyPeerConnections(bool enabled);
#if LIBTORRENT_VERSION_NUM >= 10000
bool getForceProxy() const;
void setForceProxy(bool enabled);
#endif
// Bittorrent options
int getMaxConnecs() const;
void setMaxConnecs(int val);
int getMaxConnecsPerTorrent() const;
void setMaxConnecsPerTorrent(int val);
int getMaxUploads() const;
void setMaxUploads(int val);
int getMaxUploadsPerTorrent() const;
void setMaxUploadsPerTorrent(int val);
bool isuTPEnabled() const;
void setuTPEnabled(bool enabled);
bool isuTPRateLimited() const;
void setuTPRateLimited(bool enabled);
bool isDHTEnabled() const;
void setDHTEnabled(bool enabled);
bool isPeXEnabled() const;
void setPeXEnabled(bool enabled);
bool isLSDEnabled() const;
void setLSDEnabled(bool enabled);
int getEncryptionSetting() const;
void setEncryptionSetting(int val);
qreal getGlobalMaxRatio() const;
void setGlobalMaxRatio(qreal ratio);
int getMaxRatioAction() const;
void setMaxRatioAction(int act);
// IP Filter
bool isFilteringEnabled() const;
void setFilteringEnabled(bool enabled);
QString getFilter() const;
void setFilter(const QString &path);
QStringList bannedIPs() const;
void banIP(const QString &ip);
// Search
bool isSearchEnabled() const;
void setSearchEnabled(bool enabled);
// Execution Log
bool isExecutionLogEnabled() const;
void setExecutionLogEnabled(bool b);
// Queueing system
bool isQueueingSystemEnabled() const;
void setQueueingSystemEnabled(bool enabled);
int getMaxActiveDownloads() const;
void setMaxActiveDownloads(int val);
int getMaxActiveUploads() const;
void setMaxActiveUploads(int val);
int getMaxActiveTorrents() const;
void setMaxActiveTorrents(int val);
bool ignoreSlowTorrentsForQueueing() const;
void setIgnoreSlowTorrentsForQueueing(bool ignore);
bool isWebUiEnabled() const;
void setWebUiEnabled(bool enabled);
bool isWebUiLocalAuthEnabled() const;
void setWebUiLocalAuthEnabled(bool enabled);
quint16 getWebUiPort() const;
void setWebUiPort(quint16 port);
bool useUPnPForWebUIPort() const;
void setUPnPForWebUIPort(bool enabled);
QString getWebUiUsername() const;
void setWebUiUsername(const QString &username);
QString getWebUiPassword() const;
void setWebUiPassword(const QString &new_password);
bool isWebUiHttpsEnabled() const;
void setWebUiHttpsEnabled(bool enabled);
QByteArray getWebUiHttpsCertificate() const;
void setWebUiHttpsCertificate(const QByteArray &data);
QByteArray getWebUiHttpsKey() const;
void setWebUiHttpsKey(const QByteArray &data);
bool isDynDNSEnabled() const;
void setDynDNSEnabled(bool enabled);
DNS::Service getDynDNSService() const;
void setDynDNSService(int service);
QString getDynDomainName() const;
void setDynDomainName(const QString &name);
QString getDynDNSUsername() const;
void setDynDNSUsername(const QString &username);
QString getDynDNSPassword() const;
void setDynDNSPassword(const QString &password);
// Advanced settings
void setUILockPassword(const QString &clear_password);
void clearUILockPassword();
QString getUILockPasswordMD5() const;
bool isUILocked() const;
void setUILocked(bool locked);
bool isAutoRunEnabled() const;
void setAutoRunEnabled(bool enabled);
QString getAutoRunProgram() const;
void setAutoRunProgram(const QString &program);
bool shutdownWhenDownloadsComplete() const;
void setShutdownWhenDownloadsComplete(bool shutdown);
bool suspendWhenDownloadsComplete() const;
void setSuspendWhenDownloadsComplete(bool suspend);
bool hibernateWhenDownloadsComplete() const;
void setHibernateWhenDownloadsComplete(bool hibernate);
bool shutdownqBTWhenDownloadsComplete() const;
void setShutdownqBTWhenDownloadsComplete(bool shutdown);
uint diskCacheSize() const;
void setDiskCacheSize(uint size);
uint diskCacheTTL() const;
void setDiskCacheTTL(uint ttl);
bool osCache() const;
void setOsCache(bool enable);
uint saveResumeDataInterval() const;
void setSaveResumeDataInterval(uint m);
uint outgoingPortsMin() const;
void setOutgoingPortsMin(uint val);
uint outgoingPortsMax() const;
void setOutgoingPortsMax(uint val);
bool ignoreLimitsOnLAN() const;
void ignoreLimitsOnLAN(bool ignore);
bool includeOverheadInLimits() const;
void includeOverheadInLimits(bool include);
bool trackerExchangeEnabled() const;
void setTrackerExchangeEnabled(bool enable);
bool recheckTorrentsOnCompletion() const;
void recheckTorrentsOnCompletion(bool recheck);
unsigned int getRefreshInterval() const;
void setRefreshInterval(uint interval);
bool resolvePeerCountries() const;
void resolvePeerCountries(bool resolve);
bool resolvePeerHostNames() const;
void resolvePeerHostNames(bool resolve);
int getMaxHalfOpenConnections() const;
void setMaxHalfOpenConnections(int value);
QString getNetworkInterface() const;
void setNetworkInterface(const QString& iface);
QString getNetworkInterfaceName() const;
void setNetworkInterfaceName(const QString& iface);
bool getListenIPv6() const;
void setListenIPv6(bool enable);
QString getNetworkAddress() const;
void setNetworkAddress(const QString& addr);
bool isAnonymousModeEnabled() const;
void enableAnonymousMode(bool enabled);
bool isSuperSeedingEnabled() const;
void enableSuperSeeding(bool enabled);
bool announceToAllTrackers() const;
void setAnnounceToAllTrackers(bool enabled);
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
bool useSystemIconTheme() const;
void useSystemIconTheme(bool enabled);
#endif
QStringList getTorrentLabels() const;
void setTorrentLabels(const QStringList& labels);
void addTorrentLabel(const QString& label);
void removeTorrentLabel(const QString& label);
bool recursiveDownloadDisabled() const;
void disableRecursiveDownload(bool disable=true);
#ifdef Q_OS_WIN
static QString getPythonPath();
bool neverCheckFileAssoc() const;
void setNeverCheckFileAssoc(bool check = true);
static bool isTorrentFileAssocSet();
static bool isMagnetLinkAssocSet();
static void setTorrentFileAssoc(bool set);
static void setMagnetLinkAssoc(bool set);
#endif
bool isTrackerEnabled() const;
void setTrackerEnabled(bool enabled);
int getTrackerPort() const;
void setTrackerPort(int port);
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
bool isUpdateCheckEnabled() const;
void setUpdateCheckEnabled(bool enabled);
#endif
bool confirmTorrentDeletion() const;
void setConfirmTorrentDeletion(bool enabled);
TrayIcon::Style trayIconStyle() const;
void setTrayIconStyle(TrayIcon::Style style);
// Stuff that don't appear in the Options GUI but are saved
// in the same file.
QByteArray getAddNewTorrentDialogState() const;
void setAddNewTorrentDialogState(const QByteArray &state);
int getAddNewTorrentDialogPos() const;
void setAddNewTorrentDialogPos(const int &pos);
int getAddNewTorrentDialogWidth() const;
void setAddNewTorrentDialogWidth(const int &width);
bool getAddNewTorrentDialogExpanded() const;
void setAddNewTorrentDialogExpanded(const bool expanded);
QStringList getAddNewTorrentDialogPathHistory() const;
void setAddNewTorrentDialogPathHistory(const QStringList &history);
QDateTime getDNSLastUpd() const;
void setDNSLastUpd(const QDateTime &date);
QString getDNSLastIP() const;
void setDNSLastIP(const QString &ip);
bool getAcceptedLegal() const;
void setAcceptedLegal(const bool accepted);
QByteArray getMainGeometry() const;
void setMainGeometry(const QByteArray &geometry);
QByteArray getMainVSplitterState() const;
void setMainVSplitterState(const QByteArray &state);
QString getMainLastDir() const;
void setMainLastDir(const QString &path);
#ifndef DISABLE_GUI
QSize getPrefSize(const QSize &defaultSize) const;
void setPrefSize(const QSize &size);
#endif
QPoint getPrefPos() const;
void setPrefPos(const QPoint &pos);
QStringList getPrefHSplitterSizes() const;
void setPrefHSplitterSizes(const QStringList &sizes);
QByteArray getPeerListState() const;
void setPeerListState(const QByteArray &state);
QString getPropSplitterSizes() const;
void setPropSplitterSizes(const QString &sizes);
QByteArray getPropFileListState() const;
void setPropFileListState(const QByteArray &state);
int getPropCurTab() const;
void setPropCurTab(const int &tab);
bool getPropVisible() const;
void setPropVisible(const bool visible);
QByteArray getPropTrackerListState() const;
void setPropTrackerListState(const QByteArray &state);
QByteArray getRssGeometry() const;
void setRssGeometry(const QByteArray &geometry);
QByteArray getRssHSplitterSizes() const;
void setRssHSplitterSizes(const QByteArray &sizes);
QStringList getRssOpenFolders() const;
void setRssOpenFolders(const QStringList &folders);
QByteArray getRssHSplitterState() const;
void setRssHSplitterState(const QByteArray &state);
QByteArray getRssVSplitterState() const;
void setRssVSplitterState(const QByteArray &state);
QString getSearchColsWidth() const;
void setSearchColsWidth(const QString &width);
QStringList getSearchEngDisabled() const;
void setSearchEngDisabled(const QStringList &engines);
QString getCreateTorLastAddPath() const;
void setCreateTorLastAddPath(const QString &path);
QString getCreateTorLastSavePath() const;
void setCreateTorLastSavePath(const QString &path);
QString getCreateTorTrackers() const;
void setCreateTorTrackers(const QString &path);
QByteArray getCreateTorGeometry() const;
void setCreateTorGeometry(const QByteArray &geometry);
bool getCreateTorIgnoreRatio() const;
void setCreateTorIgnoreRatio(const bool ignore);
QString getTorImportLastContentDir() const;
void setTorImportLastContentDir(const QString &path);
QByteArray getTorImportGeometry() const;
void setTorImportGeometry(const QByteArray &geometry);
int getTransSelFilter() const;
void setTransSelFilter(const int &index);
QByteArray getTransHeaderState() const;
void setTransHeaderState(const QByteArray &state);
// Temp code.
// See TorrentStatistics::loadStats() for details.
QVariantHash getStats() const;
void removeStats();
//From old RssSettings class
bool isRSSEnabled() const;
void setRSSEnabled(const bool enabled);
uint getRSSRefreshInterval() const;
void setRSSRefreshInterval(const uint &interval);
int getRSSMaxArticlesPerFeed() const;
void setRSSMaxArticlesPerFeed(const int &nb);
bool isRssDownloadingEnabled() const;
void setRssDownloadingEnabled(const bool b);
QStringList getRssFeedsUrls() const;
void setRssFeedsUrls(const QStringList &rssFeeds);
QStringList getRssFeedsAliases() const;
void setRssFeedsAliases(const QStringList &rssAliases);
QList<QByteArray> getHostNameCookies(const QString &host_name) const;
QList<QNetworkCookie> getHostNameQNetworkCookies(const QString& host_name) const;
void setHostNameCookies(const QString &host_name, const QList<QByteArray> &cookies);
};
#endif // PREFERENCES_H
/*
* Bittorrent Client using Qt4 and libtorrent.
* Copyright (C) 2006 Christophe Dumez
* Copyright (C) 2014 sledgehammer999
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* In addition, as a special exception, the copyright holders give permission to
* link this program with the OpenSSL project's "OpenSSL" library (or with
* modified versions of it that use the same license as the "OpenSSL" library),
* and distribute the linked executables. You must obey the GNU General Public
* License in all respects for all of the code used other than "OpenSSL". If you
* modify file(s), you may extend this exception to your version of the file(s),
* but you are not obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*
* Contact : chris@qbittorrent.org
* Contact : hammered999@gmail.com
*/
#ifndef PREFERENCES_H
#define PREFERENCES_H
#include <QTime>
#include <QDateTime>
#include <QList>
#include <QTimer>
#include <QReadWriteLock>
#include <QNetworkCookie>
#include <QVariant>
#include <libtorrent/version.hpp>
enum scheduler_days { EVERY_DAY, WEEK_DAYS, WEEK_ENDS, MON, TUE, WED, THU, FRI, SAT, SUN };
enum maxRatioAction {PAUSE_ACTION, REMOVE_ACTION};
namespace Proxy {
enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4, SOCKS4=5};
}
namespace TrayIcon {
enum Style { NORMAL = 0, MONO_DARK, MONO_LIGHT };
}
namespace DNS {
enum Service { DYNDNS, NOIP, NONE = -1 };
}
class Preferences : public QObject {
Q_OBJECT
Q_DISABLE_COPY(Preferences)
private:
explicit Preferences();
static Preferences* m_instance;
QHash<QString, QVariant> m_data;
bool dirty;
QTimer timer;
mutable QReadWriteLock lock;
const QVariant value(const QString &key, const QVariant &defaultValue = QVariant()) const;
void setValue(const QString &key, const QVariant &value);
public slots:
void save();
public:
static Preferences* instance();
static void drop();
~Preferences();
// General options
QString getLocale() const;
void setLocale(const QString &locale);
bool useProgramNotification() const;
void useProgramNotification(bool use);
bool deleteTorrentFilesAsDefault() const;
void setDeleteTorrentFilesAsDefault(bool del);
bool confirmOnExit() const;
void setConfirmOnExit(bool confirm);
bool speedInTitleBar() const;
void showSpeedInTitleBar(bool show);
bool useAlternatingRowColors() const;
void setAlternatingRowColors(bool b);
bool useRandomPort() const;
void setRandomPort(bool b);
bool systrayIntegration() const;
void setSystrayIntegration(bool enabled);
bool isToolbarDisplayed() const;
void setToolbarDisplayed(bool displayed);
bool minimizeToTray() const;
void setMinimizeToTray(bool b);
bool closeToTray() const;
void setCloseToTray(bool b);
bool startMinimized() const;
void setStartMinimized(bool b);
bool isSlashScreenDisabled() const;
void setSplashScreenDisabled(bool b);
bool preventFromSuspend() const;
void setPreventFromSuspend(bool b);
#ifdef Q_OS_WIN
bool WinStartup() const;
void setWinStartup(bool b);
#endif
// Downloads
QString getSavePath() const;
void setSavePath(const QString &save_path);
bool isTempPathEnabled() const;
void setTempPathEnabled(bool enabled);
QString getTempPath() const;
void setTempPath(const QString &path);
bool useIncompleteFilesExtension() const;
void useIncompleteFilesExtension(bool enabled);
bool appendTorrentLabel() const;
void setAppendTorrentLabel(bool b);
QString lastLocationPath() const;
void setLastLocationPath(const QString &path);
bool preAllocateAllFiles() const;
void preAllocateAllFiles(bool enabled);
bool useAdditionDialog() const;
void useAdditionDialog(bool b);
bool additionDialogFront() const;
void additionDialogFront(bool b);
bool addTorrentsInPause() const;
void addTorrentsInPause(bool b);
QStringList getScanDirs() const;
void setScanDirs(const QStringList &dirs);
QList<bool> getDownloadInScanDirs() const;
void setDownloadInScanDirs(const QList<bool> &list);
QString getScanDirsLastPath() const;
void setScanDirsLastPath(const QString &path);
bool isTorrentExportEnabled() const;
QString getTorrentExportDir() const;
void setTorrentExportDir(QString path);
bool isFinishedTorrentExportEnabled() const;
QString getFinishedTorrentExportDir() const;
void setFinishedTorrentExportDir(QString path);
bool isMailNotificationEnabled() const;
void setMailNotificationEnabled(bool enabled);
QString getMailNotificationEmail() const;
void setMailNotificationEmail(const QString &mail);
QString getMailNotificationSMTP() const;
void setMailNotificationSMTP(const QString &smtp_server);
bool getMailNotificationSMTPSSL() const;
void setMailNotificationSMTPSSL(bool use);
bool getMailNotificationSMTPAuth() const;
void setMailNotificationSMTPAuth(bool use);
QString getMailNotificationSMTPUsername() const;
void setMailNotificationSMTPUsername(const QString &username);
QString getMailNotificationSMTPPassword() const;
void setMailNotificationSMTPPassword(const QString &password);
int getActionOnDblClOnTorrentDl() const;
void setActionOnDblClOnTorrentDl(int act);
int getActionOnDblClOnTorrentFn() const;
void setActionOnDblClOnTorrentFn(int act);
// Connection options
int getSessionPort() const;
void setSessionPort(int port);
bool isUPnPEnabled() const;
void setUPnPEnabled(bool enabled);
int getGlobalDownloadLimit() const;
void setGlobalDownloadLimit(int limit);
int getGlobalUploadLimit() const;
void setGlobalUploadLimit(int limit);
int getAltGlobalDownloadLimit() const;
void setAltGlobalDownloadLimit(int limit);
int getAltGlobalUploadLimit() const;
void setAltGlobalUploadLimit(int limit);
bool isAltBandwidthEnabled() const;
void setAltBandwidthEnabled(bool enabled);
bool isSchedulerEnabled() const;
void setSchedulerEnabled(bool enabled);
QTime getSchedulerStartTime() const;
void setSchedulerStartTime(const QTime &time);
QTime getSchedulerEndTime() const;
void setSchedulerEndTime(const QTime &time);
scheduler_days getSchedulerDays() const;
void setSchedulerDays(scheduler_days days);
// Proxy options
bool isProxyEnabled() const;
bool isProxyAuthEnabled() const;
void setProxyAuthEnabled(bool enabled);
QString getProxyIp() const;
void setProxyIp(const QString &ip);
unsigned short getProxyPort() const;
void setProxyPort(unsigned short port);
QString getProxyUsername() const;
void setProxyUsername(const QString &username);
QString getProxyPassword() const;
void setProxyPassword(const QString &password);
int getProxyType() const;
void setProxyType(int type);
bool proxyPeerConnections() const;
void setProxyPeerConnections(bool enabled);
#if LIBTORRENT_VERSION_NUM >= 10000
bool getForceProxy() const;
void setForceProxy(bool enabled);
#endif
// Bittorrent options
int getMaxConnecs() const;
void setMaxConnecs(int val);
int getMaxConnecsPerTorrent() const;
void setMaxConnecsPerTorrent(int val);
int getMaxUploads() const;
void setMaxUploads(int val);
int getMaxUploadsPerTorrent() const;
void setMaxUploadsPerTorrent(int val);
bool isuTPEnabled() const;
void setuTPEnabled(bool enabled);
bool isuTPRateLimited() const;
void setuTPRateLimited(bool enabled);
bool isDHTEnabled() const;
void setDHTEnabled(bool enabled);
bool isPeXEnabled() const;
void setPeXEnabled(bool enabled);
bool isLSDEnabled() const;
void setLSDEnabled(bool enabled);
int getEncryptionSetting() const;
void setEncryptionSetting(int val);
qreal getGlobalMaxRatio() const;
void setGlobalMaxRatio(qreal ratio);
int getMaxRatioAction() const;
void setMaxRatioAction(int act);
// IP Filter
bool isFilteringEnabled() const;
void setFilteringEnabled(bool enabled);
QString getFilter() const;
void setFilter(const QString &path);
QStringList bannedIPs() const;
void banIP(const QString &ip);
// Search
bool isSearchEnabled() const;
void setSearchEnabled(bool enabled);
// Execution Log
bool isExecutionLogEnabled() const;
void setExecutionLogEnabled(bool b);
// Queueing system
bool isQueueingSystemEnabled() const;
void setQueueingSystemEnabled(bool enabled);
int getMaxActiveDownloads() const;
void setMaxActiveDownloads(int val);
int getMaxActiveUploads() const;
void setMaxActiveUploads(int val);
int getMaxActiveTorrents() const;
void setMaxActiveTorrents(int val);
bool ignoreSlowTorrentsForQueueing() const;
void setIgnoreSlowTorrentsForQueueing(bool ignore);
bool isWebUiEnabled() const;
void setWebUiEnabled(bool enabled);
bool isWebUiLocalAuthEnabled() const;
void setWebUiLocalAuthEnabled(bool enabled);
quint16 getWebUiPort() const;
void setWebUiPort(quint16 port);
bool useUPnPForWebUIPort() const;
void setUPnPForWebUIPort(bool enabled);
QString getWebUiUsername() const;
void setWebUiUsername(const QString &username);
QString getWebUiPassword() const;
void setWebUiPassword(const QString &new_password);
bool isWebUiHttpsEnabled() const;
void setWebUiHttpsEnabled(bool enabled);
QByteArray getWebUiHttpsCertificate() const;
void setWebUiHttpsCertificate(const QByteArray &data);
QByteArray getWebUiHttpsKey() const;
void setWebUiHttpsKey(const QByteArray &data);
bool isDynDNSEnabled() const;
void setDynDNSEnabled(bool enabled);
DNS::Service getDynDNSService() const;
void setDynDNSService(int service);
QString getDynDomainName() const;
void setDynDomainName(const QString &name);
QString getDynDNSUsername() const;
void setDynDNSUsername(const QString &username);
QString getDynDNSPassword() const;
void setDynDNSPassword(const QString &password);
// Advanced settings
void setUILockPassword(const QString &clear_password);
void clearUILockPassword();
QString getUILockPasswordMD5() const;
bool isUILocked() const;
void setUILocked(bool locked);
bool isAutoRunEnabled() const;
void setAutoRunEnabled(bool enabled);
QString getAutoRunProgram() const;
void setAutoRunProgram(const QString &program);
bool shutdownWhenDownloadsComplete() const;
void setShutdownWhenDownloadsComplete(bool shutdown);
bool suspendWhenDownloadsComplete() const;
void setSuspendWhenDownloadsComplete(bool suspend);
bool hibernateWhenDownloadsComplete() const;
void setHibernateWhenDownloadsComplete(bool hibernate);
bool shutdownqBTWhenDownloadsComplete() const;
void setShutdownqBTWhenDownloadsComplete(bool shutdown);
uint diskCacheSize() const;
void setDiskCacheSize(uint size);
uint diskCacheTTL() const;
void setDiskCacheTTL(uint ttl);
bool osCache() const;
void setOsCache(bool enable);
uint saveResumeDataInterval() const;
void setSaveResumeDataInterval(uint m);
uint outgoingPortsMin() const;
void setOutgoingPortsMin(uint val);
uint outgoingPortsMax() const;
void setOutgoingPortsMax(uint val);
bool ignoreLimitsOnLAN() const;
void ignoreLimitsOnLAN(bool ignore);
bool includeOverheadInLimits() const;
void includeOverheadInLimits(bool include);
bool trackerExchangeEnabled() const;
void setTrackerExchangeEnabled(bool enable);
bool recheckTorrentsOnCompletion() const;
void recheckTorrentsOnCompletion(bool recheck);
unsigned int getRefreshInterval() const;
void setRefreshInterval(uint interval);
bool resolvePeerCountries() const;
void resolvePeerCountries(bool resolve);
bool resolvePeerHostNames() const;
void resolvePeerHostNames(bool resolve);
int getMaxHalfOpenConnections() const;
void setMaxHalfOpenConnections(int value);
QString getNetworkInterface() const;
void setNetworkInterface(const QString& iface);
QString getNetworkInterfaceName() const;
void setNetworkInterfaceName(const QString& iface);
bool getListenIPv6() const;
void setListenIPv6(bool enable);
QString getNetworkAddress() const;
void setNetworkAddress(const QString& addr);
bool isAnonymousModeEnabled() const;
void enableAnonymousMode(bool enabled);
bool isSuperSeedingEnabled() const;
void enableSuperSeeding(bool enabled);
bool announceToAllTrackers() const;
void setAnnounceToAllTrackers(bool enabled);
#if (defined(Q_OS_UNIX) && !defined(Q_OS_MAC))
bool useSystemIconTheme() const;
void useSystemIconTheme(bool enabled);
#endif
QStringList getTorrentLabels() const;
void setTorrentLabels(const QStringList& labels);
void addTorrentLabel(const QString& label);
void removeTorrentLabel(const QString& label);
bool recursiveDownloadDisabled() const;
void disableRecursiveDownload(bool disable=true);
#ifdef Q_OS_WIN
static QString getPythonPath();
bool neverCheckFileAssoc() const;
void setNeverCheckFileAssoc(bool check = true);
static bool isTorrentFileAssocSet();
static bool isMagnetLinkAssocSet();
static void setTorrentFileAssoc(bool set);
static void setMagnetLinkAssoc(bool set);
#endif
bool isTrackerEnabled() const;
void setTrackerEnabled(bool enabled);
int getTrackerPort() const;
void setTrackerPort(int port);
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
bool isUpdateCheckEnabled() const;
void setUpdateCheckEnabled(bool enabled);
#endif
bool confirmTorrentDeletion() const;
void setConfirmTorrentDeletion(bool enabled);
TrayIcon::Style trayIconStyle() const;
void setTrayIconStyle(TrayIcon::Style style);
// Stuff that don't appear in the Options GUI but are saved
// in the same file.
QByteArray getAddNewTorrentDialogState() const;
void setAddNewTorrentDialogState(const QByteArray &state);
int getAddNewTorrentDialogPos() const;
void setAddNewTorrentDialogPos(const int &pos);
int getAddNewTorrentDialogWidth() const;
void setAddNewTorrentDialogWidth(const int &width);
bool getAddNewTorrentDialogExpanded() const;
void setAddNewTorrentDialogExpanded(const bool expanded);
QStringList getAddNewTorrentDialogPathHistory() const;
void setAddNewTorrentDialogPathHistory(const QStringList &history);
QDateTime getDNSLastUpd() const;
void setDNSLastUpd(const QDateTime &date);
QString getDNSLastIP() const;
void setDNSLastIP(const QString &ip);
bool getAcceptedLegal() const;
void setAcceptedLegal(const bool accepted);
QByteArray getMainGeometry() const;
void setMainGeometry(const QByteArray &geometry);
QByteArray getMainVSplitterState() const;
void setMainVSplitterState(const QByteArray &state);
QString getMainLastDir() const;
void setMainLastDir(const QString &path);
#ifndef DISABLE_GUI
QSize getPrefSize(const QSize &defaultSize) const;
void setPrefSize(const QSize &size);
#endif
QPoint getPrefPos() const;
void setPrefPos(const QPoint &pos);
QStringList getPrefHSplitterSizes() const;
void setPrefHSplitterSizes(const QStringList &sizes);
QByteArray getPeerListState() const;
void setPeerListState(const QByteArray &state);
QString getPropSplitterSizes() const;
void setPropSplitterSizes(const QString &sizes);
QByteArray getPropFileListState() const;
void setPropFileListState(const QByteArray &state);
int getPropCurTab() const;
void setPropCurTab(const int &tab);
bool getPropVisible() const;
void setPropVisible(const bool visible);
QByteArray getPropTrackerListState() const;
void setPropTrackerListState(const QByteArray &state);
QByteArray getRssGeometry() const;
void setRssGeometry(const QByteArray &geometry);
QByteArray getRssHSplitterSizes() const;
void setRssHSplitterSizes(const QByteArray &sizes);
QStringList getRssOpenFolders() const;
void setRssOpenFolders(const QStringList &folders);
QByteArray getRssHSplitterState() const;
void setRssHSplitterState(const QByteArray &state);
QByteArray getRssVSplitterState() const;
void setRssVSplitterState(const QByteArray &state);
QString getSearchColsWidth() const;
void setSearchColsWidth(const QString &width);
QStringList getSearchEngDisabled() const;
void setSearchEngDisabled(const QStringList &engines);
QString getCreateTorLastAddPath() const;
void setCreateTorLastAddPath(const QString &path);
QString getCreateTorLastSavePath() const;
void setCreateTorLastSavePath(const QString &path);
QString getCreateTorTrackers() const;
void setCreateTorTrackers(const QString &path);
QByteArray getCreateTorGeometry() const;
void setCreateTorGeometry(const QByteArray &geometry);
bool getCreateTorIgnoreRatio() const;
void setCreateTorIgnoreRatio(const bool ignore);
QString getTorImportLastContentDir() const;
void setTorImportLastContentDir(const QString &path);
QByteArray getTorImportGeometry() const;
void setTorImportGeometry(const QByteArray &geometry);
int getTransSelFilter() const;
void setTransSelFilter(const int &index);
QByteArray getTransHeaderState() const;
void setTransHeaderState(const QByteArray &state);
// Temp code.
// See TorrentStatistics::loadStats() for details.
QVariantHash getStats() const;
void removeStats();
//From old RssSettings class
bool isRSSEnabled() const;
void setRSSEnabled(const bool enabled);
uint getRSSRefreshInterval() const;
void setRSSRefreshInterval(const uint &interval);
int getRSSMaxArticlesPerFeed() const;
void setRSSMaxArticlesPerFeed(const int &nb);
bool isRssDownloadingEnabled() const;
void setRssDownloadingEnabled(const bool b);
QStringList getRssFeedsUrls() const;
void setRssFeedsUrls(const QStringList &rssFeeds);
QStringList getRssFeedsAliases() const;
void setRssFeedsAliases(const QStringList &rssAliases);
QList<QByteArray> getHostNameCookies(const QString &host_name) const;
QList<QNetworkCookie> getHostNameQNetworkCookies(const QString& host_name) const;
void setHostNameCookies(const QString &host_name, const QList<QByteArray> &cookies);
};
#endif // PREFERENCES_H

View file

@ -1,391 +1,391 @@
"""SocksiPy - Python SOCKS module.
Version 1.01
Copyright 2006 Dan-Haim. All rights reserved.
Various fixes by Christophe DUMEZ <chris@qbittorrent.org> - 2010
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of Dan Haim nor the names of his contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE.
This module provides a standard socket-like interface for Python
for tunneling connections through SOCKS proxies.
"""
import socket
import struct
PROXY_TYPE_SOCKS4 = 1
PROXY_TYPE_SOCKS5 = 2
PROXY_TYPE_HTTP = 3
_defaultproxy = None
_orgsocket = socket.socket
class ProxyError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class GeneralProxyError(ProxyError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class Socks5AuthError(ProxyError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class Socks5Error(ProxyError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class Socks4Error(ProxyError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class HTTPError(ProxyError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
_generalerrors = ("success",
"invalid data",
"not connected",
"not available",
"bad proxy type",
"bad input")
_socks5errors = ("succeeded",
"general SOCKS server failure",
"connection not allowed by ruleset",
"Network unreachable",
"Host unreachable",
"Connection refused",
"TTL expired",
"Command not supported",
"Address type not supported",
"Unknown error")
_socks5autherrors = ("succeeded",
"authentication is required",
"all offered authentication methods were rejected",
"unknown username or invalid password",
"unknown error")
_socks4errors = ("request granted",
"request rejected or failed",
"request rejected because SOCKS server cannot connect to identd on the client",
"request rejected because the client program and identd report different user-ids",
"unknown error")
def setdefaultproxy(proxytype=None,addr=None,port=None,rdns=True,username=None,password=None):
"""setdefaultproxy(proxytype, addr[, port[, rdns[, username[, password]]]])
Sets a default proxy which all further socksocket objects will use,
unless explicitly changed.
"""
global _defaultproxy
_defaultproxy = (proxytype,addr,port,rdns,username,password)
class socksocket(socket.socket):
"""socksocket([family[, type[, proto]]]) -> socket object
Open a SOCKS enabled socket. The parameters are the same as
those of the standard socket init. In order for SOCKS to work,
you must specify family=AF_INET, type=SOCK_STREAM and proto=0.
"""
def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None):
_orgsocket.__init__(self,family,type,proto,_sock)
if _defaultproxy != None:
self.__proxy = _defaultproxy
else:
self.__proxy = (None, None, None, None, None, None)
self.__proxysockname = None
self.__proxypeername = None
def __recvall(self, bytes):
"""__recvall(bytes) -> data
Receive EXACTLY the number of bytes requested from the socket.
Blocks until the required number of bytes have been received.
"""
data = ""
while len(data) < bytes:
d = self.recv(bytes-len(data))
if not d:
raise GeneralProxyError("connection closed unexpectedly")
data = data + d
return data
def setproxy(self,proxytype=None,addr=None,port=None,rdns=True,username=None,password=None):
"""setproxy(proxytype, addr[, port[, rdns[, username[, password]]]])
Sets the proxy to be used.
proxytype - The type of the proxy to be used. Three types
are supported: PROXY_TYPE_SOCKS4 (including socks4a),
PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP
addr - The address of the server (IP or DNS).
port - The port of the server. Defaults to 1080 for SOCKS
servers and 8080 for HTTP proxy servers.
rdns - Should DNS queries be preformed on the remote side
(rather than the local side). The default is True.
Note: This has no effect with SOCKS4 servers.
username - Username to authenticate with to the server.
The default is no authentication.
password - Password to authenticate with to the server.
Only relevant when username is also provided.
"""
self.__proxy = (proxytype,addr,port,rdns,username,password)
def __negotiatesocks5(self,destaddr,destport):
"""__negotiatesocks5(self,destaddr,destport)
Negotiates a connection through a SOCKS5 server.
"""
# First we'll send the authentication packages we support.
if (self.__proxy[4]!=None) and (self.__proxy[5]!=None):
# The username/password details were supplied to the
# setproxy method so we support the USERNAME/PASSWORD
# authentication (in addition to the standard none).
self.sendall("\x05\x02\x00\x02")
else:
# No username/password were entered, therefore we
# only support connections with no authentication.
self.sendall("\x05\x01\x00")
# We'll receive the server's response to determine which
# method was selected
chosenauth = self.__recvall(2)
if chosenauth[0] != "\x05":
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
# Check the chosen authentication method
if chosenauth[1] == "\x00":
# No authentication is required
pass
elif chosenauth[1] == "\x02":
# Okay, we need to perform a basic username/password
# authentication.
self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5])
authstat = self.__recvall(2)
if authstat[0] != "\x01":
# Bad response
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
if authstat[1] != "\x00":
# Authentication failed
self.close()
raise Socks5AuthError,((3,_socks5autherrors[3]))
# Authentication succeeded
else:
# Reaching here is always bad
self.close()
if chosenauth[1] == "\xFF":
raise Socks5AuthError((2,_socks5autherrors[2]))
else:
raise GeneralProxyError((1,_generalerrors[1]))
# Now we can request the actual connection
req = "\x05\x01\x00"
# If the given destination address is an IP address, we'll
# use the IPv4 address request even if remote resolving was specified.
try:
ipaddr = socket.inet_aton(destaddr)
req = req + "\x01" + ipaddr
except socket.error:
# Well it's not an IP number, so it's probably a DNS name.
if self.__proxy[3]==True:
# Resolve remotely
ipaddr = None
req = req + "\x03" + chr(len(destaddr)) + destaddr
else:
# Resolve locally
ipaddr = socket.inet_aton(socket.gethostbyname(destaddr))
req = req + "\x01" + ipaddr
req = req + struct.pack(">H",destport)
self.sendall(req)
# Get the response
resp = self.__recvall(4)
if resp[0] != "\x05":
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
elif resp[1] != "\x00":
# Connection failed
self.close()
if ord(resp[1])<=8:
raise Socks5Error((ord(resp[1]),_generalerrors[ord(resp[1])]))
else:
raise Socks5Error((9,_generalerrors[9]))
# Get the bound address/port
elif resp[3] == "\x01":
boundaddr = self.__recvall(4)
elif resp[3] == "\x03":
resp = resp + self.recv(1)
boundaddr = self.__recvall(ord(resp[4]))
else:
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
boundport = struct.unpack(">H",self.__recvall(2))[0]
self.__proxysockname = (boundaddr,boundport)
if ipaddr != None:
self.__proxypeername = (socket.inet_ntoa(ipaddr),destport)
else:
self.__proxypeername = (destaddr,destport)
def getproxysockname(self):
"""getsockname() -> address info
Returns the bound IP address and port number at the proxy.
"""
return self.__proxysockname
def getproxypeername(self):
"""getproxypeername() -> address info
Returns the IP and port number of the proxy.
"""
return _orgsocket.getpeername(self)
def getpeername(self):
"""getpeername() -> address info
Returns the IP address and port number of the destination
machine (note: getproxypeername returns the proxy)
"""
return self.__proxypeername
def __negotiatesocks4(self,destaddr,destport):
"""__negotiatesocks4(self,destaddr,destport)
Negotiates a connection through a SOCKS4 server.
"""
# Check if the destination address provided is an IP address
rmtrslv = False
try:
ipaddr = socket.inet_aton(destaddr)
except socket.error:
# It's a DNS name. Check where it should be resolved.
if self.__proxy[3]==True:
ipaddr = "\x00\x00\x00\x01"
rmtrslv = True
else:
ipaddr = socket.inet_aton(socket.gethostbyname(destaddr))
# Construct the request packet
req = "\x04\x01" + struct.pack(">H",destport) + ipaddr
# The username parameter is considered userid for SOCKS4
if self.__proxy[4] != None:
req = req + self.__proxy[4]
req = req + "\x00"
# DNS name if remote resolving is required
# NOTE: This is actually an extension to the SOCKS4 protocol
# called SOCKS4A and may not be supported in all cases.
if rmtrslv==True:
req = req + destaddr + "\x00"
self.sendall(req)
# Get the response from the server
resp = self.__recvall(8)
if resp[0] != "\x00":
# Bad data
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
if resp[1] != "\x5A":
# Server returned an error
self.close()
if ord(resp[1]) in (91,92,93):
self.close()
raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90]))
else:
raise Socks4Error((94,_socks4errors[4]))
# Get the bound address/port
self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",resp[2:4])[0])
if rmtrslv != None:
self.__proxypeername = (socket.inet_ntoa(ipaddr),destport)
else:
self.__proxypeername = (destaddr,destport)
def __negotiatehttp(self,destaddr,destport):
"""__negotiatehttp(self,destaddr,destport)
Negotiates a connection through an HTTP server.
"""
# If we need to resolve locally, we do this now
if self.__proxy[3] == False:
addr = socket.gethostbyname(destaddr)
else:
addr = destaddr
self.sendall("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n")
# We read the response until we get the string "\r\n\r\n"
resp = self.recv(1)
while resp.find("\r\n\r\n")==-1:
resp = resp + self.recv(1)
# We just need the first line to check if the connection
# was successful
statusline = resp.splitlines()[0].split(" ",2)
if statusline[0] not in ("HTTP/1.0","HTTP/1.1"):
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
try:
statuscode = int(statusline[1])
except ValueError:
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
if statuscode != 200:
self.close()
raise HTTPError((statuscode,statusline[2]))
self.__proxysockname = ("0.0.0.0",0)
self.__proxypeername = (addr,destport)
def connect(self,destpair):
"""connect(self,despair)
Connects to the specified destination through a proxy.
destpar - A tuple of the IP/DNS address and the port number.
(identical to socket's connect).
To select the proxy server use setproxy().
"""
# Do a minimal input check first
if (type(destpair) in (list,tuple)==False) or (len(destpair)<2) or (type(destpair[0])!=str) or (type(destpair[1])!=int):
raise GeneralProxyError((5,_generalerrors[5]))
if self.__proxy[0] == PROXY_TYPE_SOCKS5:
if self.__proxy[2] != None:
portnum = self.__proxy[2]
else:
portnum = 1080
_orgsocket.connect(self,(self.__proxy[1],portnum))
self.__negotiatesocks5(destpair[0],destpair[1])
elif self.__proxy[0] == PROXY_TYPE_SOCKS4:
if self.__proxy[2] != None:
portnum = self.__proxy[2]
else:
portnum = 1080
_orgsocket.connect(self,(self.__proxy[1],portnum))
self.__negotiatesocks4(destpair[0],destpair[1])
elif self.__proxy[0] == PROXY_TYPE_HTTP:
if self.__proxy[2] != None:
portnum = self.__proxy[2]
else:
portnum = 8080
_orgsocket.connect(self,(self.__proxy[1],portnum))
self.__negotiatehttp(destpair[0],destpair[1])
elif self.__proxy[0] == None:
_orgsocket.connect(self,(destpair[0],destpair[1]))
else:
raise GeneralProxyError((4,_generalerrors[4]))
"""SocksiPy - Python SOCKS module.
Version 1.01
Copyright 2006 Dan-Haim. All rights reserved.
Various fixes by Christophe DUMEZ <chris@qbittorrent.org> - 2010
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of Dan Haim nor the names of his contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE.
This module provides a standard socket-like interface for Python
for tunneling connections through SOCKS proxies.
"""
import socket
import struct
PROXY_TYPE_SOCKS4 = 1
PROXY_TYPE_SOCKS5 = 2
PROXY_TYPE_HTTP = 3
_defaultproxy = None
_orgsocket = socket.socket
class ProxyError(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class GeneralProxyError(ProxyError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class Socks5AuthError(ProxyError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class Socks5Error(ProxyError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class Socks4Error(ProxyError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class HTTPError(ProxyError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
_generalerrors = ("success",
"invalid data",
"not connected",
"not available",
"bad proxy type",
"bad input")
_socks5errors = ("succeeded",
"general SOCKS server failure",
"connection not allowed by ruleset",
"Network unreachable",
"Host unreachable",
"Connection refused",
"TTL expired",
"Command not supported",
"Address type not supported",
"Unknown error")
_socks5autherrors = ("succeeded",
"authentication is required",
"all offered authentication methods were rejected",
"unknown username or invalid password",
"unknown error")
_socks4errors = ("request granted",
"request rejected or failed",
"request rejected because SOCKS server cannot connect to identd on the client",
"request rejected because the client program and identd report different user-ids",
"unknown error")
def setdefaultproxy(proxytype=None,addr=None,port=None,rdns=True,username=None,password=None):
"""setdefaultproxy(proxytype, addr[, port[, rdns[, username[, password]]]])
Sets a default proxy which all further socksocket objects will use,
unless explicitly changed.
"""
global _defaultproxy
_defaultproxy = (proxytype,addr,port,rdns,username,password)
class socksocket(socket.socket):
"""socksocket([family[, type[, proto]]]) -> socket object
Open a SOCKS enabled socket. The parameters are the same as
those of the standard socket init. In order for SOCKS to work,
you must specify family=AF_INET, type=SOCK_STREAM and proto=0.
"""
def __init__(self, family=socket.AF_INET, type=socket.SOCK_STREAM, proto=0, _sock=None):
_orgsocket.__init__(self,family,type,proto,_sock)
if _defaultproxy != None:
self.__proxy = _defaultproxy
else:
self.__proxy = (None, None, None, None, None, None)
self.__proxysockname = None
self.__proxypeername = None
def __recvall(self, bytes):
"""__recvall(bytes) -> data
Receive EXACTLY the number of bytes requested from the socket.
Blocks until the required number of bytes have been received.
"""
data = ""
while len(data) < bytes:
d = self.recv(bytes-len(data))
if not d:
raise GeneralProxyError("connection closed unexpectedly")
data = data + d
return data
def setproxy(self,proxytype=None,addr=None,port=None,rdns=True,username=None,password=None):
"""setproxy(proxytype, addr[, port[, rdns[, username[, password]]]])
Sets the proxy to be used.
proxytype - The type of the proxy to be used. Three types
are supported: PROXY_TYPE_SOCKS4 (including socks4a),
PROXY_TYPE_SOCKS5 and PROXY_TYPE_HTTP
addr - The address of the server (IP or DNS).
port - The port of the server. Defaults to 1080 for SOCKS
servers and 8080 for HTTP proxy servers.
rdns - Should DNS queries be preformed on the remote side
(rather than the local side). The default is True.
Note: This has no effect with SOCKS4 servers.
username - Username to authenticate with to the server.
The default is no authentication.
password - Password to authenticate with to the server.
Only relevant when username is also provided.
"""
self.__proxy = (proxytype,addr,port,rdns,username,password)
def __negotiatesocks5(self,destaddr,destport):
"""__negotiatesocks5(self,destaddr,destport)
Negotiates a connection through a SOCKS5 server.
"""
# First we'll send the authentication packages we support.
if (self.__proxy[4]!=None) and (self.__proxy[5]!=None):
# The username/password details were supplied to the
# setproxy method so we support the USERNAME/PASSWORD
# authentication (in addition to the standard none).
self.sendall("\x05\x02\x00\x02")
else:
# No username/password were entered, therefore we
# only support connections with no authentication.
self.sendall("\x05\x01\x00")
# We'll receive the server's response to determine which
# method was selected
chosenauth = self.__recvall(2)
if chosenauth[0] != "\x05":
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
# Check the chosen authentication method
if chosenauth[1] == "\x00":
# No authentication is required
pass
elif chosenauth[1] == "\x02":
# Okay, we need to perform a basic username/password
# authentication.
self.sendall("\x01" + chr(len(self.__proxy[4])) + self.__proxy[4] + chr(len(self.__proxy[5])) + self.__proxy[5])
authstat = self.__recvall(2)
if authstat[0] != "\x01":
# Bad response
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
if authstat[1] != "\x00":
# Authentication failed
self.close()
raise Socks5AuthError,((3,_socks5autherrors[3]))
# Authentication succeeded
else:
# Reaching here is always bad
self.close()
if chosenauth[1] == "\xFF":
raise Socks5AuthError((2,_socks5autherrors[2]))
else:
raise GeneralProxyError((1,_generalerrors[1]))
# Now we can request the actual connection
req = "\x05\x01\x00"
# If the given destination address is an IP address, we'll
# use the IPv4 address request even if remote resolving was specified.
try:
ipaddr = socket.inet_aton(destaddr)
req = req + "\x01" + ipaddr
except socket.error:
# Well it's not an IP number, so it's probably a DNS name.
if self.__proxy[3]==True:
# Resolve remotely
ipaddr = None
req = req + "\x03" + chr(len(destaddr)) + destaddr
else:
# Resolve locally
ipaddr = socket.inet_aton(socket.gethostbyname(destaddr))
req = req + "\x01" + ipaddr
req = req + struct.pack(">H",destport)
self.sendall(req)
# Get the response
resp = self.__recvall(4)
if resp[0] != "\x05":
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
elif resp[1] != "\x00":
# Connection failed
self.close()
if ord(resp[1])<=8:
raise Socks5Error((ord(resp[1]),_generalerrors[ord(resp[1])]))
else:
raise Socks5Error((9,_generalerrors[9]))
# Get the bound address/port
elif resp[3] == "\x01":
boundaddr = self.__recvall(4)
elif resp[3] == "\x03":
resp = resp + self.recv(1)
boundaddr = self.__recvall(ord(resp[4]))
else:
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
boundport = struct.unpack(">H",self.__recvall(2))[0]
self.__proxysockname = (boundaddr,boundport)
if ipaddr != None:
self.__proxypeername = (socket.inet_ntoa(ipaddr),destport)
else:
self.__proxypeername = (destaddr,destport)
def getproxysockname(self):
"""getsockname() -> address info
Returns the bound IP address and port number at the proxy.
"""
return self.__proxysockname
def getproxypeername(self):
"""getproxypeername() -> address info
Returns the IP and port number of the proxy.
"""
return _orgsocket.getpeername(self)
def getpeername(self):
"""getpeername() -> address info
Returns the IP address and port number of the destination
machine (note: getproxypeername returns the proxy)
"""
return self.__proxypeername
def __negotiatesocks4(self,destaddr,destport):
"""__negotiatesocks4(self,destaddr,destport)
Negotiates a connection through a SOCKS4 server.
"""
# Check if the destination address provided is an IP address
rmtrslv = False
try:
ipaddr = socket.inet_aton(destaddr)
except socket.error:
# It's a DNS name. Check where it should be resolved.
if self.__proxy[3]==True:
ipaddr = "\x00\x00\x00\x01"
rmtrslv = True
else:
ipaddr = socket.inet_aton(socket.gethostbyname(destaddr))
# Construct the request packet
req = "\x04\x01" + struct.pack(">H",destport) + ipaddr
# The username parameter is considered userid for SOCKS4
if self.__proxy[4] != None:
req = req + self.__proxy[4]
req = req + "\x00"
# DNS name if remote resolving is required
# NOTE: This is actually an extension to the SOCKS4 protocol
# called SOCKS4A and may not be supported in all cases.
if rmtrslv==True:
req = req + destaddr + "\x00"
self.sendall(req)
# Get the response from the server
resp = self.__recvall(8)
if resp[0] != "\x00":
# Bad data
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
if resp[1] != "\x5A":
# Server returned an error
self.close()
if ord(resp[1]) in (91,92,93):
self.close()
raise Socks4Error((ord(resp[1]),_socks4errors[ord(resp[1])-90]))
else:
raise Socks4Error((94,_socks4errors[4]))
# Get the bound address/port
self.__proxysockname = (socket.inet_ntoa(resp[4:]),struct.unpack(">H",resp[2:4])[0])
if rmtrslv != None:
self.__proxypeername = (socket.inet_ntoa(ipaddr),destport)
else:
self.__proxypeername = (destaddr,destport)
def __negotiatehttp(self,destaddr,destport):
"""__negotiatehttp(self,destaddr,destport)
Negotiates a connection through an HTTP server.
"""
# If we need to resolve locally, we do this now
if self.__proxy[3] == False:
addr = socket.gethostbyname(destaddr)
else:
addr = destaddr
self.sendall("CONNECT " + addr + ":" + str(destport) + " HTTP/1.1\r\n" + "Host: " + destaddr + "\r\n\r\n")
# We read the response until we get the string "\r\n\r\n"
resp = self.recv(1)
while resp.find("\r\n\r\n")==-1:
resp = resp + self.recv(1)
# We just need the first line to check if the connection
# was successful
statusline = resp.splitlines()[0].split(" ",2)
if statusline[0] not in ("HTTP/1.0","HTTP/1.1"):
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
try:
statuscode = int(statusline[1])
except ValueError:
self.close()
raise GeneralProxyError((1,_generalerrors[1]))
if statuscode != 200:
self.close()
raise HTTPError((statuscode,statusline[2]))
self.__proxysockname = ("0.0.0.0",0)
self.__proxypeername = (addr,destport)
def connect(self,destpair):
"""connect(self,despair)
Connects to the specified destination through a proxy.
destpar - A tuple of the IP/DNS address and the port number.
(identical to socket's connect).
To select the proxy server use setproxy().
"""
# Do a minimal input check first
if (type(destpair) in (list,tuple)==False) or (len(destpair)<2) or (type(destpair[0])!=str) or (type(destpair[1])!=int):
raise GeneralProxyError((5,_generalerrors[5]))
if self.__proxy[0] == PROXY_TYPE_SOCKS5:
if self.__proxy[2] != None:
portnum = self.__proxy[2]
else:
portnum = 1080
_orgsocket.connect(self,(self.__proxy[1],portnum))
self.__negotiatesocks5(destpair[0],destpair[1])
elif self.__proxy[0] == PROXY_TYPE_SOCKS4:
if self.__proxy[2] != None:
portnum = self.__proxy[2]
else:
portnum = 1080
_orgsocket.connect(self,(self.__proxy[1],portnum))
self.__negotiatesocks4(destpair[0],destpair[1])
elif self.__proxy[0] == PROXY_TYPE_HTTP:
if self.__proxy[2] != None:
portnum = self.__proxy[2]
else:
portnum = 8080
_orgsocket.connect(self,(self.__proxy[1],portnum))
self.__negotiatehttp(destpair[0],destpair[1])
elif self.__proxy[0] == None:
_orgsocket.connect(self,(destpair[0],destpair[1]))
else:
raise GeneralProxyError((4,_generalerrors[4]))

View file

@ -1,54 +1,54 @@
/*
Core.css for Mocha UI
Theme: Default
Copyright:
Copyright (c) 2007-2009 Greg Houston, <http://greghoustondesign.com/>.
License:
MIT-style license.
Notes:
CSS rules in this file:
1. Rules required by all MochaUI components or are shared by more than one.
2. Theme specific ajustments to plugin styles.
3. Miscellaneous rules that have no better place to go.
*/
/* Required By All
---------------------------------------------------------------- */
/* Clears */
.clear {
clear: both;
height: 0;
}
* html .clear {
font-size: 1px;
line-height: 1px;
overflow: hidden;
visibility: hidden;
}
/* Miscellaneous
---------------------------------------------------------------- */
#themeControl {
margin-top: 2px;
}
/* Theme Specific Adjustments to Default Plugin Styles
---------------------------------------------------------------- */
/* Folder Tree */
.tree li a {
color: #3f3f3f !important;
/*
Core.css for Mocha UI
Theme: Default
Copyright:
Copyright (c) 2007-2009 Greg Houston, <http://greghoustondesign.com/>.
License:
MIT-style license.
Notes:
CSS rules in this file:
1. Rules required by all MochaUI components or are shared by more than one.
2. Theme specific ajustments to plugin styles.
3. Miscellaneous rules that have no better place to go.
*/
/* Required By All
---------------------------------------------------------------- */
/* Clears */
.clear {
clear: both;
height: 0;
}
* html .clear {
font-size: 1px;
line-height: 1px;
overflow: hidden;
visibility: hidden;
}
/* Miscellaneous
---------------------------------------------------------------- */
#themeControl {
margin-top: 2px;
}
/* Theme Specific Adjustments to Default Plugin Styles
---------------------------------------------------------------- */
/* Folder Tree */
.tree li a {
color: #3f3f3f !important;
}

View file

@ -1,429 +1,429 @@
/*
Core.css for Mocha UI
Theme: Default
Copyright:
Copyright (c) 2007-2009 Greg Houston, <http://greghoustondesign.com/>.
License:
MIT-style license.
Required by:
Layout.js
*/
/* Layout
---------------------------------------------------------------- */
html, body {
background: #fff;
}
body {
margin: 0; /* Required */
}
#desktop {
position: relative;
min-width: 400px; /* Helps keep header content from wrapping */
height: 100%;
min-height: 100%;
overflow: hidden;
cursor: default; /* Fix for issue in IE7. IE7 wants to use the I-bar text cursor */
}
#desktopHeader {
background: #f2f2f2;
}
#desktopTitlebarWrapper {
position: relative;
height: 45px;
overflow: hidden;
background: #718BA6 url(../images/skin/bg-header.gif) repeat-x;
}
#desktopTitlebar {
padding: 7px 8px 6px 8px;
height: 32px;
background: url(../images/skin/logo.gif) no-repeat;
background-position: left 0;
}
#desktopTitlebar h1.applicationTitle {
display: none;
margin: 0;
padding: 0 5px 0 0;
font-size: 20px;
line-height: 25px;
font-weight: bold;
color: #fff;
}
#desktopTitlebar h2.tagline {
padding: 7px 0 0 0;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #d4dce4;
font-weight: bold;
text-align: center;
text-transform: uppercase;
}
#desktopTitlebar h2.tagline .taglineEm {
color: #fff;
font-weight: bold;
}
#topNav {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
position: absolute;
right: 0;
top: 0;
color: #d4dce4;
text-align: right;
padding: 13px 10px 0 0;
}
#topNav a {
color: #fff;
font-weight: normal;
}
#topNav a:hover {
text-decoration: none;
}
/* Navbar */
#desktopNavbar {
background: #f2f2f2;
/*height: 30px;*/
margin: 0 0px;
overflow: hidden; /* Remove this line if you want the menu to be backward compatible with Firefox 2 */
/* Fixes by Chris */
/*background-color: #ccc;*/
height: 20px;
margin-bottom: 5px;
border-bottom: 1px solid #3f3f3f;
}
#desktopNavbar ul {
padding: 0;
margin: 0;
list-style: none;
font-size: 12px;
}
#desktopNavbar>ul>li {
float: left;
}
#desktopNavbar a {
display: block;
}
#desktopNavbar ul li a {
/*padding: 6px 10px 6px 10px;*/
color: #333;
font-weight: normal;
/* Fix by Chris */
padding: 2px 10px 6px 10px;
}
#desktopNavbar ul li a:hover {
color: #333;
/* Fix By Chris */
background-color: #fff;
}
#desktopNavbar ul li a.arrow-right, #desktopNavbar ul li a:hover.arrow-right {
background-image: url(../images/skin/arrow-right.gif);
background-repeat: no-repeat;
background-position: right 7px;
}
#desktopNavbar li ul {
border: 1px solid #3f3f3f;
background: #fff url(../images/skin/bg-dropdown.gif) repeat-y;
position: absolute;
left: -999em;
z-index: 8000;
/* Fix by Chris */
margin-top: -6px;
}
#desktopNavbar li:hover ul ul,
#desktopNavbar li.ieHover ul ul,
#desktopNavbar li:hover ul ul ul,
#desktopNavbar li.ieHover ul ul ul {
left: -999em;
}
#desktopNavbar li ul ul { /* third-and-above-level lists */
margin: -22px 0 0 163px;
}
#desktopNavbar li ul li .check {
position: absolute;
top: 8px;
left: 6px;
width: 5px;
height: 5px;
background: #555;
overflow: hidden;
line-height: 1px;
font-size: 1px;
}
#desktopNavbar li ul li a {
position: relative;
/*padding: 1px 9px 1px 25px;*/
min-width: 120px;
color: #3f3f3f;
font-weight: normal;
/* Fix By Chris */
padding: 1px 10px 1px 20px; /* Reduce left padding */
}
#desktopNavbar li ul li a:hover {
background: #6C98D9;
color: #fff;
-moz-border-radius: 2px;
}
#desktopNavbar li ul li a:hover .check {
background: #fff;
}
#desktopNavbar li:hover ul,
#desktopNavbar li.ieHover ul,
#desktopNavbar li li.ieHover ul,
#desktopNavbar li li li.ieHover ul,
#desktopNavbar li li:hover ul,
#desktopNavbar li li li:hover ul { /* lists nested under hovered list items */
left: auto;
}
#desktopNavbar li:hover { /* For IE7 */
position: static;
}
li.divider {
margin-top: 2px;
padding-top: 3px;
border-top: 1px solid #ebebeb;
}
#pageWrapper {
position: relative;
overflow: hidden; /* This can be set to hidden or auto */
border-top: 1px solid #909090;
border-bottom: 1px solid #909090;
/*height: 100%;*/
}
/* Footer */
#desktopFooterWrapper {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 30px;
overflow: hidden;
}
#desktopFooter {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
height: 24px;
padding: 6px 8px 0 8px;
background: #f2f2f2;
}
/* Panel Layout
---------------------------------------------------------------- */
/* Columns */
.column {
position: relative;
float: left;
overflow: hidden; /* Required by IE6 */
}
/* Panels */
.panel {
position: relative;
overflow: auto;
background: #f8f8f8;
border-bottom: 1px solid #b9b9b9;
}
.panelWrapper.collapsed .panel-header {
border-bottom: 0;
}
.panelAlt {
background: #f2f2f2;
}
.bottomPanel {
border-bottom: 0;
}
.pad {
padding: 8px;
}
#mainPanel {
background: #fff;
}
.panel-header {
position: relative;
background: #f1f1f1 url(../images/skin/bg-panel-header.gif) repeat-x;
height: 30px;
overflow: hidden;
border-bottom: 1px solid #d3d3d3;
}
.panel-headerContent {
padding-top: 2px;
}
.panel-headerContent.tabs {
background: url(../images/skin/tabs.gif) repeat-x;
background-position: left -68px;
}
.panel-header h2 {
display: inline-block;
font-size: 12px;
margin: 0;
padding: 3px 8px 0 8px;
height: 22px;
overflow: hidden;
color: #333;
}
.panel-collapse {
background: url(../images/skin/collapse-expand.gif) left top no-repeat;
}
.panel-expand {
background: url(../images/skin/collapse-expand.gif) left -16px no-repeat;
}
.icon16 {
margin: 4px 0 0 2px;
cursor: pointer;
}
/* Column and Panel Handles */
.horizontalHandle {
height: 4px;
line-height: 1px;
font-size: 1px;
overflow: hidden;
background: #eee url(../images/skin/bg-handle-horizontal.gif) repeat-x;
}
.horizontalHandle.detached .handleIcon {
background: transparent;
}
.horizontalHandle .handleIcon {
margin: 0 auto;
height: 4px;
line-height: 1px;
font-size: 1px;
overflow: hidden;
background: url(../images/skin/handle-icon-horizontal.gif) center center no-repeat;
}
.columnHandle {
min-height: 10px;
float: left;
width: 4px;
overflow: hidden;
background: #c3c3c3 url(../images/skin/handle-icon.gif) center center no-repeat;
border: 1px solid #909090;
border-top: 0;
border-bottom: 0;
}
/* Toolboxes */
.toolbox {
float: right;
margin-top: 3px;
padding: 0 5px;
height: 24px;
overflow: hidden;
text-align: right;
}
.panel-header-toolbox {
}
div.toolbox.divider { /* Have to specify div here for IE6's sake */
background: url(../images/skin/toolbox-divider.gif) repeat-y;
padding-left: 8px;
}
.toolbox img.disabled {
cursor: default;
}
.iconWrapper {
display: inline-block;
height: 22px;
min-width: 22px;
overflow: hidden;
border: 1px solid transparent;
}
* html .iconWrapper {
padding: 1px;
border: 0;
}
.iconWrapper img {
cursor: pointer;
margin: 0;
padding: 3px;
}
.iconWrapper:hover {
border: 1px solid #a0a0a0;
-moz-border-radius: 3px;
}
#spinnerWrapper {
width: 16px;
height: 16px;
background: url(../images/skin/spinner-placeholder.gif) no-repeat;
margin: 4px 5px 0 5px;
}
#spinner {
display: none;
background: url(../images/skin/spinner.gif) no-repeat;
width: 16px;
height: 16px;
}
#desktopFooter td {
vertical-align: top;
text-align: center;
/*
Core.css for Mocha UI
Theme: Default
Copyright:
Copyright (c) 2007-2009 Greg Houston, <http://greghoustondesign.com/>.
License:
MIT-style license.
Required by:
Layout.js
*/
/* Layout
---------------------------------------------------------------- */
html, body {
background: #fff;
}
body {
margin: 0; /* Required */
}
#desktop {
position: relative;
min-width: 400px; /* Helps keep header content from wrapping */
height: 100%;
min-height: 100%;
overflow: hidden;
cursor: default; /* Fix for issue in IE7. IE7 wants to use the I-bar text cursor */
}
#desktopHeader {
background: #f2f2f2;
}
#desktopTitlebarWrapper {
position: relative;
height: 45px;
overflow: hidden;
background: #718BA6 url(../images/skin/bg-header.gif) repeat-x;
}
#desktopTitlebar {
padding: 7px 8px 6px 8px;
height: 32px;
background: url(../images/skin/logo.gif) no-repeat;
background-position: left 0;
}
#desktopTitlebar h1.applicationTitle {
display: none;
margin: 0;
padding: 0 5px 0 0;
font-size: 20px;
line-height: 25px;
font-weight: bold;
color: #fff;
}
#desktopTitlebar h2.tagline {
padding: 7px 0 0 0;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
color: #d4dce4;
font-weight: bold;
text-align: center;
text-transform: uppercase;
}
#desktopTitlebar h2.tagline .taglineEm {
color: #fff;
font-weight: bold;
}
#topNav {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
position: absolute;
right: 0;
top: 0;
color: #d4dce4;
text-align: right;
padding: 13px 10px 0 0;
}
#topNav a {
color: #fff;
font-weight: normal;
}
#topNav a:hover {
text-decoration: none;
}
/* Navbar */
#desktopNavbar {
background: #f2f2f2;
/*height: 30px;*/
margin: 0 0px;
overflow: hidden; /* Remove this line if you want the menu to be backward compatible with Firefox 2 */
/* Fixes by Chris */
/*background-color: #ccc;*/
height: 20px;
margin-bottom: 5px;
border-bottom: 1px solid #3f3f3f;
}
#desktopNavbar ul {
padding: 0;
margin: 0;
list-style: none;
font-size: 12px;
}
#desktopNavbar>ul>li {
float: left;
}
#desktopNavbar a {
display: block;
}
#desktopNavbar ul li a {
/*padding: 6px 10px 6px 10px;*/
color: #333;
font-weight: normal;
/* Fix by Chris */
padding: 2px 10px 6px 10px;
}
#desktopNavbar ul li a:hover {
color: #333;
/* Fix By Chris */
background-color: #fff;
}
#desktopNavbar ul li a.arrow-right, #desktopNavbar ul li a:hover.arrow-right {
background-image: url(../images/skin/arrow-right.gif);
background-repeat: no-repeat;
background-position: right 7px;
}
#desktopNavbar li ul {
border: 1px solid #3f3f3f;
background: #fff url(../images/skin/bg-dropdown.gif) repeat-y;
position: absolute;
left: -999em;
z-index: 8000;
/* Fix by Chris */
margin-top: -6px;
}
#desktopNavbar li:hover ul ul,
#desktopNavbar li.ieHover ul ul,
#desktopNavbar li:hover ul ul ul,
#desktopNavbar li.ieHover ul ul ul {
left: -999em;
}
#desktopNavbar li ul ul { /* third-and-above-level lists */
margin: -22px 0 0 163px;
}
#desktopNavbar li ul li .check {
position: absolute;
top: 8px;
left: 6px;
width: 5px;
height: 5px;
background: #555;
overflow: hidden;
line-height: 1px;
font-size: 1px;
}
#desktopNavbar li ul li a {
position: relative;
/*padding: 1px 9px 1px 25px;*/
min-width: 120px;
color: #3f3f3f;
font-weight: normal;
/* Fix By Chris */
padding: 1px 10px 1px 20px; /* Reduce left padding */
}
#desktopNavbar li ul li a:hover {
background: #6C98D9;
color: #fff;
-moz-border-radius: 2px;
}
#desktopNavbar li ul li a:hover .check {
background: #fff;
}
#desktopNavbar li:hover ul,
#desktopNavbar li.ieHover ul,
#desktopNavbar li li.ieHover ul,
#desktopNavbar li li li.ieHover ul,
#desktopNavbar li li:hover ul,
#desktopNavbar li li li:hover ul { /* lists nested under hovered list items */
left: auto;
}
#desktopNavbar li:hover { /* For IE7 */
position: static;
}
li.divider {
margin-top: 2px;
padding-top: 3px;
border-top: 1px solid #ebebeb;
}
#pageWrapper {
position: relative;
overflow: hidden; /* This can be set to hidden or auto */
border-top: 1px solid #909090;
border-bottom: 1px solid #909090;
/*height: 100%;*/
}
/* Footer */
#desktopFooterWrapper {
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 30px;
overflow: hidden;
}
#desktopFooter {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 10px;
height: 24px;
padding: 6px 8px 0 8px;
background: #f2f2f2;
}
/* Panel Layout
---------------------------------------------------------------- */
/* Columns */
.column {
position: relative;
float: left;
overflow: hidden; /* Required by IE6 */
}
/* Panels */
.panel {
position: relative;
overflow: auto;
background: #f8f8f8;
border-bottom: 1px solid #b9b9b9;
}
.panelWrapper.collapsed .panel-header {
border-bottom: 0;
}
.panelAlt {
background: #f2f2f2;
}
.bottomPanel {
border-bottom: 0;
}
.pad {
padding: 8px;
}
#mainPanel {
background: #fff;
}
.panel-header {
position: relative;
background: #f1f1f1 url(../images/skin/bg-panel-header.gif) repeat-x;
height: 30px;
overflow: hidden;
border-bottom: 1px solid #d3d3d3;
}
.panel-headerContent {
padding-top: 2px;
}
.panel-headerContent.tabs {
background: url(../images/skin/tabs.gif) repeat-x;
background-position: left -68px;
}
.panel-header h2 {
display: inline-block;
font-size: 12px;
margin: 0;
padding: 3px 8px 0 8px;
height: 22px;
overflow: hidden;
color: #333;
}
.panel-collapse {
background: url(../images/skin/collapse-expand.gif) left top no-repeat;
}
.panel-expand {
background: url(../images/skin/collapse-expand.gif) left -16px no-repeat;
}
.icon16 {
margin: 4px 0 0 2px;
cursor: pointer;
}
/* Column and Panel Handles */
.horizontalHandle {
height: 4px;
line-height: 1px;
font-size: 1px;
overflow: hidden;
background: #eee url(../images/skin/bg-handle-horizontal.gif) repeat-x;
}
.horizontalHandle.detached .handleIcon {
background: transparent;
}
.horizontalHandle .handleIcon {
margin: 0 auto;
height: 4px;
line-height: 1px;
font-size: 1px;
overflow: hidden;
background: url(../images/skin/handle-icon-horizontal.gif) center center no-repeat;
}
.columnHandle {
min-height: 10px;
float: left;
width: 4px;
overflow: hidden;
background: #c3c3c3 url(../images/skin/handle-icon.gif) center center no-repeat;
border: 1px solid #909090;
border-top: 0;
border-bottom: 0;
}
/* Toolboxes */
.toolbox {
float: right;
margin-top: 3px;
padding: 0 5px;
height: 24px;
overflow: hidden;
text-align: right;
}
.panel-header-toolbox {
}
div.toolbox.divider { /* Have to specify div here for IE6's sake */
background: url(../images/skin/toolbox-divider.gif) repeat-y;
padding-left: 8px;
}
.toolbox img.disabled {
cursor: default;
}
.iconWrapper {
display: inline-block;
height: 22px;
min-width: 22px;
overflow: hidden;
border: 1px solid transparent;
}
* html .iconWrapper {
padding: 1px;
border: 0;
}
.iconWrapper img {
cursor: pointer;
margin: 0;
padding: 3px;
}
.iconWrapper:hover {
border: 1px solid #a0a0a0;
-moz-border-radius: 3px;
}
#spinnerWrapper {
width: 16px;
height: 16px;
background: url(../images/skin/spinner-placeholder.gif) no-repeat;
margin: 4px 5px 0 5px;
}
#spinner {
display: none;
background: url(../images/skin/spinner.gif) no-repeat;
width: 16px;
height: 16px;
}
#desktopFooter td {
vertical-align: top;
text-align: center;
}

View file

@ -1,66 +1,66 @@
/*
Tabs.css for Mocha UI
Theme: Default
Copyright:
Copyright (c) 2007-2009 Greg Houston, <http://greghoustondesign.com/>.
License:
MIT-style license.
Required by:
Tabs.js
*/
/* Toolbar Tabs */
.toolbarTabs {
padding: 0 5px 2px 2px;
background: url(../images/skin/tabs.gif) repeat-x;
background-position: left -70px;
overflow: visible;
}
.tab-menu {
padding-top: 1px;
list-style: none;
margin: 0;
padding: 0;
line-height: 16px;
font-size: 11px;
}
.tab-menu li {
display: block;
float: left;
margin: 0 0 5px 0;
cursor: pointer;
background: url(../images/skin/tabs.gif) repeat-x;
background-position: left -35px;
}
.tab-menu li.selected {
background: url(../images/skin/tabs.gif) repeat-x;
background-position: left 0;
}
.tab-menu li a {
display: block;
margin-left: 8px;
padding: 6px 15px 5px 9px;
text-align: center;
font-weight: normal;
color: #181818;
background: url(../images/skin/tabs.gif) repeat-x;
background-position: right -35px;
}
.tab-menu li.selected a {
color: #181818;
font-weight: bold;
background: url(../images/skin/tabs.gif) repeat-x;
background-position: right 0;
}
/*
Tabs.css for Mocha UI
Theme: Default
Copyright:
Copyright (c) 2007-2009 Greg Houston, <http://greghoustondesign.com/>.
License:
MIT-style license.
Required by:
Tabs.js
*/
/* Toolbar Tabs */
.toolbarTabs {
padding: 0 5px 2px 2px;
background: url(../images/skin/tabs.gif) repeat-x;
background-position: left -70px;
overflow: visible;
}
.tab-menu {
padding-top: 1px;
list-style: none;
margin: 0;
padding: 0;
line-height: 16px;
font-size: 11px;
}
.tab-menu li {
display: block;
float: left;
margin: 0 0 5px 0;
cursor: pointer;
background: url(../images/skin/tabs.gif) repeat-x;
background-position: left -35px;
}
.tab-menu li.selected {
background: url(../images/skin/tabs.gif) repeat-x;
background-position: left 0;
}
.tab-menu li a {
display: block;
margin-left: 8px;
padding: 6px 15px 5px 9px;
text-align: center;
font-weight: normal;
color: #181818;
background: url(../images/skin/tabs.gif) repeat-x;
background-position: right -35px;
}
.tab-menu li.selected a {
color: #181818;
font-weight: bold;
background: url(../images/skin/tabs.gif) repeat-x;
background-position: right 0;
}

View file

@ -1,378 +1,378 @@
/*
Window.css for Mocha UI
Theme: Default
Copyright:
Copyright (c) 2007-2009 Greg Houston, <http://greghoustondesign.com/>.
License:
MIT-style license.
Required by:
Window.js and Modal.css
*/
/* Windows
---------------------------------------------------------------- */
.mocha {
display: none;
overflow: hidden;
background-color: #e5e5e5;
}
.mocha.isFocused {
}
.mochaOverlay {
position: absolute; /* This is also set in theme.js in order to make theme transitions smoother */
top: 0;
left: 0;
}
/*
We get a little creative here in order to define a gradient in the CSS using a query
string appended to a background image.
"from" is the top color of the gradient. "to" is the bottom color of the gradient.
Both must be hex values without the leading # sign.
*/
.mochaTitlebar {
width: 100%;
overflow: hidden;
background: url(../images/skin/spacer.gif?from=fafafa&to=e5e5e5);
}
.mochaTitlebar h3 {
font-size: 12px;
line-height: 15px;
font-weight: bold;
margin: 0;
padding: 5px 10px 4px 12px;
color: #888;
}
.mocha.isFocused .mochaTitlebar h3 {
color: #181818;
}
.mochaToolbarWrapper {
width: 100%; /* For IE */
position: relative;
height: 29px;
background: #f1f1f1;
overflow: hidden;
border-top: 1px solid #d9d9d9;
}
div.mochaToolbarWrapper.bottom {
border: 0;
border-bottom: 1px solid #d9d9d9;
}
.mochaToolbar {
width: 100%; /* For IE */
border-top: 1px solid #fff;
}
.mochaContentBorder {
border-top: 1px solid #dadada;
border-bottom: 1px solid #dadada;
}
.mochaContentWrapper { /* Has a fixed height and scrollbars if required. */
font-size: 12px;
overflow: auto;
background: #fff;
}
.mochaContent {
padding: 10px 12px;
}
.mocha .handle {
position: absolute;
background: #0f0;
width: 3px;
height: 3px;
z-index: 2;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/
opacity: .0;
-moz-opacity: .0;
overflow: hidden;
font-size: 1px; /* For IE6 */
}
.mocha .corner { /* Corner resize handles */
width: 10px;
height: 10px;
background: #f00;
}
.mocha .cornerSE { /* Bottom right resize handle */
width: 20px;
height: 20px;
background: #fefefe; /* This is the color of the visible resize handle */
}
.mochaCanvasHeader {
position: absolute;
top: 0;
left: 0;
background: transparent;
z-index: -1;
visibility: hidden;
overflow: hidden;
}
.mochaControls {
position: absolute;
width: 52px;
top: 8px;
right: 8px;
height: 14px;
z-index: 4;
background: transparent;
}
.mochaCanvasControls {
position: absolute;
top: 8px;
right: 8px;
z-index: 3;
background: transparent;
}
/*
To use images for these buttons:
1. Set the useCanvasControls window option to false.
2. If you use a different button size you may need to reposition the controls.
Modify the controlsOffset window option.
2. Replcac the background-color with a background-image for each button.
*/
.mochaMinimizeButton, .mochaMaximizeButton, .mochaCloseButton {
float: right;
width: 14px;
height: 14px;
font-size: 1px;
cursor: pointer;
z-index: 4;
color: #666;
background-color: #fff;
margin-left: 5px;
}
.mochaMinimizeButton {
margin-left: 0;
}
.mochaMaximizeButton {
}
.mochaCloseButton {
}
.mochaSpinner{
display: none;
position: absolute;
bottom: 7px;
left: 6px;
width: 16px;
height: 16px;
background: url(../images/skin/spinner.gif) no-repeat;
}
.mochaIframe {
width: 100%;
}
/* Fix for IE6 select z-index issue */
.zIndexFix {
display: block;
position: absolute;
top: 0;
left: 0;
z-index: -1;
filter: mask();
width: 100px;
height: 100px;
border: 1px solid transparent;
}
/* Viewport overlays
---------------------------------------------------------------- */
#modalOverlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #000;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/
opacity: 0;
-moz-opacity: 0;
z-index: 10000;
}
/* Fix for IE6 select z-index issue */
#modalFix {
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/
opacity: 0;
-moz-opacity: 0;
z-index: 9999;
}
/* Underlay */
#windowUnderlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #fff;
}
* html #windowUnderlay {
position: absolute;
}
/* The replaced class is used internally when converting CSS values to Canvas. These classes should not be removed. */
.mocha.replaced, .mochaTitlebar.replaced, .mochaMinimizeButton.replaced, .mochaMaximizeButton.replaced, .mochaCloseButton.replaced {
background-color: transparent !important;
}
.windowClosed {
visibility: hidden;
display: none;
position: absolute;
top: -20000px;
left: -20000px;
z-index: -1;
overflow: hidden;
}
.windowClosed .mochaContentBorder, .windowClosed .mochaToolbarWrapper, .windowClosed .mochaTitlebar, .windowClosed .mochaControls,
.windowClosed .mochaCanvasControls {
position: absolute;
top: 0;
left: 0;
visibility: hidden;
display: none;
z-index: -1;
}
/* Modals */
.modal2 {
border: 8px solid #fff;
}
.modal2 .mochaContentBorder {
border-width: 0px;
}
/* Window Themes */
.mocha.no-canvas {
background: #e5e5e5;
border: 1px solid #555;
}
.mocha.no-canvas .mochaTitlebar {
background: #e5e5e5;
}
.mocha.transparent .mochaTitlebar h3 {
color: #fff;
display: none;
}
.mocha.transparent .mochaContentWrapper {
background: transparent;
}
.mocha.notification {
background: #cedff2;
}
.mocha.notification .mochaTitlebar {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/
opacity: .0;
-moz-opacity: 0;
}
.mocha.notification .mochaContentBorder {
border-width: 0px;
}
.mocha.notification .mochaContentWrapper {
text-align: center;
font-size: 12px;
font-weight: bold;
background: transparent;
}
/* Example Window Themes */
#about_contentWrapper {
background: #e5e5e5 url(../images/skin/logo2.gif) 3px 3px no-repeat;
}
#builder_contentWrapper {
background: #f5f5f7;
}
#json01 .mochaTitlebar {
background: #6dd2db;
}
#json02 .mochaTitlebar {
background: #6db6db;
}
#json03 .mochaTitlebar {
background: #6d92db;
}
.jsonExample .mochaTitlebar h3 {
color: #ddd;
}
/* This does not work in IE6. */
.isFocused.jsonExample .mochaTitlebar h3 {
color: #fff;
}
#fxmorpherExample .mochaContentWrapper {
background: #577a9e;
}
#clock {
background: #fff;
}
/* Workaround to make invisible buttons clickable */
.mochaMinimizeButton.replaced,
.mochaMaximizeButton.replaced,
.mochaCloseButton.replaced {
background-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7) !important;
/*
Window.css for Mocha UI
Theme: Default
Copyright:
Copyright (c) 2007-2009 Greg Houston, <http://greghoustondesign.com/>.
License:
MIT-style license.
Required by:
Window.js and Modal.css
*/
/* Windows
---------------------------------------------------------------- */
.mocha {
display: none;
overflow: hidden;
background-color: #e5e5e5;
}
.mocha.isFocused {
}
.mochaOverlay {
position: absolute; /* This is also set in theme.js in order to make theme transitions smoother */
top: 0;
left: 0;
}
/*
We get a little creative here in order to define a gradient in the CSS using a query
string appended to a background image.
"from" is the top color of the gradient. "to" is the bottom color of the gradient.
Both must be hex values without the leading # sign.
*/
.mochaTitlebar {
width: 100%;
overflow: hidden;
background: url(../images/skin/spacer.gif?from=fafafa&to=e5e5e5);
}
.mochaTitlebar h3 {
font-size: 12px;
line-height: 15px;
font-weight: bold;
margin: 0;
padding: 5px 10px 4px 12px;
color: #888;
}
.mocha.isFocused .mochaTitlebar h3 {
color: #181818;
}
.mochaToolbarWrapper {
width: 100%; /* For IE */
position: relative;
height: 29px;
background: #f1f1f1;
overflow: hidden;
border-top: 1px solid #d9d9d9;
}
div.mochaToolbarWrapper.bottom {
border: 0;
border-bottom: 1px solid #d9d9d9;
}
.mochaToolbar {
width: 100%; /* For IE */
border-top: 1px solid #fff;
}
.mochaContentBorder {
border-top: 1px solid #dadada;
border-bottom: 1px solid #dadada;
}
.mochaContentWrapper { /* Has a fixed height and scrollbars if required. */
font-size: 12px;
overflow: auto;
background: #fff;
}
.mochaContent {
padding: 10px 12px;
}
.mocha .handle {
position: absolute;
background: #0f0;
width: 3px;
height: 3px;
z-index: 2;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/
opacity: .0;
-moz-opacity: .0;
overflow: hidden;
font-size: 1px; /* For IE6 */
}
.mocha .corner { /* Corner resize handles */
width: 10px;
height: 10px;
background: #f00;
}
.mocha .cornerSE { /* Bottom right resize handle */
width: 20px;
height: 20px;
background: #fefefe; /* This is the color of the visible resize handle */
}
.mochaCanvasHeader {
position: absolute;
top: 0;
left: 0;
background: transparent;
z-index: -1;
visibility: hidden;
overflow: hidden;
}
.mochaControls {
position: absolute;
width: 52px;
top: 8px;
right: 8px;
height: 14px;
z-index: 4;
background: transparent;
}
.mochaCanvasControls {
position: absolute;
top: 8px;
right: 8px;
z-index: 3;
background: transparent;
}
/*
To use images for these buttons:
1. Set the useCanvasControls window option to false.
2. If you use a different button size you may need to reposition the controls.
Modify the controlsOffset window option.
2. Replcac the background-color with a background-image for each button.
*/
.mochaMinimizeButton, .mochaMaximizeButton, .mochaCloseButton {
float: right;
width: 14px;
height: 14px;
font-size: 1px;
cursor: pointer;
z-index: 4;
color: #666;
background-color: #fff;
margin-left: 5px;
}
.mochaMinimizeButton {
margin-left: 0;
}
.mochaMaximizeButton {
}
.mochaCloseButton {
}
.mochaSpinner{
display: none;
position: absolute;
bottom: 7px;
left: 6px;
width: 16px;
height: 16px;
background: url(../images/skin/spinner.gif) no-repeat;
}
.mochaIframe {
width: 100%;
}
/* Fix for IE6 select z-index issue */
.zIndexFix {
display: block;
position: absolute;
top: 0;
left: 0;
z-index: -1;
filter: mask();
width: 100px;
height: 100px;
border: 1px solid transparent;
}
/* Viewport overlays
---------------------------------------------------------------- */
#modalOverlay {
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #000;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/
opacity: 0;
-moz-opacity: 0;
z-index: 10000;
}
/* Fix for IE6 select z-index issue */
#modalFix {
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/
opacity: 0;
-moz-opacity: 0;
z-index: 9999;
}
/* Underlay */
#windowUnderlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
background: #fff;
}
* html #windowUnderlay {
position: absolute;
}
/* The replaced class is used internally when converting CSS values to Canvas. These classes should not be removed. */
.mocha.replaced, .mochaTitlebar.replaced, .mochaMinimizeButton.replaced, .mochaMaximizeButton.replaced, .mochaCloseButton.replaced {
background-color: transparent !important;
}
.windowClosed {
visibility: hidden;
display: none;
position: absolute;
top: -20000px;
left: -20000px;
z-index: -1;
overflow: hidden;
}
.windowClosed .mochaContentBorder, .windowClosed .mochaToolbarWrapper, .windowClosed .mochaTitlebar, .windowClosed .mochaControls,
.windowClosed .mochaCanvasControls {
position: absolute;
top: 0;
left: 0;
visibility: hidden;
display: none;
z-index: -1;
}
/* Modals */
.modal2 {
border: 8px solid #fff;
}
.modal2 .mochaContentBorder {
border-width: 0px;
}
/* Window Themes */
.mocha.no-canvas {
background: #e5e5e5;
border: 1px solid #555;
}
.mocha.no-canvas .mochaTitlebar {
background: #e5e5e5;
}
.mocha.transparent .mochaTitlebar h3 {
color: #fff;
display: none;
}
.mocha.transparent .mochaContentWrapper {
background: transparent;
}
.mocha.notification {
background: #cedff2;
}
.mocha.notification .mochaTitlebar {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; /* IE8 */
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=0); /* IE6 and 7*/
opacity: .0;
-moz-opacity: 0;
}
.mocha.notification .mochaContentBorder {
border-width: 0px;
}
.mocha.notification .mochaContentWrapper {
text-align: center;
font-size: 12px;
font-weight: bold;
background: transparent;
}
/* Example Window Themes */
#about_contentWrapper {
background: #e5e5e5 url(../images/skin/logo2.gif) 3px 3px no-repeat;
}
#builder_contentWrapper {
background: #f5f5f7;
}
#json01 .mochaTitlebar {
background: #6dd2db;
}
#json02 .mochaTitlebar {
background: #6db6db;
}
#json03 .mochaTitlebar {
background: #6d92db;
}
.jsonExample .mochaTitlebar h3 {
color: #ddd;
}
/* This does not work in IE6. */
.isFocused.jsonExample .mochaTitlebar h3 {
color: #fff;
}
#fxmorpherExample .mochaContentWrapper {
background: #577a9e;
}
#clock {
background: #fff;
}
/* Workaround to make invisible buttons clickable */
.mochaMinimizeButton.replaced,
.mochaMaximizeButton.replaced,
.mochaCloseButton.replaced {
background-image: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7) !important;
}

View file

@ -1,212 +1,212 @@
/*
Script: Parametrics.js
Initializes the GUI property sliders.
Copyright:
Copyright (c) 2007-2008 Greg Houston, <http://greghoustondesign.com/>.
License:
MIT-style license.
Requires:
Core.js, Window.js
*/
MochaUI.extend({
addUpLimitSlider: function(hash) {
if ($('uplimitSliderarea')) {
var windowOptions = MochaUI.Windows.windowOptions;
var sliderFirst = true;
// Get global upload limit
var maximum = 500;
var req = new Request({
url: 'command/getGlobalUpLimit',
method: 'post',
data: {},
onSuccess: function(data) {
if (data) {
var tmp = data.toInt();
if (tmp > 0) {
maximum = tmp / 1024.
}
else {
if (hash == "global")
maximum = 10000;
else
maximum = 1000;
}
}
// Get torrent upload limit
// And create slider
if (hash == 'global') {
var up_limit = maximum;
if (up_limit < 0) up_limit = 0;
maximum = 10000;
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: up_limit.round(),
onChange: function(pos) {
if (pos > 0) {
$('uplimitUpdatevalue').value = pos;
$('upLimitUnit').style.visibility = "visible";
}
else {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (up_limit == 0) {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
else {
$('uplimitUpdatevalue').value = up_limit.round();
$('upLimitUnit').style.visibility = "visible";
}
}
else {
var req = new Request({
url: 'command/getTorrentUpLimit',
method: 'post',
data: {
hash: hash
},
onSuccess: function(data) {
if (data) {
var up_limit = data.toInt();
if (up_limit < 0) up_limit = 0;
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: (up_limit / 1024.).round(),
onChange: function(pos) {
if (pos > 0) {
$('uplimitUpdatevalue').value = pos;
$('upLimitUnit').style.visibility = "visible";
}
else {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (up_limit == 0) {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
else {
$('uplimitUpdatevalue').value = (up_limit / 1024.).round();
$('upLimitUnit').style.visibility = "visible";
}
}
}
}).send();
}
}
}).send();
}
},
addDlLimitSlider: function(hash) {
if ($('dllimitSliderarea')) {
var windowOptions = MochaUI.Windows.windowOptions;
var sliderFirst = true;
// Get global upload limit
var maximum = 500;
var req = new Request({
url: 'command/getGlobalDlLimit',
method: 'post',
data: {},
onSuccess: function(data) {
if (data) {
var tmp = data.toInt();
if (tmp > 0) {
maximum = tmp / 1024.
}
else {
if (hash == "global")
maximum = 10000;
else
maximum = 1000;
}
}
// Get torrent download limit
// And create slider
if (hash == "global") {
var dl_limit = maximum;
if (dl_limit < 0) dl_limit = 0;
maximum = 10000;
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: dl_limit.round(),
onChange: function(pos) {
if (pos > 0) {
$('dllimitUpdatevalue').value = pos;
$('dlLimitUnit').style.visibility = "visible";
}
else {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (dl_limit == 0) {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
else {
$('dllimitUpdatevalue').value = dl_limit.round();
$('dlLimitUnit').style.visibility = "visible";
}
}
else {
var req = new Request({
url: 'command/getTorrentDlLimit',
method: 'post',
data: {
hash: hash
},
onSuccess: function(data) {
if (data) {
var dl_limit = data.toInt();
if (dl_limit < 0) dl_limit = 0;
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: (dl_limit / 1024.).round(),
onChange: function(pos) {
if (pos > 0) {
$('dllimitUpdatevalue').value = pos;
$('dlLimitUnit').style.visibility = "visible";
}
else {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (dl_limit == 0) {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
else {
$('dllimitUpdatevalue').value = (dl_limit / 1024.).round();
$('dlLimitUnit').style.visibility = "visible";
}
}
}
}).send();
}
}
}).send();
}
}
/*
Script: Parametrics.js
Initializes the GUI property sliders.
Copyright:
Copyright (c) 2007-2008 Greg Houston, <http://greghoustondesign.com/>.
License:
MIT-style license.
Requires:
Core.js, Window.js
*/
MochaUI.extend({
addUpLimitSlider: function(hash) {
if ($('uplimitSliderarea')) {
var windowOptions = MochaUI.Windows.windowOptions;
var sliderFirst = true;
// Get global upload limit
var maximum = 500;
var req = new Request({
url: 'command/getGlobalUpLimit',
method: 'post',
data: {},
onSuccess: function(data) {
if (data) {
var tmp = data.toInt();
if (tmp > 0) {
maximum = tmp / 1024.
}
else {
if (hash == "global")
maximum = 10000;
else
maximum = 1000;
}
}
// Get torrent upload limit
// And create slider
if (hash == 'global') {
var up_limit = maximum;
if (up_limit < 0) up_limit = 0;
maximum = 10000;
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: up_limit.round(),
onChange: function(pos) {
if (pos > 0) {
$('uplimitUpdatevalue').value = pos;
$('upLimitUnit').style.visibility = "visible";
}
else {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (up_limit == 0) {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
else {
$('uplimitUpdatevalue').value = up_limit.round();
$('upLimitUnit').style.visibility = "visible";
}
}
else {
var req = new Request({
url: 'command/getTorrentUpLimit',
method: 'post',
data: {
hash: hash
},
onSuccess: function(data) {
if (data) {
var up_limit = data.toInt();
if (up_limit < 0) up_limit = 0;
var mochaSlide = new Slider($('uplimitSliderarea'), $('uplimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: (up_limit / 1024.).round(),
onChange: function(pos) {
if (pos > 0) {
$('uplimitUpdatevalue').value = pos;
$('upLimitUnit').style.visibility = "visible";
}
else {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (up_limit == 0) {
$('uplimitUpdatevalue').value = '∞';
$('upLimitUnit').style.visibility = "hidden";
}
else {
$('uplimitUpdatevalue').value = (up_limit / 1024.).round();
$('upLimitUnit').style.visibility = "visible";
}
}
}
}).send();
}
}
}).send();
}
},
addDlLimitSlider: function(hash) {
if ($('dllimitSliderarea')) {
var windowOptions = MochaUI.Windows.windowOptions;
var sliderFirst = true;
// Get global upload limit
var maximum = 500;
var req = new Request({
url: 'command/getGlobalDlLimit',
method: 'post',
data: {},
onSuccess: function(data) {
if (data) {
var tmp = data.toInt();
if (tmp > 0) {
maximum = tmp / 1024.
}
else {
if (hash == "global")
maximum = 10000;
else
maximum = 1000;
}
}
// Get torrent download limit
// And create slider
if (hash == "global") {
var dl_limit = maximum;
if (dl_limit < 0) dl_limit = 0;
maximum = 10000;
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: dl_limit.round(),
onChange: function(pos) {
if (pos > 0) {
$('dllimitUpdatevalue').value = pos;
$('dlLimitUnit').style.visibility = "visible";
}
else {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (dl_limit == 0) {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
else {
$('dllimitUpdatevalue').value = dl_limit.round();
$('dlLimitUnit').style.visibility = "visible";
}
}
else {
var req = new Request({
url: 'command/getTorrentDlLimit',
method: 'post',
data: {
hash: hash
},
onSuccess: function(data) {
if (data) {
var dl_limit = data.toInt();
if (dl_limit < 0) dl_limit = 0;
var mochaSlide = new Slider($('dllimitSliderarea'), $('dllimitSliderknob'), {
steps: maximum,
offset: 0,
initialStep: (dl_limit / 1024.).round(),
onChange: function(pos) {
if (pos > 0) {
$('dllimitUpdatevalue').value = pos;
$('dlLimitUnit').style.visibility = "visible";
}
else {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
}.bind(this)
});
// Set default value
if (dl_limit == 0) {
$('dllimitUpdatevalue').value = '∞';
$('dlLimitUnit').style.visibility = "hidden";
}
else {
$('dllimitUpdatevalue').value = (dl_limit / 1024.).round();
$('dlLimitUnit').style.visibility = "visible";
}
}
}
}).send();
}
}
}).send();
}
}
});

View file

@ -1,61 +1,61 @@
# Adapt these paths on Windows
#Point this to the boost include folder
INCLUDEPATH += $$quote(C:/qBittorrent/boost_1_51_0)
#Point this to the libtorrent include folder
INCLUDEPATH += $$quote(C:/qBittorrent/RC_0_16/include)
#Point this to the zlib include folder
INCLUDEPATH += $$quote(C:/qBittorrent/Zlib/include)
#Point this to the boost lib folder
LIBS += $$quote(-LC:/qBittorrent/boost_1_51_0/stage/lib)
#Point this to the libtorrent lib folder
LIBS += $$quote(-LC:/qBittorrent/RC_0_16/bin/<path-according-to-the-build-options-chosen>)
#Point this to the zlib lib folder
LIBS += $$quote(-LC:/qBittorrent/Zlib/lib)
# LIBTORRENT DEFINES
DEFINES += BOOST_ALL_NO_LIB
DEFINES += BOOST_ASIO_HASH_MAP_BUCKETS=1021
DEFINES += BOOST_ASIO_SEPARATE_COMPILATION
DEFINES += BOOST_EXCEPTION_DISABLE
DEFINES += BOOST_SYSTEM_STATIC_LINK=1
DEFINES += TORRENT_USE_OPENSSL
DEFINES += UNICODE
DEFINES += _UNICODE
DEFINES += WIN32
DEFINES += _WIN32
DEFINES += WIN32_LEAN_AND_MEAN
DEFINES += _WIN32_WINNT=0x0500
DEFINES += _WIN32_IE=0x0500
DEFINES += _CRT_SECURE_NO_DEPRECATE
DEFINES += _SCL_SECURE_NO_DEPRECATE
DEFINES += __USE_W32_SOCKETS
DEFINES += _FILE_OFFSET_BITS=64
DEFINES += WITH_SHIPPED_GEOIP_H
CONFIG(debug, debug|release) {
DEFINES += TORRENT_DEBUG
} else {
DEFINES += NDEBUG
}
#Enable backtrace support
CONFIG += strace_win
strace_win:{
DEFINES += STACKTRACE_WIN
FORMS += stacktrace_win_dlg.ui
HEADERS += stacktrace_win.h \
stacktrace_win_dlg.h
}
win32-g++ {
include(winconf-mingw.pri)
}
else {
include(winconf-msvc.pri)
}
DEFINES += WITH_GEOIP_EMBEDDED
message("On Windows, GeoIP database must be embedded.")
# Adapt these paths on Windows
#Point this to the boost include folder
INCLUDEPATH += $$quote(C:/qBittorrent/boost_1_51_0)
#Point this to the libtorrent include folder
INCLUDEPATH += $$quote(C:/qBittorrent/RC_0_16/include)
#Point this to the zlib include folder
INCLUDEPATH += $$quote(C:/qBittorrent/Zlib/include)
#Point this to the boost lib folder
LIBS += $$quote(-LC:/qBittorrent/boost_1_51_0/stage/lib)
#Point this to the libtorrent lib folder
LIBS += $$quote(-LC:/qBittorrent/RC_0_16/bin/<path-according-to-the-build-options-chosen>)
#Point this to the zlib lib folder
LIBS += $$quote(-LC:/qBittorrent/Zlib/lib)
# LIBTORRENT DEFINES
DEFINES += BOOST_ALL_NO_LIB
DEFINES += BOOST_ASIO_HASH_MAP_BUCKETS=1021
DEFINES += BOOST_ASIO_SEPARATE_COMPILATION
DEFINES += BOOST_EXCEPTION_DISABLE
DEFINES += BOOST_SYSTEM_STATIC_LINK=1
DEFINES += TORRENT_USE_OPENSSL
DEFINES += UNICODE
DEFINES += _UNICODE
DEFINES += WIN32
DEFINES += _WIN32
DEFINES += WIN32_LEAN_AND_MEAN
DEFINES += _WIN32_WINNT=0x0500
DEFINES += _WIN32_IE=0x0500
DEFINES += _CRT_SECURE_NO_DEPRECATE
DEFINES += _SCL_SECURE_NO_DEPRECATE
DEFINES += __USE_W32_SOCKETS
DEFINES += _FILE_OFFSET_BITS=64
DEFINES += WITH_SHIPPED_GEOIP_H
CONFIG(debug, debug|release) {
DEFINES += TORRENT_DEBUG
} else {
DEFINES += NDEBUG
}
#Enable backtrace support
CONFIG += strace_win
strace_win:{
DEFINES += STACKTRACE_WIN
FORMS += stacktrace_win_dlg.ui
HEADERS += stacktrace_win.h \
stacktrace_win_dlg.h
}
win32-g++ {
include(winconf-mingw.pri)
}
else {
include(winconf-msvc.pri)
}
DEFINES += WITH_GEOIP_EMBEDDED
message("On Windows, GeoIP database must be embedded.")