[Lunar-commits] <lconnman> lconnman: refresh working

Samuel Verstraete samuel.verstraete at gmail.com
Tue Oct 18 12:31:11 CEST 2011


commit 6a32c046f0e667a4e60c43ee587f46ed7dba909a
Author: Samuel Verstraete <samuel.verstraete at gmail.com>
Date:   Tue Oct 18 12:31:11 2011 +0200

    lconnman: refresh working
---
 src/Makefile        |    3 --
 src/lconnman.vala   |    3 --
 src/service.vala    |   59 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/test/Makefile   |   29 +++++++++++++++++++++++++
 src/test/types      |  Bin 0 -> 132363 bytes
 src/test/types.vala |   43 +++++++++++++++++++++++++++++++++++++
 6 files changed, 131 insertions(+), 6 deletions(-)

diff --git a/src/Makefile b/src/Makefile
index 629befa..e308cc9 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -15,9 +15,6 @@ TESTBIN=test
 all:
 	valac -g -o ${BIN} ${VALAFILES} ${VALAPKGS} -X -lncurses
 
-test:
-	valac -g -o ${TESTBIN} ${TESTVALAFILES} ${VALAPKGS} -X -lncurses
-
 vapi:
 	valac --vapi lconnman.vapi --library=lconnman ${VALAFILES} ${VALAPKGS} -X -lncurses
 
