summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/irdaapplet/irda.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp
index e21f191..5b23330 100644
--- a/core/applets/irdaapplet/irda.cpp
+++ b/core/applets/irdaapplet/irda.cpp
@@ -74,74 +74,80 @@ IrdaApplet::~IrdaApplet() {
int IrdaApplet::checkIrdaStatus() {
struct ifreq ifr;
strcpy(ifr.ifr_name, "irda0");
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr))
return -1;
return (ifr.ifr_flags & IFF_UP)?1:0;
}
int IrdaApplet::setIrdaStatus(int c) {
struct ifreq ifr;
strcpy(ifr.ifr_name, "irda0");
if (ioctl(sockfd, SIOCGIFFLAGS, &ifr))
return -1;
if (c)
ifr.ifr_flags |= IFF_UP;
else
ifr.ifr_flags &= ~IFF_UP;
if (ioctl(sockfd, SIOCSIFFLAGS, &ifr))
return -1;
return 0;
}
int IrdaApplet::checkIrdaDiscoveryStatus() {
+
QFile discovery("/proc/sys/net/irda/discovery");
- char status;
- discovery.open( IO_ReadOnly|IO_Raw );
- discovery.readBlock (&status, 1);
+ QString streamIn = "0";
+
+ if (discovery.open(IO_ReadOnly) ) {
+ QTextStream stream ( &discovery );
+ streamIn = stream.read();
+ }
+
discovery.close();
- return atoi(&status);
+ return( streamIn.toInt() );
}
+
int IrdaApplet::setIrdaDiscoveryStatus(int d) {
QFile discovery("/proc/sys/net/irda/discovery");
discovery.open( IO_WriteOnly|IO_Raw );
if (d)
discovery.putch('1');
else
discovery.putch('0');
discovery.close();
return 0;
}
void IrdaApplet::showDiscovered() {
QFile discovery("/proc/net/irda/discovery");
if (discovery.open(IO_ReadOnly) ) {
QStringList list;
// since it is /proc we _must_ use QTextStream
QTextStream stream ( &discovery);
QString streamIn;
streamIn = stream.read();
list = QStringList::split("\n", streamIn);
for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) {
if( (*line).startsWith("nickname:") ){
discoveredDevice = (*line).mid(((*line).find(':'))+1,(*line).find(',')-(*line).find(':')-1);
qDebug(discoveredDevice);
}