~michihenning/storage-framework/stand-alone-provider-headers

« back to all changes in this revision

Viewing changes to src/qt/client/internal/remote_client/RuntimeImpl.cpp

  • Committer: Michi Henning
  • Date: 2016-08-23 23:45:34 UTC
  • mfrom: (53.1.4 devel)
  • Revision ID: michi.henning@canonical.com-20160823234534-4owayhnhcp67g39q
Merged devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
 
45
45
namespace
46
46
{
47
 
constexpr char BUS_NAME[] = "com.canonical.StorageFramework.Provider.ProviderTest";
48
 
}
 
47
 
 
48
static const map<QString, QString> BUS_NAMES =
 
49
{
 
50
    { "google-drive-scope", "com.canonical.StorageFramework.Provider.ProviderTest" },
 
51
    { "com.canonical.scopes.mcloud_mcloud_mcloud", "com.canonical.StorageFramework.Provider.McloudProvider" }
 
52
};
 
53
 
 
54
}  // namespace
49
55
 
50
56
namespace unity
51
57
{
78
84
        shutdown();
79
85
    }
80
86
    // LCOV_EXCL_START
81
 
    catch (std::exception const&)
 
87
    catch (std::exception const& e)
82
88
    {
83
 
        qCritical() << "shutdown error";  // TODO, log the error properly
 
89
        qCritical() << "shutdown error" << e.what();
84
90
    }
85
91
    // LCOV_EXCL_STOP
86
92
}
124
130
{
125
131
    if (destroyed_)
126
132
    {
 
133
        // LCOV_EXCL_START
127
134
        make_exceptional_future(qf_, RuntimeDestroyedException("Runtime::accounts()"));
128
135
        return;
 
136
        // LCOV_EXCL_STOP
129
137
    }
130
138
 
131
139
    timer_.stop();
132
140
 
133
 
    static QString const service_ids[] = { "com.canonical.scopes.mcloud_mcloud_mcloud", "google-drive-scope" };
134
 
 
135
141
    try
136
142
    {
137
143
        QVector<Account::SPtr> accounts;
138
 
        for (auto const service_id : service_ids)
 
144
        for (auto const map_entry : BUS_NAMES)
139
145
        {
 
146
            auto service_id = map_entry.first;
140
147
            for (auto const& a : manager_->availableAccounts(service_id))
141
148
            {
142
 
                qDebug() << "got account:" << a->displayName() << a->serviceId() << a->id();
143
149
                auto object_path = QStringLiteral("/provider/%1").arg(a->id());
144
 
                accounts.append(make_account(BUS_NAME, object_path,
145
 
                                             "", a->serviceId(), a->displayName()));
 
150
                try
 
151
                {
 
152
                    auto bus_name = map_entry.second;
 
153
                    accounts.append(make_account(bus_name, object_path,
 
154
                                                 "", a->serviceId(), a->displayName()));
 
155
 
 
156
                }
 
157
                catch (LocalCommsException const& e)
 
158
                {
 
159
                    qDebug() << "RuntimeImpl: ignoring non-existent provider" << a->serviceId();
 
160
                }
146
161
            }
147
162
        }
148
163
        accounts_ = accounts;
149
164
        make_ready_future(qf_, accounts);
150
165
    }
 
166
    // LCOV_EXCL_START
151
167
    catch (StorageException const& e)
152
168
    {
153
169
        make_exceptional_future(qf_, e);
154
170
    }
 
171
    // LCOV_EXCL_STOP
155
172
}
156
173
 
 
174
// LCOV_EXCL_START
157
175
void RuntimeImpl::timeout()
158
176
{
159
177
    make_exceptional_future(qf_, ResourceException("Runtime::accounts(): timeout retrieving Online accounts", 0));
160
178
}
 
179
// LCOV_EXCL_STOP
161
180
 
162
181
shared_ptr<Account> RuntimeImpl::make_test_account(QString const& bus_name,
163
182
                                                   QString const& object_path)