summaryrefslogtreecommitdiffstats
path: root/wifi/interface_wireless_wirelessextensions.cpp
blob: 928c2b6fc465db1030f7c0704d484835d722d752 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
/***************************************************************************
                          interface_wireless_wirelessextensions.cpp  -  description
                             -------------------
    begin                : Sun May 6 2001
    copyright            : (C) 2001 by Stefan Winter
    email                : mail@stefan-winter.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "interface_wireless_wirelessextensions.h"
#include <iwlib.h>
#include <tqdir.h>
#include <tqfile.h>
#include <tqtable.h>

#include <tdemessagebox.h>

#ifndef WITHOUT_ARTS
#include <arts/artsflow.h>
#include <arts/connect.h>
#include <arts/iomanager.h>
#include <arts/referenceclean.h>
#endif

#ifndef PROC_NET_DEV
#define PROC_NET_DEV "/proc/net/dev"
#endif

#include <iostream>
#include <string>
#include <tdelocale.h>
#include <kstandarddirs.h>
#include <kprocio.h>
#include <kdebug.h>
#include <tqstring.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>


// domi:the wireless-tools people managed to change their interfaces
// around.  Someone with more knowledge of this code should look into
// moving to use the new iw_range interfaces.
#ifdef HAVE_IW_27

#ifndef HAVE_IW_27pre19
#define WIFI_CONFIG(config,field) config.field
#define WIFI_EXTRACT_EVENT_STREAM(stream, event) \
	iw_extract_event_stream(stream, event)
#else
#define WIFI_CONFIG(config,field) config.b.field
#define WIFI_EXTRACT_EVENT_STREAM(stream, event) \
	iw_extract_event_stream(stream, event, WIRELESS_EXT)
#endif

#define WIFI_GET_STATS(skfd, ifname, stats) \
	iw_get_stats (skfd, ifname, stats, 0, 0)
#define WIFI_PRINT_STATS(buff, event) \
        iw_print_stats(buffer, sizeof(buffer), &event->u.qual, 0, 0);

#else // HAVE_IW_25
#define WIFI_CONFIG(config,field) config.field
#define WIFI_EXTRACT_EVENT_STREAM(stream, event) \
	iw_extract_event_stream(stream, event)
#define WIFI_GET_STATS(skfd, ifname, stats) \
	iw_get_stats (skfd, ifname, stats)
#define WIFI_PRINT_STATS(buff, event) \
        iw_print_stats(buffer, &event->u.qual, 0, 0);
#endif

/* ================================== FROM IWCONFIG.C ================================== */
int
Interface_wireless_wirelessextensions::get_info (int skfd, const TQString& interface,
						 struct wireless_info& info)
{
  struct iwreq wrq;
  char ifname[20];
  snprintf(ifname, sizeof(ifname), "%s", interface.latin1() );
  memset (&info, 0, sizeof(info));

  /* Get wireless name */
  if (iw_get_ext (skfd, ifname, SIOCGIWNAME, &wrq) < 0)
    {
      /* If no wireless name : no wireless extensions */
      /* But let's check if the interface exists at all */
      struct ifreq ifr;

      strcpy (ifr.ifr_name, ifname);
      if (ioctl (skfd, SIOCGIFFLAGS, &ifr) < 0)
	return (-ENODEV);
      else
	return (-ENOTSUP);
    }
  else
    {
      strncpy (WIFI_CONFIG(info,name), wrq.u.name, IFNAMSIZ);
      WIFI_CONFIG(info,name)[IFNAMSIZ] = '\0';
    }

  /* Get ranges */
  if (iw_get_range_info (skfd, ifname, &(info.range)) >= 0)
    info.has_range = 1;

  /* Get network ID */
  if (iw_get_ext (skfd, ifname, SIOCGIWNWID, &wrq) >= 0)
    {
      WIFI_CONFIG(info,has_nwid) = 1;
      memcpy (&(WIFI_CONFIG(info,nwid)), &(wrq.u.nwid), sizeof (iwparam));
    }

