Debian Codegraph @

liblomiri-app-launch/application-impl-libertine.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 #pragma once
20
21 #ifdef HAVE_LIBERTINE
22
23 #include "application-impl-base.h"
24 #include "application-info-desktop.h"
25 #include <gio/gdesktopappinfo.h>
26
27 namespace lomiri
28 {
29 namespace app_launch
30 {
31 namespace app_impls
32 {
33
34 /** Application Implementation for the Libertine container system. Libertine
35 sets up containers that are read/write on a read only system, to all for
36 more dynamic packaging systems (like deb) to work. This provides some
37 compatibility for older applications or those who are only distributed in
38 packaging systems requiring full system access.
39
40 Application IDs for Libertine applications have the package field as the
41 name of the container. The appname is similar to that of the Legacy() implementation
42 as the filename of the desktop file defining the application without the
43 ".desktop" suffix. UAL has no way to know the version, so it is always hard
44 coded to "0.0".
45
46 Libertine applications are always started using the libertine-launch
47 utility which configures the environment for the container.
48
49 More info: https://wiki.lomiri.com/Touch/Libertine
50 */
51 class Libertine : public Base
52 {
53 public:
54 Libertine(const AppID::Package& container,
55 const AppID::AppName& appname,
56 const std::shared_ptr<Registry::Impl>& registry);
57
58 AppID appId() const override
59 {
60 return {_container, _appname, AppID::Version::from_raw("0.0")};
61 }
62
63 std::shared_ptr<Info> info() override;
64
65 std::vector<std::shared_ptr<Instance>> instances() override;
66
67 std::shared_ptr<Instance> launch(const std::vector<Application::URL>& urls = {}) override;
68 std::shared_ptr<Instance> launchTest(const std::vector<Application::URL>& urls = {}) override;
69
70 virtual std::shared_ptr<Application::Instance> findInstance(const std::string& instanceid) override;
71
72 private:
73 AppID::Package _container;
74 AppID::AppName _appname;
75 std::string _container_path;
76 std::shared_ptr<GKeyFile> _keyfile;
77 std::string _basedir;
78 std::shared_ptr<app_info::Desktop> appinfo_;
79
80 std::list<std::pair<std::string, std::string>> launchEnv();
81 static std::shared_ptr<GKeyFile> keyfileFromPath(const std::string& pathname);
82 static std::shared_ptr<GKeyFile> findDesktopFile(const std::string& basepath,
83 const std::string& subpath,
84 const std::string& filename);
85 };
86
87 } // namespace app_impls
88 } // namespace app_launch
89 } // namespace lomiri
90
91 #endif // HAVE_LIBERTINE