summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2017-11-06 13:45:47 +0000
committerRoy Marples <roy@marples.name>2017-11-06 13:45:47 +0000
commited60b357213cb8d90e10483e37fa343ddb346a0c (patch)
tree1570c32be78adf8513e3f9ff8a0726cc917cd4fe
parent03789633486277c4ff8a83d63fa636e5f5f88050 (diff)
downloaddhcpcd-ui-ed60b357213cb8d90e10483e37fa343ddb346a0c.tar.xz
Don't spam the user about new AP's if we're connected already.
-rw-r--r--src/dhcpcd-gtk/main.c45
-rw-r--r--src/dhcpcd-qt/dhcpcd-qt.cpp39
2 files changed, 47 insertions, 37 deletions
diff --git a/src/dhcpcd-gtk/main.c b/src/dhcpcd-gtk/main.c
index 00e18d8..6444bf8 100644
--- a/src/dhcpcd-gtk/main.c
+++ b/src/dhcpcd-gtk/main.c
@@ -584,9 +584,8 @@ dhcpcd_wpa_scan_cb(DHCPCD_WPA *wpa, _unused void *data)
DHCPCD_IF *i;
WI_SCAN *w;
DHCPCD_WI_SCAN *scans, *s1, *s2;
- char *txt, *t;
- int lerrno, fd;
const char *msg;
+ int lerrno, fd;
/* This could be a new WPA so watch it */
fd = dhcpcd_wpa_get_fd(wpa);
@@ -621,27 +620,31 @@ dhcpcd_wpa_scan_cb(DHCPCD_WPA *wpa, _unused void *data)
TAILQ_INIT(&w->menus);
TAILQ_INSERT_TAIL(&wi_scans, w, next);
} else {
- txt = NULL;
- msg = N_("New Access Point");
- for (s1 = scans; s1; s1 = s1->next) {
- for (s2 = w->scans; s2; s2 = s2->next)
- if (g_strcmp0(s1->ssid, s2->ssid) == 0)
- break;
- if (s2 == NULL) {
- if (txt == NULL)
- txt = g_strdup(s1->ssid);
- else {
- msg = N_("New Access Points");
- t = g_strconcat(txt, "\n",
- s1->ssid, NULL);
- g_free(txt);
- txt = t;
+ if (!i->up) {
+ char *txt, *t;
+
+ txt = NULL;
+ msg = N_("New Access Point");
+ for (s1 = scans; s1; s1 = s1->next) {
+ for (s2 = w->scans; s2; s2 = s2->next)
+ if (g_strcmp0(s1->ssid, s2->ssid) == 0)
+ break;
+ if (s2 == NULL) {
+ if (txt == NULL)
+ txt = g_strdup(s1->ssid);
+ else {
+ msg = N_("New Access Points");
+ t = g_strconcat(txt, "\n",
+ s1->ssid, NULL);
+ g_free(txt);
+ txt = t;
+ }
}
}
- }
- if (txt) {
- notify(msg, txt, "network-wireless");
- g_free(txt);
+ if (txt) {
+ notify(msg, txt, "network-wireless");
+ g_free(txt);
+ }
}
menu_update_scans(w, scans);
}
diff --git a/src/dhcpcd-qt/dhcpcd-qt.cpp b/src/dhcpcd-qt/dhcpcd-qt.cpp
index 98c2a05..b7932a4 100644
--- a/src/dhcpcd-qt/dhcpcd-qt.cpp
+++ b/src/dhcpcd-qt/dhcpcd-qt.cpp
@@ -368,26 +368,33 @@ DhcpcdWi *DhcpcdQt::findWi(DHCPCD_WPA *wpa)
void DhcpcdQt::processScans(DhcpcdWi *wi, DHCPCD_WI_SCAN *scans)
{
- DHCPCD_WI_SCAN *s1, *s2;
+ DHCPCD_IF *i;
- QString title = tr("New Access Point");
- QString txt;
- for (s1 = scans; s1; s1 = s1->next) {
- for (s2 = wi->getScans(); s2; s2 = s2->next) {
- if (strcmp(s1->ssid, s2->ssid) == 0)
- break;
- }
- if (s2 == NULL) {
- if (!txt.isEmpty()) {
- title = tr("New Access Points");
- txt += '\n';
+ /* Don't spam the user if we're already connected. */
+ i = dhcpcd_wpa_if(wi->getWpa());
+
+ if (!i->up) {
+ QString title = tr("New Access Point");
+ QString txt;
+ DHCPCD_WI_SCAN *s1, *s2;
+
+ for (s1 = scans; s1; s1 = s1->next) {
+ for (s2 = wi->getScans(); s2; s2 = s2->next) {
+ if (strcmp(s1->ssid, s2->ssid) == 0)
+ break;
+ }
+ if (s2 == NULL) {
+ if (!txt.isEmpty()) {
+ title = tr("New Access Points");
+ txt += '\n';
+ }
+ txt += s1->ssid;
}
- txt += s1->ssid;
}
+ if (!txt.isEmpty() &&
+ (ssidMenu == NULL || !ssidMenu->isVisible()))
+ notify(title, txt, "network-wireless");
}
- if (!txt.isEmpty() &&
- (ssidMenu == NULL || !ssidMenu->isVisible()))
- notify(title, txt, "network-wireless");
if (wi->setScans(scans) && ssidMenu && ssidMenu->isVisible())
ssidMenu->popup(ssidMenuPos);