  /* Get frequency / channel */
  if (iw_get_ext (skfd, ifname, SIOCGIWFREQ, &wrq) >= 0)
    {
      WIFI_CONFIG(info,has_freq) = 1;
      WIFI_CONFIG(info,freq) = iw_freq2float (&(wrq.u.freq));
    }

  /* Get sensitivity */
  if (iw_get_ext (skfd, ifname, SIOCGIWSENS, &wrq) >= 0)
    {
      info.has_sens = 1;
      memcpy (&(info.sens), &(wrq.u.sens), sizeof (iwparam));
    }

  /* Get encryption information */
  wrq.u.data.pointer = (caddr_t) WIFI_CONFIG(info,key);
  wrq.u.data.length = IW_ENCODING_TOKEN_MAX;
  wrq.u.data.flags = 0;
  if (iw_get_ext (skfd, ifname, SIOCGIWENCODE, &wrq) >= 0)
    {
      WIFI_CONFIG(info,has_key) = 1;
      WIFI_CONFIG(info,key_size) = wrq.u.data.length;
      WIFI_CONFIG(info,key_flags) = wrq.u.data.flags;
    }

  /* Get ESSID */
  /* prepare NULL-terminated buffer in case the string returned by SIOCGIWESSID is NOT NULL-terminated */
  memset(wrq.u.essid.pointer, '\0', IW_ESSID_MAX_SIZE + 1);
  wrq.u.essid.pointer = (caddr_t) WIFI_CONFIG(info,essid);
  wrq.u.essid.length = IW_ESSID_MAX_SIZE + 1;
  wrq.u.essid.flags = 0;
  if (iw_get_ext (skfd, ifname, SIOCGIWESSID, &wrq) >= 0)
    {
      WIFI_CONFIG(info,has_essid) = 1;
      WIFI_CONFIG(info,essid_on) = wrq.u.data.flags;
    }

  /* Get AP address */
  if (iw_get_ext (skfd, ifname, SIOCGIWAP, &wrq) >= 0)
    {
      info.has_ap_addr = 1;
      memcpy (&(info.ap_addr), &(wrq.u.ap_addr), sizeof (sockaddr));
    }

  /* Get NickName */
  wrq.u.essid.pointer = (caddr_t) info.nickname;
  wrq.u.essid.length = IW_ESSID_MAX_SIZE + 1;
  wrq.u.essid.flags = 0;
  if (iw_get_ext (skfd, ifname, SIOCGIWNICKN, &wrq) >= 0)
    if (wrq.u.data.length > 1)
      info.has_nickname = 1;

  /* Get bit rate */
  if (iw_get_ext (skfd, ifname, SIOCGIWRATE, &wrq) >= 0)
    {
      info.has_bitrate = 1;
      memcpy (&(info.bitrate), &(wrq.u.bitrate), sizeof (iwparam));
    }

  /* Get RTS threshold */
  if (iw_get_ext (skfd, ifname, SIOCGIWRTS, &wrq) >= 0)
    {
      info.has_rts = 1;
      memcpy (&(info.rts), &(wrq.u.rts), sizeof (iwparam));
    }

  /* Get fragmentation threshold */
  if (iw_get_ext (skfd, ifname, SIOCGIWFRAG, &wrq) >= 0)
    {
      info.has_frag = 1;
      memcpy (&(info.frag), &(wrq.u.frag), sizeof (iwparam));
    }

  /* Get operation mode */
  if (iw_get_ext (skfd, ifname, SIOCGIWMODE, &wrq) >= 0)
    {
      WIFI_CONFIG(info,mode) = wrq.u.mode;
      if ((WIFI_CONFIG(info,mode) < IW_NUM_OPER_MODE) && (WIFI_CONFIG(info,mode) >= 0))
	WIFI_CONFIG(info,has_mode) = 1;
    }

