summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/bluebase.cpp19
-rw-r--r--noncore/net/opietooth/manager/bluebase.h2
-rw-r--r--noncore/net/opietooth/manager/scandialog.cpp10
-rw-r--r--noncore/net/opietooth/manager/scandialog.h4
4 files changed, 23 insertions, 12 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp
index 71da82e..c993c7c 100644
--- a/noncore/net/opietooth/manager/bluebase.cpp
+++ b/noncore/net/opietooth/manager/bluebase.cpp
@@ -1,181 +1,192 @@
/*
* bluebase.cpp *
* ---------------------
*
* begin : Sun 10 17:20:00 CEST 2002
* copyright : (c) 2002 by Maximilian Reiß
* email : max.reiss@gmx.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 "bluebase.h"
#include "scandialog.h"
#include <qframe.h>
#include <qlabel.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include <qtabwidget.h>
#include <qscrollview.h>
#include <qvbox.h>
#include <qmessagebox.h>
#include <qapplication.h>
#include <qcheckbox.h>
#include <qlineedit.h>
+#include <qlistview.h>
#include <qpe/resource.h>
#include <qpe/config.h>
namespace OpieTooth {
- class RemoteDevices;
+
+ #include <remotedevice.h>
BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl )
: BluetoothBase( parent, name, fl ) {
QObject::connect( (QObject*) PushButton2, SIGNAL( clicked() ), this, SLOT(startScan()));
QObject::connect((QObject*)configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges()));
QPalette pal = this->palette();
QColor col = pal.color(QPalette::Active, QColorGroup::Background);
pal.setColor(QPalette::Active, QColorGroup::Button, col);
pal.setColor(QPalette::Inactive, QColorGroup::Button, col);
pal.setColor(QPalette::Normal, QColorGroup::Button, col);
pal.setColor(QPalette::Disabled, QColorGroup::Button, col);
this->setPalette(pal);
setCaption( tr( "Bluetooth Manager" ) );
readConfig();
initGui();
}
/**
* Reads all options from the config file
*/
void BlueBase::readConfig() {
Config cfg("bluetoothmanager");
cfg.setGroup("bluezsettings");
deviceName = cfg.readEntry("name", "No name"); // name the device should identify with
defaultPasskey = cfg.readEntryCrypt("passkey", ""); // <- hmm, look up how good the trolls did that, maybe too weak
useEncryption = cfg.readNumEntry("useEncryption", 1);
enableAuthentification = cfg.readNumEntry("enableAuthentification", 1);
enablePagescan = cfg.readNumEntry("enablePagescan",1);
enableInquiryscan = cfg.readNumEntry("enableInquiryscan", 1);
}
/**
* Writes all options to the config file
*/
void BlueBase::writeConfig() {
Config cfg("bluetoothmanager");
cfg.setGroup("bluezsettings");
cfg.writeEntry("name", deviceName);
cfg.writeEntryCrypt("passkey", defaultPasskey);
cfg.writeEntry("useEncryption", useEncryption);
cfg.writeEntry("enableAuthentification", enableAuthentification);
cfg.writeEntry("enablePagescan",enablePagescan);
cfg.writeEntry("enableInquiryscan", enableInquiryscan);
}
/**
* Set up the gui
*/
void BlueBase::initGui() {
StatusLabel->setText(getStatus()); // maybe move it to getStatus()
cryptCheckBox->setChecked(useEncryption);
authCheckBox->setChecked(enableAuthentification);
pagescanCheckBox->setChecked(enablePagescan);
inquiryscanCheckBox->setChecked(enableInquiryscan);
deviceNameLine->setText(deviceName);
passkeyLine->setText(defaultPasskey);
}
/**
* Get the status informations and returns it
* @return QString the status informations gathered
*/
QString BlueBase::getStatus(){
return ("manger.h need also a status method");
}
/**
* Read the current values from the gui and invoke writeConfig()
*/
void BlueBase::applyConfigChanges() {
deviceName = deviceNameLine->text();
defaultPasskey = passkeyLine->text();
useEncryption = cryptCheckBox->isChecked();
enableAuthentification = authCheckBox->isChecked();
enablePagescan = pagescanCheckBox->isChecked();
enableInquiryscan = inquiryscanCheckBox->isChecked();
writeConfig();
QMessageBox* box = new QMessageBox(this, "Test");
box->setText(tr("Changes applied"));
box->show();
// falls nötig hcid killhupen - die funktionalität adden
}
- void BlueBase::addSearchedDevices( QList<RemoteDevices> &newDevices ) {
+ void BlueBase::addSearchedDevices( QList<RemoteDevice> &newDevices ) {
+
+ QListViewItem * deviceItem;
+
+ QListIterator<RemoteDevice> it(newDevices);
+ for( ; it.current(); ++it ) {
+ RemoteDevice *dev = it.current();
+ deviceItem = new QListViewItem( ListView4, dev->name() );
+ deviceItem->setText(1, dev->mac() );
+ }
}
/**
* Open the "scan for devices" dialog
*/
void BlueBase::startScan() {
ScanDialog *scan = new ScanDialog( this, "", true);
- QObject::connect((QObject*)scan, SIGNAL( selectedDevices(QList<RemoteDevices>&) ),
- this, SLOT( addSearchedDevices(QList<RemoteDevices>& ) ));
+ QObject::connect((QObject*)scan, SIGNAL( selectedDevices(QList<RemoteDevice>&) ),
+ this, SLOT( addSearchedDevices(QList<RemoteDevice>& ) ));
scan->showMaximized();
}
/**
* Decontructor
*/
BlueBase::~BlueBase(){
}
}
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h
index 5364e51..c8ceed2 100644
--- a/noncore/net/opietooth/manager/bluebase.h
+++ b/noncore/net/opietooth/manager/bluebase.h
@@ -1,63 +1,63 @@
#ifndef BLUEBASE_H
#define BLUEBASE_H
#include <qvariant.h>
#include <qwidget.h>
#include <qscrollview.h>
#include <qsplitter.h>
#include <qlist.h>
#include "bluetoothbase.h"
#include <remotedevice.h>
class QVBox;
class QHBoxLayout;
class QGridLayout;
class QFrame;
class QLabel;
class QPushButton;
class QTabWidget;
class QCheckBox;
namespace OpieTooth {
class BlueBase : public BluetoothBase {
Q_OBJECT
public:
BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
~BlueBase();
protected:
private slots:
void startScan();
private:
void readConfig();
void writeConfig();
QString getStatus();
void initGui();
QString deviceName;
QString defaultPasskey;
int useEncryption;
int enableAuthentification;
int enablePagescan;
int enableInquiryscan;
private slots:
- void addSearchedDevices( QList<RemoteDevices> &newDevices );
+ void addSearchedDevices( QList<RemoteDevice> &newDevices );
void applyConfigChanges();
};
}
#endif
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp
index 8a7ea01..bd7d23c 100644
--- a/noncore/net/opietooth/manager/scandialog.cpp
+++ b/noncore/net/opietooth/manager/scandialog.cpp
@@ -1,169 +1,169 @@
/* main.cpp
*
* ---------------------
*
* copyright : (c) 2002 by Maximilian Reiß
* email : max.reiss@gmx.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 "scandialog.h"
#include <qframe.h>
#include <qheader.h>
#include <qlabel.h>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qprogressbar.h>
#include <qlist.h>
#include <manager.h>
#include <device.h>
namespace OpieTooth {
#include <remotedevice.h>
/*
*/
ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl ) {
if ( !name )
setName( "ScanDialog" );
resize( 240, 320 );
setCaption( tr( "Scan for devices" ) );
Frame7 = new QFrame( this, "Frame7" );
Frame7->setGeometry( QRect( 0, 0, 240, 331 ) );
Frame7->setFrameShape( QFrame::StyledPanel );
Frame7->setFrameShadow( QFrame::Raised );
QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" );
privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) );
Layout11 = new QVBoxLayout( privateLayoutWidget );
Layout11->setSpacing( 6 );
Layout11->setMargin( 0 );
progress = new QProgressBar(privateLayoutWidget, "progbar");
progress->setTotalSteps(20);
QFrame *buttonFrame = new QFrame(Frame7, "");
StartButton = new QPushButton( buttonFrame, "StartButton" );
StartButton->setText( tr( "Start scan" ) );
StopButton = new QPushButton( buttonFrame, "StopButton" );
StopButton->setText( tr( "Cancel scan" ) );
QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame);
buttonLayout->addWidget(StartButton);
buttonLayout->addWidget(StopButton);
ListView1 = new QListView( privateLayoutWidget, "ListView1" );
//ListView1->addColumn( tr( "Add" ) );
ListView1->addColumn( tr( "Add Device" ) );
//ListView1->addColumn( tr( "Type" ) );
Layout11->addWidget( ListView1);
Layout11->addWidget(progress);
Layout11->addWidget( buttonFrame);
localDevice = new Manager( "hci0" );
connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) );
connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) );
connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ),
this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ;
progressStat = 0;
}
// hack, make cleaner later
void ScanDialog::progressTimer() {
progressStat++;
if (progressStat++ < 20) {
QTimer::singleShot( 1000, this, SLOT(progressTimer() ) );
}
progress->setProgress(progressStat++);
}
void ScanDialog::startSearch() {
progress->setProgress(0);
progressStat = 0;
QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox );
deviceItem2->setText(1, "BLAH" );
progressTimer();
// when finished, it emmite foundDevices()
// checken ob initialisiert , qcop ans applet.
localDevice->searchDevices();
}
void ScanDialog::stopSearch() {
}
- void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) {
+ void ScanDialog::fillList(const QString& device, RemoteDevice::ValueList deviceList) {
QCheckListItem * deviceItem;
- RemoteDevices::ValueList::Iterator it;
+ RemoteDevice::ValueList::Iterator it;
for( it = deviceList.begin(); it != deviceList.end(); ++it ) {
deviceItem = new QCheckListItem( ListView1, (*it).name() );
deviceItem->setText(1, (*it).mac() );
}
}
/*
* Iterates trough the items, and collects the checked items.
* Then it emits it, so the manager can connect to the signal to fill the listing.
*/
void ScanDialog::emitToManager() {
if (!ListView1) {
return;
}
- QList<RemoteDevices> *deviceList = new QList<RemoteDevices>;
+ QList<RemoteDevice> *deviceList = new QList<RemoteDevice>;
QListViewItemIterator it( ListView1 );
for ( ; it.current(); ++it ) {
if ( ((QCheckListItem*)it.current())->isOn() ) {
- RemoteDevices* device = new RemoteDevices( it.current()->text(1), it.current()->text(0));
- deviceList->append( device );
+ RemoteDevice * device = new RemoteDevice( it.current()->text(1), it.current()->text(0));
+ deviceList->append( device );
}
}
emit selectedDevices( *deviceList );
}
/*
* Cleanup
*/
ScanDialog::~ScanDialog() {
emitToManager();
delete localDevice;
}
}
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h
index 0ca302a..adc960c 100644
--- a/noncore/net/opietooth/manager/scandialog.h
+++ b/noncore/net/opietooth/manager/scandialog.h
@@ -1,77 +1,77 @@
/* main.cpp
*
* copyright : (c) 2002 by Maximilian Reiß
* email : max.reiss@gmx.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 SCANDIALOG_H
#define SCANDIALOG_H
#include <qvariant.h>
#include <qdialog.h>
#include <qlist.h>
#include <remotedevice.h>
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QFrame;
class QLabel;
class QListView;
class QListViewItem;
class QPushButton;
class QProgressBar;
namespace OpieTooth {
class Manager;
class Device;
class ScanDialog : public QDialog {
Q_OBJECT
public:
ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~ScanDialog();
QFrame* Frame7;
QProgressBar* progress;
QPushButton* StartButton;
QPushButton* StopButton;
QListView* ListView1;
protected:
QVBoxLayout* Layout11;
private slots:
void stopSearch();
void startSearch();
void progressTimer();
- void fillList(const QString& device, RemoteDevices::ValueList list);
+ void fillList(const QString& device, RemoteDevice::ValueList list);
private:
void emitToManager();
Manager *localDevice;
int progressStat;
signals:
- void selectedDevices(QList<RemoteDevices>&);
+ void selectedDevices(QList<RemoteDevice>&);
};
}
#endif // SCANDIALOG_H