[banshee] [Banshee.Metrics] Send data to server if opted-in



commit 762363e847929afe553c5f5d638a870fdc002c92
Author: Gabriel Burt <gabriel burt gmail com>
Date:   Thu Feb 18 15:47:35 2010 -0800

    [Banshee.Metrics] Send data to server if opted-in
    
    Removes the requirement to pass --debug-metrics for sending to happen.

 .../Banshee.Metrics/BansheeMetrics.cs              |   23 +++++++++++++-------
 1 files changed, 15 insertions(+), 8 deletions(-)
---
diff --git a/src/Core/Banshee.Services/Banshee.Metrics/BansheeMetrics.cs b/src/Core/Banshee.Services/Banshee.Metrics/BansheeMetrics.cs
index a73c437..edb4b65 100644
--- a/src/Core/Banshee.Services/Banshee.Metrics/BansheeMetrics.cs
+++ b/src/Core/Banshee.Services/Banshee.Metrics/BansheeMetrics.cs
@@ -110,15 +110,22 @@ namespace Banshee.Metrics
                 handler ();
             }
 
-            // TODO schedule sending the data to the server in some timeout?
-
-            if (ApplicationContext.CommandLine.Contains ("debug-metrics")) {
-                Log.InformationFormat ("Anonymous usage data collected:\n{0}", metrics.ToJsonString ());
-                System.IO.File.WriteAllText ("usage-data.json", metrics.ToJsonString ());
+            Application.RunTimeout (5*1000, delegate {
+                if (BansheeMetrics.Instance == null) {
+                    return false;
+                }
 
-                var poster = new HttpPoster ("http://download.banshee-project.org/metrics/metrics.py";, metrics);
-                Log.InformationFormat ("Posted usage data? {0}", poster.Post ());
-            }
+                ThreadAssist.SpawnFromMain (delegate {
+                    if (ApplicationContext.CommandLine.Contains ("debug-metrics")) {
+                        Log.InformationFormat ("Anonymous usage data collected:\n{0}", metrics.ToJsonString ());
+                        System.IO.File.WriteAllText ("usage-data.json", metrics.ToJsonString ());
+                    }
+
+                    var poster = new HttpPoster ("http://download.banshee-project.org/metrics/metrics.py";, metrics);
+                    Log.InformationFormat ("Posted usage data? {0}", poster.Post ());
+                });
+                return false;
+            });
         }
 
         private void AddMetrics ()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]