  /* Get Power Management settings */
  wrq.u.power.flags = 0;
  if (iw_get_ext (skfd, ifname, SIOCGIWPOWER, &wrq) >= 0)
    {
      info.has_power = 1;
      memcpy (&(info.power), &(wrq.u.power), sizeof (iwparam));
    }

#if WIRELESS_EXT > 9
  /* Get Transmit Power and check if it is disabled */
  bool emitTXPowerChanged = false;
  if (iw_get_ext (skfd, ifname, SIOCGIWTXPOW, &wrq) >= 0)
    {
      if (txpower_disabled != info.txpower.disabled)
        {
	  emitTXPowerChanged = true;
        }

      info.has_txpower = 1;
      memcpy (&(info.txpower), &(wrq.u.txpower), sizeof (iwparam));
    }
  has_txpower = info.has_txpower;
  txpower_disabled = ( int )info.txpower.disabled;
  if (emitTXPowerChanged)
    {
      emit txPowerChanged();
    }
#endif

#if WIRELESS_EXT > 10
  /* Get retry limit/lifetime */
  if (iw_get_ext (skfd, ifname, SIOCGIWRETRY, &wrq) >= 0)
    {
      info.has_retry = 1;
      memcpy (&(info.retry), &(wrq.u.retry), sizeof (iwparam));
    }
#endif /* WIRELESS_EXT > 10 */

  /* Get stats */
  if (WIFI_GET_STATS (skfd, (char *) ifname, &(info.stats)) >= 0)
    {
      info.has_stats = 1;
    }

  return (0);
}

/* ================================ END IWCONFIG.C ================================ */


Interface_wireless_wirelessextensions::Interface_wireless_wirelessextensions (TQStringList * ignoreInterfaces)
		: Interface_wireless(ignoreInterfaces)
{
}

bool Interface_wireless_wirelessextensions::isSocketOpen()
{
  if (socket <= 0)
    socket = iw_sockets_open ();

  return (socket > 0);
}

void Interface_wireless_wirelessextensions::setActiveDevice( TQString device )
{
  kdDebug () << "activating wireless device " << device << endl;
  interface_name = device;

  if (!isSocketOpen())
	return;

  emit interfaceChanged ();
  emit strengthChanged ();
  emit statusChanged ();
  emit modeChanged ();
  emit speedChanged ();
  valid[current] = false;
  emit statsUpdated ();
}

void Interface_wireless_wirelessextensions::setNoActiveDevice( )
{
  // interface has disappeared - unplugged?
  // reset all info except stats
  has_frequency = false;
  frequency = 0.0;
  has_mode = false;
  mode = 0;
  has_key = 0;
  key = TQString();
  key_size = 0;
  key_flags = 0;
  essid = TQString();
  access_point_address = TQString();
  ip_address = TQString();
  bitrate = 0;
  has_range = false;
  has_txpower = false;
  txpower_disabled = 0;

  // propagate the changes
  setActiveDevice( TQString() );
}

TQStringList Interface_wireless_wirelessextensions::available_wifi_devices()
{
  TQFile procnetdev(PROC_NET_DEV);
  procnetdev.open (IO_ReadOnly);

  kdDebug () << "Autodetecting..." << endl;

  TQStringList liste;
  TQString device;
  while (!procnetdev.atEnd()) {
	  procnetdev.readLine (device, 9999);
	  int pos = device.find (':');
	  if (pos == -1)
		continue;
	  device = device.left(pos).stripWhiteSpace();
	  if (device.isEmpty())
		continue;
	// Some drivers create two interfaces, ethX and wifiX.  The
	// wifiX device are not useful to users because they only
	// control the physical wlan settings, not the logical ones.  If
	// we find a wifiX device then we move it to the start of the
	// list which means the first instance of KWifiManger will pick
	// up the ethX and only the second instance will pick up the
	// wifiX.
	  if (device.startsWith("wifi"))
		liste.prepend(device);
	  else
		liste.append(device);	
  }


  if (liste.isEmpty())
	kdDebug () << "No wireless interface found." << endl;

  return liste;
}

