[pkg-fso-commits] [SCM] framworkd debian packageing branch, debian, updated. debian/0.2.0-git20080805-8-129-ga532788

Joachim Breitner mail at joachim-breitner.de
Thu Sep 11 22:32:39 UTC 2008


The following commit has been merged in the debian branch:
commit 3cefe2ee3cfa24d6e2febcb2880e8a0a4453dabe
Merge: 1a4dba13e262ce60341c9fbd296f3c3aec089dfa fa217eb73182407bbd01e21033e0dc8927e9323e
Author: Joachim Breitner <mail at joachim-breitner.de>
Date:   Thu Sep 11 22:54:49 2008 +0200

    Merge milestone3 via nomeata-fixes into Debian

diff --combined framework/subsystems/odeviced/audio.py
index 05c0038,3e03931..ce3917d
--- a/framework/subsystems/odeviced/audio.py
+++ b/framework/subsystems/odeviced/audio.py
@@@ -5,12 -5,17 +5,17 @@@ Open Device Daemon - A plugin for audi
  (C) 2008 Michael 'Mickey' Lauer <mlauer at vanille-media.de>
  (C) 2008 Openmoko, Inc.
  GPLv2 or later
+ 
+ Package: odeviced
+ Module: audio
  """
  
- __version__ = "0.3.0"
+ MODULE_NAME = "odeviced.audio"
+ __version__ = "0.4.2"
  
+ from framework.config import config
  from framework.patterns import asyncworker
--from helpers import DBUS_INTERFACE_PREFIX, DBUS_PATH_PREFIX, readFromFile, writeToFile, cleanObjectName
++from framework.helpers import DBUS_INTERFACE_PREFIX, DBUS_PATH_PREFIX, readFromFile, writeToFile, cleanObjectName
  
  import gst
  import gobject
@@@ -41,9 -46,14 +46,14 @@@ class AlreadyPlaying( dbus.DBusExceptio
      _dbus_error_name = "org.freesmartphone.Audio.AlreadyPlaying"
  
  #----------------------------------------------------------------------------#
- class InvalidScenario( dbus.DBusException ):
+ class ScenarioInvalid( dbus.DBusException ):
+ #----------------------------------------------------------------------------#
+     _dbus_error_name = "org.freesmartphone.Audio.ScenarioInvalid"
+ 
+ #----------------------------------------------------------------------------#
+ class ScenarioStackUnderflow( dbus.DBusException ):
  #----------------------------------------------------------------------------#
-     _dbus_error_name = "org.freesmartphone.Audio.InvalidScenario"
+     _dbus_error_name = "org.freesmartphone.Audio.ScenarioStackUnderflow"
  
  #----------------------------------------------------------------------------#
  class DeviceFailed( dbus.DBusException ):
@@@ -91,14 -101,14 +101,14 @@@ class GStreamerPlayer( Player )
      decoderMap = { \
          "sid": "siddec",
          "mod": "modplug",
-         "mp3": "mad" \
+         "mp3": "mad",
+         "wav": "wavparse",
          }
  
      def __init__( self, *args, **kwargs ):
          Player.__init__( self, *args, **kwargs )
          self.pipelines = {}
  
- 
      def _onMessage( self, bus, message, name ):
          pipeline, status, repeat, ok_cb, error_cb = self.pipelines[name]
          t = message.type
@@@ -179,22 -189,15 +189,15 @@@
          ok_cb()
  
      def createPipeline( self, name ):
-         extension = name.split( '.' )[-1]
-         pipeline = gst.Pipeline( "name" )
-         filesrc = gst.element_factory_make( "filesrc", "source" )
-         filesrc.set_property( "location", name )
-         pipeline.add( filesrc )
          try:
-             decoder = gst.element_factory_make( self.decoderMap[extension], "decoder" )
+             decoder = GStreamerPlayer.decoderMap[ name.split( '.' )[-1] ]
          except KeyError:
              return None
          else:
-             pipeline.add( decoder )
-             sink = gst.element_factory_make( "alsasink", "sink" )
-             pipeline.add( sink )
-             filesrc.link( decoder )
-             decoder.link( sink )
-             return pipeline
+             # parse_launch may burn a few cycles compared to element_factory_make,
+             # however it should still be faster than creating the pipeline from
+             # individual elements in python, since it's all happening in compiled code
+             return gst.parse_launch( "filesrc location=%s ! %s ! alsasink" % ( name, decoder ) )
  
  #----------------------------------------------------------------------------#
  class AlsaScenarios( object ):
@@@ -202,12 -205,42 +205,42 @@@
      """
      Controls alsa audio scenarios.
      """
-     def __init__( self, dbus_object, statedir ):
+     def __init__( self, dbus_object, statedir, defaultscene ):
          self._object = dbus_object
          self._statedir = statedir
+         self._default = defaultscene
          self._statenames = None
          # FIXME set default profile (from configuration)
+         # FIXME should be set when this audio object initializes
          self._current = "unknown"
+         self._stack = []
+         gobject.idle_add( self._initScenario )
+         logger.info( " ::: using alsa scenarios in %s, default = %s" % ( statedir, defaultscene ) )
+ 
+     def _initScenario( self ):
+         # gather default profile from preferences
+         if os.path.exists( "%s/%s.state" % ( self._statedir, self._default ) ):
+             self.setScenario( self._default )
+             logger.info( "default alsa scenario restored" )
+         else:
+             logger.warning( "default alsa scenario '%s' not found in '%s'. device may start uninitialized" % ( self._default, self._statedir ) )
+         return False
+ 
+     def pushScenario( self, scenario ):
+         current = self._current
+         if self.setScenario( scenario ):
+             self._stack.append( current )
+             return True
+         else:
+             return False
+ 
+     def pullScenario( self ):
+         previous = self._stack.pop()
+         result = self.setScenario( previous )
+         if result is False:
+             return result
+         else:
+             return previous
  
      def getScenario( self ):
          return self._current
@@@ -259,16 -292,17 +292,17 @@@ class Audio( dbus.service.Object )
      """
      DBUS_INTERFACE = DBUS_INTERFACE_PREFIX + ".Audio"
  
