File: ogsmd-execute-script-on-incoming-call.py

package info (click to toggle)
fso-frameworkd 0.9.5.9%2Bgit20110512-4
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,984 kB
  • sloc: python: 23,770; sh: 160; sql: 4; makefile: 2
file content (34 lines) | stat: -rwxr-xr-x 6,875 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import dbus                                                                                                                                                                                                                                    
import dbus.mainloop                                                                                                                                                                                                                           
import dbus.mainloop.glib                                                                                                                                                                                                                      
import gobject                                                                                                                                                                                                                                 
import subprocess                                                                                                                                                                                                                              
                                                                                                                                                                                                                                               
                                                                                                                                                                                                                                               
actions = { \                                                                                                                                                                                                                                  
  "+491002":"/usr/bin/foo1",                                                                                                                                                                                                          
  "+491002":"/usr/bin/foo2",                                                                                                                                                                                                                   
  "+491003":"/usr/bin/foo3" }                                                                                                                                                                                                                  
                                                                                                                                                                                                                                               
def onCallStatus( index, status, properties ):                                                                                                                                                                                                 
    if status == "incoming":                                                                                                                                                                                                                   
        try:                                                                                                                                                                                                                                   
             action = actions[properties["peer"]]                                                                                                                                                                                              
        except KeyError:                                                                                                                                                                                                                       
             pass                                                                                                                                                                                                                              
        else:                                                                                                                                                                                                                                  
              obj = bus.get_object( "org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device" )                                                                                                                                             
              callInterface = dbus.Interface( obj, "org.freesmartphone.GSM.Call" )                                                                                                                                                             
              callInterface.Release( index )                                                                                                                                                                                                   
              subprocess.Popen( action, shell=True )                                                                                                                                                                                           
                                                                                                                                                                                                                                               
dbus.mainloop.glib.DBusGMainLoop( set_as_default=True )                                                                                                                                                                                        
mainloop = gobject.MainLoop()                                                                                                                                                                                                                  
bus = dbus.SystemBus()                                                                                                                                                                                                                         
bus.add_signal_receiver( onCallStatus,
                         "CallStatus",
                         "org.freesmartphone.GSM.Call",
                         "org.freesmartphone.ogsmd", 
                         "/org/freesmartphone/GSM/Device" )                                                                                             
mainloop.run()