~ci-train-bot/ubuntu-app-launch/ubuntu-app-launch-ubuntu-zesty-2105

« back to all changes in this revision

Viewing changes to libubuntu-app-launch/application-impl-snap.cpp

  • Committer: Bileto Bot
  • Author(s): Ted Gould
  • Date: 2017-02-02 15:09:43 UTC
  • mfrom: (274.1.9 snap-select-u8)
  • Revision ID: ci-train-bot@canonical.com-20170202150943-184nho6mo20cg2bs
Prioritize 'unity8' interfaces over other supported interfaces

Approved by: Charles Kerr

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
 ** Interface Lists
35
35
 ************************/
36
36
 
37
 
/** All the interfaces that we support running applications with */
38
 
const std::set<std::string> SUPPORTED_INTERFACES{"unity8", "unity7", "x11"};
39
37
/** All the interfaces that we run XMir for by default */
40
38
const std::set<std::string> XMIR_INTERFACES{"unity7", "x11"};
41
39
/** All the interfaces that we tell Unity support lifecycle */
187
185
        }
188
186
        else
189
187
        {
190
 
            binname = appId_.package.value() + " " + appId_.appname.value();
 
188
            binname = appId_.package.value() + "." + appId_.appname.value();
191
189
        }
192
190
 
193
191
        binname = "/snap/bin/" + binname + " " + params;
241
239
{
242
240
}
243
241
 
 
242
/** Operator to compare apps for our sets */
 
243
struct appcompare
 
244
{
 
245
    bool operator()(const std::shared_ptr<Application>& a, const std::shared_ptr<Application>& b) const
 
246
    {
 
247
        return a->appId() < b->appId();
 
248
    }
 
249
};
 
250
 
244
251
/** Lists all the Snappy apps that are using one of our supported interfaces.
245
252
    Also makes sure they're valid.
246
253
 
248
255
*/
249
256
std::list<std::shared_ptr<Application>> Snap::list(const std::shared_ptr<Registry>& registry)
250
257
{
251
 
    std::list<std::shared_ptr<Application>> apps;
 
258
    std::set<std::shared_ptr<Application>, appcompare> apps;
252
259
 
253
 
    for (const auto& interface : SUPPORTED_INTERFACES)
254
 
    {
 
260
    auto addAppsForInterface = [&](const std::string& interface) {
255
261
        for (const auto& id : registry->impl->snapdInfo.appsForInterface(interface))
256
262
        {
257
263
            try
258
264
            {
259
265
                auto app = std::make_shared<Snap>(id, registry, interface);
260
 
                apps.emplace_back(app);
 
266
                apps.emplace(app);
261
267
            }
262
268
            catch (std::runtime_error& e)
263
269
            {
264
270
                g_debug("Unable to make Snap object for '%s': %s", std::string(id).c_str(), e.what());
265
271
            }
266
272
        }
267
 
    }
268
 
 
269
 
    return apps;
 
273
    };
 
274
 
 
275
    for (const auto& interface : LIFECYCLE_INTERFACES)
 
276
    {
 
277
        addAppsForInterface(interface);
 
278
    }
 
279
 
 
280
    /* If an app has both, this will get rejected */
 
281
    for (const auto& interface : XMIR_INTERFACES)
 
282
    {
 
283
        addAppsForInterface(interface);
 
284
    }
 
285
 
 
286
    return std::list<std::shared_ptr<Application>>(apps.begin(), apps.end());
270
287
}
271
288
 
272
289
/** Returns the stored AppID */
285
302
{
286
303
    auto ifaceset = registry->impl->snapdInfo.interfacesForAppId(appid);
287
304
 
288
 
    for (const auto& interface : SUPPORTED_INTERFACES)
 
305
    for (const auto& interface : LIFECYCLE_INTERFACES)
 
306
    {
 
307
        if (ifaceset.find(interface) != ifaceset.end())
 
308
        {
 
309
            return interface;
 
310
        }
 
311
    }
 
312
 
 
313
    for (const auto& interface : XMIR_INTERFACES)
289
314
    {
290
315
        if (ifaceset.find(interface) != ifaceset.end())
291
316
        {