-     def __init__( self, bus, config, index, node ):
+     def __init__( self, bus, index, node ):
          self.interface = self.DBUS_INTERFACE
          self.path = DBUS_PATH_PREFIX + "/Audio"
          dbus.service.Object.__init__( self, bus, self.path )
-         self.config = config
          logger.info( "%s %s initialized. Serving %s at %s" % ( self.__class__.__name__, __version__, self.interface, self.path ) )
          # FIXME make it configurable or autodetect which player is to be used
          self.player = GStreamerPlayer( self )
          # FIXME gather scenario path from configuration
-         self.scenario = AlsaScenarios( self, "/usr/share/openmoko/scenarios" )
+         scenario_dir = config.getValue( MODULE_NAME, "scenario_dir", "/etc/alsa/scenario" )
+         default_scenario = config.getValue( MODULE_NAME, "default_scenario", "default" )
+         self.scenario = AlsaScenarios( self, scenario_dir, default_scenario )
  
      #
      # dbus info methods
@@@ -299,6 -333,9 +333,9 @@@
      #
      # dbus scenario methods
      #
+ 
+     # FIXME ugly. error handling should be done by the scenario itself
+ 
      @dbus.service.method( DBUS_INTERFACE, "", "as",
                            async_callbacks=( "dbus_ok", "dbus_error" ) )
      def GetAvailableScenarios( self, dbus_ok, dbus_error ):
@@@ -313,7 -350,7 +350,7 @@@
                            async_callbacks=( "dbus_ok", "dbus_error" ) )
      def SetScenario( self, name, dbus_ok, dbus_error ):
          if not self.scenario.hasScenario( name ):
