← Back to team overview

zeitgeist team mailing list archive

[Branch ~zeitgeist/zeitgeist/bluebird] Rev 375: Implement find_storage_for_uri

 

Merge authors:
  Siegfried Gevatter (rainct)
Related merge proposals:
  https://code.launchpad.net/~rainct/zeitgeist/find_storage_for_uri/+merge/90423
  proposed by: Siegfried Gevatter (rainct)
  review: Approve - Michal Hruby (mhr3)
------------------------------------------------------------
revno: 375 [merge]
committer: Siegfried-Angel Gevatter Pujals <siegfried@xxxxxxxxxxxx>
branch nick: bluebird
timestamp: Fri 2012-01-27 14:34:18 +0100
message:
  Implement find_storage_for_uri
modified:
  extensions/storage-monitor.vala


--
lp:zeitgeist
https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird

Your team Zeitgeist Framework Team is subscribed to branch lp:zeitgeist.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'extensions/storage-monitor.vala'
--- extensions/storage-monitor.vala	2012-01-06 10:20:42 +0000
+++ extensions/storage-monitor.vala	2012-01-27 13:34:18 +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,28 @@
          */
         private string find_storage_for_uri (string uri)
         {
-            // FIXME
+            File file = File.new_for_uri (uri);
+            string uri_scheme = file.get_uri_scheme ();
+            /*
+            // FIXME: uncomment this once gvfs is our friend again
+            if (uri_scheme == "file")
+            {
+                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";
         }