bool Interface_wireless_wirelessextensions::autodetect_device()
{
  if (!isSocketOpen())
	return false;

  TQStringList liste = available_wifi_devices();

  for (TQStringList::Iterator it = liste.begin (); it != liste.end (); ++it)
  {
	TQString device = *it;
	kdDebug () << "[ " << device << " ] " << endl;
  	wireless_info info;
	int result = get_info (socket, device, info);
	if ((result != -ENODEV) && (result != -ENOTSUP) &&
	    (!ignoreInterfaces || ignoreInterfaces->findIndex(device)==-1))
	{
		setActiveDevice(device);
	}
   }

   if (interface_name.isEmpty())
   {
	close(socket);
	socket = -1;
	return false;
   }

   return true;
}

bool Interface_wireless_wirelessextensions::poll_device_info ()
{
  if (current < MAX_HISTORY-1)
	++current;
    else
	current = 0;

  if (interface_name.isEmpty())
	if (!autodetect_device())
		return false;

  wireless_info	info;
  int result = get_info (socket, interface_name, info);
  if ((result == -ENODEV) || (result == -ENOTSUP))
	{
	  // interface has disappeared - unplugged?
	  // reset all info except stats
	  setNoActiveDevice();

	  close(socket);
	  socket = -1;

	  return false;
	}

  bool
    emitStatusChanged = false, emitModeChanged = false, emitEssidChanged =
    false, emitSpeedChanged = false, emitStrengthChanged = false;

  iwstats	tempic2;
  WIFI_GET_STATS (socket, (char *) interface_name.latin1(), &tempic2);
  has_frequency = WIFI_CONFIG(info,has_freq);
  if (has_frequency)
    {
      if (frequency != WIFI_CONFIG(info,freq))
	emitStatusChanged = true;
      frequency = WIFI_CONFIG(info,freq);
    }
  has_mode = WIFI_CONFIG(info,has_mode);
  if (has_mode)
    {
      if (mode != WIFI_CONFIG(info,mode))
	emitModeChanged = true;
      mode = WIFI_CONFIG(info,mode);
    }
  has_key = WIFI_CONFIG(info,has_key);
  if (has_key)
    {
      if ((key != (char *) WIFI_CONFIG(info,key)) || (key_size != WIFI_CONFIG(info,key_size))
	  || (key_flags != WIFI_CONFIG(info,key_flags)))
	emitStatusChanged = true;
      key = (char *) WIFI_CONFIG(info,key);
      key_size = WIFI_CONFIG(info,key_size);
      key_flags = WIFI_CONFIG(info,key_flags);
    }
  if (essid != WIFI_CONFIG(info,essid))
    {
      emitStatusChanged = true;
      emitEssidChanged = true;
    }
  essid = (WIFI_CONFIG(info,essid_on) ? WIFI_CONFIG(info,essid) : "any");
  char
    ap_addr[256];
  iw_ether_ntop ( (const ether_addr *) info.ap_addr.sa_data, ap_addr);
  if (access_point_address != ap_addr)
    emitStatusChanged = true;
  access_point_address = ap_addr;
  if (bitrate != info.bitrate.value)
    emitSpeedChanged = true;
  bitrate = info.bitrate.value;
  has_range = info.has_range;

  sigLevel[current] = tempic2.qual.level;
  noiseLevel[current] = tempic2.qual.noise;

  if (has_range) {

    range = info.range.max_qual.qual;
  
    // the following checks adjust values for sig levels that are in dBm
    // according to iwlib.c. If offset is applied, the resulting
    // value is negative and the GUI knows it can add the scale
    // unit dBm. 

    if (tempic2.qual.level > info.range.max_qual.level) {
  	  sigLevel[current] = tempic2.qual.level - 0x100;
          noiseLevel[current] = tempic2.qual.noise - 0x100;
    }
  }

  if (sigLevel[current] < sigLevelMin)
    sigLevelMin = sigLevel[current];
  if (sigLevel[current] > sigLevelMax)
    sigLevelMax = sigLevel[current];

  if (noiseLevel[current] < noiseLevelMin)
    noiseLevelMin = noiseLevel[current];
  if (noiseLevel[current] > noiseLevelMax)
    noiseLevelMax = noiseLevel[current];
  int
    tempqual = tempic2.qual.qual;
  if (has_range && (range != 0))
    tempqual = tempqual * 100 / range;
  if (      qual[current != 0 ? current - 1 : MAX_HISTORY-1] != tempqual)
    emitStrengthChanged = true;

  qual[current] = ( tempqual <= 100 ? tempqual : 100 );
  valid[current] = true;

  // try to get our local IP address
  struct sockaddr *
    sa;
  struct sockaddr_in *
    sin;
  struct ifreq
    ifr;
  /* Copy the interface name into the buffer */
  strncpy (ifr.ifr_name, interface_name.latin1 (), IFNAMSIZ);

  if (ioctl (socket, SIOCGIFADDR, &ifr) == -1)
    {
      if (ip_address != "unavailable")
	emitStatusChanged = true;
      ip_address = "unavailable";
    }
  /* Now the buffer will contain the information we requested */
  sa = (struct sockaddr *) &(ifr.ifr_addr);
  if (sa->sa_family == AF_INET)
    {
      sin = (struct sockaddr_in *) sa;
      if (ip_address != (TQString) inet_ntoa (sin->sin_addr))
	emitStatusChanged = true;
      ip_address = (TQString) inet_ntoa (sin->sin_addr);
    }
  else
    {
      ip_address = "unavailable";
    }
  if (emitStatusChanged)
    emit statusChanged ();
  if (emitStrengthChanged)
    emit strengthChanged ();
  if (emitModeChanged)
    emit modeChanged ();
  if (emitSpeedChanged)
    emit speedChanged ();
  if (emitEssidChanged)
    emit essidChanged (essid);
  emit statsUpdated ();
  return true;
}

