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
1=== modified file 'data/CMakeLists.txt'
2--- data/CMakeLists.txt 2014-07-04 13:10:05 +0000
3+++ data/CMakeLists.txt 2014-07-15 14:34:54 +0000
4@@ -14,6 +14,11 @@
5 ${APPS_INI_TARGET}.in
6 )
7
8+# upstart job for default departments db
9+set(DEPARTMENTS_UPSTART_JOB click-scope-departments-db.conf)
10+configure_file(${DEPARTMENTS_UPSTART_JOB}.in ${DEPARTMENTS_UPSTART_JOB} @ONLY)
11+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DEPARTMENTS_UPSTART_JOB} DESTINATION ${CMAKE_INSTALL_DATADIR}/upstart/sessions)
12+
13 add_custom_target(${STORE_INI_TARGET} ALL
14 COMMENT "Merging translations into ${STORE_INI_TARGET}"
15 COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${STORE_INI_TARGET}.in ${STORE_INI_TARGET} >/dev/null
16@@ -35,6 +40,11 @@
17 )
18
19 install(
20+ FILES departments.db
21+ DESTINATION "${APPS_DATA_DIR}"
22+)
23+
24+install(
25 FILES "${CMAKE_CURRENT_BINARY_DIR}/${STORE_INI_TARGET}"
26 DESTINATION "${STORE_LIB_DIR}"
27 )
28
29=== added file 'data/click-scope-departments-db.conf.in'
30--- data/click-scope-departments-db.conf.in 1970-01-01 00:00:00 +0000
31+++ data/click-scope-departments-db.conf.in 2014-07-15 14:34:54 +0000
32@@ -0,0 +1,9 @@
33+description "Default Click Departments Database"
34+author "Pawel Stolowski <pawel.stolowski@canonical.com>"
35+
36+start on starting unity8
37+
38+script
39+ DB_FILE=@APPS_DATA_DIR@/departments.db
40+ [ -f $HOME/.cache/click-departments.db ] || cp $DB_FILE $HOME/.cache/click-departments.db
41+end script
42
43=== added file 'data/departments.db'
44Binary files data/departments.db 1970-01-01 00:00:00 +0000 and data/departments.db 2014-07-15 14:34:54 +0000 differ
45=== modified file 'debian/control'
46--- debian/control 2014-07-11 21:56:59 +0000
47+++ debian/control 2014-07-15 14:34:54 +0000
48@@ -30,7 +30,8 @@
49 ubuntu-app-launch-tools,
50 ubuntu-download-manager,
51 ubuntu-sdk-libs,
52- sqlite3 (>= 3.8.5),
53+ libsqlite3-0 (>= 3.8.5),
54+ unity-scope-click-departmentsdb (= ${binary:Version}),
55 ${misc:Depends},
56 ${shlibs:Depends},
57 Breaks: unity (<< 7.0),
58@@ -41,6 +42,30 @@
59 .
60 This package provides the click scope.
61
62+Package: unity-scope-click-init-departments
63+Architecture: armhf i386 amd64
64+Depends: libsqlite3-0 (>= 3.8.5),
65+ ${misc:Depends},
66+ ${shlibs:Depends},
67+Breaks: unity (<< 7.0),
68+Description: Click Scope Utility for Initialization of Departments
69+ The click scope init-departments initializes or updates the internal database
70+ of departments for installed applications. This tool is for click scope developers
71+ and for customizations of ubuntu-touch image. It's not meant to be used by end users.
72+ .
73+ This package provides the helper init-departments tool.
74+
75+Package: unity-scope-click-departmentsdb
76+Architecture: all
77+Depends: ${misc:Depends},
78+ ${shlibs:Depends},
79+Breaks: unity (<< 7.0),
80+Description: Click Scope Departments Database
81+ The click scope departments database provide the initial departments data for
82+ preinstalled (default) applications.
83+ .
84+ This package provides departments database for preinstalled applications.
85+
86 Package: unity-scope-click-autopilot
87 Architecture: all
88 Depends: libautopilot-qt (>= 1.4),
89
90=== added file 'debian/unity-scope-click-departmentsdb.install'
91--- debian/unity-scope-click-departmentsdb.install 1970-01-01 00:00:00 +0000
92+++ debian/unity-scope-click-departmentsdb.install 2014-07-15 14:34:54 +0000
93@@ -0,0 +1,2 @@
94+usr/share/unity/scopes/clickapps/departments.db
95+usr/share/upstart/sessions/*.conf
96
97=== added file 'debian/unity-scope-click-init-departments.install'
98--- debian/unity-scope-click-init-departments.install 1970-01-01 00:00:00 +0000
99+++ debian/unity-scope-click-init-departments.install 2014-07-15 14:34:54 +0000
100@@ -0,0 +1,1 @@
101+usr/sbin/init-departments
102
103=== modified file 'debian/unity-scope-click.install'
104--- debian/unity-scope-click.install 2014-07-07 10:32:36 +0000
105+++ debian/unity-scope-click.install 2014-07-15 14:34:54 +0000
106@@ -1,5 +1,7 @@
107 usr/lib/*/unity-scopes/*
108 usr/lib/unity-scope-click/*
109-usr/share/unity/scopes/*
110+usr/share/unity/scopes/clickstore/*
111+usr/share/unity/scopes/clickapps/*jpg
112+usr/share/unity/scopes/clickapps/*svg
113 usr/share/glib-2.0/schemas/*
114 usr/share/locale/*/LC_MESSAGES/unity-scope-click.mo
115
116=== modified file 'libclickscope/click/preview.cpp'
117--- libclickscope/click/preview.cpp 2014-07-15 14:34:53 +0000
118+++ libclickscope/click/preview.cpp 2014-07-15 14:34:54 +0000
119@@ -54,6 +54,39 @@
120
121 namespace click {
122
123+DepartmentUpdater::DepartmentUpdater(const std::shared_ptr<click::DepartmentsDb>& depts)
124+ : depts(depts)
125+{
126+}
127+
128+void DepartmentUpdater::store_department(const PackageDetails& details)
129+{
130+ //
131+ // store package -> department mapping in sqlite db
132+ if (depts)
133+ {
134+ if (!details.department.empty())
135+ {
136+ try
137+ {
138+ depts->store_package_mapping(details.package.name, details.department);
139+ qDebug() << "Storing mapping for" << QString::fromStdString(details.package.name) << ":" << QString::fromStdString(details.department);
140+ }
141+ catch (const std::exception& e)
142+ {
143+ qWarning() << "Failed to store package mapping for package '"
144+ << QString::fromStdString(details.package.name)
145+ << "', department '" << QString::fromStdString(details.department)
146+ << "':" << QString::fromStdString(e.what());
147+ }
148+ }
149+ else
150+ {
151+ qWarning() << "Department is empty for package" << QString::fromStdString(details.package.name);
152+ }
153+ }
154+}
155+
156 // Preview base class
157
158 Preview::Preview(const unity::scopes::Result& result,
159@@ -84,7 +117,7 @@
160 << " and close_preview="
161 << metadict.count(click::Preview::Actions::CLOSE_PREVIEW);
162
163- return new InstalledPreview(result, metadata, client);
164+ return new InstalledPreview(result, metadata, client, depts);
165 } else if (metadict.count("action_id") != 0 && metadict.count("download_url") != 0) {
166 std::string action_id = metadict["action_id"].get_string();
167 std::string download_url = metadict["download_url"].get_string();
168@@ -93,17 +126,17 @@
169 } else {
170 qWarning() << "unexpected action id " << QString::fromStdString(action_id)
171 << " given with download_url" << QString::fromStdString(download_url);
172- return new UninstalledPreview(result, client);
173+ return new UninstalledPreview(result, client, depts);
174 }
175 } else if (metadict.count(click::Preview::Actions::UNINSTALL_CLICK) != 0) {
176 return new UninstallConfirmationPreview(result);
177 } else if (metadict.count(click::Preview::Actions::CONFIRM_UNINSTALL) != 0) {
178 return new UninstallingPreview(result, client);
179 } else if (metadict.count(click::Preview::Actions::RATED) != 0) {
180- return new InstalledPreview(result, metadata, client);
181+ return new InstalledPreview(result, metadata, client, depts);
182 } else {
183 qWarning() << "preview() called with unexpected metadata. returning uninstalled preview";
184- return new UninstalledPreview(result, client);
185+ return new UninstalledPreview(result, client, depts);
186 }
187 } else {
188 // metadata.scope_data() is Null, so we return an appropriate "default" preview:
189@@ -112,9 +145,9 @@
190 return new InstalledScopePreview(result);
191 }
192 if (result["installed"].get_bool() == true) {
193- return new InstalledPreview(result, metadata, client);
194+ return new InstalledPreview(result, metadata, client, depts);
195 } else {
196- return new UninstalledPreview(result, client);
197+ return new UninstalledPreview(result, client, depts);
198 }
199 }
200
201@@ -343,7 +376,6 @@
202 reply->push(downloadErrorWidgets());
203 }
204
205-
206 // class InstallingPreview
207
208 InstallingPreview::InstallingPreview(const std::string &download_url,
209@@ -351,7 +383,8 @@
210 const QSharedPointer<click::web::Client>& client,
211 const QSharedPointer<click::network::AccessManager> &nam,
212 std::shared_ptr<click::DepartmentsDb> depts)
213- : PreviewStrategy(result, client), download_url(download_url),
214+ : PreviewStrategy(result, client), DepartmentUpdater(depts),
215+ download_url(download_url),
216 downloader(new click::Downloader(nam)),
217 depts_db(depts)
218 {
219@@ -390,7 +423,6 @@
220 qDebug() << "Successfully created UDM Download.";
221 populateDetails([this, reply, object_path](const PackageDetails &details) {
222 store_department(details);
223-
224 reply->push(headerWidgets(details));
225 reply->push(progressBarWidget(object_path));
226 reply->push(descriptionWidgets(details));
227@@ -410,38 +442,6 @@
228 });
229 }
230
231-void InstallingPreview::store_department(const PackageDetails& details)
232-{
233- //
234- // store package -> department mapping in sqlite db
235- if (depts_db)
236- {
237- if (!details.department.empty())
238- {
239- try
240- {
241- depts_db->store_package_mapping(details.package.name, { details.department });
242- qDebug() << "Storing mapping for" << QString::fromStdString(details.package.name) << ":" << QString::fromStdString(details.department);
243- }
244- catch (const std::exception& e)
245- {
246- qWarning() << "Failed to store package mapping for package '"
247- << QString::fromStdString(details.package.name)
248- << "', department '" << QString::fromStdString(details.department)
249- << "':" << QString::fromStdString(e.what());
250- }
251- }
252- else
253- {
254- qWarning() << "Department is empty for package" << QString::fromStdString(details.package.name);
255- }
256- }
257- else
258- {
259- qWarning() << "Departments database not available";
260- }
261-}
262-
263 scopes::PreviewWidgetList InstallingPreview::progressBarWidget(const std::string& object_path)
264 {
265 scopes::PreviewWidgetList widgets;
266@@ -455,13 +455,14 @@
267 return widgets;
268 }
269
270-
271 // class InstalledPreview
272
273 InstalledPreview::InstalledPreview(const unity::scopes::Result& result,
274 const unity::scopes::ActionMetadata& metadata,
275- const QSharedPointer<click::web::Client>& client)
276+ const QSharedPointer<click::web::Client>& client,
277+ const std::shared_ptr<click::DepartmentsDb>& depts)
278 : PreviewStrategy(result, client),
279+ DepartmentUpdater(depts),
280 metadata(metadata)
281 {
282 }
283@@ -524,6 +525,7 @@
284 }
285 getApplicationUri(manifest, [this, reply, manifest, app_name, &review](const std::string& uri) {
286 populateDetails([this, reply, uri, manifest, app_name, &review](const PackageDetails &details){
287+ store_department(details);
288 reply->push(headerWidgets(details));
289 reply->push(createButtons(uri, manifest));
290 reply->push(descriptionWidgets(details));
291@@ -724,8 +726,10 @@
292 // class UninstalledPreview
293
294 UninstalledPreview::UninstalledPreview(const unity::scopes::Result& result,
295- const QSharedPointer<click::web::Client>& client)
296- : PreviewStrategy(result, client)
297+ const QSharedPointer<click::web::Client>& client,
298+ const std::shared_ptr<click::DepartmentsDb>& depts)
299+ : PreviewStrategy(result, client),
300+ DepartmentUpdater(depts)
301 {
302 }
303
304@@ -738,6 +742,7 @@
305 qDebug() << "in UninstalledPreview::run, about to populate details";
306
307 populateDetails([this, reply](const PackageDetails &details){
308+ store_department(details);
309 reply->push(headerWidgets(details));
310 reply->push(uninstalledActionButtonWidgets(details));
311 reply->push(descriptionWidgets(details));
312@@ -787,7 +792,7 @@
313 // TODO: this class should be removed once uninstall() is handled elsewhere.
314 UninstallingPreview::UninstallingPreview(const unity::scopes::Result& result,
315 const QSharedPointer<click::web::Client>& client)
316- : UninstalledPreview(result, client)
317+ : UninstalledPreview(result, client, nullptr)
318 {
319 }
320 UninstallingPreview::~UninstallingPreview()
321
322=== modified file 'libclickscope/click/preview.h'
323--- libclickscope/click/preview.h 2014-07-15 14:34:53 +0000
324+++ libclickscope/click/preview.h 2014-07-15 14:34:54 +0000
325@@ -51,6 +51,17 @@
326 class PreviewStrategy;
327 class DepartmentsDb;
328
329+class DepartmentUpdater
330+{
331+protected:
332+ DepartmentUpdater(const std::shared_ptr<click::DepartmentsDb>& depts);
333+ virtual ~DepartmentUpdater() = default;
334+ void store_department(const PackageDetails& pkg);
335+
336+private:
337+ std::shared_ptr<click::DepartmentsDb> depts;
338+};
339+
340 class Preview : public unity::scopes::PreviewQueryBase
341 {
342 protected:
343@@ -137,7 +148,7 @@
344 void run(unity::scopes::PreviewReplyProxy const& reply) override;
345 };
346
347-class InstallingPreview : public PreviewStrategy
348+class InstallingPreview : public PreviewStrategy, public DepartmentUpdater
349 {
350 public:
351 InstallingPreview(std::string const& download_url,
352@@ -152,19 +163,19 @@
353
354 protected:
355 virtual scopes::PreviewWidgetList progressBarWidget(const std::string& object_path);
356- void store_department(const PackageDetails& pkg);
357 std::string download_url;
358 QSharedPointer<click::Downloader> downloader;
359 std::shared_ptr<click::DepartmentsDb> depts_db;
360 void startLauncherAnimation(const PackageDetails& details);
361 };
362
363-class InstalledPreview : public PreviewStrategy
364+class InstalledPreview : public PreviewStrategy, public DepartmentUpdater
365 {
366 public:
367 InstalledPreview(const unity::scopes::Result& result,
368 const unity::scopes::ActionMetadata& metadata,
369- const QSharedPointer<click::web::Client>& client);
370+ const QSharedPointer<click::web::Client>& client,
371+ const std::shared_ptr<click::DepartmentsDb>& depts);
372
373 virtual ~InstalledPreview();
374
375@@ -210,11 +221,12 @@
376
377 };
378
379-class UninstalledPreview : public PreviewStrategy
380+class UninstalledPreview : public PreviewStrategy, public DepartmentUpdater
381 {
382 public:
383 UninstalledPreview(const unity::scopes::Result& result,
384- const QSharedPointer<click::web::Client>& client);
385+ const QSharedPointer<click::web::Client>& client,
386+ const std::shared_ptr<click::DepartmentsDb>& depts);
387
388 virtual ~UninstalledPreview();
389
390
391=== modified file 'scope/tests/test_query.cpp'
392--- scope/tests/test_query.cpp 2014-07-15 14:34:53 +0000
393+++ scope/tests/test_query.cpp 2014-07-15 14:34:54 +0000
394@@ -109,7 +109,6 @@
395 const std::string &title,
396 const std::string &icon,
397 const scopes::CategoryRenderer &renderer_template));
398- //MOCK_METHOD1(store_departments, void(const click::DepartmentList&));
399 using click::Query::get_installed_packages; // allow tests to access protected method
400 };
401
402
403=== modified file 'tools/init-departments/CMakeLists.txt'
404--- tools/init-departments/CMakeLists.txt 2014-07-15 14:34:53 +0000
405+++ tools/init-departments/CMakeLists.txt 2014-07-15 14:34:54 +0000
406@@ -17,3 +17,5 @@
407 target_link_libraries(${INITDEPTS}
408 ${SCOPE_LIB_NAME}
409 )
410+
411+install(TARGETS ${INITDEPTS} DESTINATION sbin)

Subscribers

People subscribed via source and target branches

to all changes: