Example #1
0
def _connect_thread_(wiface, network_name, passphrase, encryption,
                     thread_finish_cb):
    '''
    This function runs in a thread so we can run a spinner alongside.

    :param wiface: wifi card id
    :param network_name: network id
    :param passphrase: password entered by user
    :param encryption: type of encryption
    :param disable_widget_cb: the callback for any widgets that need to be
                              disabled
    :param thread_finish_cb: the callback to be run when the thread is finished
    '''

    success = connect(wiface, network_name, encryption, passphrase)

    # save the connection in cache so it reconnects on next system boot
    wificache = KwifiCache()
    if success:
        wificache.save(network_name, encryption, passphrase)
    else:
        wificache.empty()

    logger.debug(
        "Connecting to {} {} {}. Successful: {}".format(
            network_name, encryption, passphrase, success
        )
    )

    GObject.idle_add(thread_finish_cb, success)
Example #2
0
def disconnect_wifi():
    from kano.network import KwifiCache, disconnect
    from kano.gtk3.kano_dialog import KanoDialog

    iface = get_wlan_device()
    disconnect(iface)
    wificache = KwifiCache()
    wificache.empty()

    kdialog = KanoDialog(
        # Text from the content team.
        _("Disconnect complete - you're now offline."),
    )
    kdialog.run()

    return 0
Example #3
0
def _connect_thread_(wiface, network_name, passphrase, encryption,
                     thread_finish_cb):
    '''
    This function runs in a thread so we can run a spinner alongside.

    :param wiface: wifi card id
    :param network_name: network id
    :param passphrase: password entered by user
    :param encryption: type of encryption
    :param disable_widget_cb: the callback for any widgets that need to be
                              disabled
    :param thread_finish_cb: the callback to be run when the thread is finished
    '''

    rc = connect(wiface, network_name, encryption, passphrase)

    # save the connection in cache so it reconnects on next system boot
    wificache = KwifiCache()
    if not rc:
        wificache.save(network_name, encryption, passphrase)
    else:
        wificache.empty()

    logger.debug("Connecting to {} {} {}. Return code: {}".format(
        network_name, encryption, passphrase, rc))

    GObject.idle_add(thread_finish_cb, rc)