Diffstat (limited to 'noncore/apps/opie-console/io_bt.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/io_bt.cpp | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/noncore/apps/opie-console/io_bt.cpp b/noncore/apps/opie-console/io_bt.cpp index 0831faf..d71aacc 100644 --- a/noncore/apps/opie-console/io_bt.cpp +++ b/noncore/apps/opie-console/io_bt.cpp | |||
@@ -1,64 +1,78 @@ | |||
1 | 1 | ||
2 | #include "io_bt.h" | 2 | #include "io_bt.h" |
3 | 3 | ||
4 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { | 4 | IOBt::IOBt( const Profile &config ) : IOSerial( config ) { |
5 | m_attach = 0; | 5 | m_attach = 0; |
6 | } | 6 | } |
7 | 7 | ||
8 | 8 | ||
9 | IOBt::~IOBt() { | 9 | IOBt::~IOBt() { |
10 | if ( m_attach ) { | 10 | if ( m_attach ) { |
11 | delete m_attach; | 11 | delete m_attach; |
12 | } | 12 | } |
13 | } | 13 | } |
14 | 14 | ||
15 | 15 | ||
16 | void IOBt::close() { | 16 | void IOBt::close() { |
17 | 17 | ||
18 | IOSerial::close(); | 18 | IOSerial::close(); |
19 | // still need error handling | 19 | // still need error handling |
20 | delete m_attach; | 20 | if ( m_attach ) { |
21 | delete m_attach; | ||
22 | m_attach = 0; | ||
23 | } | ||
21 | } | 24 | } |
22 | 25 | ||
23 | bool IOBt::open() { | 26 | bool IOBt::open() { |
24 | 27 | ||
25 | // hciattach here | 28 | // only set up bt stuff if mac address was set, otherwise use the device set |
26 | m_attach = new OProcess(); | 29 | if ( !m_mac.isEmpty() ) { |
27 | *m_attach << "hciattach /dev/ttyS2 any 57600"; | ||
28 | 30 | ||
29 | // then start hcid, then rcfomm handling (m_mac) | 31 | // now it should also be checked, if there is a connection to the device with that mac allready |
30 | 32 | ||
31 | connect( m_attach, SIGNAL( processExited( OProcess* ) ), | 33 | // hciattach here |
32 | this, SLOT( slotExited( OProcess* ) ) ); | 34 | m_attach = new OProcess(); |
35 | *m_attach << "hciattach /dev/ttyS2 any 57600"; | ||
33 | 36 | ||
34 | if ( m_attach->start() ) { | 37 | // then start hcid, then rcfomm handling (m_mac) |
35 | IOSerial::open(); | 38 | |
39 | connect( m_attach, SIGNAL( processExited( OProcess* ) ), | ||
40 | this, SLOT( slotExited( OProcess* ) ) ); | ||
41 | |||
42 | if ( m_attach->start() ) { | ||
43 | IOSerial::open(); | ||
44 | } else { | ||
45 | qWarning("could not attach to device"); | ||
46 | delete m_attach; | ||
47 | m_attach = 0; | ||
48 | } | ||
36 | } else { | 49 | } else { |
37 | qWarning("could not attach to device"); | 50 | // directly to the normal serial |
38 | delete m_attach; | 51 | // TODO: look first if the connection really exists. ( is set up ) |
39 | m_attach = 0; | 52 | |
53 | IOSerial::open(); | ||
40 | } | 54 | } |
41 | } | 55 | } |
42 | 56 | ||
43 | void IOBt::reload( const Profile &config ) { | 57 | void IOBt::reload( const Profile &config ) { |
44 | m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); | 58 | m_device = config.readEntry("Device", BT_DEFAULT_DEVICE); |
45 | m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); | 59 | m_mac = config.readEntry("Mac", BT_DEFAULT_MAC); |
46 | m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); | 60 | m_baud = config.readNumEntry("Baud", BT_DEFAULT_BAUD); |
47 | m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); | 61 | m_parity = config.readNumEntry("Parity", BT_DEFAULT_PARITY); |
48 | m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); | 62 | m_dbits = config.readNumEntry("DataBits", BT_DEFAULT_DBITS); |
49 | m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); | 63 | m_sbits = config.readNumEntry("StopBits", BT_DEFAULT_SBITS); |
50 | m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); | 64 | m_flow = config.readNumEntry("Flow", BT_DEFAULT_FLOW); |
51 | } | 65 | } |
52 | 66 | ||
53 | 67 | ||
54 | QString IOBt::identifier() const { | 68 | QString IOBt::identifier() const { |
55 | return "bluetooth"; | 69 | return "bluetooth"; |
56 | } | 70 | } |
57 | 71 | ||
58 | QString IOBt::name() const { | 72 | QString IOBt::name() const { |
59 | return "BLuetooth IO Layer"; | 73 | return "BLuetooth IO Layer"; |
60 | } | 74 | } |
61 | 75 | ||
62 | void IOBt::slotExited( OProcess* proc ){ | 76 | void IOBt::slotExited( OProcess* proc ){ |
63 | close(); | 77 | close(); |
64 | } | 78 | } |