[Dextrose] NetworkManager API (was: Re: Some learning)

Ajay Garg ajaygargnsit at gmail.com
Mon Mar 12 09:18:42 EDT 2012


Sir,
Regards.

Got the connection-activation logic working !!!!!

(Tested by killing nm-applet, ensuring "ping www.google.com" resulted
in "unknown host"; running the program (with hard-coded WIFI network
settings); and finally re-checking "ping www.google.com" in another
terminal window). It was working :) :) :)


Thanks Sascha for all your help :) :) :)

======================================================================================================
"""

LEARNINGS :

A system usually has only one (fixed) wireless device hardware.
Thus, no callbacks for addition/removal of this device are triggered.
(Can't thank you enough Sascha !!! :) :) )

However, this (single) hardware has the capacity to pair with multiple
access-points.

In Networkmanager (at least python APIs), each access-point is
represented by its path, which serves as its key. Using this key, other
properties (notably SSID) can be retreived.



For a wired device, it again is fixed; thus no addition/removal
callbacks (Thanks again Sascha). There is no concept of SSID; a wired
device is just
a medium for physical connection. Moreover, there is one-to-one
correspondence for a wired-device, and the network.

"""


"""
TESTS DONE ::

a.
Additon/Removal of USB Modem triggers corresponding ('DeviceAdded',
'DeviceRemoved') callbacks.

b.
Addition/Removal of wireless access-points triggers corresponding
('AccessPoint', 'AccessPointRemoved') callbacks.

c.
Inserting/Removal of wired-jack triggers correponding 'StateChanged'
callback for the wired-device.

d.
Connecting/Disconnecting a wireless network triggers corresponding
'StateChanged' callback for the wireless-device.
"""



import dbus
from dbus.mainloop.glib import DBusGMainLoop

DBusGMainLoop(set_as_default=True)
bus = dbus.SystemBus()

WIFI_DEVICE_PATH = None



bus = dbus.SystemBus()


# The 'id' is unique-identifier key (in the real sense).
# Two connections are considered different, only if their 'id' is
# different.
s_con = dbus.Dictionary({
    'type': '802-11-wireless',
    'uuid': '81069512-0dce-44c6-943c-b24c254172f6',
    'id': 'Auto MTNL 11'})

s_wifi = dbus.Dictionary({
    'ssid': dbus.ByteArray("MTNL"),
    'security': '802-11-wireless-security'})

s_wsec = dbus.Dictionary({'key-mgmt': 'none',
                          'wep-key0': 'ajayg',
                          'auth-alg': 'open',
                          'wep-key-type': 1})

s_ip4 = dbus.Dictionary({'method': 'auto'})
s_ip6 = dbus.Dictionary({'method': 'ignore'})

con = dbus.Dictionary({
    'connection': s_con,
    '802-11-wireless': s_wifi,
    '802-11-wireless-security': s_wsec,
    'ipv4': s_ip4,
    'ipv6': s_ip6
     })


print 'connection dekho'
print con


def haha():
    bus.add_signal_receiver(connection_added_cb,
                            signal_name='NewConnection',

dbus_interface='org.freedesktop.NetworkManagerSettings')

    proxy = bus.get_object("org.freedesktop.NetworkManagerSystemSettings",
"/org/freedesktop/NetworkManagerSettings")
    settings = dbus.Interface(proxy, "org.freedesktop.NetworkManagerSettings")
    settings.AddConnection(con)





"""
The names have been designed, keeping in consistency of the
nomenclature used in "add_signal_receiver" method.
"""
NM_BUS_NAME                    = 'org.freedesktop.NetworkManager'
NM_PATH                        = '/org/freedesktop/NetworkManager'
NM_DBUS_INTERFACE              = 'org.freedesktop.NetworkManager'

"""
Note that the following is not specifically tied to Network Manager.
"""
DBUS_PROPS_DBUS_INTERFACE      = 'org.freedesktop.DBus.Properties'

