You've already forked qBittorrent
mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-11-07 01:22:30 +01:00
Compare commits
1 Commits
release-2.
...
release-2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fa9c319f5b |
2
AUTHORS
2
AUTHORS
@@ -83,7 +83,7 @@ Translations authors:
|
|||||||
- German: Niels Hoffmann (zentralmaschine@users.sourceforge.net)
|
- German: Niels Hoffmann (zentralmaschine@users.sourceforge.net)
|
||||||
- Greek: Tsvetan Bankov (emerge_life@users.sourceforge.net) and Stephanos Antaris (santaris@csd.auth.gr)
|
- Greek: Tsvetan Bankov (emerge_life@users.sourceforge.net) and Stephanos Antaris (santaris@csd.auth.gr)
|
||||||
- Hungarian: Majoros Péter (majoros.j.p@t-online.hu)
|
- Hungarian: Majoros Péter (majoros.j.p@t-online.hu)
|
||||||
- Italian: Matteo Sechi (bu17714@gmail.com)
|
- Italian: Mirko Ferrari (mirkoferrari@gmail.com) and Ferraro Luciano (luciano.ferraro@gmail.com)
|
||||||
- Japanese: Nardog (alphisation@gmail.com)
|
- Japanese: Nardog (alphisation@gmail.com)
|
||||||
- Korean: Jin Woo Sin (jin828sin@users.sourceforge.net)
|
- Korean: Jin Woo Sin (jin828sin@users.sourceforge.net)
|
||||||
- Norwegian: Lars-Erik Labori (hamil@users.sourceforge.net)
|
- Norwegian: Lars-Erik Labori (hamil@users.sourceforge.net)
|
||||||
|
|||||||
16
Changelog
16
Changelog
@@ -1,18 +1,4 @@
|
|||||||
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.5.0
|
* Unreleased - Christophe Dumez <chris@qbittorrent.org> - v2.4.0
|
||||||
- FEATURE: qBittorrent can now act as a tracker
|
|
||||||
- FEATURE: New and improved RSS feed automated downloader
|
|
||||||
- FEATURE: Added feature to shutdown qbittorrent on torrents completion
|
|
||||||
- FEATURE: Added a torrent import assistant to seed or keep downloading outside torrents
|
|
||||||
- FEATURE: qBittorrent can update itself from Sourceforge (Windows/Mac OS X only)
|
|
||||||
- FEATURE: Added a transfer list column to display the current tracker
|
|
||||||
- FEATURE: Remember the last trackers used in the torrent creation tool
|
|
||||||
- FEATURE: The optimal piece size is now automatically computed in the torrent creation tool
|
|
||||||
- FEATURE: Bring up the connection settings when clicking on the connection status icon
|
|
||||||
- COSMETIC: Replaced message box by on-screen notification for download errors
|
|
||||||
- COSMETIC: Improved the torrent creation tool appearance
|
|
||||||
- OTHERS: Dropped support for Qt <= 4.4
|
|
||||||
|
|
||||||
* Tue Aug 24 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.4.0
|
|
||||||
- FEATURE: Added actions to "Move to top/bottom" of priority queue
|
- FEATURE: Added actions to "Move to top/bottom" of priority queue
|
||||||
- FEATURE: Auto-Shutdown on downloads completion
|
- FEATURE: Auto-Shutdown on downloads completion
|
||||||
- FEATURE: Email notification on download completion
|
- FEATURE: Email notification on download completion
|
||||||
|
|||||||
2
INSTALL
2
INSTALL
@@ -10,7 +10,7 @@ qBittorrent - A BitTorrent client in C++ / Qt4
|
|||||||
will install and execute qBittorrent hopefully without any problems.
|
will install and execute qBittorrent hopefully without any problems.
|
||||||
|
|
||||||
Dependencies:
|
Dependencies:
|
||||||
- Qt >= 4.5.0 (libqt-devel, libqtgui, libqtcore, libqtnetwork, libqtxml)
|
- Qt >= 4.4.0 (libqt-devel, libqtgui, libqtcore, libqtnetwork, libqtxml)
|
||||||
|
|
||||||
- pkg-config executable
|
- pkg-config executable
|
||||||
|
|
||||||
|
|||||||
26
configure
vendored
26
configure
vendored
@@ -325,7 +325,7 @@ cat >$1/modules.cpp <<EOT
|
|||||||
#line 1 "qt4.qcm"
|
#line 1 "qt4.qcm"
|
||||||
/*
|
/*
|
||||||
-----BEGIN QCMOD-----
|
-----BEGIN QCMOD-----
|
||||||
name: Qt >= 4.5
|
name: Qt >= 4.4
|
||||||
arg: disable-gui, Disable qBittorrent Graphical user interface for headless running
|
arg: disable-gui, Disable qBittorrent Graphical user interface for headless running
|
||||||
-----END QCMOD-----
|
-----END QCMOD-----
|
||||||
*/
|
*/
|
||||||
@@ -333,14 +333,14 @@ class qc_qt4 : public ConfObj
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
qc_qt4(Conf *c) : ConfObj(c) {}
|
qc_qt4(Conf *c) : ConfObj(c) {}
|
||||||
QString name() const { return "Qt >= 4.5"; }
|
QString name() const { return "Qt >= 4.4"; }
|
||||||
QString shortname() const { return "Qt 4.5"; }
|
QString shortname() const { return "Qt 4.4"; }
|
||||||
bool exec()
|
bool exec()
|
||||||
{
|
{
|
||||||
if(!conf->getenv("QC_DISABLE_GUI").isEmpty()) {
|
if(!conf->getenv("QC_DISABLE_GUI").isEmpty()) {
|
||||||
conf->addDefine("DISABLE_GUI");
|
conf->addDefine("DISABLE_GUI");
|
||||||
}
|
}
|
||||||
return(QT_VERSION >= 0x040500);
|
return(QT_VERSION >= 0x040400);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#line 1 "pkg-config.qcm"
|
#line 1 "pkg-config.qcm"
|
||||||
@@ -616,22 +616,22 @@ arg: with-qtsingleapplication=[system|shipped], Use the shipped qtsingleapplicat
|
|||||||
class qc_qtsingleapplication : public ConfObj
|
class qc_qtsingleapplication : public ConfObj
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
qc_qtsingleapplication(Conf *c) : ConfObj(c) {}
|
qc_qtsingleapplication(Conf *c) : ConfObj(c) {}
|
||||||
QString name() const { return "qtsingleapplication library"; }
|
QString name() const { return "qtsingleapplication library"; }
|
||||||
QString shortname() const { return "qtsingleapplication"; }
|
QString shortname() const { return "qtsingleapplication"; }
|
||||||
|
|
||||||
bool exec(){
|
bool exec(){
|
||||||
QString s;
|
QString s;
|
||||||
s = conf->getenv("QC_WITH_QTSINGLEAPPLICATION");
|
s = conf->getenv("QC_WITH_QTSINGLEAPPLICATION");
|
||||||
if(s.compare("system", Qt::CaseInsensitive) == 0) {
|
if(s.compare("system", Qt::CaseInsensitive) == 0) {
|
||||||
// System
|
// System
|
||||||
conf->addDefine("USE_SYSTEM_QTSINGLEAPPLICATION");
|
conf->addDefine("USE_SYSTEM_QTSINGLEAPPLICATION");
|
||||||
printf(" [system] ");
|
printf(" [system] ");
|
||||||
} else {
|
} else {
|
||||||
printf(" [shipped] ");
|
printf(" [shipped] ");
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
EOT
|
EOT
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
-----BEGIN QCMOD-----
|
-----BEGIN QCMOD-----
|
||||||
name: Qt >= 4.5
|
name: Qt >= 4.4
|
||||||
arg: disable-gui, Disable qBittorrent Graphical user interface for headless running
|
arg: disable-gui, Disable qBittorrent Graphical user interface for headless running
|
||||||
-----END QCMOD-----
|
-----END QCMOD-----
|
||||||
*/
|
*/
|
||||||
@@ -8,13 +8,13 @@ class qc_qt4 : public ConfObj
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
qc_qt4(Conf *c) : ConfObj(c) {}
|
qc_qt4(Conf *c) : ConfObj(c) {}
|
||||||
QString name() const { return "Qt >= 4.5"; }
|
QString name() const { return "Qt >= 4.4"; }
|
||||||
QString shortname() const { return "Qt 4.5"; }
|
QString shortname() const { return "Qt 4.4"; }
|
||||||
bool exec()
|
bool exec()
|
||||||
{
|
{
|
||||||
if(!conf->getenv("QC_DISABLE_GUI").isEmpty()) {
|
if(!conf->getenv("QC_DISABLE_GUI").isEmpty()) {
|
||||||
conf->addDefine("DISABLE_GUI");
|
conf->addDefine("DISABLE_GUI");
|
||||||
}
|
}
|
||||||
return(QT_VERSION >= 0x040500);
|
return(QT_VERSION >= 0x040400);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
/*
|
|
||||||
-----BEGIN QCMOD-----
|
|
||||||
name: libboost
|
|
||||||
arg: with-qtsingleapplication=[system|shipped], Use the shipped qtsingleapplication library or the system one
|
|
||||||
-----END QCMOD-----
|
|
||||||
*/
|
|
||||||
class qc_qtsingleapplication : public ConfObj
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
qc_qtsingleapplication(Conf *c) : ConfObj(c) {}
|
|
||||||
QString name() const { return "qtsingleapplication library"; }
|
|
||||||
QString shortname() const { return "qtsingleapplication"; }
|
|
||||||
|
|
||||||
bool exec(){
|
|
||||||
QString s;
|
|
||||||
s = conf->getenv("QC_WITH_QTSINGLEAPPLICATION");
|
|
||||||
if(s.compare("system", Qt::CaseInsensitive) == 0) {
|
|
||||||
// System
|
|
||||||
conf->addDefine("USE_SYSTEM_QTSINGLEAPPLICATION");
|
|
||||||
printf(" [system] ");
|
|
||||||
} else {
|
|
||||||
printf(" [shipped] ");
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -37,7 +37,7 @@
|
|||||||
#include "ui_mainwindow.h"
|
#include "ui_mainwindow.h"
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
|
|
||||||
class QBtSession;
|
class Bittorrent;
|
||||||
class QTimer;
|
class QTimer;
|
||||||
class downloadFromURL;
|
class downloadFromURL;
|
||||||
class SearchEngine;
|
class SearchEngine;
|
||||||
@@ -54,19 +54,19 @@ class PropertiesWidget;
|
|||||||
class StatusBar;
|
class StatusBar;
|
||||||
class consoleDlg;
|
class consoleDlg;
|
||||||
class about;
|
class about;
|
||||||
class TorrentCreatorDlg;
|
class createtorrent;
|
||||||
class downloadFromURL;
|
class downloadFromURL;
|
||||||
class HidableTabWidget;
|
class HidableTabWidget;
|
||||||
class LineEdit;
|
class LineEdit;
|
||||||
class QFileSystemWatcher;
|
class QFileSystemWatcher;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow, private Ui::MainWindow{
|
class GUI : public QMainWindow, private Ui::MainWindow{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Construct / Destruct
|
// Construct / Destruct
|
||||||
MainWindow(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
|
GUI(QWidget *parent=0, QStringList torrentCmdLine=QStringList());
|
||||||
~MainWindow();
|
~GUI();
|
||||||
// Methods
|
// Methods
|
||||||
QWidget* getCurrentTabWidget() const;
|
QWidget* getCurrentTabWidget() const;
|
||||||
TransferListWidget* getTransferList() const { return transferList; }
|
TransferListWidget* getTransferList() const { return transferList; }
|
||||||
@@ -80,7 +80,6 @@ public slots:
|
|||||||
void downloadFromURLList(const QStringList& urls);
|
void downloadFromURLList(const QStringList& urls);
|
||||||
void updateAltSpeedsBtn(bool alternative);
|
void updateAltSpeedsBtn(bool alternative);
|
||||||
void updateNbTorrents(unsigned int nb_downloading, unsigned int nb_seeding, unsigned int nb_active, unsigned int nb_inactive, unsigned int nb_paused);
|
void updateNbTorrents(unsigned int nb_downloading, unsigned int nb_seeding, unsigned int nb_active, unsigned int nb_inactive, unsigned int nb_paused);
|
||||||
void deleteBTSession();
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
// GUI related slots
|
// GUI related slots
|
||||||
@@ -105,7 +104,6 @@ protected slots:
|
|||||||
void defineUILockPassword();
|
void defineUILockPassword();
|
||||||
bool unlockUI();
|
bool unlockUI();
|
||||||
void notifyOfUpdate(QString);
|
void notifyOfUpdate(QString);
|
||||||
void showConnectionSettings();
|
|
||||||
// Keyboard shortcuts
|
// Keyboard shortcuts
|
||||||
void createKeyboardShortcuts();
|
void createKeyboardShortcuts();
|
||||||
void displayTransferTab() const;
|
void displayTransferTab() const;
|
||||||
@@ -130,10 +128,6 @@ protected slots:
|
|||||||
void optionsSaved();
|
void optionsSaved();
|
||||||
// HTTP slots
|
// HTTP slots
|
||||||
void on_actionDownload_from_URL_triggered();
|
void on_actionDownload_from_URL_triggered();
|
||||||
#if defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
|
||||||
void handleUpdateCheckFinished(bool update_available, QString new_version);
|
|
||||||
void handleUpdateInstalled(QString error_msg);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void closeEvent(QCloseEvent *);
|
void closeEvent(QCloseEvent *);
|
||||||
@@ -145,7 +139,7 @@ protected:
|
|||||||
private:
|
private:
|
||||||
QFileSystemWatcher *executable_watcher;
|
QFileSystemWatcher *executable_watcher;
|
||||||
// Bittorrent
|
// Bittorrent
|
||||||
QBtSession *BTSession;
|
Bittorrent *BTSession;
|
||||||
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
|
QList<QPair<QTorrentHandle,QString> > unauthenticated_trackers; // Still needed?
|
||||||
// GUI related
|
// GUI related
|
||||||
QTimer *guiUpdater;
|
QTimer *guiUpdater;
|
||||||
@@ -154,7 +148,7 @@ private:
|
|||||||
QPointer<options_imp> options;
|
QPointer<options_imp> options;
|
||||||
QPointer<consoleDlg> console;
|
QPointer<consoleDlg> console;
|
||||||
QPointer<about> aboutDlg;
|
QPointer<about> aboutDlg;
|
||||||
QPointer<TorrentCreatorDlg> createTorrentDlg;
|
QPointer<createtorrent> createTorrentDlg;
|
||||||
QPointer<downloadFromURL> downloadFromURLDialog;
|
QPointer<downloadFromURL> downloadFromURLDialog;
|
||||||
QPointer<QSystemTrayIcon> systrayIcon;
|
QPointer<QSystemTrayIcon> systrayIcon;
|
||||||
QPointer<QTimer> systrayCreator;
|
QPointer<QTimer> systrayCreator;
|
||||||
@@ -176,7 +170,6 @@ private:
|
|||||||
QAction *prioSeparator2;
|
QAction *prioSeparator2;
|
||||||
QSplitter *hSplitter;
|
QSplitter *hSplitter;
|
||||||
QSplitter *vSplitter;
|
QSplitter *vSplitter;
|
||||||
QMenu *lockMenu;
|
|
||||||
// Search
|
// Search
|
||||||
QPointer<SearchEngine> searchEngine;
|
QPointer<SearchEngine> searchEngine;
|
||||||
// RSS
|
// RSS
|
||||||
@@ -188,9 +181,6 @@ private slots:
|
|||||||
void on_actionSpeed_in_title_bar_triggered();
|
void on_actionSpeed_in_title_bar_triggered();
|
||||||
void on_actionTop_tool_bar_triggered();
|
void on_actionTop_tool_bar_triggered();
|
||||||
void on_actionShutdown_when_downloads_complete_triggered();
|
void on_actionShutdown_when_downloads_complete_triggered();
|
||||||
void on_actionShutdown_qBittorrent_when_downloads_complete_triggered();
|
|
||||||
void on_action_Import_Torrent_triggered();
|
|
||||||
void on_actionDonate_money_triggered();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB |
@@ -1,6 +1,6 @@
|
|||||||
[Desktop Entry]
|
[Desktop Entry]
|
||||||
Categories=Qt;Network;P2P;
|
Categories=Qt;Network;P2P;
|
||||||
Comment=V2.5.0
|
Comment=V2.4.0
|
||||||
Exec=qbittorrent %f
|
Exec=qbittorrent %f
|
||||||
GenericName=Bittorrent client
|
GenericName=Bittorrent client
|
||||||
GenericName[ar]=العميل Bittorrent
|
GenericName[ar]=العميل Bittorrent
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 79 KiB |
@@ -47,7 +47,7 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleGetInfoString</key>
|
<key>CFBundleGetInfoString</key>
|
||||||
<string>2.5.0</string>
|
<string>2.4.0</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleExecutable</key>
|
<key>CFBundleExecutable</key>
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
<!DOCTYPE RCC><RCC version="1.0">
|
|
||||||
<qresource>
|
|
||||||
<file>gpl.html</file>
|
|
||||||
</qresource>
|
|
||||||
</RCC>
|
|
||||||
|
|
||||||
438
src/about_imp.h
438
src/about_imp.h
File diff suppressed because it is too large
Load Diff
@@ -11,15 +11,15 @@
|
|||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
|
|
||||||
enum AdvSettingsCols {PROPERTY, VALUE};
|
enum AdvSettingsCols {PROPERTY, VALUE};
|
||||||
enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, PROGRAM_NOTIFICATIONS, TRACKER_STATUS, TRACKER_PORT };
|
enum AdvSettingsRows {DISK_CACHE, OUTGOING_PORT_MIN, OUTGOING_PORT_MAX, IGNORE_LIMIT_LAN, COUNT_OVERHEAD, RECHECK_COMPLETED, LIST_REFRESH, RESOLVE_COUNTRIES, RESOLVE_HOSTS, MAX_HALF_OPEN, SUPER_SEEDING, NETWORK_IFACE, PROGRAM_NOTIFICATIONS };
|
||||||
#define ROW_COUNT 15
|
#define ROW_COUNT 13
|
||||||
|
|
||||||
class AdvancedSettings: public QTableWidget {
|
class AdvancedSettings: public QTableWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max, *spin_list_refresh, *spin_maxhalfopen, *spin_tracker_port;
|
QSpinBox *spin_cache, *outgoing_ports_min, *outgoing_ports_max, *spin_list_refresh, *spin_maxhalfopen;
|
||||||
QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed, *cb_resolve_countries, *cb_resolve_hosts, *cb_super_seeding, *cb_program_notifications, *cb_tracker_status;
|
QCheckBox *cb_ignore_limits_lan, *cb_count_overhead, *cb_recheck_completed, *cb_resolve_countries, *cb_resolve_hosts, *cb_super_seeding, *cb_program_notifications;
|
||||||
QComboBox *combo_iface;
|
QComboBox *combo_iface;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -53,8 +53,6 @@ public:
|
|||||||
delete cb_super_seeding;
|
delete cb_super_seeding;
|
||||||
delete combo_iface;
|
delete combo_iface;
|
||||||
delete cb_program_notifications;
|
delete cb_program_notifications;
|
||||||
delete spin_tracker_port;
|
|
||||||
delete cb_tracker_status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@@ -90,9 +88,6 @@ public slots:
|
|||||||
}
|
}
|
||||||
// Program notification
|
// Program notification
|
||||||
Preferences::useProgramNotification(cb_program_notifications->isChecked());
|
Preferences::useProgramNotification(cb_program_notifications->isChecked());
|
||||||
// Tracker
|
|
||||||
Preferences::setTrackerEnabled(cb_tracker_status->isChecked());
|
|
||||||
Preferences::setTrackerPort(spin_tracker_port->value());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
@@ -195,25 +190,11 @@ protected slots:
|
|||||||
connect(combo_iface, SIGNAL(currentIndexChanged(int)), this, SLOT(emitSettingsChanged()));
|
connect(combo_iface, SIGNAL(currentIndexChanged(int)), this, SLOT(emitSettingsChanged()));
|
||||||
setCellWidget(NETWORK_IFACE, VALUE, combo_iface);
|
setCellWidget(NETWORK_IFACE, VALUE, combo_iface);
|
||||||
// Program notifications
|
// Program notifications
|
||||||
setItem(PROGRAM_NOTIFICATIONS, PROPERTY, new QTableWidgetItem(tr("Display program notification balloons")));
|
setItem(PROGRAM_NOTIFICATIONS, PROPERTY, new QTableWidgetItem(tr("Display program notification baloons")));
|
||||||
cb_program_notifications = new QCheckBox();
|
cb_program_notifications = new QCheckBox();
|
||||||
connect(cb_program_notifications, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
|
connect(cb_program_notifications, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
|
||||||
cb_program_notifications->setChecked(Preferences::useProgramNotification());
|
cb_program_notifications->setChecked(Preferences::useProgramNotification());
|
||||||
setCellWidget(PROGRAM_NOTIFICATIONS, VALUE, cb_program_notifications);
|
setCellWidget(PROGRAM_NOTIFICATIONS, VALUE, cb_program_notifications);
|
||||||
// Tracker State
|
|
||||||
setItem(TRACKER_STATUS, PROPERTY, new QTableWidgetItem(tr("Enable embedded tracker")));
|
|
||||||
cb_tracker_status = new QCheckBox();
|
|
||||||
connect(cb_tracker_status, SIGNAL(toggled(bool)), this, SLOT(emitSettingsChanged()));
|
|
||||||
cb_tracker_status->setChecked(Preferences::isTrackerEnabled());
|
|
||||||
setCellWidget(TRACKER_STATUS, VALUE, cb_tracker_status);
|
|
||||||
// Tracker port
|
|
||||||
setItem(TRACKER_PORT, PROPERTY, new QTableWidgetItem(tr("Embedded tracker port")));
|
|
||||||
spin_tracker_port = new QSpinBox();
|
|
||||||
connect(spin_tracker_port, SIGNAL(valueChanged(int)), this, SLOT(emitSettingsChanged()));
|
|
||||||
spin_tracker_port->setMinimum(1);
|
|
||||||
spin_tracker_port->setMaximum(65535);
|
|
||||||
spin_tracker_port->setValue(Preferences::getTrackerPort());
|
|
||||||
setCellWidget(TRACKER_PORT, VALUE, spin_tracker_port);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void emitSettingsChanged() {
|
void emitSettingsChanged() {
|
||||||
|
|||||||
2656
src/bittorrent.cpp
Normal file
2656
src/bittorrent.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -46,10 +46,7 @@
|
|||||||
#include <libtorrent/version.hpp>
|
#include <libtorrent/version.hpp>
|
||||||
#include <libtorrent/session.hpp>
|
#include <libtorrent/session.hpp>
|
||||||
#include <libtorrent/ip_filter.hpp>
|
#include <libtorrent/ip_filter.hpp>
|
||||||
|
|
||||||
#include "qtracker.h"
|
|
||||||
#include "qtorrenthandle.h"
|
#include "qtorrenthandle.h"
|
||||||
#include "trackerinfos.h"
|
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
@@ -62,43 +59,70 @@ class HttpServer;
|
|||||||
class BandwidthScheduler;
|
class BandwidthScheduler;
|
||||||
class ScanFoldersModel;
|
class ScanFoldersModel;
|
||||||
|
|
||||||
class QBtSession : public QObject {
|
class TrackerInfos {
|
||||||
Q_OBJECT
|
public:
|
||||||
Q_DISABLE_COPY(QBtSession)
|
QString name_or_url;
|
||||||
|
QString last_message;
|
||||||
|
unsigned long num_peers;
|
||||||
|
#if LIBTORRENT_VERSION_MINOR < 15
|
||||||
|
bool verified;
|
||||||
|
uint fail_count;
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
//TrackerInfos() {}
|
||||||
explicit QBtSession();
|
TrackerInfos(const TrackerInfos &b) {
|
||||||
static QBtSession* m_instance;
|
name_or_url = b.name_or_url;
|
||||||
|
Q_ASSERT(!name_or_url.isEmpty());
|
||||||
|
last_message = b.last_message;
|
||||||
|
num_peers = b.num_peers;
|
||||||
|
#if LIBTORRENT_VERSION_MINOR < 15
|
||||||
|
verified = b.verified;
|
||||||
|
fail_count = b.fail_count;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
TrackerInfos(QString name_or_url): name_or_url(name_or_url), last_message(""), num_peers(0) {
|
||||||
|
#if LIBTORRENT_VERSION_MINOR < 15
|
||||||
|
fail_count = 0;
|
||||||
|
verified = false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Bittorrent : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QBtSession* instance();
|
// Constructor / Destructor
|
||||||
static void drop();
|
Bittorrent();
|
||||||
~QBtSession();
|
~Bittorrent();
|
||||||
QTorrentHandle getTorrentHandle(QString hash) const;
|
QTorrentHandle getTorrentHandle(QString hash) const;
|
||||||
std::vector<torrent_handle> getTorrents() const;
|
std::vector<torrent_handle> getTorrents() const;
|
||||||
bool isFilePreviewPossible(QString fileHash) const;
|
bool isFilePreviewPossible(QString fileHash) const;
|
||||||
|
bool isDHTEnabled() const;
|
||||||
|
bool isLSDEnabled() const;
|
||||||
float getPayloadDownloadRate() const;
|
float getPayloadDownloadRate() const;
|
||||||
float getPayloadUploadRate() const;
|
float getPayloadUploadRate() const;
|
||||||
session_status getSessionStatus() const;
|
session_status getSessionStatus() const;
|
||||||
int getListenPort() const;
|
int getListenPort() const;
|
||||||
float getRealRatio(QString hash) const;
|
float getRealRatio(QString hash) const;
|
||||||
|
session* getSession() const;
|
||||||
QHash<QString, TrackerInfos> getTrackersInfo(QString hash) const;
|
QHash<QString, TrackerInfos> getTrackersInfo(QString hash) const;
|
||||||
bool hasActiveTorrents() const;
|
bool hasActiveTorrents() const;
|
||||||
bool hasDownloadingTorrents() const;
|
bool hasDownloadingTorrents() const;
|
||||||
//int getMaximumActiveDownloads() const;
|
bool isQueueingEnabled() const;
|
||||||
//int getMaximumActiveTorrents() const;
|
int getMaximumActiveDownloads() const;
|
||||||
|
int getMaximumActiveTorrents() const;
|
||||||
int loadTorrentPriority(QString hash);
|
int loadTorrentPriority(QString hash);
|
||||||
|
QStringList getConsoleMessages() const;
|
||||||
|
QStringList getPeerBanMessages() const;
|
||||||
qlonglong getETA(QString hash);
|
qlonglong getETA(QString hash);
|
||||||
inline QStringList getConsoleMessages() const { return consoleMessages; }
|
bool useTemporaryFolder() const;
|
||||||
inline QStringList getPeerBanMessages() const { return peerBanMessages; }
|
QString getDefaultSavePath() const;
|
||||||
inline session* getSession() const { return s; }
|
ScanFoldersModel* getScanFoldersModel() const;
|
||||||
inline bool useTemporaryFolder() const { return !defaultTempPath.isEmpty(); }
|
bool isPexEnabled() const;
|
||||||
inline QString getDefaultSavePath() const { return defaultSavePath; }
|
#if LIBTORRENT_VERSION_MINOR < 15
|
||||||
inline ScanFoldersModel* getScanFoldersModel() const { return m_scanFolders; }
|
void saveDHTEntry();
|
||||||
inline bool isDHTEnabled() const { return DHTEnabled; }
|
#endif
|
||||||
inline bool isLSDEnabled() const { return LSDEnabled; }
|
|
||||||
inline bool isPexEnabled() const { return DHTEnabled; }
|
|
||||||
inline bool isQueueingEnabled() const { return queueingEnabled; }
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
QTorrentHandle addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
|
QTorrentHandle addTorrent(QString path, bool fromScanDir = false, QString from_url = QString(), bool resumed = false);
|
||||||
@@ -123,7 +147,7 @@ public slots:
|
|||||||
void disableIPFilter();
|
void disableIPFilter();
|
||||||
void setQueueingEnabled(bool enable);
|
void setQueueingEnabled(bool enable);
|
||||||
void handleDownloadFailure(QString url, QString reason);
|
void handleDownloadFailure(QString url, QString reason);
|
||||||
void downloadUrlAndSkipDialog(QString url, QString save_path, QString label);
|
void downloadUrlAndSkipDialog(QString url, QString save_path=QString::null);
|
||||||
// Session configuration - Setters
|
// Session configuration - Setters
|
||||||
void setListeningPort(int port);
|
void setListeningPort(int port);
|
||||||
void setMaxConnections(int maxConnec);
|
void setMaxConnections(int maxConnec);
|
||||||
@@ -168,10 +192,6 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
QString getSavePath(QString hash, bool fromScanDir = false, QString filePath = QString::null, QString root_folder=QString::null);
|
QString getSavePath(QString hash, bool fromScanDir = false, QString filePath = QString::null, QString root_folder=QString::null);
|
||||||
bool initWebUi(QString username, QString password, int port);
|
bool initWebUi(QString username, QString password, int port);
|
||||||
bool loadFastResumeData(QString hash, std::vector<char> &buf);
|
|
||||||
void loadTorrentSettings(QTorrentHandle h);
|
|
||||||
void loadTorrentTempData(QTorrentHandle h, QString savePath, bool magnet);
|
|
||||||
add_torrent_params initializeAddTorrentParams(QString hash);
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void addTorrentsFromScanFolder(QStringList&);
|
void addTorrentsFromScanFolder(QStringList&);
|
||||||
@@ -183,11 +203,6 @@ protected slots:
|
|||||||
void sendNotificationEmail(QTorrentHandle h);
|
void sendNotificationEmail(QTorrentHandle h);
|
||||||
void autoRunExternalProgram(QTorrentHandle h, bool async=true);
|
void autoRunExternalProgram(QTorrentHandle h, bool async=true);
|
||||||
void cleanUpAutoRunProcess(int);
|
void cleanUpAutoRunProcess(int);
|
||||||
void mergeTorrents(QTorrentHandle h_ex, boost::intrusive_ptr<torrent_info> t);
|
|
||||||
void exportTorrentFile(QTorrentHandle h);
|
|
||||||
#if LIBTORRENT_VERSION_MINOR < 15
|
|
||||||
void saveDHTEntry();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void addedTorrent(QTorrentHandle& h);
|
void addedTorrent(QTorrentHandle& h);
|
||||||
@@ -213,7 +228,7 @@ private:
|
|||||||
session *s;
|
session *s;
|
||||||
QPointer<QTimer> timerAlerts;
|
QPointer<QTimer> timerAlerts;
|
||||||
QPointer<BandwidthScheduler> bd_scheduler;
|
QPointer<BandwidthScheduler> bd_scheduler;
|
||||||
QMap<QUrl, QPair<QString, QString> > savepathLabel_fromurl;
|
QMap<QUrl, QString> savepath_fromurl;
|
||||||
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
QHash<QString, QHash<QString, TrackerInfos> > trackersInfos;
|
||||||
QHash<QString, QString> savePathsToRemove;
|
QHash<QString, QString> savePathsToRemove;
|
||||||
QStringList torrentsToPausedAfterChecking;
|
QStringList torrentsToPausedAfterChecking;
|
||||||
@@ -262,8 +277,6 @@ private:
|
|||||||
bool geoipDBLoaded;
|
bool geoipDBLoaded;
|
||||||
bool resolve_countries;
|
bool resolve_countries;
|
||||||
#endif
|
#endif
|
||||||
// Tracker
|
|
||||||
QPointer<QTracker> m_tracker;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
#ifndef CONSOLE_H
|
#ifndef CONSOLE_H
|
||||||
#define CONSOLE_H
|
#define CONSOLE_H
|
||||||
|
|
||||||
#include "qbtsession.h"
|
#include "bittorrent.h"
|
||||||
#include "ui_console.h"
|
#include "ui_console.h"
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
@@ -39,13 +39,17 @@ using namespace libtorrent;
|
|||||||
class consoleDlg : public QDialog, private Ui_ConsoleDlg{
|
class consoleDlg : public QDialog, private Ui_ConsoleDlg{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
Bittorrent *BTSession;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
consoleDlg(QWidget *parent) : QDialog(parent) {
|
consoleDlg(QWidget *parent, Bittorrent* _BTSession) : QDialog(parent) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
setAttribute(Qt::WA_DeleteOnClose);
|
setAttribute(Qt::WA_DeleteOnClose);
|
||||||
setModal(true);
|
setModal(true);
|
||||||
textConsole->setHtml(QBtSession::instance()->getConsoleMessages().join("<br>"));
|
BTSession = _BTSession;
|
||||||
textBannedPeers->setHtml(QBtSession::instance()->getPeerBanMessages().join("<br>"));
|
textConsole->setHtml(BTSession->getConsoleMessages().join("<br>"));
|
||||||
|
textBannedPeers->setHtml(BTSession->getPeerBanMessages().join("<br>"));
|
||||||
show();
|
show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
321
src/createtorrent_imp.cpp
Normal file
321
src/createtorrent_imp.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Bittorrent Client using Qt4 and libtorrent.
|
* Bittorrent Client using Qt4 and libtorrent.
|
||||||
* Copyright (C) 2010 Christophe Dumez
|
* Copyright (C) 2006 Christophe Dumez
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@@ -31,16 +31,56 @@
|
|||||||
#ifndef CREATE_TORRENT_IMP_H
|
#ifndef CREATE_TORRENT_IMP_H
|
||||||
#define CREATE_TORRENT_IMP_H
|
#define CREATE_TORRENT_IMP_H
|
||||||
|
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
#include "ui_createtorrent.h"
|
#include "ui_createtorrent.h"
|
||||||
|
|
||||||
class TorrentCreatorThread;
|
class torrentCreatorThread : public QThread {
|
||||||
|
|
||||||
class TorrentCreatorDlg : public QDialog, private Ui::createTorrentDialog{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
QString input_path;
|
||||||
|
QString save_path;
|
||||||
|
QStringList trackers;
|
||||||
|
QStringList url_seeds;
|
||||||
|
QString comment;
|
||||||
|
bool is_private;
|
||||||
|
int piece_size;
|
||||||
|
bool abort;
|
||||||
|
QDialog *parent;
|
||||||
|
|
||||||
|
public:
|
||||||
|
torrentCreatorThread(QDialog *_parent) {
|
||||||
|
parent = _parent;
|
||||||
|
}
|
||||||
|
~torrentCreatorThread() {
|
||||||
|
abort = true;
|
||||||
|
wait();
|
||||||
|
}
|
||||||
|
void create(QString _input_path, QString _save_path, QStringList _trackers, QStringList _url_seeds, QString _comment, bool _is_private, int _piece_size);
|
||||||
|
void sendProgressSignal(int progress);
|
||||||
|
void abortCreation() { abort = true; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void run();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void creationFailure(QString msg);
|
||||||
|
void creationSuccess(QString path, QString branch_path);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void updateProgress(int progress);
|
||||||
|
};
|
||||||
|
|
||||||
|
class createtorrent : public QDialog, private Ui::createTorrentDialog{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
torrentCreatorThread *creatorThread;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TorrentCreatorDlg(QWidget *parent = 0);
|
createtorrent(QWidget *parent = 0);
|
||||||
~TorrentCreatorDlg();
|
~createtorrent();
|
||||||
|
QStringList allItems(QListWidget *list);
|
||||||
int getPieceSize() const;
|
int getPieceSize() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@@ -54,18 +94,12 @@ class TorrentCreatorDlg : public QDialog, private Ui::createTorrentDialog{
|
|||||||
void on_createButton_clicked();
|
void on_createButton_clicked();
|
||||||
void on_addFile_button_clicked();
|
void on_addFile_button_clicked();
|
||||||
void on_addFolder_button_clicked();
|
void on_addFolder_button_clicked();
|
||||||
|
void on_addTracker_button_clicked();
|
||||||
|
void on_removeTracker_button_clicked();
|
||||||
|
void on_addURLSeed_button_clicked();
|
||||||
|
void on_removeURLSeed_button_clicked();
|
||||||
void handleCreationFailure(QString msg);
|
void handleCreationFailure(QString msg);
|
||||||
void handleCreationSuccess(QString path, QString branch_path);
|
void handleCreationSuccess(QString path, QString branch_path);
|
||||||
void setInteractionEnabled(bool enabled);
|
|
||||||
void showProgressBar(bool show);
|
|
||||||
void on_checkAutoPieceSize_clicked(bool checked);
|
|
||||||
void updateOptimalPieceSize();
|
|
||||||
void saveTrackerList();
|
|
||||||
void loadTrackerList();
|
|
||||||
|
|
||||||
private:
|
|
||||||
TorrentCreatorThread *creatorThread;
|
|
||||||
QList<int> m_piece_sizes;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -43,7 +43,6 @@ using namespace libtorrent;
|
|||||||
|
|
||||||
class DownloadedPiecesBar: public QWidget {
|
class DownloadedPiecesBar: public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(DownloadedPiecesBar)
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
@@ -61,34 +60,31 @@ public:
|
|||||||
pix.fill();
|
pix.fill();
|
||||||
pixmap = pix;
|
pixmap = pix;
|
||||||
} else {
|
} else {
|
||||||
const qulonglong nb_pieces = pieces.size();
|
const int nb_pieces = pieces.size();
|
||||||
// Reduce the number of pieces before creating the pixmap
|
// Reduce the number of pieces before creating the pixmap
|
||||||
// otherwise it can crash when there are too many pieces
|
// otherwise it can crash when there are too many pieces
|
||||||
const uint w = width();
|
if(nb_pieces > width()) {
|
||||||
if(nb_pieces > w) {
|
const int ratio = floor(nb_pieces/(double)width());
|
||||||
const uint ratio = floor(nb_pieces/(double)w);
|
std::vector<bool> scaled_pieces;
|
||||||
bitfield scaled_pieces(ceil(nb_pieces/(double)ratio), false);
|
std::vector<bool> scaled_downloading;
|
||||||
bitfield scaled_downloading(ceil(nb_pieces/(double)ratio), false);
|
for(int i=0; i<nb_pieces; i+= ratio) {
|
||||||
uint scaled_index = 0;
|
|
||||||
for(qulonglong i=0; i<nb_pieces; i+= ratio) {
|
|
||||||
bool have = true;
|
bool have = true;
|
||||||
for(qulonglong j=i; j<qMin(i+ratio, nb_pieces); ++j) {
|
for(int j=i; j<qMin(i+ratio, nb_pieces); ++j) {
|
||||||
if(!pieces[i]) { have = false; break; }
|
if(!pieces[i]) { have = false; break; }
|
||||||
}
|
}
|
||||||
|
scaled_pieces.push_back(have);
|
||||||
if(have) {
|
if(have) {
|
||||||
scaled_pieces.set_bit(scaled_index);
|
scaled_downloading.push_back(false);
|
||||||
} else {
|
} else {
|
||||||
bool downloading = false;
|
bool downloading = false;
|
||||||
for(qulonglong j=i; j<qMin(i+ratio, nb_pieces); ++j) {
|
for(int j=i; j<qMin(i+ratio, nb_pieces); ++j) {
|
||||||
if(downloading_pieces[i]) { downloading = true; break; }
|
if(downloading_pieces[i]) { downloading = true; break; }
|
||||||
}
|
}
|
||||||
if(downloading)
|
scaled_downloading.push_back(downloading);
|
||||||
scaled_downloading.set_bit(scaled_index);
|
|
||||||
}
|
}
|
||||||
++scaled_index;
|
|
||||||
}
|
}
|
||||||
QPixmap pix = QPixmap(scaled_pieces.size(), 1);
|
QPixmap pix = QPixmap(scaled_pieces.size(), 1);
|
||||||
//pix.fill();
|
pix.fill();
|
||||||
QPainter painter(&pix);
|
QPainter painter(&pix);
|
||||||
for(uint i=0; i<scaled_pieces.size(); ++i) {
|
for(uint i=0; i<scaled_pieces.size(); ++i) {
|
||||||
if(scaled_pieces[i]) {
|
if(scaled_pieces[i]) {
|
||||||
@@ -105,7 +101,7 @@ public:
|
|||||||
pixmap = pix;
|
pixmap = pix;
|
||||||
} else {
|
} else {
|
||||||
QPixmap pix = QPixmap(pieces.size(), 1);
|
QPixmap pix = QPixmap(pieces.size(), 1);
|
||||||
//pix.fill();
|
pix.fill();
|
||||||
QPainter painter(&pix);
|
QPainter painter(&pix);
|
||||||
for(uint i=0; i<pieces.size(); ++i) {
|
for(uint i=0; i<pieces.size(); ++i) {
|
||||||
if(pieces[i]) {
|
if(pieces[i]) {
|
||||||
@@ -39,6 +39,8 @@
|
|||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
#include "qinisettings.h"
|
#include "qinisettings.h"
|
||||||
|
|
||||||
|
enum ProxyType {HTTP=1, SOCKS5=2, HTTP_PW=3, SOCKS5_PW=4, SOCKS4=5};
|
||||||
|
|
||||||
/** Download Thread **/
|
/** Download Thread **/
|
||||||
|
|
||||||
downloadThread::downloadThread(QObject* parent) : QObject(parent) {
|
downloadThread::downloadThread(QObject* parent) : QObject(parent) {
|
||||||
@@ -178,7 +180,7 @@ void downloadThread::applyProxySettings() {
|
|||||||
qDebug("Using proxy: %s", qPrintable(IP));
|
qDebug("Using proxy: %s", qPrintable(IP));
|
||||||
proxy.setPort(port.toUShort());
|
proxy.setPort(port.toUShort());
|
||||||
// Default proxy type is HTTP, we must change if it is SOCKS5
|
// Default proxy type is HTTP, we must change if it is SOCKS5
|
||||||
if(intValue == Proxy::SOCKS5 || intValue == Proxy::SOCKS5_PW) {
|
if(intValue == SOCKS5 || intValue == SOCKS5_PW) {
|
||||||
qDebug("Proxy is SOCKS5, not HTTP");
|
qDebug("Proxy is SOCKS5, not HTTP");
|
||||||
proxy.setType(QNetworkProxy::Socks5Proxy);
|
proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
|
||||||
enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID};
|
enum EngineColumns {ENGINE_NAME, ENGINE_URL, ENGINE_STATE, ENGINE_ID};
|
||||||
#define UPDATE_URL "http://qbittorrent.svn.sourceforge.net/viewvc/qbittorrent/trunk/src/searchengine/nova/engines/"
|
#define UPDATE_URL "http://qbittorrent.svn.sourceforge.net/viewvc/qbittorrent/trunk/src/search_engine/engines/"
|
||||||
|
|
||||||
engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines) : QDialog(parent), supported_engines(supported_engines) {
|
engineSelectDlg::engineSelectDlg(QWidget *parent, SupportedEngines *supported_engines) : QDialog(parent), supported_engines(supported_engines) {
|
||||||
setupUi(this);
|
setupUi(this);
|
||||||
@@ -164,7 +164,7 @@ void engineSelectDlg::on_actionUninstall_triggered() {
|
|||||||
int index = pluginsTree->indexOfTopLevelItem(item);
|
int index = pluginsTree->indexOfTopLevelItem(item);
|
||||||
Q_ASSERT(index != -1);
|
Q_ASSERT(index != -1);
|
||||||
QString id = item->text(ENGINE_ID);
|
QString id = item->text(ENGINE_ID);
|
||||||
if(QFile::exists(":/nova/engines/"+id+".py")) {
|
if(QFile::exists(":/search_engine/engines/"+id+".py")) {
|
||||||
error = true;
|
error = true;
|
||||||
// Disable it instead
|
// Disable it instead
|
||||||
supported_engines->value(id)->setEnabled(false);
|
supported_engines->value(id)->setEnabled(false);
|
||||||
@@ -270,7 +270,6 @@ void engineSelectDlg::installPlugin(QString path, QString plugin_name) {
|
|||||||
// Backup in case install fails
|
// Backup in case install fails
|
||||||
QFile::copy(dest_path, dest_path+".bak");
|
QFile::copy(dest_path, dest_path+".bak");
|
||||||
misc::safeRemove(dest_path);
|
misc::safeRemove(dest_path);
|
||||||
misc::safeRemove(dest_path+"c");
|
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
// Copy the plugin
|
// Copy the plugin
|
||||||
@@ -31,17 +31,16 @@
|
|||||||
|
|
||||||
#include <libtorrent/version.hpp>
|
#include <libtorrent/version.hpp>
|
||||||
#include "eventmanager.h"
|
#include "eventmanager.h"
|
||||||
#include "qbtsession.h"
|
#include "bittorrent.h"
|
||||||
#include "scannedfoldersmodel.h"
|
#include "scannedfoldersmodel.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "preferences.h"
|
#include "preferences.h"
|
||||||
//#include "proplistdelegate.h"
|
//#include "proplistdelegate.h"
|
||||||
#include "torrentpersistentdata.h"
|
#include "torrentpersistentdata.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTranslator>
|
|
||||||
|
|
||||||
EventManager::EventManager(QObject *parent)
|
EventManager::EventManager(QObject *parent, Bittorrent *BTSession)
|
||||||
: QObject(parent)
|
: QObject(parent), BTSession(BTSession)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,9 +50,9 @@ QList<QVariantMap> EventManager::getEventList() const {
|
|||||||
|
|
||||||
QList<QVariantMap> EventManager::getPropTrackersInfo(QString hash) const {
|
QList<QVariantMap> EventManager::getPropTrackersInfo(QString hash) const {
|
||||||
QList<QVariantMap> trackersInfo;
|
QList<QVariantMap> trackersInfo;
|
||||||
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
if(h.is_valid()) {
|
if(h.is_valid()) {
|
||||||
QHash<QString, TrackerInfos> trackers_data = QBtSession::instance()->getTrackersInfo(hash);
|
QHash<QString, TrackerInfos> trackers_data = BTSession->getTrackersInfo(hash);
|
||||||
std::vector<announce_entry> vect_trackers = h.trackers();
|
std::vector<announce_entry> vect_trackers = h.trackers();
|
||||||
std::vector<announce_entry>::iterator it;
|
std::vector<announce_entry>::iterator it;
|
||||||
for(it = vect_trackers.begin(); it != vect_trackers.end(); it++) {
|
for(it = vect_trackers.begin(); it != vect_trackers.end(); it++) {
|
||||||
@@ -96,7 +95,7 @@ QList<QVariantMap> EventManager::getPropTrackersInfo(QString hash) const {
|
|||||||
|
|
||||||
QList<QVariantMap> EventManager::getPropFilesInfo(QString hash) const {
|
QList<QVariantMap> EventManager::getPropFilesInfo(QString hash) const {
|
||||||
QList<QVariantMap> files;
|
QList<QVariantMap> files;
|
||||||
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
if(!h.is_valid() || !h.has_metadata()) return files;
|
if(!h.is_valid() || !h.has_metadata()) return files;
|
||||||
std::vector<int> priorities = h.file_priorities();
|
std::vector<int> priorities = h.file_priorities();
|
||||||
std::vector<size_type> fp;
|
std::vector<size_type> fp;
|
||||||
@@ -125,20 +124,8 @@ QList<QVariantMap> EventManager::getPropFilesInfo(QString hash) const {
|
|||||||
|
|
||||||
void EventManager::setGlobalPreferences(QVariantMap m) const {
|
void EventManager::setGlobalPreferences(QVariantMap m) const {
|
||||||
// UI
|
// UI
|
||||||
if(m.contains("locale")) {
|
if(m.contains("locale"))
|
||||||
QString locale = m["locale"].toString();
|
Preferences::setLocale(m["locale"].toString());
|
||||||
if(Preferences::getLocale() != locale) {
|
|
||||||
QTranslator *translator = new QTranslator;
|
|
||||||
if(translator->load(QString::fromUtf8(":/lang/qbittorrent_") + locale)){
|
|
||||||
qDebug("%s locale recognized, using translation.", qPrintable(locale));
|
|
||||||
}else{
|
|
||||||
qDebug("%s locale unrecognized, using default (en_GB).", qPrintable(locale));
|
|
||||||
}
|
|
||||||
qApp->installTranslator(translator);
|
|
||||||
}
|
|
||||||
|
|
||||||
Preferences::setLocale(locale);
|
|
||||||
}
|
|
||||||
// Downloads
|
// Downloads
|
||||||
if(m.contains("save_path"))
|
if(m.contains("save_path"))
|
||||||
Preferences::setSavePath(m["save_path"].toString());
|
Preferences::setSavePath(m["save_path"].toString());
|
||||||
@@ -160,7 +147,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) const {
|
|||||||
foreach(const QString &old_folder, old_folders) {
|
foreach(const QString &old_folder, old_folders) {
|
||||||
// Update deleted folders
|
// Update deleted folders
|
||||||
if(!new_folders.contains(old_folder)) {
|
if(!new_folders.contains(old_folder)) {
|
||||||
QBtSession::instance()->getScanFoldersModel()->removePath(old_folder);
|
BTSession->getScanFoldersModel()->removePath(old_folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -168,7 +155,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) const {
|
|||||||
qDebug("New watched folder: %s", qPrintable(new_folder));
|
qDebug("New watched folder: %s", qPrintable(new_folder));
|
||||||
// Update new folders
|
// Update new folders
|
||||||
if(!old_folders.contains(new_folder)) {
|
if(!old_folders.contains(new_folder)) {
|
||||||
QBtSession::instance()->getScanFoldersModel()->addPath(new_folder, download_at_path.at(i));
|
BTSession->getScanFoldersModel()->addPath(new_folder, download_at_path.at(i));
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@@ -269,7 +256,7 @@ void EventManager::setGlobalPreferences(QVariantMap m) const {
|
|||||||
if(m.contains("web_ui_password"))
|
if(m.contains("web_ui_password"))
|
||||||
Preferences::setWebUiPassword(m["web_ui_password"].toString());
|
Preferences::setWebUiPassword(m["web_ui_password"].toString());
|
||||||
// Reload preferences
|
// Reload preferences
|
||||||
QBtSession::instance()->configureSession();
|
BTSession->configureSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariantMap EventManager::getGlobalPreferences() const {
|
QVariantMap EventManager::getGlobalPreferences() const {
|
||||||
@@ -342,7 +329,7 @@ QVariantMap EventManager::getGlobalPreferences() const {
|
|||||||
|
|
||||||
QVariantMap EventManager::getPropGeneralInfo(QString hash) const {
|
QVariantMap EventManager::getPropGeneralInfo(QString hash) const {
|
||||||
QVariantMap data;
|
QVariantMap data;
|
||||||
QTorrentHandle h = QBtSession::instance()->getTorrentHandle(hash);
|
QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||||
if(h.is_valid() && h.has_metadata()) {
|
if(h.is_valid() && h.has_metadata()) {
|
||||||
// Save path
|
// Save path
|
||||||
QString p = TorrentPersistentData::getSavePath(hash);
|
QString p = TorrentPersistentData::getSavePath(hash);
|
||||||
@@ -370,7 +357,7 @@ QVariantMap EventManager::getPropGeneralInfo(QString hash) const {
|
|||||||
data["time_elapsed"] = elapsed_txt;
|
data["time_elapsed"] = elapsed_txt;
|
||||||
data["nb_connections"] = QVariant(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")");
|
data["nb_connections"] = QVariant(QString::number(h.num_connections())+" ("+tr("%1 max", "e.g. 10 max").arg(QString::number(h.connections_limit()))+")");
|
||||||
// Update ratio info
|
// Update ratio info
|
||||||
double ratio = QBtSession::instance()->getRealRatio(h.hash());
|
double ratio = BTSession->getRealRatio(h.hash());
|
||||||
if(ratio > 100.)
|
if(ratio > 100.)
|
||||||
data["share_ratio"] = QString::fromUtf8("∞");
|
data["share_ratio"] = QString::fromUtf8("∞");
|
||||||
else
|
else
|
||||||
@@ -404,7 +391,7 @@ void EventManager::modifiedTorrent(QTorrentHandle h)
|
|||||||
event["state"] = QVariant("pausedDL");
|
event["state"] = QVariant("pausedDL");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(QBtSession::instance()->isQueueingEnabled() && h.is_queued()) {
|
if(BTSession->isQueueingEnabled() && h.is_queued()) {
|
||||||
if(h.is_seed())
|
if(h.is_seed())
|
||||||
event["state"] = QVariant("queuedUP");
|
event["state"] = QVariant("queuedUP");
|
||||||
else
|
else
|
||||||
@@ -436,7 +423,7 @@ void EventManager::modifiedTorrent(QTorrentHandle h)
|
|||||||
event["state"] = QVariant("downloading");
|
event["state"] = QVariant("downloading");
|
||||||
else
|
else
|
||||||
event["state"] = QVariant("stalledDL");
|
event["state"] = QVariant("stalledDL");
|
||||||
event["eta"] = misc::userFriendlyDuration(QBtSession::instance()->getETA(hash));
|
event["eta"] = misc::userFriendlyDuration(BTSession->getETA(hash));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qDebug("No status, should not happen!!! status is %d", h.state());
|
qDebug("No status, should not happen!!! status is %d", h.state());
|
||||||
@@ -448,7 +435,7 @@ void EventManager::modifiedTorrent(QTorrentHandle h)
|
|||||||
event["size"] = QVariant(misc::friendlyUnit(h.actual_size()));
|
event["size"] = QVariant(misc::friendlyUnit(h.actual_size()));
|
||||||
event["progress"] = QVariant((double)h.progress());
|
event["progress"] = QVariant((double)h.progress());
|
||||||
event["dlspeed"] = QVariant(tr("%1/s", "e.g. 120 KiB/s").arg(misc::friendlyUnit(h.download_payload_rate())));
|
event["dlspeed"] = QVariant(tr("%1/s", "e.g. 120 KiB/s").arg(misc::friendlyUnit(h.download_payload_rate())));
|
||||||
if(QBtSession::instance()->isQueueingEnabled()) {
|
if(BTSession->isQueueingEnabled()) {
|
||||||
if(h.queue_position() >= 0)
|
if(h.queue_position() >= 0)
|
||||||
event["priority"] = QVariant(QString::number(h.queue_position()));
|
event["priority"] = QVariant(QString::number(h.queue_position()));
|
||||||
else
|
else
|
||||||
@@ -466,7 +453,7 @@ void EventManager::modifiedTorrent(QTorrentHandle h)
|
|||||||
leechs += " ("+QString::number(h.num_incomplete())+")";
|
leechs += " ("+QString::number(h.num_incomplete())+")";
|
||||||
event["num_leechs"] = QVariant(leechs);
|
event["num_leechs"] = QVariant(leechs);
|
||||||
event["seed"] = QVariant(h.is_seed());
|
event["seed"] = QVariant(h.is_seed());
|
||||||
double ratio = QBtSession::instance()->getRealRatio(hash);
|
double ratio = BTSession->getRealRatio(hash);
|
||||||
if(ratio > 100.)
|
if(ratio > 100.)
|
||||||
event["ratio"] = QString::fromUtf8("∞");
|
event["ratio"] = QString::fromUtf8("∞");
|
||||||
else
|
else
|
||||||
@@ -36,30 +36,31 @@
|
|||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
|
|
||||||
|
class Bittorrent;
|
||||||
|
|
||||||
class EventManager : public QObject
|
class EventManager : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_DISABLE_COPY(EventManager)
|
private:
|
||||||
|
QHash<QString, QVariantMap> event_list;
|
||||||
|
Bittorrent* BTSession;
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
QHash<QString, QVariantMap> event_list;
|
void update(QVariantMap event);
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
void update(QVariantMap event);
|
EventManager(QObject *parent, Bittorrent* BTSession);
|
||||||
|
QList<QVariantMap> getEventList() const;
|
||||||
|
QVariantMap getPropGeneralInfo(QString hash) const;
|
||||||
|
QList<QVariantMap> getPropTrackersInfo(QString hash) const;
|
||||||
|
QList<QVariantMap> getPropFilesInfo(QString hash) const;
|
||||||
|
QVariantMap getGlobalPreferences() const;
|
||||||
|
void setGlobalPreferences(QVariantMap m) const;
|
||||||
|
|
||||||
public:
|
public slots:
|
||||||
EventManager(QObject *parent);
|
void addedTorrent(QTorrentHandle& h);
|
||||||
QList<QVariantMap> getEventList() const;
|
void deletedTorrent(QString hash);
|
||||||
QVariantMap getPropGeneralInfo(QString hash) const;
|
void modifiedTorrent(QTorrentHandle h);
|
||||||
QList<QVariantMap> getPropTrackersInfo(QString hash) const;
|
|
||||||
QList<QVariantMap> getPropFilesInfo(QString hash) const;
|
|
||||||
QVariantMap getGlobalPreferences() const;
|
|
||||||
void setGlobalPreferences(QVariantMap m) const;
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void addedTorrent(QTorrentHandle& h);
|
|
||||||
void deletedTorrent(QString hash);
|
|
||||||
void modifiedTorrent(QTorrentHandle h);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
221
src/feedList.h
Normal file
221
src/feedList.h
Normal file
@@ -0,0 +1,221 @@
|
|||||||
|
#ifndef FEEDLIST_H
|
||||||
|
#define FEEDLIST_H
|
||||||
|
|
||||||
|
#include <QTreeWidget>
|
||||||
|
#include <QTreeWidgetItem>
|
||||||
|
#include <QDropEvent>
|
||||||
|
#include <QDragMoveEvent>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QUrl>
|
||||||
|
#include "rss.h"
|
||||||
|
|
||||||
|
class FeedList: public QTreeWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
private:
|
||||||
|
RssManager *rssmanager;
|
||||||
|
QHash<QTreeWidgetItem*, RssFile*> mapping;
|
||||||
|
QHash<QString, QTreeWidgetItem*> feeds_items;
|
||||||
|
QTreeWidgetItem* current_feed;
|
||||||
|
QTreeWidgetItem *unread_item;
|
||||||
|
|
||||||
|
public:
|
||||||
|
FeedList(QWidget *parent, RssManager *rssmanager): QTreeWidget(parent), rssmanager(rssmanager) {
|
||||||
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
setDragDropMode(QAbstractItemView::InternalMove);
|
||||||
|
setSelectionMode(QAbstractItemView::ExtendedSelection);
|
||||||
|
setColumnCount(1);
|
||||||
|
QTreeWidgetItem *___qtreewidgetitem = headerItem();
|
||||||
|
___qtreewidgetitem->setText(0, QApplication::translate("RSS", "RSS feeds", 0, QApplication::UnicodeUTF8));
|
||||||
|
unread_item = new QTreeWidgetItem(this);
|
||||||
|
unread_item->setText(0, tr("Unread") + QString::fromUtf8(" (") + QString::number(rssmanager->getNbUnRead(), 10)+ QString(")"));
|
||||||
|
unread_item->setData(0,Qt::DecorationRole, QVariant(QIcon(":/Icons/oxygen/mail-folder-inbox.png")));
|
||||||
|
itemAdded(unread_item, rssmanager);
|
||||||
|
connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(updateCurrentFeed(QTreeWidgetItem*)));
|
||||||
|
setCurrentItem(unread_item);
|
||||||
|
}
|
||||||
|
|
||||||
|
~FeedList() {
|
||||||
|
disconnect(this, SIGNAL(currentItemChanged(QTreeWidgetItem*,QTreeWidgetItem*)), this, SLOT(updateCurrentFeed(QTreeWidgetItem*)));
|
||||||
|
delete unread_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
void itemAdded(QTreeWidgetItem *item, RssFile* file) {
|
||||||
|
mapping[item] = file;
|
||||||
|
if(file->getType() == RssFile::STREAM) {
|
||||||
|
feeds_items[file->getID()] = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void itemAboutToBeRemoved(QTreeWidgetItem *item) {
|
||||||
|
RssFile* file = mapping.take(item);
|
||||||
|
if(file->getType() == RssFile::STREAM) {
|
||||||
|
feeds_items.remove(file->getID());
|
||||||
|
} else {
|
||||||
|
QList<RssStream*> feeds = ((RssFolder*)file)->getAllFeeds();
|
||||||
|
foreach(RssStream* feed, feeds) {
|
||||||
|
feeds_items.remove(feed->getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasFeed(QString url) const {
|
||||||
|
return feeds_items.contains(QUrl(url).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> getAllFeedItems() const {
|
||||||
|
return feeds_items.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem* getUnreadItem() const {
|
||||||
|
return unread_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList getItemPath(QTreeWidgetItem* item) const {
|
||||||
|
QStringList path;
|
||||||
|
if(item) {
|
||||||
|
if(item->parent())
|
||||||
|
path << getItemPath(item->parent());
|
||||||
|
path.append(getRSSItem(item)->getID());
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> getAllOpenFolders(QTreeWidgetItem *parent=0) const {
|
||||||
|
QList<QTreeWidgetItem*> open_folders;
|
||||||
|
int nbChildren;
|
||||||
|
if(parent)
|
||||||
|
nbChildren = parent->childCount();
|
||||||
|
else
|
||||||
|
nbChildren = topLevelItemCount();
|
||||||
|
for(int i=0; i<nbChildren; ++i) {
|
||||||
|
QTreeWidgetItem *item;
|
||||||
|
if(parent)
|
||||||
|
item = parent->child(i);
|
||||||
|
else
|
||||||
|
item = topLevelItem(i);
|
||||||
|
if(getItemType(item) == RssFile::FOLDER && item->isExpanded()) {
|
||||||
|
QList<QTreeWidgetItem*> open_subfolders = getAllOpenFolders(item);
|
||||||
|
if(!open_subfolders.empty()) {
|
||||||
|
open_folders << open_subfolders;
|
||||||
|
} else {
|
||||||
|
open_folders << item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return open_folders;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QTreeWidgetItem*> getAllFeedItems(QTreeWidgetItem* folder) {
|
||||||
|
QList<QTreeWidgetItem*> feeds;
|
||||||
|
int nbChildren = folder->childCount();
|
||||||
|
for(int i=0; i<nbChildren; ++i) {
|
||||||
|
QTreeWidgetItem *item = folder->child(i);
|
||||||
|
if(getItemType(item) == RssFile::STREAM) {
|
||||||
|
feeds << item;
|
||||||
|
} else {
|
||||||
|
feeds << getAllFeedItems(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return feeds;
|
||||||
|
}
|
||||||
|
|
||||||
|
RssFile* getRSSItem(QTreeWidgetItem *item) const {
|
||||||
|
return mapping.value(item, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
RssFile::FileType getItemType(QTreeWidgetItem *item) const {
|
||||||
|
return mapping.value(item)->getType();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString getItemID(QTreeWidgetItem *item) const {
|
||||||
|
return mapping.value(item)->getID();
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem* getTreeItemFromUrl(QString url) const{
|
||||||
|
return feeds_items.value(url, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
RssStream* getRSSItemFromUrl(QString url) const {
|
||||||
|
return (RssStream*)getRSSItem(getTreeItemFromUrl(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem* currentItem() const {
|
||||||
|
return current_feed;
|
||||||
|
}
|
||||||
|
|
||||||
|
QTreeWidgetItem* currentFeed() const {
|
||||||
|
return current_feed;
|
||||||
|
}
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void foldersAltered(QList<QTreeWidgetItem*> folders);
|
||||||
|
void overwriteAttempt(QString filename);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void updateCurrentFeed(QTreeWidgetItem* new_item) {
|
||||||
|
if(!new_item) return;
|
||||||
|
if(!mapping.contains(new_item)) return;
|
||||||
|
if((getItemType(new_item) == RssFile::STREAM) || new_item == unread_item)
|
||||||
|
current_feed = new_item;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void dragMoveEvent(QDragMoveEvent * event) {
|
||||||
|
QTreeWidgetItem *item = itemAt(event->pos());
|
||||||
|
if(item == unread_item) {
|
||||||
|
event->ignore();
|
||||||
|
} else {
|
||||||
|
if(item && getItemType(item) != RssFile::FOLDER)
|
||||||
|
event->ignore();
|
||||||
|
else {
|
||||||
|
if(selectedItems().contains(unread_item)) {
|
||||||
|
event->ignore();
|
||||||
|
} else {
|
||||||
|
QTreeWidget::dragMoveEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void dropEvent(QDropEvent *event) {
|
||||||
|
qDebug("dropEvent");
|
||||||
|
QList<QTreeWidgetItem*> folders_altered;
|
||||||
|
QTreeWidgetItem *dest_folder_item = itemAt(event->pos());
|
||||||
|
RssFolder *dest_folder;
|
||||||
|
if(dest_folder_item) {
|
||||||
|
dest_folder = (RssFolder*)getRSSItem(dest_folder_item);
|
||||||
|
folders_altered << dest_folder_item;
|
||||||
|
} else {
|
||||||
|
dest_folder = rssmanager;
|
||||||
|
}
|
||||||
|
QList<QTreeWidgetItem *> src_items = selectedItems();
|
||||||
|
// Check if there is not going to overwrite another file
|
||||||
|
foreach(QTreeWidgetItem *src_item, src_items) {
|
||||||
|
RssFile *file = getRSSItem(src_item);
|
||||||
|
if(dest_folder->hasChild(file->getID())) {
|
||||||
|
emit overwriteAttempt(file->getID());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Proceed with the move
|
||||||
|
foreach(QTreeWidgetItem *src_item, src_items) {
|
||||||
|
QTreeWidgetItem *parent_folder = src_item->parent();
|
||||||
|
if(parent_folder && !folders_altered.contains(parent_folder))
|
||||||
|
folders_altered << parent_folder;
|
||||||
|
// Actually move the file
|
||||||
|
RssFile *file = getRSSItem(src_item);
|
||||||
|
rssmanager->moveFile(file, dest_folder);
|
||||||
|
}
|
||||||
|
QTreeWidget::dropEvent(event);
|
||||||
|
if(dest_folder_item)
|
||||||
|
dest_folder_item->setExpanded(true);
|
||||||
|
// Emit signal for update
|
||||||
|
if(!folders_altered.empty())
|
||||||
|
emit foldersAltered(folders_altered);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // FEEDLIST_H
|
||||||
514
src/feeddownloader.h
Normal file
514
src/feeddownloader.h
Normal file
File diff suppressed because it is too large
Load Diff
@@ -3,12 +3,11 @@
|
|||||||
|
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
|
#ifndef Q_WS_WIN
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QHash>
|
|
||||||
|
|
||||||
#ifndef Q_WS_WIN
|
|
||||||
#include <QSet>
|
#include <QSet>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -20,8 +19,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "misc.h"
|
|
||||||
|
|
||||||
#ifndef CIFS_MAGIC_NUMBER
|
#ifndef CIFS_MAGIC_NUMBER
|
||||||
#define CIFS_MAGIC_NUMBER 0xFF534D42
|
#define CIFS_MAGIC_NUMBER 0xFF534D42
|
||||||
#endif
|
#endif
|
||||||
@@ -30,9 +27,6 @@
|
|||||||
#define NFS_SUPER_MAGIC 0x6969
|
#define NFS_SUPER_MAGIC 0x6969
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const int WATCH_INTERVAL = 10000; // 10 sec
|
|
||||||
const int MAX_PARTIAL_RETRIES = 5;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Subclassing QFileSystemWatcher in order to support Network File
|
* Subclassing QFileSystemWatcher in order to support Network File
|
||||||
* System watching (NFS, CIFS) on Linux and Mac OS.
|
* System watching (NFS, CIFS) on Linux and Mac OS.
|
||||||
@@ -45,14 +39,11 @@ private:
|
|||||||
QList<QDir> watched_folders;
|
QList<QDir> watched_folders;
|
||||||
QPointer<QTimer> watch_timer;
|
QPointer<QTimer> watch_timer;
|
||||||
#endif
|
#endif
|
||||||
QStringList m_filters;
|
QStringList filters;
|
||||||
// Partial torrents
|
|
||||||
QHash<QString, int> m_partialTorrents;
|
|
||||||
QPointer<QTimer> m_partialTorrentTimer;
|
|
||||||
|
|
||||||
#ifndef Q_WS_WIN
|
#ifndef Q_WS_WIN
|
||||||
private:
|
protected:
|
||||||
static bool isNetworkFileSystem(QString path) {
|
bool isNetworkFileSystem(QString path) {
|
||||||
QString file = path;
|
QString file = path;
|
||||||
if(!file.endsWith(QDir::separator()))
|
if(!file.endsWith(QDir::separator()))
|
||||||
file += QDir::separator();
|
file += QDir::separator();
|
||||||
@@ -108,7 +99,7 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
FileSystemWatcher(QObject *parent): QFileSystemWatcher(parent) {
|
FileSystemWatcher(QObject *parent): QFileSystemWatcher(parent) {
|
||||||
m_filters << "*.torrent";
|
filters << "*.torrent";
|
||||||
connect(this, SIGNAL(directoryChanged(QString)), this, SLOT(scanLocalFolder(QString)));
|
connect(this, SIGNAL(directoryChanged(QString)), this, SLOT(scanLocalFolder(QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,8 +108,6 @@ public:
|
|||||||
if(watch_timer)
|
if(watch_timer)
|
||||||
delete watch_timer;
|
delete watch_timer;
|
||||||
#endif
|
#endif
|
||||||
if(m_partialTorrentTimer)
|
|
||||||
delete m_partialTorrentTimer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList directories() const {
|
QStringList directories() const {
|
||||||
@@ -148,7 +137,7 @@ public:
|
|||||||
if (!watch_timer) {
|
if (!watch_timer) {
|
||||||
watch_timer = new QTimer(this);
|
watch_timer = new QTimer(this);
|
||||||
connect(watch_timer, SIGNAL(timeout()), this, SLOT(scanNetworkFolders()));
|
connect(watch_timer, SIGNAL(timeout()), this, SLOT(scanNetworkFolders()));
|
||||||
watch_timer->start(WATCH_INTERVAL); // 5 sec
|
watch_timer->start(5000); // 5 sec
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#endif
|
#endif
|
||||||
@@ -207,72 +196,19 @@ protected slots:
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void processPartialTorrents() {
|
|
||||||
QStringList no_longer_partial;
|
|
||||||
|
|
||||||
// Check which torrents are still partial
|
|
||||||
foreach(const QString& torrent_path, m_partialTorrents.keys()) {
|
|
||||||
if(!QFile::exists(torrent_path)) {
|
|
||||||
m_partialTorrents.remove(torrent_path);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(misc::isValidTorrentFile(torrent_path)) {
|
|
||||||
no_longer_partial << torrent_path;
|
|
||||||
m_partialTorrents.remove(torrent_path);
|
|
||||||
} else {
|
|
||||||
if(m_partialTorrents[torrent_path] >= MAX_PARTIAL_RETRIES) {
|
|
||||||
m_partialTorrents.remove(torrent_path);
|
|
||||||
QFile::rename(torrent_path, torrent_path+".invalid");
|
|
||||||
} else {
|
|
||||||
m_partialTorrents[torrent_path]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stop the partial timer if necessary
|
|
||||||
if(m_partialTorrents.empty()) {
|
|
||||||
m_partialTorrentTimer->stop();
|
|
||||||
m_partialTorrentTimer->deleteLater();
|
|
||||||
qDebug("No longer any partial torrent.");
|
|
||||||
} else {
|
|
||||||
qDebug("Still %d partial torrents after delayed processing.", m_partialTorrents.count());
|
|
||||||
m_partialTorrentTimer->start(WATCH_INTERVAL);
|
|
||||||
}
|
|
||||||
// Notify of new torrents
|
|
||||||
if(!no_longer_partial.isEmpty())
|
|
||||||
emit torrentsAdded(no_longer_partial);
|
|
||||||
}
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void torrentsAdded(QStringList &pathList);
|
void torrentsAdded(QStringList &pathList);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void startPartialTorrentTimer() {
|
|
||||||
Q_ASSERT(!m_partialTorrents.isEmpty());
|
|
||||||
if(!m_partialTorrentTimer) {
|
|
||||||
m_partialTorrentTimer = new QTimer();
|
|
||||||
connect(m_partialTorrentTimer, SIGNAL(timeout()), SLOT(processPartialTorrents()));
|
|
||||||
m_partialTorrentTimer->setSingleShot(true);
|
|
||||||
m_partialTorrentTimer->start(WATCH_INTERVAL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void addTorrentsFromDir(const QDir &dir, QStringList &torrents) {
|
void addTorrentsFromDir(const QDir &dir, QStringList &torrents) {
|
||||||
const QStringList files = dir.entryList(m_filters, QDir::Files, QDir::Unsorted);
|
const QStringList files = dir.entryList(filters, QDir::Files, QDir::Unsorted);
|
||||||
foreach(const QString &file, files) {
|
foreach(const QString &file, files) {
|
||||||
const QString file_abspath = dir.absoluteFilePath(file);
|
#if defined(Q_WS_WIN) || defined(Q_OS_OS2)
|
||||||
if(misc::isValidTorrentFile(file_abspath)) {
|
torrents << dir.absoluteFilePath(file).replace("/", "\\");
|
||||||
torrents << file_abspath;
|
#else
|
||||||
} else {
|
torrents << dir.absoluteFilePath(file);
|
||||||
if(!m_partialTorrents.contains(file_abspath)) {
|
#endif
|
||||||
qDebug("Partial torrent detected at: %s", qPrintable(file_abspath));
|
|
||||||
qDebug("Delay the file's processing...");
|
|
||||||
m_partialTorrents.insert(file_abspath, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if(!m_partialTorrents.empty())
|
|
||||||
startPartialTorrentTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
508
src/gpl.html
508
src/gpl.html
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user