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: | ||
- | + | <div style="border: 1px solid red; background-color: #faa; padding: 20px;">Please be aware that the recommended way to use the phone functionality is Telepathy: | |
+ | |||
+ | * [http://telepathy.freedesktop.org/wiki/ Telepathy wiki] | ||
+ | * [http://maemo.org/api_refs/5.0/5.0-final/telepathy-glib/ Telepathy-glib API] | ||
+ | * [http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/Architecture/RTCOM RTCOM architecture] | ||
+ | </div> | ||
+ | |||
+ | |||
== SMS == | == SMS == | ||
+ | |||
*Method calls: | *Method calls: | ||
Line 11: | Line 19: | ||
***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 36: | ||
***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 61: | ||
***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> |
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
- | + | ||
*Signals: | *Signals: | ||
Line 92: | Line 75: | ||
***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> |
Learn more about Contributing to the wiki.