-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 6c17974..b31e14f 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -34,141 +34,130 @@ | |||
34 | #include <qimage.h> | 34 | #include <qimage.h> |
35 | #include <qpixmap.h> | 35 | #include <qpixmap.h> |
36 | #include <qtabwidget.h> | 36 | #include <qtabwidget.h> |
37 | #include <qscrollview.h> | 37 | #include <qscrollview.h> |
38 | #include <qvbox.h> | 38 | #include <qvbox.h> |
39 | #include <qmessagebox.h> | 39 | #include <qmessagebox.h> |
40 | #include <qcheckbox.h> | 40 | #include <qcheckbox.h> |
41 | #include <qlineedit.h> | 41 | #include <qlineedit.h> |
42 | #include <qlistview.h> | 42 | #include <qlistview.h> |
43 | #include <qdir.h> | 43 | #include <qdir.h> |
44 | #include <qpopupmenu.h> | 44 | #include <qpopupmenu.h> |
45 | #include <qtimer.h> | 45 | #include <qtimer.h> |
46 | 46 | ||
47 | #include <qpe/qpeapplication.h> | 47 | #include <qpe/qpeapplication.h> |
48 | #include <qpe/resource.h> | 48 | #include <qpe/resource.h> |
49 | #include <qpe/config.h> | 49 | #include <qpe/config.h> |
50 | 50 | ||
51 | 51 | ||
52 | using namespace OpieTooth; | 52 | using namespace OpieTooth; |
53 | 53 | ||
54 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 54 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
55 | : BluetoothBase( parent, name, fl ) { | 55 | : BluetoothBase( parent, name, fl ) { |
56 | 56 | ||
57 | m_localDevice = new Manager( "hci0" ); | 57 | m_localDevice = new Manager( "hci0" ); |
58 | 58 | ||
59 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); | 59 | connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); |
60 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); | 60 | connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); |
61 | // not good since lib is async | 61 | // not good since lib is async |
62 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), | 62 | // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), |
63 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); | 63 | // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); |
64 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), | 64 | connect( ListView2, SIGNAL( clicked( QListViewItem* )), |
65 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); | 65 | this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); |
66 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), | 66 | connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), |
67 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); | 67 | this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); |
68 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), | 68 | connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), |
69 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); | 69 | this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); |
70 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), | 70 | connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), |
71 | this, SLOT( deviceActive( const QString& , bool ) ) ); | 71 | this, SLOT( deviceActive( const QString& , bool ) ) ); |
72 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), | 72 | connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), |
73 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); | 73 | this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); |
74 | 74 | ||
75 | 75 | ||
76 | // let hold be rightButtonClicked() | 76 | // let hold be rightButtonClicked() |
77 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); | 77 | QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); |
78 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); | 78 | QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); |
79 | 79 | ||
80 | //Load all icons needed | 80 | //Load all icons needed |
81 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); | 81 | m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); |
82 | m_onPix = Resource::loadPixmap( "opietooth/connected" ); | 82 | m_onPix = Resource::loadPixmap( "opietooth/connected" ); |
83 | m_findPix = Resource::loadPixmap( "opietooth/find" ); | 83 | m_findPix = Resource::loadPixmap( "opietooth/find" ); |
84 | 84 | ||
85 | QPalette pal = this->palette(); | 85 | QPalette pal = this->palette(); |
86 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); | 86 | QColor col = pal.color( QPalette::Active, QColorGroup::Background ); |
87 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); | 87 | pal.setColor( QPalette::Active, QColorGroup::Button, col ); |
88 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); | 88 | pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); |
89 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); | 89 | pal.setColor( QPalette::Normal, QColorGroup::Button, col ); |
90 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); | 90 | pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); |
91 | this->setPalette( pal ); | 91 | this->setPalette( pal ); |
92 | 92 | ||
93 | setCaption( tr( "Bluetooth Manager" ) ); | 93 | setCaption( tr( "Bluetooth Manager" ) ); |
94 | 94 | ||
95 | readConfig(); | 95 | readConfig(); |
96 | initGui(); | 96 | initGui(); |
97 | 97 | ||
98 | //TESTING | ||
99 | ListView2->setRootIsDecorated(true); | 98 | ListView2->setRootIsDecorated(true); |
100 | 99 | ||
101 | BTDeviceItem *topLV2 = new BTDeviceItem( ListView2, RemoteDevice("xx:", "Siemens S45" ) ); | ||
102 | topLV2->setPixmap( 1, m_onPix ); | ||
103 | Services s1; | ||
104 | s1.setServiceName( "Serial" ); | ||
105 | s1.insertClassId(1, "BlueNic"); | ||
106 | (void) new BTServiceItem( topLV2, s1 ); | ||
107 | s1.setServiceName( "BlueNic" ); | ||
108 | s1.insertClassId(2, "Obex"); | ||
109 | (void) new BTServiceItem( topLV2, s1 ); | ||
110 | |||
111 | writeToHciConfig(); | 100 | writeToHciConfig(); |
112 | // search conncetions | 101 | // search conncetions |
113 | addConnectedDevices(); | 102 | addConnectedDevices(); |
114 | m_iconLoader = new BTIconLoader(); | 103 | m_iconLoader = new BTIconLoader(); |
115 | readSavedDevices(); | 104 | readSavedDevices(); |
116 | } | 105 | } |
117 | 106 | ||
118 | /** | 107 | /** |
119 | * Reads all options from the config file | 108 | * Reads all options from the config file |
120 | */ | 109 | */ |
121 | void BlueBase::readConfig() { | 110 | void BlueBase::readConfig() { |
122 | 111 | ||
123 | Config cfg( "bluetoothmanager" ); | 112 | Config cfg( "bluetoothmanager" ); |
124 | cfg.setGroup( "bluezsettings" ); | 113 | cfg.setGroup( "bluezsettings" ); |
125 | 114 | ||
126 | m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with | 115 | m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with |
127 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak | 116 | m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak |
128 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); | 117 | m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); |
129 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); | 118 | m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); |
130 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); | 119 | m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); |
131 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); | 120 | m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); |
132 | } | 121 | } |
133 | 122 | ||
134 | /** | 123 | /** |
135 | * Writes all options to the config file | 124 | * Writes all options to the config file |
136 | */ | 125 | */ |
137 | void BlueBase::writeConfig() { | 126 | void BlueBase::writeConfig() { |
138 | 127 | ||
139 | Config cfg( "bluetoothmanager" ); | 128 | Config cfg( "bluetoothmanager" ); |
140 | cfg.setGroup( "bluezsettings" ); | 129 | cfg.setGroup( "bluezsettings" ); |
141 | 130 | ||
142 | cfg.writeEntry( "name" , m_deviceName ); | 131 | cfg.writeEntry( "name" , m_deviceName ); |
143 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); | 132 | cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); |
144 | cfg.writeEntry( "useEncryption" , m_useEncryption ); | 133 | cfg.writeEntry( "useEncryption" , m_useEncryption ); |
145 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); | 134 | cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); |
146 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); | 135 | cfg.writeEntry( "enablePagescan" , m_enablePagescan ); |
147 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); | 136 | cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); |
148 | 137 | ||
149 | writeToHciConfig(); | 138 | writeToHciConfig(); |
150 | } | 139 | } |
151 | 140 | ||
152 | /** | 141 | /** |
153 | * Modify the hcid.conf file to our needs | 142 | * Modify the hcid.conf file to our needs |
154 | */ | 143 | */ |
155 | void BlueBase::writeToHciConfig() { | 144 | void BlueBase::writeToHciConfig() { |
156 | qWarning("writeToHciConfig"); | 145 | qWarning("writeToHciConfig"); |
157 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); | 146 | HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); |
158 | hciconf.load(); | 147 | hciconf.load(); |
159 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); | 148 | hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); |
160 | hciconf.setName( m_deviceName ); | 149 | hciconf.setName( m_deviceName ); |
161 | hciconf.setEncrypt( m_useEncryption ); | 150 | hciconf.setEncrypt( m_useEncryption ); |
162 | hciconf.setAuth( m_enableAuthentification ); | 151 | hciconf.setAuth( m_enableAuthentification ); |
163 | hciconf.setPscan( m_enablePagescan ); | 152 | hciconf.setPscan( m_enablePagescan ); |
164 | hciconf.setIscan( m_enableInquiryscan ); | 153 | hciconf.setIscan( m_enableInquiryscan ); |
165 | hciconf.save(); | 154 | hciconf.save(); |
166 | } | 155 | } |
167 | 156 | ||
168 | 157 | ||
169 | /** | 158 | /** |
170 | * Read the list of allready known devices | 159 | * Read the list of allready known devices |
171 | */ | 160 | */ |
172 | void BlueBase::readSavedDevices() { | 161 | void BlueBase::readSavedDevices() { |
173 | 162 | ||
174 | QValueList<RemoteDevice> loadedDevices; | 163 | QValueList<RemoteDevice> loadedDevices; |