TQTable* Interface_wireless_wirelessextensions::get_available_networks ()
{

    networks = new TQTable(0,4,0);
    networks->horizontalHeader()->setLabel( 0, i18n("Network Name") );
    networks->horizontalHeader()->setLabel( 1, i18n("Mode") );
    networks->horizontalHeader()->setLabel( 2, i18n("Quality") );
    networks->horizontalHeader()->setLabel( 3, i18n("WEP") );

    KProcIO *iwlist = new KProcIO;
    TQString iwlist_bin = TDEStandardDirs::findExe("iwlist");
    if(iwlist_bin.isEmpty())
      iwlist_bin = TDEStandardDirs::findExe("iwlist", "/usr/local/sbin:/usr/sbin:/sbin");
    if(iwlist_bin.isEmpty())
      iwlist_bin = "iwlist"; // try our best ;/

    *iwlist << iwlist_bin << interface_name << "scanning";

//    connect ( iwlist, TQT_SIGNAL ( readReady ( KProcIO * ) ), this, TQT_SLOT ( parseScanData ( KProcIO * ) ) );
	    
   if ( !iwlist->start ( TDEProcess::Block ) )
        KMessageBox::sorry ( 0, i18n ( "Unable to perform the scan. Please make sure the executable \"iwlist\" is in your $PATH." ),
				i18n ( "Scanning not possible" ) );

    // this should never happen. But there was a report about Block not being as blocking as it should, so let's be safe about it
    while (iwlist->isRunning()) sleep ( 1 );

    parseScanData ( iwlist );
   
    for (int i = 0; i<4; i++ ) networks->adjustColumn(i);

    return networks;
}

