diff options
author | Krzesimir Nowak <krnowak@openismus.com> | 2012-02-06 16:48:47 +0100 |
---|---|---|
committer | Patrick Ohly <patrick.ohly@intel.com> | 2012-02-17 15:34:15 +0100 |
commit | 58f3a95fb5e5b154db7d17c10d574a0cfccb64cc (patch) | |
tree | c54d367794c5b3fb709fbdf36faa6dbd0f935070 /src/syncevo/LocalTransportAgent.cpp | |
parent | 3acc51416c83a0f96e0a107d040fd99e2c93eb29 (diff) |
GDBus libdbus+GIO: support blocking D-Bus calls
The call operator on DBusClientCall[0123] is now blocking. It will
return result values as single value, std::pair or boost::tuple,
respectively. If an error is encountered either locally or in the
peer, a runtime_error is thrown.
This is an API change. The traditional implementation was to start an
asynchronous call. That is still possible, but has to be requested
explicitly with the new start() method.
This distinction is necessary because C++ cannot guess (easily)
whether the callback parameter is a callback type or another parameter
for the D-Bus peer. It's also a bit cleaner in the source code because
now the call operator really acts like a normal, synchronous call.
The downside of the synchronous calls is that complex return values
have to be copied more often. If that is too expensive, then use the
asynchronous start() + callback approach.
Diffstat (limited to 'src/syncevo/LocalTransportAgent.cpp')
-rw-r--r-- | src/syncevo/LocalTransportAgent.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/syncevo/LocalTransportAgent.cpp b/src/syncevo/LocalTransportAgent.cpp index 2e309d23..aeeba529 100644 --- a/src/syncevo/LocalTransportAgent.cpp +++ b/src/syncevo/LocalTransportAgent.cpp @@ -225,16 +225,16 @@ void LocalTransportAgent::onChildConnect(const GDBusCXX::DBusConnectionPtr &conn sources[sourceName] = std::make_pair(targetName, sync); } } - m_child->m_startSync(m_clientContext, - StringPair(m_server->getConfigName(), - m_server->getRootPath()), - static_cast<std::string>(m_server->getLogDir()), - m_server->getDoLogging(), - StringPair(m_server->getSyncUsername(), - m_server->getSyncPassword()), - m_server->getConfigProps(), - sources, - boost::bind(&LocalTransportAgent::storeReplyMsg, this, _1, _2, _3)); + m_child->m_startSync.start(m_clientContext, + StringPair(m_server->getConfigName(), + m_server->getRootPath()), + static_cast<std::string>(m_server->getLogDir()), + m_server->getDoLogging(), + StringPair(m_server->getSyncUsername(), + m_server->getSyncPassword()), + m_server->getConfigProps(), + sources, + boost::bind(&LocalTransportAgent::storeReplyMsg, this, _1, _2, _3)); } void LocalTransportAgent::onFailure(const std::string &error) @@ -326,8 +326,8 @@ void LocalTransportAgent::send(const char *data, size_t len) { if (m_child) { m_status = ACTIVE; - m_child->m_sendMsg(m_contentType, GDBusCXX::makeDBusArray(len, (uint8_t *)(data)), - boost::bind(&LocalTransportAgent::storeReplyMsg, this, _1, _2, _3)); + m_child->m_sendMsg.start(m_contentType, GDBusCXX::makeDBusArray(len, (uint8_t *)(data)), + boost::bind(&LocalTransportAgent::storeReplyMsg, this, _1, _2, _3)); } else { m_status = FAILED; SE_THROW_EXCEPTION(TransportException, @@ -445,9 +445,9 @@ public: passwordName.c_str(), descr.c_str()); std::string password; - m_parent->m_askPassword(passwordName, descr, key, - boost::bind(&LocalTransportContext::storePassword, this, - boost::ref(password), _1, _2)); + m_parent->m_askPassword.start(passwordName, descr, key, + boost::bind(&LocalTransportContext::storePassword, this, + boost::ref(password), _1, _2)); g_main_loop_run(m_loop.get()); return password; } @@ -793,8 +793,8 @@ public: if (m_parent) { std::string report = m_clientReport.toString(); SE_LOG_DEBUG(NULL, NULL, "child sending sync report after failure:\n%s", report.c_str()); - m_parent->m_storeSyncReport(report, - boost::bind(&LocalTransportAgentChild::syncReportReceived, this, _1)); + m_parent->m_storeSyncReport.start(report, + boost::bind(&LocalTransportAgentChild::syncReportReceived, this, _1)); // wait for acknowledgement for report once: // we are in some kind of error state, better // do not wait too long @@ -810,8 +810,8 @@ public: // send final report, ignore result std::string report = m_clientReport.toString(); SE_LOG_DEBUG(NULL, NULL, "child sending sync report:\n%s", report.c_str()); - m_parent->m_storeSyncReport(report, - boost::bind(&LocalTransportAgentChild::syncReportReceived, this, _1)); + m_parent->m_storeSyncReport.start(report, + boost::bind(&LocalTransportAgentChild::syncReportReceived, this, _1)); while (!m_reportSent && m_parent) { SE_LOG_DEBUG(NULL, NULL, "waiting for parent's ACK for sync report"); g_main_loop_run(m_loop.get()); |