1
#include "ProviderEnvironment.h"
6
using namespace unity::storage::provider;
7
using namespace unity::storage::qt::client;
12
const auto SERVICE_CONNECTION_NAME = QStringLiteral("service-session-bus");
13
const auto OBJECT_PATH = QStringLiteral("/provider");
17
ProviderEnvironment::ProviderEnvironment(unique_ptr<ProviderBase>&& provider,
18
OnlineAccounts::AccountId account_id,
19
DBusEnvironment const& dbus_env)
21
client_connection_.reset(new QDBusConnection(dbus_env.connection()));
22
server_connection_.reset(new QDBusConnection(
23
QDBusConnection::connectToBus(dbus_env.busAddress(),
24
SERVICE_CONNECTION_NAME)));
26
account_manager_.reset(new OnlineAccounts::Manager("", *server_connection_));
27
account_manager_->waitForReady();
28
OnlineAccounts::Account* account = account_manager_->account(account_id);
29
assert(account != nullptr);
30
server_.reset(new testing::TestServer(move(provider), account,
32
OBJECT_PATH.toStdString()));
34
client_runtime_ = Runtime::create(*client_connection_);
35
client_account_ = client_runtime_->make_test_account(server_connection_->baseService(), OBJECT_PATH);
38
ProviderEnvironment::~ProviderEnvironment()
40
client_account_.reset();
41
client_runtime_->shutdown();
42
client_runtime_.reset();
45
account_manager_.reset();
47
server_connection_.reset();
48
QDBusConnection::disconnectFromBus(SERVICE_CONNECTION_NAME);
49
client_connection_.reset();
52
shared_ptr<Account> ProviderEnvironment::get_client() const
54
return client_account_;