Debian Codegraph @

liblomiri-app-launch/application-impl-click.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
23 #include <gio/gdesktopappinfo.h>
24 #include <json-glib/json-glib.h>
25
26 #pragma once
27
28 namespace lomiri
29 {
30 namespace app_launch
31 {
32 namespace app_info
33 {
34 class Desktop;
35 }
36 namespace app_impls
37 {
38
39 /** Application Implmentation for Click packages. Click packages
40 are installed via the click tool and have information avaialable
41 on them via libclick. There is one version per-user on the system
42 and a Lomiri App Launch hook makes a link to each of those versions
43 in the user's cache directory. Click ensures this is up-to-date.
44
45 Application IDs for Click packages are the standard it was built on.
46 Typically a package name is "$(application).$(developer id)" though
47 there isn't a requirement in the local Click tools to require that. The
48 appname element is gotten from the JSON manifest in the Click package and
49 should reference a desktop file. All Click packages also have a version.
50
51 More info: http://click.readthedocs.io/
52 */
53 class Click : public Base
54 {
55 public:
56 Click(const AppID& appid, const std::shared_ptr<Registry::Impl>& registry);
57 Click(const AppID& appid, const std::shared_ptr<JsonObject>& manifest, const std::shared_ptr<Registry::Impl>& registry);
58
59 AppID appId() const override;
60
61 std::shared_ptr<Info> info() override;
62
63 std::vector<std::shared_ptr<Instance>> instances() override;
64
65 std::shared_ptr<Instance> launch(const std::vector<Application::URL>& urls = {}) override;
66 std::shared_ptr<Instance> launchTest(const std::vector<Application::URL>& urls = {}) override;
67
68 virtual std::shared_ptr<Application::Instance> findInstance(const std::string& instanceid) override;
69
70 private:
71 AppID _appid;
72
73 std::shared_ptr<JsonObject> _manifest;
74
75 std::string _clickDir;
76 std::shared_ptr<GKeyFile> _keyfile;
77 std::string desktopPath_;
78
79 std::shared_ptr<app_info::Desktop> _info;
80
81 std::list<std::pair<std::string, std::string>> launchEnv();
82 };
83
84 } // namespace app_impls
85 } // namespace app_launch
86 } // namespace lomiri