Re: Confused: Python bindings to D-Bus - OSSO.RPC or DBUS module? Also: wlancond question

2008-02-22 Thread Kalle Valo
ext Nadav Aharony [EMAIL PROTECTED] writes:

 Second issue- controlling the WLAN connection
 From my reading I saw that for the networking stuff I would need to
 connect to wlancond and to ICD. I saw discussions about them not
 being open source, but that there is some API available. 

icd is closed but wlancond is open. You can find wlancond sources from
osso-wlan package:

http://repository.maemo.org/pool/maemo4.0/free/source/o/osso-wlan/

 Could anyone direct me to those APIs and some way to use them
 through Python?

This might help you:

http://maemo.org/development/documentation/how-tos/4-x/maemo_connectivity_guide.html

 Can I have access to all of the settings that are possible through
 the network configuration GUI application? 

The network settings are stored to GConf. I don't remember the exact
location, but it should be quite easy to find them.

 Is there any example of setting WLAN connection and IP settings
 (e..g static IP address) through python?

Create a new network connection (aka. IAP) to GConf and connect to
that IAP using libconic.

-- 
Kalle Valo
___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers


Confused: Python bindings to D-Bus - OSSO.RPC or DBUS module? Also: wlancond question

2008-02-14 Thread Nadav Aharony


Hi,

I've never used the D-Bus before and I realized its probably time for me 
to start. After doing some reading on this list and whatever Google 
brought up I am a bit confused as to what I should be using and how.


My code is all Python, and I need to do some stuff like
-  getting notified if the device is plugged in to the charger or not 
(saw some examples of that)
- modifying the network interfaces (both IP addresses and connecting to 
access points and ad-hoc networks). So far I've done this with ifconfig 
and iwconfig but it was definitely a hack, plus my device used to crash 
a lot, which I attribute to collisions between my manual changes and the 
connection daemons).


First issue:
From the python_maemo_howto - One of LibOSSO's main features is RPC 
(Remote Procedure Calls) services (as it wraps D-Bus ^3 
http://pymaemo.garage.maemo.org/documentation/pymaemo_tutorial/python_maemo_howto.html#references_maemo_sdk_tutorial)
From the example posted by Adenilson Cavalcanti just today (at the end 
of this email), I saw he used the python d-bus module, which wasn't 
mentioned in any of the other tutorials on maemo.org, but I later found 
it on the PyMaemo page.


So which is it? OSSO.RPC or the dbus module?
Can anyone point me to the difference between these two wrappers of the 
D-Bus?

Are there cases where one is better than the other?

Second issue- controlling the WLAN connection
From my reading I saw that for the networking stuff I would need to 
connect to wlancond and to ICD. I saw discussions about them not 
being open source, but that there is some API available. Could anyone 
direct me to those APIs and some way to use them through Python?
Can I have access to all of the settings that are possible through the 
network configuration GUI application?
Is there any example of setting WLAN connection and IP settings (e..g 
static IP address) through python?


Any info would be appreciated,
Thanks!
Nadav


Adenilson Cavalcanti wrote:

Luciano

Long time since the last message...
:-)

Got it working using D-Bus, with this code based on the sample code of 
BlueZ wiki page (hope that it don't break formating):



import dbus
import dbus.glib
import gobject

main_loop = None

def disc_completed_signal():
print 'Signal: DiscoveryCompleted()'
main_loop.quit()


class dbus_bluetooth:
def __init__(self):
self.bus = dbus.SystemBus()
def set_callback(self, f_callback):
self.bus.add_signal_receiver(f_callback, 'RemoteNameUpdated',
 'org.bluez.Adapter', 'org.bluez',
 '/org/bluez/hci0')
self.bus.add_signal_receiver(disc_completed_signal,
 'DiscoveryCompleted', 
'org.bluez.Adapter',

 'org.bluez', '/org/bluez/hci0')
self.obj = self.bus.get_object('org.bluez', '/org/bluez/hci0')
self.adapter = dbus.Interface(self.obj, 'org.bluez.Adapter')
def discover(self):
global main_loop
self.adapter.DiscoverDevices()
gobject.threads_init()
dbus.glib.init_threads()
main_loop = gobject.MainLoop()
main_loop.run()

def test(address, name):
print 'Got a device: (%s, %s)' % (address, name)

obj = dbus_bluetooth()
obj.set_callback(test)
obj.discover()

Best regards




___
maemo-developers mailing list
maemo-developers@maemo.org
https://lists.maemo.org/mailman/listinfo/maemo-developers