NetworkManager Dbus signals

View: New views
2 Messages — Rating Filter:   Alert me  

NetworkManager Dbus signals

by Simon Charette :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all!

I'm trying to subscribe to a NetworkManager signal in order to detect when a new Internet connection is made and detect if its of a certain type.
Basically we've got public Wifi at school but you have to enter your login information in a web form after connecting.
What I'm trying to do is detect when i connect to that specific Wifi and auto connect all that with python using httplib and dbus.

This is what i've come up with so far:


import dbus
from dbus.mainloop.glib import DBusGMainLoop

NM_DBUS_SERVICE = "org.freedesktop.NetworkManager"
NM_DBUS_OBJECT_PATH = "/org/freedesktop/NetworkManager"
NM_DBUS_INTERFACE = NM_DBUS_SERVICE

DBusGMainLoop(set_as_default=True)

bus = dbus.SystemBus()

def new_connection_handler(device):
    print device

bus.add_signal_receiver(new_connection_handler, 'DeviceNowActive', NM_DBUS_INTERFACE)


But i dont get any feedback even when unplugging a device, or a turning my wifi off and back on.

I wasn't sure where to post that, feel free to redirect me somewhere else. All i found about NetworkManager dbus api is that

Simon

_______________________________________________
dbus mailing list
dbus@...
http://lists.freedesktop.org/mailman/listinfo/dbus

Re: NetworkManager Dbus signals

by Kees Jongenburger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On Sat, Nov 7, 2009 at 2:51 AM, Simon Charette <charette.s@...> wrote:
> Hi all!
>
> I'm trying to subscribe to a NetworkManager signal in order to detect when a
> new Internet connection is made and detect if its of a certain type.
> Basically we've got public Wifi at school but you have to enter your login
> information in a web form after connecting.

I think it would be better to use the /etc/networking/interfaces as
there are some hooks to do this. This would allow you to keep away
from NetworkManager's complexity

from "man interfaces" look at the "/usr/local/sbin/map-scheme" + and
up flush-mail.

 iface lo inet loopback

       mapping eth0
            script /usr/local/sbin/map-scheme
            map HOME eth0-home
            map WORK eth0-work

       iface eth0-home inet static
            address 192.168.1.1
            netmask 255.255.255.0
            up flush-mail

       iface eth0-work inet dhcp

Greetings
_______________________________________________
dbus mailing list
dbus@...
http://lists.freedesktop.org/mailman/listinfo/dbus