[Lunar-commits] <lconnman> connmanmanager.vala: change iteration of hashtable

Samuel samuel.verstraete at gmail.com
Thu Aug 18 09:27:41 CEST 2011


commit c460b5491300c10b0d0cbf7e36fe66fc5e39b5a7
Author: Samuel <samuel.verstraete at gmail.com>
Date:   Thu Aug 18 09:27:41 2011 +0200

    connmanmanager.vala: change iteration of hashtable
---
 src/connmanmanager.vala |   22 ++++++++--------------
 1 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/connmanmanager.vala b/src/connmanmanager.vala
index af6c069..42ae1f5 100644
--- a/src/connmanmanager.vala
+++ b/src/connmanmanager.vala
@@ -5,8 +5,8 @@ interface ConnmanManager : Object {
 }
 
 public struct Service {
-  public GLib.ObjectPath first;
-  public GLib.HashTable<string, Variant> second;
+  public GLib.ObjectPath ServicePath;
+  public GLib.HashTable<string, Variant> ServiceProperties;
 }
 
 ConnmanManager connmanManager;
@@ -46,19 +46,13 @@ public static Service[] get_services() {
 
 public string print_service(Service service) {
   StringBuilder result = new StringBuilder();
-  result.append("Name: " + service.first.to_string() + "\n");
-//  List<string> keys = service.second.get_keys();
-//  List<Variant> values = service.second.get_values();
+  result.append("ServicePath: " + service.ServicePath.to_string() + "\n");
 
-  foreach (var key in service.second.get_keys()) {
-    GLib.Variant service_value;
-    string orig_key="";
-    service.second.lookup_extended(key, out orig_key, out service_value);
-    result.append("\t" + key.to_string() + " : " + service_value.print(false) +"\n");
+  HashTableIter<string, Variant> serviceProperties = HashTableIter<string, Variant> (service.ServiceProperties);
+  string hash_key;
+  GLib.Variant hash_value;
+  while (serviceProperties.next(out hash_key, out hash_value)) {
+    result.append("\t" + hash_key.to_string() + " : " + hash_value.print(false) + "\n" );
   }
-
-// for (int i = 0; i <= keys.length; i++) {
-//   result+="\t" + keys.nth(i).to_string() + " : " + values.nth(i).to_string() + "\n";
-// }
   return result.str;
 }


More information about the Lunar-commits mailing list