r291 - trunk/software/py-ophoned

smartphones-commits at linuxtogo.org smartphones-commits at linuxtogo.org
Fri May 2 12:31:38 CEST 2008


Author: mickeylauer
Date: 2008-05-02 12:31:37 +0200 (Fri, 02 May 2008)
New Revision: 291

Added:
   trunk/software/py-ophoned/objects.py
Removed:
   trunk/software/py-ophoned/serverObjects.py
Modified:
   trunk/software/py-ophoned/config.py
   trunk/software/py-ophoned/frontend.py
   trunk/software/py-ophoned/ophoned
Log:
py-ophoned: server and device register to bus now and answer to methods


Modified: trunk/software/py-ophoned/config.py
===================================================================
--- trunk/software/py-ophoned/config.py	2008-05-01 18:00:48 UTC (rev 290)
+++ trunk/software/py-ophoned/config.py	2008-05-02 10:31:37 UTC (rev 291)
@@ -1,6 +1,6 @@
 DBUS_INTERFACE_PREFIX = "org.freesmartphone.GSM"
 DBUS_PATH_PREFIX = "/org/freesmartphone/GSM"
-DBUS_BUS_NAME = "/org/freesmartphone/ophoned"
+DBUS_BUS_NAME = "org.freesmartphone.ophoned"
 
 VERSION = "0.0.0"
 

Modified: trunk/software/py-ophoned/frontend.py
===================================================================
--- trunk/software/py-ophoned/frontend.py	2008-05-01 18:00:48 UTC (rev 290)
+++ trunk/software/py-ophoned/frontend.py	2008-05-02 10:31:37 UTC (rev 291)
@@ -3,9 +3,9 @@
 import dbus.service
 from dbus.mainloop.glib import DBusGMainLoop
 import gobject
+from config import LOG, LOG_ERR, LOG_WARNING, LOG_INFO, LOG_DEBUG
+import objects
 
-import serverObjects
-
 class Controller( object ):
 
     def __init__( self, backend ):
@@ -14,16 +14,14 @@
         gobject.idle_add( self.idle )
         gobject.timeout_add_seconds( 10, self.timeout )
         self.bus = dbus.SystemBus()
-        self.busname = dbus.service.BusName( config.DBUS_INTERFACE_PREFIX, self.bus )
+        self.busname = dbus.service.BusName( config.DBUS_BUS_NAME, self.bus )
 
 
         self.backend = backend
         self.objects = {}
 
-        for klass in ( serverObjects.Server, serverObjects.Device ):
-            obj = klass( self.bus, "%s/%s" % ( config.DBUS_PATH_PREFIX, klass.__name__ ) )
-            if hasattr( obj, "NEEDS_BACKEND" ):
-                obj.setBackend( self.backend )
+        for klass in ( objects.Server, objects.Device ):
+            obj = klass( self.bus )
             self.objects[klass.__name__] = obj
             print( "registered %s" % klass.__name__ )
 

Copied: trunk/software/py-ophoned/objects.py (from rev 288, trunk/software/py-ophoned/serverObjects.py)
===================================================================
--- trunk/software/py-ophoned/objects.py	                        (rev 0)
+++ trunk/software/py-ophoned/objects.py	2008-05-02 10:31:37 UTC (rev 291)
@@ -0,0 +1,63 @@
+import config
+from config import LOG, LOG_INFO, LOG_ERR, LOG_DEBUG
+import dbus
+import dbus.service
+
+class Server( dbus.service.Object ):
+    DBUS_INTERFACE = "%s.%s" % ( config.DBUS_INTERFACE_PREFIX, "Server" )
+
+    def __init__( self, bus ):
+        self.interface = self.DBUS_INTERFACE
+        self.path = config.DBUS_PATH_PREFIX + "/Server"
+        dbus.service.Object.__init__( self, bus, self.path )
+        LOG( LOG_INFO, "%s initialized. Serving %s at %s" % ( self.__class__.__name__, self.interface, self.path ) )
+
+    #
+    # dbus
+    #
+    @dbus.service.method( DBUS_INTERFACE, "", "s" )
+    def GetVersion( self ):
+        return config.VERSION
+
+class Device( dbus.service.Object ):
+    DBUS_INTERFACE = "%s.%s" % ( config.DBUS_INTERFACE_PREFIX, "Device" )
+
+    def __init__( self, bus ):
+        self.interface = self.DBUS_INTERFACE
+        self.path = config.DBUS_PATH_PREFIX + "/Device"
+        dbus.service.Object.__init__( self, bus, self.path )
+        LOG( LOG_INFO, "%s initialized. Serving %s at %s" % ( self.__class__.__name__, self.interface, self.path ) )
+
+    #
+    # dbus
+    #
+
+    @dbus.service.method( DBUS_INTERFACE, "", "ssss" )
+    def GetInfo( self ):
+        return self.backend.ta_request_manufacturer_identification(), \
+               self.backend.ta_request_model_identifier(), \
+               self.backend.ta_request_revision_identifier(), \
+               self.backend.ta_request_serial_number_identification()
+
+    @dbus.service.method( DBUS_INTERFACE, "", "as" )
+    def GetFeatures( self ):
+        return self.backend.ta_request_overall_capabilities()
+
+    @dbus.service.method( DBUS_INTERFACE, "", "s" )
+    def GetImei( self ):
+        return self.backend.ta_request_serial_number_identification()
+
+if __name__ == "__main__":
+    import dbus
+    bus = dbus.SystemBus()
+
+    # testing 'Server'
+    proxy = bus.get_object( config.DBUS_BUS_NAME, config.DBUS_PATH_PREFIX+"/Server" )
+    print( proxy.Introspect( dbus_interface = "org.freedesktop.DBus.Introspectable" ) )
+    server = dbus.Interface(proxy, Server.DBUS_INTERFACE )
+
+    # testing 'Device'
+    proxy = bus.get_object( config.DBUS_BUS_NAME, config.DBUS_PATH_PREFIX+"/Device" )
+    print( proxy.Introspect( dbus_interface = "org.freedesktop.DBus.Introspectable" ) )
+    device = dbus.Interface(proxy, Device.DBUS_INTERFACE )
+

