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 | ||
- | < | + | <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,'') |
- | </ | + | </code> |
*Signals: | *Signals: | ||
Line 28: | Line 31: | ||
***Path: /com/nokia/phone/SMS | ***Path: /com/nokia/phone/SMS | ||
**Code: Python | **Code: Python | ||
- | < | + | <code> |
- | import gobject, dbus | + | import gobject, dbus |
- | from dbus.mainloop.glib import DBusGMainLoop | + | from dbus.mainloop.glib import DBusGMainLoop |
- | + | ||
- | + | ||
- | + | ||
- | 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) |
- | </ | + | 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 | ||
- | < | + | <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() |
- | </ | + | </code> |
**Method: Answer | **Method: Answer | ||
Line 65: | Line 70: | ||
***Destination: com.nokia.csd.Call | ***Destination: com.nokia.csd.Call | ||
**Code: Python | **Code: 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() |
- | </ | + | </code> |
- | < | + | <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() |
- | </ | + | </code> |
*Signals: | *Signals: | ||
Line 92: | Line 97: | ||
***Path: /com/nokia/csd/call | ***Path: /com/nokia/csd/call | ||
**Code: Python | **Code: Python | ||
- | < | + | <code> |
- | import gobject, dbus | + | import gobject, dbus |
- | from dbus.mainloop.glib import DBusGMainLoop | + | from dbus.mainloop.glib import DBusGMainLoop |
- | + | ||
- | + | ||
- | + | ||
- | 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) |
- | </ | + | 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.