2 * wifi - wifi resource for zavai
5 * Copyright (C) 2009 Enrico Zini <enrico@enricozini.org>
6 * Copyright (C) 2009 gregor herrmann <gregor.herrmann@comodo.priv.at>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 // For a list of dbus services, look in /etc/dbus-1/system.d/
29 public class WiFi: zavai.Service
31 public dynamic DBus.Object usage;
32 public dynamic DBus.Object device;
33 protected bool s = false;
39 // see mdbus -s org.freesmartphone.ousaged /org/freesmartphone/Usage
40 usage = zavai.registry.sbus.get_object(
41 "org.freesmartphone.ousaged",
42 "/org/freesmartphone/Usage",
43 "org.freesmartphone.Usage");
45 device = zavai.registry.sbus.get_object(
46 "org.freesmartphone.odeviced",
47 "/org/freesmartphone/Device/PowerControl/WiFi",
48 "org.freesmartphone.Device.PowerControl");
51 public void power_cycle()
53 // "Have you tried turning it off and on again?"
55 usage.SetResourcePolicy("WiFi", "disabled");
56 } catch (GLib.Error e) {
57 zavai.log.error(e.message);
59 Thread.usleep(500000);
61 usage.SetResourcePolicy("WiFi", "auto");
62 } catch (GLib.Error e) {
63 zavai.log.error(e.message);
67 /// Request WiFi resource
68 public override void start()
72 usage.RequestResource("WiFi");
73 zavai.log.info("Acquired WiFi");
75 } catch (GLib.Error e) {
76 zavai.log.error(e.message);
81 // Release usage of WiFi
82 public override void stop()
86 usage.ReleaseResource("WiFi");
87 zavai.log.info("Released WiFi");
89 } catch (GLib.Error e) {
90 zavai.log.error(e.message);
97 public zavai.wifi.WiFi wifi = null;
102 zavai.registry.register_service(wifi);