/* * gsm - gsm resource for zavai * * Copyright (C) 2009 Enrico Zini * * 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 gsm { public class GSM: zavai.Service { public dynamic DBus.Object device; public GSM() { name = "gsm.gsm"; device = zavai.registry.sbus.get_object( "org.freesmartphone.ogpsd", "/org/freesmartphone/GSM/Device", "org.freesmartphone.Resource"); } /// Request GPS resource public override void start() { if (started) return; try { device.Enable(); zavai.log.info("Started GSM"); base.start(); } catch (GLib.Error e) { zavai.log.error(e.message); } base.start(); } // Release usage of GPS public override void stop() { if (!started) return; try { device.Disable(); zavai.log.info("Stopped GSM"); base.stop(); } catch (GLib.Error e) { zavai.log.error(e.message); } base.stop(); } } public class GPRS: zavai.Service { public dynamic DBus.Object device; public GPRS() { name = "gsm.gprs"; device = zavai.registry.sbus.get_object( "org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device", "org.freesmartphone.GSM.PDP"); } /// Request GPS resource public override void start() { if (started) return; try { //gsm.request(name); device.ActivateContext( zavai.config.gprs_apn, zavai.config.gprs_user, zavai.config.gprs_pass); zavai.log.info("Started GPRS"); base.start(); } catch (GLib.Error e) { zavai.log.error(e.message); } base.start(); } // Release usage of GPS public override void stop() { if (!started) return; try { //gsm.release(name); device.DeactivateContext(); zavai.log.info("Stopped GPRS"); base.stop(); } catch (GLib.Error e) { zavai.log.error(e.message); } base.stop(); } } public zavai.gsm.GSM gsm = null; public zavai.gsm.GPRS gprs = null; public void init() { gsm = new GSM(); gprs = new GPRS(); zavai.registry.register_service(gsm); zavai.registry.register_service(gprs); } } }