From 8ec45b7aed21f8afdb77ff17ad4452ef54db8c8b Mon Sep 17 00:00:00 2001 From: Enrico Zini Date: Thu, 17 Dec 2009 22:59:12 +0000 Subject: [PATCH] Added basic uevent support --- README | 1 + src/uevent.vala | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ src/zavai.vala | 1 + 3 files changed, 67 insertions(+) create mode 100644 src/uevent.vala diff --git a/README b/README index 3d6955c..fe26084 100644 --- a/README +++ b/README @@ -166,6 +166,7 @@ TODO list / wish list selected to playlist) - playlist as reorderable standard list, allow to delete tracks, reorder tracks - save playlist to file to reload later + - pause with headset button - volume control in power menu - space buttons from sliders, to avoid shutting down instead of lowering the volume - lua config diff --git a/src/uevent.vala b/src/uevent.vala new file mode 100644 index 0000000..b63fb6f --- /dev/null +++ b/src/uevent.vala @@ -0,0 +1,65 @@ +/* + * uevent - zavai uevent handling + * + * 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 uevent { + +class UEvent : Service +{ + protected int sock; + + /// Activate the service + protected override void start() + { + if (started) return; + + sock = Omhacks.UEvent.open(); + if (sock < 0) + { + zavai.log.error("UEvent: error getting socket"); + return; + } + + base.start(); + } + + /// Deactivate the service + protected override void stop() + { + if (!started) return; + // Do here + base.stop(); + } +} + +UEvent uevent; + +public void init() +{ + if (Posix.getuid() == 0) + uevent = new UEvent(); + else + uevent = null; +} + +} +} diff --git a/src/zavai.vala b/src/zavai.vala index d506a33..bcbc556 100644 --- a/src/zavai.vala +++ b/src/zavai.vala @@ -94,6 +94,7 @@ static int main (string[] args) { // Additional infrastructure zavai.input.init(); + zavai.uevent.init(); zavai.gps.init(); zavai.gsm.init(); zavai.audio.init(); -- 2.39.5