6 def create_osso_context(name, version, v):
10 _osso_ctx = osso.Context(name, version, v)
15 Returns the DBus system bus.
18 @return: dbus system bus
24 def get_session_bus():
26 Returns the DBus session bus.
29 @return: dbus session bus
35 def get_device_state():
37 Returns the OSSO device state object.
40 @return: OSSO device state
44 return osso.DeviceState(_osso_ctx)
47 def is_offline_mode():
49 Returns whether the device is in offline (flight) mode.
51 @return: whether the device is in offline mode.
55 bus = get_system_bus()
56 obj = bus.get_object("com.nokia.mce", "/com/nokia/mce/request")
57 req = dbus.Interface(obj, "com.nokia.mce.request")
58 mode = req.get_device_mode()
60 return (mode in ["offline", "flight"])
63 def inhibit_screen_blanking():
65 Inhibits screen blanking. This function must be called repeatedly as long
66 as blanking must not take place.
69 devstate = get_device_state()
70 devstate.display_blanking_pause()
73 def get_product_code():
75 Returns the product code of the device.
89 # you can override the product code by setting the environment variable
90 # MEDIABOX_MAEMO_DEVICE
92 product = os.environ.get("MEDIABOX_MAEMO_DEVICE")
96 lines = open("/proc/component_version", "r").readlines()
103 if (line.startswith("product")):
105 product = parts[1].strip()
113 def request_connection():
115 If the device is not connected, tries to establish the default connection
116 or pop up the connection dialog.
117 Does nothing if the device does already have a network connection.
121 # dbus-send --type=method_call --system --dest=com.nokia.icd/com/nokia/icd com.nokia.icd.connect
122 # dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true
126 conn = conic.Connection()
127 conn.request_connection(conic.CONNECT_FLAG_NONE)
132 def plugin_execute(so_file):
135 plugin = osso.Plugin(_osso_ctx)
136 plugin.plugin_execute(so_file, True)
139 if (get_product_code() == "SU-18"):
141 # work around broken D-Bus bindings on OS 2006; this breaks urllib2 for us,
142 # but we don't use it anyway
143 def _f(*args): raise RuntimeError("Ignore me...")
145 urllib2.AbstractHTTPHandler.do_open = _f
148 import dbus, dbus.glib
149 _system_bus = dbus.SystemBus()
150 _session_bus = dbus.SessionBus()