Author: dmeyer
Date: Thu Mar 29 11:58:35 2007
New Revision: 9413

Added:
   trunk/core/src/ipc/ipc.py   (contents, props changed)
Modified:
   trunk/core/src/ipc/__init__.py
   trunk/core/src/ipc/mbus_wrapper.py

Log:
add decorator for eventhandler and use ipc.py for decorators

Modified: trunk/core/src/ipc/__init__.py
==============================================================================
--- trunk/core/src/ipc/__init__.py      (original)
+++ trunk/core/src/ipc/__init__.py      Thu Mar 29 11:58:35 2007
@@ -1 +1,2 @@
-from mbus_wrapper import *
+from mbus_wrapper import Instance
+from ipc import eventhandler, expose

Added: trunk/core/src/ipc/ipc.py
==============================================================================
--- (empty file)
+++ trunk/core/src/ipc/ipc.py   Thu Mar 29 11:58:35 2007
@@ -0,0 +1,49 @@
+# -*- coding: iso-8859-1 -*-
+# -----------------------------------------------------------------------------
+# ipc.py - ipc decorator
+# -----------------------------------------------------------------------------
+# $Id$
+#
+# -----------------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2005-2007 Dirk Meyer, et al.
+#
+# First Edition: Dirk Meyer <[EMAIL PROTECTED]>
+# Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
+#
+# Please see the file AUTHORS for a complete list of authors.
+#
+# 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 MER-
+# CHANTABILITY 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
+#
+# -----------------------------------------------------------------------------
+
+def expose(command, add_command=False, add_source=False):
+    """
+    Decorator to expose a function to the ipc layer.
+    """
+    def decorator(func):
+        func._ipc_rpc = (command, add_command, add_source)
+        return func
+    return decorator
+
+
+def eventhandler(event):
+    """
+    Decorator to set a function as eventhandler for ipc event.
+    """
+    def decorator(func):
+        func._ipc_event = event
+        return func
+    return decorator

Modified: trunk/core/src/ipc/mbus_wrapper.py
==============================================================================
--- trunk/core/src/ipc/mbus_wrapper.py  (original)
+++ trunk/core/src/ipc/mbus_wrapper.py  Thu Mar 29 11:58:35 2007
@@ -18,12 +18,12 @@
 #
 # -----------------------------------------------------------------------------
 # Freevo - A Home Theater PC framework
-# Copyright (C) 2002-2005 Krister Lagerstrom, Dirk Meyer, et al.
+# Copyright (C) 2005 Dirk Meyer, et al.
 #
 # First Edition: Dirk Meyer <[EMAIL PROTECTED]>
 # Maintainer:    Dirk Meyer <[EMAIL PROTECTED]>
 #
-# Please see the file doc/CREDITS for a complete list of authors.
+# Please see the file AUTHORS for a complete list of authors.
 #
 # 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
@@ -41,7 +41,7 @@
 #
 # -----------------------------------------------------------------------------
 
-__all__ = [ 'Instance', 'expose' ]
+__all__ = [ 'Instance' ]
 
 # python imports
 import os
@@ -97,16 +97,6 @@
     return True
 
 
-def expose(command, add_command=False, add_source=False):
-    """
-    Decorator to expose a function to the mbus.
-    """
-    def decorator(func):
-        func._mbus_rpc = (command, add_command, add_source)
-        return func
-    return decorator
-
-
 class RPCReturn(list):
     """
     RPC Return class. An object of this class will be passed to
@@ -499,9 +489,13 @@
             return
 
         for func in [ getattr(obj, func) for func in dir(obj) ]:
-            if callable(func) and hasattr(func, '_mbus_rpc'):
-                command, ac, as = func._mbus_rpc
+            if not callable(func):
+                continue
+            if hasattr(func, '_ipc_rpc'):
+                command, ac, as = func._ipc_rpc
                 self.connect_rpc(func, command, add_command=ac, add_source=as)
+            if hasattr(func, '_ipc_event'):
+                self.events[func._ipc_event].connect(func)
 
 
     def send_event(self, event, *args):

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to