summaryrefslogtreecommitdiff
path: root/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp
Unidiff
Diffstat (limited to 'noncore/settings/networksettings2/opietooth2/OTDriverList.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/networksettings2/opietooth2/OTDriverList.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp b/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp
index f703834..e5af742 100644
--- a/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp
+++ b/noncore/settings/networksettings2/opietooth2/OTDriverList.cpp
@@ -1,86 +1,86 @@
1/*************************************************************************** 1/***************************************************************************
2 * Copyright (C) 2003 by Mattia Merzi * 2 * Copyright (C) 2003 by Mattia Merzi *
3 * ottobit@ferrara.linux.it * 3 * ottobit@ferrara.linux.it *
4 * * 4 * *
5 * This program is free software; you can redistribute it and/or modify * 5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by * 6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or * 7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. * 8 * (at your option) any later version. *
9 ***************************************************************************/ 9 ***************************************************************************/
10 10
11#include <malloc.h> 11#include <malloc.h>
12#include <bluezlib.h> 12#include <bluezlib.h>
13 13
14#include <opie2/odebug.h> 14#include <opie2/odebug.h>
15 15
16#include <OTDriverList.h> 16#include <OTDriverList.h>
17#include <OTGateway.h> 17#include <OTGateway.h>
18#include <OTDriver.h> 18#include <OTDriver.h>
19 19
20using namespace Opietooth2; 20using namespace Opietooth2;
21 21
22OTDriverList::OTDriverList( OTGateway * _OT ) : QVector<OTDriver>() { 22OTDriverList::OTDriverList( OTGateway * _OT ) : QVector<OTDriver>() {
23 23
24 OT = _OT; 24 OT = _OT;
25 setAutoDelete( true ); 25 setAutoDelete( true );
26} 26}
27 27
28OTDriverList::~OTDriverList() { 28OTDriverList::~OTDriverList() {
29} 29}
30 30
31void OTDriverList::update() { 31void OTDriverList::update() {
32 32
33 struct hci_dev_list_req *dl; 33 struct hci_dev_list_req *dl;
34 struct hci_dev_req *dr; 34 struct hci_dev_req *dr;
35 struct hci_dev_info di; 35 struct hci_dev_info di;
36 int cur; 36 int cur;
37 37
38 dl = 0; 38 dl = 0;
39 cur = 0; 39 cur = 0;
40 do { 40 do {
41 cur += 5; 41 cur += 5;
42 42
43 dl = (struct hci_dev_list_req*) 43 dl = (struct hci_dev_list_req*)
44 ::realloc( dl, sizeof( struct hci_dev_list_req ) + 44 ::realloc( dl, sizeof( struct hci_dev_list_req ) +
45 ( cur * sizeof(struct hci_dev_req) ) 45 ( cur * sizeof(struct hci_dev_req) )
46 ); 46 );
47 47
48 if( dl == 0 ) { 48 if( dl == 0 ) {
49 // memory problem 49 // memory problem
50 exit(1); 50 exit(1);
51 } 51 }
52 52
53 dl->dev_num = cur; 53 dl->dev_num = cur;
54 54
55 if( ioctl( OT->getSocket(), HCIGETDEVLIST, (void*)dl) ) { 55 if( ioctl( OT->getSocket(), HCIGETDEVLIST, (void*)dl) ) {
56 owarn << "WARNING : cannot read device list. " 56 odebug << "WARNING : cannot read device list. "
57 << errno 57 << errno
58 << strerror( errno ) << oendl; 58 << strerror( errno ) << oendl;
59 return; 59 return;
60 } 60 }
61 61
62 // if num == cur perhaps we did not get all devices yet 62 // if num == cur perhaps we did not get all devices yet
63 } while( dl->dev_num == cur ); 63 } while( dl->dev_num == cur );
64 64
65 if( dl->dev_num != count() ) { 65 if( dl->dev_num != count() ) {
66 // new or missing devices 66 // new or missing devices
67 clear(); 67 clear();
68 68
69 dr = dl->dev_req; 69 dr = dl->dev_req;
70 resize( dl->dev_num ); 70 resize( dl->dev_num );
71 71
72 for( cur=0; cur < dl->dev_num; cur ++) { 72 for( cur=0; cur < dl->dev_num; cur ++) {
73 memset( &di, 0, sizeof( di ) ); 73 memset( &di, 0, sizeof( di ) );
74 di.dev_id = (dr+cur)->dev_id; 74 di.dev_id = (dr+cur)->dev_id;
75 75
76 // get device info 76 // get device info
77 if( ioctl( OT->getSocket(), HCIGETDEVINFO, (void*)&di) != 0 ) 77 if( ioctl( OT->getSocket(), HCIGETDEVINFO, (void*)&di) != 0 )
78 continue; // uh ? 78 continue; // uh ?
79 insert( cur, new OTDriver( OT, &di ) ); 79 insert( cur, new OTDriver( OT, &di ) );
80 } 80 }
81 81
82 owarn << "Found " << count() << " devices" << oendl; 82 odebug << "Found " << count() << " devices" << oendl;
83 83
84 ::free( dl ); 84 ::free( dl );
85 } 85 }
86} 86}