View Full Version : PyMaemo - Selecting Internet Connection when in "Always Ask" mode
code177
01-28-2010, 06:32 PM
Hi all,
I'm currently trying to get through Nokia's QA process and one of the requirements is being able to prompt the user to select an internet connection if the internet connections mode is set to "Always ask"
However, as yet, I've been unable to find anything that can point me in the right direction. Does anybody have any ideas how you would do this?
Many thanks! :)
qwerty12
01-29-2010, 06:25 AM
python-conic should take care of this for you.
There are examples by the iNdT team here (http://pymaemo.garage.maemo.org/conic.html) (test_connect.py is the example that I'm really thinking about) and frals' fMMS is worth looking at (I believe it uses python-conic in a brilliant manner). There doesn't appear to be documentation on python-conic, but the C libconic API reference manual (http://maemo.org/api_refs/5.0/5.0-final/libconic) should tell you what you can do with it; ConIcConnection being the one you want to focus on.
If the N900 is connected to something, then nothing will be shown.
If not, the Select Connections dialog will be shown and the user can choose a connection.
But the dialog will be shown regardless of the Internet Connections mode. The only difference when having the N900, say, set to connect automatically to WLAN connections is that the N900 will be connecting in the background while the dialog is being shown (the user usually dismisses it).
Nowt is to be done about that; you can see this behaviour across many applications using libconic (the Browser is the one that is prominent in my mind).
Best of luck getting Prismic in!
VDVsx
01-29-2010, 07:32 PM
If you want something simple just to play around, there's also d-bus calls for that: http://wiki.maemo.org/Documentation/Maemo_5_Developer_Guide/Using_Connectivity_Components/Maemo_Connectivity#Connectivity_UI (not documented, but " com.nokia.icd.get_state" gives you the current status)
code177
01-31-2010, 06:17 PM
Thanks guys, turns out conic was exactly what I needed :)
code177
02-08-2010, 01:22 PM
Ok guys, I've gotten word back from nokia that you can't yet use python-conic in Ovi apps since it's not available for the ovi repo.
I presume the DBUS call "show_conn_dlg" will bring up the connection request dialogue. Can anyone confirm this (also, how do I do DBUS calls)?
Thanks everyone.
VDVsx
02-08-2010, 04:33 PM
Ok guys, I've gotten word back from nokia that you can't yet use python-conic in Ovi apps since it's not available for the ovi repo.
I presume the DBUS call "show_conn_dlg" will bring up the connection request dialogue. Can anyone confirm this (also, how do I do DBUS calls)?
Thanks everyone.
Yes, you can test it in X-terminal, for example:
dbus-send --type=method_call --system --dest=com.nokia.icd_ui /com/nokia/icd_ui com.nokia.icd_ui.show_conn_dlg boolean:true
You can find some informations and short how-to about python-dbus here: http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html
code177
02-08-2010, 04:42 PM
Yes, you can test it in X-terminal, for example:
dbus-send --type=method_call --system --dest=com.nokia.icd_ui /com/nokia/icd_ui com.nokia.icd_ui.show_conn_dlg boolean:trueYou can find some informations and short how-to about python-dbus here: http://dbus.freedesktop.org/doc/dbus-python/doc/tutorial.html
AH HAH! Perfect. Please excuse my ignorance, but how would I call this from python (2 minutes of someones time here would save me several hours this evening)?
Thanks! :)
rambo
02-08-2010, 04:54 PM
AH HAH! Perfect. Please excuse my ignorance, but how would I call this from python (2 minutes of someones time here would save me several hours this evening)?
Going through shell to do DBUS calls ? very dirty...
See my ICD tests (https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/src/icd_dbus_test.py?revision=52&root=mobilehotspot&view=markup) for some examples about talking to IcD first, then see examples below:
Requesting "any connection" should be simple (all examples untested from memory)
self.icd2_iface.connect_req(dbus.UInt32(1))#ICD_CO NNECTION_FLAG_UI_EVENT(0x8000)
or
self.icd2_iface.connect_req(dbus.UInt32(32768))#IC D_CONNECTION_FLAG_USER_EVENT(0x1)
edit:
And in case you really need to always show the connection dialog (instead of letting IcD decide)
self.icdui_iface.show_conn_dlg(dbus.Boolean(True))
VDVsx
02-08-2010, 05:19 PM
Going through shell to do DBUS calls ? very dirty...
See my ICD tests (https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/src/icd_dbus_test.py?revision=52&root=mobilehotspot&view=markup) for some examples about talking to IcD first, then see examples below:
Requesting "any connection" should be simple (all examples untested from memory)
self.icd2_iface.connect_req(dbus.UInt32(1))#ICD_CO NNECTION_FLAG_UI_EVENT(0x8000)
or
self.icd2_iface.connect_req(dbus.UInt32(32768))#IC D_CONNECTION_FLAG_USER_EVENT(0x1)
edit:
And in case you really need to always show the connection dialog (instead of letting IcD decide)
self.icdui_iface.show_conn_dlg(dbus.Boolean(True))
Yes, the correct way is exactly what Rambo posted here, that's why I posted the python-dbus tutorial above :), d-bus calls in the terminal should be only used for fun/testing propose :).
code177
02-10-2010, 02:05 PM
This works perfectly (although there's a typo in the icd_ui call in init of the icd tests (https://garage.maemo.org/plugins/scmsvn/viewcvs.php/trunk/src/icd_dbus_test.py?revision=52&root=mobilehotspot&view=markup)..
self.icdui_obj = self.bus.get_object('com.nokia.icd', '/com/nokia/icd_ui')
should be
self.icdui_obj = self.bus.get_object('com.nokia.icd_ui', '/com/nokia/icd_ui')
(took me a while to figure that out so hopefully someone will save some time now)
Is there a DBUS related dependency/ies in order to make this work? Thanks!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.