Editing PyMaemo/Phone call and SMS examples

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
{{Recommended phone usage}}
{{Recommended phone usage}}
 +
 +
== SMS ==
== SMS ==
 +
*Method calls:
*Method calls:
Line 11: Line 14:
***Destination: com.nokia.phone.SMS
***Destination: com.nokia.phone.SMS
**Code: Python
**Code: Python
-
<source lang="python">
+
<code>
-
import dbus
+
        import dbus
-
bus = dbus.SystemBus()
+
        bus = dbus.SystemBus()
-
smsobject = bus.get_object('com.nokia.phone.SMS', '/com/nokia/phone/SMS/ba212ae1')
+
        smsobject = bus.get_object('com.nokia.phone.SMS', '/com/nokia/phone/SMS/ba212ae1')
-
smsiface = dbus.Interface(smsobject, 'com.nokia.csd.SMS.Outgoing')
+
        smsiface = dbus.Interface(smsobject, 'com.nokia.csd.SMS.Outgoing')
-
arr = dbus.Array(pdu_array)
+
        arr = dbus.Array(pdu_array)
-
msg = dbus.Array([arr])  
+
        msg = dbus.Array([arr])  
-
smsiface.Send(msg,'')
+
        smsiface.Send(msg,'')
-
</source>
+
</code>
*Signals:
*Signals:
Line 28: Line 31:
***Path: /com/nokia/phone/SMS
***Path: /com/nokia/phone/SMS
**Code: Python
**Code: Python
-
<source lang="python">
+
<code>
-
import gobject, dbus
+
    import gobject, dbus
-
from dbus.mainloop.glib import DBusGMainLoop
+
    from dbus.mainloop.glib import DBusGMainLoop
-
 
+
-
def handle_sms(pdu, msgcenter, somestring, sendernumber):
+
-
    print 'New message from %s' % sendernumber
+
      
      
-
DBusGMainLoop(set_as_default=True)
+
    def handle_sms(pdu, msgcenter, somestring, sendernumber):
-
bus = dbus.SystemBus()
+
        print 'New message from %s' % sendernumber
-
bus.add_signal_receiver(handle_sms, path='/com/nokia/phone/SMS',  dbus_interface='Phone.SMS', signal_name='IncomingSegment')
+
       
-
gobject.MainLoop().run()
+
    DBusGMainLoop(set_as_default=True)
-
</source>
+
    bus = dbus.SystemBus()
 +
    bus.add_signal_receiver(handle_sms, path='/com/nokia/phone/SMS',  dbus_interface='Phone.SMS', signal_name='IncomingSegment')
 +
    gobject.MainLoop().run()
 +
</code>
 +
 
== Call ==
== Call ==
 +
*Method calls:
*Method calls:
Line 51: Line 56:
***Destination: com.nokia.csd.Call
***Destination: com.nokia.csd.Call
**Code: Python
**Code: Python
-
<source lang="python">
+
<code>
-
bus = dbus.SystemBus()
+
    bus = dbus.SystemBus()
-
callobject = bus.get_object('com.nokia.csd.Call', '/com/nokia/csd/call/1')
+
    callobject = bus.get_object('com.nokia.csd.Call', '/com/nokia/csd/call/1')
-
smsiface = dbus.Interface(callobject, 'com.nokia.csd.Call.Instance')
+
    smsiface = dbus.Interface(callobject, 'com.nokia.csd.Call.Instance')
-
smsiface.Release()
+
    smsiface.Release()
-
</source>
+
</code>
**Method: Answer
**Method: Answer
Line 65: Line 70:
***Destination: com.nokia.csd.Call
***Destination: com.nokia.csd.Call
**Code: Python
**Code: Python
-
<source lang="python">
+
<code>
# Just answer
# Just answer
-
bus = dbus.SystemBus()
+
    bus = dbus.SystemBus()
-
callobject = bus.get_object('com.nokia.csd.Call', '/com/nokia/csd/call/1')
+
    callobject = bus.get_object('com.nokia.csd.Call', '/com/nokia/csd/call/1')
-
smsiface = dbus.Interface(callobject, 'com.nokia.csd.Call.Instance')
+
    smsiface = dbus.Interface(callobject, 'com.nokia.csd.Call.Instance')
-
smsiface.Answer()
+
    smsiface.Answer()
-
</source>
+
</code>
-
<source lang="python">
+
<code>
# Answer then hangup
# Answer then hangup
import time
import time
-
 
+
   
-
bus = dbus.SystemBus()
+
    bus = dbus.SystemBus()
-
callobject = bus.get_object('com.nokia.csd.Call', '/com/nokia/csd/call/1')
+
    callobject = bus.get_object('com.nokia.csd.Call', '/com/nokia/csd/call/1')
-
smsiface = dbus.Interface(callobject, 'com.nokia.csd.Call.Instance')
+
    smsiface = dbus.Interface(callobject, 'com.nokia.csd.Call.Instance')
-
smsiface.Answer()
+
    smsiface.Answer()
-
time.sleep(0.5)    # wait 0.5 secs or 500 ms
+
    time.sleep(0.5)    # wait 0.5 secs or 500 ms
-
smsiface.Release()
+
    smsiface.Release()
-
</source>
+
</code>
*Signals:
*Signals:
Line 92: Line 97:
***Path: /com/nokia/csd/call
***Path: /com/nokia/csd/call
**Code: Python
**Code: Python
-
<source lang="python">
+
<code>
-
import gobject, dbus
+
    import gobject, dbus
-
from dbus.mainloop.glib import DBusGMainLoop
+
    from dbus.mainloop.glib import DBusGMainLoop
-
 
+
-
def handle_call(obj_path, callernumber):
+
-
    print '%s is calling' % callernumber
+
      
      
-
DBusGMainLoop(set_as_default=True)
+
    def handle_call(obj_path, callernumber):
-
bus = dbus.SystemBus()
+
        print '%s is calling' % callernumber
-
bus.add_signal_receiver(handle_call, path='/com/nokia/csd/call', dbus_interface='com.nokia.csd.Call', signal_name='Coming')
+
       
-
gobject.MainLoop().run()
+
    DBusGMainLoop(set_as_default=True)
-
</source>
+
    bus = dbus.SystemBus()
 +
    bus.add_signal_receiver(handle_call, path='/com/nokia/csd/call', dbus_interface='com.nokia.csd.Call', signal_name='Coming')
 +
    gobject.MainLoop().run()
 +
</code>
[[Category:Python]]
[[Category:Python]]

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: