[Pcsclite-cvs-commit] r6020 - in /trunk/contrib/dbus: ./ README pcsc_watcher.py

rousseau at users.alioth.debian.org rousseau at users.alioth.debian.org
Sat Oct 8 09:55:52 UTC 2011


Author: rousseau
Date: Sat Oct  8 09:55:51 2011
New Revision: 6020

URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=6020
Log:
D-Bus tool to send PC/SC events as D-Bus events.

Thanks to Florian Echtler
http://old.nabble.com/Re%3A-DBus-signalling-in-pcsc-lite--p32401088.html

Added:
    trunk/contrib/dbus/
    trunk/contrib/dbus/README
    trunk/contrib/dbus/pcsc_watcher.py   (with props)

Added: trunk/contrib/dbus/README
URL: http://svn.debian.org/wsvn/pcsclite/trunk/contrib/dbus/README?rev=6020&op=file
==============================================================================
--- trunk/contrib/dbus/README (added)
+++ trunk/contrib/dbus/README Sat Oct  8 09:55:51 2011
@@ -1,0 +1,3 @@
+No client is provided yet. Use dbus-monitor as a client for now
+
+Ludovic Rousseau

Added: trunk/contrib/dbus/pcsc_watcher.py
URL: http://svn.debian.org/wsvn/pcsclite/trunk/contrib/dbus/pcsc_watcher.py?rev=6020&op=file
==============================================================================
--- trunk/contrib/dbus/pcsc_watcher.py (added)
+++ trunk/contrib/dbus/pcsc_watcher.py Sat Oct  8 09:55:51 2011
@@ -1,0 +1,73 @@
+#!/usr/bin/env python
+
+"""
+    pcsc-watcher.py: send PC/SC events as DBus events
+    Copyright (C) 2011 Florian "floe" Echtler <floe at butterbrot.org>
+
+    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 3 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, see <http://www.gnu.org/licenses/>.
+"""
+
+import gobject
+
+import dbus
+import dbus.service
+
+from dbus.mainloop.glib import DBusGMainLoop
+
+from smartcard.CardMonitoring import *
+from smartcard.util import *
+
+
+# dbus stuff
+
+service = None
+
+interface = "org.debian.alioth.pcsclite"  # also used as bus name
+path = "/org/debian/alioth/pcsclite/reader0/slot0"
+
+
+class PCSC_DBus_Service(dbus.service.Object):
+    """ very simple DBus service class with one signal """
+    def __init__(self, object_path):
+        bus_name = dbus.service.BusName(interface, bus=dbus.SessionBus())
+        dbus.service.Object.__init__(self, bus_name, object_path)
+
+    @dbus.service.signal(interface)
+    def CardPresenceChanged(self, atr, added):
+        pass
+
+
+# smartcard stuff
+
+class PCSC_Card_Observer(CardObserver):
+    """ simple card observer class which calls the DBus service """
+    def update(self, observable, (addedcards, removedcards)):
+        for card in addedcards:
+            service.CardPresenceChanged(toHexString(card.atr), True)
+        for card in removedcards:
+            service.CardPresenceChanged(toHexString(card.atr), False)
+
+
+# main
+
+DBusGMainLoop(set_as_default=True)
+gobject.threads_init()  # very important to avoid starving the PCSC thread
+
+service = PCSC_DBus_Service(path)
+
+cardmonitor = CardMonitor()
+cardobserver = PCSC_Card_Observer()
+cardmonitor.addObserver(cardobserver)
+
+gobject.MainLoop().run()

Propchange: trunk/contrib/dbus/pcsc_watcher.py
------------------------------------------------------------------------------
    svn:executable = *




More information about the Pcsclite-cvs-commit mailing list