diff --git a/src/lconnman.vala b/src/lconnman.vala
index 1a7aeb0..f947741 100644
--- a/src/lconnman.vala
+++ b/src/lconnman.vala
@@ -15,10 +15,7 @@ int main() {
   //enable up and down keys
   d.keypad(true);
   string[] services =  get_r_services();
-
-
   CursesList cw = new CursesList(services, Orientation.Vertical, Alignment.Top, COLS, LINES - 4);
-  services = get_r_services();
   string[] buttons = new string[4];
   buttons[0] = "configure";
   buttons[1] = "connect";
diff --git a/src/service.vala b/src/service.vala
new file mode 100644
index 0000000..8816db5
--- /dev/null
+++ b/src/service.vala
@@ -0,0 +1,59 @@
+public class Service {
+ /*
+[('/net/connman/service/wifi_d0df9a463a8c_5665727374726f6c646572_managed_psk',
+  {u'AutoConnect': 1,
+   u'Domains': [u'lan'],
+   u'Domains.Configuration': [],
+   u'Ethernet': {u'Address': u'D0:DF:9A:46:3A:8C',
+                 u'Interface': u'wlan0',
+                 u'Method': u'auto'},
+   u'Favorite': 1,
+   u'IPv4': {u'Address': u'192.168.2.48',
+             u'Gateway': u'192.168.2.254',
+             u'Method': u'dhcp',
+             u'Netmask': u'255.255.255.0'},
+   u'IPv4.Configuration': {u'Method': u'dhcp'},
+   u'IPv6': {},
+   u'IPv6.Configuration': {u'Method': u'off'},
+   u'Immutable': 0,
+   u'LoginRequired': 0,
+   u'Name': u'Verstrolder',
+   u'Nameservers': [u'192.168.2.254'],
+   u'Nameservers.Configuration': [],
+   u'PassphraseRequired': 0,
+   u'Provider': {},
+   u'Proxy': {u'Method': u'direct'},
+   u'Proxy.Configuration': {},
+   u'Security': [u'psk'],
+   u'State': u'online',
+   u'Strength': 85,
+   u'Type': u'wifi'})] 
+*/
+  public GLib.ObjectPath ServicePath;
+  public bool AutoConnect;
+  public bool Favorite;
+  public string Name;
+  public string Security;
+  public string State;
+  public uint8 Strength;
+  public string Technology;
+
+  public Service(dbusService dbusservice) {
+    this.ServicePath = dbusservice.ServicePath;
+    this.AutoConnect = (GetValueFromHashTable(dbusservice.ServiceProperties, "AutoConnect").get_boolean());
+    this.Favorite = (GetValueFromHashTable(dbusservice.ServiceProperties, "Favorite").get_boolean());
+    this.Name = GetValueFromHashTable(dbusservice.ServiceProperties, "Name").get_string();
+    this.State = GetValueFromHashTable(dbusservice.ServiceProperties, "State").get_string();
+    this.Strength = GetValueFromHashTable(dbusservice.ServiceProperties, "Strength").get_byte();
+    this.Technology = GetValueFromHashTable(dbusservice.ServiceProperties, "Type").get_string();
+    //this.Security = GetValueFromHashTable(dbusservice.ServiceProperties, "Security").get_string();
+  }
+
+  private GLib.Variant GetValueFromHashTable(GLib.HashTable<string, Variant> hash_table, string key){
+    string hash_key;
+    GLib.Variant hash_value;
+
+    hash_table.lookup_extended(key, out hash_key, out hash_value);
+    return hash_value;
+  }
+}
diff --git a/src/test/Makefile b/src/test/Makefile
new file mode 100644
index 0000000..c2f416b
--- /dev/null
+++ b/src/test/Makefile
@@ -0,0 +1,29 @@
+VALAFILES=../service.vala ../connmanmanager.vala types.vala
+VALAFILES+=../gui/curseslist.vala ../gui/enums.vala
+#PFX=/home/pancake/prg/racu/tmp
+#CFLAGS=-I${PFX}/include/ncurses
+LDFLAGS=-Wl -ldl -lncurses
+LDFLAGS_PKGCONFIG=`pkg-config gobject-2.0 --cflags --libs`
+
+VALAPKGS=--vapidir .
+VALAPKGS+=--pkg curses --pkg gio-2.0
+
+BIN=types
+
+all:
+	valac -g -o ${BIN} ${VALAFILES} ${VALAPKGS} -X -lncurses
+
+vapi:
+	valac --vapi lconnman.vapi --library=lconnman ${VALAFILES} ${VALAPKGS} -X -lncurses
+
+c:
+	valac -C ${VALAFILES} ${VALAPKGS} -X -lncurses
+	mv w/file.c w/file.vala.c
+
+allc:
+	gcc -g ${CFLAGS} ${LDFLAGS_PKGCONFIG} ${LDFLAGS} -o ${BIN} w/*.c *.c -I. 
+
+clean:
+	rm -f w/*.c *.c main a.out ${BIN}
+
+
diff --git a/src/test/types b/src/test/types
new file mode 100755
index 0000000..47f3da8
Binary files /dev/null and b/src/test/types differ
diff --git a/src/test/types.vala b/src/test/types.vala
new file mode 100644
index 0000000..e004680
--- /dev/null
+++ b/src/test/types.vala
@@ -0,0 +1,43 @@
+using Curses;
+
+/*
+D-Bus Vala                Description                 Example
+b     bool                Boolean
+y     uint8               Byte
+i     int                 Integer
+u     uint                Unsigned Integer
+n     int16               16-bit Integer
+q     uint16              Unsigned 16-bit Integer
+x     int64               64-bit Integer
+t     uint64              Unsigned 64-bit Integer
+d     double              Double
+s     string              String
+v     GLib.Variant        Variant
+o     GLib.ObjectPath     Object Path
+a     []                  Array                       ai maps to int[]
+a{}   GLib.HashTable<,>   Dictionary                  a{sv} maps to HashTable<string, Variant>
+()    a struct type       Struct                      a(ii) maps to Foo[] where Foo might be defined as struct Foo { public int a; public int b };
+
+
+*/
+
+
+int main() {
+  ConnmanManager manager = new ConnmanManager();
+  dbusService[] services = manager.get_services();
+
+  for( int i = 0; i < services.length; i++ ) {
+          var service = services[i];
+          stdout.printf("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)) {
+                stdout.printf("\t" + hash_key.to_string() + " : " + hash_value.print(false) + "\n" );
+                stdout.printf("\t\t" + (hash_value.get_type_string()) + "\n");
+          }
+
+  }
+  return 0;
+}
+


More information about the Lunar-commits mailing list