author | mickeyl <mickeyl> | 2004-07-13 19:34:46 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-07-13 19:34:46 (UTC) |
commit | a309681894af2632f9db2fcc252a058f218a82b2 (patch) (unidiff) | |
tree | ea4e36b019cdc25c1043e5e3d000fbaacca71596 | |
parent | 03930fa4871365efb6438b74b3a68f8f06aa7e4f (diff) | |
download | opie-a309681894af2632f9db2fcc252a058f218a82b2.zip opie-a309681894af2632f9db2fcc252a058f218a82b2.tar.gz opie-a309681894af2632f9db2fcc252a058f218a82b2.tar.bz2 |
convert blue-pin to be quicklaunchable. patch courtesy Thomas Themel.
-rw-r--r-- | noncore/net/opietooth/blue-pin/main.cc | 3 | ||||
-rw-r--r-- | noncore/net/opietooth/blue-pin/pindlg.cc | 63 | ||||
-rw-r--r-- | noncore/net/opietooth/blue-pin/pindlg.h | 15 |
3 files changed, 78 insertions, 3 deletions
diff --git a/noncore/net/opietooth/blue-pin/main.cc b/noncore/net/opietooth/blue-pin/main.cc index aa360aa..29e46ae 100644 --- a/noncore/net/opietooth/blue-pin/main.cc +++ b/noncore/net/opietooth/blue-pin/main.cc | |||
@@ -1,38 +1,41 @@ | |||
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <stdlib.h> | 2 | #include <stdlib.h> |
3 | 3 | ||
4 | 4 | ||
5 | #include <qpe/qpeapplication.h> | 5 | #include <qpe/qpeapplication.h> |
6 | #include <opie2/oapplicationfactory.h> | ||
6 | 7 | ||
7 | #include "pindlg.h" | 8 | #include "pindlg.h" |
8 | 9 | ||
10 | using namespace Opie::Core; | ||
11 | OPIE_EXPORT_APP( OApplicationFactory<OpieTooth::PinDlg> ) | ||
9 | 12 | ||
10 | int main( int argc, char* argv[] ) | 13 | int main( int argc, char* argv[] ) |
11 | { | 14 | { |
12 | if (argc < 2 ) { | 15 | if (argc < 2 ) { |
13 | printf("ERR\n"); | 16 | printf("ERR\n"); |
14 | exit(0); | 17 | exit(0); |
15 | } | 18 | } |
16 | QCString dir(argv[1] ); | 19 | QCString dir(argv[1] ); |
17 | QCString bdaddr( argv[2] ); | 20 | QCString bdaddr( argv[2] ); |
18 | QCString name; | 21 | QCString name; |
19 | if ( argc > 3 ) { | 22 | if ( argc > 3 ) { |
20 | name = argv[3]; | 23 | name = argv[3]; |
21 | } | 24 | } |
22 | QPEApplication a(argc, argv ); | 25 | QPEApplication a(argc, argv ); |
23 | QString status; | 26 | QString status; |
24 | if (dir == "out" ) { | 27 | if (dir == "out" ) { |
25 | status = QObject::tr("Outgoing connection to "); | 28 | status = QObject::tr("Outgoing connection to "); |
26 | }else | 29 | }else |
27 | status = QObject::tr("Incoming connection from "); | 30 | status = QObject::tr("Incoming connection from "); |
28 | status += name; | 31 | status += name; |
29 | status += "<br>"; | 32 | status += "<br>"; |
30 | status += "[" + bdaddr + "]"; | 33 | status += "[" + bdaddr + "]"; |
31 | OpieTooth::PinDlg dlg( status, bdaddr ); | 34 | OpieTooth::PinDlg dlg( status, bdaddr ); |
32 | if ( dlg.exec() ) { | 35 | if ( dlg.exec() ) { |
33 | printf("PIN:%s\n", dlg.pin().stripWhiteSpace().latin1() ); | 36 | printf("PIN:%s\n", dlg.pin().stripWhiteSpace().latin1() ); |
34 | }else | 37 | }else |
35 | printf("ERR\n"); | 38 | printf("ERR\n"); |
36 | return 0; | 39 | return 0; |
37 | } | 40 | } |
38 | 41 | ||
diff --git a/noncore/net/opietooth/blue-pin/pindlg.cc b/noncore/net/opietooth/blue-pin/pindlg.cc index f0b2309..96be1e5 100644 --- a/noncore/net/opietooth/blue-pin/pindlg.cc +++ b/noncore/net/opietooth/blue-pin/pindlg.cc | |||
@@ -1,64 +1,125 @@ | |||
1 | 1 | ||
2 | #include "pindlg.h" | 2 | #include "pindlg.h" |
3 | 3 | ||
4 | /* OPIE */ | 4 | /* OPIE */ |
5 | #include <qpe/config.h> | 5 | #include <qpe/config.h> |
6 | #include <qpe/qpeapplication.h> | 6 | #include <qpe/qpeapplication.h> |
7 | 7 | ||
8 | /* QT */ | 8 | /* QT */ |
9 | #include <qcheckbox.h> | 9 | #include <qcheckbox.h> |
10 | #include <qlabel.h> | 10 | #include <qlabel.h> |
11 | #include <qlineedit.h> | 11 | #include <qlineedit.h> |
12 | 12 | ||
13 | /* STD */ | 13 | /* STD */ |
14 | #include <stdio.h> | 14 | #include <stdio.h> |
15 | 15 | ||
16 | using namespace OpieTooth; | 16 | using namespace OpieTooth; |
17 | 17 | ||
18 | PinDlg::PinDlg( const QString& status, | 18 | PinDlg::PinDlg( const QString& status, |
19 | const QString& mac, QWidget* parent, | 19 | const QString& mac, QWidget* parent, |
20 | const char* name ) | 20 | const char* name ) |
21 | : PinDlgBase( parent, name, WType_Modal ) | 21 | : PinDlgBase( parent, name, WType_Modal ) |
22 | { | 22 | { |
23 | m_mac = mac; | 23 | m_mac = mac; |
24 | test( mac ); | 24 | test( mac ); |
25 | txtStatus->setText(status); | 25 | txtStatus->setText(status); |
26 | QPEApplication::showDialog( this ); | 26 | if(!m_mac.isEmpty()) |
27 | QPEApplication::showDialog( this ); | ||
28 | } | ||
29 | |||
30 | PinDlg::PinDlg(QWidget* parent, | ||
31 | const char* name, | ||
32 | Qt::WFlags f ) | ||
33 | : PinDlgBase( parent, name, f ) | ||
34 | { | ||
35 | m_mac = makeMacFromArgs(); | ||
36 | |||
37 | if(m_mac.isEmpty()) | ||
38 | { | ||
39 | // can't obtain MAC | ||
40 | printf("ERR\n"); | ||
41 | qApp->quit(); | ||
42 | } | ||
43 | else | ||
44 | { | ||
45 | test( m_mac ); | ||
46 | txtStatus->setText(makeTextFromArgs()); | ||
47 | QPEApplication::showDialog( this ) ; | ||
48 | } | ||
27 | } | 49 | } |
28 | 50 | ||
29 | PinDlg::~PinDlg() | 51 | PinDlg::~PinDlg() |
30 | {} | 52 | {} |
53 | |||
31 | void PinDlg::setMac( const QString& mac ) | 54 | void PinDlg::setMac( const QString& mac ) |
32 | { | 55 | { |
33 | txtStatus->setText( mac ); | 56 | txtStatus->setText( mac ); |
34 | } | 57 | } |
58 | |||
35 | QString PinDlg::pin() const | 59 | QString PinDlg::pin() const |
36 | { | 60 | { |
37 | return lnePin->text(); | 61 | return lnePin->text(); |
38 | } | 62 | } |
39 | 63 | ||
40 | void PinDlg::test( const QString& mac ) | 64 | void PinDlg::test( const QString& mac ) |
41 | { | 65 | { |
42 | if (!mac.isEmpty() ) | 66 | if (!mac.isEmpty() ) |
43 | { | 67 | { |
44 | Config cfg("bluepin"); | 68 | Config cfg("bluepin"); |
45 | cfg.setGroup(mac); | 69 | cfg.setGroup(mac); |
46 | lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); | 70 | lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); |
47 | if ( !lnePin->text().isEmpty() ) | 71 | if ( !lnePin->text().isEmpty() ) |
48 | { | 72 | { |
49 | //QTimer::singleShot(100, this, SLOT(accept() ) ); | 73 | //QTimer::singleShot(100, this, SLOT(accept() ) ); |
50 | } | 74 | } |
75 | } | ||
76 | |||
77 | } | ||
78 | |||
79 | QString PinDlg::makeTextFromArgs() | ||
80 | { | ||
81 | if(qApp->argc() > 2) | ||
82 | { | ||
83 | QCString dir(qApp->argv()[1]) ; | ||
84 | QCString bdaddr(qApp->argv()[2]) ; | ||
85 | |||
86 | QCString name; | ||
87 | if ( qApp->argc() > 3 ) { | ||
88 | name = qApp->argv()[3]; | ||
89 | } | ||
90 | QString status; | ||
91 | if (dir == "out" ) { | ||
92 | status = QObject::tr("Outgoing connection to "); | ||
93 | } else | ||
94 | status = QObject::tr("Incoming connection from "); | ||
51 | 95 | ||
96 | status += name; | ||
97 | status += "<br>"; | ||
98 | status += "[" + bdaddr + "]"; | ||
99 | |||
100 | return status ; | ||
52 | } | 101 | } |
102 | else | ||
103 | return QString(); | ||
104 | } | ||
53 | 105 | ||
106 | QString PinDlg::makeMacFromArgs() | ||
107 | { | ||
108 | if(qApp->argc() < 3) | ||
109 | return QString(); | ||
110 | else | ||
111 | return qApp->argv()[2] ; | ||
54 | } | 112 | } |
113 | |||
55 | void PinDlg::accept() | 114 | void PinDlg::accept() |
56 | { | 115 | { |
57 | if ( ckbPin->isChecked() ) | 116 | if ( ckbPin->isChecked() ) |
58 | { | 117 | { |
59 | Config cfg("bluepin"); | 118 | Config cfg("bluepin"); |
60 | cfg.setGroup(m_mac ); | 119 | cfg.setGroup(m_mac ); |
61 | cfg.writeEntryCrypt("pin", lnePin->text() ); | 120 | cfg.writeEntryCrypt("pin", lnePin->text() ); |
62 | } | 121 | } |
122 | printf("PIN:%s\n", lnePin->text().latin1()); | ||
63 | QDialog::accept(); | 123 | QDialog::accept(); |
124 | qApp->quit(); | ||
64 | } | 125 | } |
diff --git a/noncore/net/opietooth/blue-pin/pindlg.h b/noncore/net/opietooth/blue-pin/pindlg.h index 5e5a763..5f7dc55 100644 --- a/noncore/net/opietooth/blue-pin/pindlg.h +++ b/noncore/net/opietooth/blue-pin/pindlg.h | |||
@@ -1,29 +1,40 @@ | |||
1 | 1 | ||
2 | 2 | ||
3 | #include <qdialog.h> | 3 | #include <qdialog.h> |
4 | #include "pindlgbase.h" | 4 | #include "pindlgbase.h" |
5 | 5 | ||
6 | namespace OpieTooth { | 6 | namespace OpieTooth { |
7 | 7 | ||
8 | class PinDlg : public PinDlgBase { | 8 | class PinDlg : public PinDlgBase { |
9 | 9 | ||
10 | Q_OBJECT | 10 | Q_OBJECT |
11 | 11 | ||
12 | public: | 12 | public: |
13 | PinDlg(const QString& text, | 13 | PinDlg(const QString& text="", |
14 | const QString& mac, | 14 | const QString& mac="", |
15 | QWidget* parent = 0, | 15 | QWidget* parent = 0, |
16 | const char* name= 0 ); | 16 | const char* name= 0 ); |
17 | |||
18 | PinDlg(QWidget* parent, | ||
19 | const char* name, | ||
20 | Qt::WFlags f ); | ||
21 | |||
17 | ~PinDlg(); | 22 | ~PinDlg(); |
18 | void setMac( const QString& ); | 23 | void setMac( const QString& ); |
19 | QString pin() const; | 24 | QString pin() const; |
25 | |||
26 | static QString appName() { return QString::fromLatin1("bluepin") ; } | ||
20 | 27 | ||
21 | private: | 28 | private: |
22 | void test( const QString& mac ); | 29 | void test( const QString& mac ); |
30 | |||
31 | QString makeTextFromArgs(); | ||
32 | QString makeMacFromArgs(); | ||
33 | |||
23 | QString m_mac; | 34 | QString m_mac; |
24 | 35 | ||
25 | protected slots: | 36 | protected slots: |
26 | void accept(); | 37 | void accept(); |
27 | 38 | ||
28 | }; | 39 | }; |
29 | }; | 40 | }; |