"""
Some more :)
"""
NM_DEVICE_DBUS_INTERFACE       = 'org.freedesktop.NetworkManager.Device'
NM_WIRED_DEVICE_INTERFACE      = 'org.freedesktop.NetworkManager.Device.Wired'
NM_WIFI_DEVICE_INTERFACE       =
'org.freedesktop.NetworkManager.Device.Wireless'
NM_ACCESS_POINT_DBUS_INTERFACE = 'org.freedesktop.NetworkManager.AccessPoint'


class NMDbusPathProcessor:
    """
    This class encapsulates functions, that would be used for
    processing any networkmanager-dbus-path.
    """

    def get_nm_object(self, nm_dbus_path):
        """
        returns dbus-object for the nm-dbus-path.
        """
        return bus.get_object(NM_BUS_NAME, nm_dbus_path)

    def get_nm_props_interface(self, nm_dbus_path):
        """
        returns the interface, encapsulating the nm-dbus-path.
        """
        nm_object = self.get_nm_object(nm_dbus_path)
        return dbus.Interface(nm_object, DBUS_PROPS_DBUS_INTERFACE)


nm_dbus_path_processor = NMDbusPathProcessor()


class BaseTypeProcessor:
    """
    This class is a virtual class; each subtype of which implements a
    particular hierarchy of NetworkManager architecture. (or kind of :)
    )
    """

    def __init__(self, base_path):
        self._base_path = base_path
        self._base_obj = nm_dbus_path_processor.get_nm_object(base_path)


    def initiate(self):
        """
        Did not put in the __init__, as did not want to get into the
        dynamics of "use-before-initialization" problem.
        """
        self._base_interface = dbus.Interface(self._base_obj,
                                              self.get_interface_identifier())

        """
        List the exiting things.
        """
        self.existing_things()


        """
        Add callbacks for runtime addition and removal.
        """
        bus.add_signal_receiver(self.thing_added_cb,
                                signal_name=self.get_thing_added_signal_name(),
                                dbus_interface=self.get_interface_identifier())
        bus.add_signal_receiver(self.thing_removed_cb,

signal_name=self.get_thing_removed_signal_name(),
                                dbus_interface=self.get_interface_identifier())

    def existing_things(self):
        """
        Returns the existing "things"
        For eg., as a starting point of networkmanager, "things" would
        be devices.
        For a wireless device, "things" would be access-points.
        """
        all_things_func = self.get_all_things_func()
        all_things_nm_dbus_paths = all_things_func()
        for nm_dbus_path in all_things_nm_dbus_paths:
            self.show_info('Found', nm_dbus_path)
            self.extra_processing(nm_dbus_path)


    def thing_added_cb(self, nm_dbus_path):
        """
        callbacks such as 'DeviceAdded', 'AccessPointAdded' always pass
        a dbus-path to the callback method; this dbus-method is the
        key. from which further processing takes place.
        """
        self.show_info('Added', nm_dbus_path)
        self.extra_processing(nm_dbus_path)

    def thing_removed_cb(self, nm_dbus_path):
        """
        callbacks such as 'DeviceRemoved', 'AccessPointRemoved' always
        pass a dbus-path key. NOTE THAT NO FURTHER PROCESSING CAN BE
        DONE ON THIS DBUS-PATH - this is the last-rites method.'
        """
        self.show_info('Removed', nm_dbus_path)
        # Note that extra processing is SIMPLY NOT POSSIBLE.

    def get_thing_type(self):
        return NotImplementedError

    def show_info(self, action, nm_dbus_path):
        print '\n'
        thing_type = self.get_thing_type()
        print action + ' ( ' + thing_type + ' ) :: ' + nm_dbus_path

    def extra_processing(self, nm_dbus_path):
        """
        This is optional. A subtype may choose to add extra
        functionality"""
        pass

    def get_all_things_func(self):
        raise NotImplementedError

    def get_thing_added_signal_name(self):
        raise NotImplementedError

    def get_thing_removed_signal_name(self):
        raise NotImplementedError

    def get_interface_identifier(self):
        raise NotImplementedError


