]> ToastFreeware Gitweb - gregoa/zavai.git/commitdiff
Merge branch 'master' into gregoa
authorgregor herrmann <gregoa@debian.org>
Mon, 11 Jan 2010 18:16:43 +0000 (19:16 +0100)
committergregor herrmann <gregoa@debian.org>
Mon, 11 Jan 2010 18:16:43 +0000 (19:16 +0100)
.gitignore [new file with mode: 0644]
hooks/display
icons/wifi_0.png [new file with mode: 0644]
icons/wifi_1.png [new file with mode: 0644]
src/app_wifi.vala [new file with mode: 0644]
src/wifi.vala [new file with mode: 0644]
src/zavai.vala

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..378eac2
--- /dev/null
@@ -0,0 +1 @@
+build
index 7fb032c9f0ec177adff9cecf95f3bb0d60607de6..d29a95bec9a03377ecaa4b93dc100fd2c137d274 100755 (executable)
@@ -1,4 +1,7 @@
 #!/bin/sh
+
+export DISPLAY=:0
+
 case "$1" in
        # At the start of zavai
        init)
diff --git a/icons/wifi_0.png b/icons/wifi_0.png
new file mode 100644 (file)
index 0000000..928d615
Binary files /dev/null and b/icons/wifi_0.png differ
diff --git a/icons/wifi_1.png b/icons/wifi_1.png
new file mode 100644 (file)
index 0000000..ff28d9e
Binary files /dev/null and b/icons/wifi_1.png differ
diff --git a/src/app_wifi.vala b/src/app_wifi.vala
new file mode 100644 (file)
index 0000000..9618704
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * app_wifi - WiFi buttons
+ * copied from app_gps.vala
+ *
+ * Copyright (C) 2009  Enrico Zini <enrico@enricozini.org>
+ * Copyright (C) 2009  gregor herrmann <gregor.herrmann@comodo.priv.at>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+using GLib;
+
+namespace zavai {
+namespace ui {
+namespace wifi {
+
+public class WiFiRequest : Gtk.ToggleButton
+{
+       protected string label_start;
+       protected string label_stop;
+       protected zavai.StatusIcon status_icon;
+       protected bool power = false;
+
+       public WiFiRequest()
+       {
+               label_start = "Start WiFi";
+               label_stop = "Stop WiFi";
+               set_size_request(0, zavai.config.min_button_height);
+               toggled += on_toggled;
+
+               set_label(get_active() ? label_stop : label_start);
+
+               //tooltip = "WiFi status";
+               try {
+                       power = zavai.wifi.wifi.device.GetPower();
+               } catch (Error e) {
+                       power = false;
+               }
+               zavai.wifi.wifi.device.Power += on_power_status_changed;
+
+               // WiFi status icon
+               status_icon = new zavai.StatusIcon();
+               status_icon.install();
+               status_icon.clicked += on_status_clicked;
+               update_icon();
+       }
+
+       protected void update_icon()
+       {
+               string name;
+               if (power)
+                       name = zavai.config.icondir + "/" + "wifi_1.png";
+               else
+                       name = zavai.config.icondir + "/" + "wifi_0.png";
+               status_icon.set_from_file(name);
+       }
+
+       private void on_power_status_changed(dynamic DBus.Object pos, string device, bool power)
+       {
+               this.power = power;
+               update_icon();
+       }
+
+       private void on_toggled(Gtk.Button src)
+       {
+        if (get_active())
+            zavai.wifi.wifi.request("servicerequestlink");
+        else
+            zavai.wifi.wifi.release("servicerequestlink");
+        set_label(get_active() ? label_stop : label_start);
+        update_icon();
+       }
+
+       private void on_status_clicked(Gtk.Button b)
+       {
+               set_active(!get_active());
+       }
+}
+
+WiFiRequest wifirequest;
+
+public void init()
+{
+    wifirequest = new WiFiRequest();
+}
+
+}
+}
+}
diff --git a/src/wifi.vala b/src/wifi.vala
new file mode 100644 (file)
index 0000000..d356e85
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * 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>
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+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 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 zavai.wifi.WiFi wifi = null;
+
+public void init()
+{
+       wifi = new WiFi();
+}
+
+}
+}
index 423cfbb6b6fd9e376566fb448377c86c348b4edb..bb3bc6714ad1863eca0a9c8010a3c0814fdd0e2d 100644 (file)
@@ -98,6 +98,7 @@ static int main (string[] args) {
        zavai.power.init();
        zavai.gps.init();
        zavai.gsm.init();
+       zavai.wifi.init();
        zavai.audio.init();
        zavai.clock.init();
 
@@ -112,6 +113,7 @@ static int main (string[] args) {
        zavai.ui.main.init();
        zavai.ui.gps.init();
        zavai.ui.gsm.init();
+       zavai.ui.wifi.init();
        zavai.app.run_script(zavai.config.homedir + "/display init");
        zavai.ui.power.init();
        zavai.ui.kbd.init();