Debian Codegraph @

liblomiri-app-launch/application-impl-snap.h

raw
1 /*
2 * Copyright © 2016 Canonical Ltd.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 3, as published
6 * by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranties of
10 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11 * PURPOSE. See the GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Ted Gould <[email protected]>
18 */
19
20 #include "application-impl-base.h"
21 #include "application-info-desktop.h"
22 #include "snapd-info.h"
23
24 #pragma once
25
26 namespace lomiri
27 {
28 namespace app_launch
29 {
30 namespace app_impls
31 {
32
33 /** Class implementing a Applications that are installed in the
34 system as Snaps. This class connects to snapd to get information
35 on the interfaces of the installed snaps and sees if any of them
36 are applicable to the user session. Currently that means if the
37 command has the mir, lomiri, unity7 or x11 interfaces.
38
39 For Application IDs snaps use a very similar scheme to Click
40 packages. The package field is the name of the snap package, typically
41 this is the overall application name. The appname is the command
42 in the snap package, which needs to be associated with one of our
43 supported interfaces and have a desktop file. Lastly the version
44 field is actually the snap revision, this value changes even on
45 updates between channels of the same version so it provides a
46 greater amount of uniqueness.
47 */
48 class Snap : public Base
49 {
50 public:
51 typedef std::tuple<app_info::Desktop::XMirEnable, Application::Info::LomiriLifecycle> InterfaceInfo;
52
53 Snap(const AppID& appid, const std::shared_ptr<Registry::Impl>& registry);
54 Snap(const AppID& appid, const std::shared_ptr<Registry::Impl>& registry, const InterfaceInfo& interfaceInfo);
55
56 static std::list<std::shared_ptr<Application>> list(const std::shared_ptr<Registry::Impl>& registry);
57
58 AppID appId() const override;
59
60 std::shared_ptr<Info> info() override;
61
62 std::vector<std::shared_ptr<Instance>> instances() override;
63
64 std::shared_ptr<Instance> launch(const std::vector<Application::URL>& urls = {}) override;
65 std::shared_ptr<Instance> launchTest(const std::vector<Application::URL>& urls = {}) override;
66
67 virtual std::shared_ptr<Application::Instance> findInstance(const std::string& instanceid) override;
68
69 static InterfaceInfo findInterfaceInfo(const AppID& appid, const std::shared_ptr<Registry::Impl>& registry);
70 static bool checkPkgInfo(const std::shared_ptr<snapd::Info::PkgInfo>& pkginfo, const AppID& appid);
71
72 private:
73 /** AppID of the Snap. Should be the name of the snap package.
74 The name of the command. And then the revision. */
75 AppID appid_;
76 /** The app's displayed information. Should be from a desktop
77 file that is put in ${SNAP_DIR}/meta/gui/${command}.desktop */
78 std::shared_ptr<app_info::Desktop> info_;
79 /** Information that we get from Snapd on the package */
80 std::shared_ptr<snapd::Info::PkgInfo> pkgInfo_;
81
82 std::list<std::pair<std::string, std::string>> launchEnv();
83 };
84
85 } // namespace app_impls
86 } // namespace app_launch
87 } // namespace lomiri