-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 61 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluetoothbase.ui | 182 |
3 files changed, 234 insertions, 13 deletions
diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index 0649514..9ec5bf8 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp | |||
@@ -18,12 +18,16 @@ | |||
18 | #include "bluebase.h" | 18 | #include "bluebase.h" |
19 | #include "scandialog.h" | 19 | #include "scandialog.h" |
20 | #include "hciconfwrapper.h" | 20 | #include "hciconfwrapper.h" |
21 | #include "devicehandler.h" | 21 | #include "devicehandler.h" |
22 | #include "btconnectionitem.h" | 22 | #include "btconnectionitem.h" |
23 | #include "rfcommassigndialogimpl.h" | 23 | #include "rfcommassigndialogimpl.h" |
24 | #include "forwarder.h" | ||
25 | #include <termios.h> | ||
26 | #include <string.h> | ||
27 | #include <errno.h> | ||
24 | 28 | ||
25 | /* OPIE */ | 29 | /* OPIE */ |
26 | #include <qpe/qpeapplication.h> | 30 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/resource.h> | 31 | #include <qpe/resource.h> |
28 | #include <qpe/config.h> | 32 | #include <qpe/config.h> |
29 | #include <opie2/odebug.h> | 33 | #include <opie2/odebug.h> |
@@ -38,12 +42,13 @@ using namespace Opie::Core; | |||
38 | #include <qimage.h> | 42 | #include <qimage.h> |
39 | #include <qpixmap.h> | 43 | #include <qpixmap.h> |
40 | #include <qtabwidget.h> | 44 | #include <qtabwidget.h> |
41 | #include <qscrollview.h> | 45 | #include <qscrollview.h> |
42 | #include <qvbox.h> | 46 | #include <qvbox.h> |
43 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
48 | #include <qcombobox.h> | ||
44 | #include <qcheckbox.h> | 49 | #include <qcheckbox.h> |
45 | #include <qlineedit.h> | 50 | #include <qlineedit.h> |
46 | #include <qlistview.h> | 51 | #include <qlistview.h> |
47 | #include <qdir.h> | 52 | #include <qdir.h> |
48 | #include <qpopupmenu.h> | 53 | #include <qpopupmenu.h> |
49 | #include <qtimer.h> | 54 | #include <qtimer.h> |
@@ -52,12 +57,22 @@ using namespace Opie::Core; | |||
52 | /* STD */ | 57 | /* STD */ |
53 | #include <remotedevice.h> | 58 | #include <remotedevice.h> |
54 | #include <services.h> | 59 | #include <services.h> |
55 | #include <stdlib.h> | 60 | #include <stdlib.h> |
56 | 61 | ||
57 | using namespace OpieTooth; | 62 | using namespace OpieTooth; |
63 | //Array of possible speeds of the serial port | ||
64 | struct SerSpeed { | ||
65 | const char* str; //string value | ||
66 | int val; //value itself | ||
67 | } speeds[] = { | ||
68 | { "150", B150 }, { "300", B300 }, { "600", B600 }, { "1200", B1200 }, | ||
69 | { "2400", B2400 }, { "4800", B4800 }, { "9600", B9600 }, | ||
70 | { "19200", B19200 }, { "38400", B38400 }, { "57600", B57600 }, | ||
71 | { "115200", B115200} | ||
72 | }; | ||
58 | 73 | ||
59 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | 74 | BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) |
60 | : BluetoothBase( parent, name, fl ) | 75 | : BluetoothBase( parent, name, fl ) |
61 | { | 76 | { |
62 | m_localDevice = new Manager( "hci0" ); | 77 | m_localDevice = new Manager( "hci0" ); |
63 | 78 | ||
@@ -75,12 +90,13 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
75 | connect( m_localDevice, SIGNAL( available(const QString&,bool) ), | 90 | connect( m_localDevice, SIGNAL( available(const QString&,bool) ), |
76 | this, SLOT( deviceActive(const QString&,bool) ) ); | 91 | this, SLOT( deviceActive(const QString&,bool) ) ); |
77 | connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ), | 92 | connect( m_localDevice, SIGNAL( connections(ConnectionState::ValueList) ), |
78 | this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) ); | 93 | this, SLOT( addConnectedDevices(ConnectionState::ValueList) ) ); |
79 | connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), | 94 | connect( m_localDevice, SIGNAL( signalStrength(const QString&,const QString&) ), |
80 | this, SLOT( addSignalStrength(const QString&,const QString&) ) ); | 95 | this, SLOT( addSignalStrength(const QString&,const QString&) ) ); |
96 | connect(runButton, SIGNAL(clicked()), this, SLOT(doForward())); | ||
81 | 97 | ||
82 | // let hold be rightButtonClicked() | 98 | // let hold be rightButtonClicked() |
83 | QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold); | 99 | QPEApplication::setStylusOperation( devicesView->viewport(), QPEApplication::RightOnHold); |
84 | QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold); | 100 | QPEApplication::setStylusOperation( connectionsView->viewport(), QPEApplication::RightOnHold); |
85 | 101 | ||
86 | //Load all icons needed | 102 | //Load all icons needed |
@@ -105,12 +121,18 @@ BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) | |||
105 | m_iconLoader = new BTIconLoader(); | 121 | m_iconLoader = new BTIconLoader(); |
106 | writeToHciConfig(); | 122 | writeToHciConfig(); |
107 | addConnectedDevices(); | 123 | addConnectedDevices(); |
108 | readSavedDevices(); | 124 | readSavedDevices(); |
109 | addServicesToDevices(); | 125 | addServicesToDevices(); |
110 | QTimer::singleShot( 3000, this, SLOT( addServicesToDevices() ) ); | 126 | QTimer::singleShot( 3000, this, SLOT( addServicesToDevices() ) ); |
127 | forwarder = NULL; | ||
128 | serDevName->setText(tr("/dev/ircomm0")); | ||
129 | for (unsigned int i = 0; i < (sizeof(speeds) / sizeof(speeds[0])); i++) { | ||
130 | serSpeed->insertItem(speeds[i].str); | ||
131 | } | ||
132 | serSpeed->setCurrentItem((sizeof(speeds) / sizeof(speeds[0])) - 1); | ||
111 | } | 133 | } |
112 | 134 | ||
113 | /** | 135 | /** |
114 | * Reads all options from the config file | 136 | * Reads all options from the config file |
115 | */ | 137 | */ |
116 | void BlueBase::readConfig() | 138 | void BlueBase::readConfig() |
@@ -677,6 +699,45 @@ bool BlueBase::find( const RemoteDevice& rem ) | |||
677 | device = (BTDeviceItem*)item; | 699 | device = (BTDeviceItem*)item; |
678 | if ( rem.equals( device->remoteDevice() ) ) | 700 | if ( rem.equals( device->remoteDevice() ) ) |
679 | return true; | 701 | return true; |
680 | } | 702 | } |
681 | return false; // not found | 703 | return false; // not found |
682 | } | 704 | } |
705 | |||
706 | /** | ||
707 | * Start process of the cell phone forwarding | ||
708 | */ | ||
709 | void BlueBase::doForward() | ||
710 | { | ||
711 | if (forwarder && forwarder->isRunning()) { | ||
712 | runButton->setText("start gateway"); | ||
713 | forwarder->stop(); | ||
714 | delete forwarder; | ||
715 | forwarder = NULL; | ||
716 | return; | ||
717 | } | ||
718 | QString str = serDevName->text(); | ||
719 | forwarder = new SerialForwarder(str, speeds[serSpeed->currentItem()].val); | ||
720 | connect(forwarder, SIGNAL(processExited(Opie::Core::OProcess*)), | ||
721 | this, SLOT(forwardExited(Opie::Core::OProcess*))); | ||
722 | if (forwarder->start(OProcess::NotifyOnExit) < 0) { | ||
723 | QMessageBox::critical(this, tr("Forwarder Error"), | ||
724 | tr("Forwarder start error:") + tr(strerror(errno))); | ||
725 | return; | ||
726 | } | ||
727 | runButton->setText("stop gateway"); | ||
728 | } | ||
729 | |||
730 | /** | ||
731 | * React on the process end | ||
732 | */ | ||
733 | void BlueBase::forwardExit(Opie::Core::OProcess* proc) | ||
734 | { | ||
735 | if (proc->exitStatus() != 0) | ||
736 | QMessageBox::critical(this, tr("Forwarder Error"), | ||
737 | tr("Forwarder start error")); | ||
738 | delete proc; | ||
739 | forwarder = NULL; | ||
740 | runButton->setText("start gateway"); | ||
741 | } | ||
742 | |||
743 | //eof | ||
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index 48883d2..0128a88 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -14,12 +14,13 @@ | |||
14 | #include "btserviceitem.h" | 14 | #include "btserviceitem.h" |
15 | #include "btdeviceitem.h" | 15 | #include "btdeviceitem.h" |
16 | 16 | ||
17 | #include "popuphelper.h" | 17 | #include "popuphelper.h" |
18 | 18 | ||
19 | #include "bticonloader.h" | 19 | #include "bticonloader.h" |
20 | #include "forwarder.h" | ||
20 | 21 | ||
21 | #include <remotedevice.h> | 22 | #include <remotedevice.h> |
22 | #include <manager.h> | 23 | #include <manager.h> |
23 | 24 | ||
24 | class QVBox; | 25 | class QVBox; |
25 | class QHBoxLayout; | 26 | class QHBoxLayout; |
@@ -76,24 +77,27 @@ namespace OpieTooth { | |||
76 | 77 | ||
77 | QPixmap m_offPix; | 78 | QPixmap m_offPix; |
78 | QPixmap m_onPix; | 79 | QPixmap m_onPix; |
79 | QPixmap m_findPix; | 80 | QPixmap m_findPix; |
80 | 81 | ||
81 | BTIconLoader *m_iconLoader; | 82 | BTIconLoader *m_iconLoader; |
83 | SerialForwarder* forwarder; | ||
82 | 84 | ||
83 | private slots: | 85 | private slots: |
84 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); | 86 | void addSearchedDevices( const QValueList<RemoteDevice> &newDevices ); |
85 | void addServicesToDevices(); | 87 | void addServicesToDevices(); |
86 | void addServicesToDevice( BTDeviceItem *item ); | 88 | void addServicesToDevice( BTDeviceItem *item ); |
87 | void addServicesToDevice( const QString& device, Services::ValueList ); | 89 | void addServicesToDevice( const QString& device, Services::ValueList ); |
88 | void addConnectedDevices(); | 90 | void addConnectedDevices(); |
89 | void addConnectedDevices( ConnectionState::ValueList ); | 91 | void addConnectedDevices( ConnectionState::ValueList ); |
90 | void startServiceActionClicked( QListViewItem *item ); | 92 | void startServiceActionClicked( QListViewItem *item ); |
91 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); | 93 | void startServiceActionHold( QListViewItem *, const QPoint &, int ); |
92 | void deviceActive( const QString& mac, bool connected ); | 94 | void deviceActive( const QString& mac, bool connected ); |
93 | void applyConfigChanges(); | 95 | void applyConfigChanges(); |
96 | void doForward(); | ||
97 | void forwardExit(Opie::Core::OProcess* proc); | ||
94 | void addSignalStrength(); | 98 | void addSignalStrength(); |
95 | void addSignalStrength( const QString& mac, const QString& strengh ); | 99 | void addSignalStrength( const QString& mac, const QString& strengh ); |
96 | void rfcommDialog(); | 100 | void rfcommDialog(); |
97 | 101 | ||
98 | }; | 102 | }; |
99 | 103 | ||
diff --git a/noncore/net/opietooth/manager/bluetoothbase.ui b/noncore/net/opietooth/manager/bluetoothbase.ui index cbde3c6..a5e2c6f 100644 --- a/noncore/net/opietooth/manager/bluetoothbase.ui +++ b/noncore/net/opietooth/manager/bluetoothbase.ui | |||
@@ -8,36 +8,30 @@ | |||
8 | </property> | 8 | </property> |
9 | <property stdset="1"> | 9 | <property stdset="1"> |
10 | <name>geometry</name> | 10 | <name>geometry</name> |
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>293</width> | 14 | <width>268</width> |
15 | <height>382</height> | 15 | <height>368</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
18 | <property stdset="1"> | 18 | <property stdset="1"> |
19 | <name>caption</name> | 19 | <name>caption</name> |
20 | <string>Form1</string> | 20 | <string>Form1</string> |
21 | </property> | 21 | </property> |
22 | <property> | 22 | <vbox> |
23 | <name>layoutMargin</name> | ||
24 | </property> | ||
25 | <property> | ||
26 | <name>layoutSpacing</name> | ||
27 | </property> | ||
28 | <grid> | ||
29 | <property stdset="1"> | 23 | <property stdset="1"> |
30 | <name>margin</name> | 24 | <name>margin</name> |
31 | <number>4</number> | 25 | <number>0</number> |
32 | </property> | 26 | </property> |
33 | <property stdset="1"> | 27 | <property stdset="1"> |
34 | <name>spacing</name> | 28 | <name>spacing</name> |
35 | <number>2</number> | 29 | <number>0</number> |
36 | </property> | 30 | </property> |
37 | <widget row="0" column="0" > | 31 | <widget> |
38 | <class>QTabWidget</class> | 32 | <class>QTabWidget</class> |
39 | <property stdset="1"> | 33 | <property stdset="1"> |
40 | <name>name</name> | 34 | <name>name</name> |
41 | <cstring>Status</cstring> | 35 | <cstring>Status</cstring> |
42 | </property> | 36 | </property> |
43 | <property> | 37 | <property> |
@@ -373,10 +367,172 @@ | |||
373 | <name>text</name> | 367 | <name>text</name> |
374 | <string>Status Label</string> | 368 | <string>Status Label</string> |
375 | </property> | 369 | </property> |
376 | </widget> | 370 | </widget> |
377 | </vbox> | 371 | </vbox> |
378 | </widget> | 372 | </widget> |
373 | <widget> | ||
374 | <class>QWidget</class> | ||
375 | <property stdset="1"> | ||
376 | <name>name</name> | ||
377 | <cstring>tab</cstring> | ||
378 | </property> | ||
379 | <attribute> | ||
380 | <name>title</name> | ||
381 | <string>Phone</string> | ||
382 | </attribute> | ||
383 | <vbox> | ||
384 | <property stdset="1"> | ||
385 | <name>margin</name> | ||
386 | <number>0</number> | ||
387 | </property> | ||
388 | <property stdset="1"> | ||
389 | <name>spacing</name> | ||
390 | <number>0</number> | ||
391 | </property> | ||
392 | <widget> | ||
393 | <class>QGroupBox</class> | ||
394 | <property stdset="1"> | ||
395 | <name>name</name> | ||
396 | <cstring>cellForwarder</cstring> | ||
397 | </property> | ||
398 | <property stdset="1"> | ||
399 | <name>title</name> | ||
400 | <string>Cell Forwarder</string> | ||
401 | </property> | ||
402 | <vbox> | ||
403 | <property stdset="1"> | ||
404 | <name>margin</name> | ||
405 | <number>11</number> | ||
406 | </property> | ||
407 | <property stdset="1"> | ||
408 | <name>spacing</name> | ||
409 | <number>6</number> | ||
410 | </property> | ||
411 | <widget> | ||
412 | <class>QLayoutWidget</class> | ||
413 | <property stdset="1"> | ||
414 | <name>name</name> | ||
415 | <cstring>Layout9</cstring> | ||
416 | </property> | ||
417 | <vbox> | ||
418 | <property stdset="1"> | ||
419 | <name>margin</name> | ||
420 | <number>0</number> | ||
421 | </property> | ||
422 | <property stdset="1"> | ||
423 | <name>spacing</name> | ||
424 | <number>6</number> | ||
425 | </property> | ||
426 | <widget> | ||
427 | <class>QLayoutWidget</class> | ||
428 | <property stdset="1"> | ||
429 | <name>name</name> | ||
430 | <cstring>Layout5</cstring> | ||
431 | </property> | ||
432 | <hbox> | ||
433 | <property stdset="1"> | ||
434 | <name>margin</name> | ||
435 | <number>0</number> | ||
436 | </property> | ||
437 | <property stdset="1"> | ||
438 | <name>spacing</name> | ||
439 | <number>6</number> | ||
440 | </property> | ||
441 | <widget> | ||
442 | <class>QLabel</class> | ||
443 | <property stdset="1"> | ||
444 | <name>name</name> | ||
445 | <cstring>serDevLabel</cstring> | ||
446 | </property> | ||
447 | <property stdset="1"> | ||
448 | <name>text</name> | ||
449 | <string>Serial device:</string> | ||
450 | </property> | ||
379 | </widget> | 451 | </widget> |
380 | </grid> | 452 | <widget> |
453 | <class>QLineEdit</class> | ||
454 | <property stdset="1"> | ||
455 | <name>name</name> | ||
456 | <cstring>serDevName</cstring> | ||
457 | </property> | ||
458 | </widget> | ||
459 | </hbox> | ||
460 | </widget> | ||
461 | <widget> | ||
462 | <class>QLayoutWidget</class> | ||
463 | <property stdset="1"> | ||
464 | <name>name</name> | ||
465 | <cstring>Layout6</cstring> | ||
466 | </property> | ||
467 | <hbox> | ||
468 | <property stdset="1"> | ||
469 | <name>margin</name> | ||
470 | <number>0</number> | ||
471 | </property> | ||
472 | <property stdset="1"> | ||
473 | <name>spacing</name> | ||
474 | <number>6</number> | ||
475 | </property> | ||
476 | <widget> | ||
477 | <class>QLabel</class> | ||
478 | <property stdset="1"> | ||
479 | <name>name</name> | ||
480 | <cstring>serSpeedLabel</cstring> | ||
481 | </property> | ||
482 | <property stdset="1"> | ||
483 | <name>text</name> | ||
484 | <string>Speed:</string> | ||
485 | </property> | ||
486 | </widget> | ||
487 | <widget> | ||
488 | <class>QComboBox</class> | ||
489 | <property stdset="1"> | ||
490 | <name>name</name> | ||
491 | <cstring>serSpeed</cstring> | ||
492 | </property> | ||
493 | </widget> | ||
494 | </hbox> | ||
381 | </widget> | 495 | </widget> |
496 | <widget> | ||
497 | <class>QPushButton</class> | ||
498 | <property stdset="1"> | ||
499 | <name>name</name> | ||
500 | <cstring>runButton</cstring> | ||
501 | </property> | ||
502 | <property stdset="1"> | ||
503 | <name>text</name> | ||
504 | <string>start gateway</string> | ||
505 | </property> | ||
506 | </widget> | ||
507 | </vbox> | ||
508 | </widget> | ||
509 | </vbox> | ||
510 | </widget> | ||
511 | </vbox> | ||
512 | </widget> | ||
513 | </widget> | ||
514 | </vbox> | ||
515 | </widget> | ||
516 | <customwidgets> | ||
517 | <customwidget> | ||
518 | <class>QWidget</class> | ||
519 | <header location="local">qwidget.h</header> | ||
520 | <sizehint> | ||
521 | <width>100</width> | ||
522 | <height>100</height> | ||
523 | </sizehint> | ||
524 | <container>0</container> | ||
525 | <sizepolicy> | ||
526 | <hordata>7</hordata> | ||
527 | <verdata>7</verdata> | ||
528 | </sizepolicy> | ||
529 | <pixmap>image0</pixmap> | ||
530 | </customwidget> | ||
531 | </customwidgets> | ||
532 | <images> | ||
533 | <image> | ||
534 | <name>image0</name> | ||
535 | <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data> | ||
536 | </image> | ||
537 | </images> | ||
382 | </UI> | 538 | </UI> |