Merge lp:~ted/ubuntu-app-launch/registry-cleanup into lp:ubuntu-app-launch
- registry-cleanup
- Merge into trunk.17.04
Status: | Merged |
---|---|
Approved by: | Charles Kerr |
Approved revision: | 328 |
Merged at revision: | 310 |
Proposed branch: | lp:~ted/ubuntu-app-launch/registry-cleanup |
Merge into: | lp:ubuntu-app-launch |
Diff against target: |
4035 lines (+920/-965) 40 files modified
libubuntu-app-launch/app-store-base.cpp (+8/-8) libubuntu-app-launch/app-store-base.h (+13/-15) libubuntu-app-launch/app-store-legacy.cpp (+14/-18) libubuntu-app-launch/app-store-legacy.h (+8/-15) libubuntu-app-launch/app-store-libertine.cpp (+13/-17) libubuntu-app-launch/app-store-libertine.h (+8/-15) libubuntu-app-launch/app-store-snap.cpp (+19/-23) libubuntu-app-launch/app-store-snap.h (+8/-15) libubuntu-app-launch/application-impl-base.cpp (+2/-2) libubuntu-app-launch/application-impl-base.h (+10/-10) libubuntu-app-launch/application-impl-legacy.cpp (+8/-8) libubuntu-app-launch/application-impl-legacy.h (+1/-1) libubuntu-app-launch/application-impl-libertine.cpp (+8/-8) libubuntu-app-launch/application-impl-libertine.h (+1/-1) libubuntu-app-launch/application-impl-snap.cpp (+13/-13) libubuntu-app-launch/application-impl-snap.h (+4/-4) libubuntu-app-launch/application-info-desktop.cpp (+3/-3) libubuntu-app-launch/application-info-desktop.h (+5/-3) libubuntu-app-launch/application.cpp (+45/-34) libubuntu-app-launch/helper-impl.h (+2/-2) libubuntu-app-launch/helper.cpp (+15/-17) libubuntu-app-launch/info-watcher-zg.cpp (+1/-1) libubuntu-app-launch/info-watcher-zg.h (+1/-1) libubuntu-app-launch/info-watcher.cpp (+16/-2) libubuntu-app-launch/info-watcher.h (+10/-1) libubuntu-app-launch/jobs-base.cpp (+98/-118) libubuntu-app-launch/jobs-base.h (+33/-26) libubuntu-app-launch/jobs-systemd.cpp (+312/-352) libubuntu-app-launch/jobs-systemd.h (+6/-2) libubuntu-app-launch/registry-impl.cpp (+34/-16) libubuntu-app-launch/registry-impl.h (+52/-22) libubuntu-app-launch/registry.cpp (+27/-49) libubuntu-app-launch/registry.h (+6/-4) tests/application-info-desktop.cpp (+2/-2) tests/info-watcher-zg.cpp (+2/-3) tests/jobs-base-test.cpp (+2/-2) tests/jobs-systemd.cpp (+26/-22) tests/libual-cpp-test.cc (+40/-49) tests/list-apps.cpp (+6/-6) tests/registry-mock.h (+38/-55) |
To merge this branch: | bzr merge lp:~ted/ubuntu-app-launch/registry-cleanup |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
unity-api-1-bot | continuous-integration | Approve | |
Charles Kerr (community) | Approve | ||
James Henstridge | Abstain | ||
Review via email: mp+321240@code.launchpad.net |
Commit message
Cleanup registry references to make them consistent
Description of the change
Basically all this branch is doing is getting rid of the std::shared_
For anything that leaves the protection of the UAL API it keeps a reference to the Registry::Impl object and can use that to reference the internal structures. Everything else is just getting a Registry& to be able to find stuff again.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:318
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
James Henstridge (jamesh) wrote : | # |
I don't really know this code base, but seeing a merge that converts a bunch of smart pointers into raw pointers (which is essentially what these reference variables are) raises some red flags.
Is there a guarantee that all instances of these classes will be destroyed before the associated Registry instance? If not, you're just replacing indeterminate cleanup of the registry object for dangling pointers.
Some alternatives that might do what you want include:
1. add a shutdown() method that will do the cleanup, and then in other classes check to see if the registry has been shut down before using it.
2. use std::weak_ptr, so these other classes won't keep the registry alive, but also won't leave a dangling reference.
It's a bit hard to say what would be appropriate without looking into it more.
Ted Gould (ted) wrote : | # |
Yes, generally that is the case. Here we're talking about all objects that are owned directly by the object that is the raw pointer. Their lifecycle is guaranteed to be shorter than it.
For objects that could have a longer lifecycle than the Registry object we're using the smart pointer on the implementation to keep track of the resources.
The problem the smartpointers were causing is that they make it so the initialization is funky. You don't have the smart pointer until after the objects is initialized, so objects that are created during its initialization could take the smart pointer as a parameter. So to resolve that we had lazy initialization of the objects which was basically spaghetti all over the codebase. And that is what caused the linked bug, a path that didn't lazy initialize all the subobjects that were needed.
- 319. By Ted Gould
-
Make it so that we don't set all the objects on init of Impl, just with setters and getters in the Registry object.
- 320. By Ted Gould
-
Switch the jobs over to smart pointers
- 321. By Ted Gould
-
Switch App Stores over to using smart poitners
- 322. By Ted Gould
-
Now that the Impl is ready at init we can get the bus then too
- 323. By Ted Gould
-
Adapt tests to changes
- 324. By Ted Gould
-
Clean up the handling of the ZG Watcher
- 325. By Ted Gould
-
Fix zgwatcher setup
- 326. By Ted Gould
-
Ensure the jobs-systemd tests have a legacy appstore to use
- 327. By Ted Gould
-
Change around the zgWatcher and realize the test is really just a placeholder
unity-api-1-bot (unity-api-1-bot) wrote : | # |
FAILED: Continuous integration, rev:327
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
James Henstridge (jamesh) wrote : | # |
Having objects that aren't fully constructed by their constructor can make it difficult to reason about code, so it'd be good to avoid that if at all possible.
If all you need is for a class to be able to create a shared pointer of itself, then std::enable_
http://
There are a few caveats though:
1. You probably don't want to be using shared_from_this() from within the constructor if the constructor can throw an exception: then the object in the shared pointer will be destroyed.
2. You want to make sure the class is always instantiated into a shared pointer. Making the constructor private and offering a factory function to create a shared_ptr is one way to handle this.
Ted Gould (ted) wrote : | # |
Cool, I didn't know about that, and it would help in some situations. I was able to put the smart pointers back in most cases by using a two-stage init of the implementation object. Since it's only created once, and in private code, it's an easy one to do that with and actually solves all the issues in this (rather small) codebase.
Thanks for pushing me to fix it.
Charles Kerr (charlesk) wrote : | # |
This patch is a little confusing.
I don't think I understand the problem enough. It sounds like you're saying a second registry was created because of cyclical instantiation?
If that's the case, some of these changes seem arbitrary, e.g. keeping a registry_ pointer in the Base instead of passing it as an argument the subclasses' methods. if it's not done being created when passed as an argument, surely it's got less chance of being done in the subclass' constructors? And if that's not the rationale, why move it into the parent class?
There are also a handful of cases (commented inline) where arguments are passed in when the parent class already has the same pointer, so the inconsistency seems like it's signalling something about how the cyclical initialization's being repaired, but I have to admit I'm missing it.
Passing Registry::Impl pointers around outside of the Registry seems very strange as well. Maybe this is just cosmetic, i.e. if Impl has evolved into a public class and needs to renamed or moved.
Other comments inline.
Ted Gould (ted) wrote : | # |
Comments inline.
Generally the problem was that the initialization of most of the objects that the Registry was doing to do its work were initialized at basically random times. This lead to things like the bug that is attached.
The reason that this was is because they all wanted to have access the shared resources in the registry so they were waiting around for a std::shared_
So what the branch does is instead have those internal objects use std::shared_
Also, it removes a couple raw pointers and some other minor internal API cleanups.
Charles Kerr (charlesk) wrote : | # |
Thanks for the clarification.
Let's file the entire initialization sequence away in "things to simplify." I agree that could be out of scope for this fix; approving.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:328
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Preview Diff
1 | === modified file 'libubuntu-app-launch/app-store-base.cpp' | |||
2 | --- libubuntu-app-launch/app-store-base.cpp 2017-02-28 21:15:46 +0000 | |||
3 | +++ libubuntu-app-launch/app-store-base.cpp 2017-04-04 21:22:36 +0000 | |||
4 | @@ -29,8 +29,8 @@ | |||
5 | 29 | namespace app_store | 29 | namespace app_store |
6 | 30 | { | 30 | { |
7 | 31 | 31 | ||
10 | 32 | Base::Base() | 32 | Base::Base(const std::shared_ptr<Registry::Impl>& registry) |
11 | 33 | : info_watcher::Base({}) | 33 | : info_watcher::Base(registry) |
12 | 34 | { | 34 | { |
13 | 35 | } | 35 | } |
14 | 36 | 36 | ||
15 | @@ -38,14 +38,14 @@ | |||
16 | 38 | { | 38 | { |
17 | 39 | } | 39 | } |
18 | 40 | 40 | ||
20 | 41 | std::list<std::shared_ptr<Base>> Base::allAppStores() | 41 | std::list<std::shared_ptr<Base>> Base::allAppStores(const std::shared_ptr<Registry::Impl>& registry) |
21 | 42 | { | 42 | { |
22 | 43 | return { | 43 | return { |
28 | 44 | std::make_shared<Legacy>() /* Legacy */ | 44 | std::make_shared<Legacy>(registry) /* Legacy */ |
29 | 45 | , | 45 | , |
30 | 46 | std::make_shared<Libertine>() /* Libertine */ | 46 | std::make_shared<Libertine>(registry) /* Libertine */ |
31 | 47 | , | 47 | , |
32 | 48 | std::make_shared<Snap>() /* Snappy */ | 48 | std::make_shared<Snap>(registry) /* Snappy */ |
33 | 49 | }; | 49 | }; |
34 | 50 | } | 50 | } |
35 | 51 | 51 | ||
36 | 52 | 52 | ||
37 | === modified file 'libubuntu-app-launch/app-store-base.h' | |||
38 | --- libubuntu-app-launch/app-store-base.h 2017-02-24 20:39:24 +0000 | |||
39 | +++ libubuntu-app-launch/app-store-base.h 2017-04-04 21:22:36 +0000 | |||
40 | @@ -28,36 +28,34 @@ | |||
41 | 28 | { | 28 | { |
42 | 29 | namespace app_launch | 29 | namespace app_launch |
43 | 30 | { | 30 | { |
44 | 31 | namespace app_impls | ||
45 | 32 | { | ||
46 | 33 | class Base; | ||
47 | 34 | } | ||
48 | 31 | namespace app_store | 35 | namespace app_store |
49 | 32 | { | 36 | { |
50 | 33 | 37 | ||
51 | 34 | class Base : public info_watcher::Base | 38 | class Base : public info_watcher::Base |
52 | 35 | { | 39 | { |
53 | 36 | public: | 40 | public: |
55 | 37 | Base(); | 41 | Base(const std::shared_ptr<Registry::Impl>& registry); |
56 | 38 | virtual ~Base(); | 42 | virtual ~Base(); |
57 | 39 | 43 | ||
58 | 40 | /* Discover tools */ | 44 | /* Discover tools */ |
70 | 41 | virtual bool verifyPackage(const AppID::Package& package, const std::shared_ptr<Registry>& registry) = 0; | 45 | virtual bool verifyPackage(const AppID::Package& package) = 0; |
71 | 42 | virtual bool verifyAppname(const AppID::Package& package, | 46 | virtual bool verifyAppname(const AppID::Package& package, const AppID::AppName& appname) = 0; |
72 | 43 | const AppID::AppName& appname, | 47 | virtual AppID::AppName findAppname(const AppID::Package& package, AppID::ApplicationWildcard card) = 0; |
73 | 44 | const std::shared_ptr<Registry>& registry) = 0; | 48 | virtual AppID::Version findVersion(const AppID::Package& package, const AppID::AppName& appname) = 0; |
74 | 45 | virtual AppID::AppName findAppname(const AppID::Package& package, | 49 | virtual bool hasAppId(const AppID& appid) = 0; |
64 | 46 | AppID::ApplicationWildcard card, | ||
65 | 47 | const std::shared_ptr<Registry>& registry) = 0; | ||
66 | 48 | virtual AppID::Version findVersion(const AppID::Package& package, | ||
67 | 49 | const AppID::AppName& appname, | ||
68 | 50 | const std::shared_ptr<Registry>& registry) = 0; | ||
69 | 51 | virtual bool hasAppId(const AppID& appid, const std::shared_ptr<Registry>& registry) = 0; | ||
75 | 52 | 50 | ||
76 | 53 | /* Possible apps */ | 51 | /* Possible apps */ |
78 | 54 | virtual std::list<std::shared_ptr<Application>> list(const std::shared_ptr<Registry>& registry) = 0; | 52 | virtual std::list<std::shared_ptr<Application>> list() = 0; |
79 | 55 | 53 | ||
80 | 56 | /* Application Creation */ | 54 | /* Application Creation */ |
82 | 57 | virtual std::shared_ptr<app_impls::Base> create(const AppID& appid, const std::shared_ptr<Registry>& registry) = 0; | 55 | virtual std::shared_ptr<app_impls::Base> create(const AppID& appid) = 0; |
83 | 58 | 56 | ||
84 | 59 | /* Static get all */ | 57 | /* Static get all */ |
86 | 60 | static std::list<std::shared_ptr<Base>> allAppStores(); | 58 | static std::list<std::shared_ptr<Base>> allAppStores(const std::shared_ptr<Registry::Impl>& registry); |
87 | 61 | }; | 59 | }; |
88 | 62 | 60 | ||
89 | 63 | } // namespace app_store | 61 | } // namespace app_store |
90 | 64 | 62 | ||
91 | === modified file 'libubuntu-app-launch/app-store-legacy.cpp' | |||
92 | --- libubuntu-app-launch/app-store-legacy.cpp 2017-03-20 10:13:50 +0000 | |||
93 | +++ libubuntu-app-launch/app-store-legacy.cpp 2017-04-04 21:22:36 +0000 | |||
94 | @@ -30,7 +30,8 @@ | |||
95 | 30 | namespace app_store | 30 | namespace app_store |
96 | 31 | { | 31 | { |
97 | 32 | 32 | ||
99 | 33 | Legacy::Legacy() | 33 | Legacy::Legacy(const std::shared_ptr<Registry::Impl>& registry) |
100 | 34 | : Base(registry) | ||
101 | 34 | { | 35 | { |
102 | 35 | } | 36 | } |
103 | 36 | 37 | ||
104 | @@ -44,7 +45,7 @@ | |||
105 | 44 | \param appid AppID to check | 45 | \param appid AppID to check |
106 | 45 | \param registry persistent connections to use | 46 | \param registry persistent connections to use |
107 | 46 | */ | 47 | */ |
109 | 47 | bool Legacy::hasAppId(const AppID& appid, const std::shared_ptr<Registry>& registry) | 48 | bool Legacy::hasAppId(const AppID& appid) |
110 | 48 | { | 49 | { |
111 | 49 | try | 50 | try |
112 | 50 | { | 51 | { |
113 | @@ -53,7 +54,7 @@ | |||
114 | 53 | return false; | 54 | return false; |
115 | 54 | } | 55 | } |
116 | 55 | 56 | ||
118 | 56 | return verifyAppname(appid.package, appid.appname, registry); | 57 | return verifyAppname(appid.package, appid.appname); |
119 | 57 | } | 58 | } |
120 | 58 | catch (std::runtime_error& e) | 59 | catch (std::runtime_error& e) |
121 | 59 | { | 60 | { |
122 | @@ -66,7 +67,7 @@ | |||
123 | 66 | \param package Container name | 67 | \param package Container name |
124 | 67 | \param registry persistent connections to use | 68 | \param registry persistent connections to use |
125 | 68 | */ | 69 | */ |
127 | 69 | bool Legacy::verifyPackage(const AppID::Package& package, const std::shared_ptr<Registry>& registry) | 70 | bool Legacy::verifyPackage(const AppID::Package& package) |
128 | 70 | { | 71 | { |
129 | 71 | return package.value().empty(); | 72 | return package.value().empty(); |
130 | 72 | } | 73 | } |
131 | @@ -78,11 +79,9 @@ | |||
132 | 78 | \param appname Application name to look for | 79 | \param appname Application name to look for |
133 | 79 | \param registry persistent connections to use | 80 | \param registry persistent connections to use |
134 | 80 | */ | 81 | */ |
138 | 81 | bool Legacy::verifyAppname(const AppID::Package& package, | 82 | bool Legacy::verifyAppname(const AppID::Package& package, const AppID::AppName& appname) |
136 | 82 | const AppID::AppName& appname, | ||
137 | 83 | const std::shared_ptr<Registry>& registry) | ||
139 | 84 | { | 83 | { |
141 | 85 | if (!verifyPackage(package, registry)) | 84 | if (!verifyPackage(package)) |
142 | 86 | { | 85 | { |
143 | 87 | throw std::runtime_error{"Invalid Legacy package: " + std::string(package)}; | 86 | throw std::runtime_error{"Invalid Legacy package: " + std::string(package)}; |
144 | 88 | } | 87 | } |
145 | @@ -118,9 +117,7 @@ | |||
146 | 118 | \param card Application search paths | 117 | \param card Application search paths |
147 | 119 | \param registry persistent connections to use | 118 | \param registry persistent connections to use |
148 | 120 | */ | 119 | */ |
152 | 121 | AppID::AppName Legacy::findAppname(const AppID::Package& package, | 120 | AppID::AppName Legacy::findAppname(const AppID::Package& package, AppID::ApplicationWildcard card) |
150 | 122 | AppID::ApplicationWildcard card, | ||
151 | 123 | const std::shared_ptr<Registry>& registry) | ||
153 | 124 | { | 121 | { |
154 | 125 | throw std::runtime_error("Legacy apps can't be discovered by package"); | 122 | throw std::runtime_error("Legacy apps can't be discovered by package"); |
155 | 126 | } | 123 | } |
156 | @@ -131,17 +128,16 @@ | |||
157 | 131 | \param appname Application name (unused) | 128 | \param appname Application name (unused) |
158 | 132 | \param registry persistent connections to use (unused) | 129 | \param registry persistent connections to use (unused) |
159 | 133 | */ | 130 | */ |
163 | 134 | AppID::Version Legacy::findVersion(const AppID::Package& package, | 131 | AppID::Version Legacy::findVersion(const AppID::Package& package, const AppID::AppName& appname) |
161 | 135 | const AppID::AppName& appname, | ||
162 | 136 | const std::shared_ptr<Registry>& registry) | ||
164 | 137 | { | 132 | { |
165 | 138 | return AppID::Version::from_raw({}); | 133 | return AppID::Version::from_raw({}); |
166 | 139 | } | 134 | } |
167 | 140 | 135 | ||
168 | 141 | static const std::regex desktop_remover("^(.*)\\.desktop$"); | 136 | static const std::regex desktop_remover("^(.*)\\.desktop$"); |
169 | 142 | 137 | ||
171 | 143 | std::list<std::shared_ptr<Application>> Legacy::list(const std::shared_ptr<Registry>& registry) | 138 | std::list<std::shared_ptr<Application>> Legacy::list() |
172 | 144 | { | 139 | { |
173 | 140 | auto reg = getReg(); | ||
174 | 145 | std::list<std::shared_ptr<Application>> list; | 141 | std::list<std::shared_ptr<Application>> list; |
175 | 146 | std::unique_ptr<GList, decltype(&g_list_free)> head(g_app_info_get_all(), | 142 | std::unique_ptr<GList, decltype(&g_list_free)> head(g_app_info_get_all(), |
176 | 147 | [](GList* l) { g_list_free_full(l, g_object_unref); }); | 143 | [](GList* l) { g_list_free_full(l, g_object_unref); }); |
177 | @@ -179,7 +175,7 @@ | |||
178 | 179 | 175 | ||
179 | 180 | try | 176 | try |
180 | 181 | { | 177 | { |
182 | 182 | auto app = std::make_shared<app_impls::Legacy>(AppID::AppName::from_raw(appname), registry); | 178 | auto app = std::make_shared<app_impls::Legacy>(AppID::AppName::from_raw(appname), reg); |
183 | 183 | list.push_back(app); | 179 | list.push_back(app); |
184 | 184 | } | 180 | } |
185 | 185 | catch (std::runtime_error& e) | 181 | catch (std::runtime_error& e) |
186 | @@ -191,9 +187,9 @@ | |||
187 | 191 | return list; | 187 | return list; |
188 | 192 | } | 188 | } |
189 | 193 | 189 | ||
191 | 194 | std::shared_ptr<app_impls::Base> Legacy::create(const AppID& appid, const std::shared_ptr<Registry>& registry) | 190 | std::shared_ptr<app_impls::Base> Legacy::create(const AppID& appid) |
192 | 195 | { | 191 | { |
194 | 196 | return std::make_shared<app_impls::Legacy>(appid.appname, registry); | 192 | return std::make_shared<app_impls::Legacy>(appid.appname, getReg()); |
195 | 197 | } | 193 | } |
196 | 198 | 194 | ||
197 | 199 | } // namespace app_store | 195 | } // namespace app_store |
198 | 200 | 196 | ||
199 | === modified file 'libubuntu-app-launch/app-store-legacy.h' | |||
200 | --- libubuntu-app-launch/app-store-legacy.h 2017-02-24 20:39:24 +0000 | |||
201 | +++ libubuntu-app-launch/app-store-legacy.h 2017-04-04 21:22:36 +0000 | |||
202 | @@ -31,28 +31,21 @@ | |||
203 | 31 | class Legacy : public Base | 31 | class Legacy : public Base |
204 | 32 | { | 32 | { |
205 | 33 | public: | 33 | public: |
207 | 34 | Legacy(); | 34 | Legacy(const std::shared_ptr<Registry::Impl>& registry); |
208 | 35 | virtual ~Legacy(); | 35 | virtual ~Legacy(); |
209 | 36 | 36 | ||
210 | 37 | /* Discover tools */ | 37 | /* Discover tools */ |
222 | 38 | virtual bool verifyPackage(const AppID::Package& package, const std::shared_ptr<Registry>& registry) override; | 38 | virtual bool verifyPackage(const AppID::Package& package) override; |
223 | 39 | virtual bool verifyAppname(const AppID::Package& package, | 39 | virtual bool verifyAppname(const AppID::Package& package, const AppID::AppName& appname) override; |
224 | 40 | const AppID::AppName& appname, | 40 | virtual AppID::AppName findAppname(const AppID::Package& package, AppID::ApplicationWildcard card) override; |
225 | 41 | const std::shared_ptr<Registry>& registry) override; | 41 | virtual AppID::Version findVersion(const AppID::Package& package, const AppID::AppName& appname) override; |
226 | 42 | virtual AppID::AppName findAppname(const AppID::Package& package, | 42 | virtual bool hasAppId(const AppID& appid) override; |
216 | 43 | AppID::ApplicationWildcard card, | ||
217 | 44 | const std::shared_ptr<Registry>& registry) override; | ||
218 | 45 | virtual AppID::Version findVersion(const AppID::Package& package, | ||
219 | 46 | const AppID::AppName& appname, | ||
220 | 47 | const std::shared_ptr<Registry>& registry) override; | ||
221 | 48 | virtual bool hasAppId(const AppID& appid, const std::shared_ptr<Registry>& registry) override; | ||
227 | 49 | 43 | ||
228 | 50 | /* Possible apps */ | 44 | /* Possible apps */ |
230 | 51 | virtual std::list<std::shared_ptr<Application>> list(const std::shared_ptr<Registry>& registry) override; | 45 | virtual std::list<std::shared_ptr<Application>> list() override; |
231 | 52 | 46 | ||
232 | 53 | /* Application Creation */ | 47 | /* Application Creation */ |
235 | 54 | virtual std::shared_ptr<app_impls::Base> create(const AppID& appid, | 48 | virtual std::shared_ptr<app_impls::Base> create(const AppID& appid) override; |
234 | 55 | const std::shared_ptr<Registry>& registry) override; | ||
236 | 56 | }; | 49 | }; |
237 | 57 | 50 | ||
238 | 58 | } // namespace app_store | 51 | } // namespace app_store |
239 | 59 | 52 | ||
240 | === modified file 'libubuntu-app-launch/app-store-libertine.cpp' | |||
241 | --- libubuntu-app-launch/app-store-libertine.cpp 2017-03-20 10:13:50 +0000 | |||
242 | +++ libubuntu-app-launch/app-store-libertine.cpp 2017-04-04 21:22:36 +0000 | |||
243 | @@ -30,7 +30,8 @@ | |||
244 | 30 | namespace app_store | 30 | namespace app_store |
245 | 31 | { | 31 | { |
246 | 32 | 32 | ||
248 | 33 | Libertine::Libertine() | 33 | Libertine::Libertine(const std::shared_ptr<Registry::Impl>& registry) |
249 | 34 | : Base(registry) | ||
250 | 34 | { | 35 | { |
251 | 35 | } | 36 | } |
252 | 36 | 37 | ||
253 | @@ -44,7 +45,7 @@ | |||
254 | 44 | \param appid AppID to check | 45 | \param appid AppID to check |
255 | 45 | \param registry persistent connections to use | 46 | \param registry persistent connections to use |
256 | 46 | */ | 47 | */ |
258 | 47 | bool Libertine::hasAppId(const AppID& appid, const std::shared_ptr<Registry>& registry) | 48 | bool Libertine::hasAppId(const AppID& appid) |
259 | 48 | { | 49 | { |
260 | 49 | try | 50 | try |
261 | 50 | { | 51 | { |
262 | @@ -53,7 +54,7 @@ | |||
263 | 53 | return false; | 54 | return false; |
264 | 54 | } | 55 | } |
265 | 55 | 56 | ||
267 | 56 | return verifyAppname(appid.package, appid.appname, registry); | 57 | return verifyAppname(appid.package, appid.appname); |
268 | 57 | } | 58 | } |
269 | 58 | catch (std::runtime_error& e) | 59 | catch (std::runtime_error& e) |
270 | 59 | { | 60 | { |
271 | @@ -67,7 +68,7 @@ | |||
272 | 67 | \param package Container name | 68 | \param package Container name |
273 | 68 | \param registry persistent connections to use | 69 | \param registry persistent connections to use |
274 | 69 | */ | 70 | */ |
276 | 70 | bool Libertine::verifyPackage(const AppID::Package& package, const std::shared_ptr<Registry>& registry) | 71 | bool Libertine::verifyPackage(const AppID::Package& package) |
277 | 71 | { | 72 | { |
278 | 72 | auto containers = unique_gcharv(libertine_list_containers()); | 73 | auto containers = unique_gcharv(libertine_list_containers()); |
279 | 73 | 74 | ||
280 | @@ -90,9 +91,7 @@ | |||
281 | 90 | \param appname Application name to look for | 91 | \param appname Application name to look for |
282 | 91 | \param registry persistent connections to use | 92 | \param registry persistent connections to use |
283 | 92 | */ | 93 | */ |
287 | 93 | bool Libertine::verifyAppname(const AppID::Package& package, | 94 | bool Libertine::verifyAppname(const AppID::Package& package, const AppID::AppName& appname) |
285 | 94 | const AppID::AppName& appname, | ||
286 | 95 | const std::shared_ptr<Registry>& registry) | ||
288 | 96 | { | 95 | { |
289 | 97 | auto apps = unique_gcharv(libertine_list_apps_for_container(package.value().c_str())); | 96 | auto apps = unique_gcharv(libertine_list_apps_for_container(package.value().c_str())); |
290 | 98 | 97 | ||
291 | @@ -115,9 +114,7 @@ | |||
292 | 115 | \param card Application search paths | 114 | \param card Application search paths |
293 | 116 | \param registry persistent connections to use | 115 | \param registry persistent connections to use |
294 | 117 | */ | 116 | */ |
298 | 118 | AppID::AppName Libertine::findAppname(const AppID::Package& package, | 117 | AppID::AppName Libertine::findAppname(const AppID::Package& package, AppID::ApplicationWildcard card) |
296 | 119 | AppID::ApplicationWildcard card, | ||
297 | 120 | const std::shared_ptr<Registry>& registry) | ||
299 | 121 | { | 118 | { |
300 | 122 | throw std::runtime_error("Legacy apps can't be discovered by package"); | 119 | throw std::runtime_error("Legacy apps can't be discovered by package"); |
301 | 123 | } | 120 | } |
302 | @@ -128,17 +125,16 @@ | |||
303 | 128 | \param appname Application name (unused) | 125 | \param appname Application name (unused) |
304 | 129 | \param registry persistent connections to use (unused) | 126 | \param registry persistent connections to use (unused) |
305 | 130 | */ | 127 | */ |
309 | 131 | AppID::Version Libertine::findVersion(const AppID::Package& package, | 128 | AppID::Version Libertine::findVersion(const AppID::Package& package, const AppID::AppName& appname) |
307 | 132 | const AppID::AppName& appname, | ||
308 | 133 | const std::shared_ptr<Registry>& registry) | ||
310 | 134 | { | 129 | { |
311 | 135 | return AppID::Version::from_raw("0.0"); | 130 | return AppID::Version::from_raw("0.0"); |
312 | 136 | } | 131 | } |
313 | 137 | 132 | ||
315 | 138 | std::list<std::shared_ptr<Application>> Libertine::list(const std::shared_ptr<Registry>& registry) | 133 | std::list<std::shared_ptr<Application>> Libertine::list() |
316 | 139 | { | 134 | { |
317 | 140 | std::list<std::shared_ptr<Application>> applist; | 135 | std::list<std::shared_ptr<Application>> applist; |
318 | 141 | 136 | ||
319 | 137 | auto reg = getReg(); | ||
320 | 142 | auto containers = unique_gcharv(libertine_list_containers()); | 138 | auto containers = unique_gcharv(libertine_list_containers()); |
321 | 143 | 139 | ||
322 | 144 | for (int i = 0; containers.get()[i] != nullptr; i++) | 140 | for (int i = 0; containers.get()[i] != nullptr; i++) |
323 | @@ -151,7 +147,7 @@ | |||
324 | 151 | try | 147 | try |
325 | 152 | { | 148 | { |
326 | 153 | auto appid = AppID::parse(apps.get()[j]); | 149 | auto appid = AppID::parse(apps.get()[j]); |
328 | 154 | auto sapp = std::make_shared<app_impls::Libertine>(appid.package, appid.appname, registry); | 150 | auto sapp = std::make_shared<app_impls::Libertine>(appid.package, appid.appname, reg); |
329 | 155 | applist.emplace_back(sapp); | 151 | applist.emplace_back(sapp); |
330 | 156 | } | 152 | } |
331 | 157 | catch (std::runtime_error& e) | 153 | catch (std::runtime_error& e) |
332 | @@ -164,9 +160,9 @@ | |||
333 | 164 | return applist; | 160 | return applist; |
334 | 165 | } | 161 | } |
335 | 166 | 162 | ||
337 | 167 | std::shared_ptr<app_impls::Base> Libertine::create(const AppID& appid, const std::shared_ptr<Registry>& registry) | 163 | std::shared_ptr<app_impls::Base> Libertine::create(const AppID& appid) |
338 | 168 | { | 164 | { |
340 | 169 | return std::make_shared<app_impls::Libertine>(appid.package, appid.appname, registry); | 165 | return std::make_shared<app_impls::Libertine>(appid.package, appid.appname, getReg()); |
341 | 170 | } | 166 | } |
342 | 171 | 167 | ||
343 | 172 | } // namespace app_store | 168 | } // namespace app_store |
344 | 173 | 169 | ||
345 | === modified file 'libubuntu-app-launch/app-store-libertine.h' | |||
346 | --- libubuntu-app-launch/app-store-libertine.h 2017-02-24 20:39:24 +0000 | |||
347 | +++ libubuntu-app-launch/app-store-libertine.h 2017-04-04 21:22:36 +0000 | |||
348 | @@ -31,28 +31,21 @@ | |||
349 | 31 | class Libertine : public Base | 31 | class Libertine : public Base |
350 | 32 | { | 32 | { |
351 | 33 | public: | 33 | public: |
353 | 34 | Libertine(); | 34 | Libertine(const std::shared_ptr<Registry::Impl>& registry); |
354 | 35 | virtual ~Libertine(); | 35 | virtual ~Libertine(); |
355 | 36 | 36 | ||
356 | 37 | /* Discover tools */ | 37 | /* Discover tools */ |
368 | 38 | virtual bool verifyPackage(const AppID::Package& package, const std::shared_ptr<Registry>& registry) override; | 38 | virtual bool verifyPackage(const AppID::Package& package) override; |
369 | 39 | virtual bool verifyAppname(const AppID::Package& package, | 39 | virtual bool verifyAppname(const AppID::Package& package, const AppID::AppName& appname) override; |
370 | 40 | const AppID::AppName& appname, | 40 | virtual AppID::AppName findAppname(const AppID::Package& package, AppID::ApplicationWildcard card) override; |
371 | 41 | const std::shared_ptr<Registry>& registry) override; | 41 | virtual AppID::Version findVersion(const AppID::Package& package, const AppID::AppName& appname) override; |
372 | 42 | virtual AppID::AppName findAppname(const AppID::Package& package, | 42 | virtual bool hasAppId(const AppID& appid) override; |
362 | 43 | AppID::ApplicationWildcard card, | ||
363 | 44 | const std::shared_ptr<Registry>& registry) override; | ||
364 | 45 | virtual AppID::Version findVersion(const AppID::Package& package, | ||
365 | 46 | const AppID::AppName& appname, | ||
366 | 47 | const std::shared_ptr<Registry>& registry) override; | ||
367 | 48 | virtual bool hasAppId(const AppID& appid, const std::shared_ptr<Registry>& registry) override; | ||
373 | 49 | 43 | ||
374 | 50 | /* Possible apps */ | 44 | /* Possible apps */ |
376 | 51 | virtual std::list<std::shared_ptr<Application>> list(const std::shared_ptr<Registry>& registry) override; | 45 | virtual std::list<std::shared_ptr<Application>> list() override; |
377 | 52 | 46 | ||
378 | 53 | /* Application Creation */ | 47 | /* Application Creation */ |
381 | 54 | virtual std::shared_ptr<app_impls::Base> create(const AppID& appid, | 48 | virtual std::shared_ptr<app_impls::Base> create(const AppID& appid) override; |
380 | 55 | const std::shared_ptr<Registry>& registry) override; | ||
382 | 56 | }; | 49 | }; |
383 | 57 | 50 | ||
384 | 58 | } // namespace app_store | 51 | } // namespace app_store |
385 | 59 | 52 | ||
386 | === modified file 'libubuntu-app-launch/app-store-snap.cpp' | |||
387 | --- libubuntu-app-launch/app-store-snap.cpp 2017-03-14 19:59:21 +0000 | |||
388 | +++ libubuntu-app-launch/app-store-snap.cpp 2017-04-04 21:22:36 +0000 | |||
389 | @@ -43,7 +43,8 @@ | |||
390 | 43 | /** Snappy has more restrictive appnames than everyone else */ | 43 | /** Snappy has more restrictive appnames than everyone else */ |
391 | 44 | const std::regex appnameRegex{"^[a-zA-Z0-9](?:-?[a-zA-Z0-9])*$"}; | 44 | const std::regex appnameRegex{"^[a-zA-Z0-9](?:-?[a-zA-Z0-9])*$"}; |
392 | 45 | 45 | ||
394 | 46 | Snap::Snap() | 46 | Snap::Snap(const std::shared_ptr<Registry::Impl>& registry) |
395 | 47 | : Base(registry) | ||
396 | 47 | { | 48 | { |
397 | 48 | } | 49 | } |
398 | 49 | 50 | ||
399 | @@ -59,7 +60,7 @@ | |||
400 | 59 | \param appid Application ID of the snap | 60 | \param appid Application ID of the snap |
401 | 60 | \param registry Registry to use for persistent connections | 61 | \param registry Registry to use for persistent connections |
402 | 61 | */ | 62 | */ |
404 | 62 | bool Snap::hasAppId(const AppID& appId, const std::shared_ptr<Registry>& registry) | 63 | bool Snap::hasAppId(const AppID& appId) |
405 | 63 | { | 64 | { |
406 | 64 | if (appId.package.value().empty() || appId.version.value().empty()) | 65 | if (appId.package.value().empty() || appId.version.value().empty()) |
407 | 65 | { | 66 | { |
408 | @@ -71,7 +72,7 @@ | |||
409 | 71 | return false; | 72 | return false; |
410 | 72 | } | 73 | } |
411 | 73 | 74 | ||
413 | 74 | auto pkginfo = registry->impl->snapdInfo.pkgInfo(appId.package); | 75 | auto pkginfo = getReg()->snapdInfo.pkgInfo(appId.package); |
414 | 75 | return app_impls::Snap::checkPkgInfo(pkginfo, appId); | 76 | return app_impls::Snap::checkPkgInfo(pkginfo, appId); |
415 | 76 | } | 77 | } |
416 | 77 | 78 | ||
417 | @@ -80,11 +81,11 @@ | |||
418 | 80 | \param package Package name | 81 | \param package Package name |
419 | 81 | \param registry Registry to use for persistent connections | 82 | \param registry Registry to use for persistent connections |
420 | 82 | */ | 83 | */ |
422 | 83 | bool Snap::verifyPackage(const AppID::Package& package, const std::shared_ptr<Registry>& registry) | 84 | bool Snap::verifyPackage(const AppID::Package& package) |
423 | 84 | { | 85 | { |
424 | 85 | try | 86 | try |
425 | 86 | { | 87 | { |
427 | 87 | auto pkgInfo = registry->impl->snapdInfo.pkgInfo(package); | 88 | auto pkgInfo = getReg()->snapdInfo.pkgInfo(package); |
428 | 88 | return pkgInfo != nullptr; | 89 | return pkgInfo != nullptr; |
429 | 89 | } | 90 | } |
430 | 90 | catch (std::runtime_error& e) | 91 | catch (std::runtime_error& e) |
431 | @@ -99,16 +100,14 @@ | |||
432 | 99 | \param appname Command name | 100 | \param appname Command name |
433 | 100 | \param registry Registry to use for persistent connections | 101 | \param registry Registry to use for persistent connections |
434 | 101 | */ | 102 | */ |
438 | 102 | bool Snap::verifyAppname(const AppID::Package& package, | 103 | bool Snap::verifyAppname(const AppID::Package& package, const AppID::AppName& appname) |
436 | 103 | const AppID::AppName& appname, | ||
437 | 104 | const std::shared_ptr<Registry>& registry) | ||
439 | 105 | { | 104 | { |
440 | 106 | if (!std::regex_match(appname.value(), appnameRegex)) | 105 | if (!std::regex_match(appname.value(), appnameRegex)) |
441 | 107 | { | 106 | { |
442 | 108 | return false; | 107 | return false; |
443 | 109 | } | 108 | } |
444 | 110 | 109 | ||
446 | 111 | auto pkgInfo = registry->impl->snapdInfo.pkgInfo(package); | 110 | auto pkgInfo = getReg()->snapdInfo.pkgInfo(package); |
447 | 112 | 111 | ||
448 | 113 | if (!pkgInfo) | 112 | if (!pkgInfo) |
449 | 114 | { | 113 | { |
450 | @@ -125,11 +124,9 @@ | |||
451 | 125 | \param card Wildcard to use for finding the appname | 124 | \param card Wildcard to use for finding the appname |
452 | 126 | \param registry Registry to use for persistent connections | 125 | \param registry Registry to use for persistent connections |
453 | 127 | */ | 126 | */ |
457 | 128 | AppID::AppName Snap::findAppname(const AppID::Package& package, | 127 | AppID::AppName Snap::findAppname(const AppID::Package& package, AppID::ApplicationWildcard card) |
455 | 129 | AppID::ApplicationWildcard card, | ||
456 | 130 | const std::shared_ptr<Registry>& registry) | ||
458 | 131 | { | 128 | { |
460 | 132 | auto pkgInfo = registry->impl->snapdInfo.pkgInfo(package); | 129 | auto pkgInfo = getReg()->snapdInfo.pkgInfo(package); |
461 | 133 | 130 | ||
462 | 134 | if (!pkgInfo) | 131 | if (!pkgInfo) |
463 | 135 | { | 132 | { |
464 | @@ -165,11 +162,9 @@ | |||
465 | 165 | \param appname Not used for snaps | 162 | \param appname Not used for snaps |
466 | 166 | \param registry Registry to use for persistent connections | 163 | \param registry Registry to use for persistent connections |
467 | 167 | */ | 164 | */ |
471 | 168 | AppID::Version Snap::findVersion(const AppID::Package& package, | 165 | AppID::Version Snap::findVersion(const AppID::Package& package, const AppID::AppName& appname) |
469 | 169 | const AppID::AppName& appname, | ||
470 | 170 | const std::shared_ptr<Registry>& registry) | ||
472 | 171 | { | 166 | { |
474 | 172 | auto pkgInfo = registry->impl->snapdInfo.pkgInfo(package); | 167 | auto pkgInfo = getReg()->snapdInfo.pkgInfo(package); |
475 | 173 | if (pkgInfo) | 168 | if (pkgInfo) |
476 | 174 | { | 169 | { |
477 | 175 | return AppID::Version::from_raw(pkgInfo->revision); | 170 | return AppID::Version::from_raw(pkgInfo->revision); |
478 | @@ -194,11 +189,12 @@ | |||
479 | 194 | 189 | ||
480 | 195 | \param registry Registry to use for persistent connections | 190 | \param registry Registry to use for persistent connections |
481 | 196 | */ | 191 | */ |
483 | 197 | std::list<std::shared_ptr<Application>> Snap::list(const std::shared_ptr<Registry>& registry) | 192 | std::list<std::shared_ptr<Application>> Snap::list() |
484 | 198 | { | 193 | { |
485 | 199 | std::set<std::shared_ptr<Application>, appcompare> apps; | 194 | std::set<std::shared_ptr<Application>, appcompare> apps; |
486 | 195 | auto reg = getReg(); | ||
487 | 200 | 196 | ||
489 | 201 | auto lifecycleApps = registry->impl->snapdInfo.appsForInterface(LIFECYCLE_INTERFACE); | 197 | auto lifecycleApps = reg->snapdInfo.appsForInterface(LIFECYCLE_INTERFACE); |
490 | 202 | 198 | ||
491 | 203 | auto lifecycleForApp = [&](const AppID& appID) { | 199 | auto lifecycleForApp = [&](const AppID& appID) { |
492 | 204 | auto iterator = lifecycleApps.find(appID); | 200 | auto iterator = lifecycleApps.find(appID); |
493 | @@ -213,12 +209,12 @@ | |||
494 | 213 | }; | 209 | }; |
495 | 214 | 210 | ||
496 | 215 | auto addAppsForInterface = [&](const std::string& interface, app_info::Desktop::XMirEnable xMirEnable) { | 211 | auto addAppsForInterface = [&](const std::string& interface, app_info::Desktop::XMirEnable xMirEnable) { |
498 | 216 | for (const auto& id : registry->impl->snapdInfo.appsForInterface(interface)) | 212 | for (const auto& id : reg->snapdInfo.appsForInterface(interface)) |
499 | 217 | { | 213 | { |
500 | 218 | auto interfaceInfo = std::make_tuple(xMirEnable, lifecycleForApp(id)); | 214 | auto interfaceInfo = std::make_tuple(xMirEnable, lifecycleForApp(id)); |
501 | 219 | try | 215 | try |
502 | 220 | { | 216 | { |
504 | 221 | auto app = std::make_shared<app_impls::Snap>(id, registry, interfaceInfo); | 217 | auto app = std::make_shared<app_impls::Snap>(id, reg, interfaceInfo); |
505 | 222 | apps.emplace(app); | 218 | apps.emplace(app); |
506 | 223 | } | 219 | } |
507 | 224 | catch (std::runtime_error& e) | 220 | catch (std::runtime_error& e) |
508 | @@ -239,9 +235,9 @@ | |||
509 | 239 | return std::list<std::shared_ptr<Application>>(apps.begin(), apps.end()); | 235 | return std::list<std::shared_ptr<Application>>(apps.begin(), apps.end()); |
510 | 240 | } | 236 | } |
511 | 241 | 237 | ||
513 | 242 | std::shared_ptr<app_impls::Base> Snap::create(const AppID& appid, const std::shared_ptr<Registry>& registry) | 238 | std::shared_ptr<app_impls::Base> Snap::create(const AppID& appid) |
514 | 243 | { | 239 | { |
516 | 244 | return std::make_shared<app_impls::Snap>(appid, registry); | 240 | return std::make_shared<app_impls::Snap>(appid, getReg()); |
517 | 245 | } | 241 | } |
518 | 246 | 242 | ||
519 | 247 | } // namespace app_store | 243 | } // namespace app_store |
520 | 248 | 244 | ||
521 | === modified file 'libubuntu-app-launch/app-store-snap.h' | |||
522 | --- libubuntu-app-launch/app-store-snap.h 2017-02-24 20:39:24 +0000 | |||
523 | +++ libubuntu-app-launch/app-store-snap.h 2017-04-04 21:22:36 +0000 | |||
524 | @@ -31,28 +31,21 @@ | |||
525 | 31 | class Snap : public Base | 31 | class Snap : public Base |
526 | 32 | { | 32 | { |
527 | 33 | public: | 33 | public: |
529 | 34 | Snap(); | 34 | Snap(const std::shared_ptr<Registry::Impl>& registry); |
530 | 35 | virtual ~Snap(); | 35 | virtual ~Snap(); |
531 | 36 | 36 | ||
532 | 37 | /* Discover tools */ | 37 | /* Discover tools */ |
544 | 38 | virtual bool verifyPackage(const AppID::Package& package, const std::shared_ptr<Registry>& registry) override; | 38 | virtual bool verifyPackage(const AppID::Package& package) override; |
545 | 39 | virtual bool verifyAppname(const AppID::Package& package, | 39 | virtual bool verifyAppname(const AppID::Package& package, const AppID::AppName& appname) override; |
546 | 40 | const AppID::AppName& appname, | 40 | virtual AppID::AppName findAppname(const AppID::Package& package, AppID::ApplicationWildcard card) override; |
547 | 41 | const std::shared_ptr<Registry>& registry) override; | 41 | virtual AppID::Version findVersion(const AppID::Package& package, const AppID::AppName& appname) override; |
548 | 42 | virtual AppID::AppName findAppname(const AppID::Package& package, | 42 | virtual bool hasAppId(const AppID& appid) override; |
538 | 43 | AppID::ApplicationWildcard card, | ||
539 | 44 | const std::shared_ptr<Registry>& registry) override; | ||
540 | 45 | virtual AppID::Version findVersion(const AppID::Package& package, | ||
541 | 46 | const AppID::AppName& appname, | ||
542 | 47 | const std::shared_ptr<Registry>& registry) override; | ||
543 | 48 | virtual bool hasAppId(const AppID& appid, const std::shared_ptr<Registry>& registry) override; | ||
549 | 49 | 43 | ||
550 | 50 | /* Possible apps */ | 44 | /* Possible apps */ |
552 | 51 | virtual std::list<std::shared_ptr<Application>> list(const std::shared_ptr<Registry>& registry) override; | 45 | virtual std::list<std::shared_ptr<Application>> list() override; |
553 | 52 | 46 | ||
554 | 53 | /* Application Creation */ | 47 | /* Application Creation */ |
557 | 54 | virtual std::shared_ptr<app_impls::Base> create(const AppID& appid, | 48 | virtual std::shared_ptr<app_impls::Base> create(const AppID& appid) override; |
556 | 55 | const std::shared_ptr<Registry>& registry) override; | ||
558 | 56 | }; | 49 | }; |
559 | 57 | 50 | ||
560 | 58 | } // namespace app_store | 51 | } // namespace app_store |
561 | 59 | 52 | ||
562 | === modified file 'libubuntu-app-launch/application-impl-base.cpp' | |||
563 | --- libubuntu-app-launch/application-impl-base.cpp 2017-03-20 10:13:50 +0000 | |||
564 | +++ libubuntu-app-launch/application-impl-base.cpp 2017-04-04 21:22:36 +0000 | |||
565 | @@ -40,8 +40,8 @@ | |||
566 | 40 | namespace app_impls | 40 | namespace app_impls |
567 | 41 | { | 41 | { |
568 | 42 | 42 | ||
571 | 43 | Base::Base(const std::shared_ptr<Registry>& registry) | 43 | Base::Base(const std::shared_ptr<Registry::Impl>& registry) |
572 | 44 | : _registry(registry) | 44 | : registry_(registry) |
573 | 45 | { | 45 | { |
574 | 46 | g_debug("Application construction: %p", static_cast<void*>(this)); | 46 | g_debug("Application construction: %p", static_cast<void*>(this)); |
575 | 47 | } | 47 | } |
576 | 48 | 48 | ||
577 | === modified file 'libubuntu-app-launch/application-impl-base.h' | |||
578 | --- libubuntu-app-launch/application-impl-base.h 2017-02-23 21:18:30 +0000 | |||
579 | +++ libubuntu-app-launch/application-impl-base.h 2017-04-04 21:22:36 +0000 | |||
580 | @@ -17,21 +17,21 @@ | |||
581 | 17 | * Ted Gould <ted.gould@canonical.com> | 17 | * Ted Gould <ted.gould@canonical.com> |
582 | 18 | */ | 18 | */ |
583 | 19 | 19 | ||
584 | 20 | #pragma once | ||
585 | 21 | |||
586 | 20 | #include "application-info-desktop.h" | 22 | #include "application-info-desktop.h" |
587 | 21 | #include "application.h" | 23 | #include "application.h" |
596 | 22 | #include "info-watcher.h" | 24 | #include "registry-impl.h" |
597 | 23 | 25 | #include "registry.h" | |
590 | 24 | extern "C" { | ||
591 | 25 | #include "ubuntu-app-launch.h" | ||
592 | 26 | #include <gio/gio.h> | ||
593 | 27 | } | ||
594 | 28 | |||
595 | 29 | #pragma once | ||
598 | 30 | 26 | ||
599 | 31 | namespace ubuntu | 27 | namespace ubuntu |
600 | 32 | { | 28 | { |
601 | 33 | namespace app_launch | 29 | namespace app_launch |
602 | 34 | { | 30 | { |
603 | 31 | namespace app_info | ||
604 | 32 | { | ||
605 | 33 | class Desktop; | ||
606 | 34 | } | ||
607 | 35 | namespace app_impls | 35 | namespace app_impls |
608 | 36 | { | 36 | { |
609 | 37 | 37 | ||
610 | @@ -41,7 +41,7 @@ | |||
611 | 41 | class Base : public ubuntu::app_launch::Application | 41 | class Base : public ubuntu::app_launch::Application |
612 | 42 | { | 42 | { |
613 | 43 | public: | 43 | public: |
615 | 44 | Base(const std::shared_ptr<Registry>& registry); | 44 | Base(const std::shared_ptr<Registry::Impl>& registry); |
616 | 45 | virtual ~Base(); | 45 | virtual ~Base(); |
617 | 46 | 46 | ||
618 | 47 | bool hasInstances() override; | 47 | bool hasInstances() override; |
619 | @@ -52,7 +52,7 @@ | |||
620 | 52 | 52 | ||
621 | 53 | protected: | 53 | protected: |
622 | 54 | /** Pointer to the registry so we can ask it for things */ | 54 | /** Pointer to the registry so we can ask it for things */ |
624 | 55 | std::shared_ptr<Registry> _registry; | 55 | std::shared_ptr<Registry::Impl> registry_; |
625 | 56 | 56 | ||
626 | 57 | static std::list<std::pair<std::string, std::string>> confinedEnv(const std::string& package, | 57 | static std::list<std::pair<std::string, std::string>> confinedEnv(const std::string& package, |
627 | 58 | const std::string& pkgdir); | 58 | const std::string& pkgdir); |
628 | 59 | 59 | ||
629 | === modified file 'libubuntu-app-launch/application-impl-legacy.cpp' | |||
630 | --- libubuntu-app-launch/application-impl-legacy.cpp 2017-03-20 10:13:50 +0000 | |||
631 | +++ libubuntu-app-launch/application-impl-legacy.cpp 2017-04-04 21:22:36 +0000 | |||
632 | @@ -52,7 +52,7 @@ | |||
633 | 52 | } | 52 | } |
634 | 53 | } | 53 | } |
635 | 54 | 54 | ||
637 | 55 | Legacy::Legacy(const AppID::AppName& appname, const std::shared_ptr<Registry>& registry) | 55 | Legacy::Legacy(const AppID::AppName& appname, const std::shared_ptr<Registry::Impl>& registry) |
638 | 56 | : Base(registry) | 56 | : Base(registry) |
639 | 57 | , _appname(appname) | 57 | , _appname(appname) |
640 | 58 | { | 58 | { |
641 | @@ -73,7 +73,7 @@ | |||
642 | 73 | flags |= app_info::DesktopFlags::XMIR_DEFAULT; | 73 | flags |= app_info::DesktopFlags::XMIR_DEFAULT; |
643 | 74 | } | 74 | } |
644 | 75 | 75 | ||
646 | 76 | appinfo_ = std::make_shared<app_info::Desktop>(appId(), _keyfile, _basedir, rootDir, flags, _registry); | 76 | appinfo_ = std::make_shared<app_info::Desktop>(appId(), _keyfile, _basedir, rootDir, flags, registry_); |
647 | 77 | 77 | ||
648 | 78 | if (!_keyfile) | 78 | if (!_keyfile) |
649 | 79 | { | 79 | { |
650 | @@ -135,7 +135,7 @@ | |||
651 | 135 | 135 | ||
652 | 136 | std::vector<std::shared_ptr<Application::Instance>> Legacy::instances() | 136 | std::vector<std::shared_ptr<Application::Instance>> Legacy::instances() |
653 | 137 | { | 137 | { |
655 | 138 | auto vbase = _registry->impl->jobs->instances(appId(), "application-legacy"); | 138 | auto vbase = registry_->jobs()->instances(appId(), "application-legacy"); |
656 | 139 | return std::vector<std::shared_ptr<Application::Instance>>(vbase.begin(), vbase.end()); | 139 | return std::vector<std::shared_ptr<Application::Instance>>(vbase.begin(), vbase.end()); |
657 | 140 | } | 140 | } |
658 | 141 | 141 | ||
659 | @@ -222,8 +222,8 @@ | |||
660 | 222 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this, instance]() { | 222 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this, instance]() { |
661 | 223 | return launchEnv(instance); | 223 | return launchEnv(instance); |
662 | 224 | }; | 224 | }; |
665 | 225 | return _registry->impl->jobs->launch(appId(), "application-legacy", instance, urls, | 225 | return registry_->jobs()->launch(appId(), "application-legacy", instance, urls, jobs::manager::launchMode::STANDARD, |
666 | 226 | jobs::manager::launchMode::STANDARD, envfunc); | 226 | envfunc); |
667 | 227 | } | 227 | } |
668 | 228 | 228 | ||
669 | 229 | /** Create an UpstartInstance for this AppID using the UpstartInstance launch | 229 | /** Create an UpstartInstance for this AppID using the UpstartInstance launch |
670 | @@ -237,13 +237,13 @@ | |||
671 | 237 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this, instance]() { | 237 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this, instance]() { |
672 | 238 | return launchEnv(instance); | 238 | return launchEnv(instance); |
673 | 239 | }; | 239 | }; |
676 | 240 | return _registry->impl->jobs->launch(appId(), "application-legacy", instance, urls, jobs::manager::launchMode::TEST, | 240 | return registry_->jobs()->launch(appId(), "application-legacy", instance, urls, jobs::manager::launchMode::TEST, |
677 | 241 | envfunc); | 241 | envfunc); |
678 | 242 | } | 242 | } |
679 | 243 | 243 | ||
680 | 244 | std::shared_ptr<Application::Instance> Legacy::findInstance(const std::string& instanceid) | 244 | std::shared_ptr<Application::Instance> Legacy::findInstance(const std::string& instanceid) |
681 | 245 | { | 245 | { |
683 | 246 | return _registry->impl->jobs->existing(appId(), "application-legacy", instanceid, std::vector<Application::URL>{}); | 246 | return registry_->jobs()->existing(appId(), "application-legacy", instanceid, std::vector<Application::URL>{}); |
684 | 247 | } | 247 | } |
685 | 248 | 248 | ||
686 | 249 | } // namespace app_impls | 249 | } // namespace app_impls |
687 | 250 | 250 | ||
688 | === modified file 'libubuntu-app-launch/application-impl-legacy.h' | |||
689 | --- libubuntu-app-launch/application-impl-legacy.h 2017-02-24 21:21:03 +0000 | |||
690 | +++ libubuntu-app-launch/application-impl-legacy.h 2017-04-04 21:22:36 +0000 | |||
691 | @@ -48,7 +48,7 @@ | |||
692 | 48 | class Legacy : public Base | 48 | class Legacy : public Base |
693 | 49 | { | 49 | { |
694 | 50 | public: | 50 | public: |
696 | 51 | Legacy(const AppID::AppName& appname, const std::shared_ptr<Registry>& registry); | 51 | Legacy(const AppID::AppName& appname, const std::shared_ptr<Registry::Impl>& registry); |
697 | 52 | 52 | ||
698 | 53 | AppID appId() override | 53 | AppID appId() override |
699 | 54 | { | 54 | { |
700 | 55 | 55 | ||
701 | === modified file 'libubuntu-app-launch/application-impl-libertine.cpp' | |||
702 | --- libubuntu-app-launch/application-impl-libertine.cpp 2017-03-20 10:13:50 +0000 | |||
703 | +++ libubuntu-app-launch/application-impl-libertine.cpp 2017-04-04 21:22:36 +0000 | |||
704 | @@ -35,7 +35,7 @@ | |||
705 | 35 | 35 | ||
706 | 36 | Libertine::Libertine(const AppID::Package& container, | 36 | Libertine::Libertine(const AppID::Package& container, |
707 | 37 | const AppID::AppName& appname, | 37 | const AppID::AppName& appname, |
709 | 38 | const std::shared_ptr<Registry>& registry) | 38 | const std::shared_ptr<Registry::Impl>& registry) |
710 | 39 | : Base(registry) | 39 | : Base(registry) |
711 | 40 | , _container(container) | 40 | , _container(container) |
712 | 41 | , _appname(appname) | 41 | , _appname(appname) |
713 | @@ -68,7 +68,7 @@ | |||
714 | 68 | container.value() + "'"}; | 68 | container.value() + "'"}; |
715 | 69 | 69 | ||
716 | 70 | appinfo_ = std::make_shared<app_info::Desktop>(appId(), _keyfile, _basedir, _container_path, | 70 | appinfo_ = std::make_shared<app_info::Desktop>(appId(), _keyfile, _basedir, _container_path, |
718 | 71 | app_info::DesktopFlags::XMIR_DEFAULT, _registry); | 71 | app_info::DesktopFlags::XMIR_DEFAULT, registry_); |
719 | 72 | 72 | ||
720 | 73 | g_debug("Application Libertine object for container '%s' app '%s'", container.value().c_str(), | 73 | g_debug("Application Libertine object for container '%s' app '%s'", container.value().c_str(), |
721 | 74 | appname.value().c_str()); | 74 | appname.value().c_str()); |
722 | @@ -137,7 +137,7 @@ | |||
723 | 137 | 137 | ||
724 | 138 | std::vector<std::shared_ptr<Application::Instance>> Libertine::instances() | 138 | std::vector<std::shared_ptr<Application::Instance>> Libertine::instances() |
725 | 139 | { | 139 | { |
727 | 140 | auto vbase = _registry->impl->jobs->instances(appId(), "application-legacy"); | 140 | auto vbase = registry_->jobs()->instances(appId(), "application-legacy"); |
728 | 141 | return std::vector<std::shared_ptr<Application::Instance>>(vbase.begin(), vbase.end()); | 141 | return std::vector<std::shared_ptr<Application::Instance>>(vbase.begin(), vbase.end()); |
729 | 142 | } | 142 | } |
730 | 143 | 143 | ||
731 | @@ -181,21 +181,21 @@ | |||
732 | 181 | { | 181 | { |
733 | 182 | auto instance = getInstance(appinfo_); | 182 | auto instance = getInstance(appinfo_); |
734 | 183 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this]() { return launchEnv(); }; | 183 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this]() { return launchEnv(); }; |
737 | 184 | return _registry->impl->jobs->launch(appId(), "application-legacy", instance, urls, | 184 | return registry_->jobs()->launch(appId(), "application-legacy", instance, urls, jobs::manager::launchMode::STANDARD, |
738 | 185 | jobs::manager::launchMode::STANDARD, envfunc); | 185 | envfunc); |
739 | 186 | } | 186 | } |
740 | 187 | 187 | ||
741 | 188 | std::shared_ptr<Application::Instance> Libertine::launchTest(const std::vector<Application::URL>& urls) | 188 | std::shared_ptr<Application::Instance> Libertine::launchTest(const std::vector<Application::URL>& urls) |
742 | 189 | { | 189 | { |
743 | 190 | auto instance = getInstance(appinfo_); | 190 | auto instance = getInstance(appinfo_); |
744 | 191 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this]() { return launchEnv(); }; | 191 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this]() { return launchEnv(); }; |
747 | 192 | return _registry->impl->jobs->launch(appId(), "application-legacy", instance, urls, jobs::manager::launchMode::TEST, | 192 | return registry_->jobs()->launch(appId(), "application-legacy", instance, urls, jobs::manager::launchMode::TEST, |
748 | 193 | envfunc); | 193 | envfunc); |
749 | 194 | } | 194 | } |
750 | 195 | 195 | ||
751 | 196 | std::shared_ptr<Application::Instance> Libertine::findInstance(const std::string& instanceid) | 196 | std::shared_ptr<Application::Instance> Libertine::findInstance(const std::string& instanceid) |
752 | 197 | { | 197 | { |
754 | 198 | return _registry->impl->jobs->existing(appId(), "application-legacy", instanceid, std::vector<Application::URL>{}); | 198 | return registry_->jobs()->existing(appId(), "application-legacy", instanceid, std::vector<Application::URL>{}); |
755 | 199 | } | 199 | } |
756 | 200 | 200 | ||
757 | 201 | } // namespace app_impls | 201 | } // namespace app_impls |
758 | 202 | 202 | ||
759 | === modified file 'libubuntu-app-launch/application-impl-libertine.h' | |||
760 | --- libubuntu-app-launch/application-impl-libertine.h 2017-02-24 21:25:47 +0000 | |||
761 | +++ libubuntu-app-launch/application-impl-libertine.h 2017-04-04 21:22:36 +0000 | |||
762 | @@ -52,7 +52,7 @@ | |||
763 | 52 | public: | 52 | public: |
764 | 53 | Libertine(const AppID::Package& container, | 53 | Libertine(const AppID::Package& container, |
765 | 54 | const AppID::AppName& appname, | 54 | const AppID::AppName& appname, |
767 | 55 | const std::shared_ptr<Registry>& registry); | 55 | const std::shared_ptr<Registry::Impl>& registry); |
768 | 56 | 56 | ||
769 | 57 | AppID appId() override | 57 | AppID appId() override |
770 | 58 | { | 58 | { |
771 | 59 | 59 | ||
772 | === modified file 'libubuntu-app-launch/application-impl-snap.cpp' | |||
773 | --- libubuntu-app-launch/application-impl-snap.cpp 2017-03-20 10:13:50 +0000 | |||
774 | +++ libubuntu-app-launch/application-impl-snap.cpp 2017-04-04 21:22:36 +0000 | |||
775 | @@ -62,7 +62,7 @@ | |||
776 | 62 | 62 | ||
777 | 63 | public: | 63 | public: |
778 | 64 | SnapInfo(const AppID& appid, | 64 | SnapInfo(const AppID& appid, |
780 | 65 | const std::shared_ptr<Registry>& registry, | 65 | const std::shared_ptr<Registry::Impl>& registry, |
781 | 66 | const Snap::InterfaceInfo& interfaceInfo, | 66 | const Snap::InterfaceInfo& interfaceInfo, |
782 | 67 | const std::string& snapDir) | 67 | const std::string& snapDir) |
783 | 68 | : Desktop(appid, | 68 | : Desktop(appid, |
784 | @@ -187,11 +187,11 @@ | |||
785 | 187 | \param registry Registry to use for persistent connections | 187 | \param registry Registry to use for persistent connections |
786 | 188 | \param interfaceInfo Metadata gleaned from the snap's interfaces | 188 | \param interfaceInfo Metadata gleaned from the snap's interfaces |
787 | 189 | */ | 189 | */ |
789 | 190 | Snap::Snap(const AppID& appid, const std::shared_ptr<Registry>& registry, const InterfaceInfo& interfaceInfo) | 190 | Snap::Snap(const AppID& appid, const std::shared_ptr<Registry::Impl>& registry, const InterfaceInfo& interfaceInfo) |
790 | 191 | : Base(registry) | 191 | : Base(registry) |
791 | 192 | , appid_(appid) | 192 | , appid_(appid) |
792 | 193 | { | 193 | { |
794 | 194 | pkgInfo_ = registry->impl->snapdInfo.pkgInfo(appid.package); | 194 | pkgInfo_ = registry->snapdInfo.pkgInfo(appid.package); |
795 | 195 | if (!pkgInfo_) | 195 | if (!pkgInfo_) |
796 | 196 | { | 196 | { |
797 | 197 | throw std::runtime_error("Unable to get snap package info for AppID: " + std::string(appid)); | 197 | throw std::runtime_error("Unable to get snap package info for AppID: " + std::string(appid)); |
798 | @@ -202,7 +202,7 @@ | |||
799 | 202 | throw std::runtime_error("AppID does not match installed package for: " + std::string(appid)); | 202 | throw std::runtime_error("AppID does not match installed package for: " + std::string(appid)); |
800 | 203 | } | 203 | } |
801 | 204 | 204 | ||
803 | 205 | info_ = std::make_shared<SnapInfo>(appid_, _registry, interfaceInfo, pkgInfo_->directory); | 205 | info_ = std::make_shared<SnapInfo>(appid_, registry_, interfaceInfo, pkgInfo_->directory); |
804 | 206 | 206 | ||
805 | 207 | g_debug("Application Snap object for AppID '%s'", std::string(appid).c_str()); | 207 | g_debug("Application Snap object for AppID '%s'", std::string(appid).c_str()); |
806 | 208 | } | 208 | } |
807 | @@ -213,7 +213,7 @@ | |||
808 | 213 | \param appid Application ID of the snap | 213 | \param appid Application ID of the snap |
809 | 214 | \param registry Registry to use for persistent connections | 214 | \param registry Registry to use for persistent connections |
810 | 215 | */ | 215 | */ |
812 | 216 | Snap::Snap(const AppID& appid, const std::shared_ptr<Registry>& registry) | 216 | Snap::Snap(const AppID& appid, const std::shared_ptr<Registry::Impl>& registry) |
813 | 217 | : Snap(appid, registry, findInterfaceInfo(appid, registry)) | 217 | : Snap(appid, registry, findInterfaceInfo(appid, registry)) |
814 | 218 | { | 218 | { |
815 | 219 | } | 219 | } |
816 | @@ -230,9 +230,9 @@ | |||
817 | 230 | \param appid Application ID of the snap | 230 | \param appid Application ID of the snap |
818 | 231 | \param registry Registry to use for persistent connections | 231 | \param registry Registry to use for persistent connections |
819 | 232 | */ | 232 | */ |
821 | 233 | Snap::InterfaceInfo Snap::findInterfaceInfo(const AppID& appid, const std::shared_ptr<Registry>& registry) | 233 | Snap::InterfaceInfo Snap::findInterfaceInfo(const AppID& appid, const std::shared_ptr<Registry::Impl>& registry) |
822 | 234 | { | 234 | { |
824 | 235 | auto ifaceset = registry->impl->snapdInfo.interfacesForAppId(appid); | 235 | auto ifaceset = registry->snapdInfo.interfacesForAppId(appid); |
825 | 236 | auto xMirEnable = app_info::Desktop::XMirEnable::from_raw(false); | 236 | auto xMirEnable = app_info::Desktop::XMirEnable::from_raw(false); |
826 | 237 | auto ubuntuLifecycle = Application::Info::UbuntuLifecycle::from_raw(false); | 237 | auto ubuntuLifecycle = Application::Info::UbuntuLifecycle::from_raw(false); |
827 | 238 | 238 | ||
828 | @@ -282,7 +282,7 @@ | |||
829 | 282 | /** Get all of the instances of this snap package that are running */ | 282 | /** Get all of the instances of this snap package that are running */ |
830 | 283 | std::vector<std::shared_ptr<Application::Instance>> Snap::instances() | 283 | std::vector<std::shared_ptr<Application::Instance>> Snap::instances() |
831 | 284 | { | 284 | { |
833 | 285 | auto vbase = _registry->impl->jobs->instances(appId(), "application-snap"); | 285 | auto vbase = registry_->jobs()->instances(appId(), "application-snap"); |
834 | 286 | return std::vector<std::shared_ptr<Application::Instance>>(vbase.begin(), vbase.end()); | 286 | return std::vector<std::shared_ptr<Application::Instance>>(vbase.begin(), vbase.end()); |
835 | 287 | } | 287 | } |
836 | 288 | 288 | ||
837 | @@ -326,8 +326,8 @@ | |||
838 | 326 | { | 326 | { |
839 | 327 | auto instance = getInstance(info_); | 327 | auto instance = getInstance(info_); |
840 | 328 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this]() { return launchEnv(); }; | 328 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this]() { return launchEnv(); }; |
843 | 329 | return _registry->impl->jobs->launch(appid_, "application-snap", instance, urls, | 329 | return registry_->jobs()->launch(appid_, "application-snap", instance, urls, jobs::manager::launchMode::STANDARD, |
844 | 330 | jobs::manager::launchMode::STANDARD, envfunc); | 330 | envfunc); |
845 | 331 | } | 331 | } |
846 | 332 | 332 | ||
847 | 333 | /** Create a new instance of this Snap with a testing environment | 333 | /** Create a new instance of this Snap with a testing environment |
848 | @@ -339,13 +339,13 @@ | |||
849 | 339 | { | 339 | { |
850 | 340 | auto instance = getInstance(info_); | 340 | auto instance = getInstance(info_); |
851 | 341 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this]() { return launchEnv(); }; | 341 | std::function<std::list<std::pair<std::string, std::string>>(void)> envfunc = [this]() { return launchEnv(); }; |
854 | 342 | return _registry->impl->jobs->launch(appid_, "application-snap", instance, urls, jobs::manager::launchMode::TEST, | 342 | return registry_->jobs()->launch(appid_, "application-snap", instance, urls, jobs::manager::launchMode::TEST, |
855 | 343 | envfunc); | 343 | envfunc); |
856 | 344 | } | 344 | } |
857 | 345 | 345 | ||
858 | 346 | std::shared_ptr<Application::Instance> Snap::findInstance(const std::string& instanceid) | 346 | std::shared_ptr<Application::Instance> Snap::findInstance(const std::string& instanceid) |
859 | 347 | { | 347 | { |
861 | 348 | return _registry->impl->jobs->existing(appId(), "application-snap", instanceid, std::vector<Application::URL>{}); | 348 | return registry_->jobs()->existing(appId(), "application-snap", instanceid, std::vector<Application::URL>{}); |
862 | 349 | } | 349 | } |
863 | 350 | 350 | ||
864 | 351 | } // namespace app_impls | 351 | } // namespace app_impls |
865 | 352 | 352 | ||
866 | === modified file 'libubuntu-app-launch/application-impl-snap.h' | |||
867 | --- libubuntu-app-launch/application-impl-snap.h 2017-03-14 19:35:43 +0000 | |||
868 | +++ libubuntu-app-launch/application-impl-snap.h 2017-04-04 21:22:36 +0000 | |||
869 | @@ -50,10 +50,10 @@ | |||
870 | 50 | public: | 50 | public: |
871 | 51 | typedef std::tuple<app_info::Desktop::XMirEnable, Application::Info::UbuntuLifecycle> InterfaceInfo; | 51 | typedef std::tuple<app_info::Desktop::XMirEnable, Application::Info::UbuntuLifecycle> InterfaceInfo; |
872 | 52 | 52 | ||
875 | 53 | Snap(const AppID& appid, const std::shared_ptr<Registry>& registry); | 53 | Snap(const AppID& appid, const std::shared_ptr<Registry::Impl>& registry); |
876 | 54 | Snap(const AppID& appid, const std::shared_ptr<Registry>& registry, const InterfaceInfo& interfaceInfo); | 54 | Snap(const AppID& appid, const std::shared_ptr<Registry::Impl>& registry, const InterfaceInfo& interfaceInfo); |
877 | 55 | 55 | ||
879 | 56 | static std::list<std::shared_ptr<Application>> list(const std::shared_ptr<Registry>& registry); | 56 | static std::list<std::shared_ptr<Application>> list(const std::shared_ptr<Registry::Impl>& registry); |
880 | 57 | 57 | ||
881 | 58 | AppID appId() override; | 58 | AppID appId() override; |
882 | 59 | 59 | ||
883 | @@ -66,7 +66,7 @@ | |||
884 | 66 | 66 | ||
885 | 67 | virtual std::shared_ptr<Application::Instance> findInstance(const std::string& instanceid) override; | 67 | virtual std::shared_ptr<Application::Instance> findInstance(const std::string& instanceid) override; |
886 | 68 | 68 | ||
888 | 69 | static InterfaceInfo findInterfaceInfo(const AppID& appid, const std::shared_ptr<Registry>& registry); | 69 | static InterfaceInfo findInterfaceInfo(const AppID& appid, const std::shared_ptr<Registry::Impl>& registry); |
889 | 70 | static bool checkPkgInfo(const std::shared_ptr<snapd::Info::PkgInfo>& pkginfo, const AppID& appid); | 70 | static bool checkPkgInfo(const std::shared_ptr<snapd::Info::PkgInfo>& pkginfo, const AppID& appid); |
890 | 71 | 71 | ||
891 | 72 | private: | 72 | private: |
892 | 73 | 73 | ||
893 | === modified file 'libubuntu-app-launch/application-info-desktop.cpp' | |||
894 | --- libubuntu-app-launch/application-info-desktop.cpp 2017-03-20 10:13:50 +0000 | |||
895 | +++ libubuntu-app-launch/application-info-desktop.cpp 2017-04-04 21:22:36 +0000 | |||
896 | @@ -265,7 +265,7 @@ | |||
897 | 265 | const std::string& basePath, | 265 | const std::string& basePath, |
898 | 266 | const std::string& rootDir, | 266 | const std::string& rootDir, |
899 | 267 | std::bitset<2> flags, | 267 | std::bitset<2> flags, |
901 | 268 | std::shared_ptr<Registry> registry) | 268 | const std::shared_ptr<Registry::Impl>& registry) |
902 | 269 | : _keyfile([keyfile, flags]() { | 269 | : _keyfile([keyfile, flags]() { |
903 | 270 | if (!keyfile) | 270 | if (!keyfile) |
904 | 271 | { | 271 | { |
905 | @@ -318,7 +318,7 @@ | |||
906 | 318 | if (!iconName.value().empty() && iconName.value()[0] != '/') | 318 | if (!iconName.value().empty() && iconName.value()[0] != '/') |
907 | 319 | { | 319 | { |
908 | 320 | /* If it is not a direct filename look it up */ | 320 | /* If it is not a direct filename look it up */ |
910 | 321 | return registry->impl->getIconFinder(basePath)->find(iconName); | 321 | return registry->getIconFinder(basePath)->find(iconName); |
911 | 322 | } | 322 | } |
912 | 323 | } | 323 | } |
913 | 324 | return fileFromKeyfile<Application::Info::IconPath>(keyfile, basePath, rootDir, "Icon"); | 324 | return fileFromKeyfile<Application::Info::IconPath>(keyfile, basePath, rootDir, "Icon"); |
914 | @@ -331,7 +331,7 @@ | |||
915 | 331 | , _keywords(stringlistFromKeyfile<Application::Info::Keywords>(keyfile, "Keywords")) | 331 | , _keywords(stringlistFromKeyfile<Application::Info::Keywords>(keyfile, "Keywords")) |
916 | 332 | , _popularity([registry, appid] { | 332 | , _popularity([registry, appid] { |
917 | 333 | if (registry) | 333 | if (registry) |
919 | 334 | return Registry::Impl::getZgWatcher(registry)->lookupAppPopularity(appid); | 334 | return registry->getZgWatcher()->lookupAppPopularity(appid); |
920 | 335 | else | 335 | else |
921 | 336 | return Application::Info::Popularity::from_raw(0); | 336 | return Application::Info::Popularity::from_raw(0); |
922 | 337 | }()) | 337 | }()) |
923 | 338 | 338 | ||
924 | === modified file 'libubuntu-app-launch/application-info-desktop.h' | |||
925 | --- libubuntu-app-launch/application-info-desktop.h 2017-02-09 04:28:16 +0000 | |||
926 | +++ libubuntu-app-launch/application-info-desktop.h 2017-04-04 21:22:36 +0000 | |||
927 | @@ -17,13 +17,15 @@ | |||
928 | 17 | * Ted Gould <ted.gould@canonical.com> | 17 | * Ted Gould <ted.gould@canonical.com> |
929 | 18 | */ | 18 | */ |
930 | 19 | 19 | ||
931 | 20 | #pragma once | ||
932 | 21 | |||
933 | 20 | #include "application.h" | 22 | #include "application.h" |
934 | 23 | #include "registry-impl.h" | ||
935 | 24 | #include "registry.h" | ||
936 | 21 | #include <bitset> | 25 | #include <bitset> |
937 | 22 | #include <glib.h> | 26 | #include <glib.h> |
938 | 23 | #include <mutex> | 27 | #include <mutex> |
939 | 24 | 28 | ||
940 | 25 | #pragma once | ||
941 | 26 | |||
942 | 27 | namespace ubuntu | 29 | namespace ubuntu |
943 | 28 | { | 30 | { |
944 | 29 | namespace app_launch | 31 | namespace app_launch |
945 | @@ -46,7 +48,7 @@ | |||
946 | 46 | const std::string& basePath, | 48 | const std::string& basePath, |
947 | 47 | const std::string& rootDir, | 49 | const std::string& rootDir, |
948 | 48 | std::bitset<2> flags, | 50 | std::bitset<2> flags, |
950 | 49 | std::shared_ptr<Registry> registry); | 51 | const std::shared_ptr<Registry::Impl>& registry); |
951 | 50 | 52 | ||
952 | 51 | const Application::Info::Name& name() override | 53 | const Application::Info::Name& name() override |
953 | 52 | { | 54 | { |
954 | 53 | 55 | ||
955 | === modified file 'libubuntu-app-launch/application.cpp' | |||
956 | --- libubuntu-app-launch/application.cpp 2017-02-25 15:58:27 +0000 | |||
957 | +++ libubuntu-app-launch/application.cpp 2017-04-04 21:22:36 +0000 | |||
958 | @@ -48,20 +48,7 @@ | |||
959 | 48 | throw std::runtime_error("Invalid registry object"); | 48 | throw std::runtime_error("Invalid registry object"); |
960 | 49 | } | 49 | } |
961 | 50 | 50 | ||
976 | 51 | if (!registry->impl->jobs) | 51 | return registry->impl->createApp(appid); |
963 | 52 | { | ||
964 | 53 | registry->impl->jobs = jobs::manager::Base::determineFactory(registry); | ||
965 | 54 | } | ||
966 | 55 | |||
967 | 56 | for (const auto& appStore : registry->impl->appStores()) | ||
968 | 57 | { | ||
969 | 58 | if (appStore->hasAppId(appid, registry)) | ||
970 | 59 | { | ||
971 | 60 | return appStore->create(appid, registry); | ||
972 | 61 | } | ||
973 | 62 | } | ||
974 | 63 | |||
975 | 64 | throw std::runtime_error("Invalid app ID: " + std::string(appid)); | ||
977 | 65 | } | 52 | } |
978 | 66 | 53 | ||
979 | 67 | AppID::AppID() | 54 | AppID::AppID() |
980 | @@ -110,11 +97,16 @@ | |||
981 | 110 | AppID AppID::find(const std::string& sappid) | 97 | AppID AppID::find(const std::string& sappid) |
982 | 111 | { | 98 | { |
983 | 112 | auto registry = Registry::getDefault(); | 99 | auto registry = Registry::getDefault(); |
985 | 113 | return find(registry, sappid); | 100 | return registry->impl->find(sappid); |
986 | 114 | } | 101 | } |
987 | 115 | 102 | ||
988 | 116 | AppID AppID::find(const std::shared_ptr<Registry>& registry, const std::string& sappid) | 103 | AppID AppID::find(const std::shared_ptr<Registry>& registry, const std::string& sappid) |
989 | 117 | { | 104 | { |
990 | 105 | return registry->impl->find(sappid); | ||
991 | 106 | } | ||
992 | 107 | |||
993 | 108 | AppID Registry::Impl::find(const std::string& sappid) | ||
994 | 109 | { | ||
995 | 118 | std::smatch match; | 110 | std::smatch match; |
996 | 119 | 111 | ||
997 | 120 | if (std::regex_match(sappid, match, full_appid_regex)) | 112 | if (std::regex_match(sappid, match, full_appid_regex)) |
998 | @@ -124,7 +116,7 @@ | |||
999 | 124 | } | 116 | } |
1000 | 125 | else if (std::regex_match(sappid, match, short_appid_regex)) | 117 | else if (std::regex_match(sappid, match, short_appid_regex)) |
1001 | 126 | { | 118 | { |
1003 | 127 | return discover(registry, match[1].str(), match[2].str()); | 119 | return discover(match[1].str(), match[2].str(), AppID::VersionWildcard::CURRENT_USER_VERSION); |
1004 | 128 | } | 120 | } |
1005 | 129 | else if (std::regex_match(sappid, match, legacy_appid_regex)) | 121 | else if (std::regex_match(sappid, match, legacy_appid_regex)) |
1006 | 130 | { | 122 | { |
1007 | @@ -181,33 +173,38 @@ | |||
1008 | 181 | const std::string& appname, | 173 | const std::string& appname, |
1009 | 182 | const std::string& version) | 174 | const std::string& version) |
1010 | 183 | { | 175 | { |
1011 | 176 | return registry->impl->discover(package, appname, version); | ||
1012 | 177 | } | ||
1013 | 178 | |||
1014 | 179 | AppID Registry::Impl::discover(const std::string& package, const std::string& appname, const std::string& version) | ||
1015 | 180 | { | ||
1016 | 184 | auto pkg = AppID::Package::from_raw(package); | 181 | auto pkg = AppID::Package::from_raw(package); |
1017 | 185 | 182 | ||
1019 | 186 | for (const auto& appStore : registry->impl->appStores()) | 183 | for (const auto& appStore : appStores()) |
1020 | 187 | { | 184 | { |
1021 | 188 | /* Figure out which type we have */ | 185 | /* Figure out which type we have */ |
1022 | 189 | try | 186 | try |
1023 | 190 | { | 187 | { |
1025 | 191 | if (appStore->verifyPackage(pkg, registry)) | 188 | if (appStore->verifyPackage(pkg)) |
1026 | 192 | { | 189 | { |
1027 | 193 | auto app = AppID::AppName::from_raw({}); | 190 | auto app = AppID::AppName::from_raw({}); |
1028 | 194 | 191 | ||
1029 | 195 | if (appname.empty() || appname == "first-listed-app") | 192 | if (appname.empty() || appname == "first-listed-app") |
1030 | 196 | { | 193 | { |
1032 | 197 | app = appStore->findAppname(pkg, ApplicationWildcard::FIRST_LISTED, registry); | 194 | app = appStore->findAppname(pkg, AppID::ApplicationWildcard::FIRST_LISTED); |
1033 | 198 | } | 195 | } |
1034 | 199 | else if (appname == "last-listed-app") | 196 | else if (appname == "last-listed-app") |
1035 | 200 | { | 197 | { |
1037 | 201 | app = appStore->findAppname(pkg, ApplicationWildcard::LAST_LISTED, registry); | 198 | app = appStore->findAppname(pkg, AppID::ApplicationWildcard::LAST_LISTED); |
1038 | 202 | } | 199 | } |
1039 | 203 | else if (appname == "only-listed-app") | 200 | else if (appname == "only-listed-app") |
1040 | 204 | { | 201 | { |
1042 | 205 | app = appStore->findAppname(pkg, ApplicationWildcard::ONLY_LISTED, registry); | 202 | app = appStore->findAppname(pkg, AppID::ApplicationWildcard::ONLY_LISTED); |
1043 | 206 | } | 203 | } |
1044 | 207 | else | 204 | else |
1045 | 208 | { | 205 | { |
1046 | 209 | app = AppID::AppName::from_raw(appname); | 206 | app = AppID::AppName::from_raw(appname); |
1048 | 210 | if (!appStore->verifyAppname(pkg, app, registry)) | 207 | if (!appStore->verifyAppname(pkg, app)) |
1049 | 211 | { | 208 | { |
1050 | 212 | throw std::runtime_error("App name passed in is not valid for this package type"); | 209 | throw std::runtime_error("App name passed in is not valid for this package type"); |
1051 | 213 | } | 210 | } |
1052 | @@ -216,12 +213,12 @@ | |||
1053 | 216 | auto ver = AppID::Version::from_raw({}); | 213 | auto ver = AppID::Version::from_raw({}); |
1054 | 217 | if (version.empty() || version == "current-user-version") | 214 | if (version.empty() || version == "current-user-version") |
1055 | 218 | { | 215 | { |
1057 | 219 | ver = appStore->findVersion(pkg, app, registry); | 216 | ver = appStore->findVersion(pkg, app); |
1058 | 220 | } | 217 | } |
1059 | 221 | else | 218 | else |
1060 | 222 | { | 219 | { |
1061 | 223 | ver = AppID::Version::from_raw(version); | 220 | ver = AppID::Version::from_raw(version); |
1063 | 224 | if (!appStore->hasAppId({pkg, app, ver}, registry)) | 221 | if (!appStore->hasAppId({pkg, app, ver})) |
1064 | 225 | { | 222 | { |
1065 | 226 | throw std::runtime_error("Invalid version passed for this package type"); | 223 | throw std::runtime_error("Invalid version passed for this package type"); |
1066 | 227 | } | 224 | } |
1067 | @@ -244,16 +241,23 @@ | |||
1068 | 244 | ApplicationWildcard appwildcard, | 241 | ApplicationWildcard appwildcard, |
1069 | 245 | VersionWildcard versionwildcard) | 242 | VersionWildcard versionwildcard) |
1070 | 246 | { | 243 | { |
1071 | 244 | return registry->impl->discover(package, appwildcard, versionwildcard); | ||
1072 | 245 | } | ||
1073 | 246 | |||
1074 | 247 | AppID Registry::Impl::discover(const std::string& package, | ||
1075 | 248 | AppID::ApplicationWildcard appwildcard, | ||
1076 | 249 | AppID::VersionWildcard versionwildcard) | ||
1077 | 250 | { | ||
1078 | 247 | auto pkg = AppID::Package::from_raw(package); | 251 | auto pkg = AppID::Package::from_raw(package); |
1079 | 248 | 252 | ||
1081 | 249 | for (const auto& appStore : registry->impl->appStores()) | 253 | for (const auto& appStore : appStores()) |
1082 | 250 | { | 254 | { |
1083 | 251 | try | 255 | try |
1084 | 252 | { | 256 | { |
1086 | 253 | if (appStore->verifyPackage(pkg, registry)) | 257 | if (appStore->verifyPackage(pkg)) |
1087 | 254 | { | 258 | { |
1090 | 255 | auto app = appStore->findAppname(pkg, appwildcard, registry); | 259 | auto app = appStore->findAppname(pkg, appwildcard); |
1091 | 256 | auto ver = appStore->findVersion(pkg, app, registry); | 260 | auto ver = appStore->findVersion(pkg, app); |
1092 | 257 | return AppID{pkg, app, ver}; | 261 | return AppID{pkg, app, ver}; |
1093 | 258 | } | 262 | } |
1094 | 259 | } | 263 | } |
1095 | @@ -272,16 +276,23 @@ | |||
1096 | 272 | const std::string& appname, | 276 | const std::string& appname, |
1097 | 273 | VersionWildcard versionwildcard) | 277 | VersionWildcard versionwildcard) |
1098 | 274 | { | 278 | { |
1099 | 279 | return registry->impl->discover(package, appname, versionwildcard); | ||
1100 | 280 | } | ||
1101 | 281 | |||
1102 | 282 | AppID Registry::Impl::discover(const std::string& package, | ||
1103 | 283 | const std::string& appname, | ||
1104 | 284 | AppID::VersionWildcard versionwildcard) | ||
1105 | 285 | { | ||
1106 | 275 | auto pkg = AppID::Package::from_raw(package); | 286 | auto pkg = AppID::Package::from_raw(package); |
1107 | 276 | auto app = AppID::AppName::from_raw(appname); | 287 | auto app = AppID::AppName::from_raw(appname); |
1108 | 277 | 288 | ||
1110 | 278 | for (const auto& appStore : registry->impl->appStores()) | 289 | for (const auto& appStore : appStores()) |
1111 | 279 | { | 290 | { |
1112 | 280 | try | 291 | try |
1113 | 281 | { | 292 | { |
1115 | 282 | if (appStore->verifyPackage(pkg, registry) && appStore->verifyAppname(pkg, app, registry)) | 293 | if (appStore->verifyPackage(pkg) && appStore->verifyAppname(pkg, app)) |
1116 | 283 | { | 294 | { |
1118 | 284 | auto ver = appStore->findVersion(pkg, app, registry); | 295 | auto ver = appStore->findVersion(pkg, app); |
1119 | 285 | return AppID{pkg, app, ver}; | 296 | return AppID{pkg, app, ver}; |
1120 | 286 | } | 297 | } |
1121 | 287 | } | 298 | } |
1122 | @@ -298,19 +309,19 @@ | |||
1123 | 298 | AppID AppID::discover(const std::string& package, const std::string& appname, const std::string& version) | 309 | AppID AppID::discover(const std::string& package, const std::string& appname, const std::string& version) |
1124 | 299 | { | 310 | { |
1125 | 300 | auto registry = Registry::getDefault(); | 311 | auto registry = Registry::getDefault(); |
1127 | 301 | return discover(registry, package, appname, version); | 312 | return registry->impl->discover(package, appname, version); |
1128 | 302 | } | 313 | } |
1129 | 303 | 314 | ||
1130 | 304 | AppID AppID::discover(const std::string& package, ApplicationWildcard appwildcard, VersionWildcard versionwildcard) | 315 | AppID AppID::discover(const std::string& package, ApplicationWildcard appwildcard, VersionWildcard versionwildcard) |
1131 | 305 | { | 316 | { |
1132 | 306 | auto registry = Registry::getDefault(); | 317 | auto registry = Registry::getDefault(); |
1134 | 307 | return discover(registry, package, appwildcard, versionwildcard); | 318 | return registry->impl->discover(package, appwildcard, versionwildcard); |
1135 | 308 | } | 319 | } |
1136 | 309 | 320 | ||
1137 | 310 | AppID AppID::discover(const std::string& package, const std::string& appname, VersionWildcard versionwildcard) | 321 | AppID AppID::discover(const std::string& package, const std::string& appname, VersionWildcard versionwildcard) |
1138 | 311 | { | 322 | { |
1139 | 312 | auto registry = Registry::getDefault(); | 323 | auto registry = Registry::getDefault(); |
1141 | 313 | return discover(registry, package, appname, versionwildcard); | 324 | return registry->impl->discover(package, appname, versionwildcard); |
1142 | 314 | } | 325 | } |
1143 | 315 | 326 | ||
1144 | 316 | enum class oom::Score : std::int32_t | 327 | enum class oom::Score : std::int32_t |
1145 | 317 | 328 | ||
1146 | === modified file 'libubuntu-app-launch/helper-impl.h' | |||
1147 | --- libubuntu-app-launch/helper-impl.h 2017-03-14 03:23:02 +0000 | |||
1148 | +++ libubuntu-app-launch/helper-impl.h 2017-04-04 21:22:36 +0000 | |||
1149 | @@ -55,7 +55,7 @@ | |||
1150 | 55 | class Base : public Helper | 55 | class Base : public Helper |
1151 | 56 | { | 56 | { |
1152 | 57 | public: | 57 | public: |
1154 | 58 | Base(const Helper::Type& type, const AppID& appid, const std::shared_ptr<Registry>& registry); | 58 | Base(const Helper::Type& type, const AppID& appid, const std::shared_ptr<Registry::Impl>& registry); |
1155 | 59 | 59 | ||
1156 | 60 | AppID appId() override; | 60 | AppID appId() override; |
1157 | 61 | 61 | ||
1158 | @@ -70,7 +70,7 @@ | |||
1159 | 70 | private: | 70 | private: |
1160 | 71 | Helper::Type _type; | 71 | Helper::Type _type; |
1161 | 72 | AppID _appid; | 72 | AppID _appid; |
1163 | 73 | std::shared_ptr<Registry> _registry; | 73 | std::shared_ptr<Registry::Impl> registry_; |
1164 | 74 | 74 | ||
1165 | 75 | std::list<std::pair<std::string, std::string>> defaultEnv(); | 75 | std::list<std::pair<std::string, std::string>> defaultEnv(); |
1166 | 76 | }; | 76 | }; |
1167 | 77 | 77 | ||
1168 | === modified file 'libubuntu-app-launch/helper.cpp' | |||
1169 | --- libubuntu-app-launch/helper.cpp 2017-03-20 12:28:10 +0000 | |||
1170 | +++ libubuntu-app-launch/helper.cpp 2017-04-04 21:22:36 +0000 | |||
1171 | @@ -73,10 +73,10 @@ | |||
1172 | 73 | * Helper Class | 73 | * Helper Class |
1173 | 74 | **********************/ | 74 | **********************/ |
1174 | 75 | 75 | ||
1176 | 76 | Base::Base(const Helper::Type& type, const AppID& appid, const std::shared_ptr<Registry>& registry) | 76 | Base::Base(const Helper::Type& type, const AppID& appid, const std::shared_ptr<Registry::Impl>& registry) |
1177 | 77 | : _type(type) | 77 | : _type(type) |
1178 | 78 | , _appid(appid) | 78 | , _appid(appid) |
1180 | 79 | , _registry(registry) | 79 | , registry_(registry) |
1181 | 80 | { | 80 | { |
1182 | 81 | } | 81 | } |
1183 | 82 | 82 | ||
1184 | @@ -92,7 +92,7 @@ | |||
1185 | 92 | 92 | ||
1186 | 93 | std::vector<std::shared_ptr<Helper::Instance>> Base::instances() | 93 | std::vector<std::shared_ptr<Helper::Instance>> Base::instances() |
1187 | 94 | { | 94 | { |
1189 | 95 | auto insts = _registry->impl->jobs->instances(_appid, _type.value()); | 95 | auto insts = registry_->jobs()->instances(_appid, _type.value()); |
1190 | 96 | std::vector<std::shared_ptr<Helper::Instance>> wrapped{insts.size()}; | 96 | std::vector<std::shared_ptr<Helper::Instance>> wrapped{insts.size()}; |
1191 | 97 | 97 | ||
1192 | 98 | std::transform(insts.begin(), insts.end(), wrapped.begin(), | 98 | std::transform(insts.begin(), insts.end(), wrapped.begin(), |
1193 | @@ -104,7 +104,7 @@ | |||
1194 | 104 | /** Find an instance that we already know the ID of */ | 104 | /** Find an instance that we already know the ID of */ |
1195 | 105 | std::shared_ptr<Helper::Instance> Base::existingInstance(const std::string& instanceid) | 105 | std::shared_ptr<Helper::Instance> Base::existingInstance(const std::string& instanceid) |
1196 | 106 | { | 106 | { |
1198 | 107 | auto appinst = _registry->impl->jobs->existing(_appid, _type.value(), instanceid, {}); | 107 | auto appinst = registry_->jobs()->existing(_appid, _type.value(), instanceid, {}); |
1199 | 108 | 108 | ||
1200 | 109 | return std::make_shared<BaseInstance>(appinst); | 109 | return std::make_shared<BaseInstance>(appinst); |
1201 | 110 | } | 110 | } |
1202 | @@ -212,14 +212,14 @@ | |||
1203 | 212 | auto defaultenv = defaultEnv(); | 212 | auto defaultenv = defaultEnv(); |
1204 | 213 | std::function<std::list<std::pair<std::string, std::string>>()> envfunc = [defaultenv]() { return defaultenv; }; | 213 | std::function<std::list<std::pair<std::string, std::string>>()> envfunc = [defaultenv]() { return defaultenv; }; |
1205 | 214 | 214 | ||
1207 | 215 | return std::make_shared<BaseInstance>(_registry->impl->jobs->launch( | 215 | return std::make_shared<BaseInstance>(registry_->jobs()->launch( |
1208 | 216 | _appid, _type.value(), genInstanceId(), appURL(urls), jobs::manager::launchMode::STANDARD, envfunc)); | 216 | _appid, _type.value(), genInstanceId(), appURL(urls), jobs::manager::launchMode::STANDARD, envfunc)); |
1209 | 217 | } | 217 | } |
1210 | 218 | 218 | ||
1211 | 219 | class MirFDProxy | 219 | class MirFDProxy |
1212 | 220 | { | 220 | { |
1213 | 221 | public: | 221 | public: |
1215 | 222 | std::shared_ptr<Registry> reg_; | 222 | std::shared_ptr<Registry::Impl> reg_; |
1216 | 223 | ResourcePtr<int, void (*)(int)> mirfd; | 223 | ResourcePtr<int, void (*)(int)> mirfd; |
1217 | 224 | std::shared_ptr<proxySocketDemangler> skel; | 224 | std::shared_ptr<proxySocketDemangler> skel; |
1218 | 225 | ManagedSignalConnection<proxySocketDemangler> handle; | 225 | ManagedSignalConnection<proxySocketDemangler> handle; |
1219 | @@ -227,7 +227,7 @@ | |||
1220 | 227 | std::string name; | 227 | std::string name; |
1221 | 228 | guint timeout{0}; | 228 | guint timeout{0}; |
1222 | 229 | 229 | ||
1224 | 230 | MirFDProxy(MirPromptSession* session, const AppID& appid, const std::shared_ptr<Registry>& reg) | 230 | MirFDProxy(MirPromptSession* session, const AppID& appid, const std::shared_ptr<Registry::Impl>& reg) |
1225 | 231 | : reg_(reg) | 231 | : reg_(reg) |
1226 | 232 | , mirfd(0, | 232 | , mirfd(0, |
1227 | 233 | [](int fp) { | 233 | [](int fp) { |
1228 | @@ -235,7 +235,7 @@ | |||
1229 | 235 | close(fp); | 235 | close(fp); |
1230 | 236 | }) | 236 | }) |
1231 | 237 | , handle(SignalUnsubscriber<proxySocketDemangler>{}) | 237 | , handle(SignalUnsubscriber<proxySocketDemangler>{}) |
1233 | 238 | , name(g_dbus_connection_get_unique_name(reg->impl->_dbus.get())) | 238 | , name(g_dbus_connection_get_unique_name(reg->_dbus.get())) |
1234 | 239 | { | 239 | { |
1235 | 240 | if (appid.empty()) | 240 | if (appid.empty()) |
1236 | 241 | { | 241 | { |
1237 | @@ -268,7 +268,7 @@ | |||
1238 | 268 | } | 268 | } |
1239 | 269 | 269 | ||
1240 | 270 | /* Setup the DBus interface */ | 270 | /* Setup the DBus interface */ |
1242 | 271 | std::tie(skel, handle, path) = reg->impl->thread.executeOnThread<std::tuple< | 271 | std::tie(skel, handle, path) = reg->thread.executeOnThread<std::tuple< |
1243 | 272 | std::shared_ptr<proxySocketDemangler>, ManagedSignalConnection<proxySocketDemangler>, std::string>>( | 272 | std::shared_ptr<proxySocketDemangler>, ManagedSignalConnection<proxySocketDemangler>, std::string>>( |
1244 | 273 | [this, appid, reg]() { | 273 | [this, appid, reg]() { |
1245 | 274 | auto skel = share_gobject(proxy_socket_demangler_skeleton_new()); | 274 | auto skel = share_gobject(proxy_socket_demangler_skeleton_new()); |
1246 | @@ -285,7 +285,7 @@ | |||
1247 | 285 | GError* error = nullptr; | 285 | GError* error = nullptr; |
1248 | 286 | std::string tryname = "/com/canonical/UbuntuAppLaunch/" + dbusAppid + "/" + std::to_string(rand()); | 286 | std::string tryname = "/com/canonical/UbuntuAppLaunch/" + dbusAppid + "/" + std::to_string(rand()); |
1249 | 287 | 287 | ||
1251 | 288 | g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(skel.get()), reg->impl->_dbus.get(), | 288 | g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(skel.get()), reg->_dbus.get(), |
1252 | 289 | tryname.c_str(), &error); | 289 | tryname.c_str(), &error); |
1253 | 290 | 290 | ||
1254 | 291 | if (error == nullptr) | 291 | if (error == nullptr) |
1255 | @@ -355,7 +355,7 @@ | |||
1256 | 355 | auto reg = reg_; | 355 | auto reg = reg_; |
1257 | 356 | auto timeoutlocal = timeout; | 356 | auto timeoutlocal = timeout; |
1258 | 357 | 357 | ||
1260 | 358 | reg->impl->thread.executeOnThread([reg, timeoutlocal]() { reg->impl->thread.removeSource(timeoutlocal); }); | 358 | reg->thread.executeOnThread([reg, timeoutlocal]() { reg->thread.removeSource(timeoutlocal); }); |
1261 | 359 | 359 | ||
1262 | 360 | return true; | 360 | return true; |
1263 | 361 | } | 361 | } |
1264 | @@ -381,7 +381,7 @@ | |||
1265 | 381 | std::shared_ptr<MirFDProxy> proxy; | 381 | std::shared_ptr<MirFDProxy> proxy; |
1266 | 382 | try | 382 | try |
1267 | 383 | { | 383 | { |
1269 | 384 | proxy = std::make_shared<MirFDProxy>(session, _appid, _registry); | 384 | proxy = std::make_shared<MirFDProxy>(session, _appid, registry_); |
1270 | 385 | } | 385 | } |
1271 | 386 | catch (std::runtime_error& e) | 386 | catch (std::runtime_error& e) |
1272 | 387 | { | 387 | { |
1273 | @@ -401,10 +401,9 @@ | |||
1274 | 401 | 401 | ||
1275 | 402 | /* This will maintain a reference to the proxy for two | 402 | /* This will maintain a reference to the proxy for two |
1276 | 403 | seconds. And then it'll be dropped. */ | 403 | seconds. And then it'll be dropped. */ |
1279 | 404 | proxy->setTimeout( | 404 | proxy->setTimeout(registry_->thread.timeout(std::chrono::seconds{2}, [proxy]() { g_debug("Mir Proxy Timeout"); })); |
1278 | 405 | _registry->impl->thread.timeout(std::chrono::seconds{2}, [proxy]() { g_debug("Mir Proxy Timeout"); })); | ||
1280 | 406 | 405 | ||
1282 | 407 | return std::make_shared<BaseInstance>(_registry->impl->jobs->launch( | 406 | return std::make_shared<BaseInstance>(registry_->jobs()->launch( |
1283 | 408 | _appid, _type.value(), genInstanceId(), appURL(urls), jobs::manager::launchMode::STANDARD, envfunc)); | 407 | _appid, _type.value(), genInstanceId(), appURL(urls), jobs::manager::launchMode::STANDARD, envfunc)); |
1284 | 409 | } | 408 | } |
1285 | 410 | 409 | ||
1286 | @@ -416,8 +415,7 @@ | |||
1287 | 416 | 415 | ||
1288 | 417 | std::shared_ptr<Helper> Helper::create(Type type, AppID appid, std::shared_ptr<Registry> registry) | 416 | std::shared_ptr<Helper> Helper::create(Type type, AppID appid, std::shared_ptr<Registry> registry) |
1289 | 418 | { | 417 | { |
1292 | 419 | /* Only one type today */ | 418 | return registry->impl->createHelper(type, appid, registry->impl); |
1291 | 420 | return std::make_shared<helper_impls::Base>(type, appid, registry); | ||
1293 | 421 | } | 419 | } |
1294 | 422 | 420 | ||
1295 | 423 | /* Hardcore socket stuff */ | 421 | /* Hardcore socket stuff */ |
1296 | 424 | 422 | ||
1297 | === modified file 'libubuntu-app-launch/info-watcher-zg.cpp' | |||
1298 | --- libubuntu-app-launch/info-watcher-zg.cpp 2017-02-10 16:50:40 +0000 | |||
1299 | +++ libubuntu-app-launch/info-watcher-zg.cpp 2017-04-04 21:22:36 +0000 | |||
1300 | @@ -28,7 +28,7 @@ | |||
1301 | 28 | namespace info_watcher | 28 | namespace info_watcher |
1302 | 29 | { | 29 | { |
1303 | 30 | 30 | ||
1305 | 31 | Zeitgeist::Zeitgeist(const std::shared_ptr<Registry>& registry) | 31 | Zeitgeist::Zeitgeist(const std::shared_ptr<Registry::Impl>& registry) |
1306 | 32 | : Base(registry) | 32 | : Base(registry) |
1307 | 33 | { | 33 | { |
1308 | 34 | g_debug("Created a ZG Watcher"); | 34 | g_debug("Created a ZG Watcher"); |
1309 | 35 | 35 | ||
1310 | === modified file 'libubuntu-app-launch/info-watcher-zg.h' | |||
1311 | --- libubuntu-app-launch/info-watcher-zg.h 2017-02-10 16:50:40 +0000 | |||
1312 | +++ libubuntu-app-launch/info-watcher-zg.h 2017-04-04 21:22:36 +0000 | |||
1313 | @@ -36,7 +36,7 @@ | |||
1314 | 36 | class Zeitgeist : public Base | 36 | class Zeitgeist : public Base |
1315 | 37 | { | 37 | { |
1316 | 38 | public: | 38 | public: |
1318 | 39 | Zeitgeist(const std::shared_ptr<Registry>& registry); | 39 | Zeitgeist(const std::shared_ptr<Registry::Impl>& registry); |
1319 | 40 | virtual ~Zeitgeist() = default; | 40 | virtual ~Zeitgeist() = default; |
1320 | 41 | 41 | ||
1321 | 42 | virtual Application::Info::Popularity lookupAppPopularity(const AppID& appid); | 42 | virtual Application::Info::Popularity lookupAppPopularity(const AppID& appid); |
1322 | 43 | 43 | ||
1323 | === modified file 'libubuntu-app-launch/info-watcher.cpp' | |||
1324 | --- libubuntu-app-launch/info-watcher.cpp 2017-02-08 21:31:37 +0000 | |||
1325 | +++ libubuntu-app-launch/info-watcher.cpp 2017-04-04 21:22:36 +0000 | |||
1326 | @@ -18,6 +18,7 @@ | |||
1327 | 18 | */ | 18 | */ |
1328 | 19 | 19 | ||
1329 | 20 | #include "info-watcher.h" | 20 | #include "info-watcher.h" |
1330 | 21 | #include <glib.h> | ||
1331 | 21 | 22 | ||
1332 | 22 | namespace ubuntu | 23 | namespace ubuntu |
1333 | 23 | { | 24 | { |
1334 | @@ -26,8 +27,21 @@ | |||
1335 | 26 | namespace info_watcher | 27 | namespace info_watcher |
1336 | 27 | { | 28 | { |
1337 | 28 | 29 | ||
1340 | 29 | Base::Base(const std::shared_ptr<Registry>& registry) | 30 | Base::Base(const std::shared_ptr<Registry::Impl>& registry) |
1341 | 30 | { | 31 | : registry_(registry) |
1342 | 32 | { | ||
1343 | 33 | } | ||
1344 | 34 | |||
1345 | 35 | /** Accessor function to the registry that ensures we can still | ||
1346 | 36 | get it, which we always should be able to, but in case. */ | ||
1347 | 37 | std::shared_ptr<Registry::Impl> Base::getReg() | ||
1348 | 38 | { | ||
1349 | 39 | auto reg = registry_.lock(); | ||
1350 | 40 | if (G_UNLIKELY(!reg)) | ||
1351 | 41 | { | ||
1352 | 42 | throw std::runtime_error{"App Store lost track of the Registry that owns it"}; | ||
1353 | 43 | } | ||
1354 | 44 | return reg; | ||
1355 | 31 | } | 45 | } |
1356 | 32 | 46 | ||
1357 | 33 | } // namespace info_watcher | 47 | } // namespace info_watcher |
1358 | 34 | 48 | ||
1359 | === modified file 'libubuntu-app-launch/info-watcher.h' | |||
1360 | --- libubuntu-app-launch/info-watcher.h 2017-02-08 21:31:37 +0000 | |||
1361 | +++ libubuntu-app-launch/info-watcher.h 2017-04-04 21:22:36 +0000 | |||
1362 | @@ -35,7 +35,7 @@ | |||
1363 | 35 | class Base | 35 | class Base |
1364 | 36 | { | 36 | { |
1365 | 37 | public: | 37 | public: |
1367 | 38 | Base(const std::shared_ptr<Registry>& registry); | 38 | Base(const std::shared_ptr<Registry::Impl>& registry); |
1368 | 39 | virtual ~Base() = default; | 39 | virtual ~Base() = default; |
1369 | 40 | 40 | ||
1370 | 41 | virtual core::Signal<const std::shared_ptr<Application>&>& infoChanged() | 41 | virtual core::Signal<const std::shared_ptr<Application>&>& infoChanged() |
1371 | @@ -44,7 +44,16 @@ | |||
1372 | 44 | } | 44 | } |
1373 | 45 | 45 | ||
1374 | 46 | protected: | 46 | protected: |
1375 | 47 | /** Signal for info changed on an application */ | ||
1376 | 47 | core::Signal<const std::shared_ptr<Application>&> infoChanged_; | 48 | core::Signal<const std::shared_ptr<Application>&> infoChanged_; |
1377 | 49 | |||
1378 | 50 | /** Accessor function to the registry that ensures we can still | ||
1379 | 51 | get it, which we always should be able to, but in case. */ | ||
1380 | 52 | std::shared_ptr<Registry::Impl> getReg(); | ||
1381 | 53 | |||
1382 | 54 | private: | ||
1383 | 55 | /** Pointer to our implementing registry */ | ||
1384 | 56 | std::weak_ptr<Registry::Impl> registry_; | ||
1385 | 48 | }; | 57 | }; |
1386 | 49 | 58 | ||
1387 | 50 | } // namespace info_watcher | 59 | } // namespace info_watcher |
1388 | 51 | 60 | ||
1389 | === modified file 'libubuntu-app-launch/jobs-base.cpp' | |||
1390 | --- libubuntu-app-launch/jobs-base.cpp 2017-03-21 03:28:22 +0000 | |||
1391 | +++ libubuntu-app-launch/jobs-base.cpp 2017-04-04 21:22:36 +0000 | |||
1392 | @@ -43,10 +43,9 @@ | |||
1393 | 43 | namespace manager | 43 | namespace manager |
1394 | 44 | { | 44 | { |
1395 | 45 | 45 | ||
1398 | 46 | Base::Base(const std::shared_ptr<Registry>& registry) | 46 | Base::Base(const std::shared_ptr<Registry::Impl>& registry) |
1399 | 47 | : registry_(registry) | 47 | : registry_{registry} |
1400 | 48 | , allApplicationJobs_{"application-legacy", "application-snap"} | 48 | , allApplicationJobs_{"application-legacy", "application-snap"} |
1401 | 49 | , dbus_(registry->impl->_dbus) | ||
1402 | 50 | { | 49 | { |
1403 | 51 | } | 50 | } |
1404 | 52 | 51 | ||
1405 | @@ -56,7 +55,7 @@ | |||
1406 | 56 | 55 | ||
1407 | 57 | /** Should determine which jobs backend to use, but we only have | 56 | /** Should determine which jobs backend to use, but we only have |
1408 | 58 | one right now. */ | 57 | one right now. */ |
1410 | 59 | std::shared_ptr<Base> Base::determineFactory(std::shared_ptr<Registry> registry) | 58 | std::shared_ptr<Base> Base::determineFactory(const std::shared_ptr<Registry::Impl>& registry) |
1411 | 60 | { | 59 | { |
1412 | 61 | g_debug("Building a systemd jobs manager"); | 60 | g_debug("Building a systemd jobs manager"); |
1413 | 62 | return std::make_shared<jobs::manager::SystemD>(registry); | 61 | return std::make_shared<jobs::manager::SystemD>(registry); |
1414 | @@ -79,10 +78,9 @@ | |||
1415 | 79 | 78 | ||
1416 | 80 | try | 79 | try |
1417 | 81 | { | 80 | { |
1422 | 82 | auto reg = registry_.lock(); | 81 | auto reg = getReg(); |
1423 | 83 | 82 | auto appId = reg->find(appid); | |
1424 | 84 | auto appId = AppID::find(reg, appid); | 83 | auto app = reg->createApp(appId); |
1421 | 85 | auto app = Application::create(appId, reg); | ||
1425 | 86 | auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(instanceid); | 84 | auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(instanceid); |
1426 | 87 | 85 | ||
1427 | 88 | sig_appStarted(app, inst); | 86 | sig_appStarted(app, inst); |
1428 | @@ -109,10 +107,9 @@ | |||
1429 | 109 | 107 | ||
1430 | 110 | try | 108 | try |
1431 | 111 | { | 109 | { |
1436 | 112 | auto reg = registry_.lock(); | 110 | auto reg = getReg(); |
1437 | 113 | 111 | auto appId = reg->find(appid); | |
1438 | 114 | auto appId = AppID::find(reg, appid); | 112 | auto app = reg->createApp(appId); |
1435 | 115 | auto app = Application::create(appId, reg); | ||
1439 | 116 | auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(instanceid); | 113 | auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(instanceid); |
1440 | 117 | 114 | ||
1441 | 118 | sig_appStopped(app, inst); | 115 | sig_appStopped(app, inst); |
1442 | @@ -141,10 +138,9 @@ | |||
1443 | 141 | 138 | ||
1444 | 142 | try | 139 | try |
1445 | 143 | { | 140 | { |
1450 | 144 | auto reg = registry_.lock(); | 141 | auto reg = getReg(); |
1451 | 145 | 142 | auto appId = reg->find(appid); | |
1452 | 146 | auto appId = AppID::find(reg, appid); | 143 | auto app = reg->createApp(appId); |
1449 | 147 | auto app = Application::create(appId, reg); | ||
1453 | 148 | auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(instanceid); | 144 | auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(instanceid); |
1454 | 149 | 145 | ||
1455 | 150 | sig_appFailed(app, inst, reason); | 146 | sig_appFailed(app, inst, reason); |
1456 | @@ -166,7 +162,7 @@ | |||
1457 | 166 | { | 162 | { |
1458 | 167 | /** Keeping a weak pointer because the handle is held by | 163 | /** Keeping a weak pointer because the handle is held by |
1459 | 168 | the registry implementation. */ | 164 | the registry implementation. */ |
1461 | 169 | std::weak_ptr<Registry> weakReg; | 165 | std::weak_ptr<Registry::Impl> weakReg; |
1462 | 170 | }; | 166 | }; |
1463 | 171 | 167 | ||
1464 | 172 | /** Core handler for pause and resume events. Includes turning the GVariant | 168 | /** Core handler for pause and resume events. Includes turning the GVariant |
1465 | @@ -175,7 +171,7 @@ | |||
1466 | 175 | const std::shared_ptr<Application::Instance>&, | 171 | const std::shared_ptr<Application::Instance>&, |
1467 | 176 | const std::vector<pid_t>&>& signal, | 172 | const std::vector<pid_t>&>& signal, |
1468 | 177 | const std::shared_ptr<GVariant>& params, | 173 | const std::shared_ptr<GVariant>& params, |
1470 | 178 | const std::shared_ptr<Registry>& reg) | 174 | const std::shared_ptr<Registry::Impl>& reg) |
1471 | 179 | { | 175 | { |
1472 | 180 | std::vector<pid_t> pids; | 176 | std::vector<pid_t> pids; |
1473 | 181 | auto vappid = unique_glib(g_variant_get_child_value(params.get(), 0)); | 177 | auto vappid = unique_glib(g_variant_get_child_value(params.get(), 0)); |
1474 | @@ -193,8 +189,8 @@ | |||
1475 | 193 | auto cappid = g_variant_get_string(vappid.get(), NULL); | 189 | auto cappid = g_variant_get_string(vappid.get(), NULL); |
1476 | 194 | auto cinstid = g_variant_get_string(vinstid.get(), NULL); | 190 | auto cinstid = g_variant_get_string(vinstid.get(), NULL); |
1477 | 195 | 191 | ||
1480 | 196 | auto appid = ubuntu::app_launch::AppID::find(reg, cappid); | 192 | auto appid = reg->find(cappid); |
1481 | 197 | auto app = Application::create(appid, reg); | 193 | auto app = reg->createApp(appid); |
1482 | 198 | auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(cinstid); | 194 | auto inst = std::dynamic_pointer_cast<app_impls::Base>(app)->findInstance(cinstid); |
1483 | 199 | 195 | ||
1484 | 200 | signal(app, inst, pids); | 196 | signal(app, inst, pids); |
1485 | @@ -210,13 +206,12 @@ | |||
1486 | 210 | Base::appPaused() | 206 | Base::appPaused() |
1487 | 211 | { | 207 | { |
1488 | 212 | std::call_once(flag_appPaused, [this]() { | 208 | std::call_once(flag_appPaused, [this]() { |
1492 | 213 | auto reg = registry_.lock(); | 209 | auto reg = getReg(); |
1493 | 214 | 210 | reg->thread.executeOnThread<bool>([this, reg]() { | |
1491 | 215 | reg->impl->thread.executeOnThread<bool>([this, reg]() { | ||
1494 | 216 | upstartEventData* data = new upstartEventData{reg}; | 211 | upstartEventData* data = new upstartEventData{reg}; |
1495 | 217 | 212 | ||
1496 | 218 | handle_appPaused = managedDBusSignalConnection( | 213 | handle_appPaused = managedDBusSignalConnection( |
1498 | 219 | g_dbus_connection_signal_subscribe(reg->impl->_dbus.get(), /* bus */ | 214 | g_dbus_connection_signal_subscribe(reg->_dbus.get(), /* bus */ |
1499 | 220 | nullptr, /* sender */ | 215 | nullptr, /* sender */ |
1500 | 221 | "com.canonical.UbuntuAppLaunch", /* interface */ | 216 | "com.canonical.UbuntuAppLaunch", /* interface */ |
1501 | 222 | "ApplicationPaused", /* signal */ | 217 | "ApplicationPaused", /* signal */ |
1502 | @@ -235,7 +230,7 @@ | |||
1503 | 235 | } | 230 | } |
1504 | 236 | 231 | ||
1505 | 237 | auto sparams = share_glib(g_variant_ref(params)); | 232 | auto sparams = share_glib(g_variant_ref(params)); |
1507 | 238 | auto manager = std::dynamic_pointer_cast<Base>(reg->impl->jobs); | 233 | auto manager = std::dynamic_pointer_cast<Base>(reg->jobs()); |
1508 | 239 | manager->pauseEventEmitted(manager->sig_appPaused, sparams, reg); | 234 | manager->pauseEventEmitted(manager->sig_appPaused, sparams, reg); |
1509 | 240 | }, /* callback */ | 235 | }, /* callback */ |
1510 | 241 | data, /* user data */ | 236 | data, /* user data */ |
1511 | @@ -243,7 +238,7 @@ | |||
1512 | 243 | auto data = reinterpret_cast<upstartEventData*>(user_data); | 238 | auto data = reinterpret_cast<upstartEventData*>(user_data); |
1513 | 244 | delete data; | 239 | delete data; |
1514 | 245 | }), /* user data destroy */ | 240 | }), /* user data destroy */ |
1516 | 246 | reg->impl->_dbus); | 241 | reg->_dbus); |
1517 | 247 | 242 | ||
1518 | 248 | return true; | 243 | return true; |
1519 | 249 | }); | 244 | }); |
1520 | @@ -260,13 +255,12 @@ | |||
1521 | 260 | Base::appResumed() | 255 | Base::appResumed() |
1522 | 261 | { | 256 | { |
1523 | 262 | std::call_once(flag_appResumed, [this]() { | 257 | std::call_once(flag_appResumed, [this]() { |
1527 | 263 | auto reg = registry_.lock(); | 258 | auto reg = getReg(); |
1528 | 264 | 259 | reg->thread.executeOnThread<bool>([this, reg]() { | |
1526 | 265 | reg->impl->thread.executeOnThread<bool>([this, reg]() { | ||
1529 | 266 | upstartEventData* data = new upstartEventData{reg}; | 260 | upstartEventData* data = new upstartEventData{reg}; |
1530 | 267 | 261 | ||
1531 | 268 | handle_appResumed = managedDBusSignalConnection( | 262 | handle_appResumed = managedDBusSignalConnection( |
1533 | 269 | g_dbus_connection_signal_subscribe(reg->impl->_dbus.get(), /* bus */ | 263 | g_dbus_connection_signal_subscribe(reg->_dbus.get(), /* bus */ |
1534 | 270 | nullptr, /* sender */ | 264 | nullptr, /* sender */ |
1535 | 271 | "com.canonical.UbuntuAppLaunch", /* interface */ | 265 | "com.canonical.UbuntuAppLaunch", /* interface */ |
1536 | 272 | "ApplicationResumed", /* signal */ | 266 | "ApplicationResumed", /* signal */ |
1537 | @@ -285,7 +279,7 @@ | |||
1538 | 285 | } | 279 | } |
1539 | 286 | 280 | ||
1540 | 287 | auto sparams = share_glib(g_variant_ref(params)); | 281 | auto sparams = share_glib(g_variant_ref(params)); |
1542 | 288 | auto manager = std::dynamic_pointer_cast<Base>(reg->impl->jobs); | 282 | auto manager = std::dynamic_pointer_cast<Base>(reg->jobs()); |
1543 | 289 | manager->pauseEventEmitted(manager->sig_appResumed, sparams, | 283 | manager->pauseEventEmitted(manager->sig_appResumed, sparams, |
1544 | 290 | reg); | 284 | reg); |
1545 | 291 | }, /* callback */ | 285 | }, /* callback */ |
1546 | @@ -294,7 +288,7 @@ | |||
1547 | 294 | auto data = reinterpret_cast<upstartEventData*>(user_data); | 288 | auto data = reinterpret_cast<upstartEventData*>(user_data); |
1548 | 295 | delete data; | 289 | delete data; |
1549 | 296 | }), /* user data destroy */ | 290 | }), /* user data destroy */ |
1551 | 297 | reg->impl->_dbus); | 291 | reg->_dbus); |
1552 | 298 | 292 | ||
1553 | 299 | return true; | 293 | return true; |
1554 | 300 | }); | 294 | }); |
1555 | @@ -321,10 +315,9 @@ | |||
1556 | 321 | 315 | ||
1557 | 322 | try | 316 | try |
1558 | 323 | { | 317 | { |
1563 | 324 | auto reg = registry_.lock(); | 318 | auto reg = getReg(); |
1564 | 325 | 319 | auto appId = reg->find(appid); | |
1565 | 326 | auto appId = ubuntu::app_launch::AppID::parse(appid); | 320 | auto helper = reg->createHelper(type, appId, reg); |
1562 | 327 | auto helper = Helper::create(type, appId, reg); | ||
1566 | 328 | auto inst = std::dynamic_pointer_cast<helper_impls::Base>(helper)->existingInstance(instanceid); | 321 | auto inst = std::dynamic_pointer_cast<helper_impls::Base>(helper)->existingInstance(instanceid); |
1567 | 329 | 322 | ||
1568 | 330 | (*sig_helpersStarted.at(type.value()))(helper, inst); | 323 | (*sig_helpersStarted.at(type.value()))(helper, inst); |
1569 | @@ -361,10 +354,9 @@ | |||
1570 | 361 | 354 | ||
1571 | 362 | try | 355 | try |
1572 | 363 | { | 356 | { |
1575 | 364 | auto reg = registry_.lock(); | 357 | auto reg = getReg(); |
1574 | 365 | |||
1576 | 366 | auto appId = ubuntu::app_launch::AppID::parse(appid); | 358 | auto appId = ubuntu::app_launch::AppID::parse(appid); |
1578 | 367 | auto helper = Helper::create(type, appId, reg); | 359 | auto helper = reg->createHelper(type, appId, reg); |
1579 | 368 | auto inst = std::dynamic_pointer_cast<helper_impls::Base>(helper)->existingInstance(instanceid); | 360 | auto inst = std::dynamic_pointer_cast<helper_impls::Base>(helper)->existingInstance(instanceid); |
1580 | 369 | 361 | ||
1581 | 370 | (*sig_helpersStopped.at(type.value()))(helper, inst); | 362 | (*sig_helpersStopped.at(type.value()))(helper, inst); |
1582 | @@ -401,10 +393,9 @@ | |||
1583 | 401 | 393 | ||
1584 | 402 | try | 394 | try |
1585 | 403 | { | 395 | { |
1588 | 404 | auto reg = registry_.lock(); | 396 | auto reg = getReg(); |
1587 | 405 | |||
1589 | 406 | auto appId = ubuntu::app_launch::AppID::parse(appid); | 397 | auto appId = ubuntu::app_launch::AppID::parse(appid); |
1591 | 407 | auto helper = Helper::create(type, appId, reg); | 398 | auto helper = reg->createHelper(type, appId, reg); |
1592 | 408 | auto inst = std::dynamic_pointer_cast<helper_impls::Base>(helper)->existingInstance(instanceid); | 399 | auto inst = std::dynamic_pointer_cast<helper_impls::Base>(helper)->existingInstance(instanceid); |
1593 | 409 | 400 | ||
1594 | 410 | (*sig_helpersFailed.at(type.value()))(helper, inst, reason); | 401 | (*sig_helpersFailed.at(type.value()))(helper, inst, reason); |
1595 | @@ -427,7 +418,7 @@ | |||
1596 | 427 | /** Take the GVariant of parameters and turn them into an application and | 418 | /** Take the GVariant of parameters and turn them into an application and |
1597 | 428 | and instance. Easier to read in the smaller function */ | 419 | and instance. Easier to read in the smaller function */ |
1598 | 429 | std::tuple<std::shared_ptr<Application>, std::shared_ptr<Application::Instance>> Base::managerParams( | 420 | std::tuple<std::shared_ptr<Application>, std::shared_ptr<Application::Instance>> Base::managerParams( |
1600 | 430 | const std::shared_ptr<GVariant>& params, const std::shared_ptr<Registry>& reg) | 421 | const std::shared_ptr<GVariant>& params, const std::shared_ptr<Registry::Impl>& reg) |
1601 | 431 | { | 422 | { |
1602 | 432 | std::shared_ptr<Application> app; | 423 | std::shared_ptr<Application> app; |
1603 | 433 | std::shared_ptr<Application::Instance> instance; | 424 | std::shared_ptr<Application::Instance> instance; |
1604 | @@ -436,8 +427,10 @@ | |||
1605 | 436 | const gchar* cinstid = nullptr; | 427 | const gchar* cinstid = nullptr; |
1606 | 437 | g_variant_get(params.get(), "(&s&s)", &cappid, &cinstid); | 428 | g_variant_get(params.get(), "(&s&s)", &cappid, &cinstid); |
1607 | 438 | 429 | ||
1610 | 439 | auto appid = ubuntu::app_launch::AppID::find(reg, cappid); | 430 | auto appid = reg->find(cappid); |
1611 | 440 | app = ubuntu::app_launch::Application::create(appid, reg); | 431 | app = reg->createApp(appid); |
1612 | 432 | |||
1613 | 433 | /* TODO Instance */ | ||
1614 | 441 | 434 | ||
1615 | 442 | return std::make_tuple(app, instance); | 435 | return std::make_tuple(app, instance); |
1616 | 443 | } | 436 | } |
1617 | @@ -448,8 +441,8 @@ | |||
1618 | 448 | { | 441 | { |
1619 | 449 | /* Keeping a weak pointer because the handle is held by | 442 | /* Keeping a weak pointer because the handle is held by |
1620 | 450 | the registry implementation. */ | 443 | the registry implementation. */ |
1623 | 451 | std::weak_ptr<Registry> weakReg; | 444 | std::weak_ptr<Registry::Impl> weakReg; |
1624 | 452 | std::function<void(const std::shared_ptr<Registry>& reg, | 445 | std::function<void(const std::shared_ptr<Registry::Impl>& reg, |
1625 | 453 | const std::shared_ptr<Application>& app, | 446 | const std::shared_ptr<Application>& app, |
1626 | 454 | const std::shared_ptr<Application::Instance>& instance, | 447 | const std::shared_ptr<Application::Instance>& instance, |
1627 | 455 | const std::shared_ptr<GDBusConnection>&, | 448 | const std::shared_ptr<GDBusConnection>&, |
1628 | @@ -462,19 +455,19 @@ | |||
1629 | 462 | code so it got pulled out into a function. Takes the same of the signal, the registry | 455 | code so it got pulled out into a function. Takes the same of the signal, the registry |
1630 | 463 | that we're using and a function to call after we've messaged all the parameters | 456 | that we're using and a function to call after we've messaged all the parameters |
1631 | 464 | into being something C++-ish. */ | 457 | into being something C++-ish. */ |
1635 | 465 | guint Base::managerSignalHelper(const std::shared_ptr<Registry>& reg, | 458 | guint Base::managerSignalHelper(const std::string& signalname, |
1636 | 466 | const std::string& signalname, | 459 | std::function<void(const std::shared_ptr<Registry::Impl>& reg, |
1634 | 467 | std::function<void(const std::shared_ptr<Registry>& reg, | ||
1637 | 468 | const std::shared_ptr<Application>& app, | 460 | const std::shared_ptr<Application>& app, |
1638 | 469 | const std::shared_ptr<Application::Instance>& instance, | 461 | const std::shared_ptr<Application::Instance>& instance, |
1639 | 470 | const std::shared_ptr<GDBusConnection>&, | 462 | const std::shared_ptr<GDBusConnection>&, |
1640 | 471 | const std::string&, | 463 | const std::string&, |
1641 | 472 | const std::shared_ptr<GVariant>&)> responsefunc) | 464 | const std::shared_ptr<GVariant>&)> responsefunc) |
1642 | 473 | { | 465 | { |
1643 | 466 | auto reg = getReg(); | ||
1644 | 474 | managerEventData* focusdata = new managerEventData{reg, responsefunc}; | 467 | managerEventData* focusdata = new managerEventData{reg, responsefunc}; |
1645 | 475 | 468 | ||
1646 | 476 | return g_dbus_connection_signal_subscribe( | 469 | return g_dbus_connection_signal_subscribe( |
1648 | 477 | reg->impl->_dbus.get(), /* bus */ | 470 | reg->_dbus.get(), /* bus */ |
1649 | 478 | nullptr, /* sender */ | 471 | nullptr, /* sender */ |
1650 | 479 | "com.canonical.UbuntuAppLaunch", /* interface */ | 472 | "com.canonical.UbuntuAppLaunch", /* interface */ |
1651 | 480 | signalname.c_str(), /* signal */ | 473 | signalname.c_str(), /* signal */ |
1652 | @@ -494,7 +487,7 @@ | |||
1653 | 494 | 487 | ||
1654 | 495 | /* If we're still conneted and the manager has been cleared | 488 | /* If we're still conneted and the manager has been cleared |
1655 | 496 | we'll just be a no-op */ | 489 | we'll just be a no-op */ |
1657 | 497 | auto ljobs = std::dynamic_pointer_cast<Base>(reg->impl->jobs); | 490 | auto ljobs = std::dynamic_pointer_cast<Base>(reg->jobs()); |
1658 | 498 | if (!ljobs->manager_) | 491 | if (!ljobs->manager_) |
1659 | 499 | { | 492 | { |
1660 | 500 | return; | 493 | return; |
1661 | @@ -540,41 +533,43 @@ | |||
1662 | 540 | manager_ = manager; | 533 | manager_ = manager; |
1663 | 541 | 534 | ||
1664 | 542 | std::call_once(flag_managerSignals, [this]() { | 535 | std::call_once(flag_managerSignals, [this]() { |
1674 | 543 | auto reg = registry_.lock(); | 536 | auto reg = getReg(); |
1675 | 544 | 537 | ||
1676 | 545 | if (!reg) | 538 | if (!reg->thread.executeOnThread<bool>([this, reg]() { |
1668 | 546 | { | ||
1669 | 547 | g_warning("Registry object invalid!"); | ||
1670 | 548 | return; | ||
1671 | 549 | } | ||
1672 | 550 | |||
1673 | 551 | if (!reg->impl->thread.executeOnThread<bool>([this, reg]() { | ||
1677 | 552 | handle_managerSignalFocus = managedDBusSignalConnection( | 539 | handle_managerSignalFocus = managedDBusSignalConnection( |
1678 | 553 | managerSignalHelper( | 540 | managerSignalHelper( |
1681 | 554 | reg, "UnityFocusRequest", | 541 | "UnityFocusRequest", |
1682 | 555 | [](const std::shared_ptr<Registry>& reg, const std::shared_ptr<Application>& app, | 542 | [](const std::shared_ptr<Registry::Impl>& reg, const std::shared_ptr<Application>& app, |
1683 | 556 | const std::shared_ptr<Application::Instance>& instance, | 543 | const std::shared_ptr<Application::Instance>& instance, |
1684 | 557 | const std::shared_ptr<GDBusConnection>& conn, const std::string& sender, | 544 | const std::shared_ptr<GDBusConnection>& conn, const std::string& sender, |
1685 | 558 | const std::shared_ptr<GVariant>& params) { | 545 | const std::shared_ptr<GVariant>& params) { |
1686 | 559 | /* Nothing to do today */ | 546 | /* Nothing to do today */ |
1688 | 560 | std::dynamic_pointer_cast<Base>(reg->impl->jobs) | 547 | std::dynamic_pointer_cast<Base>(reg->jobs()) |
1689 | 561 | ->manager_->focusRequest(app, instance, [](bool response) { | 548 | ->manager_->focusRequest(app, instance, [](bool response) { |
1693 | 562 | /* NOTE: We have no clue what thread this is gonna be | 549 | /* NOTE: We have no |
1694 | 563 | executed on, but since we're just talking to the GDBus | 550 | clue what thread |
1695 | 564 | thread it isn't an issue today. Be careful in changing | 551 | this is gonna be |
1696 | 552 | executed on, but | ||
1697 | 553 | since we're just | ||
1698 | 554 | talking to the | ||
1699 | 555 | GDBus | ||
1700 | 556 | thread it isn't an | ||
1701 | 557 | issue today. Be | ||
1702 | 558 | careful in | ||
1703 | 559 | changing | ||
1704 | 565 | this code. */ | 560 | this code. */ |
1705 | 566 | }); | 561 | }); |
1706 | 567 | }), | 562 | }), |
1708 | 568 | reg->impl->_dbus); | 563 | reg->_dbus); |
1709 | 569 | handle_managerSignalStarting = managedDBusSignalConnection( | 564 | handle_managerSignalStarting = managedDBusSignalConnection( |
1710 | 570 | managerSignalHelper( | 565 | managerSignalHelper( |
1713 | 571 | reg, "UnityStartingBroadcast", | 566 | "UnityStartingBroadcast", |
1714 | 572 | [](const std::shared_ptr<Registry>& reg, const std::shared_ptr<Application>& app, | 567 | [](const std::shared_ptr<Registry::Impl>& reg, const std::shared_ptr<Application>& app, |
1715 | 573 | const std::shared_ptr<Application::Instance>& instance, | 568 | const std::shared_ptr<Application::Instance>& instance, |
1716 | 574 | const std::shared_ptr<GDBusConnection>& conn, const std::string& sender, | 569 | const std::shared_ptr<GDBusConnection>& conn, const std::string& sender, |
1717 | 575 | const std::shared_ptr<GVariant>& params) { | 570 | const std::shared_ptr<GVariant>& params) { |
1718 | 576 | 571 | ||
1720 | 577 | std::dynamic_pointer_cast<Base>(reg->impl->jobs) | 572 | std::dynamic_pointer_cast<Base>(reg->jobs()) |
1721 | 578 | ->manager_->startingRequest(app, instance, [conn, sender, params](bool response) { | 573 | ->manager_->startingRequest(app, instance, [conn, sender, params](bool response) { |
1722 | 579 | /* NOTE: We have no clue what thread this is gonna be | 574 | /* NOTE: We have no clue what thread this is gonna be |
1723 | 580 | executed on, but since we're just talking to the GDBus | 575 | executed on, but since we're just talking to the GDBus |
1724 | @@ -591,15 +586,15 @@ | |||
1725 | 591 | } | 586 | } |
1726 | 592 | }); | 587 | }); |
1727 | 593 | }), | 588 | }), |
1729 | 594 | reg->impl->_dbus); | 589 | reg->_dbus); |
1730 | 595 | handle_managerSignalResume = managedDBusSignalConnection( | 590 | handle_managerSignalResume = managedDBusSignalConnection( |
1731 | 596 | managerSignalHelper( | 591 | managerSignalHelper( |
1734 | 597 | reg, "UnityResumeRequest", | 592 | "UnityResumeRequest", |
1735 | 598 | [](const std::shared_ptr<Registry>& reg, const std::shared_ptr<Application>& app, | 593 | [](const std::shared_ptr<Registry::Impl>& reg, const std::shared_ptr<Application>& app, |
1736 | 599 | const std::shared_ptr<Application::Instance>& instance, | 594 | const std::shared_ptr<Application::Instance>& instance, |
1737 | 600 | const std::shared_ptr<GDBusConnection>& conn, const std::string& sender, | 595 | const std::shared_ptr<GDBusConnection>& conn, const std::string& sender, |
1738 | 601 | const std::shared_ptr<GVariant>& params) { | 596 | const std::shared_ptr<GVariant>& params) { |
1740 | 602 | std::dynamic_pointer_cast<Base>(reg->impl->jobs) | 597 | std::dynamic_pointer_cast<Base>(reg->jobs()) |
1741 | 603 | ->manager_->resumeRequest(app, instance, [conn, sender, params](bool response) { | 598 | ->manager_->resumeRequest(app, instance, [conn, sender, params](bool response) { |
1742 | 604 | /* NOTE: We have no clue what thread this is gonna be | 599 | /* NOTE: We have no clue what thread this is gonna be |
1743 | 605 | executed on, but since we're just talking to the GDBus | 600 | executed on, but since we're just talking to the GDBus |
1744 | @@ -616,7 +611,7 @@ | |||
1745 | 616 | } | 611 | } |
1746 | 617 | }); | 612 | }); |
1747 | 618 | }), | 613 | }), |
1749 | 619 | reg->impl->_dbus); | 614 | reg->_dbus); |
1750 | 620 | 615 | ||
1751 | 621 | return true; | 616 | return true; |
1752 | 622 | })) | 617 | })) |
1753 | @@ -637,20 +632,13 @@ | |||
1754 | 637 | on the appids associated with the application jobs */ | 632 | on the appids associated with the application jobs */ |
1755 | 638 | std::list<std::shared_ptr<Application>> Base::runningApps() | 633 | std::list<std::shared_ptr<Application>> Base::runningApps() |
1756 | 639 | { | 634 | { |
1765 | 640 | auto registry = registry_.lock(); | 635 | auto reg = getReg(); |
1758 | 641 | |||
1759 | 642 | if (!registry) | ||
1760 | 643 | { | ||
1761 | 644 | g_warning("Unable to list apps without a registry"); | ||
1762 | 645 | return {}; | ||
1763 | 646 | } | ||
1764 | 647 | |||
1766 | 648 | auto appids = runningAppIds(allApplicationJobs_); | 636 | auto appids = runningAppIds(allApplicationJobs_); |
1767 | 649 | 637 | ||
1768 | 650 | std::list<std::shared_ptr<Application>> apps; | 638 | std::list<std::shared_ptr<Application>> apps; |
1769 | 651 | for (const auto& appid : appids) | 639 | for (const auto& appid : appids) |
1770 | 652 | { | 640 | { |
1772 | 653 | auto id = AppID::find(registry, appid); | 641 | auto id = reg->find(appid); |
1773 | 654 | if (id.empty()) | 642 | if (id.empty()) |
1774 | 655 | { | 643 | { |
1775 | 656 | g_debug("Unable to handle AppID: %s", appid.c_str()); | 644 | g_debug("Unable to handle AppID: %s", appid.c_str()); |
1776 | @@ -659,7 +647,7 @@ | |||
1777 | 659 | 647 | ||
1778 | 660 | try | 648 | try |
1779 | 661 | { | 649 | { |
1781 | 662 | apps.emplace_back(Application::create(id, registry)); | 650 | apps.emplace_back(reg->createApp(id)); |
1782 | 663 | } | 651 | } |
1783 | 664 | catch (std::runtime_error& e) | 652 | catch (std::runtime_error& e) |
1784 | 665 | { | 653 | { |
1785 | @@ -674,27 +662,20 @@ | |||
1786 | 674 | on the appids associated with the application jobs */ | 662 | on the appids associated with the application jobs */ |
1787 | 675 | std::list<std::shared_ptr<Helper>> Base::runningHelpers(const Helper::Type& type) | 663 | std::list<std::shared_ptr<Helper>> Base::runningHelpers(const Helper::Type& type) |
1788 | 676 | { | 664 | { |
1797 | 677 | auto registry = registry_.lock(); | 665 | auto reg = getReg(); |
1790 | 678 | |||
1791 | 679 | if (!registry) | ||
1792 | 680 | { | ||
1793 | 681 | g_warning("Unable to list helpers without a registry"); | ||
1794 | 682 | return {}; | ||
1795 | 683 | } | ||
1796 | 684 | |||
1798 | 685 | auto appids = runningAppIds({type.value()}); | 666 | auto appids = runningAppIds({type.value()}); |
1799 | 686 | 667 | ||
1800 | 687 | std::list<std::shared_ptr<Helper>> helpers; | 668 | std::list<std::shared_ptr<Helper>> helpers; |
1801 | 688 | for (const auto& appid : appids) | 669 | for (const auto& appid : appids) |
1802 | 689 | { | 670 | { |
1804 | 690 | auto id = AppID::parse(appid); | 671 | auto id = reg->find(appid); |
1805 | 691 | if (id.empty()) | 672 | if (id.empty()) |
1806 | 692 | { | 673 | { |
1807 | 693 | g_debug("Unable to handle AppID: %s", appid.c_str()); | 674 | g_debug("Unable to handle AppID: %s", appid.c_str()); |
1808 | 694 | continue; | 675 | continue; |
1809 | 695 | } | 676 | } |
1810 | 696 | 677 | ||
1812 | 697 | helpers.emplace_back(Helper::create(type, id, registry)); | 678 | helpers.emplace_back(reg->createHelper(type, id, reg)); |
1813 | 698 | } | 679 | } |
1814 | 699 | 680 | ||
1815 | 700 | return helpers; | 681 | return helpers; |
1816 | @@ -709,7 +690,7 @@ | |||
1817 | 709 | const std::string& job, | 690 | const std::string& job, |
1818 | 710 | const std::string& instance, | 691 | const std::string& instance, |
1819 | 711 | const std::vector<Application::URL>& urls, | 692 | const std::vector<Application::URL>& urls, |
1821 | 712 | const std::shared_ptr<Registry>& registry) | 693 | const std::shared_ptr<Registry::Impl>& registry) |
1822 | 713 | : appId_(appId) | 694 | : appId_(appId) |
1823 | 714 | , job_(job) | 695 | , job_(job) |
1824 | 715 | , instance_(instance) | 696 | , instance_(instance) |
1825 | @@ -742,7 +723,7 @@ | |||
1826 | 742 | void Base::pause() | 723 | void Base::pause() |
1827 | 743 | { | 724 | { |
1828 | 744 | g_debug("Pausing application: %s", std::string(appId_).c_str()); | 725 | g_debug("Pausing application: %s", std::string(appId_).c_str()); |
1830 | 745 | registry_->impl->zgSendEvent(appId_, ZEITGEIST_ZG_LEAVE_EVENT); | 726 | registry_->zgSendEvent(appId_, ZEITGEIST_ZG_LEAVE_EVENT); |
1831 | 746 | 727 | ||
1832 | 747 | auto pids = forAllPids([this](pid_t pid) { | 728 | auto pids = forAllPids([this](pid_t pid) { |
1833 | 748 | auto oomval = oom::paused(); | 729 | auto oomval = oom::paused(); |
1834 | @@ -759,7 +740,7 @@ | |||
1835 | 759 | void Base::resume() | 740 | void Base::resume() |
1836 | 760 | { | 741 | { |
1837 | 761 | g_debug("Resuming application: %s", std::string(appId_).c_str()); | 742 | g_debug("Resuming application: %s", std::string(appId_).c_str()); |
1839 | 762 | registry_->impl->zgSendEvent(appId_, ZEITGEIST_ZG_ACCESS_EVENT); | 743 | registry_->zgSendEvent(appId_, ZEITGEIST_ZG_ACCESS_EVENT); |
1840 | 763 | 744 | ||
1841 | 764 | auto pids = forAllPids([this](pid_t pid) { | 745 | auto pids = forAllPids([this](pid_t pid) { |
1842 | 765 | auto oomval = oom::focused(); | 746 | auto oomval = oom::focused(); |
1843 | @@ -782,7 +763,7 @@ | |||
1844 | 782 | g_variant_builder_init(¶ms, G_VARIANT_TYPE_TUPLE); | 763 | g_variant_builder_init(¶ms, G_VARIANT_TYPE_TUPLE); |
1845 | 783 | g_variant_builder_add_value(¶ms, g_variant_new_string(std::string(appId_).c_str())); | 764 | g_variant_builder_add_value(¶ms, g_variant_new_string(std::string(appId_).c_str())); |
1846 | 784 | g_variant_builder_add_value(¶ms, g_variant_new_string(instance_.c_str())); | 765 | g_variant_builder_add_value(¶ms, g_variant_new_string(instance_.c_str())); |
1848 | 785 | g_dbus_connection_emit_signal(registry_->impl->_dbus.get(), /* bus */ | 766 | g_dbus_connection_emit_signal(registry_->_dbus.get(), /* bus */ |
1849 | 786 | nullptr, /* destination */ | 767 | nullptr, /* destination */ |
1850 | 787 | "/", /* path */ | 768 | "/", /* path */ |
1851 | 788 | "com.canonical.UbuntuAppLaunch", /* interface */ | 769 | "com.canonical.UbuntuAppLaunch", /* interface */ |
1852 | @@ -835,7 +816,7 @@ | |||
1853 | 835 | \param pids List of PIDs to turn into variants to send | 816 | \param pids List of PIDs to turn into variants to send |
1854 | 836 | \param signal Name of the DBus signal to send | 817 | \param signal Name of the DBus signal to send |
1855 | 837 | */ | 818 | */ |
1857 | 838 | void Base::pidListToDbus(const std::shared_ptr<Registry>& reg, | 819 | void Base::pidListToDbus(const std::shared_ptr<Registry::Impl>& reg, |
1858 | 839 | const AppID& appid, | 820 | const AppID& appid, |
1859 | 840 | const std::string& instanceid, | 821 | const std::string& instanceid, |
1860 | 841 | const std::vector<pid_t>& pids, | 822 | const std::vector<pid_t>& pids, |
1861 | @@ -867,7 +848,7 @@ | |||
1862 | 867 | g_variant_builder_add_value(¶ms, vpids.get()); | 848 | g_variant_builder_add_value(¶ms, vpids.get()); |
1863 | 868 | 849 | ||
1864 | 869 | GError* error = nullptr; | 850 | GError* error = nullptr; |
1866 | 870 | g_dbus_connection_emit_signal(reg->impl->_dbus.get(), /* bus */ | 851 | g_dbus_connection_emit_signal(reg->_dbus.get(), /* bus */ |
1867 | 871 | nullptr, /* destination */ | 852 | nullptr, /* destination */ |
1868 | 872 | "/", /* path */ | 853 | "/", /* path */ |
1869 | 873 | "com.canonical.UbuntuAppLaunch", /* interface */ | 854 | "com.canonical.UbuntuAppLaunch", /* interface */ |
1870 | @@ -1039,22 +1020,21 @@ | |||
1871 | 1039 | std::array<const char*, 4> args = {OOM_HELPER, pidstr.c_str(), oomstr.c_str(), nullptr}; | 1020 | std::array<const char*, 4> args = {OOM_HELPER, pidstr.c_str(), oomstr.c_str(), nullptr}; |
1872 | 1040 | 1021 | ||
1873 | 1041 | g_debug("Excuting OOM Helper (pid: %d, score: %d): %s", int(pid), int(oomvalue), | 1022 | g_debug("Excuting OOM Helper (pid: %d, score: %d): %s", int(pid), int(oomvalue), |
1890 | 1042 | std::accumulate(args.begin(), args.end(), std::string{}, | 1023 | std::accumulate(args.begin(), args.end(), std::string{}, [](const std::string& instr, |
1891 | 1043 | [](const std::string& instr, const char* output) -> std::string { | 1024 | const char* output) -> std::string { |
1892 | 1044 | if (instr.empty()) | 1025 | if (instr.empty()) |
1893 | 1045 | { | 1026 | { |
1894 | 1046 | return output; | 1027 | return output; |
1895 | 1047 | } | 1028 | } |
1896 | 1048 | else if (output != nullptr) | 1029 | else if (output != nullptr) |
1897 | 1049 | { | 1030 | { |
1898 | 1050 | return instr + " " + std::string(output); | 1031 | return instr + " " + std::string(output); |
1899 | 1051 | } | 1032 | } |
1900 | 1052 | else | 1033 | else |
1901 | 1053 | { | 1034 | { |
1902 | 1054 | return instr; | 1035 | return instr; |
1903 | 1055 | } | 1036 | } |
1904 | 1056 | }) | 1037 | }).c_str()); |
1889 | 1057 | .c_str()); | ||
1905 | 1058 | 1038 | ||
1906 | 1059 | g_spawn_async(nullptr, /* working dir */ | 1039 | g_spawn_async(nullptr, /* working dir */ |
1907 | 1060 | (char**)(args.data()), /* args */ | 1040 | (char**)(args.data()), /* args */ |
1908 | 1061 | 1041 | ||
1909 | === modified file 'libubuntu-app-launch/jobs-base.h' | |||
1910 | --- libubuntu-app-launch/jobs-base.h 2017-03-21 03:28:22 +0000 | |||
1911 | +++ libubuntu-app-launch/jobs-base.h 2017-04-04 21:22:36 +0000 | |||
1912 | @@ -45,7 +45,7 @@ | |||
1913 | 45 | const std::string& job, | 45 | const std::string& job, |
1914 | 46 | const std::string& instance, | 46 | const std::string& instance, |
1915 | 47 | const std::vector<Application::URL>& urls, | 47 | const std::vector<Application::URL>& urls, |
1917 | 48 | const std::shared_ptr<Registry>& registry); | 48 | const std::shared_ptr<Registry::Impl>& registry); |
1918 | 49 | virtual ~Base() = default; | 49 | virtual ~Base() = default; |
1919 | 50 | 50 | ||
1920 | 51 | bool isRunning() override; | 51 | bool isRunning() override; |
1921 | @@ -74,10 +74,10 @@ | |||
1922 | 74 | should look at perhaps changing that. */ | 74 | should look at perhaps changing that. */ |
1923 | 75 | std::vector<Application::URL> urls_; | 75 | std::vector<Application::URL> urls_; |
1924 | 76 | /** A link to the registry we're using for connections */ | 76 | /** A link to the registry we're using for connections */ |
1926 | 77 | std::shared_ptr<Registry> registry_; | 77 | std::shared_ptr<Registry::Impl> registry_; |
1927 | 78 | 78 | ||
1928 | 79 | std::vector<pid_t> forAllPids(std::function<void(pid_t)> eachPid); | 79 | std::vector<pid_t> forAllPids(std::function<void(pid_t)> eachPid); |
1930 | 80 | static void pidListToDbus(const std::shared_ptr<Registry>& reg, | 80 | static void pidListToDbus(const std::shared_ptr<Registry::Impl>& reg, |
1931 | 81 | const AppID& appid, | 81 | const AppID& appid, |
1932 | 82 | const std::string& instanceid, | 82 | const std::string& instanceid, |
1933 | 83 | const std::vector<pid_t>& pids, | 83 | const std::vector<pid_t>& pids, |
1934 | @@ -104,7 +104,7 @@ | |||
1935 | 104 | class Base | 104 | class Base |
1936 | 105 | { | 105 | { |
1937 | 106 | public: | 106 | public: |
1939 | 107 | Base(const std::shared_ptr<Registry>& registry); | 107 | Base(const std::shared_ptr<Registry::Impl>& registry); |
1940 | 108 | virtual ~Base(); | 108 | virtual ~Base(); |
1941 | 109 | 109 | ||
1942 | 110 | virtual std::shared_ptr<Application::Instance> launch( | 110 | virtual std::shared_ptr<Application::Instance> launch( |
1943 | @@ -129,7 +129,7 @@ | |||
1944 | 129 | 129 | ||
1945 | 130 | const std::list<std::string>& getAllApplicationJobs() const; | 130 | const std::list<std::string>& getAllApplicationJobs() const; |
1946 | 131 | 131 | ||
1948 | 132 | static std::shared_ptr<Base> determineFactory(std::shared_ptr<Registry> registry); | 132 | static std::shared_ptr<Base> determineFactory(const std::shared_ptr<Registry::Impl>& registry); |
1949 | 133 | 133 | ||
1950 | 134 | /* Signals to apps */ | 134 | /* Signals to apps */ |
1951 | 135 | virtual core::Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&>& | 135 | virtual core::Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&>& |
1952 | @@ -153,9 +153,8 @@ | |||
1953 | 153 | Helper::Type type); | 153 | Helper::Type type); |
1954 | 154 | virtual core::Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&>& helperStopped( | 154 | virtual core::Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&>& helperStopped( |
1955 | 155 | Helper::Type type); | 155 | Helper::Type type); |
1959 | 156 | virtual core::Signal<const std::shared_ptr<Helper>&, | 156 | virtual core:: |
1960 | 157 | const std::shared_ptr<Helper::Instance>&, | 157 | Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&, Registry::FailureType>& |
1958 | 158 | Registry::FailureType>& | ||
1961 | 159 | helperFailed(Helper::Type type); | 158 | helperFailed(Helper::Type type); |
1962 | 160 | /* Job signals from implementations */ | 159 | /* Job signals from implementations */ |
1963 | 161 | virtual core::Signal<const std::string&, const std::string&, const std::string&>& jobStarted() = 0; | 160 | virtual core::Signal<const std::string&, const std::string&, const std::string&>& jobStarted() = 0; |
1964 | @@ -168,19 +167,28 @@ | |||
1965 | 168 | virtual void clearManager(); | 167 | virtual void clearManager(); |
1966 | 169 | 168 | ||
1967 | 170 | protected: | 169 | protected: |
1968 | 170 | /** Accessor function to the registry that ensures we can still | ||
1969 | 171 | get it, which we always should be able to, but in case. */ | ||
1970 | 172 | std::shared_ptr<Registry::Impl> getReg() | ||
1971 | 173 | { | ||
1972 | 174 | auto reg = registry_.lock(); | ||
1973 | 175 | if (G_UNLIKELY(!reg)) | ||
1974 | 176 | { | ||
1975 | 177 | throw std::runtime_error{"Jobs manager lost track of the Registry that owns it"}; | ||
1976 | 178 | } | ||
1977 | 179 | return reg; | ||
1978 | 180 | } | ||
1979 | 181 | |||
1980 | 182 | /** Application manager instance */ | ||
1981 | 183 | std::shared_ptr<Registry::Manager> manager_; | ||
1982 | 184 | |||
1983 | 185 | private: | ||
1984 | 171 | /** A link to the registry */ | 186 | /** A link to the registry */ |
1986 | 172 | std::weak_ptr<Registry> registry_; | 187 | std::weak_ptr<Registry::Impl> registry_; |
1987 | 173 | 188 | ||
1988 | 174 | /** A set of all the job names used by applications */ | 189 | /** A set of all the job names used by applications */ |
1989 | 175 | std::list<std::string> allApplicationJobs_; | 190 | std::list<std::string> allApplicationJobs_; |
1990 | 176 | 191 | ||
1991 | 177 | /** The DBus connection we're connecting to */ | ||
1992 | 178 | std::shared_ptr<GDBusConnection> dbus_; | ||
1993 | 179 | |||
1994 | 180 | /** Application manager instance */ | ||
1995 | 181 | std::shared_ptr<Registry::Manager> manager_; | ||
1996 | 182 | |||
1997 | 183 | private: | ||
1998 | 184 | /** Signal object for applications started */ | 192 | /** Signal object for applications started */ |
1999 | 185 | core::Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&> sig_appStarted; | 193 | core::Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&> sig_appStarted; |
2000 | 186 | /** Signal object for applications stopped */ | 194 | /** Signal object for applications stopped */ |
2001 | @@ -241,18 +249,17 @@ | |||
2002 | 241 | const std::shared_ptr<Application::Instance>&, | 249 | const std::shared_ptr<Application::Instance>&, |
2003 | 242 | const std::vector<pid_t>&>& signal, | 250 | const std::vector<pid_t>&>& signal, |
2004 | 243 | const std::shared_ptr<GVariant>& params, | 251 | const std::shared_ptr<GVariant>& params, |
2006 | 244 | const std::shared_ptr<Registry>& reg); | 252 | const std::shared_ptr<Registry::Impl>& reg); |
2007 | 245 | 253 | ||
2008 | 246 | static std::tuple<std::shared_ptr<Application>, std::shared_ptr<Application::Instance>> managerParams( | 254 | static std::tuple<std::shared_ptr<Application>, std::shared_ptr<Application::Instance>> managerParams( |
2018 | 247 | const std::shared_ptr<GVariant>& params, const std::shared_ptr<Registry>& reg); | 255 | const std::shared_ptr<GVariant>& params, const std::shared_ptr<Registry::Impl>& reg); |
2019 | 248 | static guint managerSignalHelper(const std::shared_ptr<Registry>& reg, | 256 | guint managerSignalHelper(const std::string& signalname, |
2020 | 249 | const std::string& signalname, | 257 | std::function<void(const std::shared_ptr<Registry::Impl>& reg, |
2021 | 250 | std::function<void(const std::shared_ptr<Registry>& reg, | 258 | const std::shared_ptr<Application>& app, |
2022 | 251 | const std::shared_ptr<Application>& app, | 259 | const std::shared_ptr<Application::Instance>& instance, |
2023 | 252 | const std::shared_ptr<Application::Instance>& instance, | 260 | const std::shared_ptr<GDBusConnection>&, |
2024 | 253 | const std::shared_ptr<GDBusConnection>&, | 261 | const std::string&, |
2025 | 254 | const std::string&, | 262 | const std::shared_ptr<GVariant>&)> responsefunc); |
2017 | 255 | const std::shared_ptr<GVariant>&)> responsefunc); | ||
2026 | 256 | }; | 263 | }; |
2027 | 257 | 264 | ||
2028 | 258 | } // namespace manager | 265 | } // namespace manager |
2029 | 259 | 266 | ||
2030 | === modified file 'libubuntu-app-launch/jobs-systemd.cpp' | |||
2031 | --- libubuntu-app-launch/jobs-systemd.cpp 2017-03-21 03:28:22 +0000 | |||
2032 | +++ libubuntu-app-launch/jobs-systemd.cpp 2017-04-04 21:22:36 +0000 | |||
2033 | @@ -57,7 +57,7 @@ | |||
2034 | 57 | const std::string& job, | 57 | const std::string& job, |
2035 | 58 | const std::string& instance, | 58 | const std::string& instance, |
2036 | 59 | const std::vector<Application::URL>& urls, | 59 | const std::vector<Application::URL>& urls, |
2038 | 60 | const std::shared_ptr<Registry>& registry); | 60 | const std::shared_ptr<Registry::Impl>& registry); |
2039 | 61 | virtual ~SystemD() | 61 | virtual ~SystemD() |
2040 | 62 | { | 62 | { |
2041 | 63 | g_debug("Destroying a SystemD for '%s' instance '%s'", std::string(appId_).c_str(), instance_.c_str()); | 63 | g_debug("Destroying a SystemD for '%s' instance '%s'", std::string(appId_).c_str(), instance_.c_str()); |
2042 | @@ -76,7 +76,7 @@ | |||
2043 | 76 | const std::string& job, | 76 | const std::string& job, |
2044 | 77 | const std::string& instance, | 77 | const std::string& instance, |
2045 | 78 | const std::vector<Application::URL>& urls, | 78 | const std::vector<Application::URL>& urls, |
2047 | 79 | const std::shared_ptr<Registry>& registry) | 79 | const std::shared_ptr<Registry::Impl>& registry) |
2048 | 80 | : Base(appId, job, instance, urls, registry) | 80 | : Base(appId, job, instance, urls, registry) |
2049 | 81 | { | 81 | { |
2050 | 82 | g_debug("Creating a new SystemD for '%s' instance '%s'", std::string(appId).c_str(), instance.c_str()); | 82 | g_debug("Creating a new SystemD for '%s' instance '%s'", std::string(appId).c_str(), instance.c_str()); |
2051 | @@ -84,19 +84,19 @@ | |||
2052 | 84 | 84 | ||
2053 | 85 | pid_t SystemD::primaryPid() | 85 | pid_t SystemD::primaryPid() |
2054 | 86 | { | 86 | { |
2056 | 87 | auto manager = std::dynamic_pointer_cast<manager::SystemD>(registry_->impl->jobs); | 87 | auto manager = std::dynamic_pointer_cast<manager::SystemD>(registry_->jobs()); |
2057 | 88 | return manager->unitPrimaryPid(appId_, job_, instance_); | 88 | return manager->unitPrimaryPid(appId_, job_, instance_); |
2058 | 89 | } | 89 | } |
2059 | 90 | 90 | ||
2060 | 91 | std::vector<pid_t> SystemD::pids() | 91 | std::vector<pid_t> SystemD::pids() |
2061 | 92 | { | 92 | { |
2063 | 93 | auto manager = std::dynamic_pointer_cast<manager::SystemD>(registry_->impl->jobs); | 93 | auto manager = std::dynamic_pointer_cast<manager::SystemD>(registry_->jobs()); |
2064 | 94 | return manager->unitPids(appId_, job_, instance_); | 94 | return manager->unitPids(appId_, job_, instance_); |
2065 | 95 | } | 95 | } |
2066 | 96 | 96 | ||
2067 | 97 | void SystemD::stop() | 97 | void SystemD::stop() |
2068 | 98 | { | 98 | { |
2070 | 99 | auto manager = std::dynamic_pointer_cast<manager::SystemD>(registry_->impl->jobs); | 99 | auto manager = std::dynamic_pointer_cast<manager::SystemD>(registry_->jobs()); |
2071 | 100 | manager->stopUnit(appId_, job_, instance_); | 100 | manager->stopUnit(appId_, job_, instance_); |
2072 | 101 | } | 101 | } |
2073 | 102 | 102 | ||
2074 | @@ -111,7 +111,7 @@ | |||
2075 | 111 | // static const char * SYSTEMD_DBUS_IFACE_UNIT{"org.freedesktop.systemd1.Unit"}; | 111 | // static const char * SYSTEMD_DBUS_IFACE_UNIT{"org.freedesktop.systemd1.Unit"}; |
2076 | 112 | static const char* SYSTEMD_DBUS_IFACE_SERVICE{"org.freedesktop.systemd1.Service"}; | 112 | static const char* SYSTEMD_DBUS_IFACE_SERVICE{"org.freedesktop.systemd1.Service"}; |
2077 | 113 | 113 | ||
2079 | 114 | SystemD::SystemD(std::shared_ptr<Registry> registry) | 114 | SystemD::SystemD(const std::shared_ptr<Registry::Impl>& registry) |
2080 | 115 | : Base(registry) | 115 | : Base(registry) |
2081 | 116 | , handle_unitNew(DBusSignalUnsubscriber{}) | 116 | , handle_unitNew(DBusSignalUnsubscriber{}) |
2082 | 117 | , handle_unitRemoved(DBusSignalUnsubscriber{}) | 117 | , handle_unitRemoved(DBusSignalUnsubscriber{}) |
2083 | @@ -129,8 +129,18 @@ | |||
2084 | 129 | cgroup_root_ = gcgroup_root; | 129 | cgroup_root_ = gcgroup_root; |
2085 | 130 | } | 130 | } |
2086 | 131 | 131 | ||
2089 | 132 | auto cancel = registry->impl->thread.getCancellable(); | 132 | if (getenv("UBUNTU_APP_LAUNCH_SYSTEMD_NO_RESET") != nullptr) |
2090 | 133 | userbus_ = registry->impl->thread.executeOnThread<std::shared_ptr<GDBusConnection>>([this, cancel]() { | 133 | { |
2091 | 134 | noResetUnits_ = true; | ||
2092 | 135 | } | ||
2093 | 136 | |||
2094 | 137 | setupUserbus(registry); | ||
2095 | 138 | } | ||
2096 | 139 | |||
2097 | 140 | void SystemD::setupUserbus(const std::shared_ptr<Registry::Impl>& reg) | ||
2098 | 141 | { | ||
2099 | 142 | auto cancel = reg->thread.getCancellable(); | ||
2100 | 143 | userbus_ = reg->thread.executeOnThread<std::shared_ptr<GDBusConnection>>([this, cancel]() { | ||
2101 | 134 | GError* error = nullptr; | 144 | GError* error = nullptr; |
2102 | 135 | auto bus = std::shared_ptr<GDBusConnection>( | 145 | auto bus = std::shared_ptr<GDBusConnection>( |
2103 | 136 | [&]() -> GDBusConnection* { | 146 | [&]() -> GDBusConnection* { |
2104 | @@ -163,7 +173,7 @@ | |||
2105 | 163 | throw std::runtime_error(message); | 173 | throw std::runtime_error(message); |
2106 | 164 | } | 174 | } |
2107 | 165 | 175 | ||
2109 | 166 | /* If we don't subscribe, it doesn't send us signals :-( */ | 176 | /* If we don't subscribe, it doesn't send us signals */ |
2110 | 167 | g_dbus_connection_call(bus.get(), /* user bus */ | 177 | g_dbus_connection_call(bus.get(), /* user bus */ |
2111 | 168 | SYSTEMD_DBUS_ADDRESS, /* bus name */ | 178 | SYSTEMD_DBUS_ADDRESS, /* bus name */ |
2112 | 169 | SYSTEMD_DBUS_PATH_MANAGER, /* path */ | 179 | SYSTEMD_DBUS_PATH_MANAGER, /* path */ |
2113 | @@ -301,11 +311,6 @@ | |||
2114 | 301 | 311 | ||
2115 | 302 | return bus; | 312 | return bus; |
2116 | 303 | }); | 313 | }); |
2117 | 304 | |||
2118 | 305 | if (getenv("UBUNTU_APP_LAUNCH_SYSTEMD_NO_RESET") != nullptr) | ||
2119 | 306 | { | ||
2120 | 307 | noResetUnits_ = true; | ||
2121 | 308 | } | ||
2122 | 309 | } | 314 | } |
2123 | 310 | 315 | ||
2124 | 311 | SystemD::~SystemD() | 316 | SystemD::~SystemD() |
2125 | @@ -354,14 +359,12 @@ | |||
2126 | 354 | while (g_variant_iter_loop(iter.get(), "(&s&s&s&s&s&s&ou&s&o)", &id, &description, &loadState, &activeState, | 359 | while (g_variant_iter_loop(iter.get(), "(&s&s&s&s&s&s&ou&s&o)", &id, &description, &loadState, &activeState, |
2127 | 355 | &subState, &following, &path, &jobId, &jobType, &jobPath)) | 360 | &subState, &following, &path, &jobId, &jobType, &jobPath)) |
2128 | 356 | { | 361 | { |
2129 | 357 | g_debug("List Units: %s", id); | ||
2130 | 358 | try | 362 | try |
2131 | 359 | { | 363 | { |
2132 | 360 | unitNew(id, jobPath, bus); | 364 | unitNew(id, jobPath, bus); |
2133 | 361 | } | 365 | } |
2134 | 362 | catch (std::runtime_error& e) | 366 | catch (std::runtime_error& e) |
2135 | 363 | { | 367 | { |
2136 | 364 | g_debug("%s", e.what()); | ||
2137 | 365 | } | 368 | } |
2138 | 366 | } | 369 | } |
2139 | 367 | } | 370 | } |
2140 | @@ -511,12 +514,12 @@ | |||
2141 | 511 | if (g_strcmp0(remote_error, "org.freedesktop.systemd1.UnitExists") == 0) | 514 | if (g_strcmp0(remote_error, "org.freedesktop.systemd1.UnitExists") == 0) |
2142 | 512 | { | 515 | { |
2143 | 513 | auto urls = instance::SystemD::urlsToStrv(data->ptr->urls_); | 516 | auto urls = instance::SystemD::urlsToStrv(data->ptr->urls_); |
2150 | 514 | second_exec(data->bus.get(), /* DBus */ | 517 | second_exec(data->bus.get(), /* DBus */ |
2151 | 515 | data->ptr->registry_->impl->thread.getCancellable().get(), /* cancellable */ | 518 | data->ptr->registry_->thread.getCancellable().get(), /* cancellable */ |
2152 | 516 | data->ptr->primaryPid(), /* primary pid */ | 519 | data->ptr->primaryPid(), /* primary pid */ |
2153 | 517 | std::string(data->ptr->appId_).c_str(), /* appid */ | 520 | std::string(data->ptr->appId_).c_str(), /* appid */ |
2154 | 518 | data->ptr->instance_.c_str(), /* instance */ | 521 | data->ptr->instance_.c_str(), /* instance */ |
2155 | 519 | urls.get()); /* urls */ | 522 | urls.get()); /* urls */ |
2156 | 520 | } | 523 | } |
2157 | 521 | 524 | ||
2158 | 522 | g_free(remote_error); | 525 | g_free(remote_error); |
2159 | @@ -579,247 +582,246 @@ | |||
2160 | 579 | if (appId.empty()) | 582 | if (appId.empty()) |
2161 | 580 | return {}; | 583 | return {}; |
2162 | 581 | 584 | ||
2313 | 582 | bool isApplication = | 585 | auto appJobs = getAllApplicationJobs(); |
2314 | 583 | std::find(allApplicationJobs_.begin(), allApplicationJobs_.end(), job) != allApplicationJobs_.end(); | 586 | bool isApplication = std::find(appJobs.begin(), appJobs.end(), job) != appJobs.end(); |
2315 | 584 | 587 | ||
2316 | 585 | auto registry = registry_.lock(); | 588 | auto reg = getReg(); |
2317 | 586 | return registry->impl->thread.executeOnThread<std::shared_ptr<instance::SystemD>>( | 589 | return reg->thread.executeOnThread<std::shared_ptr<instance::SystemD>>([&]() -> std::shared_ptr<instance::SystemD> { |
2318 | 587 | [&]() -> std::shared_ptr<instance::SystemD> { | 590 | auto manager = std::dynamic_pointer_cast<manager::SystemD>(reg->jobs()); |
2319 | 588 | auto manager = std::dynamic_pointer_cast<manager::SystemD>(registry->impl->jobs); | 591 | std::string appIdStr{appId}; |
2320 | 589 | std::string appIdStr{appId}; | 592 | g_debug("Initializing params for an new instance::SystemD for: %s", appIdStr.c_str()); |
2321 | 590 | g_debug("Initializing params for an new instance::SystemD for: %s", appIdStr.c_str()); | 593 | |
2322 | 591 | 594 | tracepoint(ubuntu_app_launch, libual_start, appIdStr.c_str()); | |
2323 | 592 | tracepoint(ubuntu_app_launch, libual_start, appIdStr.c_str()); | 595 | |
2324 | 593 | 596 | int timeout = 1; | |
2325 | 594 | int timeout = 1; | 597 | if (ubuntu::app_launch::Registry::Impl::isWatchingAppStarting()) |
2326 | 595 | if (ubuntu::app_launch::Registry::Impl::isWatchingAppStarting()) | 598 | { |
2327 | 596 | { | 599 | timeout = 0; |
2328 | 597 | timeout = 0; | 600 | } |
2329 | 598 | } | 601 | |
2330 | 599 | 602 | handshake_t* handshake{nullptr}; | |
2331 | 600 | handshake_t* handshake{nullptr}; | 603 | |
2332 | 601 | 604 | if (isApplication) | |
2333 | 602 | if (isApplication) | 605 | { |
2334 | 603 | { | 606 | handshake = starting_handshake_start(appIdStr.c_str(), instance.c_str(), timeout); |
2335 | 604 | handshake = starting_handshake_start(appIdStr.c_str(), instance.c_str(), timeout); | 607 | if (handshake == nullptr) |
2336 | 605 | if (handshake == nullptr) | 608 | { |
2337 | 606 | { | 609 | g_warning("Unable to setup starting handshake"); |
2338 | 607 | g_warning("Unable to setup starting handshake"); | 610 | } |
2339 | 608 | } | 611 | } |
2340 | 609 | } | 612 | |
2341 | 610 | 613 | /* Figure out the unit name for the job */ | |
2342 | 611 | /* Figure out the unit name for the job */ | 614 | auto unitname = unitName(SystemD::UnitInfo{appIdStr, job, instance}); |
2343 | 612 | auto unitname = unitName(SystemD::UnitInfo{appIdStr, job, instance}); | 615 | |
2344 | 613 | 616 | /* Build up our environment */ | |
2345 | 614 | /* Build up our environment */ | 617 | auto env = getenv(); |
2346 | 615 | auto env = getenv(); | 618 | |
2347 | 616 | 619 | env.emplace_back(std::make_pair("APP_ID", appIdStr)); /* Application ID */ | |
2348 | 617 | env.emplace_back(std::make_pair("APP_ID", appIdStr)); /* Application ID */ | 620 | env.emplace_back(std::make_pair("APP_LAUNCHER_PID", std::to_string(getpid()))); /* Who we are, for bugs */ |
2349 | 618 | env.emplace_back(std::make_pair("APP_LAUNCHER_PID", std::to_string(getpid()))); /* Who we are, for bugs */ | 621 | |
2350 | 619 | 622 | copyEnv("DISPLAY", env); | |
2351 | 620 | copyEnv("DISPLAY", env); | 623 | |
2352 | 621 | 624 | for (const auto& prefix : {"DBUS_", "MIR_", "UBUNTU_APP_LAUNCH_"}) | |
2353 | 622 | for (const auto& prefix : {"DBUS_", "MIR_", "UBUNTU_APP_LAUNCH_"}) | 625 | { |
2354 | 623 | { | 626 | copyEnvByPrefix(prefix, env); |
2355 | 624 | copyEnvByPrefix(prefix, env); | 627 | } |
2356 | 625 | } | 628 | |
2357 | 626 | 629 | /* If we're in deb mode and launching legacy apps, they're gonna need | |
2358 | 627 | /* If we're in deb mode and launching legacy apps, they're gonna need | 630 | * more context, they really have no other way to get it. */ |
2359 | 628 | * more context, they really have no other way to get it. */ | 631 | if (g_getenv("SNAP") == nullptr && appId.package.value().empty()) |
2360 | 629 | if (g_getenv("SNAP") == nullptr && appId.package.value().empty()) | 632 | { |
2361 | 630 | { | 633 | copyEnvByPrefix("QT_", env); |
2362 | 631 | copyEnvByPrefix("QT_", env); | 634 | copyEnvByPrefix("XDG_", env); |
2363 | 632 | copyEnvByPrefix("XDG_", env); | 635 | copyEnv("UBUNTU_APP_LAUNCH_XMIR_PATH", env); |
2364 | 633 | copyEnv("UBUNTU_APP_LAUNCH_XMIR_PATH", env); | 636 | |
2365 | 634 | 637 | /* If we're in Unity8 we don't want to pass it's platform, we want | |
2366 | 635 | /* If we're in Unity8 we don't want to pass it's platform, we want | 638 | * an application platform. */ |
2367 | 636 | * an application platform. */ | 639 | if (findEnv("QT_QPA_PLATFORM", env) == "mirserver") |
2368 | 637 | if (findEnv("QT_QPA_PLATFORM", env) == "mirserver") | 640 | { |
2369 | 638 | { | 641 | removeEnv("QT_QPA_PLATFORM", env); |
2370 | 639 | removeEnv("QT_QPA_PLATFORM", env); | 642 | env.emplace_back(std::make_pair("QT_QPA_PLATFORM", "ubuntumirclient")); |
2371 | 640 | env.emplace_back(std::make_pair("QT_QPA_PLATFORM", "ubuntumirclient")); | 643 | } |
2372 | 641 | } | 644 | } |
2373 | 642 | } | 645 | |
2374 | 643 | 646 | /* Mir socket if we don't have one in our env */ | |
2375 | 644 | /* Mir socket if we don't have one in our env */ | 647 | if (findEnv("MIR_SOCKET", env).empty()) |
2376 | 645 | if (findEnv("MIR_SOCKET", env).empty()) | 648 | { |
2377 | 646 | { | 649 | env.emplace_back(std::make_pair("MIR_SOCKET", g_get_user_runtime_dir() + std::string{"/mir_socket"})); |
2378 | 647 | env.emplace_back(std::make_pair("MIR_SOCKET", g_get_user_runtime_dir() + std::string{"/mir_socket"})); | 650 | } |
2379 | 648 | } | 651 | |
2380 | 649 | 652 | if (!urls.empty()) | |
2381 | 650 | if (!urls.empty()) | 653 | { |
2382 | 651 | { | 654 | auto accumfunc = [](const std::string& prev, Application::URL thisurl) -> std::string { |
2383 | 652 | auto accumfunc = [](const std::string& prev, Application::URL thisurl) -> std::string { | 655 | gchar* gescaped = g_shell_quote(thisurl.value().c_str()); |
2384 | 653 | gchar* gescaped = g_shell_quote(thisurl.value().c_str()); | 656 | std::string escaped; |
2385 | 654 | std::string escaped; | 657 | if (gescaped != nullptr) |
2386 | 655 | if (gescaped != nullptr) | 658 | { |
2387 | 656 | { | 659 | escaped = gescaped; |
2388 | 657 | escaped = gescaped; | 660 | g_free(gescaped); |
2389 | 658 | g_free(gescaped); | 661 | } |
2390 | 659 | } | 662 | else |
2391 | 660 | else | 663 | { |
2392 | 661 | { | 664 | g_warning("Unable to escape URL: %s", thisurl.value().c_str()); |
2393 | 662 | g_warning("Unable to escape URL: %s", thisurl.value().c_str()); | 665 | return prev; |
2394 | 663 | return prev; | 666 | } |
2395 | 664 | } | 667 | |
2396 | 665 | 668 | if (prev.empty()) | |
2397 | 666 | if (prev.empty()) | 669 | { |
2398 | 667 | { | 670 | return escaped; |
2399 | 668 | return escaped; | 671 | } |
2400 | 669 | } | 672 | else |
2401 | 670 | else | 673 | { |
2402 | 671 | { | 674 | return prev + " " + escaped; |
2403 | 672 | return prev + " " + escaped; | 675 | } |
2404 | 673 | } | 676 | }; |
2405 | 674 | }; | 677 | auto urlstring = std::accumulate(urls.begin(), urls.end(), std::string{}, accumfunc); |
2406 | 675 | auto urlstring = std::accumulate(urls.begin(), urls.end(), std::string{}, accumfunc); | 678 | env.emplace_back(std::make_pair("APP_URIS", urlstring)); |
2407 | 676 | env.emplace_back(std::make_pair("APP_URIS", urlstring)); | 679 | } |
2408 | 677 | } | 680 | |
2409 | 678 | 681 | if (mode == launchMode::TEST) | |
2410 | 679 | if (mode == launchMode::TEST) | 682 | { |
2411 | 680 | { | 683 | env.emplace_back(std::make_pair("QT_LOAD_TESTABILITY", "1")); |
2412 | 681 | env.emplace_back(std::make_pair("QT_LOAD_TESTABILITY", "1")); | 684 | } |
2413 | 682 | } | 685 | |
2414 | 683 | 686 | /* Convert to GVariant */ | |
2415 | 684 | /* Convert to GVariant */ | 687 | GVariantBuilder builder; |
2416 | 685 | GVariantBuilder builder; | 688 | g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE); |
2417 | 686 | g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE); | 689 | |
2418 | 687 | 690 | g_variant_builder_add_value(&builder, g_variant_new_string(unitname.c_str())); | |
2419 | 688 | g_variant_builder_add_value(&builder, g_variant_new_string(unitname.c_str())); | 691 | g_variant_builder_add_value(&builder, g_variant_new_string("replace")); // Job mode |
2420 | 689 | g_variant_builder_add_value(&builder, g_variant_new_string("replace")); // Job mode | 692 | |
2421 | 690 | 693 | /* Parameter Array */ | |
2422 | 691 | /* Parameter Array */ | 694 | g_variant_builder_open(&builder, G_VARIANT_TYPE_ARRAY); |
2423 | 692 | g_variant_builder_open(&builder, G_VARIANT_TYPE_ARRAY); | 695 | |
2424 | 693 | 696 | /* ExecStart */ | |
2425 | 694 | /* ExecStart */ | 697 | auto commands = parseExec(env); |
2426 | 695 | auto commands = parseExec(env); | 698 | if (!commands.empty()) |
2427 | 696 | if (!commands.empty()) | 699 | { |
2278 | 697 | { | ||
2279 | 698 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); | ||
2280 | 699 | g_variant_builder_add_value(&builder, g_variant_new_string("ExecStart")); | ||
2281 | 700 | g_variant_builder_open(&builder, G_VARIANT_TYPE_VARIANT); | ||
2282 | 701 | g_variant_builder_open(&builder, G_VARIANT_TYPE_ARRAY); | ||
2283 | 702 | |||
2284 | 703 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); | ||
2285 | 704 | |||
2286 | 705 | gchar* pathexec = g_find_program_in_path(commands[0].c_str()); | ||
2287 | 706 | if (pathexec != nullptr) | ||
2288 | 707 | { | ||
2289 | 708 | g_variant_builder_add_value(&builder, g_variant_new_take_string(pathexec)); | ||
2290 | 709 | } | ||
2291 | 710 | else | ||
2292 | 711 | { | ||
2293 | 712 | g_debug("Unable to find '%s' in PATH=%s", commands[0].c_str(), g_getenv("PATH")); | ||
2294 | 713 | g_variant_builder_add_value(&builder, g_variant_new_string(commands[0].c_str())); | ||
2295 | 714 | } | ||
2296 | 715 | |||
2297 | 716 | g_variant_builder_open(&builder, G_VARIANT_TYPE_ARRAY); | ||
2298 | 717 | for (const auto& param : commands) | ||
2299 | 718 | { | ||
2300 | 719 | g_variant_builder_add_value(&builder, g_variant_new_string(param.c_str())); | ||
2301 | 720 | } | ||
2302 | 721 | g_variant_builder_close(&builder); | ||
2303 | 722 | |||
2304 | 723 | g_variant_builder_add_value(&builder, g_variant_new_boolean(FALSE)); | ||
2305 | 724 | |||
2306 | 725 | g_variant_builder_close(&builder); | ||
2307 | 726 | g_variant_builder_close(&builder); | ||
2308 | 727 | g_variant_builder_close(&builder); | ||
2309 | 728 | g_variant_builder_close(&builder); | ||
2310 | 729 | } | ||
2311 | 730 | |||
2312 | 731 | /* RemainAfterExit */ | ||
2428 | 732 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); | 700 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); |
2430 | 733 | g_variant_builder_add_value(&builder, g_variant_new_string("RemainAfterExit")); | 701 | g_variant_builder_add_value(&builder, g_variant_new_string("ExecStart")); |
2431 | 734 | g_variant_builder_open(&builder, G_VARIANT_TYPE_VARIANT); | 702 | g_variant_builder_open(&builder, G_VARIANT_TYPE_VARIANT); |
2432 | 703 | g_variant_builder_open(&builder, G_VARIANT_TYPE_ARRAY); | ||
2433 | 704 | |||
2434 | 705 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); | ||
2435 | 706 | |||
2436 | 707 | gchar* pathexec = g_find_program_in_path(commands[0].c_str()); | ||
2437 | 708 | if (pathexec != nullptr) | ||
2438 | 709 | { | ||
2439 | 710 | g_variant_builder_add_value(&builder, g_variant_new_take_string(pathexec)); | ||
2440 | 711 | } | ||
2441 | 712 | else | ||
2442 | 713 | { | ||
2443 | 714 | g_debug("Unable to find '%s' in PATH=%s", commands[0].c_str(), g_getenv("PATH")); | ||
2444 | 715 | g_variant_builder_add_value(&builder, g_variant_new_string(commands[0].c_str())); | ||
2445 | 716 | } | ||
2446 | 717 | |||
2447 | 718 | g_variant_builder_open(&builder, G_VARIANT_TYPE_ARRAY); | ||
2448 | 719 | for (const auto& param : commands) | ||
2449 | 720 | { | ||
2450 | 721 | g_variant_builder_add_value(&builder, g_variant_new_string(param.c_str())); | ||
2451 | 722 | } | ||
2452 | 723 | g_variant_builder_close(&builder); | ||
2453 | 724 | |||
2454 | 735 | g_variant_builder_add_value(&builder, g_variant_new_boolean(FALSE)); | 725 | g_variant_builder_add_value(&builder, g_variant_new_boolean(FALSE)); |
2542 | 736 | g_variant_builder_close(&builder); | 726 | |
2543 | 737 | g_variant_builder_close(&builder); | 727 | g_variant_builder_close(&builder); |
2544 | 738 | 728 | g_variant_builder_close(&builder); | |
2545 | 739 | /* Type */ | 729 | g_variant_builder_close(&builder); |
2546 | 740 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); | 730 | g_variant_builder_close(&builder); |
2547 | 741 | g_variant_builder_add_value(&builder, g_variant_new_string("Type")); | 731 | } |
2548 | 742 | g_variant_builder_open(&builder, G_VARIANT_TYPE_VARIANT); | 732 | |
2549 | 743 | g_variant_builder_add_value(&builder, g_variant_new_string("oneshot")); | 733 | /* RemainAfterExit */ |
2550 | 744 | g_variant_builder_close(&builder); | 734 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); |
2551 | 745 | g_variant_builder_close(&builder); | 735 | g_variant_builder_add_value(&builder, g_variant_new_string("RemainAfterExit")); |
2552 | 746 | 736 | g_variant_builder_open(&builder, G_VARIANT_TYPE_VARIANT); | |
2553 | 747 | /* Working Directory */ | 737 | g_variant_builder_add_value(&builder, g_variant_new_boolean(FALSE)); |
2554 | 748 | if (!findEnv("APP_DIR", env).empty()) | 738 | g_variant_builder_close(&builder); |
2555 | 749 | { | 739 | g_variant_builder_close(&builder); |
2556 | 750 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); | 740 | |
2557 | 751 | g_variant_builder_add_value(&builder, g_variant_new_string("WorkingDirectory")); | 741 | /* Type */ |
2558 | 752 | g_variant_builder_open(&builder, G_VARIANT_TYPE_VARIANT); | 742 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); |
2559 | 753 | g_variant_builder_add_value(&builder, g_variant_new_string(findEnv("APP_DIR", env).c_str())); | 743 | g_variant_builder_add_value(&builder, g_variant_new_string("Type")); |
2560 | 754 | g_variant_builder_close(&builder); | 744 | g_variant_builder_open(&builder, G_VARIANT_TYPE_VARIANT); |
2561 | 755 | g_variant_builder_close(&builder); | 745 | g_variant_builder_add_value(&builder, g_variant_new_string("oneshot")); |
2562 | 756 | } | 746 | g_variant_builder_close(&builder); |
2563 | 757 | 747 | g_variant_builder_close(&builder); | |
2564 | 758 | /* Clean up env before shipping it */ | 748 | |
2565 | 759 | for (const auto& rmenv : | 749 | /* Working Directory */ |
2566 | 760 | {"APP_XMIR_ENABLE", "APP_DIR", "APP_URIS", "APP_EXEC", "APP_EXEC_POLICY", "APP_LAUNCHER_PID", | 750 | if (!findEnv("APP_DIR", env).empty()) |
2567 | 761 | "INSTANCE_ID", "MIR_SERVER_PLATFORM_PATH", "MIR_SERVER_PROMPT_FILE", "MIR_SERVER_HOST_SOCKET", | 751 | { |
2568 | 762 | "UBUNTU_APP_LAUNCH_OOM_HELPER", "UBUNTU_APP_LAUNCH_LEGACY_ROOT", "UBUNTU_APP_LAUNCH_XMIR_HELPER"}) | 752 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); |
2569 | 763 | { | 753 | g_variant_builder_add_value(&builder, g_variant_new_string("WorkingDirectory")); |
2570 | 764 | removeEnv(rmenv, env); | 754 | g_variant_builder_open(&builder, G_VARIANT_TYPE_VARIANT); |
2571 | 765 | } | 755 | g_variant_builder_add_value(&builder, g_variant_new_string(findEnv("APP_DIR", env).c_str())); |
2572 | 766 | 756 | g_variant_builder_close(&builder); | |
2573 | 767 | g_debug("Environment length: %d", envSize(env)); | 757 | g_variant_builder_close(&builder); |
2574 | 768 | 758 | } | |
2575 | 769 | /* Environment */ | 759 | |
2576 | 770 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); | 760 | /* Clean up env before shipping it */ |
2577 | 771 | g_variant_builder_add_value(&builder, g_variant_new_string("Environment")); | 761 | for (const auto& rmenv : |
2578 | 772 | g_variant_builder_open(&builder, G_VARIANT_TYPE_VARIANT); | 762 | {"APP_XMIR_ENABLE", "APP_DIR", "APP_URIS", "APP_EXEC", "APP_EXEC_POLICY", "APP_LAUNCHER_PID", |
2579 | 773 | g_variant_builder_open(&builder, G_VARIANT_TYPE_ARRAY); | 763 | "INSTANCE_ID", "MIR_SERVER_PLATFORM_PATH", "MIR_SERVER_PROMPT_FILE", "MIR_SERVER_HOST_SOCKET", |
2580 | 774 | for (const auto& envvar : env) | 764 | "UBUNTU_APP_LAUNCH_OOM_HELPER", "UBUNTU_APP_LAUNCH_LEGACY_ROOT", "UBUNTU_APP_LAUNCH_XMIR_HELPER"}) |
2581 | 775 | { | 765 | { |
2582 | 776 | if (!envvar.first.empty() && !envvar.second.empty()) | 766 | removeEnv(rmenv, env); |
2583 | 777 | { | 767 | } |
2584 | 778 | g_variant_builder_add_value(&builder, g_variant_new_take_string(g_strdup_printf( | 768 | |
2585 | 779 | "%s=%s", envvar.first.c_str(), envvar.second.c_str()))); | 769 | g_debug("Environment length: %d", envSize(env)); |
2586 | 780 | // g_debug("Setting environment: %s=%s", envvar.first.c_str(), envvar.second.c_str()); | 770 | |
2587 | 781 | } | 771 | /* Environment */ |
2588 | 782 | } | 772 | g_variant_builder_open(&builder, G_VARIANT_TYPE_TUPLE); |
2589 | 783 | 773 | g_variant_builder_add_value(&builder, g_variant_new_string("Environment")); | |
2590 | 784 | g_variant_builder_close(&builder); | 774 | g_variant_builder_open(&builder, G_VARIANT_TYPE_VARIANT); |
2591 | 785 | g_variant_builder_close(&builder); | 775 | g_variant_builder_open(&builder, G_VARIANT_TYPE_ARRAY); |
2592 | 786 | g_variant_builder_close(&builder); | 776 | for (const auto& envvar : env) |
2593 | 787 | 777 | { | |
2594 | 788 | /* Parameter Array */ | 778 | if (!envvar.first.empty() && !envvar.second.empty()) |
2595 | 789 | g_variant_builder_close(&builder); | 779 | { |
2596 | 790 | 780 | g_variant_builder_add_value(&builder, g_variant_new_take_string(g_strdup_printf( | |
2597 | 791 | /* Dependent Units (none) */ | 781 | "%s=%s", envvar.first.c_str(), envvar.second.c_str()))); |
2598 | 792 | g_variant_builder_add_value(&builder, g_variant_new_array(G_VARIANT_TYPE("(sa(sv))"), nullptr, 0)); | 782 | // g_debug("Setting environment: %s=%s", envvar.first.c_str(), envvar.second.c_str()); |
2599 | 793 | 783 | } | |
2600 | 794 | auto retval = std::make_shared<instance::SystemD>(appId, job, instance, urls, registry); | 784 | } |
2601 | 795 | auto chelper = new StartCHelper{}; | 785 | |
2602 | 796 | chelper->ptr = retval; | 786 | g_variant_builder_close(&builder); |
2603 | 797 | chelper->bus = registry->impl->_dbus; | 787 | g_variant_builder_close(&builder); |
2604 | 798 | 788 | g_variant_builder_close(&builder); | |
2605 | 799 | tracepoint(ubuntu_app_launch, handshake_wait, appIdStr.c_str()); | 789 | |
2606 | 800 | starting_handshake_wait(handshake); | 790 | /* Parameter Array */ |
2607 | 801 | tracepoint(ubuntu_app_launch, handshake_complete, appIdStr.c_str()); | 791 | g_variant_builder_close(&builder); |
2608 | 802 | 792 | ||
2609 | 803 | /* Call the job start function */ | 793 | /* Dependent Units (none) */ |
2610 | 804 | g_debug("Asking systemd to start task for: %s", appIdStr.c_str()); | 794 | g_variant_builder_add_value(&builder, g_variant_new_array(G_VARIANT_TYPE("(sa(sv))"), nullptr, 0)); |
2611 | 805 | g_dbus_connection_call(manager->userbus_.get(), /* bus */ | 795 | |
2612 | 806 | SYSTEMD_DBUS_ADDRESS, /* service name */ | 796 | auto retval = std::make_shared<instance::SystemD>(appId, job, instance, urls, reg); |
2613 | 807 | SYSTEMD_DBUS_PATH_MANAGER, /* Path */ | 797 | auto chelper = new StartCHelper{}; |
2614 | 808 | SYSTEMD_DBUS_IFACE_MANAGER, /* interface */ | 798 | chelper->ptr = retval; |
2615 | 809 | "StartTransientUnit", /* method */ | 799 | chelper->bus = reg->_dbus; |
2616 | 810 | g_variant_builder_end(&builder), /* params */ | 800 | |
2617 | 811 | G_VARIANT_TYPE("(o)"), /* return */ | 801 | tracepoint(ubuntu_app_launch, handshake_wait, appIdStr.c_str()); |
2618 | 812 | G_DBUS_CALL_FLAGS_NONE, /* flags */ | 802 | starting_handshake_wait(handshake); |
2619 | 813 | -1, /* default timeout */ | 803 | tracepoint(ubuntu_app_launch, handshake_complete, appIdStr.c_str()); |
2620 | 814 | registry->impl->thread.getCancellable().get(), /* cancellable */ | 804 | |
2621 | 815 | application_start_cb, /* callback */ | 805 | /* Call the job start function */ |
2622 | 816 | chelper /* object */ | 806 | g_debug("Asking systemd to start task for: %s", appIdStr.c_str()); |
2623 | 817 | ); | 807 | g_dbus_connection_call(manager->userbus_.get(), /* bus */ |
2624 | 818 | 808 | SYSTEMD_DBUS_ADDRESS, /* service name */ | |
2625 | 819 | tracepoint(ubuntu_app_launch, libual_start_message_sent, appIdStr.c_str()); | 809 | SYSTEMD_DBUS_PATH_MANAGER, /* Path */ |
2626 | 820 | 810 | SYSTEMD_DBUS_IFACE_MANAGER, /* interface */ | |
2627 | 821 | return retval; | 811 | "StartTransientUnit", /* method */ |
2628 | 822 | }); | 812 | g_variant_builder_end(&builder), /* params */ |
2629 | 813 | G_VARIANT_TYPE("(o)"), /* return */ | ||
2630 | 814 | G_DBUS_CALL_FLAGS_NONE, /* flags */ | ||
2631 | 815 | -1, /* default timeout */ | ||
2632 | 816 | reg->thread.getCancellable().get(), /* cancellable */ | ||
2633 | 817 | application_start_cb, /* callback */ | ||
2634 | 818 | chelper /* object */ | ||
2635 | 819 | ); | ||
2636 | 820 | |||
2637 | 821 | tracepoint(ubuntu_app_launch, libual_start_message_sent, appIdStr.c_str()); | ||
2638 | 822 | |||
2639 | 823 | return retval; | ||
2640 | 824 | }); | ||
2641 | 823 | } | 825 | } |
2642 | 824 | 826 | ||
2643 | 825 | std::shared_ptr<Application::Instance> SystemD::existing(const AppID& appId, | 827 | std::shared_ptr<Application::Instance> SystemD::existing(const AppID& appId, |
2644 | @@ -827,20 +829,15 @@ | |||
2645 | 827 | const std::string& instance, | 829 | const std::string& instance, |
2646 | 828 | const std::vector<Application::URL>& urls) | 830 | const std::vector<Application::URL>& urls) |
2647 | 829 | { | 831 | { |
2649 | 830 | return std::make_shared<instance::SystemD>(appId, job, instance, urls, registry_.lock()); | 832 | return std::make_shared<instance::SystemD>(appId, job, instance, urls, getReg()); |
2650 | 831 | } | 833 | } |
2651 | 832 | 834 | ||
2652 | 833 | std::vector<std::shared_ptr<instance::Base>> SystemD::instances(const AppID& appID, const std::string& job) | 835 | std::vector<std::shared_ptr<instance::Base>> SystemD::instances(const AppID& appID, const std::string& job) |
2653 | 834 | { | 836 | { |
2654 | 837 | auto reg = getReg(); | ||
2655 | 838 | |||
2656 | 835 | std::vector<std::shared_ptr<instance::Base>> instances; | 839 | std::vector<std::shared_ptr<instance::Base>> instances; |
2657 | 836 | std::vector<Application::URL> urls; | 840 | std::vector<Application::URL> urls; |
2658 | 837 | auto registry = registry_.lock(); | ||
2659 | 838 | |||
2660 | 839 | if (!registry) | ||
2661 | 840 | { | ||
2662 | 841 | g_warning("Unable to list instances without a registry"); | ||
2663 | 842 | return {}; | ||
2664 | 843 | } | ||
2665 | 844 | 841 | ||
2666 | 845 | std::string sappid{appID}; | 842 | std::string sappid{appID}; |
2667 | 846 | for (const auto& unit : unitPaths) | 843 | for (const auto& unit : unitPaths) |
2668 | @@ -857,7 +854,7 @@ | |||
2669 | 857 | continue; | 854 | continue; |
2670 | 858 | } | 855 | } |
2671 | 859 | 856 | ||
2673 | 860 | instances.emplace_back(std::make_shared<instance::SystemD>(appID, job, unitinfo.inst, urls, registry)); | 857 | instances.emplace_back(std::make_shared<instance::SystemD>(appID, job, unitinfo.inst, urls, reg)); |
2674 | 861 | } | 858 | } |
2675 | 862 | 859 | ||
2676 | 863 | g_debug("Found %d instances for AppID '%s'", int(instances.size()), std::string(appID).c_str()); | 860 | g_debug("Found %d instances for AppID '%s'", int(instances.size()), std::string(appID).c_str()); |
2677 | @@ -867,14 +864,6 @@ | |||
2678 | 867 | 864 | ||
2679 | 868 | std::list<std::string> SystemD::runningAppIds(const std::list<std::string>& allJobs) | 865 | std::list<std::string> SystemD::runningAppIds(const std::list<std::string>& allJobs) |
2680 | 869 | { | 866 | { |
2681 | 870 | auto registry = registry_.lock(); | ||
2682 | 871 | |||
2683 | 872 | if (!registry) | ||
2684 | 873 | { | ||
2685 | 874 | g_warning("Unable to list instances without a registry"); | ||
2686 | 875 | return {}; | ||
2687 | 876 | } | ||
2688 | 877 | |||
2689 | 878 | std::set<std::string> appids; | 867 | std::set<std::string> appids; |
2690 | 879 | 868 | ||
2691 | 880 | for (const auto& unit : unitPaths) | 869 | for (const auto& unit : unitPaths) |
2692 | @@ -923,6 +912,7 @@ | |||
2693 | 923 | 912 | ||
2694 | 924 | std::string SystemD::unitPath(const SystemD::UnitInfo& info) | 913 | std::string SystemD::unitPath(const SystemD::UnitInfo& info) |
2695 | 925 | { | 914 | { |
2696 | 915 | auto reg = getReg(); | ||
2697 | 926 | auto data = unitPaths[info]; | 916 | auto data = unitPaths[info]; |
2698 | 927 | 917 | ||
2699 | 928 | if (!data) | 918 | if (!data) |
2700 | @@ -930,17 +920,9 @@ | |||
2701 | 930 | return {}; | 920 | return {}; |
2702 | 931 | } | 921 | } |
2703 | 932 | 922 | ||
2704 | 933 | auto registry = registry_.lock(); | ||
2705 | 934 | |||
2706 | 935 | if (!registry) | ||
2707 | 936 | { | ||
2708 | 937 | g_warning("Unable to get registry to determine path"); | ||
2709 | 938 | return {}; | ||
2710 | 939 | } | ||
2711 | 940 | |||
2712 | 941 | /* Execute on the thread so that we're sure that we're not in | 923 | /* Execute on the thread so that we're sure that we're not in |
2713 | 942 | a dbus call to get the value. No racey for you! */ | 924 | a dbus call to get the value. No racey for you! */ |
2715 | 943 | return registry->impl->thread.executeOnThread<std::string>([&data]() { return data->unitpath; }); | 925 | return reg->thread.executeOnThread<std::string>([&data]() { return data->unitpath; }); |
2716 | 944 | } | 926 | } |
2717 | 945 | 927 | ||
2718 | 946 | SystemD::UnitInfo SystemD::unitNew(const std::string& name, | 928 | SystemD::UnitInfo SystemD::unitNew(const std::string& name, |
2719 | @@ -952,9 +934,11 @@ | |||
2720 | 952 | throw std::runtime_error{"Job path for unit is '/' so likely failed"}; | 934 | throw std::runtime_error{"Job path for unit is '/' so likely failed"}; |
2721 | 953 | } | 935 | } |
2722 | 954 | 936 | ||
2723 | 937 | auto info = parseUnit(name); | ||
2724 | 938 | |||
2725 | 955 | g_debug("New Unit: %s", name.c_str()); | 939 | g_debug("New Unit: %s", name.c_str()); |
2726 | 956 | 940 | ||
2728 | 957 | auto info = parseUnit(name); | 941 | auto reg = getReg(); |
2729 | 958 | 942 | ||
2730 | 959 | auto data = std::make_shared<UnitData>(); | 943 | auto data = std::make_shared<UnitData>(); |
2731 | 960 | data->jobpath = path; | 944 | data->jobpath = path; |
2732 | @@ -971,24 +955,16 @@ | |||
2733 | 971 | comes an asking at this point we'll think that we have the | 955 | comes an asking at this point we'll think that we have the |
2734 | 972 | app, but not yet its path */ | 956 | app, but not yet its path */ |
2735 | 973 | GError* error{nullptr}; | 957 | GError* error{nullptr}; |
2754 | 974 | auto reg = registry_.lock(); | 958 | auto call = unique_glib(g_dbus_connection_call_sync(bus.get(), /* user bus */ |
2755 | 975 | 959 | SYSTEMD_DBUS_ADDRESS, /* bus name */ | |
2756 | 976 | if (!reg) | 960 | SYSTEMD_DBUS_PATH_MANAGER, /* path */ |
2757 | 977 | { | 961 | SYSTEMD_DBUS_IFACE_MANAGER, /* interface */ |
2758 | 978 | g_warning("Unable to get SystemD unit path for '%s': Registry out of scope", name.c_str()); | 962 | "GetUnit", /* method */ |
2759 | 979 | throw std::runtime_error{"Unable to get SystemD unit path for '" + name + "': Registry out of scope"}; | 963 | g_variant_new("(s)", name.c_str()), /* params */ |
2760 | 980 | } | 964 | G_VARIANT_TYPE("(o)"), /* ret type */ |
2761 | 981 | 965 | G_DBUS_CALL_FLAGS_NONE, /* flags */ | |
2762 | 982 | auto call = unique_glib(g_dbus_connection_call_sync(bus.get(), /* user bus */ | 966 | -1, /* timeout */ |
2763 | 983 | SYSTEMD_DBUS_ADDRESS, /* bus name */ | 967 | reg->thread.getCancellable().get(), /* cancellable */ |
2746 | 984 | SYSTEMD_DBUS_PATH_MANAGER, /* path */ | ||
2747 | 985 | SYSTEMD_DBUS_IFACE_MANAGER, /* interface */ | ||
2748 | 986 | "GetUnit", /* method */ | ||
2749 | 987 | g_variant_new("(s)", name.c_str()), /* params */ | ||
2750 | 988 | G_VARIANT_TYPE("(o)"), /* ret type */ | ||
2751 | 989 | G_DBUS_CALL_FLAGS_NONE, /* flags */ | ||
2752 | 990 | -1, /* timeout */ | ||
2753 | 991 | reg->impl->thread.getCancellable().get(), /* cancellable */ | ||
2764 | 992 | &error)); | 968 | &error)); |
2765 | 993 | 969 | ||
2766 | 994 | if (error != nullptr) | 970 | if (error != nullptr) |
2767 | @@ -1023,14 +999,6 @@ | |||
2768 | 1023 | 999 | ||
2769 | 1024 | pid_t SystemD::unitPrimaryPid(const AppID& appId, const std::string& job, const std::string& instance) | 1000 | pid_t SystemD::unitPrimaryPid(const AppID& appId, const std::string& job, const std::string& instance) |
2770 | 1025 | { | 1001 | { |
2771 | 1026 | auto registry = registry_.lock(); | ||
2772 | 1027 | |||
2773 | 1028 | if (!registry) | ||
2774 | 1029 | { | ||
2775 | 1030 | g_warning("Unable to get registry to determine primary PID"); | ||
2776 | 1031 | return 0; | ||
2777 | 1032 | } | ||
2778 | 1033 | |||
2779 | 1034 | auto unitinfo = SystemD::UnitInfo{appId, job, instance}; | 1002 | auto unitinfo = SystemD::UnitInfo{appId, job, instance}; |
2780 | 1035 | auto unitname = unitName(unitinfo); | 1003 | auto unitname = unitName(unitinfo); |
2781 | 1036 | auto unitpath = unitPath(unitinfo); | 1004 | auto unitpath = unitPath(unitinfo); |
2782 | @@ -1040,7 +1008,9 @@ | |||
2783 | 1040 | return 0; | 1008 | return 0; |
2784 | 1041 | } | 1009 | } |
2785 | 1042 | 1010 | ||
2787 | 1043 | return registry->impl->thread.executeOnThread<pid_t>([this, registry, unitname, unitpath]() { | 1011 | auto reg = getReg(); |
2788 | 1012 | |||
2789 | 1013 | return reg->thread.executeOnThread<pid_t>([this, unitname, unitpath, reg]() { | ||
2790 | 1044 | GError* error{nullptr}; | 1014 | GError* error{nullptr}; |
2791 | 1045 | auto call = unique_glib( | 1015 | auto call = unique_glib( |
2792 | 1046 | g_dbus_connection_call_sync(userbus_.get(), /* user bus */ | 1016 | g_dbus_connection_call_sync(userbus_.get(), /* user bus */ |
2793 | @@ -1052,7 +1022,7 @@ | |||
2794 | 1052 | G_VARIANT_TYPE("(v)"), /* ret type */ | 1022 | G_VARIANT_TYPE("(v)"), /* ret type */ |
2795 | 1053 | G_DBUS_CALL_FLAGS_NONE, /* flags */ | 1023 | G_DBUS_CALL_FLAGS_NONE, /* flags */ |
2796 | 1054 | -1, /* timeout */ | 1024 | -1, /* timeout */ |
2798 | 1055 | registry->impl->thread.getCancellable().get(), /* cancellable */ | 1025 | reg->thread.getCancellable().get(), /* cancellable */ |
2799 | 1056 | &error)); | 1026 | &error)); |
2800 | 1057 | 1027 | ||
2801 | 1058 | if (error != nullptr) | 1028 | if (error != nullptr) |
2802 | @@ -1080,14 +1050,6 @@ | |||
2803 | 1080 | 1050 | ||
2804 | 1081 | std::vector<pid_t> SystemD::unitPids(const AppID& appId, const std::string& job, const std::string& instance) | 1051 | std::vector<pid_t> SystemD::unitPids(const AppID& appId, const std::string& job, const std::string& instance) |
2805 | 1082 | { | 1052 | { |
2806 | 1083 | auto registry = registry_.lock(); | ||
2807 | 1084 | |||
2808 | 1085 | if (!registry) | ||
2809 | 1086 | { | ||
2810 | 1087 | g_warning("Unable to get registry to determine primary PID"); | ||
2811 | 1088 | return {}; | ||
2812 | 1089 | } | ||
2813 | 1090 | |||
2814 | 1091 | auto unitinfo = SystemD::UnitInfo{appId, job, instance}; | 1053 | auto unitinfo = SystemD::UnitInfo{appId, job, instance}; |
2815 | 1092 | auto unitname = unitName(unitinfo); | 1054 | auto unitname = unitName(unitinfo); |
2816 | 1093 | auto unitpath = unitPath(unitinfo); | 1055 | auto unitpath = unitPath(unitinfo); |
2817 | @@ -1097,7 +1059,9 @@ | |||
2818 | 1097 | return {}; | 1059 | return {}; |
2819 | 1098 | } | 1060 | } |
2820 | 1099 | 1061 | ||
2822 | 1100 | auto cgrouppath = registry->impl->thread.executeOnThread<std::string>([this, registry, unitname, unitpath]() { | 1062 | auto reg = getReg(); |
2823 | 1063 | |||
2824 | 1064 | auto cgrouppath = reg->thread.executeOnThread<std::string>([this, unitname, unitpath, reg]() { | ||
2825 | 1101 | GError* error{nullptr}; | 1065 | GError* error{nullptr}; |
2826 | 1102 | auto call = unique_glib( | 1066 | auto call = unique_glib( |
2827 | 1103 | g_dbus_connection_call_sync(userbus_.get(), /* user bus */ | 1067 | g_dbus_connection_call_sync(userbus_.get(), /* user bus */ |
2828 | @@ -1106,10 +1070,10 @@ | |||
2829 | 1106 | "org.freedesktop.DBus.Properties", /* interface */ | 1070 | "org.freedesktop.DBus.Properties", /* interface */ |
2830 | 1107 | "Get", /* method */ | 1071 | "Get", /* method */ |
2831 | 1108 | g_variant_new("(ss)", SYSTEMD_DBUS_IFACE_SERVICE, "ControlGroup"), /* params */ | 1072 | g_variant_new("(ss)", SYSTEMD_DBUS_IFACE_SERVICE, "ControlGroup"), /* params */ |
2836 | 1109 | G_VARIANT_TYPE("(v)"), /* ret type */ | 1073 | G_VARIANT_TYPE("(v)"), /* ret type */ |
2837 | 1110 | G_DBUS_CALL_FLAGS_NONE, /* flags */ | 1074 | G_DBUS_CALL_FLAGS_NONE, /* flags */ |
2838 | 1111 | -1, /* timeout */ | 1075 | -1, /* timeout */ |
2839 | 1112 | registry->impl->thread.getCancellable().get(), /* cancellable */ | 1076 | reg->thread.getCancellable().get(), /* cancellable */ |
2840 | 1113 | &error)); | 1077 | &error)); |
2841 | 1114 | 1078 | ||
2842 | 1115 | if (error != nullptr) | 1079 | if (error != nullptr) |
2843 | @@ -1182,10 +1146,10 @@ | |||
2844 | 1182 | 1146 | ||
2845 | 1183 | void SystemD::stopUnit(const AppID& appId, const std::string& job, const std::string& instance) | 1147 | void SystemD::stopUnit(const AppID& appId, const std::string& job, const std::string& instance) |
2846 | 1184 | { | 1148 | { |
2847 | 1185 | auto registry = registry_.lock(); | ||
2848 | 1186 | auto unitname = unitName(SystemD::UnitInfo{appId, job, instance}); | 1149 | auto unitname = unitName(SystemD::UnitInfo{appId, job, instance}); |
2849 | 1150 | auto reg = getReg(); | ||
2850 | 1187 | 1151 | ||
2852 | 1188 | registry->impl->thread.executeOnThread<bool>([this, registry, unitname] { | 1152 | reg->thread.executeOnThread<bool>([this, unitname, reg] { |
2853 | 1189 | GError* error{nullptr}; | 1153 | GError* error{nullptr}; |
2854 | 1190 | unique_glib(g_dbus_connection_call_sync( | 1154 | unique_glib(g_dbus_connection_call_sync( |
2855 | 1191 | userbus_.get(), /* user bus */ | 1155 | userbus_.get(), /* user bus */ |
2856 | @@ -1194,13 +1158,13 @@ | |||
2857 | 1194 | SYSTEMD_DBUS_IFACE_MANAGER, /* interface */ | 1158 | SYSTEMD_DBUS_IFACE_MANAGER, /* interface */ |
2858 | 1195 | "StopUnit", /* method */ | 1159 | "StopUnit", /* method */ |
2859 | 1196 | g_variant_new( | 1160 | g_variant_new( |
2867 | 1197 | "(ss)", /* params */ | 1161 | "(ss)", /* params */ |
2868 | 1198 | unitname.c_str(), /* param: specify unit */ | 1162 | unitname.c_str(), /* param: specify unit */ |
2869 | 1199 | "replace-irreversibly"), /* param: replace the current job but don't allow us to be replaced */ | 1163 | "replace-irreversibly"), /* param: replace the current job but don't allow us to be replaced */ |
2870 | 1200 | G_VARIANT_TYPE("(o)"), /* ret type */ | 1164 | G_VARIANT_TYPE("(o)"), /* ret type */ |
2871 | 1201 | G_DBUS_CALL_FLAGS_NONE, /* flags */ | 1165 | G_DBUS_CALL_FLAGS_NONE, /* flags */ |
2872 | 1202 | -1, /* timeout */ | 1166 | -1, /* timeout */ |
2873 | 1203 | registry->impl->thread.getCancellable().get(), /* cancellable */ | 1167 | reg->thread.getCancellable().get(), /* cancellable */ |
2874 | 1204 | &error)); | 1168 | &error)); |
2875 | 1205 | 1169 | ||
2876 | 1206 | if (error != nullptr) | 1170 | if (error != nullptr) |
2877 | @@ -1217,29 +1181,26 @@ | |||
2878 | 1217 | 1181 | ||
2879 | 1218 | core::Signal<const std::string&, const std::string&, const std::string&>& SystemD::jobStarted() | 1182 | core::Signal<const std::string&, const std::string&, const std::string&>& SystemD::jobStarted() |
2880 | 1219 | { | 1183 | { |
2883 | 1220 | /* For systemd we're automatically listening to the UnitNew signal | 1184 | /* Ensure we're connecting to the signals */ |
2882 | 1221 | and emitting on the object */ | ||
2884 | 1222 | return sig_jobStarted; | 1185 | return sig_jobStarted; |
2885 | 1223 | } | 1186 | } |
2886 | 1224 | 1187 | ||
2887 | 1225 | core::Signal<const std::string&, const std::string&, const std::string&>& SystemD::jobStopped() | 1188 | core::Signal<const std::string&, const std::string&, const std::string&>& SystemD::jobStopped() |
2888 | 1226 | { | 1189 | { |
2891 | 1227 | /* For systemd we're automatically listening to the UnitRemoved signal | 1190 | /* Ensure we're connecting to the signals */ |
2890 | 1228 | and emitting on the object */ | ||
2892 | 1229 | return sig_jobStopped; | 1191 | return sig_jobStopped; |
2893 | 1230 | } | 1192 | } |
2894 | 1231 | 1193 | ||
2895 | 1232 | struct FailedData | 1194 | struct FailedData |
2896 | 1233 | { | 1195 | { |
2898 | 1234 | std::weak_ptr<Registry> registry; | 1196 | std::weak_ptr<Registry::Impl> registry; |
2899 | 1235 | }; | 1197 | }; |
2900 | 1236 | 1198 | ||
2901 | 1237 | core::Signal<const std::string&, const std::string&, const std::string&, Registry::FailureType>& SystemD::jobFailed() | 1199 | core::Signal<const std::string&, const std::string&, const std::string&, Registry::FailureType>& SystemD::jobFailed() |
2902 | 1238 | { | 1200 | { |
2903 | 1239 | std::call_once(flag_appFailed, [this]() { | 1201 | std::call_once(flag_appFailed, [this]() { |
2907 | 1240 | auto reg = registry_.lock(); | 1202 | auto reg = getReg(); |
2908 | 1241 | 1203 | reg->thread.executeOnThread<bool>([this, reg]() { | |
2906 | 1242 | reg->impl->thread.executeOnThread<bool>([this, reg]() { | ||
2909 | 1243 | auto data = new FailedData{reg}; | 1204 | auto data = new FailedData{reg}; |
2910 | 1244 | 1205 | ||
2911 | 1245 | handle_appFailed = managedDBusSignalConnection( | 1206 | handle_appFailed = managedDBusSignalConnection( |
2912 | @@ -1258,11 +1219,10 @@ | |||
2913 | 1258 | 1219 | ||
2914 | 1259 | if (!reg) | 1220 | if (!reg) |
2915 | 1260 | { | 1221 | { |
2918 | 1261 | g_warning("Registry object invalid!"); | 1222 | throw std::runtime_error{"Lost our connection with the registry"}; |
2917 | 1262 | return; | ||
2919 | 1263 | } | 1223 | } |
2920 | 1264 | 1224 | ||
2922 | 1265 | auto manager = std::dynamic_pointer_cast<SystemD>(reg->impl->jobs); | 1225 | auto manager = std::dynamic_pointer_cast<SystemD>(reg->jobs()); |
2923 | 1266 | 1226 | ||
2924 | 1267 | /* Check to see if this is a path we care about */ | 1227 | /* Check to see if this is a path we care about */ |
2925 | 1268 | bool pathfound{false}; | 1228 | bool pathfound{false}; |
2926 | @@ -1334,19 +1294,19 @@ | |||
2927 | 1334 | failed so that we can continue to work with it. This includes | 1294 | failed so that we can continue to work with it. This includes |
2928 | 1335 | starting it anew, which can fail if it is left in the failed | 1295 | starting it anew, which can fail if it is left in the failed |
2929 | 1336 | state. */ | 1296 | state. */ |
2931 | 1337 | void SystemD::resetUnit(const UnitInfo& info) const | 1297 | void SystemD::resetUnit(const UnitInfo& info) |
2932 | 1338 | { | 1298 | { |
2933 | 1339 | if (noResetUnits_) | 1299 | if (noResetUnits_) |
2934 | 1340 | { | 1300 | { |
2935 | 1341 | return; | 1301 | return; |
2936 | 1342 | } | 1302 | } |
2937 | 1343 | 1303 | ||
2939 | 1344 | auto registry = registry_.lock(); | 1304 | auto reg = getReg(); |
2940 | 1345 | auto unitname = unitName(info); | 1305 | auto unitname = unitName(info); |
2941 | 1346 | auto bus = userbus_; | 1306 | auto bus = userbus_; |
2943 | 1347 | auto cancel = registry->impl->thread.getCancellable(); | 1307 | auto cancel = reg->thread.getCancellable(); |
2944 | 1348 | 1308 | ||
2946 | 1349 | registry->impl->thread.executeOnThread([bus, unitname, cancel] { | 1309 | reg->thread.executeOnThread([bus, unitname, cancel] { |
2947 | 1350 | if (g_cancellable_is_cancelled(cancel.get())) | 1310 | if (g_cancellable_is_cancelled(cancel.get())) |
2948 | 1351 | { | 1311 | { |
2949 | 1352 | return; | 1312 | return; |
2950 | 1353 | 1313 | ||
2951 | === modified file 'libubuntu-app-launch/jobs-systemd.h' | |||
2952 | --- libubuntu-app-launch/jobs-systemd.h 2017-03-20 10:13:50 +0000 | |||
2953 | +++ libubuntu-app-launch/jobs-systemd.h 2017-04-04 21:22:36 +0000 | |||
2954 | @@ -41,7 +41,7 @@ | |||
2955 | 41 | class SystemD : public Base | 41 | class SystemD : public Base |
2956 | 42 | { | 42 | { |
2957 | 43 | public: | 43 | public: |
2959 | 44 | SystemD(std::shared_ptr<Registry> registry); | 44 | SystemD(const std::shared_ptr<Registry::Impl>& registry); |
2960 | 45 | virtual ~SystemD(); | 45 | virtual ~SystemD(); |
2961 | 46 | 46 | ||
2962 | 47 | virtual std::shared_ptr<Application::Instance> launch( | 47 | virtual std::shared_ptr<Application::Instance> launch( |
2963 | @@ -73,7 +73,11 @@ | |||
2964 | 73 | 73 | ||
2965 | 74 | private: | 74 | private: |
2966 | 75 | std::string cgroup_root_; | 75 | std::string cgroup_root_; |
2967 | 76 | |||
2968 | 77 | /** Connection to the User DBus bus */ | ||
2969 | 76 | std::shared_ptr<GDBusConnection> userbus_; | 78 | std::shared_ptr<GDBusConnection> userbus_; |
2970 | 79 | /** Setup the bus and all the details in it */ | ||
2971 | 80 | void setupUserbus(const std::shared_ptr<Registry::Impl>& reg); | ||
2972 | 77 | 81 | ||
2973 | 78 | core::Signal<const std::string&, const std::string&, const std::string&> sig_jobStarted; | 82 | core::Signal<const std::string&, const std::string&, const std::string&> sig_jobStarted; |
2974 | 79 | core::Signal<const std::string&, const std::string&, const std::string&> sig_jobStopped; | 83 | core::Signal<const std::string&, const std::string&, const std::string&> sig_jobStopped; |
2975 | @@ -131,7 +135,7 @@ | |||
2976 | 131 | static std::vector<std::string> parseExec(std::list<std::pair<std::string, std::string>>& env); | 135 | static std::vector<std::string> parseExec(std::list<std::pair<std::string, std::string>>& env); |
2977 | 132 | static void application_start_cb(GObject* obj, GAsyncResult* res, gpointer user_data); | 136 | static void application_start_cb(GObject* obj, GAsyncResult* res, gpointer user_data); |
2978 | 133 | 137 | ||
2980 | 134 | void resetUnit(const UnitInfo& info) const; | 138 | void resetUnit(const UnitInfo& info); |
2981 | 135 | }; | 139 | }; |
2982 | 136 | 140 | ||
2983 | 137 | } // namespace manager | 141 | } // namespace manager |
2984 | 138 | 142 | ||
2985 | === modified file 'libubuntu-app-launch/registry-impl.cpp' | |||
2986 | --- libubuntu-app-launch/registry-impl.cpp 2017-03-20 12:28:10 +0000 | |||
2987 | +++ libubuntu-app-launch/registry-impl.cpp 2017-04-04 21:22:36 +0000 | |||
2988 | @@ -20,6 +20,7 @@ | |||
2989 | 20 | #include "registry-impl.h" | 20 | #include "registry-impl.h" |
2990 | 21 | #include "application-icon-finder.h" | 21 | #include "application-icon-finder.h" |
2991 | 22 | #include "application-impl-base.h" | 22 | #include "application-impl-base.h" |
2992 | 23 | #include "helper-impl.h" | ||
2993 | 23 | #include <regex> | 24 | #include <regex> |
2994 | 24 | #include <unity/util/GObjectMemory.h> | 25 | #include <unity/util/GObjectMemory.h> |
2995 | 25 | #include <unity/util/GlibMemory.h> | 26 | #include <unity/util/GlibMemory.h> |
2996 | @@ -31,24 +32,19 @@ | |||
2997 | 31 | namespace app_launch | 32 | namespace app_launch |
2998 | 32 | { | 33 | { |
2999 | 33 | 34 | ||
3006 | 34 | Registry::Impl::Impl(Registry& registry) | 35 | Registry::Impl::Impl() |
3001 | 35 | : Impl(registry, app_store::Base::allAppStores()) | ||
3002 | 36 | { | ||
3003 | 37 | } | ||
3004 | 38 | |||
3005 | 39 | Registry::Impl::Impl(Registry& registry, std::list<std::shared_ptr<app_store::Base>> appStores) | ||
3007 | 40 | : thread([]() {}, | 36 | : thread([]() {}, |
3008 | 41 | [this]() { | 37 | [this]() { |
3009 | 42 | zgLog_.reset(); | 38 | zgLog_.reset(); |
3011 | 43 | jobs.reset(); | 39 | jobs_.reset(); |
3012 | 44 | 40 | ||
3013 | 45 | if (_dbus) | 41 | if (_dbus) |
3014 | 46 | g_dbus_connection_flush_sync(_dbus.get(), nullptr, nullptr); | 42 | g_dbus_connection_flush_sync(_dbus.get(), nullptr, nullptr); |
3015 | 47 | _dbus.reset(); | 43 | _dbus.reset(); |
3016 | 48 | }) | 44 | }) |
3020 | 49 | , _registry{registry} | 45 | , jobs_{} |
3021 | 50 | , _iconFinders() | 46 | , _iconFinders{} |
3022 | 51 | , _appStores(appStores) | 47 | , _appStores{} |
3023 | 52 | { | 48 | { |
3024 | 53 | auto cancel = thread.getCancellable(); | 49 | auto cancel = thread.getCancellable(); |
3025 | 54 | _dbus = thread.executeOnThread<std::shared_ptr<GDBusConnection>>( | 50 | _dbus = thread.executeOnThread<std::shared_ptr<GDBusConnection>>( |
3026 | @@ -145,7 +141,7 @@ | |||
3027 | 145 | }); | 141 | }); |
3028 | 146 | } | 142 | } |
3029 | 147 | 143 | ||
3031 | 148 | std::shared_ptr<IconFinder> Registry::Impl::getIconFinder(std::string basePath) | 144 | std::shared_ptr<IconFinder>& Registry::Impl::getIconFinder(std::string basePath) |
3032 | 149 | { | 145 | { |
3033 | 150 | if (_iconFinders.find(basePath) == _iconFinders.end()) | 146 | if (_iconFinders.find(basePath) == _iconFinders.end()) |
3034 | 151 | { | 147 | { |
3035 | @@ -175,23 +171,45 @@ | |||
3036 | 175 | return watchingAppStarting_; | 171 | return watchingAppStarting_; |
3037 | 176 | } | 172 | } |
3038 | 177 | 173 | ||
3040 | 178 | core::Signal<const std::shared_ptr<Application>&>& Registry::Impl::appInfoUpdated(const std::shared_ptr<Registry>& reg) | 174 | core::Signal<const std::shared_ptr<Application>&>& Registry::Impl::appInfoUpdated() |
3041 | 179 | { | 175 | { |
3043 | 180 | std::call_once(flag_appInfoUpdated, [this, reg] { | 176 | std::call_once(flag_appInfoUpdated, [this] { |
3044 | 181 | g_debug("App Info Updated Signal Initialized"); | 177 | g_debug("App Info Updated Signal Initialized"); |
3045 | 182 | 178 | ||
3046 | 183 | std::list<std::shared_ptr<info_watcher::Base>> apps{_appStores.begin(), _appStores.end()}; | 179 | std::list<std::shared_ptr<info_watcher::Base>> apps{_appStores.begin(), _appStores.end()}; |
3048 | 184 | apps.push_back(Registry::Impl::getZgWatcher(reg)); | 180 | apps.push_back(getZgWatcher()); |
3049 | 185 | 181 | ||
3050 | 186 | for (const auto& app : apps) | 182 | for (const auto& app : apps) |
3051 | 187 | { | 183 | { |
3052 | 188 | infoWatchers_.emplace_back( | 184 | infoWatchers_.emplace_back( |
3055 | 189 | std::make_pair(app, app->infoChanged().connect( | 185 | std::make_pair(app, app->infoChanged().connect([this](const std::shared_ptr<Application>& app) { |
3056 | 190 | [this](const std::shared_ptr<Application>& app) { sig_appInfoUpdated(app); }))); | 186 | sig_appInfoUpdated(app); |
3057 | 187 | }))); | ||
3058 | 191 | } | 188 | } |
3059 | 192 | }); | 189 | }); |
3060 | 193 | return sig_appInfoUpdated; | 190 | return sig_appInfoUpdated; |
3061 | 194 | } | 191 | } |
3062 | 195 | 192 | ||
3063 | 193 | std::shared_ptr<Application> Registry::Impl::createApp(const AppID& appid) | ||
3064 | 194 | { | ||
3065 | 195 | for (const auto& appStore : appStores()) | ||
3066 | 196 | { | ||
3067 | 197 | if (appStore->hasAppId(appid)) | ||
3068 | 198 | { | ||
3069 | 199 | return appStore->create(appid); | ||
3070 | 200 | } | ||
3071 | 201 | } | ||
3072 | 202 | |||
3073 | 203 | throw std::runtime_error("Invalid app ID: " + std::string(appid)); | ||
3074 | 204 | } | ||
3075 | 205 | |||
3076 | 206 | std::shared_ptr<Helper> Registry::Impl::createHelper(const Helper::Type& type, | ||
3077 | 207 | const AppID& appid, | ||
3078 | 208 | const std::shared_ptr<Registry::Impl>& sharedimpl) | ||
3079 | 209 | { | ||
3080 | 210 | /* Only one type today */ | ||
3081 | 211 | return std::make_shared<helper_impls::Base>(type, appid, sharedimpl); | ||
3082 | 212 | } | ||
3083 | 213 | |||
3084 | 196 | } // namespace app_launch | 214 | } // namespace app_launch |
3085 | 197 | } // namespace ubuntu | 215 | } // namespace ubuntu |
3086 | 198 | 216 | ||
3087 | === modified file 'libubuntu-app-launch/registry-impl.h' | |||
3088 | --- libubuntu-app-launch/registry-impl.h 2017-03-20 10:13:50 +0000 | |||
3089 | +++ libubuntu-app-launch/registry-impl.h 2017-04-04 21:22:36 +0000 | |||
3090 | @@ -17,6 +17,8 @@ | |||
3091 | 17 | * Ted Gould <ted.gould@canonical.com> | 17 | * Ted Gould <ted.gould@canonical.com> |
3092 | 18 | */ | 18 | */ |
3093 | 19 | 19 | ||
3094 | 20 | #pragma once | ||
3095 | 21 | |||
3096 | 20 | #include "app-store-base.h" | 22 | #include "app-store-base.h" |
3097 | 21 | #include "glib-thread.h" | 23 | #include "glib-thread.h" |
3098 | 22 | #include "info-watcher-zg.h" | 24 | #include "info-watcher-zg.h" |
3099 | @@ -29,14 +31,16 @@ | |||
3100 | 29 | #include <unordered_map> | 31 | #include <unordered_map> |
3101 | 30 | #include <zeitgeist.h> | 32 | #include <zeitgeist.h> |
3102 | 31 | 33 | ||
3103 | 32 | #pragma once | ||
3104 | 33 | |||
3105 | 34 | namespace ubuntu | 34 | namespace ubuntu |
3106 | 35 | { | 35 | { |
3107 | 36 | namespace app_launch | 36 | namespace app_launch |
3108 | 37 | { | 37 | { |
3109 | 38 | 38 | ||
3110 | 39 | class IconFinder; | 39 | class IconFinder; |
3111 | 40 | namespace app_store | ||
3112 | 41 | { | ||
3113 | 42 | class Base; | ||
3114 | 43 | } | ||
3115 | 40 | 44 | ||
3116 | 41 | /** \private | 45 | /** \private |
3117 | 42 | \brief Private implementation of the Registry object | 46 | \brief Private implementation of the Registry object |
3118 | @@ -45,8 +49,7 @@ | |||
3119 | 45 | class Registry::Impl | 49 | class Registry::Impl |
3120 | 46 | { | 50 | { |
3121 | 47 | public: | 51 | public: |
3124 | 48 | Impl(Registry& registry); | 52 | Impl(); |
3123 | 49 | Impl(Registry& registry, std::list<std::shared_ptr<app_store::Base>> appStores); | ||
3125 | 50 | 53 | ||
3126 | 51 | virtual ~Impl() | 54 | virtual ~Impl() |
3127 | 52 | { | 55 | { |
3128 | @@ -66,9 +69,7 @@ | |||
3129 | 66 | /** Snapd information object */ | 69 | /** Snapd information object */ |
3130 | 67 | snapd::Info snapdInfo; | 70 | snapd::Info snapdInfo; |
3131 | 68 | 71 | ||
3135 | 69 | std::shared_ptr<jobs::manager::Base> jobs; | 72 | std::shared_ptr<IconFinder>& getIconFinder(std::string basePath); |
3133 | 70 | |||
3134 | 71 | std::shared_ptr<IconFinder> getIconFinder(std::string basePath); | ||
3136 | 72 | 73 | ||
3137 | 73 | virtual void zgSendEvent(AppID appid, const std::string& eventtype); | 74 | virtual void zgSendEvent(AppID appid, const std::string& eventtype); |
3138 | 74 | 75 | ||
3139 | @@ -86,27 +87,59 @@ | |||
3140 | 86 | return oomHelper_; | 87 | return oomHelper_; |
3141 | 87 | } | 88 | } |
3142 | 88 | 89 | ||
3153 | 89 | static std::shared_ptr<info_watcher::Zeitgeist> getZgWatcher(const std::shared_ptr<Registry>& reg) | 90 | std::shared_ptr<info_watcher::Zeitgeist> getZgWatcher() |
3154 | 90 | { | 91 | { |
3155 | 91 | std::call_once(reg->impl->zgWatcherOnce_, | 92 | return zgWatcher_; |
3156 | 92 | [reg] { reg->impl->zgWatcher_ = std::make_shared<info_watcher::Zeitgeist>(reg); }); | 93 | } |
3157 | 93 | return reg->impl->zgWatcher_; | 94 | |
3158 | 94 | } | 95 | void setZgWatcher(const std::shared_ptr<info_watcher::Zeitgeist>& watcher) |
3159 | 95 | 96 | { | |
3160 | 96 | core::Signal<const std::shared_ptr<Application>&>& appInfoUpdated(const std::shared_ptr<Registry>& reg); | 97 | zgWatcher_ = watcher; |
3161 | 97 | 98 | } | |
3162 | 98 | std::list<std::shared_ptr<app_store::Base>> appStores() | 99 | |
3163 | 100 | core::Signal<const std::shared_ptr<Application>&>& appInfoUpdated(); | ||
3164 | 101 | |||
3165 | 102 | const std::list<std::shared_ptr<app_store::Base>>& appStores() | ||
3166 | 99 | { | 103 | { |
3167 | 100 | return _appStores; | 104 | return _appStores; |
3168 | 101 | } | 105 | } |
3169 | 102 | 106 | ||
3171 | 103 | void setAppStores(std::list<std::shared_ptr<app_store::Base>>& newlist) | 107 | void setAppStores(const std::list<std::shared_ptr<app_store::Base>>& newlist) |
3172 | 104 | { | 108 | { |
3173 | 105 | _appStores = newlist; | 109 | _appStores = newlist; |
3174 | 106 | } | 110 | } |
3175 | 107 | 111 | ||
3176 | 112 | const std::shared_ptr<jobs::manager::Base>& jobs() | ||
3177 | 113 | { | ||
3178 | 114 | if (G_UNLIKELY(!jobs_)) | ||
3179 | 115 | { | ||
3180 | 116 | throw std::runtime_error{"Registry Implmentation has no Jobs object"}; | ||
3181 | 117 | } | ||
3182 | 118 | return jobs_; | ||
3183 | 119 | } | ||
3184 | 120 | |||
3185 | 121 | void setJobs(const std::shared_ptr<jobs::manager::Base>& jobs) | ||
3186 | 122 | { | ||
3187 | 123 | jobs_ = jobs; | ||
3188 | 124 | } | ||
3189 | 125 | |||
3190 | 126 | /* Create functions */ | ||
3191 | 127 | std::shared_ptr<Application> createApp(const AppID& appid); | ||
3192 | 128 | std::shared_ptr<Helper> createHelper(const Helper::Type& type, | ||
3193 | 129 | const AppID& appid, | ||
3194 | 130 | const std::shared_ptr<Registry::Impl>& sharedimpl); | ||
3195 | 131 | |||
3196 | 132 | /* AppID functions */ | ||
3197 | 133 | AppID find(const std::string& sappid); | ||
3198 | 134 | AppID discover(const std::string& package, const std::string& appname, const std::string& version); | ||
3199 | 135 | AppID discover(const std::string& package, | ||
3200 | 136 | AppID::ApplicationWildcard appwildcard, | ||
3201 | 137 | AppID::VersionWildcard versionwildcard); | ||
3202 | 138 | AppID discover(const std::string& package, const std::string& appname, AppID::VersionWildcard versionwildcard); | ||
3203 | 139 | |||
3204 | 108 | private: | 140 | private: |
3206 | 109 | Registry& _registry; /**< The Registry that we're spawned from */ | 141 | /** The job creation engine */ |
3207 | 142 | std::shared_ptr<jobs::manager::Base> jobs_; | ||
3208 | 110 | 143 | ||
3209 | 111 | /** Shared instance of the Zeitgeist Log */ | 144 | /** Shared instance of the Zeitgeist Log */ |
3210 | 112 | std::shared_ptr<ZeitgeistLog> zgLog_; | 145 | std::shared_ptr<ZeitgeistLog> zgLog_; |
3211 | @@ -128,11 +161,8 @@ | |||
3212 | 128 | /** List of info watchers along with a signal handle to our connection to their update signal */ | 161 | /** List of info watchers along with a signal handle to our connection to their update signal */ |
3213 | 129 | std::list<std::pair<std::shared_ptr<info_watcher::Base>, core::ScopedConnection>> infoWatchers_; | 162 | std::list<std::pair<std::shared_ptr<info_watcher::Base>, core::ScopedConnection>> infoWatchers_; |
3214 | 130 | 163 | ||
3215 | 131 | protected: | ||
3216 | 132 | /** ZG Info Watcher */ | 164 | /** ZG Info Watcher */ |
3217 | 133 | std::shared_ptr<info_watcher::Zeitgeist> zgWatcher_; | 165 | std::shared_ptr<info_watcher::Zeitgeist> zgWatcher_; |
3218 | 134 | /** Init checker for ZG Watcher */ | ||
3219 | 135 | std::once_flag zgWatcherOnce_; | ||
3220 | 136 | }; | 166 | }; |
3221 | 137 | 167 | ||
3222 | 138 | } // namespace app_launch | 168 | } // namespace app_launch |
3223 | 139 | 169 | ||
3224 | === modified file 'libubuntu-app-launch/registry.cpp' | |||
3225 | --- libubuntu-app-launch/registry.cpp 2017-03-20 10:13:50 +0000 | |||
3226 | +++ libubuntu-app-launch/registry.cpp 2017-04-04 21:22:36 +0000 | |||
3227 | @@ -21,6 +21,8 @@ | |||
3228 | 21 | #include <numeric> | 21 | #include <numeric> |
3229 | 22 | #include <regex> | 22 | #include <regex> |
3230 | 23 | 23 | ||
3231 | 24 | #include "info-watcher-zg.h" | ||
3232 | 25 | #include "jobs-base.h" | ||
3233 | 24 | #include "registry-impl.h" | 26 | #include "registry-impl.h" |
3234 | 25 | #include "registry.h" | 27 | #include "registry.h" |
3235 | 26 | 28 | ||
3236 | @@ -30,8 +32,17 @@ | |||
3237 | 30 | { | 32 | { |
3238 | 31 | 33 | ||
3239 | 32 | Registry::Registry() | 34 | Registry::Registry() |
3242 | 33 | { | 35 | : impl{std::make_shared<Impl>()} |
3243 | 34 | impl = std::unique_ptr<Impl>(new Impl(*this)); | 36 | { |
3244 | 37 | impl->setJobs(jobs::manager::Base::determineFactory(impl)); | ||
3245 | 38 | impl->setAppStores(app_store::Base::allAppStores(impl)); | ||
3246 | 39 | impl->setZgWatcher(std::make_shared<info_watcher::Zeitgeist>(impl)); | ||
3247 | 40 | } | ||
3248 | 41 | |||
3249 | 42 | Registry::Registry(const std::shared_ptr<Impl>& inimpl) | ||
3250 | 43 | : impl{inimpl} | ||
3251 | 44 | { | ||
3252 | 45 | /* We're assuming the impl has been setup */ | ||
3253 | 35 | } | 46 | } |
3254 | 36 | 47 | ||
3255 | 37 | Registry::~Registry() | 48 | Registry::~Registry() |
3256 | @@ -40,12 +51,7 @@ | |||
3257 | 40 | 51 | ||
3258 | 41 | std::list<std::shared_ptr<Application>> Registry::runningApps(std::shared_ptr<Registry> registry) | 52 | std::list<std::shared_ptr<Application>> Registry::runningApps(std::shared_ptr<Registry> registry) |
3259 | 42 | { | 53 | { |
3266 | 43 | if (!registry->impl->jobs) | 54 | return registry->impl->jobs()->runningApps(); |
3261 | 44 | { | ||
3262 | 45 | registry->impl->jobs = jobs::manager::Base::determineFactory(registry); | ||
3263 | 46 | } | ||
3264 | 47 | |||
3265 | 48 | return registry->impl->jobs->runningApps(); | ||
3267 | 49 | } | 55 | } |
3268 | 50 | 56 | ||
3269 | 51 | std::list<std::shared_ptr<Application>> Registry::installedApps(std::shared_ptr<Registry> connection) | 57 | std::list<std::shared_ptr<Application>> Registry::installedApps(std::shared_ptr<Registry> connection) |
3270 | @@ -54,7 +60,7 @@ | |||
3271 | 54 | 60 | ||
3272 | 55 | for (const auto& appStore : connection->impl->appStores()) | 61 | for (const auto& appStore : connection->impl->appStores()) |
3273 | 56 | { | 62 | { |
3275 | 57 | list.splice(list.begin(), appStore->list(connection)); | 63 | list.splice(list.begin(), appStore->list()); |
3276 | 58 | } | 64 | } |
3277 | 59 | 65 | ||
3278 | 60 | return list; | 66 | return list; |
3279 | @@ -62,37 +68,17 @@ | |||
3280 | 62 | 68 | ||
3281 | 63 | std::list<std::shared_ptr<Helper>> Registry::runningHelpers(Helper::Type type, std::shared_ptr<Registry> registry) | 69 | std::list<std::shared_ptr<Helper>> Registry::runningHelpers(Helper::Type type, std::shared_ptr<Registry> registry) |
3282 | 64 | { | 70 | { |
3298 | 65 | if (!registry->impl->jobs) | 71 | return registry->impl->jobs()->runningHelpers(type); |
3284 | 66 | { | ||
3285 | 67 | registry->impl->jobs = jobs::manager::Base::determineFactory(registry); | ||
3286 | 68 | } | ||
3287 | 69 | |||
3288 | 70 | return registry->impl->jobs->runningHelpers(type); | ||
3289 | 71 | } | ||
3290 | 72 | |||
3291 | 73 | /* Quick little helper to bundle up standard code */ | ||
3292 | 74 | inline void setJobs(const std::shared_ptr<Registry>& registry) | ||
3293 | 75 | { | ||
3294 | 76 | if (!registry->impl->jobs) | ||
3295 | 77 | { | ||
3296 | 78 | registry->impl->jobs = jobs::manager::Base::determineFactory(registry); | ||
3297 | 79 | } | ||
3299 | 80 | } | 72 | } |
3300 | 81 | 73 | ||
3301 | 82 | void Registry::setManager(const std::shared_ptr<Manager>& manager, const std::shared_ptr<Registry>& registry) | 74 | void Registry::setManager(const std::shared_ptr<Manager>& manager, const std::shared_ptr<Registry>& registry) |
3302 | 83 | { | 75 | { |
3305 | 84 | setJobs(registry); | 76 | registry->impl->jobs()->setManager(manager); |
3304 | 85 | registry->impl->jobs->setManager(manager); | ||
3306 | 86 | } | 77 | } |
3307 | 87 | 78 | ||
3308 | 88 | void Registry::clearManager() | 79 | void Registry::clearManager() |
3309 | 89 | { | 80 | { |
3316 | 90 | if (!impl->jobs) | 81 | impl->jobs()->clearManager(); |
3311 | 91 | { | ||
3312 | 92 | return; | ||
3313 | 93 | } | ||
3314 | 94 | |||
3315 | 95 | impl->jobs->clearManager(); | ||
3317 | 96 | } | 82 | } |
3318 | 97 | 83 | ||
3319 | 98 | std::shared_ptr<Registry> defaultRegistry; | 84 | std::shared_ptr<Registry> defaultRegistry; |
3320 | @@ -114,22 +100,19 @@ | |||
3321 | 114 | core::Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&>& Registry::appStarted( | 100 | core::Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&>& Registry::appStarted( |
3322 | 115 | const std::shared_ptr<Registry>& reg) | 101 | const std::shared_ptr<Registry>& reg) |
3323 | 116 | { | 102 | { |
3326 | 117 | setJobs(reg); | 103 | return reg->impl->jobs()->appStarted(); |
3325 | 118 | return reg->impl->jobs->appStarted(); | ||
3327 | 119 | } | 104 | } |
3328 | 120 | 105 | ||
3329 | 121 | core::Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&>& Registry::appStopped( | 106 | core::Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&>& Registry::appStopped( |
3330 | 122 | const std::shared_ptr<Registry>& reg) | 107 | const std::shared_ptr<Registry>& reg) |
3331 | 123 | { | 108 | { |
3334 | 124 | setJobs(reg); | 109 | return reg->impl->jobs()->appStopped(); |
3333 | 125 | return reg->impl->jobs->appStopped(); | ||
3335 | 126 | } | 110 | } |
3336 | 127 | 111 | ||
3337 | 128 | core::Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&, Registry::FailureType>& | 112 | core::Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&, Registry::FailureType>& |
3338 | 129 | Registry::appFailed(const std::shared_ptr<Registry>& reg) | 113 | Registry::appFailed(const std::shared_ptr<Registry>& reg) |
3339 | 130 | { | 114 | { |
3342 | 131 | setJobs(reg); | 115 | return reg->impl->jobs()->appFailed(); |
3341 | 132 | return reg->impl->jobs->appFailed(); | ||
3343 | 133 | } | 116 | } |
3344 | 134 | 117 | ||
3345 | 135 | core::Signal<const std::shared_ptr<Application>&, | 118 | core::Signal<const std::shared_ptr<Application>&, |
3346 | @@ -137,8 +120,7 @@ | |||
3347 | 137 | const std::vector<pid_t>&>& | 120 | const std::vector<pid_t>&>& |
3348 | 138 | Registry::appPaused(const std::shared_ptr<Registry>& reg) | 121 | Registry::appPaused(const std::shared_ptr<Registry>& reg) |
3349 | 139 | { | 122 | { |
3352 | 140 | setJobs(reg); | 123 | return reg->impl->jobs()->appPaused(); |
3351 | 141 | return reg->impl->jobs->appPaused(); | ||
3353 | 142 | } | 124 | } |
3354 | 143 | 125 | ||
3355 | 144 | core::Signal<const std::shared_ptr<Application>&, | 126 | core::Signal<const std::shared_ptr<Application>&, |
3356 | @@ -146,34 +128,30 @@ | |||
3357 | 146 | const std::vector<pid_t>&>& | 128 | const std::vector<pid_t>&>& |
3358 | 147 | Registry::appResumed(const std::shared_ptr<Registry>& reg) | 129 | Registry::appResumed(const std::shared_ptr<Registry>& reg) |
3359 | 148 | { | 130 | { |
3362 | 149 | setJobs(reg); | 131 | return reg->impl->jobs()->appResumed(); |
3361 | 150 | return reg->impl->jobs->appResumed(); | ||
3363 | 151 | } | 132 | } |
3364 | 152 | 133 | ||
3365 | 153 | core::Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&>& Registry::helperStarted( | 134 | core::Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&>& Registry::helperStarted( |
3366 | 154 | Helper::Type type, const std::shared_ptr<Registry>& reg) | 135 | Helper::Type type, const std::shared_ptr<Registry>& reg) |
3367 | 155 | { | 136 | { |
3370 | 156 | setJobs(reg); | 137 | return reg->impl->jobs()->helperStarted(type); |
3369 | 157 | return reg->impl->jobs->helperStarted(type); | ||
3371 | 158 | } | 138 | } |
3372 | 159 | 139 | ||
3373 | 160 | core::Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&>& Registry::helperStopped( | 140 | core::Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&>& Registry::helperStopped( |
3374 | 161 | Helper::Type type, const std::shared_ptr<Registry>& reg) | 141 | Helper::Type type, const std::shared_ptr<Registry>& reg) |
3375 | 162 | { | 142 | { |
3378 | 163 | setJobs(reg); | 143 | return reg->impl->jobs()->helperStopped(type); |
3377 | 164 | return reg->impl->jobs->helperStopped(type); | ||
3379 | 165 | } | 144 | } |
3380 | 166 | 145 | ||
3381 | 167 | core::Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&, Registry::FailureType>& | 146 | core::Signal<const std::shared_ptr<Helper>&, const std::shared_ptr<Helper::Instance>&, Registry::FailureType>& |
3382 | 168 | Registry::helperFailed(Helper::Type type, const std::shared_ptr<Registry>& reg) | 147 | Registry::helperFailed(Helper::Type type, const std::shared_ptr<Registry>& reg) |
3383 | 169 | { | 148 | { |
3386 | 170 | setJobs(reg); | 149 | return reg->impl->jobs()->helperFailed(type); |
3385 | 171 | return reg->impl->jobs->helperFailed(type); | ||
3387 | 172 | } | 150 | } |
3388 | 173 | 151 | ||
3389 | 174 | core::Signal<const std::shared_ptr<Application>&>& Registry::appInfoUpdated(const std::shared_ptr<Registry>& reg) | 152 | core::Signal<const std::shared_ptr<Application>&>& Registry::appInfoUpdated(const std::shared_ptr<Registry>& reg) |
3390 | 175 | { | 153 | { |
3392 | 176 | return reg->impl->appInfoUpdated(reg); | 154 | return reg->impl->appInfoUpdated(); |
3393 | 177 | } | 155 | } |
3394 | 178 | 156 | ||
3395 | 179 | } // namespace app_launch | 157 | } // namespace app_launch |
3396 | 180 | 158 | ||
3397 | === modified file 'libubuntu-app-launch/registry.h' | |||
3398 | --- libubuntu-app-launch/registry.h 2017-03-20 12:28:10 +0000 | |||
3399 | +++ libubuntu-app-launch/registry.h 2017-04-04 21:22:36 +0000 | |||
3400 | @@ -99,9 +99,8 @@ | |||
3401 | 99 | 99 | ||
3402 | 100 | \param reg Registry to get the handler from | 100 | \param reg Registry to get the handler from |
3403 | 101 | */ | 101 | */ |
3407 | 102 | static core::Signal<const std::shared_ptr<Application>&, | 102 | static core:: |
3408 | 103 | const std::shared_ptr<Application::Instance>&, | 103 | Signal<const std::shared_ptr<Application>&, const std::shared_ptr<Application::Instance>&, FailureType>& |
3406 | 104 | FailureType>& | ||
3409 | 105 | appFailed(const std::shared_ptr<Registry>& reg = getDefault()); | 104 | appFailed(const std::shared_ptr<Registry>& reg = getDefault()); |
3410 | 106 | 105 | ||
3411 | 107 | /** Get the signal object that is signaled when an application has been | 106 | /** Get the signal object that is signaled when an application has been |
3412 | @@ -269,7 +268,10 @@ | |||
3413 | 269 | /** \private */ | 268 | /** \private */ |
3414 | 270 | class Impl; | 269 | class Impl; |
3415 | 271 | /** \private */ | 270 | /** \private */ |
3417 | 272 | std::unique_ptr<Impl> impl; | 271 | std::shared_ptr<Impl> impl; |
3418 | 272 | |||
3419 | 273 | protected: | ||
3420 | 274 | Registry(const std::shared_ptr<Impl>& inimpl); | ||
3421 | 273 | }; | 275 | }; |
3422 | 274 | 276 | ||
3423 | 275 | } // namespace app_launch | 277 | } // namespace app_launch |
3424 | 276 | 278 | ||
3425 | === modified file 'tests/application-info-desktop.cpp' | |||
3426 | --- tests/application-info-desktop.cpp 2017-03-14 02:58:43 +0000 | |||
3427 | +++ tests/application-info-desktop.cpp 2017-04-04 21:22:36 +0000 | |||
3428 | @@ -88,7 +88,7 @@ | |||
3429 | 88 | { | 88 | { |
3430 | 89 | auto reg = registry(); | 89 | auto reg = registry(); |
3431 | 90 | 90 | ||
3433 | 91 | return std::dynamic_pointer_cast<zgWatcherMock>(reg->impl->getZgWatcher(reg)); | 91 | return std::dynamic_pointer_cast<zgWatcherMock>(reg->impl->getZgWatcher()); |
3434 | 92 | } | 92 | } |
3435 | 93 | }; | 93 | }; |
3436 | 94 | 94 | ||
3437 | @@ -410,7 +410,7 @@ | |||
3438 | 410 | auto keyfile = defaultKeyfile(); | 410 | auto keyfile = defaultKeyfile(); |
3439 | 411 | EXPECT_EQ(5u, | 411 | EXPECT_EQ(5u, |
3440 | 412 | ubuntu::app_launch::app_info::Desktop(simpleAppID(), keyfile, "/", {}, | 412 | ubuntu::app_launch::app_info::Desktop(simpleAppID(), keyfile, "/", {}, |
3442 | 413 | ubuntu::app_launch::app_info::DesktopFlags::NONE, registry()) | 413 | ubuntu::app_launch::app_info::DesktopFlags::NONE, registry()->impl) |
3443 | 414 | .popularity() | 414 | .popularity() |
3444 | 415 | .value()); | 415 | .value()); |
3445 | 416 | } | 416 | } |
3446 | 417 | 417 | ||
3447 | === modified file 'tests/info-watcher-zg.cpp' | |||
3448 | --- tests/info-watcher-zg.cpp 2017-02-10 16:50:40 +0000 | |||
3449 | +++ tests/info-watcher-zg.cpp 2017-04-04 21:22:36 +0000 | |||
3450 | @@ -49,7 +49,6 @@ | |||
3451 | 49 | 49 | ||
3452 | 50 | TEST_F(InfoWatcherZg, InitTest) | 50 | TEST_F(InfoWatcherZg, InitTest) |
3453 | 51 | { | 51 | { |
3457 | 52 | auto watcher = std::make_shared<ubuntu::app_launch::info_watcher::Zeitgeist>(registry); | 52 | /* Gets init by part of the mock now, we may need to split |
3458 | 53 | 53 | * that out when we want to test this more. */ | |
3456 | 54 | watcher.reset(); | ||
3459 | 55 | } | 54 | } |
3460 | 56 | 55 | ||
3461 | === modified file 'tests/jobs-base-test.cpp' | |||
3462 | --- tests/jobs-base-test.cpp 2017-01-19 18:39:44 +0000 | |||
3463 | +++ tests/jobs-base-test.cpp 2017-04-04 21:22:36 +0000 | |||
3464 | @@ -34,7 +34,7 @@ | |||
3465 | 34 | const std::string& job, | 34 | const std::string& job, |
3466 | 35 | const std::string& instance, | 35 | const std::string& instance, |
3467 | 36 | const std::vector<ubuntu::app_launch::Application::URL>& urls, | 36 | const std::vector<ubuntu::app_launch::Application::URL>& urls, |
3469 | 37 | const std::shared_ptr<ubuntu::app_launch::Registry>& registry) | 37 | const std::shared_ptr<ubuntu::app_launch::Registry::Impl>& registry) |
3470 | 38 | : ubuntu::app_launch::jobs::instance::Base(appId, job, instance, urls, registry) | 38 | : ubuntu::app_launch::jobs::instance::Base(appId, job, instance, urls, registry) |
3471 | 39 | { | 39 | { |
3472 | 40 | } | 40 | } |
3473 | @@ -76,7 +76,7 @@ | |||
3474 | 76 | std::shared_ptr<instanceMock> simpleInstance() | 76 | std::shared_ptr<instanceMock> simpleInstance() |
3475 | 77 | { | 77 | { |
3476 | 78 | return std::make_shared<instanceMock>(simpleAppID(), "application-job", "1234567890", | 78 | return std::make_shared<instanceMock>(simpleAppID(), "application-job", "1234567890", |
3478 | 79 | std::vector<ubuntu::app_launch::Application::URL>{}, registry); | 79 | std::vector<ubuntu::app_launch::Application::URL>{}, registry->impl); |
3479 | 80 | } | 80 | } |
3480 | 81 | }; | 81 | }; |
3481 | 82 | 82 | ||
3482 | 83 | 83 | ||
3483 | === modified file 'tests/jobs-systemd.cpp' | |||
3484 | --- tests/jobs-systemd.cpp 2017-02-04 03:53:34 +0000 | |||
3485 | +++ tests/jobs-systemd.cpp 2017-04-04 21:22:36 +0000 | |||
3486 | @@ -18,6 +18,7 @@ | |||
3487 | 18 | */ | 18 | */ |
3488 | 19 | 19 | ||
3489 | 20 | #include "jobs-systemd.h" | 20 | #include "jobs-systemd.h" |
3490 | 21 | #include "app-store-legacy.h" | ||
3491 | 21 | 22 | ||
3492 | 22 | #include "eventually-fixture.h" | 23 | #include "eventually-fixture.h" |
3493 | 23 | #include "registry-mock.h" | 24 | #include "registry-mock.h" |
3494 | @@ -57,6 +58,7 @@ | |||
3495 | 57 | 58 | ||
3496 | 58 | dbus_test_service_start_tasks(service.get()); | 59 | dbus_test_service_start_tasks(service.get()); |
3497 | 59 | registry = std::make_shared<RegistryMock>(); | 60 | registry = std::make_shared<RegistryMock>(); |
3498 | 61 | registry->impl->setAppStores({std::make_shared<ubuntu::app_launch::app_store::Legacy>(registry->impl)}); | ||
3499 | 60 | 62 | ||
3500 | 61 | bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr); | 63 | bus = g_bus_get_sync(G_BUS_TYPE_SESSION, nullptr, nullptr); |
3501 | 62 | g_dbus_connection_set_exit_on_close(bus, FALSE); | 64 | g_dbus_connection_set_exit_on_close(bus, FALSE); |
3502 | @@ -96,13 +98,15 @@ | |||
3503 | 96 | /* Make sure we can build an object and destroy it */ | 98 | /* Make sure we can build an object and destroy it */ |
3504 | 97 | TEST_F(JobsSystemd, Init) | 99 | TEST_F(JobsSystemd, Init) |
3505 | 98 | { | 100 | { |
3507 | 99 | registry->impl->jobs = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 101 | registry->impl->setJobs(std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl)); |
3508 | 100 | } | 102 | } |
3509 | 101 | 103 | ||
3510 | 102 | /* Make sure we make the initial call to get signals and an initial list */ | 104 | /* Make sure we make the initial call to get signals and an initial list */ |
3511 | 103 | TEST_F(JobsSystemd, Startup) | 105 | TEST_F(JobsSystemd, Startup) |
3512 | 104 | { | 106 | { |
3514 | 105 | registry->impl->jobs = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 107 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3515 | 108 | registry->impl->setJobs(manager); | ||
3516 | 109 | manager->runningApps(); | ||
3517 | 106 | 110 | ||
3518 | 107 | EXPECT_EVENTUALLY_FUNC_EQ(true, std::function<bool()>([this]() { return systemd->subscribeCallsCnt() > 0; })); | 111 | EXPECT_EVENTUALLY_FUNC_EQ(true, std::function<bool()>([this]() { return systemd->subscribeCallsCnt() > 0; })); |
3519 | 108 | EXPECT_EVENTUALLY_FUNC_EQ(true, std::function<bool()>([this]() -> bool { return systemd->listCallsCnt() > 0; })); | 112 | EXPECT_EVENTUALLY_FUNC_EQ(true, std::function<bool()>([this]() -> bool { return systemd->listCallsCnt() > 0; })); |
3520 | @@ -117,8 +121,8 @@ | |||
3521 | 117 | /* Get the running apps and check out their instances */ | 121 | /* Get the running apps and check out their instances */ |
3522 | 118 | TEST_F(JobsSystemd, RunningApps) | 122 | TEST_F(JobsSystemd, RunningApps) |
3523 | 119 | { | 123 | { |
3526 | 120 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 124 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3527 | 121 | registry->impl->jobs = manager; | 125 | registry->impl->setJobs(manager); |
3528 | 122 | 126 | ||
3529 | 123 | auto apps = manager->runningApps(); | 127 | auto apps = manager->runningApps(); |
3530 | 124 | ASSERT_FALSE(apps.empty()); | 128 | ASSERT_FALSE(apps.empty()); |
3531 | @@ -144,8 +148,8 @@ | |||
3532 | 144 | /* Check to make sure we're getting the user bus path correctly */ | 148 | /* Check to make sure we're getting the user bus path correctly */ |
3533 | 145 | TEST_F(JobsSystemd, UserBusPath) | 149 | TEST_F(JobsSystemd, UserBusPath) |
3534 | 146 | { | 150 | { |
3537 | 147 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 151 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3538 | 148 | registry->impl->jobs = manager; | 152 | registry->impl->setJobs(manager); |
3539 | 149 | 153 | ||
3540 | 150 | EXPECT_EQ(std::string{"/this/should/not/exist"}, manager->userBusPath()); | 154 | EXPECT_EQ(std::string{"/this/should/not/exist"}, manager->userBusPath()); |
3541 | 151 | 155 | ||
3542 | @@ -156,8 +160,8 @@ | |||
3543 | 156 | /* PID Tools */ | 160 | /* PID Tools */ |
3544 | 157 | TEST_F(JobsSystemd, PidTools) | 161 | TEST_F(JobsSystemd, PidTools) |
3545 | 158 | { | 162 | { |
3548 | 159 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 163 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3549 | 160 | registry->impl->jobs = manager; | 164 | registry->impl->setJobs(manager); |
3550 | 161 | 165 | ||
3551 | 162 | EXPECT_EQ(5, manager->unitPrimaryPid(singleAppID(), defaultJobName(), {})); | 166 | EXPECT_EQ(5, manager->unitPrimaryPid(singleAppID(), defaultJobName(), {})); |
3552 | 163 | std::vector<pid_t> pidlist{1, 2, 3, 4, 5}; | 167 | std::vector<pid_t> pidlist{1, 2, 3, 4, 5}; |
3553 | @@ -167,8 +171,8 @@ | |||
3554 | 167 | /* PID Instance */ | 171 | /* PID Instance */ |
3555 | 168 | TEST_F(JobsSystemd, PidInstance) | 172 | TEST_F(JobsSystemd, PidInstance) |
3556 | 169 | { | 173 | { |
3559 | 170 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 174 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3560 | 171 | registry->impl->jobs = manager; | 175 | registry->impl->setJobs(manager); |
3561 | 172 | 176 | ||
3562 | 173 | auto inst = manager->existing(singleAppID(), defaultJobName(), {}, {}); | 177 | auto inst = manager->existing(singleAppID(), defaultJobName(), {}, {}); |
3563 | 174 | EXPECT_TRUE(bool(inst)); | 178 | EXPECT_TRUE(bool(inst)); |
3564 | @@ -181,8 +185,8 @@ | |||
3565 | 181 | /* Stopping a Job */ | 185 | /* Stopping a Job */ |
3566 | 182 | TEST_F(JobsSystemd, StopUnit) | 186 | TEST_F(JobsSystemd, StopUnit) |
3567 | 183 | { | 187 | { |
3570 | 184 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 188 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3571 | 185 | registry->impl->jobs = manager; | 189 | registry->impl->setJobs(manager); |
3572 | 186 | 190 | ||
3573 | 187 | manager->stopUnit(singleAppID(), defaultJobName(), {}); | 191 | manager->stopUnit(singleAppID(), defaultJobName(), {}); |
3574 | 188 | 192 | ||
3575 | @@ -211,8 +215,8 @@ | |||
3576 | 211 | /* Stop Instance */ | 215 | /* Stop Instance */ |
3577 | 212 | TEST_F(JobsSystemd, StopInstance) | 216 | TEST_F(JobsSystemd, StopInstance) |
3578 | 213 | { | 217 | { |
3581 | 214 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 218 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3582 | 215 | registry->impl->jobs = manager; | 219 | registry->impl->setJobs(manager); |
3583 | 216 | 220 | ||
3584 | 217 | auto inst = manager->existing(singleAppID(), defaultJobName(), {}, {}); | 221 | auto inst = manager->existing(singleAppID(), defaultJobName(), {}, {}); |
3585 | 218 | EXPECT_TRUE(bool(inst)); | 222 | EXPECT_TRUE(bool(inst)); |
3586 | @@ -231,8 +235,8 @@ | |||
3587 | 231 | /* Starting a new job */ | 235 | /* Starting a new job */ |
3588 | 232 | TEST_F(JobsSystemd, LaunchJob) | 236 | TEST_F(JobsSystemd, LaunchJob) |
3589 | 233 | { | 237 | { |
3592 | 234 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 238 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3593 | 235 | registry->impl->jobs = manager; | 239 | registry->impl->setJobs(manager); |
3594 | 236 | 240 | ||
3595 | 237 | bool gotenv{false}; | 241 | bool gotenv{false}; |
3596 | 238 | std::function<std::list<std::pair<std::string, std::string>>()> getenvfunc = | 242 | std::function<std::list<std::pair<std::string, std::string>>()> getenvfunc = |
3597 | @@ -291,8 +295,8 @@ | |||
3598 | 291 | 295 | ||
3599 | 292 | TEST_F(JobsSystemd, SignalNew) | 296 | TEST_F(JobsSystemd, SignalNew) |
3600 | 293 | { | 297 | { |
3603 | 294 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 298 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3604 | 295 | registry->impl->jobs = manager; | 299 | registry->impl->setJobs(manager); |
3605 | 296 | 300 | ||
3606 | 297 | std::promise<ubuntu::app_launch::AppID> newunit; | 301 | std::promise<ubuntu::app_launch::AppID> newunit; |
3607 | 298 | manager->appStarted().connect([&](const std::shared_ptr<ubuntu::app_launch::Application> &app, | 302 | manager->appStarted().connect([&](const std::shared_ptr<ubuntu::app_launch::Application> &app, |
3608 | @@ -327,8 +331,8 @@ | |||
3609 | 327 | 331 | ||
3610 | 328 | TEST_F(JobsSystemd, SignalRemove) | 332 | TEST_F(JobsSystemd, SignalRemove) |
3611 | 329 | { | 333 | { |
3614 | 330 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 334 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3615 | 331 | registry->impl->jobs = manager; | 335 | registry->impl->setJobs(manager); |
3616 | 332 | 336 | ||
3617 | 333 | std::promise<ubuntu::app_launch::AppID> removeunit; | 337 | std::promise<ubuntu::app_launch::AppID> removeunit; |
3618 | 334 | manager->appStopped().connect([&](const std::shared_ptr<ubuntu::app_launch::Application> &app, | 338 | manager->appStopped().connect([&](const std::shared_ptr<ubuntu::app_launch::Application> &app, |
3619 | @@ -363,8 +367,8 @@ | |||
3620 | 363 | 367 | ||
3621 | 364 | TEST_F(JobsSystemd, UnitFailure) | 368 | TEST_F(JobsSystemd, UnitFailure) |
3622 | 365 | { | 369 | { |
3625 | 366 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry); | 370 | auto manager = std::make_shared<ubuntu::app_launch::jobs::manager::SystemD>(registry->impl); |
3626 | 367 | registry->impl->jobs = manager; | 371 | registry->impl->setJobs(manager); |
3627 | 368 | 372 | ||
3628 | 369 | ubuntu::app_launch::AppID failedappid; | 373 | ubuntu::app_launch::AppID failedappid; |
3629 | 370 | manager->appFailed().connect([&](const std::shared_ptr<ubuntu::app_launch::Application> &app, | 374 | manager->appFailed().connect([&](const std::shared_ptr<ubuntu::app_launch::Application> &app, |
3630 | 371 | 375 | ||
3631 | === modified file 'tests/libual-cpp-test.cc' | |||
3632 | --- tests/libual-cpp-test.cc 2017-03-20 15:17:02 +0000 | |||
3633 | +++ tests/libual-cpp-test.cc 2017-04-04 21:22:36 +0000 | |||
3634 | @@ -258,16 +258,16 @@ | |||
3635 | 258 | { | 258 | { |
3636 | 259 | auto store = storeForHelper(appid); | 259 | auto store = storeForHelper(appid); |
3637 | 260 | 260 | ||
3639 | 261 | ON_CALL(*store, list(testing::_)) | 261 | ON_CALL(*store, list()) |
3640 | 262 | .WillByDefault(testing::Return(std::list<std::shared_ptr<ubuntu::app_launch::Application>>{})); | 262 | .WillByDefault(testing::Return(std::list<std::shared_ptr<ubuntu::app_launch::Application>>{})); |
3641 | 263 | 263 | ||
3644 | 264 | auto app = std::make_shared<MockApp>(appid, registry); | 264 | auto app = std::make_shared<MockApp>(appid, registry->impl); |
3645 | 265 | ON_CALL(*store, create(appid, testing::_)).WillByDefault(testing::Return(app)); | 265 | ON_CALL(*store, create(appid)).WillByDefault(testing::Return(app)); |
3646 | 266 | 266 | ||
3647 | 267 | if (!instanceid.empty()) | 267 | if (!instanceid.empty()) |
3648 | 268 | { | 268 | { |
3649 | 269 | std::vector<ubuntu::app_launch::Application::URL> urls; | 269 | std::vector<ubuntu::app_launch::Application::URL> urls; |
3651 | 270 | auto inst = std::make_shared<MockInst>(appid, jobtype, instanceid, urls, registry); | 270 | auto inst = std::make_shared<MockInst>(appid, jobtype, instanceid, urls, registry->impl); |
3652 | 271 | ON_CALL(*app, findInstance(instanceid)).WillByDefault(testing::Return(inst)); | 271 | ON_CALL(*app, findInstance(instanceid)).WillByDefault(testing::Return(inst)); |
3653 | 272 | ON_CALL(*app, launch(testing::_)).WillByDefault(testing::Return(inst)); | 272 | ON_CALL(*app, launch(testing::_)).WillByDefault(testing::Return(inst)); |
3654 | 273 | ON_CALL(*app, launchTest(testing::_)).WillByDefault(testing::Return(inst)); | 273 | ON_CALL(*app, launchTest(testing::_)).WillByDefault(testing::Return(inst)); |
3655 | @@ -286,15 +286,13 @@ | |||
3656 | 286 | std::shared_ptr<MockStore> storeForHelper(const ubuntu::app_launch::AppID& appid) | 286 | std::shared_ptr<MockStore> storeForHelper(const ubuntu::app_launch::AppID& appid) |
3657 | 287 | { | 287 | { |
3658 | 288 | /* Setup a store for looking up the AppID */ | 288 | /* Setup a store for looking up the AppID */ |
3660 | 289 | auto store = std::make_shared<MockStore>(); | 289 | auto store = std::make_shared<MockStore>(registry->impl); |
3661 | 290 | 290 | ||
3669 | 291 | ON_CALL(*store, verifyPackage(appid.package, testing::_)).WillByDefault(testing::Return(true)); | 291 | ON_CALL(*store, verifyPackage(appid.package)).WillByDefault(testing::Return(true)); |
3670 | 292 | ON_CALL(*store, verifyAppname(appid.package, appid.appname, testing::_)).WillByDefault(testing::Return(true)); | 292 | ON_CALL(*store, verifyAppname(appid.package, appid.appname)).WillByDefault(testing::Return(true)); |
3671 | 293 | ON_CALL(*store, findAppname(appid.package, testing::_, testing::_)) | 293 | ON_CALL(*store, findAppname(appid.package, testing::_)).WillByDefault(testing::Return(appid.appname)); |
3672 | 294 | .WillByDefault(testing::Return(appid.appname)); | 294 | ON_CALL(*store, findVersion(appid.package, appid.appname)).WillByDefault(testing::Return(appid.version)); |
3673 | 295 | ON_CALL(*store, findVersion(appid.package, appid.appname, testing::_)) | 295 | ON_CALL(*store, hasAppId(appid)).WillByDefault(testing::Return(true)); |
3667 | 296 | .WillByDefault(testing::Return(appid.version)); | ||
3668 | 297 | ON_CALL(*store, hasAppId(appid, testing::_)).WillByDefault(testing::Return(true)); | ||
3674 | 298 | 296 | ||
3675 | 299 | std::list<std::shared_ptr<ubuntu::app_launch::app_store::Base>> list; | 297 | std::list<std::shared_ptr<ubuntu::app_launch::app_store::Base>> list; |
3676 | 300 | list.push_back(store); | 298 | list.push_back(store); |
3677 | @@ -435,46 +433,46 @@ | |||
3678 | 435 | 433 | ||
3679 | 436 | TEST_F(LibUAL, ApplicationId) | 434 | TEST_F(LibUAL, ApplicationId) |
3680 | 437 | { | 435 | { |
3682 | 438 | auto mockstore = std::make_shared<MockStore>(); | 436 | auto mockstore = std::make_shared<MockStore>(registry->impl); |
3683 | 439 | registry = | 437 | registry = |
3685 | 440 | std::make_shared<RegistryMock>(std::list<std::shared_ptr<ubuntu::app_launch::app_store::Base>>{mockstore}); | 438 | std::make_shared<RegistryMock>(std::list<std::shared_ptr<ubuntu::app_launch::app_store::Base>>{mockstore}, |
3686 | 439 | std::shared_ptr<ubuntu::app_launch::jobs::manager::Base>{}); | ||
3687 | 441 | 440 | ||
3689 | 442 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), testing::_)) | 441 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"))) |
3690 | 443 | .WillOnce(testing::Return(true)); | 442 | .WillOnce(testing::Return(true)); |
3691 | 444 | EXPECT_CALL(*mockstore, verifyAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), | 443 | EXPECT_CALL(*mockstore, verifyAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), |
3693 | 445 | ubuntu::app_launch::AppID::AppName::from_raw("application"), testing::_)) | 444 | ubuntu::app_launch::AppID::AppName::from_raw("application"))) |
3694 | 446 | .WillOnce(testing::Return(true)); | 445 | .WillOnce(testing::Return(true)); |
3695 | 447 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), | 446 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), |
3697 | 448 | ubuntu::app_launch::AppID::AppName::from_raw("application"), testing::_)) | 447 | ubuntu::app_launch::AppID::AppName::from_raw("application"))) |
3698 | 449 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); | 448 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); |
3699 | 450 | 449 | ||
3700 | 451 | /* Test with current-user-version, should return the version in the manifest */ | 450 | /* Test with current-user-version, should return the version in the manifest */ |
3701 | 452 | EXPECT_EQ("com.test.good_application_1.2.3", | 451 | EXPECT_EQ("com.test.good_application_1.2.3", |
3702 | 453 | (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.good", "application")); | 452 | (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.good", "application")); |
3703 | 454 | 453 | ||
3705 | 455 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), testing::_)) | 454 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"))) |
3706 | 456 | .WillOnce(testing::Return(true)); | 455 | .WillOnce(testing::Return(true)); |
3707 | 457 | EXPECT_CALL(*mockstore, verifyAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), | 456 | EXPECT_CALL(*mockstore, verifyAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), |
3709 | 458 | ubuntu::app_launch::AppID::AppName::from_raw("application"), testing::_)) | 457 | ubuntu::app_launch::AppID::AppName::from_raw("application"))) |
3710 | 459 | .WillOnce(testing::Return(true)); | 458 | .WillOnce(testing::Return(true)); |
3711 | 460 | EXPECT_CALL(*mockstore, | 459 | EXPECT_CALL(*mockstore, |
3712 | 461 | hasAppId(ubuntu::app_launch::AppID{ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), | 460 | hasAppId(ubuntu::app_launch::AppID{ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), |
3713 | 462 | ubuntu::app_launch::AppID::AppName::from_raw("application"), | 461 | ubuntu::app_launch::AppID::AppName::from_raw("application"), |
3716 | 463 | ubuntu::app_launch::AppID::Version::from_raw("1.2.4")}, | 462 | ubuntu::app_launch::AppID::Version::from_raw("1.2.4")})) |
3715 | 464 | testing::_)) | ||
3717 | 465 | .WillOnce(testing::Return(true)); | 463 | .WillOnce(testing::Return(true)); |
3718 | 466 | 464 | ||
3719 | 467 | /* Test with version specified, shouldn't even read the manifest */ | 465 | /* Test with version specified, shouldn't even read the manifest */ |
3720 | 468 | EXPECT_EQ("com.test.good_application_1.2.4", | 466 | EXPECT_EQ("com.test.good_application_1.2.4", |
3721 | 469 | (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.good", "application", "1.2.4")); | 467 | (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.good", "application", "1.2.4")); |
3722 | 470 | 468 | ||
3724 | 471 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), testing::_)) | 469 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"))) |
3725 | 472 | .WillOnce(testing::Return(true)); | 470 | .WillOnce(testing::Return(true)); |
3726 | 473 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), | 471 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), |
3728 | 474 | ubuntu::app_launch::AppID::ApplicationWildcard::FIRST_LISTED, testing::_)) | 472 | ubuntu::app_launch::AppID::ApplicationWildcard::FIRST_LISTED)) |
3729 | 475 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw("application"))); | 473 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw("application"))); |
3730 | 476 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), | 474 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), |
3732 | 477 | ubuntu::app_launch::AppID::AppName::from_raw("application"), testing::_)) | 475 | ubuntu::app_launch::AppID::AppName::from_raw("application"))) |
3733 | 478 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); | 476 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); |
3734 | 479 | 477 | ||
3735 | 480 | /* Test with out a version or app, should return the version in the manifest */ | 478 | /* Test with out a version or app, should return the version in the manifest */ |
3736 | @@ -483,79 +481,72 @@ | |||
3737 | 483 | "current-user-version")); | 481 | "current-user-version")); |
3738 | 484 | 482 | ||
3739 | 485 | /* Make sure we can select the app from a list correctly */ | 483 | /* Make sure we can select the app from a list correctly */ |
3742 | 486 | EXPECT_CALL(*mockstore, | 484 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"))) |
3741 | 487 | verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), testing::_)) | ||
3743 | 488 | .WillOnce(testing::Return(true)); | 485 | .WillOnce(testing::Return(true)); |
3744 | 489 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), | 486 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), |
3746 | 490 | ubuntu::app_launch::AppID::ApplicationWildcard::FIRST_LISTED, testing::_)) | 487 | ubuntu::app_launch::AppID::ApplicationWildcard::FIRST_LISTED)) |
3747 | 491 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw("first"))); | 488 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw("first"))); |
3748 | 492 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), | 489 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), |
3750 | 493 | ubuntu::app_launch::AppID::AppName::from_raw("first"), testing::_)) | 490 | ubuntu::app_launch::AppID::AppName::from_raw("first"))) |
3751 | 494 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); | 491 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); |
3752 | 495 | EXPECT_EQ("com.test.multiple_first_1.2.3", | 492 | EXPECT_EQ("com.test.multiple_first_1.2.3", |
3753 | 496 | (std::string)ubuntu::app_launch::AppID::discover( | 493 | (std::string)ubuntu::app_launch::AppID::discover( |
3754 | 497 | registry, "com.test.multiple", ubuntu::app_launch::AppID::ApplicationWildcard::FIRST_LISTED)); | 494 | registry, "com.test.multiple", ubuntu::app_launch::AppID::ApplicationWildcard::FIRST_LISTED)); |
3755 | 498 | 495 | ||
3758 | 499 | EXPECT_CALL(*mockstore, | 496 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"))) |
3757 | 500 | verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), testing::_)) | ||
3759 | 501 | .WillOnce(testing::Return(true)); | 497 | .WillOnce(testing::Return(true)); |
3760 | 502 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), | 498 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), |
3762 | 503 | ubuntu::app_launch::AppID::ApplicationWildcard::FIRST_LISTED, testing::_)) | 499 | ubuntu::app_launch::AppID::ApplicationWildcard::FIRST_LISTED)) |
3763 | 504 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw("first"))); | 500 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw("first"))); |
3764 | 505 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), | 501 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), |
3766 | 506 | ubuntu::app_launch::AppID::AppName::from_raw("first"), testing::_)) | 502 | ubuntu::app_launch::AppID::AppName::from_raw("first"))) |
3767 | 507 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); | 503 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); |
3768 | 508 | EXPECT_EQ("com.test.multiple_first_1.2.3", | 504 | EXPECT_EQ("com.test.multiple_first_1.2.3", |
3769 | 509 | (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.multiple")); | 505 | (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.multiple")); |
3770 | 510 | 506 | ||
3773 | 511 | EXPECT_CALL(*mockstore, | 507 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"))) |
3772 | 512 | verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), testing::_)) | ||
3774 | 513 | .WillOnce(testing::Return(true)); | 508 | .WillOnce(testing::Return(true)); |
3775 | 514 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), | 509 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), |
3777 | 515 | ubuntu::app_launch::AppID::ApplicationWildcard::LAST_LISTED, testing::_)) | 510 | ubuntu::app_launch::AppID::ApplicationWildcard::LAST_LISTED)) |
3778 | 516 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw("fifth"))); | 511 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw("fifth"))); |
3779 | 517 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), | 512 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), |
3781 | 518 | ubuntu::app_launch::AppID::AppName::from_raw("fifth"), testing::_)) | 513 | ubuntu::app_launch::AppID::AppName::from_raw("fifth"))) |
3782 | 519 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); | 514 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); |
3783 | 520 | EXPECT_EQ("com.test.multiple_fifth_1.2.3", | 515 | EXPECT_EQ("com.test.multiple_fifth_1.2.3", |
3784 | 521 | (std::string)ubuntu::app_launch::AppID::discover( | 516 | (std::string)ubuntu::app_launch::AppID::discover( |
3785 | 522 | registry, "com.test.multiple", ubuntu::app_launch::AppID::ApplicationWildcard::LAST_LISTED)); | 517 | registry, "com.test.multiple", ubuntu::app_launch::AppID::ApplicationWildcard::LAST_LISTED)); |
3786 | 523 | 518 | ||
3789 | 524 | EXPECT_CALL(*mockstore, | 519 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"))) |
3788 | 525 | verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), testing::_)) | ||
3790 | 526 | .WillOnce(testing::Return(true)); | 520 | .WillOnce(testing::Return(true)); |
3791 | 527 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), | 521 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.multiple"), |
3793 | 528 | ubuntu::app_launch::AppID::ApplicationWildcard::ONLY_LISTED, testing::_)) | 522 | ubuntu::app_launch::AppID::ApplicationWildcard::ONLY_LISTED)) |
3794 | 529 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw(""))); | 523 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw(""))); |
3795 | 530 | EXPECT_EQ("", (std::string)ubuntu::app_launch::AppID::discover( | 524 | EXPECT_EQ("", (std::string)ubuntu::app_launch::AppID::discover( |
3796 | 531 | registry, "com.test.multiple", ubuntu::app_launch::AppID::ApplicationWildcard::ONLY_LISTED)); | 525 | registry, "com.test.multiple", ubuntu::app_launch::AppID::ApplicationWildcard::ONLY_LISTED)); |
3797 | 532 | 526 | ||
3799 | 533 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), testing::_)) | 527 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"))) |
3800 | 534 | .WillOnce(testing::Return(true)); | 528 | .WillOnce(testing::Return(true)); |
3801 | 535 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), | 529 | EXPECT_CALL(*mockstore, findAppname(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), |
3803 | 536 | ubuntu::app_launch::AppID::ApplicationWildcard::ONLY_LISTED, testing::_)) | 530 | ubuntu::app_launch::AppID::ApplicationWildcard::ONLY_LISTED)) |
3804 | 537 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw("application"))); | 531 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::AppName::from_raw("application"))); |
3805 | 538 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), | 532 | EXPECT_CALL(*mockstore, findVersion(ubuntu::app_launch::AppID::Package::from_raw("com.test.good"), |
3807 | 539 | ubuntu::app_launch::AppID::AppName::from_raw("application"), testing::_)) | 533 | ubuntu::app_launch::AppID::AppName::from_raw("application"))) |
3808 | 540 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); | 534 | .WillOnce(testing::Return(ubuntu::app_launch::AppID::Version::from_raw("1.2.3"))); |
3809 | 541 | EXPECT_EQ("com.test.good_application_1.2.3", | 535 | EXPECT_EQ("com.test.good_application_1.2.3", |
3810 | 542 | (std::string)ubuntu::app_launch::AppID::discover( | 536 | (std::string)ubuntu::app_launch::AppID::discover( |
3811 | 543 | registry, "com.test.good", ubuntu::app_launch::AppID::ApplicationWildcard::ONLY_LISTED)); | 537 | registry, "com.test.good", ubuntu::app_launch::AppID::ApplicationWildcard::ONLY_LISTED)); |
3812 | 544 | 538 | ||
3813 | 545 | /* A bunch that should be NULL */ | 539 | /* A bunch that should be NULL */ |
3816 | 546 | EXPECT_CALL(*mockstore, | 540 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.no-hooks"))) |
3815 | 547 | verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.no-hooks"), testing::_)) | ||
3817 | 548 | .WillOnce(testing::Return(false)); | 541 | .WillOnce(testing::Return(false)); |
3818 | 549 | EXPECT_EQ("", (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.no-hooks")); | 542 | EXPECT_EQ("", (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.no-hooks")); |
3820 | 550 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.no-json"), testing::_)) | 543 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.no-json"))) |
3821 | 551 | .WillOnce(testing::Return(false)); | 544 | .WillOnce(testing::Return(false)); |
3822 | 552 | EXPECT_EQ("", (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.no-json")); | 545 | EXPECT_EQ("", (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.no-json")); |
3825 | 553 | EXPECT_CALL(*mockstore, | 546 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.no-object"))) |
3824 | 554 | verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.no-object"), testing::_)) | ||
3826 | 555 | .WillOnce(testing::Return(false)); | 547 | .WillOnce(testing::Return(false)); |
3827 | 556 | EXPECT_EQ("", (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.no-object")); | 548 | EXPECT_EQ("", (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.no-object")); |
3830 | 557 | EXPECT_CALL(*mockstore, | 549 | EXPECT_CALL(*mockstore, verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.no-version"))) |
3829 | 558 | verifyPackage(ubuntu::app_launch::AppID::Package::from_raw("com.test.no-version"), testing::_)) | ||
3831 | 559 | .WillOnce(testing::Return(false)); | 550 | .WillOnce(testing::Return(false)); |
3832 | 560 | EXPECT_EQ("", (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.no-version")); | 551 | EXPECT_EQ("", (std::string)ubuntu::app_launch::AppID::discover(registry, "com.test.no-version")); |
3833 | 561 | } | 552 | } |
3834 | 562 | 553 | ||
3835 | === modified file 'tests/list-apps.cpp' | |||
3836 | --- tests/list-apps.cpp 2017-03-14 21:41:39 +0000 | |||
3837 | +++ tests/list-apps.cpp 2017-04-04 21:22:36 +0000 | |||
3838 | @@ -139,8 +139,8 @@ | |||
3839 | 139 | TEST_F(ListApps, ListLegacy) | 139 | TEST_F(ListApps, ListLegacy) |
3840 | 140 | { | 140 | { |
3841 | 141 | auto registry = std::make_shared<ubuntu::app_launch::Registry>(); | 141 | auto registry = std::make_shared<ubuntu::app_launch::Registry>(); |
3844 | 142 | ubuntu::app_launch::app_store::Legacy store; | 142 | ubuntu::app_launch::app_store::Legacy store(registry->impl); |
3845 | 143 | auto apps = store.list(registry); | 143 | auto apps = store.list(); |
3846 | 144 | 144 | ||
3847 | 145 | printApps(apps); | 145 | printApps(apps); |
3848 | 146 | 146 | ||
3849 | @@ -154,8 +154,8 @@ | |||
3850 | 154 | TEST_F(ListApps, ListLibertine) | 154 | TEST_F(ListApps, ListLibertine) |
3851 | 155 | { | 155 | { |
3852 | 156 | auto registry = std::make_shared<ubuntu::app_launch::Registry>(); | 156 | auto registry = std::make_shared<ubuntu::app_launch::Registry>(); |
3855 | 157 | ubuntu::app_launch::app_store::Libertine store; | 157 | ubuntu::app_launch::app_store::Libertine store(registry->impl); |
3856 | 158 | auto apps = store.list(registry); | 158 | auto apps = store.list(); |
3857 | 159 | 159 | ||
3858 | 160 | printApps(apps); | 160 | printApps(apps); |
3859 | 161 | 161 | ||
3860 | @@ -197,8 +197,8 @@ | |||
3861 | 197 | interfaces, x11Package, x11Package, x11Package}}; /* x11 check */ | 197 | interfaces, x11Package, x11Package, x11Package}}; /* x11 check */ |
3862 | 198 | auto registry = std::make_shared<ubuntu::app_launch::Registry>(); | 198 | auto registry = std::make_shared<ubuntu::app_launch::Registry>(); |
3863 | 199 | 199 | ||
3866 | 200 | ubuntu::app_launch::app_store::Snap store; | 200 | ubuntu::app_launch::app_store::Snap store(registry->impl); |
3867 | 201 | auto apps = store.list(registry); | 201 | auto apps = store.list(); |
3868 | 202 | 202 | ||
3869 | 203 | printApps(apps); | 203 | printApps(apps); |
3870 | 204 | 204 | ||
3871 | 205 | 205 | ||
3872 | === modified file 'tests/registry-mock.h' | |||
3873 | --- tests/registry-mock.h 2017-03-20 10:13:50 +0000 | |||
3874 | +++ tests/registry-mock.h 2017-04-04 21:22:36 +0000 | |||
3875 | @@ -29,8 +29,8 @@ | |||
3876 | 29 | class MockStore : public ubuntu::app_launch::app_store::Base | 29 | class MockStore : public ubuntu::app_launch::app_store::Base |
3877 | 30 | { | 30 | { |
3878 | 31 | public: | 31 | public: |
3881 | 32 | MockStore() | 32 | MockStore(const std::shared_ptr<ubuntu::app_launch::Registry::Impl>& registry) |
3882 | 33 | : ubuntu::app_launch::app_store::Base() | 33 | : ubuntu::app_launch::app_store::Base(registry) |
3883 | 34 | { | 34 | { |
3884 | 35 | } | 35 | } |
3885 | 36 | 36 | ||
3886 | @@ -38,32 +38,22 @@ | |||
3887 | 38 | { | 38 | { |
3888 | 39 | } | 39 | } |
3889 | 40 | 40 | ||
3897 | 41 | MOCK_METHOD2(verifyPackage, | 41 | MOCK_METHOD1(verifyPackage, bool(const ubuntu::app_launch::AppID::Package&)); |
3898 | 42 | bool(const ubuntu::app_launch::AppID::Package&, const std::shared_ptr<ubuntu::app_launch::Registry>&)); | 42 | MOCK_METHOD2(verifyAppname, |
3899 | 43 | MOCK_METHOD3(verifyAppname, | 43 | bool(const ubuntu::app_launch::AppID::Package&, const ubuntu::app_launch::AppID::AppName&)); |
3900 | 44 | bool(const ubuntu::app_launch::AppID::Package&, | 44 | MOCK_METHOD2(findAppname, |
3894 | 45 | const ubuntu::app_launch::AppID::AppName&, | ||
3895 | 46 | const std::shared_ptr<ubuntu::app_launch::Registry>&)); | ||
3896 | 47 | MOCK_METHOD3(findAppname, | ||
3901 | 48 | ubuntu::app_launch::AppID::AppName(const ubuntu::app_launch::AppID::Package&, | 45 | ubuntu::app_launch::AppID::AppName(const ubuntu::app_launch::AppID::Package&, |
3905 | 49 | ubuntu::app_launch::AppID::ApplicationWildcard, | 46 | ubuntu::app_launch::AppID::ApplicationWildcard)); |
3906 | 50 | const std::shared_ptr<ubuntu::app_launch::Registry>&)); | 47 | MOCK_METHOD2(findVersion, |
3904 | 51 | MOCK_METHOD3(findVersion, | ||
3907 | 52 | ubuntu::app_launch::AppID::Version(const ubuntu::app_launch::AppID::Package&, | 48 | ubuntu::app_launch::AppID::Version(const ubuntu::app_launch::AppID::Package&, |
3912 | 53 | const ubuntu::app_launch::AppID::AppName&, | 49 | const ubuntu::app_launch::AppID::AppName&)); |
3913 | 54 | const std::shared_ptr<ubuntu::app_launch::Registry>&)); | 50 | MOCK_METHOD1(hasAppId, bool(const ubuntu::app_launch::AppID&)); |
3910 | 55 | MOCK_METHOD2(hasAppId, | ||
3911 | 56 | bool(const ubuntu::app_launch::AppID&, const std::shared_ptr<ubuntu::app_launch::Registry>&)); | ||
3914 | 57 | 51 | ||
3915 | 58 | /* Possible apps */ | 52 | /* Possible apps */ |
3919 | 59 | MOCK_METHOD1(list, | 53 | MOCK_METHOD0(list, std::list<std::shared_ptr<ubuntu::app_launch::Application>>()); |
3917 | 60 | std::list<std::shared_ptr<ubuntu::app_launch::Application>>( | ||
3918 | 61 | const std::shared_ptr<ubuntu::app_launch::Registry>&)); | ||
3920 | 62 | 54 | ||
3921 | 63 | /* Application Creation */ | 55 | /* Application Creation */ |
3925 | 64 | MOCK_METHOD2(create, | 56 | MOCK_METHOD1(create, std::shared_ptr<ubuntu::app_launch::app_impls::Base>(const ubuntu::app_launch::AppID&)); |
3923 | 65 | std::shared_ptr<ubuntu::app_launch::app_impls::Base>( | ||
3924 | 66 | const ubuntu::app_launch::AppID&, const std::shared_ptr<ubuntu::app_launch::Registry>&)); | ||
3926 | 67 | }; | 57 | }; |
3927 | 68 | 58 | ||
3928 | 69 | class MockApp : public ubuntu::app_launch::app_impls::Base | 59 | class MockApp : public ubuntu::app_launch::app_impls::Base |
3929 | @@ -71,7 +61,7 @@ | |||
3930 | 71 | public: | 61 | public: |
3931 | 72 | ubuntu::app_launch::AppID appid_; | 62 | ubuntu::app_launch::AppID appid_; |
3932 | 73 | 63 | ||
3934 | 74 | MockApp(const ubuntu::app_launch::AppID& appid, const std::shared_ptr<ubuntu::app_launch::Registry>& reg) | 64 | MockApp(const ubuntu::app_launch::AppID& appid, const std::shared_ptr<ubuntu::app_launch::Registry::Impl>& reg) |
3935 | 75 | : ubuntu::app_launch::app_impls::Base(reg) | 65 | : ubuntu::app_launch::app_impls::Base(reg) |
3936 | 76 | , appid_(appid) | 66 | , appid_(appid) |
3937 | 77 | { | 67 | { |
3938 | @@ -105,7 +95,7 @@ | |||
3939 | 105 | const std::string& job, | 95 | const std::string& job, |
3940 | 106 | const std::string& instance, | 96 | const std::string& instance, |
3941 | 107 | const std::vector<ubuntu::app_launch::Application::URL>& urls, | 97 | const std::vector<ubuntu::app_launch::Application::URL>& urls, |
3943 | 108 | const std::shared_ptr<ubuntu::app_launch::Registry>& registry) | 98 | const std::shared_ptr<ubuntu::app_launch::Registry::Impl>& registry) |
3944 | 109 | : ubuntu::app_launch::jobs::instance::Base(appId, job, instance, urls, registry){}; | 99 | : ubuntu::app_launch::jobs::instance::Base(appId, job, instance, urls, registry){}; |
3945 | 110 | ~MockInst(){}; | 100 | ~MockInst(){}; |
3946 | 111 | 101 | ||
3947 | @@ -117,7 +107,7 @@ | |||
3948 | 117 | class MockJobsManager : public ubuntu::app_launch::jobs::manager::Base | 107 | class MockJobsManager : public ubuntu::app_launch::jobs::manager::Base |
3949 | 118 | { | 108 | { |
3950 | 119 | public: | 109 | public: |
3952 | 120 | MockJobsManager(const std::shared_ptr<ubuntu::app_launch::Registry>& reg) | 110 | MockJobsManager(const std::shared_ptr<ubuntu::app_launch::Registry::Impl>& reg) |
3953 | 121 | : ubuntu::app_launch::jobs::manager::Base(reg) | 111 | : ubuntu::app_launch::jobs::manager::Base(reg) |
3954 | 122 | { | 112 | { |
3955 | 123 | } | 113 | } |
3956 | @@ -164,8 +154,8 @@ | |||
3957 | 164 | class zgWatcherMock : public ubuntu::app_launch::info_watcher::Zeitgeist | 154 | class zgWatcherMock : public ubuntu::app_launch::info_watcher::Zeitgeist |
3958 | 165 | { | 155 | { |
3959 | 166 | public: | 156 | public: |
3962 | 167 | zgWatcherMock() | 157 | zgWatcherMock(const std::shared_ptr<ubuntu::app_launch::Registry::Impl>& registry) |
3963 | 168 | : ubuntu::app_launch::info_watcher::Zeitgeist({}) | 158 | : ubuntu::app_launch::info_watcher::Zeitgeist(registry) |
3964 | 169 | { | 159 | { |
3965 | 170 | } | 160 | } |
3966 | 171 | 161 | ||
3967 | @@ -180,31 +170,10 @@ | |||
3968 | 180 | class RegistryImplMock : public ubuntu::app_launch::Registry::Impl | 170 | class RegistryImplMock : public ubuntu::app_launch::Registry::Impl |
3969 | 181 | { | 171 | { |
3970 | 182 | public: | 172 | public: |
3996 | 183 | RegistryImplMock(ubuntu::app_launch::Registry& reg) | 173 | RegistryImplMock() |
3997 | 184 | : ubuntu::app_launch::Registry::Impl(reg) | 174 | : ubuntu::app_launch::Registry::Impl() |
3998 | 185 | { | 175 | { |
3999 | 186 | setupZgWatcher(); | 176 | g_debug("Registry Mock Implementation Created"); |
3975 | 187 | |||
3976 | 188 | g_debug("Registry Mock Implementation Created"); | ||
3977 | 189 | } | ||
3978 | 190 | |||
3979 | 191 | RegistryImplMock(ubuntu::app_launch::Registry& reg, | ||
3980 | 192 | std::list<std::shared_ptr<ubuntu::app_launch::app_store::Base>> appStores) | ||
3981 | 193 | : ubuntu::app_launch::Registry::Impl(reg, appStores) | ||
3982 | 194 | { | ||
3983 | 195 | setupZgWatcher(); | ||
3984 | 196 | |||
3985 | 197 | g_debug("Registry Mock Implementation Created"); | ||
3986 | 198 | } | ||
3987 | 199 | |||
3988 | 200 | void setupZgWatcher() | ||
3989 | 201 | { | ||
3990 | 202 | auto zgWatcher = std::make_shared<zgWatcherMock>(); | ||
3991 | 203 | zgWatcher_ = zgWatcher; | ||
3992 | 204 | std::call_once(zgWatcherOnce_, [] {}); | ||
3993 | 205 | |||
3994 | 206 | ON_CALL(*zgWatcher, lookupAppPopularity(testing::_)) | ||
3995 | 207 | .WillByDefault(testing::Return(ubuntu::app_launch::Application::Info::Popularity::from_raw(1u))); | ||
4000 | 208 | } | 177 | } |
4001 | 209 | 178 | ||
4002 | 210 | ~RegistryImplMock() | 179 | ~RegistryImplMock() |
4003 | @@ -219,15 +188,29 @@ | |||
4004 | 219 | { | 188 | { |
4005 | 220 | public: | 189 | public: |
4006 | 221 | RegistryMock() | 190 | RegistryMock() |
4007 | 191 | : Registry(std::make_shared<RegistryImplMock>()) | ||
4008 | 222 | { | 192 | { |
4009 | 193 | auto zgWatcher = std::make_shared<zgWatcherMock>(impl); | ||
4010 | 194 | ON_CALL(*zgWatcher, lookupAppPopularity(testing::_)) | ||
4011 | 195 | .WillByDefault(testing::Return(ubuntu::app_launch::Application::Info::Popularity::from_raw(1u))); | ||
4012 | 196 | impl->setZgWatcher(zgWatcher); | ||
4013 | 197 | |||
4014 | 223 | g_debug("Registry Mock Created"); | 198 | g_debug("Registry Mock Created"); |
4015 | 224 | impl = std::unique_ptr<RegistryImplMock>(new RegistryImplMock(*this)); | ||
4016 | 225 | } | 199 | } |
4017 | 226 | 200 | ||
4019 | 227 | RegistryMock(std::list<std::shared_ptr<ubuntu::app_launch::app_store::Base>> appStores) | 201 | RegistryMock(std::list<std::shared_ptr<ubuntu::app_launch::app_store::Base>> appStores, |
4020 | 202 | std::shared_ptr<ubuntu::app_launch::jobs::manager::Base> jobManager) | ||
4021 | 203 | : Registry(std::make_shared<RegistryImplMock>()) | ||
4022 | 228 | { | 204 | { |
4023 | 205 | impl->setAppStores(appStores); | ||
4024 | 206 | impl->setJobs(jobManager); | ||
4025 | 207 | |||
4026 | 208 | auto zgWatcher = std::make_shared<zgWatcherMock>(impl); | ||
4027 | 209 | ON_CALL(*zgWatcher, lookupAppPopularity(testing::_)) | ||
4028 | 210 | .WillByDefault(testing::Return(ubuntu::app_launch::Application::Info::Popularity::from_raw(1u))); | ||
4029 | 211 | impl->setZgWatcher(zgWatcher); | ||
4030 | 212 | |||
4031 | 229 | g_debug("Registry Mock Created"); | 213 | g_debug("Registry Mock Created"); |
4032 | 230 | impl = std::unique_ptr<RegistryImplMock>(new RegistryImplMock(*this, appStores)); | ||
4033 | 231 | } | 214 | } |
4034 | 232 | 215 | ||
4035 | 233 | ~RegistryMock() | 216 | ~RegistryMock() |
FAILED: Continuous integration, rev:317 /jenkins. canonical. com/unity- api-1/job/ lp-ubuntu- app-launch- ci/281/ /jenkins. canonical. com/unity- api-1/job/ build/1879/ console /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/1886 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1668/console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= zesty/1668/ console /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1668 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1668/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= zesty/1668 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= zesty/1668/ artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1668 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1668/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= zesty/1668/ console
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-ubuntu- app-launch- ci/281/ rebuild
https:/