If we don't understand the AP security (such as EAP) then disable the
authorRoy Marples <roy@marples.name>
Sun, 31 Jul 2016 13:51:47 +0000 (13:51 +0000)
committerRoy Marples <roy@marples.name>
Sun, 31 Jul 2016 13:51:47 +0000 (13:51 +0000)
SSID in the menu.
Partial fix for [0ae4f29bf5].

src/dhcpcd-gtk/menu.c
src/dhcpcd-qt/dhcpcd-ssidmenu.cpp
src/dhcpcd-qt/dhcpcd-ssidmenuwidget.cpp
src/dhcpcd-qt/dhcpcd-ssidmenuwidget.h

index ce23424227477c9a8af1041839b9f84892d688ee..1c554baf42134de1c14f2d1345fec863bbadbf87 100644 (file)
@@ -100,11 +100,30 @@ is_associated(WI_SCAN *wi, DHCPCD_WI_SCAN *scan)
        return dhcpcd_wi_associated(wi->interface, scan);
 }
 
+static bool
+get_security_icon(int flags, const char **icon)
+{
+       bool active;
+
+       active = true;
+       if (flags & WSF_SECURE) {
+               if (flags & WSF_PSK)
+                       *icon = "network-wireless-encrypted";
+               else {
+                       *icon = "network-error";        
+                       active = false;
+               }
+       } else
+               *icon = "dialog-warning";
+       return active;
+}
+
 static void
 update_item(WI_SCAN *wi, WI_MENU *m, DHCPCD_WI_SCAN *scan)
 {
        const char *icon;
        GtkWidget *sel;
+       bool active;
 
        m->scan = scan;
 
@@ -128,12 +147,12 @@ update_item(WI_SCAN *wi, WI_MENU *m, DHCPCD_WI_SCAN *scan)
                g_free(lbl);
        } else
                gtk_label_set_text(GTK_LABEL(m->ssid), scan->ssid);
-       if (scan->flags & WSF_SECURE)
-               icon = "network-wireless-encrypted";
-       else
-               icon = "dialog-warning";
+       
+       active = get_security_icon(scan->flags, &icon);
        m->icon = gtk_image_new_from_icon_name(icon,
            GTK_ICON_SIZE_MENU);
+       if (gtk_widget_get_sensitive(GTK_WIDGET(m->menu)) != active)
+               gtk_widget_set_sensitive(GTK_WIDGET(m->menu), active);
 
        icon = get_strength_icon_name(scan->strength.value);
        m->strength = gtk_image_new_from_icon_name(icon,
@@ -170,10 +189,7 @@ create_menu(WI_SCAN *wis, DHCPCD_WI_SCAN *scan)
        gtk_misc_set_alignment(GTK_MISC(wim->ssid), 0.0, 0.5);
        gtk_box_pack_start(GTK_BOX(box), wim->ssid, TRUE, TRUE, 0);
 
-       if (scan->flags & WSF_SECURE)
-               icon = "network-wireless-encrypted";
-       else
-               icon = "dialog-warning";
+       get_security_icon(scan->flags, &icon);
        wim->icon = gtk_image_new_from_icon_name(icon,
            GTK_ICON_SIZE_MENU);
        gtk_box_pack_start(GTK_BOX(box), wim->icon, FALSE, FALSE, 0);
index 6c60ec89757ae750dc092ff2a66801766f31e8a3..a60438c258c41778785a15320e57233210ca49e9 100644 (file)
@@ -54,6 +54,7 @@ QWidget *DhcpcdSsidMenu::createWidget(QWidget *parent)
        ssidWidget = new DhcpcdSsidMenuWidget(parent, wi, scan);
        connect(ssidWidget, SIGNAL(hovered()), this, SLOT(hover()));
        connect(ssidWidget, SIGNAL(triggered()), this, SLOT(trigger()));
+       setEnabled(false);
        return ssidWidget;
 }
 
