Merge lp:~marcustomlinson/unity-scope-click/lp-1378186 into lp:unity-scope-click

Proposed by Marcus Tomlinson
Status: Merged
Approved by: dobey
Approved revision: 453
Merged at revision: 459
Proposed branch: lp:~marcustomlinson/unity-scope-click/lp-1378186
Merge into: lp:unity-scope-click
Diff against target: 133 lines (+23/-15)
5 files modified
libclickscope/click/scope_activation.cpp (+17/-6)
libclickscope/click/scope_activation.h (+1/-4)
scope/clickapps/apps-query.cpp (+3/-2)
scope/clickapps/apps-query.h (+1/-1)
scope/clickapps/apps-scope.cpp (+1/-2)
To merge this branch: bzr merge lp:~marcustomlinson/unity-scope-click/lp-1378186
Reviewer Review Type Date Requested Status
dobey (community) Approve
PS Jenkins bot continuous-integration Pending
Review via email: mp+295023@code.launchpad.net

Commit message

Return apps scope to root department if current department becomes empty after an uninstall

To post a comment you must log in.
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

I have tested this on the phone. If you'd like to confirm, here's a build: https://code.launchpad.net/~unity-api-team/+archive/ubuntu/dev-build-3

Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote :

This is now in silo 47

Revision history for this message
dobey (dobey) :
review: Needs Fixing
453. By Marcus Tomlinson

uninstall_sucess_f -> uninstall_success_f

Revision history for this message
Marcus Tomlinson (marcustomlinson) :
Revision history for this message
dobey (dobey) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'libclickscope/click/scope_activation.cpp'
2--- libclickscope/click/scope_activation.cpp 2014-06-16 12:40:06 +0000
3+++ libclickscope/click/scope_activation.cpp 2016-05-19 18:06:18 +0000
4@@ -28,6 +28,7 @@
5 */
6
7 #include "scope_activation.h"
8+#include <click/download-manager.h>
9 #include <click/package.h>
10 #include <click/interface.h>
11 #include <click/qtbridge.h>
12@@ -55,31 +56,41 @@
13 hints_[key] = value;
14 }
15
16-click::PerformUninstallAction::PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata, const unity::scopes::ActivationResponse& response)
17- : unity::scopes::ActivationQueryBase(result, metadata),
18- response(response)
19+click::PerformUninstallAction::PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata)
20+ : unity::scopes::ActivationQueryBase(result, metadata)
21 {
22 }
23
24 unity::scopes::ActivationResponse click::PerformUninstallAction::activate()
25 {
26+ std::promise<bool> uninstall_success_p;
27+ std::future<bool> uninstall_success_f = uninstall_success_p.get_future();
28+
29 auto const res = result();
30 click::Package package;
31 package.title = res.title();
32 package.name = res["name"].get_string();
33 package.version = res["version"].get_string();
34- qt::core::world::enter_with_task([this, package] ()
35+ qt::core::world::enter_with_task([this, package, &uninstall_success_p] ()
36 {
37 click::PackageManager manager;
38 manager.uninstall(package, [&](int code, std::string stderr_content) {
39 if (code != 0) {
40 qDebug() << "Error removing package:" << stderr_content.c_str();
41+ uninstall_success_p.set_value(false);
42 } else {
43 qDebug() << "successfully removed package";
44-
45+ uninstall_success_p.set_value(true);
46 }
47 } );
48 });
49
50- return response;
51+ if (uninstall_success_f.get())
52+ {
53+ if (res.contains("lonely_result") && res.value("lonely_result").get_bool())
54+ {
55+ return unity::scopes::ActivationResponse(unity::scopes::CannedQuery(APPS_SCOPE_ID.toUtf8().data()));
56+ }
57+ }
58+ return unity::scopes::ActivationResponse(unity::scopes::ActivationResponse::ShowDash);
59 }
60
61=== modified file 'libclickscope/click/scope_activation.h'
62--- libclickscope/click/scope_activation.h 2014-06-16 12:40:06 +0000
63+++ libclickscope/click/scope_activation.h 2016-05-19 18:06:18 +0000
64@@ -40,11 +40,8 @@
65 class PerformUninstallAction: public unity::scopes::ActivationQueryBase
66 {
67 public:
68- PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata, const unity::scopes::ActivationResponse& response);
69+ PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata);
70 unity::scopes::ActivationResponse activate() override;
71-
72-private:
73- unity::scopes::ActivationResponse response;
74 };
75
76 class ScopeActivation : public unity::scopes::ActivationQueryBase
77
78=== modified file 'scope/clickapps/apps-query.cpp'
79--- scope/clickapps/apps-query.cpp 2016-05-10 14:56:11 +0000
80+++ scope/clickapps/apps-query.cpp 2016-05-19 18:06:18 +0000
81@@ -116,7 +116,7 @@
82 }
83 }
84
85-void click::apps::ResultPusher::push_result(scopes::Category::SCPtr& cat, const click::Application& a)
86+void click::apps::ResultPusher::push_result(scopes::Category::SCPtr& cat, const click::Application& a, bool lonely_result)
87 {
88 scopes::CategorisedResult res(cat);
89 res.set_title(a.title);
90@@ -127,6 +127,7 @@
91 res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = a.main_screenshot;
92 res[click::apps::Query::ResultKeys::INSTALLED] = true;
93 res[click::apps::Query::ResultKeys::VERSION] = a.version;
94+ res["lonely_result"] = lonely_result;
95 replyProxy->push(res);
96 }
97
98@@ -166,7 +167,7 @@
99 {
100 if (top_apps_lookup.size() == 0 || top_apps_lookup.find(get_app_identifier(a)) == top_apps_lookup.end())
101 {
102- push_result(cat, a);
103+ push_result(cat, a, apps.size() == 1);
104 }
105 }
106 catch (const std::runtime_error &e)
107
108=== modified file 'scope/clickapps/apps-query.h'
109--- scope/clickapps/apps-query.h 2016-05-10 14:56:11 +0000
110+++ scope/clickapps/apps-query.h 2016-05-19 18:06:18 +0000
111@@ -106,7 +106,7 @@
112 const std::vector<click::Application>& apps,
113 const std::string& categoryTemplate);
114 protected:
115- virtual void push_result(scopes::Category::SCPtr& cat, const click::Application& a);
116+ virtual void push_result(scopes::Category::SCPtr& cat, const click::Application& a, bool lonely_result = false);
117 static std::string get_app_identifier(const click::Application& app);
118 };
119 } // namespace apps
120
121=== modified file 'scope/clickapps/apps-scope.cpp'
122--- scope/clickapps/apps-scope.cpp 2016-05-10 14:56:11 +0000
123+++ scope/clickapps/apps-scope.cpp 2016-05-19 18:06:18 +0000
124@@ -118,8 +118,7 @@
125 std::string const& widget_id, std::string const& action_id)
126 {
127 if (action_id == click::Preview::Actions::CONFIRM_UNINSTALL) {
128- auto response = unity::scopes::ActivationResponse(unity::scopes::ActivationResponse::ShowDash);
129- return scopes::ActivationQueryBase::UPtr(new PerformUninstallAction(result, metadata, response));
130+ return scopes::ActivationQueryBase::UPtr(new PerformUninstallAction(result, metadata));
131 }
132
133 auto activation = new ScopeActivation(result, metadata);

Subscribers

People subscribed via source and target branches