summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
authorwimpie <wimpie>2005-01-12 01:40:53 (UTC)
committer wimpie <wimpie>2005-01-12 01:40:53 (UTC)
commitf9a83585111afa08a47176097a150d9f468bfcdf (patch) (unidiff)
tree6d5a3b5f9716f7c6ca6e7fae8b0e2bac8d6c57da /noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
parentb2e60aa0222b348f34aab501feb8bc854e94413c (diff)
downloadopie-f9a83585111afa08a47176097a150d9f468bfcdf.zip
opie-f9a83585111afa08a47176097a150d9f468bfcdf.tar.gz
opie-f9a83585111afa08a47176097a150d9f468bfcdf.tar.bz2
*** empty log message ***
Diffstat (limited to 'noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp42
1 files changed, 35 insertions, 7 deletions
diff --git a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
index cd7bb4a..63b214e 100644
--- a/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
+++ b/noncore/settings/networksettings2/bluetooth/bluetoothRFCOMMrun.cpp
@@ -1,15 +1,27 @@
1#include <qapplication.h> 1#include <qapplication.h>
2#include <resources.h> 2#include <resources.h>
3
4#include <OTPeer.h>
3#include <OTDevice.h> 5#include <OTDevice.h>
4#include <OTGateway.h> 6#include <OTGateway.h>
7#include <Opietooth.h>
8
9#include <qlistbox.h>
10#include <qframe.h>
11#include <qlabel.h>
12#include <qlayout.h>
13#include <qdialog.h>
14
5#include "bluetoothRFCOMMrun.h" 15#include "bluetoothRFCOMMrun.h"
6 16
7using Opietooth2::OTGateway; 17using Opietooth2::OTGateway;
8using Opietooth2::OTDevice; 18using Opietooth2::OTDevice;
9using Opietooth2::OTDeviceAddress; 19using Opietooth2::OTDeviceAddress;
20using Opietooth2::OTScan;
21using Opietooth2::OTPeer;
10 22
11BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) { 23BluetoothRFCOMMRun::~BluetoothRFCOMMRun( void ) {
12 if( OT ) { 24 if( OT ) {
13 OTGateway::releaseOTGateway(); 25 OTGateway::releaseOTGateway();
14 } 26 }
15} 27}
@@ -52,12 +64,15 @@ QString BluetoothRFCOMMRun::setMyState( NetworkSetup *,
52 S << "rfcomm" 64 S << "rfcomm"
53 << "bind" 65 << "bind"
54 << QString().setNum( DeviceNr ) 66 << QString().setNum( DeviceNr )
55 << Ch->BDAddress 67 << Ch->BDAddress
56 << QString().setNum( Ch->Channel ); 68 << QString().setNum( Ch->Channel );
57 69
70 // no longer needed
71 delete Ch;
72
58 if( Sys.runAsRoot( S ) ) { 73 if( Sys.runAsRoot( S ) ) {
59 return QString( "Error starting %1").arg(S.join(" ")); 74 return QString( "Error starting %1").arg(S.join(" "));
60 } 75 }
61 76
62 // here rfcomm should be running -> we will detect state later 77 // here rfcomm should be running -> we will detect state later
63 return QString(); 78 return QString();
@@ -75,26 +90,36 @@ QString BluetoothRFCOMMRun::setMyState( NetworkSetup *,
75 DeviceNr = -1; 90 DeviceNr = -1;
76 } 91 }
77 } 92 }
78 return QString(); 93 return QString();
79} 94}
80 95
81#include <qlistbox.h>
82#include <qframe.h>
83#include <qlabel.h>
84#include <qlayout.h>
85#include <qdialog.h>
86
87RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) { 96RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) {
88 97
89 if( Data->Devices.count() == 1 ) { 98 if( Data->Devices.count() == 1 ) {
90 // only one device -> return channel 99 // only one device -> return channel
91 return Data->Devices[0]; 100 return Data->Devices[0];
92 } 101 }
93 102
94 RFCOMMChannel * Ch = 0; 103 RFCOMMChannel * Ch = 0;
104
105 if( Data->Devices.count() == 0 ) {
106 OTPeer * Peer;
107 int Channel;
108
109 if( OTScan::getDevice( Peer, Channel, OT ) == QDialog::Accepted ) {
110 Ch = new RFCOMMChannel;
111 Ch->BDAddress = Peer->address().toString();
112 Ch->Name = Peer->name();
113 Ch->Channel = Channel;
114 return Ch;
115 }
116
117 return 0;
118 }
119
95 QDialog * Dlg = new QDialog( qApp->mainWidget(), 0, TRUE ); 120 QDialog * Dlg = new QDialog( qApp->mainWidget(), 0, TRUE );
96 QVBoxLayout * V = new QVBoxLayout( Dlg ); 121 QVBoxLayout * V = new QVBoxLayout( Dlg );
97 122
98 QLabel * L = new QLabel( 123 QLabel * L = new QLabel(
99 qApp->translate( "BluetoothRFCOMMRun", 124 qApp->translate( "BluetoothRFCOMMRun",
100 "Select device to connect to"), 125 "Select device to connect to"),
@@ -117,13 +142,16 @@ RFCOMMChannel * BluetoothRFCOMMRun::getChannel( void ) {
117 142
118 if( Dlg->exec() == QDialog::Accepted ) { 143 if( Dlg->exec() == QDialog::Accepted ) {
119 unsigned int i = 0; 144 unsigned int i = 0;
120 for( i = 0; i < Data->Devices.count(); i ++ ) { 145 for( i = 0; i < Data->Devices.count(); i ++ ) {
121 if( LB->isSelected(i) ) { 146 if( LB->isSelected(i) ) {
122 odebug << "Selected " << Data->Devices[i]->Name << oendl; 147 odebug << "Selected " << Data->Devices[i]->Name << oendl;
123 Ch = Data->Devices[i]; 148 Ch = new RFCOMMChannel;
149 Ch->BDAddress = Data->Devices[i]->BDAddress;
150 Ch->Name = Data->Devices[i]->Name;
151 Ch->Channel = Data->Devices[i]->Channel;
124 break; 152 break;
125 } 153 }
126 } 154 }
127 } 155 }
128 156
129 delete Dlg; 157 delete Dlg;