#!/usr/bin/python

import dbus

apns = {
	'S COMVIQ': 'internet.parlino.se',
#	'S COMVIQ': 'internet.tele2.se',
	'TELIA S': 'internet.telia.se',
	'vodafone SE': 'services.vodafone.net'
}
username = 'x'
password = 'x'

sbus = dbus.SystemBus()
obj = 'org.freesmartphone.frameworkd'
objpath = '/org/freesmartphone/GSM/Device'
proxy = sbus.get_object(obj, objpath)
status = proxy.GetStatus(dbus_interface='org.freesmartphone.GSM.Network')

if (status['registration'] != 'home'):
  print "Illegal GSM network registration state: " + status['registration'];
  print "You might want to mdbus -s org.freesmartphone.ophoned /org/freesmartphone/GSM/Device org.freesmartphone.GSM.Network.Register"
else:
  apn = apns[status['provider']]
  proxy.ActivateContext(apn, username, password, dbus_interface='org.freesmartphone.GSM.PDP')