-             dbus_error( InvalidScenario( "available scenarios are: %s" % self.scenario.getAvailableScenarios() ) )
+             dbus_error( ScenarioInvalid( "available scenarios are: %s" % self.scenario.getAvailableScenarios() ) )
          else:
              if self.scenario.setScenario( name ):
                  dbus_ok()
@@@ -322,6 -359,30 +359,30 @@@
  
      @dbus.service.method( DBUS_INTERFACE, "s", "",
                            async_callbacks=( "dbus_ok", "dbus_error" ) )
+     def PushScenario( self, name, dbus_ok, dbus_error ):
+         if not self.scenario.hasScenario( name ):
+             dbus_error( ScenarioInvalid( "available scenarios are: %s" % self.scenario.getAvailableScenarios() ) )
+         else:
+             if self.scenario.pushScenario( name ):
+                 dbus_ok()
+             else:
+                 dbus_error( DeviceFailed( "unknown error while pushing scenario" ) )
+ 
+     @dbus.service.method( DBUS_INTERFACE, "", "s",
+                           async_callbacks=( "dbus_ok", "dbus_error" ) )
+     def PullScenario( self, dbus_ok, dbus_error ):
+         try:
+             previousScenario = self.scenario.pullScenario()
+         except IndexError:
+             dbus_error( ScenarioStackUnderflow( "forgot to push a scenario?" ) )
+         else:
+             if previousScenario is False:
+                 dbus_error( DeviceFailed( "unknown error while pulling scenario" ) )
+             else:
+                 dbus_ok( previousScenario )
+ 
+     @dbus.service.method( DBUS_INTERFACE, "s", "",
+                           async_callbacks=( "dbus_ok", "dbus_error" ) )
      def StoreScenario( self, name, dbus_ok, dbus_error ):
          if self.scenario.storeScenario( name ):
              dbus_ok()
@@@ -344,7 -405,7 +405,7 @@@ def factory( prefix, controller )
  #----------------------------------------------------------------------------#
      """Instanciate plugins"""
  
-     return [ Audio( controller.bus, controller.config, 0, "" ) ]
+     return [ Audio( controller.bus, 0, "" ) ]
  
  if __name__ == "__main__":
      import dbus
diff --combined framework/subsystems/ogsmd/gsm/const.py
index a4ce291,9a6e2dc..f0695be
--- a/framework/subsystems/ogsmd/gsm/const.py
+++ b/framework/subsystems/ogsmd/gsm/const.py
@@@ -1,5 -1,5 +1,5 @@@
  #!/usr/bin/env python
- # -*- coding: iso-8859-15 -*-
+ #coding=utf8
  """
  The Open Device Daemon - Python Implementation
  
@@@ -13,9 -13,12 +13,12 @@@ Module: cons
  GSM constants, strings, formats, parse patterns, timeouts, you name it.
  """
  
 -import re
 +import re, sys
  from ogsmd.helpers import BiDict
  
+ import logging
+ logger = logging.getLogger( "ogsmd" )
+ 
  #=========================================================================#
  # format patterns
  #=========================================================================#