Modified: trunk/software/py-ophoned/ophoned
===================================================================
--- trunk/software/py-ophoned/ophoned	2008-05-01 18:00:48 UTC (rev 290)
+++ trunk/software/py-ophoned/ophoned	2008-05-02 10:31:37 UTC (rev 291)
@@ -1,15 +1,18 @@
-#!/usr/bin/env python2.5
-# -*- coding: latin1 -*-
-#
-# Authored by Michael 'Mickey' Lauer <mickey at vanille-media.de>
-# (C) 2008 Openmoko, Inc.
-# GPLv2 or later
-#############################################################################
+#!/usr/bin/env python
+"""
+The Open Device Daemon - Python Implementation
 
+(C) 2008 Michael 'Mickey' Lauer <mlauer at vanille-media.de>
+(C) 2008 Openmoko, Inc.
+GPLv2 or later
+"""
+
+__version__ = "0.0.0"
+
 import pygsm
 from optparse import OptionParser
 from config import LOG, LOG_ERR, LOG_WARNING, LOG_INFO, LOG_DEBUG
-from syslog import LOG_PERROR, LOG_DAEMON
+from syslog import openlog, LOG_PERROR, LOG_DAEMON
 import os
 
 parser = OptionParser()

Deleted: trunk/software/py-ophoned/serverObjects.py
===================================================================
--- trunk/software/py-ophoned/serverObjects.py	2008-05-01 18:00:48 UTC (rev 290)
+++ trunk/software/py-ophoned/serverObjects.py	2008-05-02 10:31:37 UTC (rev 291)
@@ -1,51 +0,0 @@
-import config
-import dbus
-import dbus.service
-
-class Server( dbus.service.Object ):
-    DBUS_INTERFACE = "%s.%s" % ( config.DBUS_INTERFACE_PREFIX, "Server" )
-
-    @dbus.service.method( DBUS_INTERFACE, "", "s" )
-    def GetVersion( self ):
-        return config.VERSION
-
-class Device( dbus.service.Object ):
-    DBUS_INTERFACE = "%s.%s" % ( config.DBUS_INTERFACE_PREFIX, "Device" )
-    NEEDS_BACKEND = ""
-
-    def setBackend( self, backend ):
-        self.backend = backend
-
-    @dbus.service.method( DBUS_INTERFACE, "", "ssss" )
-    def GetInfo( self ):
-        return self.backend.ta_request_manufacturer_identification(), \
-               self.backend.ta_request_model_identifier(), \
-               self.backend.ta_request_revision_identifier(), \
-               self.backend.ta_request_serial_number_identification()
-
-    @dbus.service.method( DBUS_INTERFACE, "", "as" )
-    def GetFeatures( self ):
-        return self.backend.ta_request_overall_capabilities()
-
-    @dbus.service.method( DBUS_INTERFACE, "", "s" )
-    def GetImei( self ):
-        return self.backend.ta_request_serial_number_identification()
-
-if __name__ == "__main__":
-    import dbus
-    bus = dbus.SessionBus()
-
-    # testing 'Server'
-    proxy = bus.get_object( config.DBUS_INTERFACE_PREFIX, config.DBUS_PATH_PREFIX+"/Server" )
-    print( proxy.Introspect( dbus_interface = "org.freedesktop.DBus.Introspectable" ) )
-    iface = dbus.Interface(proxy, Server.DBUS_INTERFACE )
-    assert ( iface.GetVersion() == config.VERSION )
-
-    # testing 'Device'
-    proxy = bus.get_object( config.DBUS_INTERFACE_PREFIX, config.DBUS_PATH_PREFIX+"/Device" )
-    print( proxy.Introspect( dbus_interface = "org.freedesktop.DBus.Introspectable" ) )
-    iface = dbus.Interface(proxy, Device.DBUS_INTERFACE )
-    iface.GetInfo()
-    iface.GetFeatures()
-    iface.GetImei()
-




More information about the Smartphones-commits mailing list