summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-01-26 12:35:30 -0600
committerDan Williams <dcbw@redhat.com>2012-01-26 12:35:30 -0600
commit346060efe87b43266326830af3c590052245a1ce (patch)
tree1384b4b652e6acdcb5c6157519f5a285f9876000 /test
parentb9037d11504834cea5341ea48ddcdd3afc9952d1 (diff)
downloadModemManager-346060efe87b43266326830af3c590052245a1ce.tar.gz
test: add SMS get example/test
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.am1
-rwxr-xr-xtest/sms-get.py55
2 files changed, 56 insertions, 0 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index aaedc4b34..6fcefc25a 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -26,6 +26,7 @@ EXTRA_DIST = \
list-modems.py \
location.py \
sms-send.py \
+ sms-get.py \
send-pin.py \
modem-autoenable.py \
ussd.py \
diff --git a/test/sms-get.py b/test/sms-get.py
new file mode 100755
index 000000000..c302459e3
--- /dev/null
+++ b/test/sms-get.py
@@ -0,0 +1,55 @@
+#!/usr/bin/python
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details:
+#
+# Copyright (C) 2009 Novell, Inc.
+# Copyright (C) 2009 - 2012 Red Hat, Inc.
+#
+
+# An example on how to read SMS messages using ModemManager
+
+import sys
+import dbus
+import os
+
+MM_DBUS_SERVICE='org.freedesktop.ModemManager'
+MM_DBUS_PATH='/org/freedesktop/ModemManager'
+MM_DBUS_INTERFACE_MODEM='org.freedesktop.ModemManager.Modem'
+MM_DBUS_INTERFACE_MODEM_SMS='org.freedesktop.ModemManager.Modem.Gsm.SMS'
+
+arglen = len(sys.argv)
+if arglen != 2 and arglen != 3:
+ print "Usage: %s <modem path> [message #]" % sys.argv[0]
+ sys.exit(1)
+
+msgnum = None
+if len(sys.argv) == 3:
+ msgnum = int(sys.argv[2])
+
+objpath = sys.argv[1]
+if objpath[:1] != '/':
+ objpath = "/org/freedesktop/ModemManager/Modems/" + str(objpath)
+
+# Create the modem properties proxy
+bus = dbus.SystemBus()
+proxy = bus.get_object(MM_DBUS_SERVICE, objpath)
+modem = dbus.Interface(proxy, dbus_interface="org.freedesktop.DBus.Properties")
+
+# Make sure the modem is enabled first
+if modem.Get(MM_DBUS_INTERFACE_MODEM, "Enabled") == False:
+ print "Modem is not enabled"
+ sys.exit(1)
+
+# Create the SMS interface proxy
+sms = dbus.Interface(proxy, dbus_interface=MM_DBUS_INTERFACE_MODEM_SMS)
+
+msgs = sms.List()
+print msgs