Merge lp:~michihenning/storage-framework/remove-gio-dep into lp:storage-framework/devel

Proposed by Michi Henning
Status: Merged
Approved by: James Henstridge
Approved revision: 120
Merged at revision: 122
Proposed branch: lp:~michihenning/storage-framework/remove-gio-dep
Merge into: lp:storage-framework/devel
Diff against target: 331 lines (+45/-62)
9 files modified
CMakeLists.txt (+0/-1)
debian/changelog (+2/-1)
demo/provider_test/provider-test.cpp (+9/-9)
src/local-provider/CMakeLists.txt (+0/-2)
src/local-provider/LocalProvider.cpp (+17/-35)
src/local-provider/LocalProvider.h (+4/-0)
src/provider/internal/PendingJobs.cpp (+5/-0)
tests/local-provider/local-provider_test.cpp (+6/-13)
tests/registry/registry_test.cpp (+2/-1)
To merge this branch: bzr merge lp:~michihenning/storage-framework/remove-gio-dep
Reviewer Review Type Date Requested Status
James Henstridge Approve
unity-api-1-bot continuous-integration Approve
Review via email: mp+320762@code.launchpad.net

Commit message

Removed dependency on libgio by using QMimeDatabase to detect content type.
Fixed a bunch of compiler warnings on zesty.

Description of the change

Removed dependency on libgio by using QMimeDatabase to detect content type.
Fixed a bunch of compiler warnings on zesty.

To post a comment you must log in.
Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:119
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/270/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1857
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1864
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1640
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1640/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1640
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1640/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1640
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1640/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1640
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1640/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1640
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1640/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1640
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1640/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/270/rebuild

review: Approve (continuous-integration)
120. By Michi Henning

Merged devel and updated changelog.

Revision history for this message
unity-api-1-bot (unity-api-1-bot) wrote :

PASSED: Continuous integration, rev:120
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/272/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build/1882
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-0-fetch/1889
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1671
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=xenial+overlay/1671/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1671
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=amd64,release=zesty/1671/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1671
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=xenial+overlay/1671/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1671
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=armhf,release=zesty/1671/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1671
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=xenial+overlay/1671/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1671
        deb: https://jenkins.canonical.com/unity-api-1/job/build-2-binpkg/arch=i386,release=zesty/1671/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/unity-api-1/job/lp-storage-framework-ci/272/rebuild

