summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/wellenreiter.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/noncore/net/wellenreiter/gui/wellenreiter.cpp b/noncore/net/wellenreiter/gui/wellenreiter.cpp
index 02a6f76..693f20d 100644
--- a/noncore/net/wellenreiter/gui/wellenreiter.cpp
+++ b/noncore/net/wellenreiter/gui/wellenreiter.cpp
@@ -1,172 +1,176 @@
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 "../libwellenreiter/source/proto.hh" // <--- ugly path, FIX THIS!
32#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS! 32#include "../daemon/source/config.hh" // <--- ugly path, FIX THIS!
33 33
34Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl ) 34Wellenreiter::Wellenreiter( QWidget* parent, const char* name, WFlags fl )
35 : WellenreiterBase( parent, name, fl ) 35 : WellenreiterBase( parent, name, fl )
36{ 36{
37 37
38 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) ); 38 connect( button, SIGNAL( clicked() ), this, SLOT( buttonClicked() ) );
39 netview->setColumnWidthMode( 1, QListView::Manual ); 39 netview->setColumnWidthMode( 1, QListView::Manual );
40 40
41 // 41 //
42 // setup socket for daemon communication and start poller 42 // setup socket for daemon communication and start poller
43 // 43 //
44 44
45 daemon_fd = commsock( DAEMONADDR, DAEMONPORT ); 45 daemon_fd = commsock( GUIADDR, GUIPORT );
46 if ( daemon_fd == -1 ) 46 if ( daemon_fd == -1 )
47 qDebug( "D'oh! Could not get file descriptor for daemon socket." ); 47 qDebug( "D'oh! Could not get file descriptor for daemon-->gui communication socket." );
48 else 48 //else
49 startTimer( 700 ); 49 //startTimer( 700 );
50 50
51} 51}
52 52
53Wellenreiter::~Wellenreiter() 53Wellenreiter::~Wellenreiter()
54{ 54{
55 // 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
56} 56}
57 57
58void Wellenreiter::handleMessage() 58void Wellenreiter::handleMessage()
59{ 59{
60 // FIXME: receive message and handle it 60 // FIXME: receive message and handle it
61 61
62 qDebug( "received message from daemon." ); 62 qDebug( "received message from daemon." );
63 63
64 char buffer[128]; 64 char buffer[128];
65 65
66 int result = recvcomm( &daemon_fd, (char*) &buffer, sizeof(buffer) ); 66 int result = recvcomm( &daemon_fd, (char*) &buffer, sizeof(buffer) );
67 qDebug( "received %d from recvcomm", result ); 67 qDebug( "received %d from recvcomm", result );
68 68
69/* 69/*
70typedef struct { 70typedef struct {
71 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc 71 int net_type; 1 = Accesspoint ; 2 = Ad-Hoc
72 int ssid_len; Length of SSID 72 int ssid_len; Length of SSID
73 int channel; Channel 73 int channel; Channel
74 int wep; 1 = WEP enabled ; 0 = disabled 74 int wep; 1 = WEP enabled ; 0 = disabled
75 char mac[64]; MAC address of Accesspoint 75 char mac[64]; MAC address of Accesspoint
76 char bssid[128]; BSSID of Accesspoint 76 char bssid[128]; BSSID of Accesspoint
77} wl_network_t; 77} wl_network_t;
78*/ 78*/
79 79
80 if ( result == 1 ) /* new network found */ 80 if ( result == NETFOUND ) /* new network found */
81 { 81 {
82 qDebug( "Sniffer said: new network found." ); 82 qDebug( "Sniffer said: new network found." );
83 wl_network_t n; 83 wl_network_t n;
84 get_network_found( &n, (const char*) &buffer ); 84 get_network_found( &n, (char*) &buffer );
85 n.bssid[n.ssid_len] = "\0"; 85 n.bssid[n.ssid_len] = "\0";
86 86
87 QString type; 87 QString type;
88 88
89 if ( n.net_type == 1 ) 89 if ( n.net_type == 1 )
90 type == "managed"; 90 type == "managed";
91 else 91 else
92 type == "adhoc"; 92 type == "adhoc";
93 93
94 addNewItem( type, n.bssid, n.mac, n.wep, n.channel, 0 ); 94 addNewItem( type, n.bssid, n.mac, n.wep, n.channel, 0 );
95 95
96 } 96 }
97 97
98 else 98 else
99 99
100 { 100 {
101 qDebug( "unknown sniffer command." ); 101 qDebug( "unknown sniffer command." );
102 } 102 }
103 103
104} 104}
105 105
106 106
107bool Wellenreiter::hasMessage() 107bool Wellenreiter::hasMessage()
108{ 108{
109 109
110 // FIXME: do this in libwellenreiter, not here!!! 110 // FIXME: do this in libwellenreiter, not here!!!
111 111
112 fd_set rfds; 112 fd_set rfds;
113 FD_ZERO( &rfds ); 113 FD_ZERO( &rfds );
114 FD_SET( daemon_fd, &rfds ); 114 FD_SET( daemon_fd, &rfds );
115 struct timeval tv; 115 struct timeval tv;
116 tv.tv_sec = 0; 116 tv.tv_sec = 0;
117 tv.tv_usec = 0; 117 tv.tv_usec = 0;
118 int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv ); 118 int result = select( daemon_fd+1, &rfds, NULL, NULL, &tv );
119 return FD_ISSET( daemon_fd, &rfds ); 119 return FD_ISSET( daemon_fd, &rfds );
120} 120}
121 121
122void Wellenreiter::timerEvent( QTimerEvent* e ) 122void Wellenreiter::timerEvent( QTimerEvent* e )
123{ 123{
124 qDebug( "checking for message..." ); 124 //qDebug( "checking for message..." );
125 125
126 if ( hasMessage() ) 126 if ( hasMessage() )
127 { 127 {
128 handleMessage(); 128 handleMessage();
129 } 129 }
130 else 130 else
131 { 131 {
132 qDebug( "no message :(" ); 132 //qDebug( "no message :(" );
133 } 133 }
134} 134}
135 135
136void Wellenreiter::addNewItem( 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 )
137{ 137{
138 // FIXME: this code belongs in customized QListView, not into this class 138 // FIXME: this code belongs in customized QListView, not into this class
139 139
140 // search, if we had an item with this essid once before 140 // search, if we had an item with this essid once before
141 141
142 QListViewItem* item = netview->firstChild(); 142 QListViewItem* item = netview->firstChild();
143 143
144 while ( item && ( item->text( 0 ) != essid ) ) 144 while ( item && ( item->text( 0 ) != essid ) )
145 { 145 {
146 qDebug( "itemtext: %s", (const char*) item->text( 0 ) ); 146 qDebug( "itemtext: %s", (const char*) item->text( 0 ) );
147 item = item->itemBelow(); 147 item = item->itemBelow();
148 } 148 }
149 if ( item ) 149 if ( item )
150 { 150 {
151 qDebug( "found!" ); 151 qDebug( "found!" );
152 new MScanListItem( item, type, essid, ap, wep, channel, signal ); 152 new MScanListItem( item, type, essid, ap, wep, channel, signal );
153 } 153 }
154 else 154 else
155 { 155 {
156 new MScanListItem( netview, type, essid, ap, wep, channel, signal ); 156 new MScanListItem( netview, type, essid, ap, wep, channel, signal );
157 } 157 }
158} 158}
159 159
160void Wellenreiter::buttonClicked() 160void Wellenreiter::buttonClicked()
161{ 161{
162 162
163 // FIXME: communicate with daemon and set button text according to state 163 // FIXME: communicate with daemon and set button text according to state
164 164
165 button->setText( "Stop Scanning" ); 165 button->setText( "Stop Scanning" );
166 166
167 // add some icons, so that we can see if this works 167 // add some icons, so that we can see if this works
168 168
169 addNewItem( "managed", "MyNet", "04:00:20:EF:A6:43", true, 6, 80 ); 169 addNewItem( "managed", "DummyNet", "04:00:20:EF:A6:43", true, 6, 80 );
170 addNewItem( "adhoc", "YourNet", "40:03:A3:E7:56:22", false, 11, 30 ); 170 addNewItem( "adhoc", "DummyNet", "40:03:A3:E7:56:22", false, 11, 30 );
171
172 QString command ("98");
173
174 sendcomm( DAEMONADDR, DAEMONPORT, (const char*) command );
171 175
172} 176}