summaryrefslogtreecommitdiff
authorwimpie <wimpie>2005-01-06 23:52:47 (UTC)
committer wimpie <wimpie>2005-01-06 23:52:47 (UTC)
commita8e5ecd107a79f940d8a99d4a77071606a3a932f (patch) (side-by-side diff)
tree3b2603d07877fb05fc5f2a0dbbbcf3ad1cce74c3
parenta056b6d067800486d9c1ce99d1b923289d335e8f (diff)
downloadopie-a8e5ecd107a79f940d8a99d4a77071606a3a932f.zip
opie-a8e5ecd107a79f940d8a99d4a77071606a3a932f.tar.gz
opie-a8e5ecd107a79f940d8a99d4a77071606a3a932f.tar.bz2
Some namespace } -> };
added NS2SetMac.sh script in control file added activate/disactivate for usb renamed templates directory to NS2templates
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/main.cpp12
-rw-r--r--noncore/settings/networksettings2/networksettings2/systemfile.cpp2
-rw-r--r--noncore/settings/networksettings2/opie-networksettings2.control2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDevice.h4
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriver.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTIcons.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTInquiry.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTPeer.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTSDPService.h2
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTUUID.h2
-rw-r--r--noncore/settings/networksettings2/usb/usbrun.cpp14
13 files changed, 25 insertions, 25 deletions
diff --git a/noncore/settings/networksettings2/main.cpp b/noncore/settings/networksettings2/main.cpp
index 8487e3e..973b4b7 100644
--- a/noncore/settings/networksettings2/main.cpp
+++ b/noncore/settings/networksettings2/main.cpp
@@ -1,175 +1,163 @@
#include "nsdata.h"
#include "activateprofile.h"
#include "activatevpn.h"
#include "networksettings.h"
#include <opie2/odebug.h>
#include <qpe/qpeapplication.h>
#include <opie2/oapplicationfactory.h>
using namespace Opie::Core;
#ifdef GONE
OPIE_EXPORT_APP( OApplicationFactory<NetworkSettings> )
#else
// just standard GUI
#define ACT_GUI 0
// used by interfaces to request for allow of up/down
#define ACT_REQUEST 1
// regenerate config files
#define ACT_REGEN 2
// used by interfaces to request user prompt
#define ACT_PROMPT 3
// used by interfaces to trigger VPN
#define ACT_VPN 4
// activate opietooth
#define ACT_OT 5
// include Opietooth GUI
#include <opietooth2/Opietooth.h>
using namespace Opietooth2;
#include <qpushbutton.h>
#include <qlayout.h>
#include <qframe.h>
#include <qlabel.h>
int main( int argc, char * argv[] ) {
int rv = 0;
int Action = ACT_GUI;
// could be overruled by -qws
QApplication::Type GuiType = QApplication::GuiClient;
-#ifdef _WS_QWS_
QPEApplication * TheApp;
-#else
- QApplication * TheApp;
-#endif
for ( int i = 1; i < argc; i ++ ) {
int rmv;
rmv = 0;
if( strcmp( argv[i], "--regen" ) == 0 ) {
Action = ACT_REGEN;
GuiType = QApplication::Tty;
rmv = 1;
} else if( strcmp( argv[i], "--prompt" ) == 0 ) {
Action = ACT_PROMPT;
rmv = 1;
} else if( strcmp( argv[i], "--triggervpn" ) == 0 ) {
Action = ACT_VPN;
rmv = 1;
} else if( strcmp( argv[i], "--opietooth" ) == 0 ) {
Action = ACT_OT;
rmv = 1;
}
if( rmv ) {
memmove( argv+i, argv+i+rmv,
sizeof( char * ) * (argc-i-rmv) );
i --;
argc -= rmv;
}
}
if( strstr( argv[0], "-request" ) ) {
// called from system to request something
GuiType = QApplication::Tty;
Action = ACT_REQUEST;
Log(("Request : %s\n", argv[1] ));
} else if( strstr( argv[0], "-opietooth" ) ) {
Action = ACT_OT;
}
// Start Qt
-#ifdef _WS_QWS_
// because QPEApplication does not handle GuiType well
if( GuiType == QApplication::Tty ) {
// this cast is NOT correct but we do not use
// TheApp anymore ...
TheApp = (QPEApplication *)new QApplication( argc, argv, GuiType );
} else {
TheApp = new QPEApplication( argc, argv, GuiType );
}
-#else
- TheApp = new QApplication( argc, argv, GuiType );
-#endif
// init qt with app widget
switch( Action ) {
case ACT_REQUEST :
{ NetworkSettingsData NS;
if( NS.canStart( argv[1] ) ) {
QStringList S;
S << QPEApplication::qpeDir() + "/bin/networksettings2";
S << "networksettings2";
S << "--prompt";
S << argv[1];
NSResources->system().execAsUser( S );
Log(("FAILED %s-cNN-allowed\n", argv[1] ));
// if we come here , failed
printf( "%s-cNN-disallowed", argv[1] );
}
}
break;
case ACT_REGEN :
{ NetworkSettingsData NS;
QString S= NS.generateSettings();
// regen returns 0 if OK
rv = ( S.isEmpty() ) ? 0 : 1;
}
break;
case ACT_PROMPT :
{ ActivateProfile AP(argv[1]);
if( AP.exec() == QDialog::Accepted ) {
Log(("%s-c%ld-allowed\n",
argv[1], AP.selectedProfile() ));
printf( "%s-c%ld-allowed", argv[1], AP.selectedProfile() );
} else {
Log(("%s-c%NN-disallowed\n", argv[1] ));
printf( "%s-cNN-disallowed", argv[1] );
}
}
break;
case ACT_VPN :
{ ActivateVPN AVPN;
AVPN.exec();
}
break;
case ACT_GUI :
case ACT_OT :
{ QWidget * W;
if( Action == ACT_OT ) {
W = new OTMain( 0 );
} else {
W = new NetworkSettings(0);
}
TheApp->setMainWidget( W );
W->show();
-#ifdef _WS_QWS_
W->showMaximized();
-#else
- W->resize( W->sizeHint() );
-#endif
rv = TheApp->exec();
delete W;
}
break;
}
LogClose();
return rv;
}
#endif
// main.cpp
diff --git a/noncore/settings/networksettings2/networksettings2/systemfile.cpp b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
index 82fd43a..8deef94 100644
--- a/noncore/settings/networksettings2/networksettings2/systemfile.cpp
+++ b/noncore/settings/networksettings2/networksettings2/systemfile.cpp
@@ -1,235 +1,235 @@
#include <stdio.h>
#include <qpe/qpeapplication.h>
#include <qfileinfo.h>
#include <qmessagebox.h>
#include <qfile.h>
#include <qtextstream.h>
#include "resources.h"
#include "systemfile.h"
-#define TEMPLATEDIR "networktemplates/"
+#define TEMPLATEDIR "NS2templates/"
QString TemplDir;
SystemFile::SystemFile( const QString & N,
const QString & P,
bool KDI ){
Name = N;
Path = P;
InAppend = 0;
F = 0;
// get template info
{ QString S;
QFileInfo FI;
// find location of templates
TemplDir = QPEApplication::qpeDir() + "etc/" + TEMPLATEDIR;
FI.setFile( TemplDir );
if( ! FI.isDir() ) {
// try current dir
TemplDir = "./" TEMPLATEDIR;
FI.setFile( TemplDir );
if( ! FI.isDir() ) {
hasPreSection =
hasPostSection =
hasPreNodeSection =
hasPostNodeSection =
hasPreDeviceSection =
hasPostDeviceSection = 0;
return;
}
}
// have found location
S = TemplDir + Name + "/presection";
FI.setFile( S );
hasPreSection = ( FI.exists() && FI.isReadable() );
S = TemplDir + Name + "/postsection";
FI.setFile( S );
hasPostSection = ( FI.exists() && FI.isReadable() );
S = TemplDir + Name + "/prenodesection";
FI.setFile( S );
hasPreNodeSection = ( FI.exists() && FI.isReadable() );
S = TemplDir + Name + "/postnodesection";
FI.setFile( S );
hasPostNodeSection = ( FI.exists() && FI.isReadable() );
S = TemplDir + Name + "/predevicesection";
FI.setFile( S );
hasPreDeviceSection = ( FI.exists() && FI.isReadable() );
S = TemplDir + Name + "/postdevicesection";
FI.setFile( S );
hasPostDeviceSection = ( FI.exists() && FI.isReadable() );
}
KnowsDeviceInstances = KDI;
}
SystemFile::SystemFile( const QString & N, bool KDI ){
Name = N;
Path = "";
InAppend = 0;
F =0;
KnowsDeviceInstances = KDI;
hasPreSection =
hasPostSection =
hasPreNodeSection =
hasPostNodeSection =
hasPreDeviceSection =
hasPostDeviceSection = 0;
}
SystemFile::~SystemFile( void ) {
close();
}
bool SystemFile::open( void ) {
QString Prefix = getenv( "NS2OUTPUTTO" );
if( Prefix != "stderr" /* && Name != "interfaces" */ ) {
// generate files where the need to be
if( F ) {
F->close();
delete F;
}
F = new QFile( Prefix + Path + ((InAppend)?"":"bup") );
Log(( "Open systemfile %s\n", F->name().latin1() ));
if( ! F->open( ((InAppend)?IO_Append : 0 ) | IO_WriteOnly ) ) {
return 0;
}
} else {
if( ! F ) {
owarn << "!!!!!!!!!!!!!!!!!! " << oendl;
owarn << "!!!! TESTMODE !!!!" << oendl;
owarn << "!!!!!!!!!!!!!!!!!! " << oendl;
owarn << "!!!!" << oendl;
owarn << "!!!! GENERATE " << Path << oendl;
if( InAppend ) {
owarn << "!!!! In APPEND mode" << oendl;
}
owarn << "!!!!" << oendl;
owarn << "!!!!!!!!!!!!!!!!!!" << oendl;
F = new QFile();
F->open( IO_WriteOnly, stderr );
}
}
setDevice( F );
return 1;
}
bool SystemFile::close( void ) {
if( ! F || ! F->isOpen() ) {
return 1 ;
}
QString Prefix = getenv( "NS2OUTPUTTO" );
if( Prefix == "stderr" ) {
return 1;
}
QString OldP = Prefix + Path + "bup";
F->close();
delete F;
F = 0;
if( ! InAppend ) {
owarn << "Rename " << OldP << " to " << Path << oendl;
return ( rename( OldP.latin1(), Path.latin1() ) >= 0 );
}
return 1;
}
bool SystemFile::preSection( void ) {
if( hasPreSection ) {
QFile Fl( TemplDir + Name + "/presection" );
if( ! Fl.open( IO_ReadOnly ) )
return 0; // error
// copy file to this file
F->writeBlock( Fl.readAll() );
}
return 1;
}
bool SystemFile::postSection( void ) {
if( hasPostSection ) {
QFile Fl( TemplDir + Name + "/postsection" );
if( ! Fl.open( IO_ReadOnly ) )
return 0; // error
// copy file to this file
F->writeBlock( Fl.readAll() );
}
return 1;
}
bool SystemFile::preNodeSection( ANetNodeInstance * NNI, long ) {
if( hasPreNodeSection ) {
QFile Fl( TemplDir + Name + "/prenodesection" );
if( ! Fl.open( IO_ReadOnly ) )
return 0; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
while( ! TX.eof() ) {
Out = S.
arg(NNI->nodeClass()->name());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 1;
}
bool SystemFile::postNodeSection( ANetNodeInstance * NNI, long ) {
if( hasPostNodeSection ) {
QFile Fl( TemplDir + Name + "/postnodesection" );
if( ! Fl.open( IO_ReadOnly ) )
return 0; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
while( ! TX.eof() ) {
Out = S.
arg(NNI->name());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 1;
}
bool SystemFile::preDeviceSection( ANetNode * NN ) {
if( hasPreDeviceSection ) {
QFile Fl( TemplDir + Name + "/predevicesection" );
if( ! Fl.open( IO_ReadOnly ) )
return 0; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
while( ! TX.eof() ) {
Out = S.arg(NN->name());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 1;
}
bool SystemFile::postDeviceSection( ANetNode * NN ) {
if( hasPostDeviceSection ) {
QFile Fl( TemplDir + Name + "/postdevicesection" );
if( ! Fl.open( IO_ReadOnly ) )
return 0; // error
QTextStream TX( &Fl );
QString Out;
QString S = TX.readLine();
while( ! TX.eof() ) {
Out = S.arg(NN->name());
(*this) << Out << endl;
S = TX.readLine();
}
}
return 1;
}
diff --git a/noncore/settings/networksettings2/opie-networksettings2.control b/noncore/settings/networksettings2/opie-networksettings2.control
index 874833c..a79a740 100644
--- a/noncore/settings/networksettings2/opie-networksettings2.control
+++ b/noncore/settings/networksettings2/opie-networksettings2.control
@@ -1,10 +1,10 @@
Package: opie-networksettings2
-Files: bin/networksettings2 apps/Settings/networksettings2.desktop pics/networksettings2/*.png lib/libnetworksettings2.so* pics/networksettings2/Devices/*.png etc/NS2templates/* etc/NS2templates/*/*
+Files: bin/networksettings2 apps/Settings/networksettings2.desktop pics/networksettings2/*.png lib/libnetworksettings2.so* pics/networksettings2/Devices/*.png etc/NS2templates/* etc/NS2templates/*/* bin/NS2SetMac.sh
Priority: optional
Section: opie/settings
Maintainer: wim delvaux <wimpie@handhelds.org>
Architecture: arm
Depends: task-opie-minimal, libopietooth2
Description: Network settings.
Replaces: opie-networksetup
Version: $QPE_VERSION$EXTRAVERSION
diff --git a/noncore/settings/networksettings2/opietooth2/OTDevice.h b/noncore/settings/networksettings2/opietooth2/OTDevice.h
index c2abb09..cf1c4b6 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDevice.h
+++ b/noncore/settings/networksettings2/opietooth2/OTDevice.h
@@ -1,116 +1,116 @@
#ifndef OTDEVICE_H
#define OTDEVICE_H
#include <qobject.h>
#include <qstring.h>
#include <bluezlib.h>
#include <OTGateway.h>
// define if you want to use the process hciattach for detection
// #define USEHCIPROC
class QTimerEvent;
namespace Opie {
namespace Core {
class OProcess;
- }
-}
+ };
+};
namespace Opietooth2 {
/**
* Device takes care of attaching serial
* devices to the blueZ stack.
* After attaching it hciconfig ups it
*/
class OTDevice : public QObject {
Q_OBJECT
public:
/**
* Brings up the device.
* will detech which device is needed
* Usage example: new Device(/dev/ttySB0, csr)
*
*/
OTDevice( OTGateway * _OT );
/**
* unloads the device
*/
~OTDevice();
inline OTGateway * gateway() const
{ return OT; }
inline bool needsAttach( void ) const
{ return NeedsAttach; }
inline int deviceNr() const
{ return m_deviceNr; }
/**
* attach the device
* @return bool which is TRUE if command started sucessfully
*/
bool attach();
/**
* detach the device
* @return bool which is TRUE if command started sucessfully
*/
bool detach();
/**
* Is the device loaded?
* @return bool, if the device is loaded
*/
bool isAttached()const;
// check current state of attachment
bool checkAttach();
// returns pattern that points to the proper
// RFCOMM device file. Put %1 where device nr should be put
// e.g. : /dev/bluetooth/rfcomm/%1 or /def/rfcomm%1
QString getRFCommDevicePattern();
signals:
/**
* Signals if the attach/detach of the device produced
* errors
* @param Mesg contains an error message
*/
void error( const QString & mesg );
void isEnabled( int devnr, bool );
private slots:
void slotStdOut(Opie::Core::OProcess*, char*, int );
void slotStdErr(Opie::Core::OProcess*, char*, int );
private:
void detectDeviceType( QString & Device,
QString & Mode,
unsigned long & Speed );
pid_t getPidOfHCIAttach( void );
Opie::Core::OProcess* m_hciattach; // ptr to hciattach proces
int m_deviceNr; // x as in hci(x)
pid_t m_hciattachPid; // pid of hciattach program
// backpointer
OTGateway * OT;
bool NeedsAttach;
};
};
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h b/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h
index 8395f37..50f28fc 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h
+++ b/noncore/settings/networksettings2/opietooth2/OTDeviceAddress.h
@@ -1,108 +1,108 @@
//-*-c++-*-
/***************************************************************************
* Copyright (C) 2003 by Fred Schaettgen *
* kdebluetooth@0xF.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. *
***************************************************************************/
#ifndef OTDEVICEADDRESS_H
#define OTDEVICEADDRESS_H
#include <qstring.h>
#include <bluezlib.h>
namespace Opietooth2 {
/** Represents a Bluetooth device address.
* This class allows easy conversion of Bluetooth addresses
* from and to strings. It also works with the bdaddr_t type
* used by BlueZ.
* The class offers a comparsion and less-than operator, so
* that it can be used a key in an STL map or similar.
* The string conversion functions of BlueZ are used internally,
* so the string format is the same than for BlueZ's ba2str().
*/
class OTDeviceAddress {
public:
/** Default constructor.
The resulting address is equal to DeviceAddress::invalid.
*/
OTDeviceAddress();
/** Initialize the object with a BlueZ bdaddr_t.
@param bdaddr address
@param networkbyteorder if true, bdaddr is assumed to be in
network byte order and converted to host byte order first.
*/
explicit OTDeviceAddress( const bdaddr_t& bdaddr,
bool networkbyteorder = false
);
/** Initializes the object with an address given as a string.
The string must be in a format which is understood by the
BlueZ str2ba function, like 00:61:58:4C:E6:AD. Case doesn't matter.
@param s address string
*/
explicit OTDeviceAddress(const QString& s);
/** convert the address to a string.
@return address string
*/
QString toString() const;
/** Converts the DeviceAddress into a BlueZ bdaddr_t.
@param networkbyteorder if true, the address is returned
in network byte order.
@return the address as bdaddr_t
*/
inline const bdaddr_t & getBDAddr( void ) const
{ return BDaddr; }
bdaddr_t getBDAddrInNetworkByteOrder() const;
void setBDAddr( const bdaddr_t& bdaddr,
bool networkbyteorder = false
);
/** Less-than-operator.
Mainly there to use DeviceAddress inside STL containers,
like STL sets or as a key in a STL map.
@param b the DeviceAddress to compare to (right hand side)
@return true if this < b, false otherwise.
*/
bool operator<(const OTDeviceAddress& b) const;
/** Equality operator.
Tests two device addresses for equality.
@param b the DeviceAddress to compare to (right hand side)
@return true if this and b have the same address or
if both are invalid, false otherwise
*/
bool operator==(const OTDeviceAddress& b) const;
inline bool operator!=(const OTDeviceAddress& b) const
{ return ! ( *this == b ); }
/** The address 00:00:00:FF:FF:FF */
static const OTDeviceAddress local;
/** The address 00:00:00:00:00:00 */
static const OTDeviceAddress any;
/** An address tagged as invalid */
static const OTDeviceAddress invalid;
protected:
bdaddr_t BDaddr;
bool IsValid;
};
-}
+};
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriver.h b/noncore/settings/networksettings2/opietooth2/OTDriver.h
index b54ffdf..f249cf7 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDriver.h
+++ b/noncore/settings/networksettings2/opietooth2/OTDriver.h
@@ -1,232 +1,232 @@
/***************************************************************************
* Copyright (C) 2003 by Mattia Merzi *
* ottobit@ferrara.linux.it *
* *
* 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. *
***************************************************************************/
#ifndef OTDRIVER_H
#define OTDRIVER_H
/*
* This class handles the connection with the BlueZ libraries, implements
* most of the bluetooth-related functions and owns the KBTDevice class
* that is a single local bluetooth device representation.
* It is used as a Singleton pattern thru the getDefaultConnector() method.
*
*/
#include <qobject.h>
#include <opie2/odebug.h>
#include <bluezlib.h>
#include <OTDeviceAddress.h>
namespace Opietooth2 {
class OTGateway;
class OTHCISocket;
class OTDeviceAddress;
class OTPeer;
/*
* This is the representation of a
* Bluetooth device for the local
* machine.
*/
class OTDriver : public QObject {
Q_OBJECT
public:
OTDriver( OTGateway * Ot, struct hci_dev_info* di);
~OTDriver();
inline OTGateway * gateway() const
{ return OT; }
/*
* Initializes the device using the passed hci_dev_info
* struct, contining the basic information in order to
* talk with the pyisical device.
*/
void init(struct hci_dev_info* di);
/*
* Open the device and obtains a file descriptor to id
* return if open
*/
bool open();
OTHCISocket * openSocket();
void closeSocket();
/*
* Return true if the device is opened.
*/
int isOpen()
{ return Fd != -1; };
/*
* Calls the ioctl(HCIDEVRESET) in order to
* reset the device.
*/
int reset();
// set Up if true and not yet up
void setUp( bool Mode );
/*
* Turn the device up and the reinitializes the device.
* If the device is already up, nothing is done.
*/
void bringUp();
/*
* Turn the device down and the reinitializes the device.
* If the device is already down, nothing is done.
*/
void bringDown();
// is the device UP now
bool isUp() const
{ return IsUp; }
// get current state
// return 1 if UP, 0 if DOWN, -1 if ERROR
int currentState();
/*
* Returns the name of the device. If the device is
* down, the device id is returned.
*/
QString name();
int devId() const
{ return Dev_id; };
/*
* Returns the string representation of the device id,
* with the same format of the hciconfig tool.
*/
QString devname()
{ return Dev; };
/*
* Returns the file descriptor for the local
* connection to this device
*/
int fd() const
{ return Fd; };
void setfd(int _fd)
{ Fd = _fd; };
void setType(int _type)
{ Type = _type; };
int type() const
{ return Type; };
QString strType();
int iscan() const
{ return Iscan; }
void setIScan(int _iscan)
{ Iscan = _iscan; }
int pscan() const
{ return Pscan; }
void setPScan(int _pscan)
{ Pscan = _pscan; }
int authentication() const
{ return Auth; }
void setAuthentication(int _auth)
{ Auth = _auth; }
int encryption() const
{ return Encrypt; }
void setEncryption(int _encrypt)
{ Encrypt = _encrypt; }
void setDevId(int _dev_id)
{ Dev_id = _dev_id; };
void setDev(char* _dev)
{ Dev = _dev; };
void setFlags( unsigned long flags);
const OTDeviceAddress & address()
{ return Address; }
void setFeatures( unsigned char * _f);
QString features()
{ return Features; }
void setManufacturer(int compid);
QString manufacturer()
{ return Manufacturer; }
QString revision();
void setScanMode(bool iscan, bool pscan);
void setClass(unsigned long cls);
void changeDevName(const char* name);
void changeEncryption(bool _encryption);
void changeAuthentication(bool _auth);
void getClass( QString & service,
QString & device );
void changeClass( unsigned char service,
unsigned char major,
unsigned char minor);
QString getPeerName( const OTDeviceAddress & PAddr );
// address must be connected to this driver
long getLinkQuality( const OTDeviceAddress & Address );
signals :
void error( const QString & );
void stateChange( OTDriver * , bool );
void driverDisappeared( OTDriver * );
private slots :
/*
* Reinitializes the device, obtaining a fresh
* hci_dev_info structure.
*/
void reinit();
void SLOT_CloseFd();
private:
QString getRevEricsson();
QString getRevCsr(unsigned short rev);
QString Name;
QString Dev;
QString Revision;
QString Manufacturer;
OTDeviceAddress Address;
QString Features;
QTimer * AutoClose;
int Dev_id,Fd,Type;
bool IsUp;
int Iscan,Pscan,Auth,Encrypt;
// socket bound to this device
OTHCISocket * Socket;
// backpointer to opietooth system
OTGateway * OT;
};
-}
+};
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTIcons.h b/noncore/settings/networksettings2/opietooth2/OTIcons.h
index ee10831..966ed24 100644
--- a/noncore/settings/networksettings2/opietooth2/OTIcons.h
+++ b/noncore/settings/networksettings2/opietooth2/OTIcons.h
@@ -1,54 +1,54 @@
#ifndef OTICONLOADER_H
#define OTICONLOADER_H
#include <OTUUID.h>
#include <qpixmap.h>
#include <qmap.h>
namespace Opietooth2 {
class OTIcons {
public:
OTIcons();
~OTIcons();
/**
* Returns an icon depending on device class
* @param deviceClass the device class name
* @return the pixmap
*/
QPixmap deviceIcon( const QString & );
/**
* Returns an icon depending on service id
* @param serviceClass the service id
* @return the pixmap
* @return true if found
*/
QPixmap serviceIcon( int, bool & );
// returns all UUID that represent channels with modem function
const UUIDVector & modems()
{ return Modems; }
// returns all UUID that represent channels with network
const UUIDVector & network()
{ return Networks; }
// set Sub to find icons in .../Icons dir
QPixmap loadPixmap( const QString &, bool Sub = 0 );
private:
// first ist id, second is icon name
QMap<QString,QString> deviceIcons;
QMap<int,QString> serviceIcons;
UUIDVector Modems;
UUIDVector Networks;
};
-}
+};
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTInquiry.h b/noncore/settings/networksettings2/opietooth2/OTInquiry.h
index f7bdeec..2682499 100644
--- a/noncore/settings/networksettings2/opietooth2/OTInquiry.h
+++ b/noncore/settings/networksettings2/opietooth2/OTInquiry.h
@@ -1,178 +1,178 @@
//-*-c++-*-
/***************************************************************************
* Copyright (C) 2003 by Fred Schaettgen *
* kdebluetooth@schaettgen.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. *
***************************************************************************/
#ifndef OTINQUIRY_H
#define OTINQUIRY_H
#include <qstring.h>
#include <qobject.h>
#include <qguardedptr.h>
#include <qtimer.h>
#include <OTPeer.h>
// #include <set>
// #include <deque>
namespace Opietooth2 {
class QSocket;
class QDateTime;
class OTDriver;
class OTHCISocket;
/** Scans for nearby bluetooth devices.
* This class provides an asynchronous interface to the
* inquriy HCI command. To scan for other devices, connect
* to the signals neighbourFound() and finished() and call
* inquiry(). Inquiry results are signalled as soon as they arrive,
* so the information can be displayed before the whole inquiry
* process is finished.
* Still no connections should be set up before
* the finished() signal was sent (hmm, is this always true..?)
*/
class OTInquiry : public QObject {
Q_OBJECT
public:
/** Constructor.
@param owner The owning parent object
*/
OTInquiry( OTDriver* Drv );
/** Destructor. */
virtual ~OTInquiry();
// General/Unlimited Inquiry Access Code
static const int GIAC = 0x9E8B33;
// Limited Dedicated Inquiry Access Code
static const int LIAC = 0x9E8B00;
/** Starts the inquiry.
if you start inquiry several times without calling clear(),
you will receive each result only once.
@param timeout duration of the inquiry in seconds.
It will be rounded to the next multiple of 1.28 sec,
with a maximum of 61.44 sec.
@param lap
*/
bool inquire( double timeout = 8.0,
int numResponses = 0,
int lap = GIAC);
void stopInquiring( );
/** Enters periodic inquiry mode.
An inquiry will be started at a random time in the intervall
between minduration and maxduration.
@param minduration minimum time between two inquiries. Rounded to
a multiple of 1.28, (3.84 <= d <= 83884.8)
@param maxduration maximum time between two inquiries. Rounded to
a multiple of 1.28, (3.84 <= d <= 83884.8)
@param timeout duration of the inquiry in seconds.
It will be rounded to the next multiple of 1.28 sec,
with a maximum of 61.44 sec.
@param numResponses Number of responses after which the inquiry
will be stopped. 0 means no limit.
@param lap
*/
/*
void inquirePeriodically( double minduration,
double maxduration,
double timeout = 8.0,
int numResponses = 0,
int lap = LIAC
);
*/
/** checks if there the inquiry is running currently
@return true if there is an inquiry running
which was started by this object.
@todo possibility to check for "foreign" inquiries. Deal with
the fact that we can receive foreign inquiry results.
*/
bool isInquiring();
/** This function returns true after after an inquiry was
started, results were received and the inquiry ended successfully.
This can be the case without calling inquiry() at all, because
results of inquiries started by other programs are also processed.
*/
bool isFinished();
/** Resets the list of received results and sets
isInquiryComplete() to false.
*/
void reset();
inline OTDriver * driver() const
{ return Driver; }
protected:
/** Called when a new neighbour was found. The default
implementation emits the neighbourFound signal.
@param bdaddr the address found.
*/
virtual void onPeerFound( OTPeer * Peer, bool );
enum ErrorCode {
InquiryFinishedTimeout = 0x0100
};
signals :
void peerFound( OTPeer *, bool );
/** Emitted after an inquiry has finished successfully.
If the inquiry was canceled, no finished signals is emitted.
This signal can be emitted without having called inquiry, since
other processes may have started an inquiry.
*/
void finished();
/** Emitted instead of finished if an error occured after
calling inquiry() or periodicInquiryMode()
@param code error code.
@param message Error message
*/
void error( QString message );
private:
// std::set<DeviceAddress> addrCache;
// double currentTimeout;
// QByteArray* buf;
// QSocket* hciSocket;
QGuardedPtr<OTHCISocket> Socket;
OTDriver * Driver;
//QDateTime *startTime;
QTimer *InquiryTimeoutTimer;
// std::deque<InquiryInfo> infoQueue;
bool SuccessfullyStarted;
bool SuccessfullyEnded;
private slots:
void slotInquiryTimeout();
void slotHCIEvent(unsigned char eventCode, QByteArray buf);
};
-}
+};
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTPeer.h b/noncore/settings/networksettings2/opietooth2/OTPeer.h
index c09af15..9cd0dc7 100644
--- a/noncore/settings/networksettings2/opietooth2/OTPeer.h
+++ b/noncore/settings/networksettings2/opietooth2/OTPeer.h
@@ -1,135 +1,135 @@
//-*-c++-*-
/***************************************************************************
* Copyright (C) 2003 by Fred Schaettgen *
* kdebluetooth@0xF.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. *
***************************************************************************/
#ifndef OTPEER_H
#define OTPEER_H
#include <qstring.h>
#include <qobject.h>
#include <qvector.h>
#include <bluezlib.h>
#include <OTDeviceAddress.h>
class QTextStream;
class QTimerEvent;
namespace Opietooth2 {
class OTGateway;
class OTDriver;
class OTSDPService;
class OTSDPAttribute;
class OTUUID;
typedef QVector<OTSDPService> ServiceVector;
class OTPeer : public QObject {
Q_OBJECT;
public :
typedef enum PeerState_E {
Peer_Unknown = -1,
Peer_Down = 0,
Peer_Up = 1
} PeerState_t;
OTPeer( OTGateway * _OT );
OTPeer( QTextStream & TS, OTGateway * _TS );
~OTPeer();
inline OTGateway * gateway() const
{ return OT; }
inline int deviceClass( void ) const
{ return Class; }
inline void setDeviceClass( int cls )
{ Class = cls; }
void setAddress( const OTDeviceAddress & A )
{ Addr = A; }
const OTDeviceAddress & address( void )
{ return Addr; }
inline QString name( void ) const
{ return Name; }
inline void setName( const QString & n )
{ Name = n; }
ServiceVector & services( bool Force = 0 )
{ if( Force || serviceList.count() == 0 ) {
updateServices();
}
return serviceList;
}
/* Returns TRUE if the device has at least a service
with inside the required class Id.*/
bool hasServiceClassID( const OTUUID & uuid);
/* Get a vector of Rfcomm channels of the services
having "uuid" in the class ID List */
QArray<int> rfcommList( const OTUUID & uuid );
inline void setState( PeerState_t S)
{ State = S; }
inline PeerState_t state( void )
{ return State; }
// go and find out state
// will report back with signal
void findOutState( int timeoutInSec = 1, bool Force = 0 );
void stopFindingOutState( void );
// return driver to which this peer is connected to
// if it is connected
inline OTDriver * connectedTo( void ) const
{ return ConnectedTo; }
inline void setConnectedTo( OTDriver * D )
{ ConnectedTo = D; }
void save( QTextStream& TS );
void load( QTextStream& TS );
signals :
// report back state
void peerStateReport( OTPeer *);
void error( const QString & );
protected :
// while polling for result of ping
void timerEvent( QTimerEvent * ev );
private:
void updateServices();
OTGateway * OT;
OTDeviceAddress Addr;
QString Name;
int Class;
ServiceVector serviceList;
// -1 : don't know, 0 no, 1 yes
PeerState_t State;
OTDriver * ConnectedTo;
int ProbeFD;
int ProbePhase; // see OTDriver
long ProbeTimeout;
};
-}
+};
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h
index e79e33d..86b5623 100644
--- a/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h
+++ b/noncore/settings/networksettings2/opietooth2/OTSDPAttribute.h
@@ -1,140 +1,140 @@
//-*-c++-*-
/***************************************************************************
* Copyright (C) 2003 by Fred Schaettgen *
* kdebluetooth@schaettgen.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. *
***************************************************************************/
#ifndef OTATTRIBUTE_H
#define OTATTRIBUTE_H
#include <stdio.h>
#include <qstring.h>
#include <qarray.h>
#include <qvector.h>
#include <bluezlib.h>
#include <OTUUID.h>
namespace Opietooth2 {
class OTSDPAttribute;
class OTUUID;
typedef QVector<OTSDPAttribute> AttributeVector;
/**
@author Fred Schaettgen
*/
class OTSDPAttribute {
public:
enum AttrType {
INVALID = 0,
NIL = 1,
UINT = 2,
INT = 3,
UUID = 4,
BOOLEAN = 5,
STRING = 6,
SEQUENCE = 7,
ALTERNATIVE = 8,
URL = 9,
UNKNOWN = 10
};
class int128_t {
public :
int128_t(int64_t l=0, int64_t h=0) {
hi = h;
lo = l;
}
int128_t(const OTSDPAttribute::int128_t & l) {
hi = l.hi;
lo = l.lo;
}
QString toString() const {
char Buf[50];
sprintf( Buf, "%lld%lld", hi, lo );
return QString( Buf );
}
int64_t hi;
int64_t lo;
};
class uint128_t {
public :
uint128_t( uint64_t l=0, uint64_t h=0) {
hi = h;
lo = l;
}
uint128_t( const OTSDPAttribute::uint128_t & l) {
hi = l.hi;
lo = l.lo;
}
QString toString() const {
char Buf[50];
sprintf( Buf, "%llu%llu", hi, lo );
return QString( Buf );
}
uint64_t hi;
uint64_t lo;
};
public:
OTSDPAttribute();
OTSDPAttribute( sdp_data_t * D );
~OTSDPAttribute();
QString toString( void );
void setNil();
void setInt(const OTSDPAttribute::int128_t & val);
void setUInt(const OTSDPAttribute::uint128_t & val);
void setUUID( const OTUUID & val);
void setBool(bool val);
void setString(const QString & val);
void setURL(const QString & val);
void setSequence(const AttributeVector& val);
void setAlternative(const AttributeVector& val);
QString getString();
QString getURL();
const OTSDPAttribute::int128_t & getInt();
const OTSDPAttribute::uint128_t & getUInt();
const OTUUID & getUUID();
bool getBool();
AttributeVector * getSequence();
AttributeVector * getAlternative();
UUIDVector getAllUUIDs();
inline AttrType getType()
{ return type; }
//QString getValString();
const char * getTypeString();
private:
AttrType type;
union {
OTSDPAttribute::int128_t * intVal;
OTSDPAttribute::uint128_t * uintVal;
OTUUID * uuidVal;
bool boolVal;
QString * stringVal; // strings and urls
AttributeVector * sequenceVal; // sequences and alternatives
} Value;
};
-}
+};
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTSDPService.h b/noncore/settings/networksettings2/opietooth2/OTSDPService.h
index 4831df0..21d7344 100644
--- a/noncore/settings/networksettings2/opietooth2/OTSDPService.h
+++ b/noncore/settings/networksettings2/opietooth2/OTSDPService.h
@@ -1,75 +1,75 @@
//-*-c++-*-
/***************************************************************************
* Copyright (C) 2003 by Fred Schaettgen *
* kdebluetooth@schaettgen.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. *
***************************************************************************/
#ifndef SDPSERVICE_H
#define SDPSERVICE_H
#include <qvector.h>
#include <qarray.h>
#include <OTSDPAttribute.h>
namespace Opietooth2 {
/**
@author Fred Schaettgen
*/
class OTSDPService {
public:
OTSDPService();
virtual ~OTSDPService();
void addAttribute(int id, OTSDPAttribute * attr);
const OTSDPAttribute & attribute( int index );
int attributeID( int index );
AttributeVector subAttributes( OTSDPAttribute * attr);
OTSDPAttribute * attributeByID( int id );
// See Bluetooth Core Spec Sec. 5.1
bool recordHandle(uint32_t *handle); // 0x00
//bool getServiceClassIDList(vector<uuid_t> *classIDList); // 0x01
//bool getServiceRecordState(uint32_t *state); // 0x02
//bool getServiceID(uuid_t *id); // 0x03;
//bool getProtocolDescriptorList(SDP::Attribute *attribute); // 0x04
//bool getBrowseGroupList(vector<uuid_t> *browseGroupList); // 0x05
QString name(void); // langBase + 0x00
QString description(void); // langBase + 0x01
UUIDVector allUUIDs();
// return list of classes this service belongs to
UUIDVector classIDList();
/** Retrieves the Rfcomm channel.
This function is provided just for conveniance.
@param n The Rfcomm channel.
@ret true if an rfcomm channel was found, false otherwise. */
bool rfcommChannel(unsigned int &n);
bool hasClassID(const OTUUID & uuid);
private:
struct AttributeEntry {
int id;
OTSDPAttribute * attr;
};
QArray<AttributeEntry> attributeList;
};
-}
+};
#endif
diff --git a/noncore/settings/networksettings2/opietooth2/OTUUID.h b/noncore/settings/networksettings2/opietooth2/OTUUID.h
index aebd9b9..97df114 100644
--- a/noncore/settings/networksettings2/opietooth2/OTUUID.h
+++ b/noncore/settings/networksettings2/opietooth2/OTUUID.h
@@ -1,58 +1,58 @@
//-*-c++-*-
/***************************************************************************
* Copyright (C) 2003 by Fred Schaettgen *
* kdebluetooth@schaettgen.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. *
***************************************************************************/
#ifndef OTUUID_H
#define OTUUID_H
#include <qstring.h>
#include <qarray.h>
#include <bluezlib.h>
namespace Opietooth2 {
class OTUUID;
typedef QArray<OTUUID> UUIDVector;
class OTUUID {
public :
OTUUID( QString s );
OTUUID( uint64_t l=0, uint64_t h=0);
OTUUID( const OTUUID & O );
bool fromString(QString s);
void setUUID128(uint64_t hi, uint64_t lo);
void setUUID32(uint32_t v);
uint16_t toShort()
{ return ((hi>>32) & 0xffff); }
uint32_t toLong()
{ return ((hi>>32) & 0xffffffff); }
uint64_t toLongLong()
{ return hi; }
QString toString() const ;
operator QString() const;
operator ::uuid_t() const;
OTUUID & operator=( const OTUUID & other ) ;
bool operator<( const OTUUID & other ) const;
bool operator==(const OTUUID & uuid) const;
uint64_t hi;
uint64_t lo;
};
-}
+};
#endif
diff --git a/noncore/settings/networksettings2/usb/usbrun.cpp b/noncore/settings/networksettings2/usb/usbrun.cpp
index f8824e0..0a46642 100644
--- a/noncore/settings/networksettings2/usb/usbrun.cpp
+++ b/noncore/settings/networksettings2/usb/usbrun.cpp
@@ -1,112 +1,124 @@
#include <qfile.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#include <resources.h>
#include "usbrun.h"
State_t USBRun::detectState( void ) {
// unavailable : no card found
// available : card found and assigned to us or free
// up : card found and assigned to us and up
NodeCollection * NC = nodeCollection();
QString S = QString( "/tmp/profile-%1.up" ).arg(NC->number());
System & Sys = NSResources->system();
InterfaceInfo * Run;
QFile F( S );
Log(("Detecting for %s\n", NC->name().latin1() ));
if( F.open( IO_ReadOnly ) ) {
// could open file -> read interface and assign
QString X;
QTextStream TS(&F);
X = TS.readLine();
Log(("%s exists\n", S.latin1() ));
// find interface
if( handlesInterface( X ) ) {
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
if( X == Run->Name ) {
NC->assignInterface( Run );
return IsUp;
}
}
}
}
Log(("Assigned %p\n", NC->assignedInterface() ));
if( ( Run = NC->assignedInterface() ) ) {
// we already have an interface assigned -> still present ?
if( ! Run->IsUp ) {
// usb is still free -> keep assignment
return Available;
} // else interface is up but NOT us -> some other profile
}
// nothing (valid) assigned to us
NC->assignInterface( 0 );
// find possible interface
for( QDictIterator<InterfaceInfo> It(Sys.interfaces());
It.current();
++It ) {
Run = It.current();
Log(("%s %d %d=%d %d\n",
Run->Name.latin1(),
handlesInterface( Run->Name ),
Run->CardType, ARPHRD_ETHER,
! Run->IsUp ));
if( handlesInterface( Run->Name ) &&
Run->CardType == ARPHRD_ETHER &&
! Run->IsUp
) {
// proper type, and Not UP -> free
return Off;
}
}
return Unavailable;
}
-QString USBRun::setMyState( NodeCollection *, Action_t , bool ) {
+QString USBRun::setMyState( NodeCollection * NC, Action_t A, bool ) {
+
+ // nothing needs to be done to 'activate' or 'deactivate'
+ // a cable
+
+ // perhaps (later) we can figure out if the device is IN the
+ // cradle
+ if( A == Activate ) {
+ NC->setCurrentState( Available );
+ } else if ( A == Deactivate ) {
+ NC->setCurrentState( Unavailable );
+ }
+
return QString();
}
// get interface that is free or assigned to us
InterfaceInfo * USBRun::getInterface( void ) {
System & S = NSResources->system();
InterfaceInfo * best = 0, * Run;
QRegExp R( "usb[0-9abcdef]" );
for( QDictIterator<InterfaceInfo> It(S.interfaces());
It.current();
++It ) {
Run = It.current();
if( handlesInterface( Run->Name ) &&
Run->CardType == ARPHRD_ETHER
) {
// this is a USB card
if( Run->assignedConnection() == netNode()->connection() ) {
// assigned to us
return Run;
} else if( Run->assignedConnection() == 0 ) {
// free
best = Run;
}
}
}
return best; // can be 0
}
bool USBRun::handlesInterface( const QString & S ) {
return Pat.match( S ) >= 0;
}
bool USBRun::handlesInterface( InterfaceInfo * I ) {
return handlesInterface( I->Name );
}