void
Interface_wireless_wirelessextensions::parseScanData ( KProcIO * iwlist )
{
  TQString data;
  int cellcount = 0, iteratecount = 0;
  bool ignoreRemainingBits = false;
  while ( iwlist->readln ( data, true ) >= 0 )
    {
      kdDebug (  ) << "iwlist: " << data << "\n";
      if ( data.contains ( "does not support scanning" ) )
        KMessageBox::sorry ( 0,
                             i18n
                             ( "Your card does not support scanning. The results window will not contain any results." ),
                             i18n ( "Scanning not possible" ) );
      if ( data.contains ( "Scan completed" ) )
        cellcount = 0;          // at the very beginning of a scan
      if ( data.contains ( "Cell" ) ) {
        cellcount++;            // new cell discovered
	networks->setNumRows ( networks->numRows() +1 );
	ignoreRemainingBits = false;
      }
      if ( data.contains ( "ESSID:" ) )
        {
          TQString ssid = data.mid ( data.find ( "\"" ) + 1, data.length (  ) - data.find ( "\"" ) - 2 );
	  if ((ssid=="") || (ssid==" ")) ssid = "(hidden cell)";
          networks->setText ( cellcount - 1, 0, ssid );
        }
      if ( data.contains ( "Mode:" ) )
        {
          if ( data.contains ( "Master" ) )
            networks->setText ( cellcount - 1, 1, TQString ( i18n ( "Managed" ) ) );
          if ( data.contains ( "Ad-Hoc" ) )
            networks->setText ( cellcount - 1, 1, TQString ( i18n ( "Ad-Hoc" ) ) );
	  // if could be that this cell belongs to an SSID already discovered, or that there are more than one
	  // hidden cells, which doesn't give any new information. So, we first search for duplicates and delete 
	  // this row if it's a duplicate. If the same SSID is there once as Managed and once as Ad-Hoc it is no
	  // duplicate of course, but "something completely different"
	  for (iteratecount = 0; iteratecount < cellcount - 1; iteratecount++)
	  {
	      kdDebug() << "Comparing <" << networks->text(cellcount - 1, 0) << "," << networks->text(iteratecount,0) << " and <"
		        << networks->text(cellcount - 1, 1) << "," << networks->text(iteratecount,1) << ">.\n";
	      if ((networks->text(cellcount - 1 , 0) == networks->text(iteratecount,0)) &&
	          (networks->text(cellcount - 1 , 1) == networks->text(iteratecount,1)) )
	      {
	           networks->setNumRows ( networks->numRows() - 1 );
	           cellcount--;
		   ignoreRemainingBits = true;
	      }
	  }
        }
      if ( !ignoreRemainingBits && data.contains ( "Encryption key:" ) )
        {
          if ( data.contains ( "off" ) )
            networks->setText ( cellcount - 1, 3, TQString ( "off" ) );
          else
            networks->setText ( cellcount - 1, 3, TQString ( "on" ) );
        }
      if ( !ignoreRemainingBits && data.contains ( "Quality:" ) )
        {
          TQString quality = data.mid ( data.find ( ":" ) + 1, data.find ( "/" ) - data.find ( ":" ) - 1 );
          networks->setText ( cellcount - 1, 2, quality );
        }
      
      if ( !ignoreRemainingBits && data.contains ( "Quality=" ) )
        {
          TQString quality = data.mid ( data.find ( "=" ) + 1, data.find ( "/" ) - data.find ( "=" ) - 1 );
          networks->setText ( cellcount - 1, 2, quality );
        }
      
      if ( !ignoreRemainingBits && data.contains ( "wpa_ie" ) )
	{
	  networks->setText ( cellcount - 1, 3, TQString ( "WPA" ) );
	}
      
      if ( !ignoreRemainingBits && data.contains ( "rsn_ie" ) )
        {
          networks->setText ( cellcount - 1, 3, TQString ( "WPA2" ) );
        }
      
    }
}

#include "interface_wireless_wirelessextensions.moc"