index d980dba37ecf1c1c47423fcf8db0c45ba4b6ad66..71ff1aaa212ac3faccc39693a31db29aa0e4a165 100644 (file)
@@ -46,6 +46,7 @@ DhcpcdSsidMenuWidget::DhcpcdSsidMenuWidget(QWidget *parent,
 
        this->wi = wi;
        this->scan = scan;
+       this->active = true;
 
        QHBoxLayout *layout = new QHBoxLayout(this);
        layout->setContentsMargins(1, 1, 1, 1);
@@ -88,12 +89,28 @@ bool DhcpcdSsidMenuWidget::isAssociated()
        return associated;
 }
 
+bool DhcpcdSsidMenuWidget::isActive()
+{
+
+       return active;
+}
+
+void DhcpcdSsidMenuWidget::setActive(bool active)
+{
+
+       if (this->active != active) {
+               this->ssid->setEnabled(active);
+               this->active = active;
+       }
+}
+
 void DhcpcdSsidMenuWidget::setScan(DHCPCD_WI_SCAN *scan)
 {
        DHCPCD_WPA *wpa;
        DHCPCD_IF *i;
        QIcon icon;
        QPixmap picon;
+       bool active;
 
        this->scan = scan;
        wpa = wi->getWpa();
@@ -119,10 +136,17 @@ void DhcpcdSsidMenuWidget::setScan(DHCPCD_WI_SCAN *scan)
                ssid->setStyleSheet(NULL);
        }
        ssid->setText(scan->ssid);
-       if (scan->flags & WSF_SECURE)
-               icon = DhcpcdQt::getIcon("status",
-                   "network-wireless-encrypted");
-       else
+       active = true;
+       if (scan->flags & WSF_SECURE) {
+               if (scan->flags & WSF_PSK)
+                       icon = DhcpcdQt::getIcon("status",
+                           "network-wireless-encrypted");
+               else {
+                       icon = DhcpcdQt::getIcon("status",
+                           "network-error");
+                       active = false;
+               }
+       } else
                icon = DhcpcdQt::getIcon("status", "dialog-warning");
        picon = icon.pixmap(ICON_SIZE);
        if (picon.height() != ICON_SIZE)
@@ -135,19 +159,26 @@ void DhcpcdSsidMenuWidget::setScan(DHCPCD_WI_SCAN *scan)
        if (picon.height() != ICON_SIZE)
                picon = picon.scaledToHeight(ICON_SIZE, Qt::SmoothTransformation);
        stricon->setPixmap(picon);
+
+       setActive(active);
 }
 
 bool DhcpcdSsidMenuWidget::eventFilter(QObject *, QEvent *event)
 {
 
-       if (event->type() == QEvent::MouseButtonPress)
-               emit triggered();
+       if (event->type() == QEvent::MouseButtonPress) {
+               if (active)
+                       emit triggered();
+       }
        return false;
 }
 
 void DhcpcdSsidMenuWidget::enterEvent(QEvent *)
 {
 
+       if (!active)
+               return;
+
        if (associated)
                ssid->setStyleSheet("color:palette(highlighted-text); font:bold;");
        else
@@ -158,6 +189,9 @@ void DhcpcdSsidMenuWidget::enterEvent(QEvent *)
 void DhcpcdSsidMenuWidget::leaveEvent(QEvent *)
 {
 
+       if (!active)
+               return;
+
        if (associated)
                ssid->setStyleSheet("color:palette(text); font:bold;");
        else
index b84d2c30f829133a7e4d30e69e00cf5c362db7a0..7b0958de307a5c956c76c6d4a6dfc94c1771fae5 100644 (file)
@@ -44,6 +44,8 @@ public:
        DHCPCD_WI_SCAN *getScan();
        void setScan(DHCPCD_WI_SCAN *scan);
        bool isAssociated();
+       bool isActive();
+       void setActive(bool active);
 
 signals:
        void triggered();
@@ -60,6 +62,7 @@ private:
        DhcpcdWi *wi;
        DHCPCD_WI_SCAN *scan;
        bool associated;
+       bool active;
 
        QLabel *selicon;
        QLabel *ssid;