summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2002-11-30 18:33:06 (UTC)
committer mickeyl <mickeyl>2002-11-30 18:33:06 (UTC)
commit2e2bbf823ba532f349ad9ca3dd84cf7f758f36b0 (patch) (unidiff)
treeb554ae6b7f2bd4e7db9b34bf25e85b8f129fa2dd
parent197b74a6193151cca8b7f5f725fb19098cb76eb2 (diff)
downloadopie-2e2bbf823ba532f349ad9ca3dd84cf7f758f36b0.zip
opie-2e2bbf823ba532f349ad9ca3dd84cf7f758f36b0.tar.gz
opie-2e2bbf823ba532f349ad9ca3dd84cf7f758f36b0.tar.bz2
gui should now show newly found stations.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp58
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.h2
2 files changed, 53 insertions, 7 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index afb010c..02a6f76 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,126 +1,172 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14***********************************************************************/ 14***********************************************************************/
15 15
16// Qt 16// Qt
17 17
18#include <qpushbutton.h> 18#include <qpushbutton.h>
19 19
20// Standard 20// Standard
21 21
22#include <unistd.h> 22#include <unistd.h>
23#include <sys/types.h> 23#include <sys/types.h>
24 24
25// Local 25// Local
26 26
27#include "wellenreiter.h" 27#include "wellenreiter.h"
28#include "scanlistitem.h" 28#include "scanlistitem.h"
29 29
30#include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS! 30#include "../libwellenreiter/source/sock.hh" // <--- ugly path, FIX THIS!
31#include "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS!
31#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS! 32#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS!
32 33
33Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) 34Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
34 : WellenreiterBase( parent, name, fl ) 35 : WellenreiterBase( parent, name, fl )
35{ 36{
36 37
37 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); 38 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) );
38 netview->setColumnWidthMode( 1, QListView::Manual ); 39 netview->setColumnWidthMode( 1, QListView::Manual );
39 40
40 // 41 //
41 // setup socket for daemon communication and start poller 42 // setup socket for daemon communication and start poller
42 // 43 //
43 44
44 daemon_fd = commsock( DAEMONADDR, DAEMONPORT ); 45 daemon_fd = commsock( DAEMONADDR, DAEMONPORT );
45 if ( daemon_fd == -1 ) 46 if ( daemon_fd == -1 )
46 qDebug( "D'oh! Could not get file descriptor for daemon socket." ); 47 qDebug( "D'oh! Could not get file descriptor for daemon socket." );
47 else 48 else
48 startTimer( 700 ); 49 startTimer( 700 );
49 50
50} 51}
51 52
52Wellenreiter::~Wellenreiter() 53Wellenreiter::~Wellenreiter()
53{ 54{
54 // no need to delete child widgets, Qt does it all for us 55 // no need to delete child widgets, Qt does it all for us
55} 56}
56 57
57void Wellenreiter::handleMessage() 58void Wellenreiter::handleMessage()
58{ 59{
59 // FIXME: receive message and handle it 60 // FIXME: receive message and handle it
60 61
61 qDebug( "received message from daemon." ); 62 qDebug( "received message from daemon." );
63
64 char buffer[128];
65
66 int result = recvcomm( &daemon_fd, (char*) &buffer, sizeof(buffer) );
67 qDebug( "received %d from recvcomm", result );
68
69/*
70typedef struct {
71 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc
72 int ssid_len; Length of SSID
73 int channel; Channel
74 int wep; 1 = WEP enabled ; 0 = disabled
75 char mac[64]; MAC address of Accesspoint
76 char bssid[128]; BSSID of Accesspoint
77} wl_network_t;
78*/
79
80 if ( result == 1 ) /* new network found */
81 {
82 qDebug( "Sniffer said: new network found." );
83 wl_network_t n;
84 get_network_found( &n, (const char*) &buffer );
85 n.bssid[n.ssid_len] = "\0";
86
87 QString type;
88
89 if ( n.net_type == 1 )
90 type == "managed";
91 else
92 type == "adhoc";
93
94 addNewItem( type, n.bssid, n.mac, n.wep, n.channel, 0 );
95
96 }
97
98 else
99
100 {
101 qDebug( "unknown sniffer command." );
102 }
103
62} 104}
63 105
64 106
65bool Wellenreiter::hasMessage() 107bool Wellenreiter::hasMessage()
66{ 108{
109
110 // FIXME: do this in libwellenreiter, not here!!!
111
67 fd_set rfds; 112 fd_set rfds;
68 FD_ZERO( &rfds ); 113 FD_ZERO( &rfds );
69 FD_SET( daemon_fd, &rfds ); 114 FD_SET( daemon_fd, &rfds );
70 struct timeval tv; 115 struct timeval tv;
71 tv.tv_sec = 0; 116 tv.tv_sec = 0;
72 tv.tv_usec = 0; 117 tv.tv_usec = 0;
73 return select( 1, &rfds, NULL, NULL, &tv ); 118 int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv );
119 return FD_ISSET( daemon_fd, &rfds );
74} 120}
75 121
76void Wellenreiter::timerEvent( QTimerEvent* e ) 122void Wellenreiter::timerEvent( QTimerEvent* e )
77{ 123{
78 // qDebug( "checking for message..." ); 124 qDebug( "checking for message..." );
79 125
80 if ( hasMessage() ) 126 if ( hasMessage() )
81 { 127 {
82 handleMessage(); 128 handleMessage();
83 } 129 }
84 else 130 else
85 { 131 {
86 // qDebug( "no message :(" ); 132 qDebug( "no message :(" );
87 } 133 }
88} 134}
89 135
90void Wellenreiter::addNewStation( QString type, QString essid, QString ap, bool wep, int channel, int signal ) 136void Wellenreiter::addNewItem( QString type, QString essid, QString ap, bool wep, int channel, int signal )
91{ 137{
92 // FIXME: this code belongs in customized QListView, not into this class 138 // FIXME: this code belongs in customized QListView, not into this class
93 139
94 // search, if we had an item with this essid once before 140 // search, if we had an item with this essid once before
95 141
96 QListViewItem* item = netview->firstChild(); 142 QListViewItem* item = netview->firstChild();
97 143
98 while ( item && ( item->text( 0 ) != essid ) ) 144 while ( item && ( item->text( 0 ) != essid ) )
99 { 145 {
100 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 146 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
101 item = item->itemBelow(); 147 item = item->itemBelow();
102 } 148 }
103 if ( item ) 149 if ( item )
104 { 150 {
105 qDebug( "found!" ); 151 qDebug( "found!" );
106 new MScanListItem( item, type, essid, ap, wep, channel, signal ); 152 new MScanListItem( item, type, essid, ap, wep, channel, signal );
107 } 153 }
108 else 154 else
109 { 155 {
110 new MScanListItem( netview, type, essid, ap, wep, channel, signal ); 156 new MScanListItem( netview, type, essid, ap, wep, channel, signal );
111 } 157 }
112} 158}
113 159
114void Wellenreiter::buttonClicked() 160void Wellenreiter::buttonClicked()
115{ 161{
116 162
117 // FIXME: communicate with daemon and set button text according to state 163 // FIXME: communicate with daemon and set button text according to state
118 164
119 button->setText( "Stop Scanning" ); 165 button->setText( "Stop Scanning" );
120 166
121 // add some icons, so that we can see if this works 167 // add some icons, so that we can see if this works
122 168
123 addNewStation( "managed", "MyNet", "04:00:20:EF:A6:43", true, 6, 80 ); 169 addNewItem( "managed", "MyNet", "04:00:20:EF:A6:43", true, 6, 80 );
124 addNewStation( "adhoc", "YourNet", "40:03:A3:E7:56:22", false, 11, 30 ); 170 addNewItem( "adhoc", "YourNet", "40:03:A3:E7:56:22", false, 11, 30 );
125 171
126} 172}
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.h b/noncore/net/wellenreiter/gui/wellenreiter.h
index b0f41e3..61f7503 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.h
+++ b/noncore/net/wellenreiter/gui/wellenreiter.h
@@ -1,48 +1,48 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14**********************************************************************/ 14**********************************************************************/
15 15
16#ifndef WELLENREITER_H 16#ifndef WELLENREITER_H
17#define WELLENREITER_H 17#define WELLENREITER_H
18 18
19#include "wellenreiterbase.h" 19#include "wellenreiterbase.h"
20 20
21class QTimerEvent; 21class QTimerEvent;
22 22
23class Wellenreiter : public WellenreiterBase { 23class Wellenreiter : public WellenreiterBase {
24 Q_OBJECT 24 Q_OBJECT
25 25
26public: 26public:
27 27
28 Wellenreiter( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 28 Wellenreiter( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
29 ~Wellenreiter(); 29 ~Wellenreiter();
30 30
31protected: 31protected:
32 virtual void timerEvent( QTimerEvent* ); 32 virtual void timerEvent( QTimerEvent* );
33 33
34public slots: 34public slots:
35 void buttonClicked(); 35 void buttonClicked();
36 void addNewStation( QString type, QString essid, QString ap, bool wep, int channel, int signal ); 36 void addNewItem( QString type, QString essid, QString ap, bool wep, int channel, int signal );
37 37
38private: 38private:
39 int daemon_fd; // socket filedescriptor for udp communication socket 39 int daemon_fd; // socket filedescriptor for udp communication socket
40 40
41 bool hasMessage(); 41 bool hasMessage();
42 void handleMessage(); 42 void handleMessage();
43 43
44 //void readConfig(); 44 //void readConfig();
45 //void writeConfig(); 45 //void writeConfig();
46}; 46};
47 47
48#endif 48#endif