review: Approve (continuous-integration)
Revision history for this message
James Henstridge (jamesh) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2017-03-29 05:53:32 +0000
3+++ CMakeLists.txt 2017-03-30 00:57:41 +0000
4@@ -123,7 +123,6 @@
5
6 include(FindPkgConfig)
7 pkg_check_modules(APPARMOR_DEPS REQUIRED libapparmor)
8-pkg_check_modules(GIO_DEPS REQUIRED gio-2.0 gio-unix-2.0)
9 pkg_check_modules(GLIB_DEPS REQUIRED glib-2.0)
10 pkg_check_modules(ONLINEACCOUNTS_DEPS REQUIRED OnlineAccountsQt)
11
12
13=== modified file 'debian/changelog'
14--- debian/changelog 2017-03-29 02:22:03 +0000
15+++ debian/changelog 2017-03-30 00:57:41 +0000
16@@ -1,6 +1,7 @@
17 storage-framework (0.4+17.04.20170320.1-0ubuntu2) UNRELEASED; urgency=medium
18
19- *
20+ [ Michi Henning ]
21+ * Removed dependency on libgio.
22
23 -- Michi Henning <michi.henning@canonical.com> Wed, 29 Mar 2017 12:21:40 +1000
24
25
26=== modified file 'demo/provider_test/provider-test.cpp'
27--- demo/provider_test/provider-test.cpp 2017-03-16 03:30:18 +0000
28+++ demo/provider_test/provider-test.cpp 2017-03-30 00:57:41 +0000
29@@ -99,7 +99,7 @@
30 {
31 }
32
33-boost::future<ItemList> MyProvider::roots(vector<string> const& keys, Context const& ctx)
34+boost::future<ItemList> MyProvider::roots(vector<string> const& /* keys */, Context const& ctx)
35 {
36 printf("roots() called by %s (%d)\n", ctx.security_label.c_str(), ctx.pid);
37 fflush(stdout);
38@@ -110,7 +110,7 @@
39 }
40
41 boost::future<tuple<ItemList,string>> MyProvider::list(
42- string const& item_id, string const& page_token, vector<string> const& keys,
43+ string const& item_id, string const& page_token, vector<string> const& /* keys */,
44 Context const& ctx)
45 {
46 printf("list('%s', '%s') called by %s (%d)\n", item_id.c_str(), page_token.c_str(), ctx.security_label.c_str(), ctx.pid);
47@@ -138,7 +138,7 @@
48 }
49
50 boost::future<ItemList> MyProvider::lookup(
51- string const& parent_id, string const& name, vector<string> const& keys, Context const& ctx)
52+ string const& parent_id, string const& name, vector<string> const& /* keys */, Context const& ctx)
53 {
54 printf("lookup('%s', '%s') called by %s (%d)\n", parent_id.c_str(), name.c_str(), ctx.security_label.c_str(), ctx.pid);
55 fflush(stdout);
56@@ -161,7 +161,7 @@
57 }
58
59 boost::future<Item> MyProvider::metadata(string const& item_id,
60- vector<string> const& keys,
61+ vector<string> const& /* keys */,
62 Context const& ctx)
63 {
64 printf("metadata('%s') called by %s (%d)\n", item_id.c_str(), ctx.security_label.c_str(), ctx.pid);
65@@ -189,7 +189,7 @@
66 }
67
68 boost::future<Item> MyProvider::create_folder(
69- string const& parent_id, string const& name, vector<string> const& keys,
70+ string const& parent_id, string const& name, vector<string> const& /* keys */,
71 Context const& ctx)
72 {
73 printf("create_folder('%s', '%s') called by %s (%d)\n", parent_id.c_str(), name.c_str(), ctx.security_label.c_str(), ctx.pid);
74@@ -206,7 +206,7 @@
75
76 boost::future<unique_ptr<UploadJob>> MyProvider::create_file(
77 string const& parent_id, string const& name,
78- int64_t size, string const& content_type, bool allow_overwrite, vector<string> const& keys,
79+ int64_t size, string const& content_type, bool allow_overwrite, vector<string> const& /* keys */,
80 Context const& ctx)
81 {
82 printf("create_file('%s', '%s', %" PRId64 ", '%s', %d) called by %s (%d)\n", parent_id.c_str(), name.c_str(), size, content_type.c_str(), allow_overwrite, ctx.security_label.c_str(), ctx.pid);
83@@ -215,7 +215,7 @@
84 }
85
86 boost::future<unique_ptr<UploadJob>> MyProvider::update(
87- string const& item_id, int64_t size, string const& old_etag, vector<string> const& keys, Context const& ctx)
88+ string const& item_id, int64_t size, string const& old_etag, vector<string> const& /* keys */, Context const& ctx)
89 {
90 printf("update('%s', %" PRId64 ", '%s') called by %s (%d)\n", item_id.c_str(), size, old_etag.c_str(), ctx.security_label.c_str(), ctx.pid);
91 fflush(stdout);
92@@ -250,7 +250,7 @@
93
94 boost::future<Item> MyProvider::move(
95 string const& item_id, string const& new_parent_id,
96- string const& new_name, vector<string> const& keys, Context const& ctx)
97+ string const& new_name, vector<string> const& /* keys */, Context const& ctx)
98 {
99 printf("move('%s', '%s', '%s') called by %s (%d)\n", item_id.c_str(), new_parent_id.c_str(), new_name.c_str(), ctx.security_label.c_str(), ctx.pid);
100 fflush(stdout);
101@@ -260,7 +260,7 @@
102
103 boost::future<Item> MyProvider::copy(
104 string const& item_id, string const& new_parent_id,
105- string const& new_name, vector<string> const& keys, Context const& ctx)
106+ string const& new_name, vector<string> const& /* keys */, Context const& ctx)
107 {
108 printf("copy('%s', '%s', '%s') called by %s (%d)\n", item_id.c_str(), new_parent_id.c_str(), new_name.c_str(), ctx.security_label.c_str(), ctx.pid);
109 fflush(stdout);
110
111=== modified file 'src/local-provider/CMakeLists.txt'
112--- src/local-provider/CMakeLists.txt 2017-03-17 04:59:44 +0000
113+++ src/local-provider/CMakeLists.txt 2017-03-30 00:57:41 +0000
114@@ -10,7 +10,6 @@
115 target_include_directories(local-provider-lib PRIVATE
116 ${Qt5Network_INCLUDE_DIRS}
117 ${GLIB_DEPS_INCLUDE_DIRS}
118- ${GIO_DEPS_INCLUDE_DIRS}
119 )
120
121 set_target_properties(local-provider-lib PROPERTIES
122@@ -27,7 +26,6 @@
123 storage-framework-provider
124 Qt5::Network
125 ${GLIB_DEPS_LIBRARIES}
126- ${GIO_DEPS_LIBRARIES}
127 )
128
129 install(
130
131=== modified file 'src/local-provider/LocalProvider.cpp'
132--- src/local-provider/LocalProvider.cpp 2017-03-17 04:59:44 +0000
133+++ src/local-provider/LocalProvider.cpp 2017-03-30 00:57:41 +0000
134@@ -27,12 +27,6 @@
135
136 #include <boost/algorithm/string.hpp>
137
138-#pragma GCC diagnostic push
139-#pragma GCC diagnostic ignored "-Wold-style-cast"
140-#include <gio/gio.h>
141-#include <glib.h>
142-#pragma GCC diagnostic pop
143-
144 using namespace unity::storage::provider;
145 using namespace std;
146
147@@ -141,34 +135,6 @@
148 return buf;
149 }
150
151-string get_content_type(string const& filename)
152-{
153- using namespace unity::storage::internal;
154-
155- static string const unknown_content_type = "application/octet-stream";
156-
157- gobj_ptr<GFile> file(g_file_new_for_path(filename.c_str()));
158- assert(file); // Cannot fail according to doc.
159-
160- GError* err = nullptr;
161- gobj_ptr<GFileInfo> full_info(g_file_query_info(file.get(),
162- G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE,
163- G_FILE_QUERY_INFO_NONE,
164- /* cancellable */ NULL,
165- &err));
166- if (!full_info)
167- {
168- return unknown_content_type; // LCOV_EXCL_LINE
169- }
170-
171- string content_type = g_file_info_get_attribute_string(full_info.get(), G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE);
172- if (content_type.empty())
173- {
174- return unknown_content_type; // LCOV_EXCL_LINE
175- }
176- return content_type;
177-}
178-
179 // Simple wrapper template that deals with exception handling so we don't
180 // have to repeat ourselves endlessly in the various lambdas below.
181 // The auto deduction of the return type requires C++ 14.
182@@ -568,7 +534,7 @@
183 meta.insert({USED_SPACE_BYTES, int64_t(info.capacity - info.available)});
184
185 meta.insert({LAST_MODIFIED_TIME, iso_mtime});
186- meta.insert({CONTENT_TYPE, get_content_type(item_id)});
187+ meta.insert({CONTENT_TYPE, get_content_type(item_id, type)});
188
189 auto perms = st.permissions();
190 bool writable;
191@@ -584,3 +550,19 @@
192
193 return Item{ item_id, parents, name, etag, type, meta };
194 }
195+
196+string LocalProvider::get_content_type(string const& filename, unity::storage::ItemType type) const
197+{
198+ if (type != unity::storage::ItemType::file)
199+ {
200+ return "inode/directory";
201+ }
202+
203+ auto mime_type = mime_db_.mimeTypeForFile(QString::fromStdString(filename), QMimeDatabase::MatchExtension);
204+ if (!mime_type.isValid())
205+ {
206+ return "application/octet-stream"; // LCOV_EXCL_LINE
207+ }
208+
209+ return mime_type.name().toStdString();
210+}
211
212=== modified file 'src/local-provider/LocalProvider.h'
213--- src/local-provider/LocalProvider.h 2017-03-14 07:11:40 +0000
214+++ src/local-provider/LocalProvider.h 2017-03-30 00:57:41 +0000
215@@ -21,6 +21,7 @@
216 #include <unity/storage/provider/ProviderBase.h>
217
218 #include <boost/filesystem.hpp>
219+#include <QMimeDatabase>
220
221 class LocalProvider : public unity::storage::provider::ProviderBase
222 {
223@@ -80,5 +81,8 @@
224 boost::filesystem::file_status const& st) const;
225
226 private:
227+ std::string get_content_type(std::string const& filename, unity::storage::ItemType type) const;
228+
229 boost::filesystem::path const root_;
230+ QMimeDatabase mime_db_;
231 };
232
233=== modified file 'src/provider/internal/PendingJobs.cpp'
234--- src/provider/internal/PendingJobs.cpp 2016-09-06 04:41:17 +0000
235+++ src/provider/internal/PendingJobs.cpp 2017-03-30 00:57:41 +0000
236@@ -175,6 +175,9 @@
237 }
238 }
239
240+#pragma GCC diagnostic push
241+#pragma GCC diagnostic ignored "-Wattributes"
242+
243 template<typename Job>
244 void PendingJobs::cancel_job(shared_ptr<Job> const& job, string const& identifier)
245 {
246@@ -203,6 +206,8 @@
247 });
248 }
249
250+#pragma GCC diagnostic pop
251+
252 }
253 }
254 }
255
256=== modified file 'tests/local-provider/local-provider_test.cpp'
257--- tests/local-provider/local-provider_test.cpp 2017-03-17 07:06:29 +0000
258+++ tests/local-provider/local-provider_test.cpp 2017-03-30 00:57:41 +0000
259@@ -259,12 +259,12 @@
260 ASSERT_EQ(5, root.metadata().size());
261 auto free_space_bytes = root.metadata().value("free_space_bytes").toULongLong();
262 cout << "free_space_bytes: " << free_space_bytes << endl;
263- EXPECT_GT(free_space_bytes, 0);
264+ EXPECT_GT(free_space_bytes, uint64_t(0));
265 auto used_space_bytes = root.metadata().value("used_space_bytes").toULongLong();
266 cout << "used_space_bytes: " << used_space_bytes << endl;
267- EXPECT_GT(used_space_bytes, 0);
268+ EXPECT_GT(used_space_bytes, uint64_t(0));
269 auto content_type = root.metadata().value("content_type").toString();
270- EXPECT_EQ("inode/directory", content_type);
271+ EXPECT_EQ("inode/directory", content_type.toStdString());
272 auto writable = root.metadata().value("writable").toBool();
273 EXPECT_TRUE(writable);
274
275@@ -336,7 +336,7 @@
276 Item child = job->item();
277 unique_ptr<VoidJob> delete_job(child.deleteItem());
278 wait(delete_job.get());
279- ASSERT_EQ(ItemJob::Finished, delete_job->status()) << delete_job->error().errorString().toStdString();
280+ ASSERT_EQ(VoidJob::Finished, delete_job->status()) << delete_job->error().errorString().toStdString();
281
282 struct stat st;
283 ASSERT_EQ(-1, stat(child.itemId().toStdString().c_str(), &st));
284@@ -383,7 +383,7 @@
285
286 auto fut = p->metadata(ROOT_DIR(), {}, provider::Context());
287 auto item = fut.get();
288- EXPECT_EQ(5, item.metadata.size());
289+ EXPECT_EQ(uint64_t(5), item.metadata.size());
290
291 // Again, to get coverage for the "not file or folder" case in make_item().
292 ASSERT_EQ(0, mknod((ROOT_DIR() + "/pipe").c_str(), S_IFIFO | 06666, 0));
293@@ -431,7 +431,7 @@
294
295 job.reset(root.lookup("child"));
296 wait(job.get());
297- EXPECT_EQ(ItemJob::Error, job->status());
298+ EXPECT_EQ(ItemListJob::Error, job->status());
299 EXPECT_EQ(string("NotExists: lookup(): \"") + ROOT_DIR() + "/child\": boost::filesystem::canonical: "
300 + "No such file or directory: \"" + ROOT_DIR() + "/child\"",
301 job->error().errorString().toStdString());
302@@ -1456,13 +1456,6 @@
303 {
304 setenv("LANG", "C", true);
305
306- // Test test fixture repeatedly creates and tears down the dbus connection.
307- // The provider calls g_file_new_for_path() which talks to the GVfs backend
308- // via dbus. If the dbus connection disappears, that causes GIO to send a
309- // a SIGTERM, killing the test.
310- // Setting GIO_USE_VFS variable to "local" disables sending the signal.
311- setenv("GIO_USE_VFS", "local", true);
312-
313 QCoreApplication app(argc, argv);
314
315 ::testing::InitGoogleTest(&argc, argv);
316
317=== modified file 'tests/registry/registry_test.cpp'
318--- tests/registry/registry_test.cpp 2017-03-17 09:43:46 +0000
319+++ tests/registry/registry_test.cpp 2017-03-30 00:57:41 +0000
320@@ -27,9 +27,10 @@
321
322 #pragma GCC diagnostic push
323 #pragma GCC diagnostic ignored "-Wold-style-cast"
324+#pragma GCC diagnostic ignored "-Wctor-dtor-privacy"
325 #include <glib.h>
326+#include <gtest/gtest.h>
327 #pragma GCC diagnostic pop
328-#include <gtest/gtest.h>
329 #include <QCoreApplication>
330 #include <QDBusConnection>
331 #include <QDBusMessage>

Subscribers

People subscribed via source and target branches

to all changes: