[Lunar-commits] <lconnman> connmanmanager: restyling

Samuel samuel.verstraete at gmail.com
Thu Aug 18 22:07:33 CEST 2011


commit e42636880f1ea9c384138067e6e8bf1dd5ab0d84
Author: Samuel <samuel.verstraete at gmail.com>
Date:   Thu Aug 18 22:07:33 2011 +0200

    connmanmanager: restyling
---
 src/connmanmanager.vala |  126 +++++++++++++++++++++++++---------------------
 1 files changed, 68 insertions(+), 58 deletions(-)

diff --git a/src/connmanmanager.vala b/src/connmanmanager.vala
index ddde309..8c27d23 100644
--- a/src/connmanmanager.vala
+++ b/src/connmanmanager.vala
@@ -1,5 +1,5 @@
 [DBus (name = "net.connman.Manager")]
-interface ConnmanManager : Object {
+interface IConnmanManager : Object {
   public abstract string get_state() throws IOError;
   public abstract Service[] get_services() throws IOError;
   public abstract GLib.HashTable<string, Variant> get_properties() throws IOError;
@@ -10,74 +10,84 @@ public struct Service {
   public GLib.HashTable<string, Variant> ServiceProperties;
 }
 
-ConnmanManager connmanManager;
+public class ConnmanManager {
+  IConnmanManager connmanManager;
 
-void main () {
-
-  try {
-    connmanManager = Bus.get_proxy_sync (BusType.SYSTEM, "net.connman", "/");
-    stdout.printf( "System state:\n" );
-    string state = get_state();
-    stdout.printf(state +"\n");
-  } catch (IOError e) {
-    stderr.printf (e.message +"\n");
-  }
-  stdout.printf( "Available Services:\n");
-  foreach (Service service in get_services()) {
-    stdout.printf(print_service(service));
+  public ConnmanManager(){
+    try {
+      connmanManager = Bus.get_proxy_sync (BusType.SYSTEM, "net.connman", "/");
+    } catch (IOError e) {
+      stderr.printf ( e.message + "\n" ); 
+    }
   }
-  stdout.printf( "System Properties:\n");
-  GLib.HashTable<string,Variant> SystemProperties = get_properties();
-  stdout.printf( print_system_properties(SystemProperties) );
-}
 
-public static string get_state() {
-  try {
-    return connmanManager.get_state();
-  } catch (IOError e) {
-    stderr.printf (e.message + "\n");
-    return e.message;
+//void main () {
+
+//  try {
+//    connmanManager = Bus.get_proxy_sync (BusType.SYSTEM, "net.connman", "/");
+//    stdout.printf( "System state:\n" );
+//    string state = get_state();
+//    stdout.printf(state +"\n");
+//  } catch (IOError e) {
+//    stderr.printf (e.message +"\n");
+//  }
+//  stdout.printf( "Available Services:\n");
+//  foreach (Service service in get_services()) {
+//    stdout.printf(print_service(service));
+//  }
+//  stdout.printf( "System Properties:\n");
+//  GLib.HashTable<string,Variant> systemProperties = get_properties();
+//  stdout.printf( print_system_properties(systemProperties) );
+//}
+
+  public string get_state() {
+    try {
+      return connmanManager.get_state();
+    } catch (IOError e) {
+      stderr.printf (e.message + "\n");
+      return e.message;
+    }
   }
-}
 
-public static Service[] get_services() {
-  try {
-    return connmanManager.get_services();
-  } catch (IOError e) {
-    stderr.printf (e.message + "\n");
-    return new Service[0];
+  public Service[] get_services() {
+    try {
+      return connmanManager.get_services();
+    } catch (IOError e) {
+      stderr.printf (e.message + "\n");
+      return new Service[0];
+    }
   }
-}
 
-public static GLib.HashTable<string, Variant> get_properties() {
-  try {
-    return connmanManager.get_properties();
-  } catch ( IOError e ) {
-    stderr.printf ( e.message + "\n" );
-    return new GLib.HashTable<string, Variant>( GLib.str_hash, GLib.str_equal );
+  public GLib.HashTable<string, Variant> get_properties() {
+    try {
+      return connmanManager.get_properties();
+    } catch ( IOError e ) {
+      stderr.printf ( e.message + "\n" );
+      return new GLib.HashTable<string, Variant>( GLib.str_hash, GLib.str_equal );
+    }
   }
-}
 
-public string print_service(Service service) {
-  StringBuilder result = new StringBuilder();
-  result.append("ServicePath: " + service.ServicePath.to_string() + "\n");
+  private string print_service(Service service) {
+    StringBuilder result = new StringBuilder();
+    result.append("ServicePath: " + service.ServicePath.to_string() + "\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" );
+    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" );
+    }
+    return result.str;
   }
-  return result.str;
-}
 
-public string print_system_properties (GLib.HashTable<string,Variant> systemProperties) {
-  StringBuilder result = new StringBuilder();
-  HashTableIter<string, Variant> systemPropertiesIter = HashTableIter<string, Variant> (systemProperties);
-  string hash_key;
-  GLib.Variant hash_value;
-  while (systemPropertiesIter.next(out hash_key, out hash_value)) {
-    result.append(hash_key.to_string() + " : " + hash_value.print(false) + "\n" );
+  private string print_system_properties (GLib.HashTable<string,Variant> systemProperties) {
+    StringBuilder result = new StringBuilder();
+    HashTableIter<string, Variant> systemPropertiesIter = HashTableIter<string, Variant> (systemProperties);
+    string hash_key;
+    GLib.Variant hash_value;
+    while (systemPropertiesIter.next(out hash_key, out hash_value)) {
+      result.append(hash_key.to_string() + " : " + hash_value.print(false) + "\n" );
+    }
+    return result.str;
   }
-  return result.str;
 }


More information about the Lunar-commits mailing list