author | harlekin <harlekin> | 2002-06-19 00:37:35 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-19 00:37:35 (UTC) |
commit | 0f9955585ccaa45db582640c415b97de67bc8555 (patch) (unidiff) | |
tree | b976ce4baad6f407b998e1119c73bfaf0e7fd631 | |
parent | 35ecb27ed64368d30d6360cbd5e30acf3a216a46 (diff) | |
download | opie-0f9955585ccaa45db582640c415b97de67bc8555.zip opie-0f9955585ccaa45db582640c415b97de67bc8555.tar.gz opie-0f9955585ccaa45db582640c415b97de67bc8555.tar.bz2 |
no more permanent QFile::writeBlock: Write operation not permitted, and also its now more c++ rather than c style , the discovery part
-rw-r--r-- | core/applets/irdaapplet/irda.cpp | 14 |
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 | |||
@@ -90,42 +90,48 @@ int IrdaApplet::setIrdaStatus(int c) { | |||
90 | 90 | ||
91 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr)) | 91 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr)) |
92 | return -1; | 92 | return -1; |
93 | 93 | ||
94 | if (c) | 94 | if (c) |
95 | ifr.ifr_flags |= IFF_UP; | 95 | ifr.ifr_flags |= IFF_UP; |
96 | else | 96 | else |
97 | ifr.ifr_flags &= ~IFF_UP; | 97 | ifr.ifr_flags &= ~IFF_UP; |
98 | 98 | ||
99 | if (ioctl(sockfd, SIOCSIFFLAGS, &ifr)) | 99 | if (ioctl(sockfd, SIOCSIFFLAGS, &ifr)) |
100 | return -1; | 100 | return -1; |
101 | 101 | ||
102 | return 0; | 102 | return 0; |
103 | } | 103 | } |
104 | 104 | ||
105 | int IrdaApplet::checkIrdaDiscoveryStatus() { | 105 | int IrdaApplet::checkIrdaDiscoveryStatus() { |
106 | |||
106 | QFile discovery("/proc/sys/net/irda/discovery"); | 107 | QFile discovery("/proc/sys/net/irda/discovery"); |
107 | char status; | ||
108 | 108 | ||
109 | discovery.open( IO_ReadOnly|IO_Raw ); | 109 | QString streamIn = "0"; |
110 | discovery.readBlock (&status, 1); | 110 | |
111 | if (discovery.open(IO_ReadOnly) ) { | ||
112 | QTextStream stream ( &discovery ); | ||
113 | streamIn = stream.read(); | ||
114 | } | ||
115 | |||
111 | discovery.close(); | 116 | discovery.close(); |
112 | 117 | ||
113 | return atoi(&status); | 118 | return( streamIn.toInt() ); |
114 | } | 119 | } |
115 | 120 | ||
121 | |||
116 | int IrdaApplet::setIrdaDiscoveryStatus(int d) { | 122 | int IrdaApplet::setIrdaDiscoveryStatus(int d) { |
117 | QFile discovery("/proc/sys/net/irda/discovery"); | 123 | QFile discovery("/proc/sys/net/irda/discovery"); |
118 | 124 | ||
119 | discovery.open( IO_WriteOnly|IO_Raw ); | 125 | discovery.open( IO_WriteOnly|IO_Raw ); |
120 | 126 | ||
121 | if (d) | 127 | if (d) |
122 | discovery.putch('1'); | 128 | discovery.putch('1'); |
123 | else | 129 | else |
124 | discovery.putch('0'); | 130 | discovery.putch('0'); |
125 | 131 | ||
126 | discovery.close(); | 132 | discovery.close(); |
127 | 133 | ||
128 | return 0; | 134 | return 0; |
129 | } | 135 | } |
130 | 136 | ||
131 | 137 | ||