Merge lp:~stolowski/unity-scope-click/provide-default-db into lp:unity-scope-click/devel

Proposed by Paweł Stołowski
Status: Superseded
Proposed branch: lp:~stolowski/unity-scope-click/provide-default-db
Merge into: lp:unity-scope-click/devel
Diff against target: 411 lines (+122/-55)
10 files modified
data/CMakeLists.txt (+10/-0)
data/click-scope-departments-db.conf.in (+9/-0)
debian/control (+26/-1)
debian/unity-scope-click-departmentsdb.install (+2/-0)
debian/unity-scope-click-init-departments.install (+1/-0)
debian/unity-scope-click.install (+3/-1)
libclickscope/click/preview.cpp (+51/-46)
libclickscope/click/preview.h (+18/-6)
scope/tests/test_query.cpp (+0/-1)
tools/init-departments/CMakeLists.txt (+2/-0)
To merge this branch: bzr merge lp:~stolowski/unity-scope-click/provide-default-db
Reviewer Review Type Date Requested Status
Unity Team Pending
Review via email: mp+226842@code.launchpad.net

Commit message

Provide default departments db and an upstart job that copies it to user's home directory (unless it's there already). Added new deb packages.

Description of the change

Provide default departments db and an upstart job that copies it to user's home directory (unless it's there already). Added new deb packages.

To post a comment you must log in.
347. By Paweł Stołowski

Merged populate-departments-db.

348. By Paweł Stołowski

