/* * wifi - wifi resource for zavai * copied from gps.vala * * Copyright (C) 2009 Enrico Zini * Copyright (C) 2009 gregor herrmann * * 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(); } } }