Ticket #8850: 0004-eap-Add-initial-option-to-dialog.patch

File 0004-eap-Add-initial-option-to-dialog.patch, 3.3 KB (added by kallisti5, 11 years ago)

wpa_supplicant change v1

  • wpa_supplicant/WirelessConfigDialog.cpp

    From 8f0cba5cb83e8529316db147ccfaf3438fed59cb Mon Sep 17 00:00:00 2001
    From: Alexander von Gluck IV <kallisti5@unixzen.com>
    Date: Fri, 2 Aug 2013 02:26:38 -0500
    Subject: [PATCH 4/4] eap: Add initial option to dialog
    
    ---
     wpa_supplicant/WirelessConfigDialog.cpp |   33 ++++++++++++++++++++++++++++---
     1 file changed, 30 insertions(+), 3 deletions(-)
    
    diff --git a/wpa_supplicant/WirelessConfigDialog.cpp b/wpa_supplicant/WirelessConfigDialog.cpp
    index 6fdad6a..8c78f2e 100644
    a b public:  
    3838    WirelessConfigView()
    3939        :
    4040        BView("WirelessConfigView", B_WILL_DRAW),
     41        fUsername(NULL),
    4142        fPassword(NULL)
    4243    {
    4344        SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
    public:  
    7879        authMenu->AddItem(fAuthWEP);
    7980        fAuthWPA = new(std::nothrow) BMenuItem("WPA/WPA2", NULL);
    8081        authMenu->AddItem(fAuthWPA);
     82        fAuthWPAEAP = new(std::nothrow) BMenuItem("WPA/WPA2 Enterprise", NULL);
     83        authMenu->AddItem(fAuthWPAEAP);
    8184
    8285        BMenuField* authMenuField = new(std::nothrow) BMenuField(
    8386            "Authentication:", authMenu);
    public:  
    8790        layout->AddItem(authMenuField->CreateLabelLayoutItem(), 0, row);
    8891        layout->AddItem(authMenuField->CreateMenuBarLayoutItem(), 1, row++);
    8992
     93        fUsername = new(std::nothrow) BTextControl("Username:", "", NULL);
     94        if (fUsername == NULL)
     95            return;
     96
     97        BLayoutItem* usernameItem = fUsername->CreateTextViewLayoutItem();
     98        layout->AddItem(fUsername->CreateLabelLayoutItem(), 0, row);
     99        layout->AddItem(usernameItem, 1, row++);
     100
    90101        fPassword = new(std::nothrow) BTextControl("Password:", "", NULL);
    91102        if (fPassword == NULL)
    92103            return;
    93104
    94         BLayoutItem* layoutItem = fPassword->CreateTextViewLayoutItem();
    95         layoutItem->SetExplicitMinSize(BSize(fPassword->StringWidth(
     105        BLayoutItem* passwordItem = fPassword->CreateTextViewLayoutItem();
     106        passwordItem->SetExplicitMinSize(BSize(fPassword->StringWidth(
    96107                "0123456789012345678901234567890123456789") + inset,
    97108            B_SIZE_UNSET));
    98109
    99110        layout->AddItem(fPassword->CreateLabelLayoutItem(), 0, row);
    100         layout->AddItem(layoutItem, 1, row++);
     111        layout->AddItem(passwordItem, 1, row++);
    101112
    102113        fPersist = new(std::nothrow) BCheckBox("Store this configuration");
    103114        layout->AddItem(BSpaceLayoutItem::CreateGlue(), 0, row);
    public:  
    152163            case B_NETWORK_AUTHENTICATION_WPA2:
    153164                fAuthWPA->SetMarked(true);
    154165                break;
     166            case B_NETWORK_AUTHENTICATION_EAP:
     167                fAuthWPAEAP->SetMarked(true);
     168                BString username;
     169                if (message.FindString("username", &username)
     170                        == B_OK) {
     171                    fUsername->SetText(username);
     172                }
     173                fUsername->SetText(username);
     174                break;
    155175        }
    156176
    157177        BString password;
    public:  
    170190            authMode = B_NETWORK_AUTHENTICATION_WEP;
    171191        else if (fAuthWPA->IsMarked())
    172192            authMode = B_NETWORK_AUTHENTICATION_WPA;
     193        else if (fAuthWPAEAP->IsMarked()) {
     194            authMode = B_NETWORK_AUTHENTICATION_EAP;
     195            message.RemoveName("username");
     196            message.AddString("username", fUsername->Text());
     197        }
    173198
    174199        message.RemoveName("authentication");
    175200        message.AddUInt32("authentication", authMode);
    private:  
    186211    BMenuItem* fAuthOpen;
    187212    BMenuItem* fAuthWEP;
    188213    BMenuItem* fAuthWPA;
     214    BMenuItem* fAuthWPAEAP;
     215    BTextControl* fUsername;
    189216    BTextControl* fPassword;
    190217    BCheckBox* fPersist;
    191218    BButton* fCancelButton;