Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

stumbler.cpp

Go to the documentation of this file.
00001 #include <qstring.h>
00002 #include <qtimer.h>
00003 #include <qapplication.h>
00004 
00005 //#include <opie2/onetutils.h>
00006 #include <opie2/onetwork.h>
00007 #include <opie2/odebug.h>
00008 
00009 #include "stumbler.h"
00010 
00011 using namespace Opie::Net;
00012 
00013 Stumbler::Stumbler(const QString &iface, QObject *parent, const char *name)
00014     :QObject(parent, name), m_interval(5000),
00015     m_wifaceName(iface),
00016     m_timer(new QTimer(this))
00017 {
00018     m_wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_wifaceName));
00019     connect(m_timer, SIGNAL(timeout()), this, SLOT(slotRefresh()));
00020 }
00021    
00022 
00023 void Stumbler::start()
00024 {
00025     if (!m_wiface) {
00026         odebug << "Error, interface " << m_wifaceName << " does not exist" << oendl;
00027         return;
00028     }
00029     
00030     if (!ONetwork::instance()->isWirelessInterface(m_wifaceName.ascii())) {
00031         odebug << "Error, " << m_wifaceName << " is not a wireless interface" << oendl;
00032         //FIXME: Tell the user about this
00033         return;
00034     }
00035     
00036     if (!m_timer->isActive()) {
00037         odebug << "Starting stumbler" << oendl;
00038         m_wiface->setUp(false);
00039         m_wiface->setSSID("any");
00040         m_wiface->setAssociatedAP( OMacAddress::broadcast );
00041         m_wiface->setUp(true);
00042         m_timer->start(m_interval);
00043     }
00044 }
00045 
00046 void Stumbler::stop()
00047 {
00048     if (m_timer->isActive()) {
00049         odebug << "Stoping stumbler" << oendl;
00050         m_timer->stop();
00051     }
00052 }
00053 
00054 void Stumbler::setInterval(int msec)
00055 {
00056     m_interval = msec;
00057     if (m_timer->isActive()) {
00058         m_timer->stop();
00059         m_timer->start(m_interval);
00060     }
00061 }
00062 
00063 void Stumbler::setIface(const QString &iface)
00064 {
00065     m_wifaceName = iface;
00066     m_wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_wifaceName));
00067 }
00068 
00069 void Stumbler::slotRefresh()
00070 {
00071     m_stationList = m_wiface->scanNetwork();
00072     if ( qApp )
00073         qApp->processEvents();
00074     emit (newdata());
00075 }
00076 
00077 Opie::Net::OStationList * Stumbler::stations()
00078 {
00079     return m_stationList;
00080 }

Generated on Sat Nov 5 16:17:42 2005 for OPIE by  doxygen 1.4.2