mirror of
https://github.com/transmission/transmission
synced 2024-12-23 00:04:06 +00:00
2b917de65b
This refactoring is driven by the need to be able to do true queued RPC calls (where each successive call uses the result of the previous). Currently, such queueing of requests is done by assigning them special "magic" tag numbers, which are then intercepted in one big switch() statement and acted upon. This (aside from making code greatly unclear) effectively makes each such queue a singleton, because state passing is restricted to global variables. We refactor RpcClient to assign an unique tag to each remote call, and then abstract all the call<->response matching with Qt's future/promise mechanism. Finally, we introduce a "RPC request queue" class (RpcQueue) which is built on top of QFutureWatcher and C++11's <functional> library. This class maintains a queue of functions, where each function receives an RPC response, does necessary processing, performs another call and finally returns its future.
42 lines
648 B
C++
42 lines
648 B
C++
/*
|
|
* This file Copyright (C) 2013-2016 Mnemosyne LLC
|
|
*
|
|
* It may be used under the GNU GPL versions 2 or 3
|
|
* or any future license endorsed by Mnemosyne LLC.
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <QLabel>
|
|
#include <QString>
|
|
#include <QTimer>
|
|
|
|
class Session;
|
|
|
|
extern "C"
|
|
{
|
|
struct tr_variant;
|
|
}
|
|
|
|
class FreeSpaceLabel: public QLabel
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
FreeSpaceLabel (QWidget * parent = nullptr);
|
|
virtual ~FreeSpaceLabel () {}
|
|
|
|
void setSession (Session& session);
|
|
void setPath (const QString& folder);
|
|
|
|
private slots:
|
|
void onTimer ();
|
|
|
|
private:
|
|
Session * mySession;
|
|
QString myPath;
|
|
QTimer myTimer;
|
|
};
|
|
|