zeitgeist team mailing list archive
-
zeitgeist team
-
Mailing list archive
-
Message #04595
[Merge] lp:~rainct/zeitgeist/find_storage_for_uri into lp:zeitgeist
Siegfried Gevatter has proposed merging lp:~rainct/zeitgeist/find_storage_for_uri into lp:zeitgeist.
Requested reviews:
Zeitgeist Framework Team (zeitgeist)
For more details, see:
https://code.launchpad.net/~rainct/zeitgeist/find_storage_for_uri/+merge/90423
--
https://code.launchpad.net/~rainct/zeitgeist/find_storage_for_uri/+merge/90423
Your team Zeitgeist Framework Team is requested to review the proposed merge of lp:~rainct/zeitgeist/find_storage_for_uri into lp:zeitgeist.
=== modified file 'extensions/storage-monitor.vala'
--- extensions/storage-monitor.vala 2012-01-06 10:20:42 +0000
+++ extensions/storage-monitor.vala 2012-01-27 12:55:28 +0000
@@ -3,6 +3,8 @@
* Copyright © 2011 Collabora Ltd.
* By Siegfried-Angel Gevatter Pujals <siegfried@xxxxxxxxxxxx>
* Copyright © 2011 Stefano Candori <stefano.candori@xxxxxxxxx>
+ * Copyright © 2012 Canonical Ltd.
+ * By Siegfried-A. Gevatter <siegfried.gevatter@xxxxxxxxxxxxxxx>
*
* Based upon a Python implementation:
* Copyright © 2009 Mikkel Kamstrup Erlandsen <mikkel.kamstrup@xxxxxxxxx>
@@ -91,7 +93,7 @@
* they reside in;
* - otherwise, the fixed identifier `unknown`.
*
- * Subjects with storage `local` or `unwknown` are always considered as
+ * Subjects with storage `local` or `unknown` are always considered as
* available; for network resources, the monitor will use either ConnMan
* or NetworkManager (whichever is available).
*
@@ -100,6 +102,10 @@
*/
class StorageMonitor: Extension, RemoteStorageMonitor
{
+ private const string[] network_uri_schemes = {
+ "dav", "davs", "ftp", "http", "https", "mailto",
+ "sftp", "smb", "ssh" };
+
private Zeitgeist.SQLite.ZeitgeistDatabase database;
private unowned Sqlite.Database db;
private uint registration_id;
@@ -277,7 +283,26 @@
*/
private string find_storage_for_uri (string uri)
{
- // FIXME
+ string uri_scheme = uri.substring (0, uri.index_of ("://"));
+ debug ("URI Scheme is: %s for %s", uri_scheme, uri);
+ if (uri_scheme == "file")
+ {
+ File file = File.new_for_uri (uri);
+ try
+ {
+ Mount mount = file.find_enclosing_mount ();
+ return get_volume_id (mount.get_volume ());
+ }
+ catch (Error err)
+ {
+ return "local";
+ }
+ }
+ else if (uri_scheme in network_uri_schemes)
+ {
+ return "net";
+ }
+
return "unknown";
}
Follow ups