Merge lp:~rainct/zeitgeist/find_storage_for_uri into lp:~zeitgeist/zeitgeist/bluebird

Proposed by Siegfried Gevatter
Status: Merged
Merged at revision: 375
Proposed branch: lp:~rainct/zeitgeist/find_storage_for_uri
Merge into: lp:~zeitgeist/zeitgeist/bluebird
Diff against target: 60 lines (+28/-2)
1 file modified
extensions/storage-monitor.vala (+28/-2)
To merge this branch: bzr merge lp:~rainct/zeitgeist/find_storage_for_uri
Reviewer Review Type Date Requested Status
Michal Hruby (community) Approve
Review via email: mp+90423@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michal Hruby (mhr3) wrote :

38 + string uri_scheme = uri.substring (0, uri.index_of ("://"));

There's File.get_uri_scheme() for that.

45 + Mount mount = file.find_enclosing_mount ();

I'm really worried here, it's bringing back gvfs and I dont like that one bit, can be disable it for now and just distinguish net vs unknown?

review: Needs Fixing
376. By Siegfried Gevatter

Remove the usage of gvfs (find_enclosing_mount) for now.

Revision history for this message
Michal Hruby (mhr3) wrote :

54 + else*/ if (uri_scheme in network_uri_schemes)

Would be nice to add a linebreak there, but otherwise fine...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'extensions/storage-monitor.vala'
2--- extensions/storage-monitor.vala 2012-01-06 10:20:42 +0000
3+++ extensions/storage-monitor.vala 2012-01-27 13:18:25 +0000
4@@ -3,6 +3,8 @@
5 * Copyright © 2011 Collabora Ltd.
6 * By Siegfried-Angel Gevatter Pujals <siegfried@gevatter.com>
7 * Copyright © 2011 Stefano Candori <stefano.candori@gmail.com>
8+ * Copyright © 2012 Canonical Ltd.
9+ * By Siegfried-A. Gevatter <siegfried.gevatter@collabora.co.uk>
10 *
11 * Based upon a Python implementation:
12 * Copyright © 2009 Mikkel Kamstrup Erlandsen <mikkel.kamstrup@gmail.com>
13@@ -91,7 +93,7 @@
14 * they reside in;
15 * - otherwise, the fixed identifier `unknown`.
16 *
17- * Subjects with storage `local` or `unwknown` are always considered as
18+ * Subjects with storage `local` or `unknown` are always considered as
19 * available; for network resources, the monitor will use either ConnMan
20 * or NetworkManager (whichever is available).
21 *
22@@ -100,6 +102,10 @@
23 */
24 class StorageMonitor: Extension, RemoteStorageMonitor
25 {
26+ private const string[] network_uri_schemes = {
27+ "dav", "davs", "ftp", "http", "https", "mailto",
28+ "sftp", "smb", "ssh" };
29+
30 private Zeitgeist.SQLite.ZeitgeistDatabase database;
31 private unowned Sqlite.Database db;
32 private uint registration_id;
33@@ -277,7 +283,27 @@
34 */
35 private string find_storage_for_uri (string uri)
36 {
37- // FIXME
38+ File file = File.new_for_uri (uri);
39+ string uri_scheme = file.get_uri_scheme ();
40+ /*
41+ // FIXME: uncomment this once gvfs is our friend again
42+ if (uri_scheme == "file")
43+ {
44+ try
45+ {
46+ Mount mount = file.find_enclosing_mount ();
47+ return get_volume_id (mount.get_volume ());
48+ }
49+ catch (Error err)
50+ {
51+ return "local";
52+ }
53+ }
54+ else*/ if (uri_scheme in network_uri_schemes)
55+ {
56+ return "net";
57+ }
58+
59 return "unknown";
60 }
61

Subscribers

People subscribed via source and target branches