exit(EXIT_FAILURE);
return;
}
+ dhcpcd_set_progname(con, "dhcpcd-qt");
dhcpcd_set_status_callback(con, dhcpcd_status_cb, this);
dhcpcd_set_if_callback(con, dhcpcd_if_cb, this);
dhcpcd_wpa_set_scan_callback(con, dhcpcd_wpa_scan_cb, this);
DhcpcdQt::~DhcpcdQt()
{
- qDeleteAll(*wis);
- delete wis;
-
if (con != NULL) {
dhcpcd_close(con);
dhcpcd_free(con);
}
free(lastStatus);
+
+ qDeleteAll(*wis);
+ delete wis;
+
+}
+
+DHCPCD_CONNECTION *DhcpcdQt::getConnection()
+{
+
+ return con;
+}
+
+QList<DhcpcdWi *> *DhcpcdQt::getWis()
+{
+
+ return wis;
}
void DhcpcdQt::animate()
aniCounter = 0;
onLine = carrier = false;
setIcon("status", "network-offline");
+ trayIcon->setToolTip(tr("Not connected to dhcpcd"));
+ /* Close down everything */
if (notifier) {
delete notifier;
notifier = NULL;
}
- trayIcon->setToolTip(tr("Not connected to dhcpcd"));
+ if (ssidMenu) {
+ delete ssidMenu;
+ ssidMenu = NULL;
+ }
+ if (preferences) {
+ delete preferences;
+ preferences = NULL;
+ }
+ preferencesAction->setEnabled(false);
} else {
bool refresh;
}
void DhcpcdQt::tryOpen() {
- int fd = dhcpcd_open(con);
+ int fd = dhcpcd_open(con, true);
static int last_error;
if (fd == -1) {
+ if (errno == EACCES || errno == EPERM) {
+ if ((fd = dhcpcd_open(con, false)) != -1)
+ goto unprived;
+ }
if (errno != last_error) {
last_error = errno;
- qCritical("dhcpcd_open: %s", strerror(errno));
+ const char *errt = strerror(errno);
+ qCritical("dhcpcd_open: %s", errt);
+ trayIcon->setToolTip(
+ tr("Error connecting to dhcpcd: %1").arg(errt));
}
if (retryOpenTimer == NULL) {
retryOpenTimer = new QTimer(this);
return;
}
+unprived:
/* Start listening to WPA events */
dhcpcd_wpa_start(con);
notifier = new QSocketNotifier(fd, QSocketNotifier::Read);
connect(notifier, SIGNAL(activated(int)), this, SLOT(dispatch()));
+
+ preferencesAction->setEnabled(dhcpcd_privileged(con));
}
void DhcpcdQt::dispatch() {
preferencesAction = new QAction(tr("&Preferences"), this);
preferencesAction->setIcon(QIcon::fromTheme("preferences-system-network"));
+ preferencesAction->setEnabled(false);
connect(preferencesAction, SIGNAL(triggered()),
this, SLOT(showPreferences()));