From 8b834d7bcbb43d0745d6e636fe2655ea90fbcde6 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Wed, 23 Jun 2010 14:42:22 +0200 Subject: [PATCH] Initial import --- API.txt | 102 ++++++++++++++++++++++++++++++++++++++++++++++++ fso-auth.py | 30 ++++++++++++++ fso-listen-for-calls.py | 49 +++++++++++++++++++++++ fso-make-call.py | 52 ++++++++++++++++++++++++ fso-print-info.py | 83 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 316 insertions(+) create mode 100644 API.txt create mode 100755 fso-auth.py create mode 100755 fso-listen-for-calls.py create mode 100755 fso-make-call.py create mode 100755 fso-print-info.py diff --git a/API.txt b/API.txt new file mode 100644 index 0000000..c29a4f9 --- /dev/null +++ b/API.txt @@ -0,0 +1,102 @@ +[METHOD] org.freesmartphone.Info.GetInfo() +[METHOD] org.freesmartphone.GSM.Call.Activate( i:id ) +[METHOD] org.freesmartphone.GSM.Call.ActivateConference( i:id ) +[METHOD] org.freesmartphone.GSM.Call.Emergency( s:number ) +[METHOD] org.freesmartphone.GSM.Call.HoldActive() +[METHOD] org.freesmartphone.GSM.Call.Initiate( s:number, s:type ) +[METHOD] org.freesmartphone.GSM.Call.Join() +[METHOD] org.freesmartphone.GSM.Call.ListCalls() +[METHOD] org.freesmartphone.GSM.Call.Release( i:id ) +[METHOD] org.freesmartphone.GSM.Call.ReleaseAll() +[METHOD] org.freesmartphone.GSM.Call.ReleaseHeld() +[METHOD] org.freesmartphone.GSM.Call.SendDtmf( s:tones ) +[METHOD] org.freesmartphone.GSM.Call.Transfer( s:number ) +[SIGNAL] org.freesmartphone.GSM.Call.CallStatus( i:id, s:status, a{sv}:properties ) +[METHOD] org.freedesktop.DBus.Properties.Get( s:interface, s:propname ) +[METHOD] org.freedesktop.DBus.Properties.GetAll( s:interface ) +[METHOD] org.freedesktop.DBus.Properties.Set( s:interface, s:propname, v:value ) +[METHOD] org.freedesktop.DBus.Introspectable.Introspect() +[METHOD] org.freesmartphone.GSM.Device.GetDeviceStatus() +[METHOD] org.freesmartphone.GSM.Device.GetFeatures() +[METHOD] org.freesmartphone.GSM.Device.GetFunctionality() +[METHOD] org.freesmartphone.GSM.Device.GetMicrophoneMuted() +[METHOD] org.freesmartphone.GSM.Device.GetSpeakerVolume() +[METHOD] org.freesmartphone.GSM.Device.SetFunctionality( s:level, b:autoregister, s:pin ) +[METHOD] org.freesmartphone.GSM.Device.SetMicrophoneMuted( b:muted ) +[METHOD] org.freesmartphone.GSM.Device.SetSpeakerVolume( i:volume ) +[SIGNAL] org.freesmartphone.GSM.Device.DeviceStatus( s:status ) +[SIGNAL] org.freesmartphone.GSM.Device.KeypadEvent( s:name, b:pressed ) +[METHOD] org.freesmartphone.GSM.SMS.GetSizeForTextMessage( s:contents ) +[METHOD] org.freesmartphone.GSM.SMS.RetrieveTextMessages() +[METHOD] org.freesmartphone.GSM.SMS.SendTextMessage( s:recipient_number, s:contents, b:report ) +[SIGNAL] org.freesmartphone.GSM.SMS.IncomingMessageReport( i:reference, s:status, s:sender_number, s:contents ) +[SIGNAL] org.freesmartphone.GSM.SMS.IncomingTextMessage( s:number, s:timestamp, s:contents ) +[METHOD] org.freesmartphone.GSM.SIM.ChangeAuthCode( s:old_pin, s:new_pin ) +[METHOD] org.freesmartphone.GSM.SIM.DeleteEntry( s:category, i:index ) +[METHOD] org.freesmartphone.GSM.SIM.DeleteMessage( i:index ) +[METHOD] org.freesmartphone.GSM.SIM.GetAuthCodeRequired() +[METHOD] org.freesmartphone.GSM.SIM.GetAuthStatus() +[METHOD] org.freesmartphone.GSM.SIM.GetHomeZoneParameters() +[METHOD] org.freesmartphone.GSM.SIM.GetPhonebookInfo( s:category ) +[METHOD] org.freesmartphone.GSM.SIM.GetServiceCenterNumber() +[METHOD] org.freesmartphone.GSM.SIM.GetSimInfo() +[METHOD] org.freesmartphone.GSM.SIM.RetrieveMessage( i:index ) +[METHOD] org.freesmartphone.GSM.SIM.RetrievePhonebook( s:category, i:mindex, i:maxdex ) +[METHOD] org.freesmartphone.GSM.SIM.SendAuthCode( s:pin ) +[METHOD] org.freesmartphone.GSM.SIM.SendGenericSimCommand( s:command ) +[METHOD] org.freesmartphone.GSM.SIM.SendRestrictedSimCommand( i:command, i:fileid, i:p1, i:p2, i:p3, s:data ) +[METHOD] org.freesmartphone.GSM.SIM.SendStoredMessage( i:index ) +[METHOD] org.freesmartphone.GSM.SIM.SetAuthCodeRequired( b:check, s:pin ) +[METHOD] org.freesmartphone.GSM.SIM.SetServiceCenterNumber( s:number ) +[METHOD] org.freesmartphone.GSM.SIM.StoreEntry( s:category, i:index, s:name, s:number ) +[METHOD] org.freesmartphone.GSM.SIM.StoreMessage( s:recipient_number, s:contents, a{sv}:properties ) +[METHOD] org.freesmartphone.GSM.SIM.Unlock( s:puk, s:new_pin ) +[SIGNAL] org.freesmartphone.GSM.SIM.AuthStatus( s:status ) +[SIGNAL] org.freesmartphone.GSM.SIM.IncomingMessage( i:index ) +[METHOD] org.freesmartphone.GSM.HZ.GetHomeZoneStatus() +[METHOD] org.freesmartphone.GSM.HZ.GetKnownHomeZones() +[SIGNAL] org.freesmartphone.GSM.HZ.HomeZoneStatus( s:name ) +[METHOD] org.freesmartphone.GSM.Network.DisableCallForwarding( s:reason, s:class_ ) +[METHOD] org.freesmartphone.GSM.Network.EnableCallForwarding( s:reason, s:class_, s:number, i:timeout ) +[METHOD] org.freesmartphone.GSM.Network.GetCallForwarding( s:reason ) +[METHOD] org.freesmartphone.GSM.Network.GetCallingIdentification() +[METHOD] org.freesmartphone.GSM.Network.GetSignalStrength() +[METHOD] org.freesmartphone.GSM.Network.GetStatus() +[METHOD] org.freesmartphone.GSM.Network.GetTimeReport() +[METHOD] org.freesmartphone.GSM.Network.ListProviders() +[METHOD] org.freesmartphone.GSM.Network.Register() +[METHOD] org.freesmartphone.GSM.Network.RegisterWithProvider( s:operator_code ) +[METHOD] org.freesmartphone.GSM.Network.SendUssdRequest( s:request ) +[METHOD] org.freesmartphone.GSM.Network.SetCallingIdentification( s:status ) +[METHOD] org.freesmartphone.GSM.Network.Unregister() +[SIGNAL] org.freesmartphone.GSM.Network.CipherStatus( s:telephony, s:pdp ) +[SIGNAL] org.freesmartphone.GSM.Network.IncomingUssd( s:mode, s:message_ ) +[SIGNAL] org.freesmartphone.GSM.Network.SignalStrength( i:signal_strength ) +[SIGNAL] org.freesmartphone.GSM.Network.Status( a{sv}:status ) +[SIGNAL] org.freesmartphone.GSM.Network.TimeReport( i:time, i:zone ) +[METHOD] org.freesmartphone.GSM.Debug.DebugCommand( s:command, s:channel ) +[METHOD] org.freesmartphone.GSM.Debug.DebugInjectResponse( s:response, s:channel ) +[METHOD] org.freesmartphone.GSM.Debug.DebugPing() +[SIGNAL] org.freesmartphone.GSM.Debug.DebugStatus( a{ss}:channels ) +[METHOD] org.freesmartphone.GSM.Monitor.GetNeighbourCellInformation() +[METHOD] org.freesmartphone.GSM.Monitor.GetServingCellInformation() +[METHOD] org.freesmartphone.Device.RealtimeClock.GetCurrentTime() +[METHOD] org.freesmartphone.Device.RealtimeClock.GetWakeupTime() +[METHOD] org.freesmartphone.Device.RealtimeClock.SetCurrentTime( i:time ) +[METHOD] org.freesmartphone.Device.RealtimeClock.SetWakeupTime( i:time ) +[SIGNAL] org.freesmartphone.Device.RealtimeClock.Alarm( i:time ) +[SIGNAL] org.freesmartphone.Device.RealtimeClock.WakeupTimeChanged( i:time ) +[METHOD] org.freesmartphone.Device.PowerSupply.GetCapacity() +[METHOD] org.freesmartphone.Device.PowerSupply.GetPowerStatus() +[SIGNAL] org.freesmartphone.Device.PowerSupply.Capacity( i:energy ) +[SIGNAL] org.freesmartphone.Device.PowerSupply.PowerStatus( s:status ) +[METHOD] org.freesmartphone.GSM.CB.GetCellBroadcastSubscriptions() +[METHOD] org.freesmartphone.GSM.CB.SetCellBroadcastSubscriptions( s:channels ) +[SIGNAL] org.freesmartphone.GSM.CB.IncomingCellBroadcast( s:text, s:language, a{sv}:properties ) +[METHOD] org.freesmartphone.GSM.PDP.ActivateContext() +[METHOD] org.freesmartphone.GSM.PDP.DeactivateContext() +[METHOD] org.freesmartphone.GSM.PDP.GetContextStatus() +[METHOD] org.freesmartphone.GSM.PDP.GetCredentials() +[METHOD] org.freesmartphone.GSM.PDP.InternalStatusUpdate( s:status, a{sv}:properties ) +[METHOD] org.freesmartphone.GSM.PDP.SetCredentials( s:apn, s:username, s:password ) +[SIGNAL] org.freesmartphone.GSM.PDP.ContextStatus( s:status, a{sv}:properties ) diff --git a/fso-auth.py b/fso-auth.py new file mode 100755 index 0000000..0fc26f9 --- /dev/null +++ b/fso-auth.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +import sys +import dbus + +def fso_auth(pin): + bus = dbus.SystemBus() + + usage_obj = bus.get_object("org.freesmartphone.ousaged", "/org/freesmartphone/Usage") + usage_iface = dbus.Interface(usage_obj, "org.freesmartphone.Usage") + usage_iface.RequestResource("GSM") + + gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device") + gsm_sim_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.SIM") + + if gsm_sim_iface.GetAuthStatus() == 'SIM PIN': + gsm_sim_iface.SendAuthCode(pin) + if gsm_sim_iface.GetAuthStatus() == 'READY': + print "OK" + + usage_iface.ReleaseResource("GSM") + +if __name__ == "__main__": + + if len(sys.argv) != 2: + sys.stderr.write("usage: %s \n") + sys.exit(1) + + pin = sys.argv[1] + fso_auth(pin) diff --git a/fso-listen-for-calls.py b/fso-listen-for-calls.py new file mode 100755 index 0000000..a0bc8f2 --- /dev/null +++ b/fso-listen-for-calls.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +import dbus +import gobject + +from dbus.mainloop.glib import DBusGMainLoop +DBusGMainLoop(set_as_default=True) + +def onCallStatus(sender = "", *args, **kwargs): + status = str(args[0]) + if (args[1].has_key("peer")): + caller = str(args[1]["peer"]) + else: + caller = "unknown" + + print "onCallStatus" + print sender + print status + print caller + print + +def fso_listen_for_calls(): + bus = dbus.SystemBus() + + usage_obj = bus.get_object("org.freesmartphone.ousaged", "/org/freesmartphone/Usage") + usage_iface = dbus.Interface(usage_obj, "org.freesmartphone.Usage") + usage_iface.RequestResource("GSM") + + gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device") + gsm_call_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.Call") + + print "Set Functionality: full" + gsm_network_iface.SetFunctionality("full", True, "") + + gsm_call_iface.connect_to_signal('CallStatus', onCallStatus) + + print "starting the main loop" + loop = gobject.MainLoop() + try: + loop.run() + except KeyboardInterrupt: + print "Interrupted" + loop.quit() + + gsm_network_iface.SetFunctionality("minimal", True, "") + usage_iface.ReleaseResource("GSM") + +if __name__ == "__main__": + fso_listen_for_calls() diff --git a/fso-make-call.py b/fso-make-call.py new file mode 100755 index 0000000..eceb5b8 --- /dev/null +++ b/fso-make-call.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +import sys +import time +import dbus + +def onCallStatus(sender = "", *args, **kwargs): + status = str(args[0]) + if (args[1].has_key("peer")): + caller = str(args[1]["peer"]) + else: + caller = "unknown" + + print "onCallStatus" + print sender + print status + print caller + print + +def fso_dial(number): + bus = dbus.SystemBus() + + usage_obj = bus.get_object("org.freesmartphone.ousaged", "/org/freesmartphone/Usage") + usage_iface = dbus.Interface(usage_obj, "org.freesmartphone.Usage") + usage_iface.RequestResource("GSM") + + gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device") + gsm_device_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.Device") + gsm_call_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.Call") + + print "Set Functionality: full" + gsm_device_iface.SetFunctionality("full", True, "") + + gsm_call_iface.connect_to_signal('CallStatus', onCallStatus) + + id = gsm_call_iface.Initiate(number, "voice") + print "Call id:", id + time.sleep(30) + gsm_call_iface.Release(id) + + gsm_device_iface.SetFunctionality("minimal", True, "") + usage_iface.ReleaseResource("GSM") + +if __name__ == "__main__": + + if len(sys.argv) != 2: + sys.stderr.write("usage: %s \n") + sys.exit(1) + + number = sys.argv[1] + fso_dial(number) + diff --git a/fso-print-info.py b/fso-print-info.py new file mode 100755 index 0000000..355904a --- /dev/null +++ b/fso-print-info.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python + +import dbus +from pprint import pprint + +# Taken from telepathy-gabble: +# http://git.collabora.co.uk/?p=user/wjt/telepathy-gabble-wjt.git;a=blob;f=tests/twisted/servicetest.py;h=476c2e171dc7d535f70fa49827892a4cfb5d8402;hb=HEAD#l265 +def unwrap(x): + """Hack to unwrap D-Bus values, so that they're easier to read when + printed.""" + + if isinstance(x, list): + return map(unwrap, x) + + if isinstance(x, tuple): + return tuple(map(unwrap, x)) + + if isinstance(x, dict): + return dict([(unwrap(k), unwrap(v)) for k, v in x.iteritems()]) + + if isinstance(x, dbus.Boolean): + return bool(x) + + for t in [unicode, str, long, int, float]: + if isinstance(x, t): + return t(x) + + return x + +def fso_print_info(): + # Get proxies and add signal handlers + bus = dbus.SystemBus() + usage_obj = bus.get_object("org.freesmartphone.ousaged", "/org/freesmartphone/Usage") + usage_iface = dbus.Interface(usage_obj, "org.freesmartphone.Usage") + usage_iface.RequestResource("GSM") + + gsm_device_obj = bus.get_object("org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device") + + gsm_info_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.Info") + gsm_device_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.Device") + gsm_sim_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.SIM") + gsm_network_iface = dbus.Interface(gsm_device_obj, "org.freesmartphone.GSM.Network") + + info = gsm_info_iface.GetInfo() + pprint(unwrap(info)) + print + + device_status = gsm_device_iface.GetDeviceStatus() + pprint(unwrap(device_status)) + print + + features = gsm_device_iface.GetFeatures() + pprint(unwrap(features)) + print + + functionality = gsm_device_iface.GetFunctionality() + pprint(unwrap(functionality)) + print + + auth_code = gsm_sim_iface.GetAuthCodeRequired() + pprint(unwrap(auth_code)) + print + + auth_status = gsm_sim_iface.GetAuthStatus() + pprint(unwrap(auth_status)) + print + + service_center = gsm_sim_iface.GetServiceCenterNumber() + pprint(unwrap(service_center)) + print + + sim_info = gsm_sim_iface.GetSimInfo() + pprint(unwrap(sim_info)) + print + + net_status = gsm_network_iface.GetStatus() + pprint(unwrap(net_status)) + print + + usage_iface.ReleaseResource("GSM") + +if __name__ == "__main__": + fso_print_info() -- 2.1.4