Merged devel.

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'data/CMakeLists.txt'
--- data/CMakeLists.txt 2014-07-04 13:10:05 +0000
+++ data/CMakeLists.txt 2014-07-15 14:34:54 +0000
@@ -14,6 +14,11 @@
14 ${APPS_INI_TARGET}.in14 ${APPS_INI_TARGET}.in
15)15)
1616
17# upstart job for default departments db
18set(DEPARTMENTS_UPSTART_JOB click-scope-departments-db.conf)
19configure_file(${DEPARTMENTS_UPSTART_JOB}.in ${DEPARTMENTS_UPSTART_JOB} @ONLY)
20install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DEPARTMENTS_UPSTART_JOB} DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
21
17add_custom_target(${STORE_INI_TARGET} ALL22add_custom_target(${STORE_INI_TARGET} ALL
18 COMMENT "Merging translations into ${STORE_INI_TARGET}"23 COMMENT "Merging translations into ${STORE_INI_TARGET}"
19 COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${STORE_INI_TARGET}.in ${STORE_INI_TARGET} >/dev/null24 COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${STORE_INI_TARGET}.in ${STORE_INI_TARGET} >/dev/null
@@ -35,6 +40,11 @@
35)40)
3641
37install(42install(
43 FILES departments.db
44 DESTINATION "${APPS_DATA_DIR}"
45)
46
47install(
38 FILES "${CMAKE_CURRENT_BINARY_DIR}/${STORE_INI_TARGET}"48 FILES "${CMAKE_CURRENT_BINARY_DIR}/${STORE_INI_TARGET}"
39 DESTINATION "${STORE_LIB_DIR}"49 DESTINATION "${STORE_LIB_DIR}"
40)50)
4151
=== added file 'data/click-scope-departments-db.conf.in'
--- data/click-scope-departments-db.conf.in 1970-01-01 00:00:00 +0000
+++ data/click-scope-departments-db.conf.in 2014-07-15 14:34:54 +0000
@@ -0,0 +1,9 @@
1description "Default Click Departments Database"
2author "Pawel Stolowski <pawel.stolowski@canonical.com>"
3
4start on starting unity8
5
6script
7 DB_FILE=@APPS_DATA_DIR@/departments.db
8 [ -f $HOME/.cache/click-departments.db ] || cp $DB_FILE $HOME/.cache/click-departments.db
9end script
010
=== added file 'data/departments.db'
1Binary files data/departments.db 1970-01-01 00:00:00 +0000 and data/departments.db 2014-07-15 14:34:54 +0000 differ11Binary files data/departments.db 1970-01-01 00:00:00 +0000 and data/departments.db 2014-07-15 14:34:54 +0000 differ
=== modified file 'debian/control'
--- debian/control 2014-07-11 21:56:59 +0000
+++ debian/control 2014-07-15 14:34:54 +0000
@@ -30,7 +30,8 @@
30 ubuntu-app-launch-tools,30 ubuntu-app-launch-tools,
31 ubuntu-download-manager,31 ubuntu-download-manager,
32 ubuntu-sdk-libs,32 ubuntu-sdk-libs,
33 sqlite3 (>= 3.8.5),33 libsqlite3-0 (>= 3.8.5),
34 unity-scope-click-departmentsdb (= ${binary:Version}),
34 ${misc:Depends},35 ${misc:Depends},
35 ${shlibs:Depends},36 ${shlibs:Depends},
36Breaks: unity (<< 7.0),37Breaks: unity (<< 7.0),
@@ -41,6 +42,30 @@
41 .42 .
42 This package provides the click scope.43 This package provides the click scope.
4344
45Package: unity-scope-click-init-departments
46Architecture: armhf i386 amd64
47Depends: libsqlite3-0 (>= 3.8.5),
48 ${misc:Depends},
49 ${shlibs:Depends},
50Breaks: unity (<< 7.0),
51Description: Click Scope Utility for Initialization of Departments
52 The click scope init-departments initializes or updates the internal database
53 of departments for installed applications. This tool is for click scope developers
54 and for customizations of ubuntu-touch image. It's not meant to be used by end users.
55 .
56 This package provides the helper init-departments tool.
57
58Package: unity-scope-click-departmentsdb
59Architecture: all
60Depends: ${misc:Depends},
61 ${shlibs:Depends},
62Breaks: unity (<< 7.0),
63Description: Click Scope Departments Database
64 The click scope departments database provide the initial departments data for
65 preinstalled (default) applications.
66 .
67 This package provides departments database for preinstalled applications.
68
44Package: unity-scope-click-autopilot69Package: unity-scope-click-autopilot
45Architecture: all70Architecture: all
46Depends: libautopilot-qt (>= 1.4),71Depends: libautopilot-qt (>= 1.4),
4772
=== added file 'debian/unity-scope-click-departmentsdb.install'
--- debian/unity-scope-click-departmentsdb.install 1970-01-01 00:00:00 +0000
+++ debian/unity-scope-click-departmentsdb.install 2014-07-15 14:34:54 +0000
@@ -0,0 +1,2 @@
1usr/share/unity/scopes/clickapps/departments.db
2usr/share/upstart/sessions/*.conf
03
=== added file 'debian/unity-scope-click-init-departments.install'
--- debian/unity-scope-click-init-departments.install 1970-01-01 00:00:00 +0000
+++ debian/unity-scope-click-init-departments.install 2014-07-15 14:34:54 +0000
@@ -0,0 +1,1 @@
1usr/sbin/init-departments
02
=== modified file 'debian/unity-scope-click.install'
--- debian/unity-scope-click.install 2014-07-07 10:32:36 +0000
+++ debian/unity-scope-click.install 2014-07-15 14:34:54 +0000
@@ -1,5 +1,7 @@
1usr/lib/*/unity-scopes/*1usr/lib/*/unity-scopes/*
2usr/lib/unity-scope-click/*2usr/lib/unity-scope-click/*
3usr/share/unity/scopes/*3usr/share/unity/scopes/clickstore/*
4usr/share/unity/scopes/clickapps/*jpg
5usr/share/unity/scopes/clickapps/*svg
4usr/share/glib-2.0/schemas/*6usr/share/glib-2.0/schemas/*
5usr/share/locale/*/LC_MESSAGES/unity-scope-click.mo7usr/share/locale/*/LC_MESSAGES/unity-scope-click.mo
68
=== modified file 'libclickscope/click/preview.cpp'
--- libclickscope/click/preview.cpp 2014-07-15 14:34:53 +0000
+++ libclickscope/click/preview.cpp 2014-07-15 14:34:54 +0000
@@ -54,6 +54,39 @@
5454
55namespace click {55namespace click {
5656
57DepartmentUpdater::DepartmentUpdater(const std::shared_ptr<click::DepartmentsDb>& depts)
58 : depts(depts)
59{
60}
61
62void DepartmentUpdater::store_department(const PackageDetails& details)
63{
64 //
65 // store package -> department mapping in sqlite db
66 if (depts)
67 {
68 if (!details.department.empty())
69 {
70 try
71 {
72 depts->store_package_mapping(details.package.name, details.department);
73 qDebug() << "Storing mapping for" << QString::fromStdString(details.package.name) << ":" << QString::fromStdString(details.department);
74 }
75 catch (const std::exception& e)
76 {
77 qWarning() << "Failed to store package mapping for package '"
78 << QString::fromStdString(details.package.name)
79 << "', department '" << QString::fromStdString(details.department)
80 << "':" << QString::fromStdString(e.what());
81 }
82 }
83 else
84 {
85 qWarning() << "Department is empty for package" << QString::fromStdString(details.package.name);
86 }
87 }
88}
89
57// Preview base class90// Preview base class
5891
59Preview::Preview(const unity::scopes::Result& result,92Preview::Preview(const unity::scopes::Result& result,
@@ -84,7 +117,7 @@
84 << " and close_preview="117 << " and close_preview="
85 << metadict.count(click::Preview::Actions::CLOSE_PREVIEW);118 << metadict.count(click::Preview::Actions::CLOSE_PREVIEW);
86119
87 return new InstalledPreview(result, metadata, client);120 return new InstalledPreview(result, metadata, client, depts);
88 } else if (metadict.count("action_id") != 0 && metadict.count("download_url") != 0) {121 } else if (metadict.count("action_id") != 0 && metadict.count("download_url") != 0) {
89 std::string action_id = metadict["action_id"].get_string();122 std::string action_id = metadict["action_id"].get_string();
90 std::string download_url = metadict["download_url"].get_string();123 std::string download_url = metadict["download_url"].get_string();
@@ -93,17 +126,17 @@
93 } else {126 } else {
94 qWarning() << "unexpected action id " << QString::fromStdString(action_id)127 qWarning() << "unexpected action id " << QString::fromStdString(action_id)
95 << " given with download_url" << QString::fromStdString(download_url);128 << " given with download_url" << QString::fromStdString(download_url);
96 return new UninstalledPreview(result, client);129 return new UninstalledPreview(result, client, depts);
97 }130 }
98 } else if (metadict.count(click::Preview::Actions::UNINSTALL_CLICK) != 0) {131 } else if (metadict.count(click::Preview::Actions::UNINSTALL_CLICK) != 0) {
99 return new UninstallConfirmationPreview(result);132 return new UninstallConfirmationPreview(result);
100 } else if (metadict.count(click::Preview::Actions::CONFIRM_UNINSTALL) != 0) {133 } else if (metadict.count(click::Preview::Actions::CONFIRM_UNINSTALL) != 0) {
101 return new UninstallingPreview(result, client);134 return new UninstallingPreview(result, client);
102 } else if (metadict.count(click::Preview::Actions::RATED) != 0) {135 } else if (metadict.count(click::Preview::Actions::RATED) != 0) {
103 return new InstalledPreview(result, metadata, client);136 return new InstalledPreview(result, metadata, client, depts);
104 } else {137 } else {
105 qWarning() << "preview() called with unexpected metadata. returning uninstalled preview";138 qWarning() << "preview() called with unexpected metadata. returning uninstalled preview";
106 return new UninstalledPreview(result, client);139 return new UninstalledPreview(result, client, depts);
107 }140 }
108 } else {141 } else {
109 // metadata.scope_data() is Null, so we return an appropriate "default" preview:142 // metadata.scope_data() is Null, so we return an appropriate "default" preview:
@@ -112,9 +145,9 @@
112 return new InstalledScopePreview(result);145 return new InstalledScopePreview(result);
113 }146 }
114 if (result["installed"].get_bool() == true) {147 if (result["installed"].get_bool() == true) {
115 return new InstalledPreview(result, metadata, client);148 return new InstalledPreview(result, metadata, client, depts);
116 } else {149 } else {
117 return new UninstalledPreview(result, client);150 return new UninstalledPreview(result, client, depts);
118 }151 }
119 }152 }
120153
@@ -343,7 +376,6 @@
343 reply->push(downloadErrorWidgets());376 reply->push(downloadErrorWidgets());
344}377}
345378
346
347// class InstallingPreview379// class InstallingPreview
348380
349InstallingPreview::InstallingPreview(const std::string &download_url,381InstallingPreview::InstallingPreview(const std::string &download_url,
@@ -351,7 +383,8 @@
351 const QSharedPointer<click::web::Client>& client,383 const QSharedPointer<click::web::Client>& client,
352 const QSharedPointer<click::network::AccessManager> &nam,384 const QSharedPointer<click::network::AccessManager> &nam,
353 std::shared_ptr<click::DepartmentsDb> depts)385 std::shared_ptr<click::DepartmentsDb> depts)
354 : PreviewStrategy(result, client), download_url(download_url),386 : PreviewStrategy(result, client), DepartmentUpdater(depts),
387 download_url(download_url),
355 downloader(new click::Downloader(nam)),388 downloader(new click::Downloader(nam)),
356 depts_db(depts)389 depts_db(depts)
357{390{
@@ -390,7 +423,6 @@
390 qDebug() << "Successfully created UDM Download.";423 qDebug() << "Successfully created UDM Download.";
391 populateDetails([this, reply, object_path](const PackageDetails &details) {424 populateDetails([this, reply, object_path](const PackageDetails &details) {
392 store_department(details);425 store_department(details);
393
394 reply->push(headerWidgets(details));426 reply->push(headerWidgets(details));
395 reply->push(progressBarWidget(object_path));427 reply->push(progressBarWidget(object_path));
396 reply->push(descriptionWidgets(details));428 reply->push(descriptionWidgets(details));
@@ -410,38 +442,6 @@
410 });442 });
411}443}
412444
413void InstallingPreview::store_department(const PackageDetails& details)
414{
415 //
416 // store package -> department mapping in sqlite db
417 if (depts_db)
418 {
419 if (!details.department.empty())
420 {
421 try
422 {
423 depts_db->store_package_mapping(details.package.name, { details.department });
424 qDebug() << "Storing mapping for" << QString::fromStdString(details.package.name) << ":" << QString::fromStdString(details.department);
425 }
426 catch (const std::exception& e)
427 {
428 qWarning() << "Failed to store package mapping for package '"
429 << QString::fromStdString(details.package.name)
430 << "', department '" << QString::fromStdString(details.department)
431 << "':" << QString::fromStdString(e.what());
432 }
433 }
434 else
435 {
436 qWarning() << "Department is empty for package" << QString::fromStdString(details.package.name);
437 }
438 }
439 else
440 {
441 qWarning() << "Departments database not available";
442 }
443}
444
445scopes::PreviewWidgetList InstallingPreview::progressBarWidget(const std::string& object_path)445scopes::PreviewWidgetList InstallingPreview::progressBarWidget(const std::string& object_path)
446{446{
447 scopes::PreviewWidgetList widgets;447 scopes::PreviewWidgetList widgets;
@@ -455,13 +455,14 @@
455 return widgets;455 return widgets;
456}456}
457457
458
459// class InstalledPreview458// class InstalledPreview
460459
461InstalledPreview::InstalledPreview(const unity::scopes::Result& result,460InstalledPreview::InstalledPreview(const unity::scopes::Result& result,
462 const unity::scopes::ActionMetadata& metadata,461 const unity::scopes::ActionMetadata& metadata,
463 const QSharedPointer<click::web::Client>& client)462 const QSharedPointer<click::web::Client>& client,
463 const std::shared_ptr<click::DepartmentsDb>& depts)
464 : PreviewStrategy(result, client),464 : PreviewStrategy(result, client),
465 DepartmentUpdater(depts),
465 metadata(metadata)466 metadata(metadata)
466{467{
467}468}
@@ -524,6 +525,7 @@
524 }525 }
525 getApplicationUri(manifest, [this, reply, manifest, app_name, &review](const std::string& uri) {526 getApplicationUri(manifest, [this, reply, manifest, app_name, &review](const std::string& uri) {
526 populateDetails([this, reply, uri, manifest, app_name, &review](const PackageDetails &details){527 populateDetails([this, reply, uri, manifest, app_name, &review](const PackageDetails &details){
528 store_department(details);
527 reply->push(headerWidgets(details));529 reply->push(headerWidgets(details));
528 reply->push(createButtons(uri, manifest));530 reply->push(createButtons(uri, manifest));
529 reply->push(descriptionWidgets(details));531 reply->push(descriptionWidgets(details));
@@ -724,8 +726,10 @@
724// class UninstalledPreview726// class UninstalledPreview
725727
726UninstalledPreview::UninstalledPreview(const unity::scopes::Result& result,728UninstalledPreview::UninstalledPreview(const unity::scopes::Result& result,
727 const QSharedPointer<click::web::Client>& client)729 const QSharedPointer<click::web::Client>& client,
728 : PreviewStrategy(result, client)730 const std::shared_ptr<click::DepartmentsDb>& depts)
731 : PreviewStrategy(result, client),
732 DepartmentUpdater(depts)
729{733{
730}734}
731735
@@ -738,6 +742,7 @@
738qDebug() << "in UninstalledPreview::run, about to populate details";742qDebug() << "in UninstalledPreview::run, about to populate details";
739743
740 populateDetails([this, reply](const PackageDetails &details){744 populateDetails([this, reply](const PackageDetails &details){
745 store_department(details);
741 reply->push(headerWidgets(details));746 reply->push(headerWidgets(details));
742 reply->push(uninstalledActionButtonWidgets(details));747 reply->push(uninstalledActionButtonWidgets(details));
743 reply->push(descriptionWidgets(details));748 reply->push(descriptionWidgets(details));
@@ -787,7 +792,7 @@
787// TODO: this class should be removed once uninstall() is handled elsewhere.792// TODO: this class should be removed once uninstall() is handled elsewhere.
788UninstallingPreview::UninstallingPreview(const unity::scopes::Result& result,793UninstallingPreview::UninstallingPreview(const unity::scopes::Result& result,
789 const QSharedPointer<click::web::Client>& client)794 const QSharedPointer<click::web::Client>& client)
790 : UninstalledPreview(result, client)795 : UninstalledPreview(result, client, nullptr)
791{796{
792}797}
793UninstallingPreview::~UninstallingPreview()798UninstallingPreview::~UninstallingPreview()
794799
=== modified file 'libclickscope/click/preview.h'
--- libclickscope/click/preview.h 2014-07-15 14:34:53 +0000
+++ libclickscope/click/preview.h 2014-07-15 14:34:54 +0000
@@ -51,6 +51,17 @@
51class PreviewStrategy;51class PreviewStrategy;
52class DepartmentsDb;52class DepartmentsDb;
5353
54class DepartmentUpdater
55{
56protected:
57 DepartmentUpdater(const std::shared_ptr<click::DepartmentsDb>& depts);
58 virtual ~DepartmentUpdater() = default;
59 void store_department(const PackageDetails& pkg);
60
61private:
62 std::shared_ptr<click::DepartmentsDb> depts;
63};
64
54class Preview : public unity::scopes::PreviewQueryBase65class Preview : public unity::scopes::PreviewQueryBase
55{66{
56protected:67protected:
@@ -137,7 +148,7 @@
137 void run(unity::scopes::PreviewReplyProxy const& reply) override;148 void run(unity::scopes::PreviewReplyProxy const& reply) override;
138};149};
139150
140class InstallingPreview : public PreviewStrategy151class InstallingPreview : public PreviewStrategy, public DepartmentUpdater
141{152{
142public:153public:
143 InstallingPreview(std::string const& download_url,154 InstallingPreview(std::string const& download_url,
@@ -152,19 +163,19 @@
152163
153protected:164protected:
154 virtual scopes::PreviewWidgetList progressBarWidget(const std::string& object_path);165 virtual scopes::PreviewWidgetList progressBarWidget(const std::string& object_path);
155 void store_department(const PackageDetails& pkg);
156 std::string download_url;166 std::string download_url;
157 QSharedPointer<click::Downloader> downloader;167 QSharedPointer<click::Downloader> downloader;
158 std::shared_ptr<click::DepartmentsDb> depts_db;168 std::shared_ptr<click::DepartmentsDb> depts_db;
159 void startLauncherAnimation(const PackageDetails& details);169 void startLauncherAnimation(const PackageDetails& details);
160};170};
161171
162class InstalledPreview : public PreviewStrategy172class InstalledPreview : public PreviewStrategy, public DepartmentUpdater
163{173{
164public:174public:
165 InstalledPreview(const unity::scopes::Result& result,175 InstalledPreview(const unity::scopes::Result& result,
166 const unity::scopes::ActionMetadata& metadata,176 const unity::scopes::ActionMetadata& metadata,
167 const QSharedPointer<click::web::Client>& client);177 const QSharedPointer<click::web::Client>& client,
178 const std::shared_ptr<click::DepartmentsDb>& depts);
168179
169 virtual ~InstalledPreview();180 virtual ~InstalledPreview();
170181
@@ -210,11 +221,12 @@
210221
211};222};
212223
213class UninstalledPreview : public PreviewStrategy224class UninstalledPreview : public PreviewStrategy, public DepartmentUpdater
214{225{
215public:226public:
216 UninstalledPreview(const unity::scopes::Result& result,227 UninstalledPreview(const unity::scopes::Result& result,
217 const QSharedPointer<click::web::Client>& client);228 const QSharedPointer<click::web::Client>& client,
229 const std::shared_ptr<click::DepartmentsDb>& depts);
218230
219 virtual ~UninstalledPreview();231 virtual ~UninstalledPreview();
220232
221233
=== modified file 'scope/tests/test_query.cpp'
--- scope/tests/test_query.cpp 2014-07-15 14:34:53 +0000
+++ scope/tests/test_query.cpp 2014-07-15 14:34:54 +0000
@@ -109,7 +109,6 @@
109 const std::string &title,109 const std::string &title,
110 const std::string &icon,110 const std::string &icon,
111 const scopes::CategoryRenderer &renderer_template));111 const scopes::CategoryRenderer &renderer_template));
112 //MOCK_METHOD1(store_departments, void(const click::DepartmentList&));
113 using click::Query::get_installed_packages; // allow tests to access protected method112 using click::Query::get_installed_packages; // allow tests to access protected method
114};113};
115114
116115
=== modified file 'tools/init-departments/CMakeLists.txt'
--- tools/init-departments/CMakeLists.txt 2014-07-15 14:34:53 +0000
+++ tools/init-departments/CMakeLists.txt 2014-07-15 14:34:54 +0000
@@ -17,3 +17,5 @@
17target_link_libraries(${INITDEPTS}17target_link_libraries(${INITDEPTS}
18 ${SCOPE_LIB_NAME}18 ${SCOPE_LIB_NAME}
19 )19 )
20
21install(TARGETS ${INITDEPTS} DESTINATION sbin)

Subscribers

People subscribed via source and target branches

to all changes: