Allow specifying the key file to load via an environment variable
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Thu, 22 Jul 2010 15:24:14 +0000 (16:24 +0100)
committerTravis Reitter <travis.reitter@collabora.co.uk>
Tue, 3 Aug 2010 14:23:12 +0000 (10:23 -0400)
backends/key-file/kf-backend.vala

index b5bf475..1fd3961 100644 (file)
@@ -52,9 +52,23 @@ public class Folks.Backends.Kf.Backend : Folks.Backend
 
   public override async void prepare ()
     {
-      File file = File.new_for_path (Environment.get_user_data_dir ());
-      file = file.get_child ("folks");
-      file = file.get_child ("relationships.ini");
+      File file;
+      string path = Environment.get_variable ("FOLKS_BACKEND_KEY_FILE_PATH");
+      if (path == null)
+        {
+          file = File.new_for_path (Environment.get_user_data_dir ());
+          file = file.get_child ("folks");
+          file = file.get_child ("relationships.ini");
+
+          debug ("Using built-in key file '%s' (override with environment " +
+              "variable FOLKS_BACKEND_KEY_FILE_PATH)", file.get_path ());
+        }
+      else
+        {
+          file = File.new_for_path (path);
+          debug ("Using environment variable FOLKS_BACKEND_KEY_FILE_PATH = '%s'"
+              + " to load the key file.", path);
+        }
 
       /* Create the PersonaStore for the key file */
       PersonaStore store = new Kf.PersonaStore (file);