-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 14 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 5 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 46 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.h | 10 |
4 files changed, 64 insertions, 11 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index e3b9e53..71da82e 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -1,167 +1,181 @@ | |||
1 | /* | 1 | /* |
2 | * bluebase.cpp * | 2 | * bluebase.cpp * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * begin : Sun 10 17:20:00 CEST 2002 | 5 | * begin : Sun 10 17:20:00 CEST 2002 |
6 | * copyright : (c) 2002 by Maximilian Reiß | 6 | * copyright : (c) 2002 by Maximilian Reiß |
7 | * email : max.reiss@gmx.de | 7 | * email : max.reiss@gmx.de |
8 | * | 8 | * |
9 | */ | 9 | */ |
10 | /*************************************************************************** | 10 | /*************************************************************************** |
11 | * * | 11 | * * |
12 | * This program is free software; you can redistribute it and/or modify * | 12 | * This program is free software; you can redistribute it and/or modify * |
13 | * it under the terms of the GNU General Public License as published by * | 13 | * it under the terms of the GNU General Public License as published by * |
14 | * the Free Software Foundation; either version 2 of the License, or * | 14 | * the Free Software Foundation; either version 2 of the License, or * |
15 | * (at your option) any later version. * | 15 | * (at your option) any later version. * |
16 | * * | 16 | * * |
17 | ***************************************************************************/ | 17 | ***************************************************************************/ |
18 | 18 | ||
19 | #include "bluebase.h" | 19 | #include "bluebase.h" |
20 | #include "scandialog.h" | 20 | #include "scandialog.h" |
21 | 21 | ||
22 | #include <qframe.h> | 22 | #include <qframe.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qpushbutton.h> | 24 | #include <qpushbutton.h> |
25 | #include <qlayout.h> | 25 | #include <qlayout.h> |
26 | #include <qvariant.h> | 26 | #include <qvariant.h> |
27 | #include <qwhatsthis.h> | 27 | #include <qwhatsthis.h> |
28 | #include <qimage.h> | 28 | #include <qimage.h> |
29 | #include <qpixmap.h> | 29 | #include <qpixmap.h> |
30 | #include <qtabwidget.h> | 30 | #include <qtabwidget.h> |
31 | #include <qscrollview.h> | 31 | #include <qscrollview.h> |
32 | #include <qvbox.h> | 32 | #include <qvbox.h> |
33 | #include <qmessagebox.h> | 33 | #include <qmessagebox.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qcheckbox.h> | 35 | #include <qcheckbox.h> |
36 | #include <qlineedit.h> | 36 | #include <qlineedit.h> |
37 | 37 | ||
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | 40 | ||
41 | 41 | ||
42 | namespace OpieTooth { | 42 | namespace OpieTooth { |
43 | 43 | ||
44 | class RemoteDevices; | ||
44 | 45 | ||
45 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 46 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
46 | : BluetoothBase( parent, name, fl ) { | 47 | : BluetoothBase( parent, name, fl ) { |
47 | 48 | ||
48 | 49 | ||
49 | QObject::connect( (QObject*) PushButton2, SIGNAL( clicked() ), this, SLOT(startScan())); | 50 | QObject::connect( (QObject*) PushButton2, SIGNAL( clicked() ), this, SLOT(startScan())); |
50 | QObject::connect((QObject*)configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges())); | 51 | QObject::connect((QObject*)configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges())); |
51 | 52 | ||
53 | |||
54 | |||
55 | |||
52 | QPalette pal = this->palette(); | 56 | QPalette pal = this->palette(); |
53 | QColor col = pal.color(QPalette::Active, QColorGroup::Background); | 57 | QColor col = pal.color(QPalette::Active, QColorGroup::Background); |
54 | pal.setColor(QPalette::Active, QColorGroup::Button, col); | 58 | pal.setColor(QPalette::Active, QColorGroup::Button, col); |
55 | pal.setColor(QPalette::Inactive, QColorGroup::Button, col); | 59 | pal.setColor(QPalette::Inactive, QColorGroup::Button, col); |
56 | pal.setColor(QPalette::Normal, QColorGroup::Button, col); | 60 | pal.setColor(QPalette::Normal, QColorGroup::Button, col); |
57 | pal.setColor(QPalette::Disabled, QColorGroup::Button, col); | 61 | pal.setColor(QPalette::Disabled, QColorGroup::Button, col); |
58 | this->setPalette(pal); | 62 | this->setPalette(pal); |
59 | 63 | ||
60 | setCaption( tr( "Bluetooth Manager" ) ); | 64 | setCaption( tr( "Bluetooth Manager" ) ); |
61 | 65 | ||
62 | readConfig(); | 66 | readConfig(); |
63 | initGui(); | 67 | initGui(); |
64 | } | 68 | } |
65 | 69 | ||
66 | /** | 70 | /** |
67 | * Reads all options from the config file | 71 | * Reads all options from the config file |
68 | */ | 72 | */ |
69 | void BlueBase::readConfig() { | 73 | void BlueBase::readConfig() { |
70 | 74 | ||
71 | Config cfg("bluetoothmanager"); | 75 | Config cfg("bluetoothmanager"); |
72 | cfg.setGroup("bluezsettings"); | 76 | cfg.setGroup("bluezsettings"); |
73 | 77 | ||
74 | 78 | ||
75 | deviceName = cfg.readEntry("name", "No name"); // name the device should identify with | 79 | deviceName = cfg.readEntry("name", "No name"); // name the device should identify with |
76 | defaultPasskey = cfg.readEntryCrypt("passkey", ""); // <- hmm, look up how good the trolls did that, maybe too weak | 80 | defaultPasskey = cfg.readEntryCrypt("passkey", ""); // <- hmm, look up how good the trolls did that, maybe too weak |
77 | useEncryption = cfg.readNumEntry("useEncryption", 1); | 81 | useEncryption = cfg.readNumEntry("useEncryption", 1); |
78 | enableAuthentification = cfg.readNumEntry("enableAuthentification", 1); | 82 | enableAuthentification = cfg.readNumEntry("enableAuthentification", 1); |
79 | enablePagescan = cfg.readNumEntry("enablePagescan",1); | 83 | enablePagescan = cfg.readNumEntry("enablePagescan",1); |
80 | enableInquiryscan = cfg.readNumEntry("enableInquiryscan", 1); | 84 | enableInquiryscan = cfg.readNumEntry("enableInquiryscan", 1); |
81 | 85 | ||
82 | } | 86 | } |
83 | 87 | ||
84 | /** | 88 | /** |
85 | * Writes all options to the config file | 89 | * Writes all options to the config file |
86 | */ | 90 | */ |
87 | void BlueBase::writeConfig() { | 91 | void BlueBase::writeConfig() { |
88 | 92 | ||
89 | 93 | ||
90 | Config cfg("bluetoothmanager"); | 94 | Config cfg("bluetoothmanager"); |
91 | cfg.setGroup("bluezsettings"); | 95 | cfg.setGroup("bluezsettings"); |
92 | 96 | ||
93 | 97 | ||
94 | cfg.writeEntry("name", deviceName); | 98 | cfg.writeEntry("name", deviceName); |
95 | cfg.writeEntryCrypt("passkey", defaultPasskey); | 99 | cfg.writeEntryCrypt("passkey", defaultPasskey); |
96 | cfg.writeEntry("useEncryption", useEncryption); | 100 | cfg.writeEntry("useEncryption", useEncryption); |
97 | cfg.writeEntry("enableAuthentification", enableAuthentification); | 101 | cfg.writeEntry("enableAuthentification", enableAuthentification); |
98 | cfg.writeEntry("enablePagescan",enablePagescan); | 102 | cfg.writeEntry("enablePagescan",enablePagescan); |
99 | cfg.writeEntry("enableInquiryscan", enableInquiryscan); | 103 | cfg.writeEntry("enableInquiryscan", enableInquiryscan); |
100 | } | 104 | } |
101 | 105 | ||
102 | 106 | ||
103 | /** | 107 | /** |
104 | * Set up the gui | 108 | * Set up the gui |
105 | */ | 109 | */ |
106 | void BlueBase::initGui() { | 110 | void BlueBase::initGui() { |
107 | 111 | ||
108 | StatusLabel->setText(getStatus()); // maybe move it to getStatus() | 112 | StatusLabel->setText(getStatus()); // maybe move it to getStatus() |
109 | 113 | ||
110 | cryptCheckBox->setChecked(useEncryption); | 114 | cryptCheckBox->setChecked(useEncryption); |
111 | authCheckBox->setChecked(enableAuthentification); | 115 | authCheckBox->setChecked(enableAuthentification); |
112 | pagescanCheckBox->setChecked(enablePagescan); | 116 | pagescanCheckBox->setChecked(enablePagescan); |
113 | inquiryscanCheckBox->setChecked(enableInquiryscan); | 117 | inquiryscanCheckBox->setChecked(enableInquiryscan); |
114 | deviceNameLine->setText(deviceName); | 118 | deviceNameLine->setText(deviceName); |
115 | passkeyLine->setText(defaultPasskey); | 119 | passkeyLine->setText(defaultPasskey); |
116 | } | 120 | } |
117 | 121 | ||
118 | 122 | ||
119 | /** | 123 | /** |
120 | * Get the status informations and returns it | 124 | * Get the status informations and returns it |
121 | * @return QString the status informations gathered | 125 | * @return QString the status informations gathered |
122 | */ | 126 | */ |
123 | QString BlueBase::getStatus(){ | 127 | QString BlueBase::getStatus(){ |
124 | 128 | ||
125 | return ("manger.h need also a status method"); | 129 | return ("manger.h need also a status method"); |
126 | 130 | ||
127 | } | 131 | } |
128 | 132 | ||
129 | 133 | ||
130 | /** | 134 | /** |
131 | * Read the current values from the gui and invoke writeConfig() | 135 | * Read the current values from the gui and invoke writeConfig() |
132 | */ | 136 | */ |
133 | void BlueBase::applyConfigChanges() { | 137 | void BlueBase::applyConfigChanges() { |
134 | 138 | ||
135 | deviceName = deviceNameLine->text(); | 139 | deviceName = deviceNameLine->text(); |
136 | defaultPasskey = passkeyLine->text(); | 140 | defaultPasskey = passkeyLine->text(); |
137 | useEncryption = cryptCheckBox->isChecked(); | 141 | useEncryption = cryptCheckBox->isChecked(); |
138 | enableAuthentification = authCheckBox->isChecked(); | 142 | enableAuthentification = authCheckBox->isChecked(); |
139 | enablePagescan = pagescanCheckBox->isChecked(); | 143 | enablePagescan = pagescanCheckBox->isChecked(); |
140 | enableInquiryscan = inquiryscanCheckBox->isChecked(); | 144 | enableInquiryscan = inquiryscanCheckBox->isChecked(); |
141 | 145 | ||
142 | writeConfig(); | 146 | writeConfig(); |
143 | 147 | ||
144 | QMessageBox* box = new QMessageBox(this, "Test"); | 148 | QMessageBox* box = new QMessageBox(this, "Test"); |
145 | box->setText(tr("Changes applied")); | 149 | box->setText(tr("Changes applied")); |
146 | box->show(); | 150 | box->show(); |
147 | 151 | ||
148 | // falls nötig hcid killhupen - die funktionalität adden | 152 | // falls nötig hcid killhupen - die funktionalität adden |
149 | } | 153 | } |
150 | 154 | ||
151 | 155 | ||
156 | void BlueBase::addSearchedDevices( QList<RemoteDevices> &newDevices ) { | ||
157 | |||
158 | |||
159 | |||
160 | } | ||
161 | |||
162 | |||
152 | /** | 163 | /** |
153 | * Open the "scan for devices" dialog | 164 | * Open the "scan for devices" dialog |
154 | */ | 165 | */ |
155 | void BlueBase::startScan() { | 166 | void BlueBase::startScan() { |
156 | ScanDialog *scan = new ScanDialog( this, "", true); | 167 | ScanDialog *scan = new ScanDialog( this, "", true); |
168 | QObject::connect((QObject*)scan, SIGNAL( selectedDevices(QList<RemoteDevices>&) ), | ||
169 | this, SLOT( addSearchedDevices(QList<RemoteDevices>& ) )); | ||
170 | |||
157 | scan->showMaximized(); | 171 | scan->showMaximized(); |
158 | } | 172 | } |
159 | 173 | ||
160 | /** | 174 | /** |
161 | * Decontructor | 175 | * Decontructor |
162 | */ | 176 | */ |
163 | BlueBase::~BlueBase(){ | 177 | BlueBase::~BlueBase(){ |
164 | } | 178 | } |
165 | 179 | ||
166 | } | 180 | } |
167 | 181 | ||
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 023af7a..ae5ce67 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -1,58 +1,61 @@ | |||
1 | 1 | ||
2 | #ifndef BLUEBASE_H | 2 | #ifndef BLUEBASE_H |
3 | #define BLUEBASE_H | 3 | #define BLUEBASE_H |
4 | 4 | ||
5 | #include <qvariant.h> | 5 | #include <qvariant.h> |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qscrollview.h> | 7 | #include <qscrollview.h> |
8 | #include <qsplitter.h> | 8 | #include <qsplitter.h> |
9 | #include <qlist.h> | ||
9 | 10 | ||
10 | #include "bluetoothbase.h" | 11 | #include "bluetoothbase.h" |
11 | 12 | ||
12 | class QVBox; | 13 | class QVBox; |
13 | class QHBoxLayout; | 14 | class QHBoxLayout; |
14 | class QGridLayout; | 15 | class QGridLayout; |
15 | class QFrame; | 16 | class QFrame; |
16 | class QLabel; | 17 | class QLabel; |
17 | class QPushButton; | 18 | class QPushButton; |
18 | class QTabWidget; | 19 | class QTabWidget; |
19 | class QCheckBox; | 20 | class QCheckBox; |
20 | 21 | ||
21 | namespace OpieTooth { | 22 | namespace OpieTooth { |
22 | 23 | ||
24 | |||
25 | |||
23 | class BlueBase : public BluetoothBase { | 26 | class BlueBase : public BluetoothBase { |
24 | Q_OBJECT | 27 | Q_OBJECT |
25 | 28 | ||
26 | public: | 29 | public: |
27 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 30 | BlueBase( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
28 | ~BlueBase(); | 31 | ~BlueBase(); |
29 | 32 | ||
30 | protected: | 33 | protected: |
31 | 34 | ||
32 | 35 | ||
33 | private slots: | 36 | private slots: |
34 | void startScan(); | 37 | void startScan(); |
35 | 38 | ||
36 | private: | 39 | private: |
37 | void readConfig(); | 40 | void readConfig(); |
38 | void writeConfig(); | 41 | void writeConfig(); |
39 | QString getStatus(); | 42 | QString getStatus(); |
40 | void initGui(); | 43 | void initGui(); |
41 | 44 | ||
42 | 45 | ||
43 | QString deviceName; | 46 | QString deviceName; |
44 | QString defaultPasskey; | 47 | QString defaultPasskey; |
45 | int useEncryption; | 48 | int useEncryption; |
46 | int enableAuthentification; | 49 | int enableAuthentification; |
47 | int enablePagescan; | 50 | int enablePagescan; |
48 | int enableInquiryscan; | 51 | int enableInquiryscan; |
49 | 52 | ||
50 | private slots: | 53 | private slots: |
51 | 54 | void addSearchedDevices( QList<RemoteDevices> &newDevices ); | |
52 | void applyConfigChanges(); | 55 | void applyConfigChanges(); |
53 | 56 | ||
54 | }; | 57 | }; |
55 | 58 | ||
56 | } | 59 | } |
57 | 60 | ||
58 | #endif | 61 | #endif |
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index 63c5472..70ea77a 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -1,138 +1,170 @@ | |||
1 | /* main.cpp | 1 | /* main.cpp |
2 | * | 2 | * |
3 | * --------------------- | 3 | * --------------------- |
4 | * | 4 | * |
5 | * copyright : (c) 2002 by Maximilian Reiß | 5 | * copyright : (c) 2002 by Maximilian Reiß |
6 | * email : max.reiss@gmx.de | 6 | * email : max.reiss@gmx.de |
7 | * | 7 | * |
8 | */ | 8 | */ |
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | 18 | ||
19 | #include "scandialog.h" | 19 | #include "scandialog.h" |
20 | 20 | ||
21 | #include <qframe.h> | 21 | #include <qframe.h> |
22 | #include <qheader.h> | 22 | #include <qheader.h> |
23 | #include <qlabel.h> | 23 | #include <qlabel.h> |
24 | #include <qlistview.h> | 24 | #include <qlistview.h> |
25 | #include <qpushbutton.h> | 25 | #include <qpushbutton.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvariant.h> | 27 | #include <qvariant.h> |
28 | #include <qtooltip.h> | 28 | #include <qtooltip.h> |
29 | #include <qwhatsthis.h> | 29 | #include <qwhatsthis.h> |
30 | #include <qprogressbar.h> | 30 | #include <qprogressbar.h> |
31 | #include <qlist.h> | ||
31 | 32 | ||
32 | #include <manager.h> | 33 | #include <manager.h> |
33 | #include <device.h> | 34 | #include <device.h> |
34 | #include <remotedevice.h> | 35 | |
35 | 36 | ||
36 | 37 | ||
37 | namespace OpieTooth { | 38 | namespace OpieTooth { |
38 | 39 | ||
40 | #include <remotedevice.h> | ||
41 | |||
39 | /* | 42 | /* |
40 | */ | 43 | */ |
41 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 44 | ScanDialog::ScanDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
42 | : QDialog( parent, name, modal, fl ) { | 45 | : QDialog( parent, name, modal, fl ) { |
43 | 46 | ||
44 | if ( !name ) | 47 | if ( !name ) |
45 | setName( "ScanDialog" ); | 48 | setName( "ScanDialog" ); |
46 | resize( 240, 320 ); | 49 | resize( 240, 320 ); |
47 | setCaption( tr( "Scan for devices" ) ); | 50 | setCaption( tr( "Scan for devices" ) ); |
48 | 51 | ||
49 | Frame7 = new QFrame( this, "Frame7" ); | 52 | Frame7 = new QFrame( this, "Frame7" ); |
50 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); | 53 | Frame7->setGeometry( QRect( 0, 0, 240, 331 ) ); |
51 | Frame7->setFrameShape( QFrame::StyledPanel ); | 54 | Frame7->setFrameShape( QFrame::StyledPanel ); |
52 | Frame7->setFrameShadow( QFrame::Raised ); | 55 | Frame7->setFrameShadow( QFrame::Raised ); |
53 | 56 | ||
54 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); | 57 | QWidget* privateLayoutWidget = new QWidget( Frame7, "Layout11" ); |
55 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); | 58 | privateLayoutWidget->setGeometry( QRect( 10, 9, 221, 280 ) ); |
56 | Layout11 = new QVBoxLayout( privateLayoutWidget ); | 59 | Layout11 = new QVBoxLayout( privateLayoutWidget ); |
57 | Layout11->setSpacing( 6 ); | 60 | Layout11->setSpacing( 6 ); |
58 | Layout11->setMargin( 0 ); | 61 | Layout11->setMargin( 0 ); |
59 | 62 | ||
60 | progress = new QProgressBar(privateLayoutWidget, "progbar"); | 63 | progress = new QProgressBar(privateLayoutWidget, "progbar"); |
61 | progress->setTotalSteps(20); | 64 | progress->setTotalSteps(20); |
62 | 65 | ||
63 | QFrame *buttonFrame = new QFrame(Frame7, ""); | 66 | QFrame *buttonFrame = new QFrame(Frame7, ""); |
64 | 67 | ||
65 | StartButton = new QPushButton( buttonFrame, "StartButton" ); | 68 | StartButton = new QPushButton( buttonFrame, "StartButton" ); |
66 | StartButton->setText( tr( "Start" ) ); | 69 | StartButton->setText( tr( "Start scan" ) ); |
67 | 70 | ||
68 | StopButton = new QPushButton( buttonFrame, "StopButton" ); | 71 | StopButton = new QPushButton( buttonFrame, "StopButton" ); |
69 | StopButton->setText( tr( "Cancel" ) ); | 72 | StopButton->setText( tr( "Cancel scan" ) ); |
70 | 73 | ||
71 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); | 74 | QHBoxLayout *buttonLayout = new QHBoxLayout(buttonFrame); |
75 | |||
72 | buttonLayout->addWidget(StartButton); | 76 | buttonLayout->addWidget(StartButton); |
73 | buttonLayout->addWidget(StopButton); | 77 | buttonLayout->addWidget(StopButton); |
74 | 78 | ||
75 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); | 79 | ListView1 = new QListView( privateLayoutWidget, "ListView1" ); |
76 | 80 | ||
77 | ListView1->addColumn( tr( "Add" ) ); | 81 | //ListView1->addColumn( tr( "Add" ) ); |
78 | ListView1->addColumn( tr( "Device Name" ) ); | 82 | ListView1->addColumn( tr( "Add Device" ) ); |
79 | //ListView1->addColumn( tr( "Type" ) ); | 83 | //ListView1->addColumn( tr( "Type" ) ); |
80 | 84 | ||
81 | Layout11->addWidget( ListView1); | 85 | Layout11->addWidget( ListView1); |
82 | Layout11->addWidget(progress); | 86 | Layout11->addWidget(progress); |
83 | Layout11->addWidget( buttonFrame); | 87 | Layout11->addWidget( buttonFrame); |
84 | 88 | ||
85 | localDevice = new Manager( "hci0" ); | 89 | localDevice = new Manager( "hci0" ); |
86 | 90 | ||
87 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); | 91 | connect( (QObject*)StartButton, SIGNAL( clicked() ), this, SLOT( startSearch() ) ); |
88 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); | 92 | connect( (QObject*)StopButton, SIGNAL( clicked() ), this, SLOT( stopSearch() ) ); |
89 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), | 93 | connect( (QObject*)localDevice, SIGNAL( foundDevices( const QString& , RemoteDevices::ValueList ) ), |
90 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; | 94 | this, SLOT(fillList(const QString& , RemoteDevices::ValueList ) ) ) ; |
91 | progressStat = 0; | 95 | progressStat = 0; |
92 | } | 96 | } |
93 | 97 | ||
94 | // hack, make cleaner later | 98 | // hack, make cleaner later |
95 | void ScanDialog::progressTimer() { | 99 | void ScanDialog::progressTimer() { |
96 | 100 | ||
97 | progressStat++; | 101 | progressStat++; |
98 | if (progressStat++ < 20) { | 102 | if (progressStat++ < 20) { |
99 | QTimer::singleShot( 1000, this, SLOT(progressTimer() ) ); | 103 | QTimer::singleShot( 1000, this, SLOT(progressTimer() ) ); |
100 | } | 104 | } |
101 | progress->setProgress(progressStat++); | 105 | progress->setProgress(progressStat++); |
102 | 106 | ||
103 | } | 107 | } |
104 | 108 | ||
105 | void ScanDialog::startSearch() { | 109 | void ScanDialog::startSearch() { |
106 | progress->setProgress(0); | 110 | progress->setProgress(0); |
107 | progressStat = 0; | 111 | progressStat = 0; |
108 | 112 | ||
113 | QCheckListItem *deviceItem2 = new QCheckListItem( ListView1, "Test1", QCheckListItem::CheckBox ); | ||
114 | deviceItem2->setText(1, "BLAH" ); | ||
115 | |||
109 | progressTimer(); | 116 | progressTimer(); |
110 | // when finished, it emmite foundDevices() | 117 | // when finished, it emmite foundDevices() |
111 | // checken ob initialisiert , qcop ans applet. | 118 | // checken ob initialisiert , qcop ans applet. |
112 | localDevice->searchDevices(); | 119 | localDevice->searchDevices(); |
113 | 120 | ||
114 | } | 121 | } |
115 | 122 | ||
116 | void ScanDialog::stopSearch() { | 123 | void ScanDialog::stopSearch() { |
117 | 124 | ||
118 | } | 125 | } |
119 | 126 | ||
120 | void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { | 127 | void ScanDialog::fillList(const QString& device, RemoteDevices::ValueList deviceList) { |
121 | 128 | ||
122 | QListViewItem * deviceItem; | 129 | QCheckListItem * deviceItem; |
123 | 130 | ||
124 | RemoteDevices::ValueList::Iterator it; | 131 | RemoteDevices::ValueList::Iterator it; |
125 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 132 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
126 | 133 | ||
127 | deviceItem = new QListViewItem( ListView1, (*it).name() ); | 134 | deviceItem = new QCheckListItem( ListView1, (*it).name() ); |
135 | deviceItem->setText(1, (*it).mac() ); | ||
136 | } | ||
137 | |||
138 | } | ||
139 | |||
140 | /* | ||
141 | * Iterates trough the items, and collects the checked items. | ||
142 | * Then it emits it, so the manager can connect to the signal to fill the listing. | ||
143 | */ | ||
144 | void ScanDialog::emitToManager() { | ||
145 | |||
146 | if (!ListView1) { | ||
147 | return; | ||
148 | } | ||
149 | |||
150 | QList<RemoteDevices> *deviceList = new QList<RemoteDevices>; | ||
151 | |||
152 | QListViewItemIterator it( ListView1 ); | ||
153 | for ( ; it.current(); ++it ) { | ||
154 | if ( it.current()->isSelected() ) { | ||
155 | RemoteDevices* device = new RemoteDevices( it.current()->text(1), it.current()->text(0)); | ||
156 | deviceList->append( device ); | ||
157 | } | ||
128 | } | 158 | } |
159 | emit selectedDevices( *deviceList ); | ||
129 | } | 160 | } |
130 | 161 | ||
131 | /* | 162 | /* |
132 | * Cleanup | 163 | * Cleanup |
133 | */ | 164 | */ |
134 | ScanDialog::~ScanDialog() { | 165 | ScanDialog::~ScanDialog() { |
166 | emitToManager(); | ||
135 | delete localDevice; | 167 | delete localDevice; |
136 | } | 168 | } |
137 | 169 | ||
138 | } | 170 | } |
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h index fcaee6e..4785a62 100644 --- a/noncore/net/opietooth/manager/scandialog.h +++ b/noncore/net/opietooth/manager/scandialog.h | |||
@@ -1,73 +1,77 @@ | |||
1 | /* main.cpp | 1 | /* main.cpp |
2 | * | 2 | * |
3 | * copyright : (c) 2002 by Maximilian Reiß | 3 | * copyright : (c) 2002 by Maximilian Reiß |
4 | * email : max.reiss@gmx.de | 4 | * email : max.reiss@gmx.de |
5 | * | 5 | * |
6 | */ | 6 | */ |
7 | /*************************************************************************** | 7 | /*************************************************************************** |
8 | * * | 8 | * * |
9 | * This program is free software; you can redistribute it and/or modify * | 9 | * This program is free software; you can redistribute it and/or modify * |
10 | * it under the terms of the GNU General Public License as published by * | 10 | * it under the terms of the GNU General Public License as published by * |
11 | * the Free Software Foundation; either version 2 of the License, or * | 11 | * the Free Software Foundation; either version 2 of the License, or * |
12 | * (at your option) any later version. * | 12 | * (at your option) any later version. * |
13 | * * | 13 | * * |
14 | ***************************************************************************/ | 14 | ***************************************************************************/ |
15 | 15 | ||
16 | 16 | ||
17 | #ifndef SCANDIALOG_H | 17 | #ifndef SCANDIALOG_H |
18 | #define SCANDIALOG_H | 18 | #define SCANDIALOG_H |
19 | 19 | ||
20 | #include <qvariant.h> | 20 | #include <qvariant.h> |
21 | #include <qdialog.h> | 21 | #include <qdialog.h> |
22 | #include <qlist.h> | ||
22 | 23 | ||
23 | 24 | ||
24 | #include <remotedevice.h> | ||
25 | |||
26 | class QVBoxLayout; | 25 | class QVBoxLayout; |
27 | class QHBoxLayout; | 26 | class QHBoxLayout; |
28 | class QGridLayout; | 27 | class QGridLayout; |
29 | class QFrame; | 28 | class QFrame; |
30 | class QLabel; | 29 | class QLabel; |
31 | class QListView; | 30 | class QListView; |
32 | class QListViewItem; | 31 | class QListViewItem; |
33 | class QPushButton; | 32 | class QPushButton; |
34 | class QProgressBar; | 33 | class QProgressBar; |
35 | 34 | ||
36 | 35 | ||
37 | namespace OpieTooth { | 36 | namespace OpieTooth { |
38 | 37 | ||
39 | 38 | #include <remotedevices.h> | |
40 | class Manager; | 39 | class Manager; |
41 | class Device; | 40 | class Device; |
42 | 41 | ||
43 | class ScanDialog : public QDialog { | 42 | class ScanDialog : public QDialog { |
44 | Q_OBJECT | 43 | Q_OBJECT |
45 | 44 | ||
46 | public: | 45 | public: |
47 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 46 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
48 | ~ScanDialog(); | 47 | ~ScanDialog(); |
49 | 48 | ||
50 | QFrame* Frame7; | 49 | QFrame* Frame7; |
51 | QProgressBar* progress; | 50 | QProgressBar* progress; |
52 | QPushButton* StartButton; | 51 | QPushButton* StartButton; |
53 | QPushButton* StopButton; | 52 | QPushButton* StopButton; |
54 | QListView* ListView1; | 53 | QListView* ListView1; |
55 | 54 | ||
56 | 55 | ||
57 | protected: | 56 | protected: |
58 | QVBoxLayout* Layout11; | 57 | QVBoxLayout* Layout11; |
59 | 58 | ||
60 | private slots: | 59 | private slots: |
61 | void stopSearch(); | 60 | void stopSearch(); |
62 | void startSearch(); | 61 | void startSearch(); |
63 | void progressTimer(); | 62 | void progressTimer(); |
64 | void fillList(const QString& device, RemoteDevices::ValueList list); | 63 | void fillList(const QString& device, RemoteDevices::ValueList list); |
65 | 64 | ||
66 | private: | 65 | private: |
66 | void emitToManager(); | ||
67 | Manager *localDevice; | 67 | Manager *localDevice; |
68 | int progressStat; | 68 | int progressStat; |
69 | |||
70 | signals: | ||
71 | void selectedDevices(QList<RemoteDevices>&); | ||
69 | }; | 72 | }; |
70 | 73 | ||
74 | |||
71 | } | 75 | } |
72 | 76 | ||
73 | #endif // SCANDIALOG_H | 77 | #endif // SCANDIALOG_H |