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
19 #include <QFileInfoList>
20 #include <QNetworkAccessManager>
28 #include <libtransmission/transmission.h>
37 class Session
: public QObject
42 Session( const char * configDir
, Prefs
& prefs
);
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
; }
59 int64_t blocklistSize( ) const { return myBlocklistSize
; }
60 void setBlocklistSize( int64_t i
);
61 void updateBlocklist( );
63 void copyMagnetLinkToClipboard( int torrentId
);
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;
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 * );
80 void exec( const char * json
);
81 void exec( const struct tr_benc
* request
);
84 int64_t getUniqueTag( ) { return nextUniqueTag
++; }
87 void sessionSet( const char * key
, const QVariant
& variant
);
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( );
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
);
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
);
124 void onFinished( QNetworkReply
* reply
);
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( );
140 int64_t nextUniqueTag
;
141 int64_t myBlocklistSize
;
143 tr_session
* mySession
;
147 QNetworkAccessManager
* myNAM
;
148 struct tr_session_stats myStats
;
149 struct tr_session_stats myCumulativeStats
;
150 QString mySessionVersion
;