Revert "transmission: update from 2.13 to 2.22"
[tomato.git] / release / src / router / transmission / qt / session.h
blobdfe186858332caf9d32ce2815806aa087e5c2e07
1 /*
2 * This file Copyright (C) Mnemosyne LLC
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2
6 * as published by the Free Software Foundation.
8 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10 * $Id: session.h 11209 2010-09-14 06:23:48Z Longinus00 $
13 #ifndef TR_APP_SESSION_H
14 #define TR_APP_SESSION_H
16 #include <QObject>
17 #include <QSet>
18 #include <QBuffer>
19 #include <QFileInfoList>
20 #include <QNetworkAccessManager>
21 #include <QString>
22 #include <QUrl>
24 class QStringList;
26 class AddData;
28 #include <libtransmission/transmission.h>
30 extern "C"
32 struct tr_benc;
35 class Prefs;
37 class Session: public QObject
39 Q_OBJECT
41 public:
42 Session( const char * configDir, Prefs& prefs );
43 ~Session( );
45 public:
46 void stop( );
47 void restart( );
49 private:
50 void start( );
52 public:
53 const QUrl& getRemoteUrl( ) const { return myUrl; }
54 const struct tr_session_stats& getStats( ) const { return myStats; }
55 const struct tr_session_stats& getCumulativeStats( ) const { return myCumulativeStats; }
56 const QString& sessionVersion( ) const { return mySessionVersion; }
58 public:
59 int64_t blocklistSize( ) const { return myBlocklistSize; }
60 void setBlocklistSize( int64_t i );
61 void updateBlocklist( );
62 void portTest( );
63 void copyMagnetLinkToClipboard( int torrentId );
65 public:
67 /** returns true if the transmission session is being run inside this client */
68 bool isServer( ) const;
70 /** returns true if isServer() is true or if the remote address is the localhost */
71 bool isLocal( ) const;
73 private:
74 void updateStats( struct tr_benc * args );
75 void updateInfo( struct tr_benc * args );
76 void parseResponse( const char * json, size_t len );
77 static void localSessionCallback( tr_session *, const char *, size_t, void * );
79 public:
80 void exec( const char * json );
81 void exec( const struct tr_benc * request );
83 public:
84 int64_t getUniqueTag( ) { return nextUniqueTag++; }
86 private:
87 void sessionSet( const char * key, const QVariant& variant );
88 void pumpRequests( );
89 void sendTorrentRequest( const char * request, const QSet<int>& torrentIds );
90 static void updateStats( struct tr_benc * d, struct tr_session_stats * stats );
91 void refreshTorrents( const QSet<int>& torrentIds );
92 QNetworkAccessManager * networkAccessManager( );
94 public:
95 void torrentSet( const QSet<int>& ids, const QString& key, bool val );
96 void torrentSet( const QSet<int>& ids, const QString& key, int val );
97 void torrentSet( const QSet<int>& ids, const QString& key, double val );
98 void torrentSet( const QSet<int>& ids, const QString& key, const QList<int>& val );
99 void torrentSet( const QSet<int>& ids, const QString& key, const QStringList& val );
100 void torrentSet( const QSet<int>& ids, const QString& key, const QPair<int,QString>& val);
101 void torrentSetLocation( const QSet<int>& ids, const QString& path, bool doMove );
104 public slots:
105 void pauseTorrents( const QSet<int>& torrentIds = QSet<int>() );
106 void startTorrents( const QSet<int>& torrentIds = QSet<int>() );
107 void refreshSessionInfo( );
108 void refreshSessionStats( );
109 void refreshActiveTorrents( );
110 void refreshAllTorrents( );
111 void initTorrents( const QSet<int>& ids = QSet<int>() );
112 void addNewlyCreatedTorrent( const QString& filename, const QString& localPath );
113 void addTorrent( const AddData& addme );
114 void removeTorrents( const QSet<int>& torrentIds, bool deleteFiles=false );
115 void verifyTorrents( const QSet<int>& torrentIds );
116 void reannounceTorrents( const QSet<int>& torrentIds );
117 void launchWebInterface( );
118 void updatePref( int key );
120 /** request a refresh for statistics, including the ones only used by the properties dialog, for a specific torrent */
121 void refreshExtraStats( const QSet<int>& ids );
123 private slots:
124 void onFinished( QNetworkReply * reply );
126 signals:
127 void executed( int64_t tag, const QString& result, struct tr_benc * arguments );
128 void sourceChanged( );
129 void portTested( bool isOpen );
130 void statsUpdated( );
131 void sessionUpdated( );
132 void blocklistUpdated( int );
133 void torrentsUpdated( struct tr_benc * torrentList, bool completeList );
134 void torrentsRemoved( struct tr_benc * torrentList );
135 void dataReadProgress( );
136 void dataSendProgress( );
137 void httpAuthenticationRequired( );
139 private:
140 int64_t nextUniqueTag;
141 int64_t myBlocklistSize;
142 Prefs& myPrefs;
143 tr_session * mySession;
144 QString myConfigDir;
145 QString mySessionId;
146 QUrl myUrl;
147 QNetworkAccessManager * myNAM;
148 struct tr_session_stats myStats;
149 struct tr_session_stats myCumulativeStats;
150 QString mySessionVersion;
153 #endif