|
|
@ -44,129 +44,74 @@ |
|
|
|
|
|
|
|
|
|
|
|
class TorrentTempData { |
|
|
|
class TorrentTempData { |
|
|
|
public: |
|
|
|
public: |
|
|
|
static bool hasTempData(QString hash) { |
|
|
|
static bool hasTempData(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
return data.contains(hash); |
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
return all_data.contains(hash); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void deleteTempData(QString hash) { |
|
|
|
static void deleteTempData(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
data.remove(hash); |
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
if (all_data.contains(hash)) { |
|
|
|
|
|
|
|
all_data.remove(hash); |
|
|
|
|
|
|
|
settings.setValue("torrents-tmp", all_data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setFilesPriority(QString hash, const std::vector<int> &pp) { |
|
|
|
static void setFilesPriority(const QString &hash, const std::vector<int> &pp) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
data[hash].files_priority = pp; |
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
QStringList pieces_priority; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<int>::const_iterator pp_it = pp.begin(); |
|
|
|
|
|
|
|
std::vector<int>::const_iterator pp_itend = pp.end(); |
|
|
|
|
|
|
|
while(pp_it != pp_itend) { |
|
|
|
|
|
|
|
pieces_priority << QString::number(*pp_it); |
|
|
|
|
|
|
|
++pp_it; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
data["files_priority"] = pieces_priority; |
|
|
|
|
|
|
|
all_data[hash] = data; |
|
|
|
|
|
|
|
settings.setValue("torrents-tmp", all_data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setFilesPath(QString hash, const QStringList &path_list) { |
|
|
|
static void setFilesPath(const QString &hash, const QStringList &path_list) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
data[hash].path_list = path_list; |
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
data["files_path"] = path_list; |
|
|
|
|
|
|
|
all_data[hash] = data; |
|
|
|
|
|
|
|
settings.setValue("torrents-tmp", all_data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setSavePath(QString hash, QString save_path) { |
|
|
|
static void setSavePath(const QString &hash, const QString &save_path) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
data[hash].save_path = save_path; |
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
data["save_path"] = save_path; |
|
|
|
|
|
|
|
all_data[hash] = data; |
|
|
|
|
|
|
|
settings.setValue("torrents-tmp", all_data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setLabel(QString hash, QString label) { |
|
|
|
static void setLabel(const QString &hash, const QString &label) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
data[hash].label = label; |
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
qDebug("Saving label %s to tmp data", label.toLocal8Bit().data()); |
|
|
|
|
|
|
|
data["label"] = label; |
|
|
|
|
|
|
|
all_data[hash] = data; |
|
|
|
|
|
|
|
settings.setValue("torrents-tmp", all_data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setSequential(QString hash, bool sequential) { |
|
|
|
static void setSequential(const QString &hash, const bool &sequential) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
data[hash].sequential = sequential; |
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
data["sequential"] = sequential; |
|
|
|
|
|
|
|
all_data[hash] = data; |
|
|
|
|
|
|
|
settings.setValue("torrents-tmp", all_data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool isSequential(QString hash) { |
|
|
|
static bool isSequential(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
return data.value(hash).sequential; |
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
return data.value("sequential", false).toBool(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void setSeedingMode(QString hash,bool seed) { |
|
|
|
static void setSeedingMode(const QString &hash, const bool &seed) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
data[hash].seed = seed; |
|
|
|
QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
data["seeding"] = seed; |
|
|
|
|
|
|
|
all_data[hash] = data; |
|
|
|
|
|
|
|
settings.setValue("torrents-tmp", all_data); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static bool isSeedingMode(QString hash) { |
|
|
|
static bool isSeedingMode(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
return data.value(hash).seed; |
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
return data.value("seeding", false).toBool(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static QString getSavePath(QString hash) { |
|
|
|
static QString getSavePath(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
return data.value(hash).save_path; |
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
return data.value("save_path").toString(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static QStringList getFilesPath(QString hash) { |
|
|
|
static QStringList getFilesPath(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
return data.value(hash).path_list; |
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
return data.value("files_path").toStringList(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static QString getLabel(QString hash) { |
|
|
|
static QString getLabel(const QString &hash) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
return data.value(hash).label; |
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
qDebug("Got label %s from tmp data", data.value("label", "").toString().toLocal8Bit().data()); |
|
|
|
|
|
|
|
return data.value("label", "").toString(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void getFilesPriority(QString hash, std::vector<int> &fp) { |
|
|
|
static void getFilesPriority(const QString &hash, std::vector<int> &fp) { |
|
|
|
QIniSettings settings(QString::fromUtf8("qBittorrent"), QString::fromUtf8("qBittorrent-resume")); |
|
|
|
fp = data.value(hash).files_priority; |
|
|
|
const QHash<QString, QVariant> all_data = settings.value("torrents-tmp").toHash(); |
|
|
|
|
|
|
|
const QHash<QString, QVariant> data = all_data.value(hash).toHash(); |
|
|
|
|
|
|
|
const QList<int> list_var = misc::intListfromStringList(data.value("files_priority").toStringList()); |
|
|
|
|
|
|
|
foreach (const int &var, list_var) { |
|
|
|
|
|
|
|
fp.push_back(var); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
|
|
|
|
struct TorrentData { |
|
|
|
|
|
|
|
TorrentData(): sequential(false), seed(false) {} |
|
|
|
|
|
|
|
std::vector<int> files_priority; |
|
|
|
|
|
|
|
QStringList path_list; |
|
|
|
|
|
|
|
QString save_path; |
|
|
|
|
|
|
|
QString label; |
|
|
|
|
|
|
|
bool sequential; |
|
|
|
|
|
|
|
bool seed; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static QHash<QString, TorrentData> data; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
class TorrentPersistentData { |
|
|
|
class TorrentPersistentData { |
|
|
|