]> ToastFreeware Gitweb - gregoa/zavai.git/blobdiff - src/wifi.vala
butcher butcher butcher
[gregoa/zavai.git] / src / wifi.vala
index d356e85becd65ac8ccb5a2318440482a90d35f9d..55cf1ccc257062ce90fb837441ba881f9b6243fa 100644 (file)
@@ -1,9 +1,7 @@
 /*
  * wifi - wifi resource for zavai
- * copied from gps.vala
  *
- * Copyright (C) 2009  Enrico Zini <enrico@enricozini.org>
- * Copyright (C) 2009  gregor herrmann <gregor.herrmann@comodo.priv.at>
+ * Copyright (C) 2010  Enrico Zini <enrico@enricozini.org>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -25,64 +23,38 @@ using GLib;
 namespace zavai {
 namespace wifi {
 
-// For a list of dbus services, look in /etc/dbus-1/system.d/
-public class WiFi: zavai.Service
+public class Wifi: zavai.ScriptService
 {
-       public dynamic DBus.Object usage;
-       public dynamic DBus.Object device;
-       protected bool s = false;
-
-       public WiFi()
-       {
-               Object(name: "wifi.wifi");
-
-               // see mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage
-               usage = zavai.registry.sbus.get_object(
-                       "org.freesmartphone.ousaged",
-                       "/org/freesmartphone/Usage",
-                       "org.freesmartphone.Usage");
-
-               device = zavai.registry.sbus.get_object(
-                       "org.freesmartphone.odeviced", 
-                       "/org/freesmartphone/Device/PowerControl/WiFi",
-                       "org.freesmartphone.Device.PowerControl");
-       }
-
-       /// Request WiFi resource
-       public override void start()
-       {
-               if (started) return;
-               try {
-                       usage.RequestResource("WiFi");
-                       zavai.log.info("Acquired WiFi");
-                       base.start();
-               } catch (GLib.Error e) {
-                       zavai.log.error(e.message);
-               }
-               base.start();
-       }
-
-       // Release usage of WiFi
-       public override void stop()
-       {
-               if (!started) return;
-               try {
-                       usage.ReleaseResource("WiFi");
-                       zavai.log.info("Released WiFi");
-                       base.stop();
-               } catch (GLib.Error e) {
-                       zavai.log.error(e.message);
-               }
-               base.stop();
-       }
+    public Wifi()
+    {
+        Object(name: "wifi");
+        started = script_status();
+    }
+
+    /// Start wifi
+    public override void start()
+    {
+        if (started) return;
+        if (!script_start()) return;
+        zavai.log.info("wifi turned on");
+        base.start();
+    }
+
+    // Release usage of wifi
+    public override void stop()
+    {
+        if (!started) return;
+        script_stop();
+        base.stop();
+    }
 }
 
-
-public zavai.wifi.WiFi wifi = null;
+public Wifi wifi = null;
 
 public void init()
 {
-       wifi = new WiFi();
+    wifi = new Wifi();
+
 }
 
 }