class NMWirelessAccessPointsProcessor(BaseTypeProcessor):
    """
    Processor for access-points for a (singular) wireless device.
    """

    def __init__(self, wireless_device_nm_path):
        BaseTypeProcessor.__init__(self, wireless_device_nm_path)

    def get_thing_type(self):
        return 'Access Point'

    def get_all_things_func(self):
        return self._base_interface.GetAccessPoints

    def get_thing_added_signal_name(self):
        return 'AccessPointAdded'

    def get_thing_removed_signal_name(self):
        return 'AccessPointRemoved'

    def extra_processing(self, nm_wireless_access_point_path):
        print 'SSID is :: ' + self.get_ssid(nm_wireless_access_point_path)

    def get_ssid(self, nm_wireless_access_point_path):
        access_point_obj = bus.get_object(NM_BUS_NAME,
nm_wireless_access_point_path)
        nm_wireless_access_point_props_interface = \

nm_dbus_path_processor.get_nm_props_interface(nm_wireless_access_point_path)
        ssid_dbus_byte_array =
nm_wireless_access_point_props_interface.Get(NM_ACCESS_POINT_DBUS_INTERFACE,
'Ssid')

        ssid = ""
        for c in ssid_dbus_byte_array:
            ssid = ssid + chr(c)

        return ssid

    def get_interface_identifier(self):
        return NM_WIFI_DEVICE_INTERFACE



class NMDevicesProcessor(BaseTypeProcessor):
    """
    Processor for devices.
    """

    def __init__(self, nm_path):
        BaseTypeProcessor.__init__(self, nm_path)

    def get_thing_type(self):
        return 'Device'

    def extra_processing(self, nm_device_path):
        device_type = self.get_nm_device_type(nm_device_path)
        print 'Device Type is :: ' + str(device_type)

        if device_type == 1:
            print '\nWired Hardware found !!'
            bus.add_signal_receiver(self.handle_wired_state_change,
                                    signal_name='StateChanged',
                                    path=nm_device_path,
                                    dbus_interface=NM_DEVICE_DBUS_INTERFACE)

        if device_type == 2:
            print '\nWireless Hardware found !!'
            global WIFI_DEVICE_PATH
            WIFI_DEVICE_PATH = nm_device_path
            NMWirelessAccessPointsProcessor(nm_device_path).initiate()
            bus.add_signal_receiver(self.handle_wireless_state_change,
                                    signal_name='StateChanged',
                                    path=nm_device_path,
                                    dbus_interface=NM_DEVICE_DBUS_INTERFACE)
            haha()

        if device_type == 3:
            print '\nGSM Hardware found !!'
            bus.add_signal_receiver(self.handle_gsm_state_change,
                                    signal_name='StateChanged',
                                    path=nm_device_path,
                                    dbus_interface=NM_DEVICE_DBUS_INTERFACE)

    def get_nm_device_type(self, nm_device_path):
        nm_interface =
nm_dbus_path_processor.get_nm_props_interface(nm_device_path)
        return nm_interface.Get(NM_DEVICE_DBUS_INTERFACE, 'DeviceType')

    def handle_wired_state_change(self, new_state, old_state, reason):
        self.show_state_changed_info(new_state, old_state, reason, 1)

    def handle_wireless_state_change(self, new_state, old_state, reason):
        self.show_state_changed_info(new_state, old_state, reason, 2)

    def handle_gsm_state_change(self, new_state, old_state, reason):
        self.show_state_changed_info(new_state, old_state, reason, 3)

    def show_state_changed_info(self, new_state, old_state, reason,
                                device_type):
        print '\n\nState Changed for Device ' + str(device_type) + ' :: ' + \
                str(old_state) + ' -> ' + str(new_state) + ' , (Reason) : ' + \
                str(reason)

    def get_all_things_func(self):
        return self._base_interface.GetDevices

    def get_thing_added_signal_name(self):
        return 'DeviceAdded'

    def get_thing_removed_signal_name(self):
        return 'DeviceRemoved'

    def get_interface_identifier(self):
        return NM_DBUS_INTERFACE


