author | korovkin <korovkin> | 2006-04-15 16:03:19 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-04-15 16:03:19 (UTC) |
commit | 6d3a8eaf3b92f8eec9908eed91568342fac5de1d (patch) (side-by-side diff) | |
tree | deb2f977342b99f72ddcbbaec4066c81278cd65f | |
parent | a1bcbe41d45924713c4ead9b25ac5518473c9ca9 (diff) | |
download | opie-6d3a8eaf3b92f8eec9908eed91568342fac5de1d.zip opie-6d3a8eaf3b92f8eec9908eed91568342fac5de1d.tar.gz opie-6d3a8eaf3b92f8eec9908eed91568342fac5de1d.tar.bz2 |
Added default passkey writing to /etc/bluetooth/pin file.
Added encrypt default passkey in edit line button.
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 20 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 1 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluetoothbase.ui | 264 |
3 files changed, 145 insertions, 140 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 9ec5bf8..924d191 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -40,32 +40,33 @@ using namespace Opie::Core; #include <qlayout.h> #include <qvariant.h> #include <qimage.h> #include <qpixmap.h> #include <qtabwidget.h> #include <qscrollview.h> #include <qvbox.h> #include <qmessagebox.h> #include <qcombobox.h> #include <qcheckbox.h> #include <qlineedit.h> #include <qlistview.h> #include <qdir.h> #include <qpopupmenu.h> #include <qtimer.h> #include <qlist.h> +#include <qfile.h> /* STD */ #include <remotedevice.h> #include <services.h> #include <stdlib.h> using namespace OpieTooth; //Array of possible speeds of the serial port struct SerSpeed { const char* str; //string value int val; //value itself } speeds[] = { { "150", B150 }, { "300", B300 }, { "600", B600 }, { "1200", B1200 }, { "2400", B2400 }, { "4800", B4800 }, { "9600", B9600 }, { "19200", B19200 }, { "38400", B38400 }, { "57600", B57600 }, { "115200", B115200} @@ -81,32 +82,33 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) connect( rfcommBindButton, SIGNAL( clicked() ), this, SLOT( rfcommDialog() ) ); connect( devicesView, SIGNAL( clicked(QListViewItem*)), this, SLOT( startServiceActionClicked(QListViewItem*) ) ); connect( devicesView, SIGNAL( rightButtonClicked(QListViewItem*,const QPoint&,int) ), this, SLOT(startServiceActionHold(QListViewItem*,const QPoint&,int) ) ); connect( m_localDevice , SIGNAL( foundServices(const QString&,Services::ValueList) ), this, SLOT( addServicesToDevice(const QString&,Services::ValueList) ) ); connect( m_localDevice, SIGNAL( available(const QString&,bool) ), this, SLOT( deviceActive(const QString&,bool) ) ); connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ), this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) ); connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), this, SLOT( addSignalStrength(const QString&,const QString&) ) ); connect(runButton, SIGNAL(clicked()), this, SLOT(doForward())); + connect(encCheckBox, SIGNAL(toggled(bool)), this, SLOT(doEncrypt(bool))); // let hold be rightButtonClicked() QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold); QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold); //Load all icons needed m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); m_onPix = Resource::loadPixmap( "opietooth/connected" ); m_findPix = Resource::loadPixmap( "opietooth/find" ); QPalette pal = this->palette(); QColor col = pal.color( QPalette::Active, QColorGroup::Background ); pal.setColor( QPalette::Active, QColorGroup::Button, col ); pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); pal.setColor( QPalette::Normal, QColorGroup::Button, col ); pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); @@ -117,32 +119,33 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) readConfig(); initGui(); devicesView->setRootIsDecorated(true); m_iconLoader = new BTIconLoader(); writeToHciConfig(); addConnectedDevices(); readSavedDevices(); addServicesToDevices(); QTimer::singleShot( 3000, this, SLOT( addServicesToDevices() ) ); forwarder = NULL; serDevName->setText(tr("/dev/ircomm0")); for (unsigned int i = 0; i < (sizeof(speeds) / sizeof(speeds[0])); i++) { serSpeed->insertItem(speeds[i].str); } serSpeed->setCurrentItem((sizeof(speeds) / sizeof(speeds[0])) - 1); + encCheckBox->setChecked(true); } /** * Reads all options from the config file */ void BlueBase::readConfig() { Config cfg( "bluetoothmanager" ); cfg.setGroup( "bluezsettings" ); m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); @@ -160,42 +163,50 @@ void BlueBase::writeConfig() cfg.writeEntry( "name" , m_deviceName ); cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); cfg.writeEntry( "useEncryption" , m_useEncryption ); cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); cfg.writeEntry( "enablePagescan" , m_enablePagescan ); cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); writeToHciConfig(); } /** * Modify the hcid.conf file to our needs */ void BlueBase::writeToHciConfig() { + QFile pinFile("/etc/bluetooth/pin"); // /etc/bluetooth/pin file owarn << "writeToHciConfig" << oendl; + //Write /etc/bluetooth/hcid.conf file HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); hciconf.load(); hciconf.setPinHelper( QPEApplication::qpeDir() + "bin/bluepin" ); hciconf.setName( m_deviceName ); hciconf.setEncrypt( m_useEncryption ); hciconf.setAuth( m_enableAuthentification ); hciconf.setPscan( m_enablePagescan ); hciconf.setIscan( m_enableInquiryscan ); hciconf.save(); + // Write /etc/bluetooth/pin (default PIN file) + pinFile.open(IO_WriteOnly | IO_Truncate); + pinFile.writeBlock(m_defaultPasskey, m_defaultPasskey.length()); + pinFile.writeBlock("\n", sizeof("\n")); + pinFile.flush(); + pinFile.close(); } /** * Read the list of already known devices */ void BlueBase::readSavedDevices() { QValueList<RemoteDevice> loadedDevices; DeviceHandler handler; loadedDevices = handler.load(); addSearchedDevices( loadedDevices ); } @@ -727,17 +738,26 @@ void BlueBase::doForward() runButton->setText("stop gateway"); } /** * React on the process end */ void BlueBase::forwardExit(Opie::Core::OProcess* proc) { if (proc->exitStatus() != 0) QMessageBox::critical(this, tr("Forwarder Error"), tr("Forwarder start error")); delete proc; forwarder = NULL; runButton->setText("start gateway"); } +/** + * Encrypt entered passkey + * doit - do encryption of the key + */ +void BlueBase::doEncrypt(bool doit) +{ + passkeyLine->setEchoMode((doit)? QLineEdit::Password: QLineEdit::Normal); +} + //eof diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 0128a88..9cbea56 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h @@ -81,26 +81,27 @@ namespace OpieTooth { BTIconLoader *m_iconLoader; SerialForwarder* forwarder; private slots: void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); void addServicesToDevices(); void addServicesToDevice( BTDeviceItem *item ); void addServicesToDevice( const QString& device, Services::ValueList ); void addConnectedDevices(); void addConnectedDevices( ConnectionState::ValueList ); void startServiceActionClicked( QListViewItem *item ); void startServiceActionHold( QListViewItem *, const QPoint &, int ); void deviceActive( const QString& mac, bool connected ); void applyConfigChanges(); void doForward(); + void doEncrypt(bool); void forwardExit(Opie::Core::OProcess* proc); void addSignalStrength(); void addSignalStrength( const QString& mac, const QString& strengh ); void rfcommDialog(); }; } #endif diff --git a/noncore/net/opietooth/manager/bluetoothbase.ui b/noncore/net/opietooth/manager/bluetoothbase.ui index a5e2c6f..5539181 100644 --- a/noncore/net/opietooth/manager/bluetoothbase.ui +++ b/noncore/net/opietooth/manager/bluetoothbase.ui @@ -1,38 +1,38 @@ <!DOCTYPE UI><UI> <class>BluetoothBase</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>BluetoothBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>268</width> + <width>273</width> <height>368</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Form1</string> </property> - <vbox> + <hbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>0</number> </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>Status</cstring> </property> <property> <name>layoutMargin</name> @@ -226,313 +226,297 @@ </property> <property> <name>layoutMargin</name> </property> <property> <name>layoutSpacing</name> </property> <grid> <property stdset="1"> <name>margin</name> <number>4</number> </property> <property stdset="1"> <name>spacing</name> <number>2</number> </property> - <widget row="6" column="0" rowspan="1" colspan="2" > - <class>QPushButton</class> + <widget row="0" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>configApplyButton</cstring> + <cstring>deviceNameLabel</cstring> </property> <property stdset="1"> <name>text</name> - <string>Apply</string> + <string>Device Name</string> </property> </widget> - <widget row="2" column="0" rowspan="1" colspan="2" > - <class>QCheckBox</class> + <widget row="1" column="0" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>authCheckBox</cstring> + <cstring>passkeyLabel</cstring> </property> <property stdset="1"> <name>text</name> - <string>enable authentification</string> + <string>Default Passkey</string> </property> </widget> - <widget row="3" column="0" rowspan="1" colspan="2" > - <class>QCheckBox</class> + <widget row="0" column="1" > + <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>cryptCheckBox</cstring> + <cstring>deviceNameLine</cstring> </property> + </widget> + <widget row="1" column="1" > + <class>QLineEdit</class> <property stdset="1"> - <name>text</name> - <string>enable encryption</string> + <name>name</name> + <cstring>passkeyLine</cstring> + </property> + <property stdset="1"> + <name>echoMode</name> + <enum>Password</enum> </property> </widget> - <widget row="4" column="0" rowspan="1" colspan="2" > + <widget row="2" column="1" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>pagescanCheckBox</cstring> + <cstring>encCheckBox</cstring> </property> <property stdset="1"> <name>text</name> - <string>Enable Page scan</string> + <string>encrypt</string> </property> </widget> - <widget row="5" column="0" rowspan="1" colspan="2" > + <widget row="3" column="0" rowspan="1" colspan="2" > <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>inquiryscanCheckBox</cstring> + <cstring>authCheckBox</cstring> </property> <property stdset="1"> <name>text</name> - <string>Enable Inquiry scan</string> + <string>enable authentification</string> </property> </widget> - <widget row="0" column="0" > - <class>QLabel</class> + <widget row="4" column="0" rowspan="1" colspan="2" > + <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>deviceNameLabel</cstring> + <cstring>cryptCheckBox</cstring> </property> <property stdset="1"> <name>text</name> - <string>Device Name</string> + <string>enable encryption</string> </property> </widget> - <widget row="1" column="0" > - <class>QLabel</class> + <widget row="5" column="0" rowspan="1" colspan="2" > + <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>passkeyLabel</cstring> + <cstring>pagescanCheckBox</cstring> </property> <property stdset="1"> <name>text</name> - <string>Default Passkey</string> + <string>Enable Page scan</string> </property> </widget> - <widget row="0" column="1" > - <class>QLineEdit</class> + <widget row="6" column="0" rowspan="1" colspan="2" > + <class>QCheckBox</class> <property stdset="1"> <name>name</name> - <cstring>deviceNameLine</cstring> + <cstring>inquiryscanCheckBox</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Enable Inquiry scan</string> </property> </widget> - <widget row="1" column="1" > - <class>QLineEdit</class> + <widget row="7" column="0" rowspan="1" colspan="2" > + <class>QPushButton</class> <property stdset="1"> <name>name</name> - <cstring>passkeyLine</cstring> + <cstring>configApplyButton</cstring> </property> <property stdset="1"> - <name>echoMode</name> - <enum>Password</enum> + <name>text</name> + <string>Apply</string> </property> </widget> </grid> </widget> </grid> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Status</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> - <number>4</number> + <number>0</number> </property> <property stdset="1"> <name>spacing</name> - <number>2</number> + <number>0</number> </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>StatusLabel</cstring> </property> <property stdset="1"> <name>text</name> <string>Status Label</string> </property> </widget> </vbox> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Phone</string> </attribute> <vbox> <property stdset="1"> <name>margin</name> - <number>0</number> + <number>4</number> </property> <property stdset="1"> <name>spacing</name> - <number>0</number> + <number>2</number> </property> <widget> <class>QGroupBox</class> <property stdset="1"> <name>name</name> <cstring>cellForwarder</cstring> </property> <property stdset="1"> <name>title</name> <string>Cell Forwarder</string> </property> - <vbox> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <grid> <property stdset="1"> <name>margin</name> - <number>11</number> + <number>4</number> </property> <property stdset="1"> <name>spacing</name> - <number>6</number> + <number>2</number> </property> - <widget> - <class>QLayoutWidget</class> + <widget row="2" column="0" rowspan="1" colspan="3" > + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>runButton</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>start gateway</string> + </property> + </widget> + <widget row="0" column="0" rowspan="1" colspan="2" > + <class>QLabel</class> <property stdset="1"> <name>name</name> - <cstring>Layout9</cstring> + <cstring>serDevLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Serial device:</string> </property> - <vbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout5</cstring> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>serDevLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Serial device:</string> - </property> - </widget> - <widget> - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>serDevName</cstring> - </property> - </widget> - </hbox> - </widget> - <widget> - <class>QLayoutWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>Layout6</cstring> - </property> - <hbox> - <property stdset="1"> - <name>margin</name> - <number>0</number> - </property> - <property stdset="1"> - <name>spacing</name> - <number>6</number> - </property> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>serSpeedLabel</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Speed:</string> - </property> - </widget> - <widget> - <class>QComboBox</class> - <property stdset="1"> - <name>name</name> - <cstring>serSpeed</cstring> - </property> - </widget> - </hbox> - </widget> - <widget> - <class>QPushButton</class> - <property stdset="1"> - <name>name</name> - <cstring>runButton</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>start gateway</string> - </property> - </widget> - </vbox> </widget> - </vbox> + <widget row="0" column="2" > + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>serDevName</cstring> + </property> + </widget> + <widget row="1" column="1" rowspan="1" colspan="2" > + <class>QComboBox</class> + <property stdset="1"> + <name>name</name> + <cstring>serSpeed</cstring> + </property> + </widget> + <widget row="1" column="0" > + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>serSpeedLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Speed:</string> + </property> + </widget> + </grid> </widget> </vbox> </widget> </widget> - </vbox> + </hbox> </widget> <customwidgets> <customwidget> <class>QWidget</class> <header location="local">qwidget.h</header> <sizehint> <width>100</width> <height>100</height> </sizehint> <container>0</container> <sizepolicy> <hordata>7</hordata> <verdata>7</verdata> </sizepolicy> <pixmap>image0</pixmap> </customwidget> </customwidgets> <images> <image> <name>image0</name> <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> </image> </images> +<tabstops> + <tabstop>Status</tabstop> + <tabstop>devicesView</tabstop> + <tabstop>PushButton2</tabstop> + <tabstop>connectionsView</tabstop> + <tabstop>deviceNameLine</tabstop> + <tabstop>passkeyLine</tabstop> + <tabstop>encCheckBox</tabstop> + <tabstop>authCheckBox</tabstop> + <tabstop>cryptCheckBox</tabstop> + <tabstop>pagescanCheckBox</tabstop> + <tabstop>inquiryscanCheckBox</tabstop> + <tabstop>configApplyButton</tabstop> + <tabstop>rfcommBindButton</tabstop> + <tabstop>serDevName</tabstop> + <tabstop>serSpeed</tabstop> + <tabstop>runButton</tabstop> +</tabstops> </UI> |