Exemple #1
0
def nmc_new(io_priority=GLib.PRIORITY_DEFAULT, cancellable=None):
    # create a NMClient instance using the async initialization
    # (but the function itself iterates the main context until
    # the initialization completes).

    result = []

    def cb(source_object, res):

        try:
            source_object.init_finish(res)
        except Exception as e:
            result.append(e)
        else:
            result.append(None)

    nmc = NM.Client()
    nmc.init_async(io_priority, cancellable, cb)
    while not result:
        nmc.get_main_context().iteration(may_block=True)

    if result[0]:
        raise result[0]

    log("initialized NMClient cache")

    return nmc
Exemple #2
0
    def __init__(self):

        self.nm = NM.Client()
        self.nm.init()
        for dev in self.nm.get_all_devices():
            if isinstance(dev, NM.DeviceP2PWifi):
                self.dev = dev
                break
        else:
            raise AssertionError("No P2P Wifi device was found!")
    def __init__(self, connmgr):
        logging.debug("Constructing NetworkManager logger")
        self.connmgr = connmgr
        logging.debug("Connecting client signal for connection added callback")
        self.nmclient = NM.Client()
        #self.nmclient.connect('connection-added', self.connection_added_cb)

        # self.proxy = dbus.SystemBus().get_object(
        #     self.BUS_NAME, self.OBJECT_PATH)
        # self.iface = dbus.Interface(
        #     self.proxy, dbus_interface=self.INTERFACE_NAME)
        # self.iface.connect_to_signal('NewConnection', self.new_connection_cb)

        self.dbus_conn = Gio.bus_get_sync(Gio.BusType.SYSTEM)

        subs_id = self.dbus_conn.signal_subscribe(self.BUS_NAME,
                                                  self.INTERFACE_NAME,
                                                  'NewConnection',
                                                  self.OBJECT_PATH, None,
                                                  Gio.DBusSignalFlags.NONE,
                                                  self.new_connection_cb, None)
Exemple #4
0
def have_wireless_networks():
    return network.have_wireless_networks()


def get_publish_information():
    settings = Gio.Settings('org.sugarlabs.collaboration')
    publish = settings.get_boolean('publish-gadget')
    return publish


def print_publish_information():
    print(get_publish_information())


def set_publish_information(value):
    """ If set to true, Sugar will make you searchable for
    the other users of the Jabber server.
    value: 0/1
    """
    try:
        value = (False, True)[int(value)]
    except:
        raise ValueError(_('Error in specified argument. Use 0/1.'))

    settings = Gio.Settings('org.sugarlabs.collaboration')
    settings.set_boolean('publish-gadget', value)
    return 0


nm_client = NM.Client()