def connection_added_cb(connection_path):
    print 'yay !!! connection add ho gaya'
    print connection_path

    print 'activating now'
    print WIFI_DEVICE_PATH
    dbus.Interface(bus.get_object(NM_BUS_NAME, NM_PATH),
            NM_DBUS_INTERFACE).ActivateConnection('org.freedesktop.NetworkManagerSystemSettings',connection_path,WIFI_DEVICE_PATH,'/')

try:
    NMDevicesProcessor(NM_PATH).initiate()
except dbus.DBusException, e:
    print e







import gobject
gobject.MainLoop().run()
======================================================================================================


Thanks and Regards,
Ajay


On Fri, Mar 9, 2012 at 10:39 PM, Ajay Garg <ajaygargnsit at gmail.com> wrote:
> SIr,
> Regards.
>
> Thanks a ton for the reply.
>
> Thanks, Thanks, Thanks !!!
>
> That solved it !!!
>
> Following is the modified program, along with its output (just one quirk; as
> can be seen from the output, occassionally there are (spurious)
> 'AccessPointAdded' signals received, *with a blank SSID*. Don't know what
> the reason may be).
>
>
> Anyways, here is the program (connection-activation logic excluded) and
> output :
>
> ================================================================================
> """
> LEARNINGS :
>
> A system usually has only one (fixed) wireless device hardware.
> Thus, no callbacks for addition/removal of this device are triggered.
> (Can't thank you enough Sascha !!! :) :) )
>
> However, this (single) hardware has the capacity to pair with multiple
> access-points.
>
> In Networkmanager (at least python APIs), each access-point is
> represented by its path, which serves as its key. Using this key, other
> properties (notably SSID) can be retreived.
>
>
>
> For a wired device, it again is fixed; thus no addition/removal
> callbacks (Thanks again Sascha). There is no concept of SSID; a wired device
> is just
> a medium for physical connection. Moreover, there is one-to-one
> correspondence for a wired-device, and the network.
> """
>
> """
> TESTS DONE ::
>
> a. Additon/Removal of USB Modem triggers corresponding callbacks.
> b. Addition/Removal of wireless access-points triggers callbacks.
> """
>
>
> import dbus
> from dbus.mainloop.glib import DBusGMainLoop
>
> DBusGMainLoop(set_as_default=True)
> bus = dbus.SystemBus()
>
> """
> The names have been designed, keeping in consistency of the
> nomenclature used in "add_signal_receiver" method.
> """
> NM_BUS_NAME                    = 'org.freedesktop.NetworkManager'
> NM_PATH                        = '/org/freedesktop/NetworkManager'
> NM_DBUS_INTERFACE              = 'org.freedesktop.NetworkManager'
>
> """
> Note that the following is not specifically tied to Network Manager.
> """
> DBUS_PROPS_DBUS_INTERFACE      = 'org.freedesktop.DBus.Properties'
>
> """
> Some more :)
> """
> NM_DEVICE_DBUS_INTERFACE       = 'org.freedesktop.NetworkManager.Device'
> NM_WIRED_DEVICE_INTERFACE      =
> 'org.freedesktop.NetworkManager.Device.Wired'
> NM_WIFI_DEVICE_INTERFACE       =
> 'org.freedesktop.NetworkManager.Device.Wireless'
> NM_ACCESS_POINT_DBUS_INTERFACE =
> 'org.freedesktop.NetworkManager.AccessPoint'
>
>
> class NMDbusPathProcessor:
>     """
>     This class encapsulates functions, that would be used for
>     processing any networkmanager-dbus-path.
>     """
>
>     def get_nm_object(self, nm_dbus_path):
>         """
>         returns dbus-object for the nm-dbus-path.
>         """
>         return bus.get_object(NM_BUS_NAME, nm_dbus_path)
>
>     def get_nm_props_interface(self, nm_dbus_path):
>         """
>         returns the interface, encapsulating the nm-dbus-path.
>         """
>         nm_object = self.get_nm_object(nm_dbus_path)
>         return dbus.Interface(nm_object, DBUS_PROPS_DBUS_INTERFACE)
>
>
> nm_dbus_path_processor = NMDbusPathProcessor()
>
>
> class BaseTypeProcessor:
>     """
>     This class is a virtual class; each subtype of which implements a
>     particular hierarchy of NetworkManager architecture. (or kind of :)
>     )
>     """
>
>     def __init__(self, base_path):
>         self._base_path = base_path
>         self._base_obj = nm_dbus_path_processor.get_nm_object(base_path)
>
>
>     def initiate(self):
>         """
>         Did not put in the __init__, as did not want to get into the
>         dynamics of "use-before-initialization" problem.
>         """
>         self._base_interface = dbus.Interface(self._base_obj,
>
> self.get_interface_identifier())
>
>         """
>         List the exiting things.
>         """
>         self.existing_things()
>
>
>         """
>         Add callbacks for runtime addition and removal.
>         """
>         bus.add_signal_receiver(self.thing_added_cb,
>
> signal_name=self.get_thing_added_signal_name(),
>
> dbus_interface=self.get_interface_identifier())
>         bus.add_signal_receiver(self.thing_removed_cb,
>
> signal_name=self.get_thing_removed_signal_name(),
>
> dbus_interface=self.get_interface_identifier())
>
>     def existing_things(self):
>         """
>         Returns the existing "things"
>         For eg., as a starting point of networkmanager, "things" would
>         be devices.
>         For a wireless device, "things" would be access-points.
>         """
>         all_things_func = self.get_all_things_func()
>         all_things_nm_dbus_paths = all_things_func()
>         for nm_dbus_path in all_things_nm_dbus_paths:
>             self.show_info('Found', nm_dbus_path)
>             self.extra_processing(nm_dbus_path)
>
>
>     def thing_added_cb(self, nm_dbus_path):
>         """
>         callbacks such as 'DeviceAdded', 'AccessPointAdded' always pass
>         a dbus-path to the callback method; this dbus-method is the
>         key. from which further processing takes place.
>         """
>         self.show_info('Added', nm_dbus_path)
>         self.extra_processing(nm_dbus_path)
>
>     def thing_removed_cb(self, nm_dbus_path):
>         """
>         callbacks such as 'DeviceRemoved', 'AccessPointRemoved' always
>         pass a dbus-path key. NOTE THAT NO FURTHER PROCESSING CAN BE
>         DONE ON THIS DBUS-PATH - this is the last-rites method.'
>         """
>         self.show_info('Removed', nm_dbus_path)
>         # Note that extra processing is SIMPLY NOT POSSIBLE.
>
>     def get_thing_type(self):
>         return NotImplementedError
>
>     def show_info(self, action, nm_dbus_path):
>         print '\n'
>         thing_type = self.get_thing_type()
>         print action + ' ( ' + thing_type + ' ) :: ' + nm_dbus_path
>
>     def extra_processing(self, nm_dbus_path):
>         """
>         This is optional. A subtype may choose to add extra
>         functionality"""
>         pass
>
>     def get_all_things_func(self):
>         raise NotImplementedError
>
>     def get_thing_added_signal_name(self):
>         raise NotImplementedError
>
>     def get_thing_removed_signal_name(self):
>         raise NotImplementedError
>
>     def get_interface_identifier(self):
>         raise NotImplementedError
>
>
> class NMAccessPointsProcessor(BaseTypeProcessor):
>     """
>     Processor for access-points for a (singular) device.
>     """
>
>     def __init__(self, wireless_device_nm_path):
>         BaseTypeProcessor.__init__(self, wireless_device_nm_path)
>
>     def get_thing_type(self):
>         return 'Access Point'
>
>     def get_all_things_func(self):
>         return self._base_interface.GetAccessPoints
>
>     def get_thing_added_signal_name(self):
>         return 'AccessPointAdded'
>
>     def get_thing_removed_signal_name(self):
>         return 'AccessPointRemoved'
>
>
> class NMWiredAccessPointsProcessor(NMAccessPointsProcessor):
>     """
>     Processor for access-points for a (singular) wired device.
>     """
>     """
>     THERE IS ABSOLUTELY NO CONCEPT OF SSID FOR A WIRED DEVICE.
>
>     def __init__(self, wired_device_nm_path):
>         NMAccessPointsProcessor.__init__(self, wired_device_nm_path)
>
>     def get_interface_identifier(self):
>         return NM_WIRED_DEVICE_INTERFACE
>     """
>
>
>
> class NMWirelessAccessPointsProcessor(NMAccessPointsProcessor):
>     """
>     Processor for access-points for a (singular) wirelessdevice.
>     """
>
>     def __init__(self, wireless_device_nm_path):
>         NMAccessPointsProcessor.__init__(self, wireless_device_nm_path)
>
>     def extra_processing(self, nm_wireless_access_point_path):
>         print 'SSID is :: ' + self.get_ssid(nm_wireless_access_point_path)
>
>     def get_ssid(self, nm_wireless_access_point_path):
>         access_point_obj = bus.get_object(NM_BUS_NAME,
> nm_wireless_access_point_path)
>         nm_wireless_access_point_props_interface = \
>
> nm_dbus_path_processor.get_nm_props_interface(nm_wireless_access_point_path)
>         ssid_dbus_byte_array =
> nm_wireless_access_point_props_interface.Get(NM_ACCESS_POINT_DBUS_INTERFACE,
> 'Ssid')
>
>         ssid = ""
>         for c in ssid_dbus_byte_array:
>             ssid = ssid + chr(c)
>
>         return ssid
>
>     def get_interface_identifier(self):
>         return NM_WIFI_DEVICE_INTERFACE
>
>
>
> class NMDevicesProcessor(BaseTypeProcessor):
>     """
>     Processor for devices.
>     """
>
>     def __init__(self, nm_path):
>         BaseTypeProcessor.__init__(self, nm_path)
>
>     def get_thing_type(self):
>         return 'Device'
>
>     def extra_processing(self, nm_device_path):
>         device_type = self.get_nm_device_type(nm_device_path)
>         print 'Device Type is :: ' + str(device_type)
>
>
>         """
>         I REPEAT, THERE IS NO CONCEPT OF SSID FOR A WIRED DEVICE.
>
>         if device_type == 1:
>             print '\nWired Hardware found !!'
>             NMWiredAccessPointsProcessor(nm_device_path).initiate()
>         """
>
>
>         if device_type == 2:
>             print '\nWireless Hardware found !!'
>             NMWirelessAccessPointsProcessor(nm_device_path).initiate()
>
>     def get_nm_device_type(self, nm_device_path):
>         nm_interface =
> nm_dbus_path_processor.get_nm_props_interface(nm_device_path)
>         return nm_interface.Get(NM_DEVICE_DBUS_INTERFACE, 'DeviceType')
>
>     def get_all_things_func(self):
>         return self._base_interface.GetDevices
>
>     def get_thing_added_signal_name(self):
>         return 'DeviceAdded'
>
>     def get_thing_removed_signal_name(self):
>         return 'DeviceRemoved'
>
>     def get_interface_identifier(self):
>         return NM_DBUS_INTERFACE
>
>
> try:
>     bus = dbus.SystemBus()
>     NMDevicesProcessor(NM_PATH).initiate()
> except dbus.DBusException, e:
>     print e
>
>
>
>
> import gobject
> gobject.MainLoop().run()
> =============================================================================================
>
>
>
>
> =============================================================================================
> [ajay at ajay ~]$ python learn_networkmanager.py
>
>
> Found ( Device ) :: /org/freedesktop/NetworkManager/Devices/0
> Device Type is :: 2
>
> Wireless Hardware found !!
>
>
> Found ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/13
> SSID is :: sr
>
>
> Found ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/11
> SSID is :: RT2561_6
>
>
> Found ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/0
> SSID is :: NegiJuhi
>
>
> Found ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/2
> SSID is :: Ad-hoc Network 1
>
>
> Found ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/1
> SSID is :: vanshika
>
>
> Found ( Device ) :: /org/freedesktop/NetworkManager/Devices/1
> Device Type is :: 1
>
>
> Found ( Device ) :: /org/freedesktop/NetworkManager/Devices/2
> Device Type is :: 3
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/14
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/15
> SSID is :: 24651045
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/16
> SSID is :: star
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/17
> SSID is :: MTNL
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/18
> SSID is ::
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/2
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/14
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/12
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/19
> SSID is :: Ad-hoc Network 1
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/15
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/20
> SSID is :: 24651045
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/21
> SSID is :: MANUTD
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/22
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/23
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/24
> SSID is ::
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/20
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/17
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/11
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/6
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/25
> SSID is :: RT2561_6
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/24
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/23
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/22
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/16
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/18
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/13
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/10
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/9
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/8
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/7
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/5
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/4
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/3
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/1
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/26
> SSID is :: vanshika
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/27
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/28
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/29
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/30
> SSID is ::
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/21
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/31
> SSID is :: sr
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/32
> SSID is :: 24651045
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/33
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/34
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/35
> SSID is ::
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/30
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/36
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/37
> SSID is ::
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/34
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/32
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/28
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/27
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/38
> SSID is :: star
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/39
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/40
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/41
> SSID is ::
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/37
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/36
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/35
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/33
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/31
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/42
> SSID is :: sr
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/43
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/44
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/45
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/46
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/47
> SSID is ::
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/40
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/39
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/29
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/48
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/49
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/50
> SSID is ::
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/45
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/44
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/43
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/42
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/51
> SSID is :: MTNL
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/47
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/38
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/52
> SSID is ::
>
>
> Removed ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/25
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/53
> SSID is :: RT2561_6
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/54
> SSID is :: MANUTD
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/55
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/56
> SSID is ::
>
>
> Added ( Access Point ) :: /org/freedesktop/NetworkManager/AccessPoint/57
> SSID is ::
>
> Removed ( Device ) :: /org/freedesktop/NetworkManager/Devices/2
>
> ===================================================================================
>
>
> Thanks a ton again :) :) :)
>
> Regards,
> Ajay
>
>
>
> On Wed, Mar 7, 2012 at 4:06 AM, Sascha Silbe <silbe at activitycentral.com>
> wrote:
>>
>> Excerpts from Ajay Garg's message of 2012-03-03 04:46:33 +0100:
>>
>> > I have written a very basic python program, that utilizes Networkmanager
>> > dbus-apis, to detect addition/removal of network devices.
>> > It's working as expected, when I insert a 3G USB modem (both addition
>> > and
>> > removal callbacks are hit as expected).
>> >
>> > However, when I try this with
>> >
>> > a. Inserting/Removing a wired network jack
>> > b. Enable/Disable Wireless from the Dell Keyboard
>> > c. On/Off the wireless modem-cum-router-cum-accesspoint
>> >
>> > neither of the callbacks is hit.
>>
>> Yes, that's expected. The signals you connect to are for network
>> _hardware_ (dis)appearing.
>>
>> a) is just making a new (wired) network on the existing wired ethernet
>>   interface available. NM will usually connect automatically to this
>>   new network ASAP.
>>
>> b) depends on how its implemented in hardware. On the XO-1, it would
>>   power down the wireless network module completely, causing it to drop
>>   off from USB and thus really cause a DeviceRemoved / DeviceAdded
>>   signal. On most systems, only the radio gets disabled, so the device
>>   will stay visible.
>>
>> c) is just making a wireless network (un)available. Depending on
>>   settings, NM may or may not try to connect to it automatically. In
>>   any case there's no hardware that (dis)appears, just a network
>>   (Basic Service Set (BSS) in IEEE 802.11-speak).
>>
>>
>> If you want to see NM connecting to networks, you can either listen to
>> the StateChanged signal on each device (to see when/if you're connected)
>> or monitor [1] the (global) ActiveConnections property (which gives you
>> a list of object paths of the active connection objects [2] that you can
>> examine further).
>>
>> Sascha
>>
>> [1]
>> http://projects.gnome.org/NetworkManager/developers/spec-08.html#org.freedesktop.NetworkManager.PropertiesChanged
>> [2]
>> http://projects.gnome.org/NetworkManager/developers/spec-08.html#org.freedesktop.NetworkManager.Connection.Active
>> --
>> http://sascha.silbe.org/
>> http://www.infra-silbe.de/
>
>


More information about the Dextrose mailing list