From d17a09e4fe10612cf6647808913d72f47eb79e85 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 18 Jan 2015 14:00:53 +0100 Subject: [PATCH] packethandlers: wrapper for a bunch of packet receivers --- src/packethandlers.vala | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/packethandlers.vala diff --git a/src/packethandlers.vala b/src/packethandlers.vala new file mode 100644 index 0000000..e16775b --- /dev/null +++ b/src/packethandlers.vala @@ -0,0 +1,62 @@ +/* ex:ts=4:sw=4:sts=4:et */ +/* -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */ +/** + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * AUTHORS + * Maciek Borzecki + */ + +class PacketHandlers : Object { + + private List _handlers = null; + + public List handlers { + get { + return _handlers; + } + private set { + _handlers = handlers.copy(); + } + } + public string[] interfaces { get; private set; default = null; } + + public PacketHandlers() { + _handlers = load_handlers(); + string [] ifaces; + list_handlers(out ifaces); + interfaces = ifaces; + } + + private static List load_handlers() { + List hnd = new List(); + + var notification = NotificationHandler.instance(); + var battery = BatteryHandler.instance(); + + hnd.append(notification); + hnd.append(battery); + + return hnd; + } + + public void list_handlers(out string[] interfaces) { + interfaces = new string[_handlers.length()]; + // string[] interfaces = new string[_handlers.length()]; + for (int i = 0; i < _handlers.length(); i++) { + interfaces[i] = _handlers.nth_data(i).get_pkt_type(); + } + // return interfaces; + } +} \ No newline at end of file