-rw-r--r-- | core/applets/irdaapplet/irda.cpp | 44 | ||||
-rw-r--r-- | core/applets/irdaapplet/irda.h | 2 |
2 files changed, 42 insertions, 4 deletions
diff --git a/core/applets/irdaapplet/irda.cpp b/core/applets/irdaapplet/irda.cpp index 28a79d1..e21f191 100644 --- a/core/applets/irdaapplet/irda.cpp +++ b/core/applets/irdaapplet/irda.cpp | |||
@@ -37,16 +37,17 @@ | |||
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qslider.h> | 38 | #include <qslider.h> |
39 | #include <qlayout.h> | 39 | #include <qlayout.h> |
40 | #include <qframe.h> | 40 | #include <qframe.h> |
41 | #include <qpixmap.h> | 41 | #include <qpixmap.h> |
42 | #include <qstring.h> | 42 | #include <qstring.h> |
43 | #include <qfile.h> | 43 | #include <qfile.h> |
44 | #include <qtimer.h> | 44 | #include <qtimer.h> |
45 | #include <qtextstream.h> | ||
45 | #include <qpopupmenu.h> | 46 | #include <qpopupmenu.h> |
46 | 47 | ||
47 | #include <net/if.h> | 48 | #include <net/if.h> |
48 | #include <netinet/in.h> | 49 | #include <netinet/in.h> |
49 | #include <sys/types.h> | 50 | #include <sys/types.h> |
50 | #include <sys/socket.h> | 51 | #include <sys/socket.h> |
51 | #include <sys/ioctl.h> | 52 | #include <sys/ioctl.h> |
52 | 53 | ||
@@ -123,34 +124,69 @@ int IrdaApplet::setIrdaDiscoveryStatus(int d) { | |||
123 | discovery.putch('0'); | 124 | discovery.putch('0'); |
124 | 125 | ||
125 | discovery.close(); | 126 | discovery.close(); |
126 | 127 | ||
127 | return 0; | 128 | return 0; |
128 | } | 129 | } |
129 | 130 | ||
130 | 131 | ||
132 | void IrdaApplet::showDiscovered() { | ||
133 | QFile discovery("/proc/net/irda/discovery"); | ||
134 | |||
135 | if (discovery.open(IO_ReadOnly) ) { | ||
136 | QStringList list; | ||
137 | // since it is /proc we _must_ use QTextStream | ||
138 | QTextStream stream ( &discovery); | ||
139 | QString streamIn; | ||
140 | streamIn = stream.read(); | ||
141 | list = QStringList::split("\n", streamIn); | ||
142 | |||
143 | for(QStringList::Iterator line=list.begin(); line!=list.end(); line++) { | ||
144 | if( (*line).startsWith("nickname:") ){ | ||
145 | discoveredDevice = (*line).mid(((*line).find(':'))+1,(*line).find(',')-(*line).find(':')-1); | ||
146 | qDebug(discoveredDevice); | ||
147 | } | ||
148 | } | ||
149 | } | ||
150 | |||
151 | } | ||
152 | |||
131 | void IrdaApplet::mousePressEvent( QMouseEvent *) { | 153 | void IrdaApplet::mousePressEvent( QMouseEvent *) { |
132 | QPopupMenu *menu = new QPopupMenu(); | 154 | QPopupMenu *menu = new QPopupMenu(); |
133 | QString cmd; | 155 | QString cmd; |
134 | int ret=0; | 156 | int ret=0; |
157 | showDiscovered(); | ||
135 | 158 | ||
136 | /* Refresh active state */ | 159 | /* Refresh active state */ |
137 | timerEvent(NULL); | 160 | timerEvent(NULL); |
138 | 161 | ||
139 | //menu->insertItem( tr("More..."), 4 ); | 162 | //menu->insertItem( tr("More..."), 4 ); |
140 | if (irdaactive) | 163 | |
164 | menu->insertItem( tr("Discovered Device:"), 9); | ||
165 | |||
166 | if ( !discoveredDevice.isEmpty() ) { | ||
167 | menu->insertItem( discoveredDevice ,7 ); | ||
168 | } else { | ||
169 | menu->insertItem( tr("None"), 8); | ||
170 | } | ||
171 | |||
172 | menu->insertSeparator(); | ||
173 | |||
174 | if (irdaactive) { | ||
141 | menu->insertItem( tr("Disable IrDA"), 0 ); | 175 | menu->insertItem( tr("Disable IrDA"), 0 ); |
142 | else | 176 | } else { |
143 | menu->insertItem( tr("Enable IrDA"), 1 ); | 177 | menu->insertItem( tr("Enable IrDA"), 1 ); |
178 | } | ||
144 | 179 | ||
145 | if (irdaDiscoveryActive) | 180 | if (irdaDiscoveryActive) { |
146 | menu->insertItem( tr("Disable Discovery"), 2 ); | 181 | menu->insertItem( tr("Disable Discovery"), 2 ); |
147 | else | 182 | } else { |
148 | menu->insertItem( tr("Enable Discovery"), 3 ); | 183 | menu->insertItem( tr("Enable Discovery"), 3 ); |
184 | } | ||
149 | 185 | ||
150 | if( receiveActive ){ | 186 | if( receiveActive ){ |
151 | menu->insertItem( tr("Disable Receive"), 5 ); | 187 | menu->insertItem( tr("Disable Receive"), 5 ); |
152 | } else { | 188 | } else { |
153 | menu->insertItem( tr("Enable Receive"), 4 ); | 189 | menu->insertItem( tr("Enable Receive"), 4 ); |
154 | } | 190 | } |
155 | 191 | ||
156 | QPoint p = mapToGlobal( QPoint(1, menu->sizeHint().height()-1) ); | 192 | QPoint p = mapToGlobal( QPoint(1, menu->sizeHint().height()-1) ); |
diff --git a/core/applets/irdaapplet/irda.h b/core/applets/irdaapplet/irda.h index 002d295..5822afe 100644 --- a/core/applets/irdaapplet/irda.h +++ b/core/applets/irdaapplet/irda.h | |||
@@ -37,23 +37,25 @@ protected: | |||
37 | 37 | ||
38 | private: | 38 | private: |
39 | void mousePressEvent( QMouseEvent * ); | 39 | void mousePressEvent( QMouseEvent * ); |
40 | void paintEvent( QPaintEvent* ); | 40 | void paintEvent( QPaintEvent* ); |
41 | int checkIrdaStatus(); | 41 | int checkIrdaStatus(); |
42 | int setIrdaStatus(int); | 42 | int setIrdaStatus(int); |
43 | int checkIrdaDiscoveryStatus(); | 43 | int checkIrdaDiscoveryStatus(); |
44 | int setIrdaDiscoveryStatus(int); | 44 | int setIrdaDiscoveryStatus(int); |
45 | void showDiscovered(); | ||
45 | int sockfd; | 46 | int sockfd; |
46 | 47 | ||
47 | private: | 48 | private: |
48 | QPixmap irdaOnPixmap; | 49 | QPixmap irdaOnPixmap; |
49 | QPixmap irdaOffPixmap; | 50 | QPixmap irdaOffPixmap; |
50 | QPixmap irdaDiscoveryOnPixmap; | 51 | QPixmap irdaDiscoveryOnPixmap; |
51 | QPixmap receiveActivePixmap; | 52 | QPixmap receiveActivePixmap; |
53 | QString discoveredDevice; | ||
52 | int irdaactive; // bool and bitfields later bool irdaactive :1 ; | 54 | int irdaactive; // bool and bitfields later bool irdaactive :1 ; |
53 | int irdaDiscoveryActive; | 55 | int irdaDiscoveryActive; |
54 | bool receiveActive : 1; | 56 | bool receiveActive : 1; |
55 | bool receiveStateChanged; | 57 | bool receiveStateChanged; |
56 | private slots: | 58 | private slots: |
57 | 59 | ||
58 | 60 | ||
59 | }; | 61 | }; |