← Back to team overview

zeitgeist team mailing list archive

[Branch ~zeitgeist/zeitgeist/bluebird] Rev 295: Don't overuse Variants if we can just use a struct

 

------------------------------------------------------------
revno: 295
committer: Michal Hruby <michal.mhr@xxxxxxxxx>
branch nick: bb-fts
timestamp: Tue 2011-10-11 12:18:06 +0200
message:
  Don't overuse Variants if we can just use a struct
modified:
  src/remote.vala
  src/zeitgeist-daemon.vala


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

Your team Zeitgeist Framework Team is subscribed to branch lp:~zeitgeist/zeitgeist/bluebird.
To unsubscribe from this branch go to https://code.launchpad.net/~zeitgeist/zeitgeist/bluebird/+edit-subscription
=== modified file 'src/remote.vala'
--- src/remote.vala	2011-10-09 15:54:56 +0000
+++ src/remote.vala	2011-10-11 10:18:06 +0000
@@ -21,6 +21,12 @@
 
 namespace Zeitgeist
 {
+    public struct VersionStruct
+    {
+        int major;
+        int minor;
+        int micro;
+    }
 
     [DBus (name = "org.gnome.zeitgeist.Log")]
     public interface RemoteLog : Object
@@ -86,8 +92,8 @@
         [DBus (name = "extensions")]
         public abstract string[] extensions { owned get; }
 
-        [DBus (signature = "iii", name = "version")]
-        public abstract Variant version { owned get; }
+        [DBus (name = "version")]
+        public abstract VersionStruct version { owned get; }
 
     }
 

=== modified file 'src/zeitgeist-daemon.vala'
--- src/zeitgeist-daemon.vala	2011-10-09 10:42:33 +0000
+++ src/zeitgeist-daemon.vala	2011-10-11 10:18:06 +0000
@@ -88,26 +88,26 @@
             }
         }
 
-        public Variant version
+        public VersionStruct version
         {
             owned get
             {
-                var vb = new VariantBuilder (new VariantType ("(iii)"));
+                var s = VersionStruct ();
                 string[] ver = Config.VERSION.split (".");
                 if (ver.length >= 3)
                 {
-                    vb.add ("i", int.parse (ver[0]));
-                    vb.add ("i", int.parse (ver[1]));
-                    vb.add ("i", int.parse (ver[2]));
+                    s.major = int.parse (ver[0]);
+                    s.minor = int.parse (ver[1]);
+                    s.micro = int.parse (ver[2]);
                 }
                 else
                 {
                     warning ("Unable to parse version info!");
-                    vb.add ("i", 0);
-                    vb.add ("i", 8);
-                    vb.add ("i", 99);
+                    s.major = 0;
+                    s.minor = 8;
+                    s.micro = 99;
                 }
-                return vb.end ();
+                return s;
             }
         }