2 #include <QSocketNotifier>
10 DhcpcdWi::DhcpcdWi(DhcpcdQt *parent, DHCPCD_WPA *wpa)
13 this->dhcpcdQt = parent;
17 int fd = dhcpcd_wpa_get_fd(wpa);
18 notifier = new QSocketNotifier(fd, QSocketNotifier::Read);
19 connect(notifier, SIGNAL(activated(int)), this, SLOT(dispatch()));
20 retryOpenTimer = NULL;
26 dhcpcd_wi_scans_free(scans);
31 DHCPCD_WPA * DhcpcdWi::getWpa()
37 DHCPCD_WI_SCAN *DhcpcdWi::getScans()
42 void DhcpcdWi::setScans(DHCPCD_WI_SCAN *scans)
45 dhcpcd_wi_scans_free(this->scans);
49 void DhcpcdWi::wpaOpen()
51 int fd = dhcpcd_wpa_open(wpa);
52 static int last_error;
55 if (errno != last_error) {
57 qCritical("%s: dhcpcd_wpa_open: %s",
58 dhcpcd_wpa_if(wpa)->ifname,
59 strerror(last_error));
64 notifier = new QSocketNotifier(fd, QSocketNotifier::Read);
65 connect(notifier, SIGNAL(activated(int)), this, SLOT(dispatch()));
67 delete retryOpenTimer;
68 retryOpenTimer = NULL;
72 void DhcpcdWi::dispatch()
75 if (dhcpcd_wpa_get_fd(wpa) == -1) {
78 DHCPCD_IF *i = dhcpcd_wpa_if(wpa);
80 strcmp(i->reason, "DEPARTED") == 0 ||
81 strcmp(i->reason, "STOPPED") == 0)
85 qPrintable(tr("dhcpcd WPA connection lost")));
86 if (retryOpenTimer == NULL) {
87 retryOpenTimer = new QTimer(this);
88 connect(retryOpenTimer, SIGNAL(timeout()),
89 this, SLOT(wpaOpen()));
90 retryOpenTimer->start(DHCPCD_RETRYOPEN);
95 dhcpcd_wpa_dispatch(wpa);