source: trunk/qt/RpcClient.h @ 14608

Last change on this file since 14608 was 14608, checked in by jordan, 6 years ago

(trivial) remove trailing semicolon after Q_DECLARE_METATYPE

  • Property svn:keywords set to Date Rev Author Id
File size: 1.8 KB
Line 
1/*
2 * This file Copyright (C) 2014-2015 Mnemosyne LLC
3 *
4 * It may be used under the GNU GPL versions 2 or 3
5 * or any future license endorsed by Mnemosyne LLC.
6 *
7 * $Id: RpcClient.h 14608 2015-12-06 17:28:54Z jordan $
8 */
9
10#ifndef QTR_RPC_CLIENT_H
11#define QTR_RPC_CLIENT_H
12
13#include <memory>
14
15#include <QNetworkReply>
16#include <QObject>
17#include <QString>
18#include <QUrl>
19
20#include <libtransmission/transmission.h>
21#include <libtransmission/quark.h>
22#include <libtransmission/variant.h>
23
24class QByteArray;
25class QNetworkAccessManager;
26
27typedef std::shared_ptr<tr_variant> TrVariantPtr;
28Q_DECLARE_METATYPE (TrVariantPtr)
29
30extern "C"
31{
32  struct evbuffer;
33  struct tr_session;
34}
35
36class RpcClient: public QObject
37{
38    Q_OBJECT
39
40  public:
41    RpcClient (QObject * parent = nullptr);
42    virtual ~RpcClient () {}
43
44    void stop ();
45    void start (tr_session * session);
46    void start (const QUrl& url);
47
48    bool isLocal () const;
49    const QUrl& url () const;
50
51    void exec (tr_quark method, tr_variant * args, int64_t tag = -1);
52    void exec (const char* method, tr_variant * args, int64_t tag = -1);
53
54  signals:
55    void httpAuthenticationRequired ();
56    void dataReadProgress ();
57    void dataSendProgress ();
58    void error (QNetworkReply::NetworkError code);
59    void errorMessage (const QString& message);
60    void executed (int64_t tag, const QString& result, tr_variant * args);
61
62    // private
63    void responseReceived (TrVariantPtr json);
64
65  private:
66    void sendRequest (TrVariantPtr json);
67    QNetworkAccessManager * networkAccessManager ();
68
69    static void localSessionCallback (tr_session * s, tr_variant * response, void * vself);
70
71  private slots:
72    void onFinished (QNetworkReply * reply);
73    void parseResponse (TrVariantPtr json);
74
75  private:
76    tr_session * mySession;
77    QString mySessionId;
78    QUrl myUrl;
79    QNetworkAccessManager * myNAM;
80};
81
82#endif // QTR_RPC_CLIENT_H
Note: See TracBrowser for help on using the repository browser.