File: ktcli.h

package info (click to toggle)
libktorrent 25.04.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,948 kB
  • sloc: cpp: 40,776; makefile: 7; sh: 3
file content (52 lines) | stat: -rw-r--r-- 1,177 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
    SPDX-FileCopyrightText: 2010 Joris Guisson <joris.guisson@gmail.com>

    SPDX-License-Identifier: GPL-2.0-or-later
*/

#ifndef KTCLI_H
#define KTCLI_H

#include <QCommandLineParser>
#include <QCoreApplication>
#include <QTimer>
#include <interfaces/queuemanagerinterface.h>
#include <torrent/torrentcontrol.h>

class QUrl;

typedef std::unique_ptr<bt::TorrentControl> TorrentControlPtr;

class KTCLI : public QCoreApplication, public bt::QueueManagerInterface
{
    Q_OBJECT
public:
    KTCLI(int argc, char **argv);
    ~KTCLI() override;

    /// Start downloading
    bool start();

private:
    QString tempDir();
    bool load(const QUrl &url);
    bool loadFromFile(const QString &path);
    bool loadFromDir(const QString &path);

    bool notify(QObject *obj, QEvent *ev) override;
    bool alreadyLoaded(const bt::SHA1Hash &ih) const override;
    void mergeAnnounceList(const bt::SHA1Hash &ih, const bt::TrackerTier *trk) override;

public Q_SLOTS:
    void update();
    void finished(bt::TorrentInterface *tor);
    void shutdown();

private:
    QCommandLineParser parser;
    QTimer timer;
    TorrentControlPtr tc;
    int updates;
};

#endif // KTCLI_H