Ticket #9666: networkstatus.patch

File networkstatus.patch, 4.2 KB (added by przemub, 11 years ago)
  • src/apps/networkstatus/NetworkStatus.rdef

    commit 3da645d67eb02fce86823179c4ebdbf1ef67fba6
    Author: Przemysław Buczkowski <przemub@przemub.pl>
    Date:   Fri Nov 8 22:54:33 2013 +0100
    
        NetworkStatus: show authentication mode in WiFi list (bug #9666)
        
        * now WirelessNetworkMenuItem appends authentication mode to its label
        
        Signed-off-by: Przemysław Buczkowski <przemub@przemub.pl>
    
    diff --git a/src/apps/networkstatus/NetworkStatus.rdef b/src/apps/networkstatus/NetworkStatus.rdef
    index c2d9389..d78e346 100644
    a b resource app_version {  
    1414    internal = 0,
    1515
    1616    short_info = "NetworkStatus",
    17     long_info = "NetworkStatus ©2007-2009 Haiku"
     17    long_info = "NetworkStatus ©2007-2013 Haiku"
    1818};
    1919
    2020resource vector_icon {
  • src/apps/networkstatus/NetworkStatusView.cpp

    diff --git a/src/apps/networkstatus/NetworkStatusView.cpp b/src/apps/networkstatus/NetworkStatusView.cpp
    index 45b5a4a..4c338dd 100644
    a b NetworkStatusView::MouseDown(BPoint point)  
    472472            message->AddFlat("address", &network.address);
    473473
    474474            BMenuItem* item = new WirelessNetworkMenuItem(network.name,
    475                 network.signal_strength,
    476                 (network.flags & B_NETWORK_IS_ENCRYPTED) != 0, message);
     475                network.signal_strength, network.authentication_mode, message);
    477476            menu->AddItem(item);
    478477            if (associated.find(network.address) != associated.end())
    479478                item->SetMarked(true);
  • src/apps/networkstatus/WirelessNetworkMenuItem.cpp

    diff --git a/src/apps/networkstatus/WirelessNetworkMenuItem.cpp b/src/apps/networkstatus/WirelessNetworkMenuItem.cpp
    index 043f293..0ee6345 100644
    a b  
    66
    77#include "WirelessNetworkMenuItem.h"
    88
     9#include <Catalog.h>
     10#include <NetworkDevice.h>
     11#include <String.h>
     12
    913#include "RadioView.h"
    1014
     15#undef B_TRANSLATION_CONTEXT
     16#define B_TRANSLATION_CONTEXT "WirelessNetworkMenuItem"
     17
    1118
    1219WirelessNetworkMenuItem::WirelessNetworkMenuItem(const char* name,
    13     int32 signalQuality, bool encrypted, BMessage* message)
     20    int32 signalQuality, int32 authenticationMode, BMessage* message)
    1421    :
    1522    BMenuItem(name, message),
    16     fQuality(signalQuality),
    17     fIsEncrypted(encrypted)
     23    fQuality(signalQuality)
    1824{
     25    // Append authentication mode to label
     26    BString label = B_TRANSLATE("%name% (%authenticationMode%)");
     27    label.Replace("%name%", name, 1);
     28    label.Replace("%authenticationMode%",
     29        AuthenticationName(authenticationMode), 1);
     30
     31    SetLabel(label.String());
    1932}
    2033
    2134
    WirelessNetworkMenuItem::SetSignalQuality(int32 quality)  
    3043    fQuality = quality;
    3144}
    3245
     46BString
     47WirelessNetworkMenuItem::AuthenticationName(int32 mode)
     48{
     49    switch (mode) {
     50        default:
     51        case B_NETWORK_AUTHENTICATION_NONE:
     52            return B_TRANSLATE_CONTEXT("open", "Open network");
     53            break;
     54        case B_NETWORK_AUTHENTICATION_WEP:
     55            return B_TRANSLATE_CONTEXT("WEP", "WEP protected network");
     56            break;
     57        case B_NETWORK_AUTHENTICATION_WPA:
     58            return B_TRANSLATE_CONTEXT("WPA", "WPA protected network");
     59            break;
     60        case B_NETWORK_AUTHENTICATION_WPA2:
     61            return B_TRANSLATE_CONTEXT("WPA2", "WPA2 protected network");
     62            break;
     63        case B_NETWORK_AUTHENTICATION_EAP:
     64            return B_TRANSLATE_CONTEXT("EAP", "EAP protected network");
     65            break;
     66    }
     67}
    3368
    3469void
    3570WirelessNetworkMenuItem::DrawContent()
  • src/apps/networkstatus/WirelessNetworkMenuItem.h

    diff --git a/src/apps/networkstatus/WirelessNetworkMenuItem.h b/src/apps/networkstatus/WirelessNetworkMenuItem.h
    index 83e18f9..4e04817 100644
    a b  
    1212class WirelessNetworkMenuItem : public BMenuItem {
    1313public:
    1414                                WirelessNetworkMenuItem(const char* name,
    15                                     int32 signalQuality, bool encrypted,
     15                                    int32 signalQuality, int32 authenticationMode,
    1616                                    BMessage* message);
    1717    virtual                     ~WirelessNetworkMenuItem();
    1818
    1919            void                SetSignalQuality(int32 quality);
    2020            int32               SignalQuality() const
    2121                                    { return fQuality; }
    22             bool                IsEncrypted() const
    23                                     { return fIsEncrypted; }
     22            BString             AuthenticationName(int32 mode);
    2423
    2524protected:
    2625    virtual void                DrawContent();
    protected:  
    3029
    3130private:
    3231            int32               fQuality;
    33             bool                fIsEncrypted;
    3432};
    3533
    3634