@@@ -41,9 -44,14 +44,14 @@@ PAT_PHONEBOOK_INFO = re.compile( '\((?P
  # +CMGL: 20,"STO UNSENT","",,,128,10
  PAT_SMS_TEXT_HEADER = re.compile( '(?P<index>\d+),"(?P<status>[^"]+)","(?P<number>[^"]*)",(?:"(?P<name>[^"]+)")?,(?:"(?P<timestamp>[^"]+)")?,(?P<ntype>\d+),(?P<textlen>\d+)' )
  
+ # +CMGL: 1,1,"",125
+ PAT_SMS_PDU_HEADER = re.compile( '(?P<index>\d+),(?P<status>\d+),(?:"(?P<name>[^"]+)")?,(?P<pdulen>\d+)' )
+ 
  # +CMGR: "REC READ","Alice-Team",,"08/05/13,09:12:15+08",208,133
  PAT_SMS_TEXT_HEADER_SINGLE = re.compile( '"(?P<status>[^"]+)","(?P<number>[^"]+)",(?:"(?P<name>[^"]+)")?,(?:"(?P<timestamp>[^"]+)")?,(?P<ntype>\d+),(?P<textlen>\d+)' )
  
+ PAT_SMS_PDU_HEADER_SINGLE = re.compile( '(?P<status>\d+),(?:"(?P<name>[^"]+)"),(?P<pdulen>\d+)' )
+ 
  PAT_STRING = re.compile( r'''"([^"]+?)"''' )
  
  # call forwarding
@@@ -66,8 -74,6 +74,6 @@@ def groupDictIfMatch( pattern, string )
      return match.groupdict() if match is not None else None
  
  #=========================================================================#
- # timeouts
- #=========================================================================#
  TIMEOUT = { \
    "CPIN": 6+1,
    "CFUN": 8+1,
@@@ -79,6 -85,17 +85,17 @@@
  }
  
  #=========================================================================#
+ #        "112"      // GSM 02.30, Europe
+ #        "911"      // GSM 02.30, US and Canada
+ #        "08"       // GSM 02.30, Mexico
+ #        "000"      // GSM 22.101, Australia
+ #        "999"      // GSM 22.101, United Kingdom
+ #        "110"      // GSM 22.101
+ #        "118"      // GSM 22.101
+ #        "119"      // GSM 22.101
+ EMERGENCY_NUMBERS = "112 911 08 000 999 110 118 119".split()
+ 
+ #=========================================================================#
  CME = { \
      0:    "Phone failure",
      1:    "No connection to phone",
@@@ -662,6 -679,23 +679,23 @@@ SMS_STATUS_IN = { 
  }
  
  #=========================================================================#
+ SMS_PDU_STATUS_OUT = { \
+     0 : "unread",
+     1 : "read",
+     2 : "unsent",
+     3 : "sent",
+ }
+ 
+ #=========================================================================#
+ SMS_PDU_STATUS_IN = { \
+     "unread": 0,
+     "read": 1,
+     "unsent": 2,
+     "sent": 3,
+     "all": 4,
+ }
+ 
+ #=========================================================================#
  CALL_DIRECTION = { \
      0: "outgoing",
      1: "incoming",
@@@ -726,6 -760,165 +760,165 @@@ CALL_IDENTIFICATION_RESTRICTION = BiDic
  CALL_VALID_DTMF = "0123456789*#ABCD"
  
  #=========================================================================#
+ NETWORK_USSD_MODE = { \
+     0: "completed",
+     1: "useraction",
+     2: "terminated",
+     3: "localclient",
+     4: "unsupported",
+     5: "timeout",
+ }
+ 
+ #=========================================================================#
+ # PDU TP definitions follow here according to the appearance in GSM 03.40
+ # chapter 9.2.3
+ TP_MTI_INCOMING = { \
+     "sms-deliver" : 0,
+     "sms-submit-report" : 1,
+     "sms-status-report" : 2,
+     "reserved" : 3,
+ }
+ 
+ TP_MTI_OUTGOING = { \
+     "sms-deliver-report" : 0,
+     "sms-submit" : 1,
+     "sms-command" : 2,
+     "reserved" : 3,
+ }
+ 
+ #=========================================================================#
+ TP_VPF = { \
+     "n/a" : 0,
+     "enhanced" : 1,
+     "relative" : 2,
+     "absolute" : 3,
+ }
+ 
+ #=========================================================================#
+ TP_PID = { \
+     "implicit" : 0,
+     "telex" : 1,
+     "g3-telefax" : 2,
+     "g4-telefax" : 3,
+     "voice-telphone" : 4,
+     "ermes" : 5,
+     "paging" : 6,
+     "videotex" : 7,
+     "teletex" : 8,
+     "teletex-pspdn" : 9,
+     "teletex-cspdn" : 10,
+     "teletex-pstn" : 11,
+     "teletex-isdn" : 12,
+     "uci" : 13,
+     # reserved
+     "message-handling" : 16,
+     "public-x400" : 17,
+     "e-mail" : 18,
+     # reserved
+     "gsm-ms" : 31,
+ }
+ # FIXME incomplete
+ # Missing TP_VPEXT
+ #=========================================================================#
+ TP_ST = { \
+     # Transaction completed
+     "received" : 0,
+     "forwarded" : 1,
+     "replaced" : 2,
+     # Temporary error, trying again
+     "congestion" : 32,
+     "sme-busy" : 33,
+     "sme-no-response" : 34,
+     "service-rejected" : 35,
+     "qos-na" : 36,
+     "sme-error" : 37,
+     # Permanent error
+     "remote-procedure-error" : 64,
+     "incompatible-destination" : 65,
+     "sme-connection-rejected" : 66,
+     "not-obtainable" : 67,
+     "qos-na" : 68,
+     "internetworking-na" : 69,
+     "vp-expired" : 70,
+     "deleted-by-origin" : 71,
+     "deleted-by-sc" : 72,
+     "nonexistant" : 73,
+     # Temporary error, giving up
+     "congestion" : 96,
+     "sme-busy" : 97,
+     "sme-no-response" : 98,
+     "service-rejected" : 99,
+     "qos-na" : 100,
+     "sme-error" : 101,
+ }
+ 
+ #=========================================================================#
+ TP_CT = { \
+     "request-status-report" : 0,
+     "cancel-status-report" : 1,
+     "delete-sm" : 2,
+     "enable-status-report" : 3,
+ }
+ 
+ #=========================================================================#
+ TP_FCS = { \
+     "telematic-unsupported" : 0x80,
+     "sm-type0-unsupported" : 0x81,
+     "replace-sm-failed" : 0x82,
+     "tp-pid-error" : 0x8f,
+ 
+     "dcs-unsupported" : 0x90,
+     "message-class-unsupported" : 0x91,
+     "tp-dcs-error" : 0x9f,
+ 
+     "cmd-no-action" : 0xa0,
+     "cmd-unsupported" : 0xa1,
+     "tp-cmd-error" : 0xaf,
+ 
+     "sc-busy" : 0xc0,
+     "sc-no-subscription" : 0xc1,
+     "sc-failure" : 0xc2,
+     "invalid-address" : 0xc3,
+     "destination-barred" : 0xc4,
+     "rejected-duplicaet" : 0xc5,
+     "tp-vfp-unsupported" : 0xc6,
+     "tp-vf-unsupported" : 0xc7,
+ 
+     "sim-storage-full" : 0xd0,
+     "no-sim-storage" : 0xd1,
+     "ms-error" : 0xd2,
+     "memory-exceeded" : 0xd3,
+     "stk-busy" : 0xd4,
+     "data-download-error" : 0xd5,
+ 
+     "error" : 0xff,
+ }
+ 
+ #=========================================================================#
+ TP_UDH_IEI = { \
+     "csm8" : 0,
+     "special-sms" : 1,
+     "port8" : 4,
+     "port16" : 5,
+     "smsc-control" : 6,
+     "udh-source" : 7,
+     "csm16" : 8,
+     "wcmp" : 9,
+     #stk-security
+     #various specific foo
+ }
+ 
+ #=========================================================================#
+ GSMALPHABET =    u'@£$¥èéùìòÇ\nØø\nÅåΔ_ΦΓΛΩΠΨΣΘΞ�ÆæßÉ !"#¤%&\'()*+,-./'+\
+                  u'0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿'+\
+                  u'abcdefghijklmnopqrstuvwxyzäöñà'
+ GSMEXTBYTE = 27
+ GSMEXTALPHABET = u'          \n         ^                   {}    '+\
+                  u' \\            [~] |                              '+\
+                  u'    €                          '
+ 
+ 
+ #=========================================================================#
  import types, math
  
  #=========================================================================#
@@@ -849,13 -1042,17 +1042,17 @@@ def unicodeToString( uni )
  def textToUnicode( text ):
  #=========================================================================#
      """
-     Returns a unicode text for a text given from the modem.
+     Strip " from a modem text and convert it to unicode. Do nothing, if already unicode.
      """
+     stripped = text.strip( '"' )
+     if type( stripped ) == types.UnicodeType:
+         logger.warning( "textToUnicode called with unicode string, ignoring." )
+         return stripped
      try:
-         result = unicode( text.strip( '"' ), "iso-8859-1" ) # as set via +CSCS
+         result = unicode( stripped, "iso-8859-1" ) # as set via +CSCS
      except UnicodeDecodeError:
          result = "<??? undecodable ???>"
-         # log warning
+         logger.error( "textToUnicode called with unconvertable string" )
      return result
  
  #=========================================================================#
diff --combined setup.py
index 9685ea8,edafa6c..f11fd88
--- a/setup.py
+++ b/setup.py
@@@ -4,6 -4,9 +4,9 @@@ from Cython.Distutils import build_ex
  
  import os
  
+ def getDir( dirname ):
+     return [ dirname+'/'+x for x in os.listdir( dirname ) ]
+ 
  # Get the list of all the packages
  packages = [ x[0] for x in os.walk( "framework" ) ]
  
@@@ -20,10 -23,13 +23,13 @@@ setup
      packages = packages,
      scripts = [ "framework/frameworkd", "tools/cli-framework" ],
      data_files = [
 -        ("../../etc/dbus-1/system.d", ["etc/dbus-1/system.d/frameworkd.conf"] ),
 -        ("../../etc/freesmartphone/opreferences/schema/", ["etc/freesmartphone/opreferences/schema/phone.yaml"]),
 -        ("../../etc/freesmartphone/opreferences/schema/", ["etc/freesmartphone/opreferences/schema/profiles.yaml"]),
 -        ("../../etc/freesmartphone/opreferences/conf/profiles/", ["etc/freesmartphone/opreferences/conf/profiles/default.yaml"]),
 -        ("../../etc/freesmartphone/opreferences/conf/phone", ["etc/freesmartphone/opreferences/conf/phone/default.yaml"]),
 -        ("../../etc/freesmartphone/opreferences/conf/phone", ["etc/freesmartphone/opreferences/conf/phone/silent.yaml"]),
 -        ("../../etc/freesmartphone/oevents", ["etc/freesmartphone/oevents/rules.yaml"]),
 -        ("freesmartphone/examples/", getDir( "examples" ) ),
 +        ("/etc/dbus-1/system.d", ["etc/dbus-1/system.d/frameworkd.conf"] ),
++        ("/etc/freesmartphone/opreferences/schema/", ["etc/freesmartphone/opreferences/schema/phone.yaml"]),
 +        ("/etc/freesmartphone/opreferences/schema/", ["etc/freesmartphone/opreferences/schema/profiles.yaml"]),
-         ("/etc/freesmartphone/opreferences/conf/", ["etc/freesmartphone/opreferences/conf/profiles/default.yaml"]),
- 	("/etc/", ["etc/frameworkd.conf"]),
-         ("freesmartphone/examples/", ["examples/gsm-log-data.py"]),
++        ("/etc/freesmartphone/opreferences/conf/profiles/", ["etc/freesmartphone/opreferences/conf/profiles/default.yaml"]),
++        ("/etc/freesmartphone/opreferences/conf/phone", ["etc/freesmartphone/opreferences/conf/phone/default.yaml"]),
++        ("/etc/freesmartphone/opreferences/conf/phone", ["etc/freesmartphone/opreferences/conf/phone/silent.yaml"]),
++        ("/etc/freesmartphone/oevents", ["etc/freesmartphone/oevents/rules.yaml"]),
++        ("/usr/share/doc/fso-frameworkd/examples/", getDir( "examples" ) ),
      ]
  )

-- 
framworkd debian packageing



More information about the pkg-fso-commits mailing list