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
=== modified file 'libclickscope/click/scope_activation.cpp'
--- libclickscope/click/scope_activation.cpp 2014-06-16 12:40:06 +0000
+++ libclickscope/click/scope_activation.cpp 2016-05-19 18:06:18 +0000
@@ -28,6 +28,7 @@
28 */28 */
2929
30#include "scope_activation.h"30#include "scope_activation.h"
31#include <click/download-manager.h>
31#include <click/package.h>32#include <click/package.h>
32#include <click/interface.h>33#include <click/interface.h>
33#include <click/qtbridge.h>34#include <click/qtbridge.h>
@@ -55,31 +56,41 @@
55 hints_[key] = value;56 hints_[key] = value;
56}57}
5758
58click::PerformUninstallAction::PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata, const unity::scopes::ActivationResponse& response)59click::PerformUninstallAction::PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata)
59 : unity::scopes::ActivationQueryBase(result, metadata),60 : unity::scopes::ActivationQueryBase(result, metadata)
60 response(response)
61{61{
62}62}
6363
64unity::scopes::ActivationResponse click::PerformUninstallAction::activate()64unity::scopes::ActivationResponse click::PerformUninstallAction::activate()
65{65{
66 std::promise<bool> uninstall_success_p;
67 std::future<bool> uninstall_success_f = uninstall_success_p.get_future();
68
66 auto const res = result();69 auto const res = result();
67 click::Package package;70 click::Package package;
68 package.title = res.title();71 package.title = res.title();
69 package.name = res["name"].get_string();72 package.name = res["name"].get_string();
70 package.version = res["version"].get_string();73 package.version = res["version"].get_string();
71 qt::core::world::enter_with_task([this, package] ()74 qt::core::world::enter_with_task([this, package, &uninstall_success_p] ()
72 {75 {
73 click::PackageManager manager;76 click::PackageManager manager;
74 manager.uninstall(package, [&](int code, std::string stderr_content) {77 manager.uninstall(package, [&](int code, std::string stderr_content) {
75 if (code != 0) {78 if (code != 0) {
76 qDebug() << "Error removing package:" << stderr_content.c_str();79 qDebug() << "Error removing package:" << stderr_content.c_str();
80 uninstall_success_p.set_value(false);
77 } else {81 } else {
78 qDebug() << "successfully removed package";82 qDebug() << "successfully removed package";
7983 uninstall_success_p.set_value(true);
80 }84 }
81 } );85 } );
82 });86 });
8387
84 return response;88 if (uninstall_success_f.get())
89 {
90 if (res.contains("lonely_result") && res.value("lonely_result").get_bool())
91 {
92 return unity::scopes::ActivationResponse(unity::scopes::CannedQuery(APPS_SCOPE_ID.toUtf8().data()));
93 }
94 }
95 return unity::scopes::ActivationResponse(unity::scopes::ActivationResponse::ShowDash);
85}96}
8697
=== modified file 'libclickscope/click/scope_activation.h'
--- libclickscope/click/scope_activation.h 2014-06-16 12:40:06 +0000
+++ libclickscope/click/scope_activation.h 2016-05-19 18:06:18 +0000
@@ -40,11 +40,8 @@
40class PerformUninstallAction: public unity::scopes::ActivationQueryBase40class PerformUninstallAction: public unity::scopes::ActivationQueryBase
41{41{
42public:42public:
43 PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata, const unity::scopes::ActivationResponse& response);43 PerformUninstallAction(const unity::scopes::Result& result, const unity::scopes::ActionMetadata& metadata);
44 unity::scopes::ActivationResponse activate() override;44 unity::scopes::ActivationResponse activate() override;
45
46private:
47 unity::scopes::ActivationResponse response;
48};45};
4946
50class ScopeActivation : public unity::scopes::ActivationQueryBase47class ScopeActivation : public unity::scopes::ActivationQueryBase
5148
=== modified file 'scope/clickapps/apps-query.cpp'
--- scope/clickapps/apps-query.cpp 2016-05-10 14:56:11 +0000
+++ scope/clickapps/apps-query.cpp 2016-05-19 18:06:18 +0000
@@ -116,7 +116,7 @@
116 }116 }
117}117}
118118
119void click::apps::ResultPusher::push_result(scopes::Category::SCPtr& cat, const click::Application& a)119void click::apps::ResultPusher::push_result(scopes::Category::SCPtr& cat, const click::Application& a, bool lonely_result)
120{120{
121 scopes::CategorisedResult res(cat);121 scopes::CategorisedResult res(cat);
122 res.set_title(a.title);122 res.set_title(a.title);
@@ -127,6 +127,7 @@
127 res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = a.main_screenshot;127 res[click::apps::Query::ResultKeys::MAIN_SCREENSHOT] = a.main_screenshot;
128 res[click::apps::Query::ResultKeys::INSTALLED] = true;128 res[click::apps::Query::ResultKeys::INSTALLED] = true;
129 res[click::apps::Query::ResultKeys::VERSION] = a.version;129 res[click::apps::Query::ResultKeys::VERSION] = a.version;
130 res["lonely_result"] = lonely_result;
130 replyProxy->push(res);131 replyProxy->push(res);
131}132}
132133
@@ -166,7 +167,7 @@
166 {167 {
167 if (top_apps_lookup.size() == 0 || top_apps_lookup.find(get_app_identifier(a)) == top_apps_lookup.end())168 if (top_apps_lookup.size() == 0 || top_apps_lookup.find(get_app_identifier(a)) == top_apps_lookup.end())
168 {169 {
169 push_result(cat, a);170 push_result(cat, a, apps.size() == 1);
170 }171 }
171 }172 }
172 catch (const std::runtime_error &e)173 catch (const std::runtime_error &e)
173174
=== modified file 'scope/clickapps/apps-query.h'
--- scope/clickapps/apps-query.h 2016-05-10 14:56:11 +0000
+++ scope/clickapps/apps-query.h 2016-05-19 18:06:18 +0000
@@ -106,7 +106,7 @@
106 const std::vector<click::Application>& apps,106 const std::vector<click::Application>& apps,
107 const std::string& categoryTemplate);107 const std::string& categoryTemplate);
108protected:108protected:
109 virtual void push_result(scopes::Category::SCPtr& cat, const click::Application& a);109 virtual void push_result(scopes::Category::SCPtr& cat, const click::Application& a, bool lonely_result = false);
110 static std::string get_app_identifier(const click::Application& app);110 static std::string get_app_identifier(const click::Application& app);
111};111};
112} // namespace apps112} // namespace apps
113113
=== modified file 'scope/clickapps/apps-scope.cpp'
--- scope/clickapps/apps-scope.cpp 2016-05-10 14:56:11 +0000
+++ scope/clickapps/apps-scope.cpp 2016-05-19 18:06:18 +0000
@@ -118,8 +118,7 @@
118 std::string const& widget_id, std::string const& action_id)118 std::string const& widget_id, std::string const& action_id)
119{119{
120 if (action_id == click::Preview::Actions::CONFIRM_UNINSTALL) {120 if (action_id == click::Preview::Actions::CONFIRM_UNINSTALL) {
121 auto response = unity::scopes::ActivationResponse(unity::scopes::ActivationResponse::ShowDash);121 return scopes::ActivationQueryBase::UPtr(new PerformUninstallAction(result, metadata));
122 return scopes::ActivationQueryBase::UPtr(new PerformUninstallAction(result, metadata, response));
123 }122 }
124123
125 auto activation = new ScopeActivation(result, metadata);124 auto activation = new ScopeActivation(result, metadata);

Subscribers

People subscribed via source and target branches