mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
fix(sharedstate): Pass success/failure with QFuture
This commit is contained in:
@@ -45,7 +45,7 @@ namespace BlackMisc
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
//! Get a duplex object for the calling process.
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<void>> getDuplex(const CIdentifier &) = 0;
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<bool>> getDuplex(const CIdentifier &) = 0;
|
||||
|
||||
public slots:
|
||||
//! Create a duplex object for the identified process.
|
||||
@@ -56,7 +56,7 @@ namespace BlackMisc
|
||||
|
||||
protected:
|
||||
//! Create a duplex object and return status via future.
|
||||
virtual QFuture<void> openDuplexAsync(const CIdentifier &client) = 0;
|
||||
virtual QFuture<bool> openDuplexAsync(const CIdentifier &client) = 0;
|
||||
|
||||
//! Constructor.
|
||||
IHub(QObject *parent = nullptr);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BlackMisc::SharedState::DBus
|
||||
if (server) { server->addObject(BLACKMISC_HUB_PATH, this); }
|
||||
}
|
||||
|
||||
std::pair<QSharedPointer<IDuplex>, QFuture<void>> CHub::getDuplex(const CIdentifier &identifier)
|
||||
std::pair<QSharedPointer<IDuplex>, QFuture<bool>> CHub::getDuplex(const CIdentifier &identifier)
|
||||
{
|
||||
auto future = openDuplexAsync(identifier);
|
||||
return std::make_pair(m_clients.value(identifier), future);
|
||||
@@ -37,12 +37,12 @@ namespace BlackMisc::SharedState::DBus
|
||||
m_clients.take(client);
|
||||
}
|
||||
|
||||
QFuture<void> CHub::openDuplexAsync(const CIdentifier &client)
|
||||
QFuture<bool> CHub::openDuplexAsync(const CIdentifier &client)
|
||||
{
|
||||
openDuplex(client);
|
||||
|
||||
CPromise<void> promise;
|
||||
promise.setResult();
|
||||
CPromise<bool> promise;
|
||||
promise.setResult(true);
|
||||
return promise.future();
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace BlackMisc
|
||||
//! \name Interface implementations
|
||||
//! @{
|
||||
virtual bool isConnected() const override { return true; }
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<void>> getDuplex(const CIdentifier &) override;
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<bool>> getDuplex(const CIdentifier &) override;
|
||||
//! @}
|
||||
|
||||
public slots:
|
||||
@@ -57,7 +57,7 @@ namespace BlackMisc
|
||||
protected:
|
||||
//! \name Interface implementations
|
||||
//! @{
|
||||
virtual QFuture<void> openDuplexAsync(const CIdentifier &client) override;
|
||||
virtual QFuture<bool> openDuplexAsync(const CIdentifier &client) override;
|
||||
//! @}
|
||||
|
||||
private:
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace BlackMisc::SharedState::DBus
|
||||
return m_interface->isValid();
|
||||
}
|
||||
|
||||
std::pair<QSharedPointer<IDuplex>, QFuture<void>> CHubProxy::getDuplex(const CIdentifier &identifier)
|
||||
std::pair<QSharedPointer<IDuplex>, QFuture<bool>> CHubProxy::getDuplex(const CIdentifier &identifier)
|
||||
{
|
||||
auto duplex = QSharedPointer<CDuplexProxy>::create(m_interface->connection(), m_service, this);
|
||||
connect(duplex.get(), &QObject::destroyed, this, [=] { closeDuplex(identifier); });
|
||||
@@ -39,7 +39,7 @@ namespace BlackMisc::SharedState::DBus
|
||||
m_interface->callDBus(QLatin1String("closeDuplex"), client);
|
||||
}
|
||||
|
||||
QFuture<void> CHubProxy::openDuplexAsync(const CIdentifier &client)
|
||||
QFuture<bool> CHubProxy::openDuplexAsync(const CIdentifier &client)
|
||||
{
|
||||
return m_interface->callDBusFuture<bool>(QLatin1String("openDuplex"), client);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace BlackMisc
|
||||
//! \name Interface implementations
|
||||
//! @{
|
||||
virtual bool isConnected() const override;
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<void>> getDuplex(const CIdentifier &) override;
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<bool>> getDuplex(const CIdentifier &) override;
|
||||
//! @}
|
||||
|
||||
public slots:
|
||||
@@ -50,7 +50,7 @@ namespace BlackMisc
|
||||
protected:
|
||||
//! \name Interface implementations
|
||||
//! @{
|
||||
virtual QFuture<void> openDuplexAsync(const CIdentifier &client) override;
|
||||
virtual QFuture<bool> openDuplexAsync(const CIdentifier &client) override;
|
||||
//! @}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user