Diffstat (limited to 'noncore/net/opietooth/blue-pin/pindlg.cc') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/opietooth/blue-pin/pindlg.cc | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/noncore/net/opietooth/blue-pin/pindlg.cc b/noncore/net/opietooth/blue-pin/pindlg.cc index 96be1e5..e40fe33 100644 --- a/noncore/net/opietooth/blue-pin/pindlg.cc +++ b/noncore/net/opietooth/blue-pin/pindlg.cc | |||
@@ -6,83 +6,66 @@ | |||
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, | ||
19 | const QString& mac, QWidget* parent, | ||
20 | const char* name ) | ||
21 | : PinDlgBase( parent, name, WType_Modal ) | ||
22 | { | ||
23 | m_mac = mac; | ||
24 | test( mac ); | ||
25 | txtStatus->setText(status); | ||
26 | if(!m_mac.isEmpty()) | ||
27 | QPEApplication::showDialog( this ); | ||
28 | } | ||
29 | |||
30 | PinDlg::PinDlg(QWidget* parent, | 18 | PinDlg::PinDlg(QWidget* parent, |
31 | const char* name, | 19 | const char* name, |
32 | Qt::WFlags f ) | 20 | Qt::WFlags f ) |
33 | : PinDlgBase( parent, name, f ) | 21 | : PinDlgBase( parent, name, f ) |
34 | { | 22 | { |
35 | m_mac = makeMacFromArgs(); | 23 | m_mac = makeMacFromArgs(); |
36 | 24 | ||
37 | if(m_mac.isEmpty()) | 25 | if(m_mac.isEmpty()) |
38 | { | 26 | { |
39 | // can't obtain MAC | 27 | // can't obtain MAC |
40 | printf("ERR\n"); | 28 | printf("ERR\n"); |
41 | qApp->quit(); | 29 | ::exit(0); |
42 | } | 30 | } |
43 | else | 31 | else |
44 | { | 32 | { |
45 | test( m_mac ); | 33 | test( m_mac ); |
46 | txtStatus->setText(makeTextFromArgs()); | 34 | txtStatus->setText(makeTextFromArgs()); |
47 | QPEApplication::showDialog( this ) ; | 35 | QPEApplication::showDialog( this , true) ; |
48 | } | 36 | } |
49 | } | 37 | } |
50 | 38 | ||
51 | PinDlg::~PinDlg() | 39 | PinDlg::~PinDlg() |
52 | {} | 40 | {} |
53 | 41 | ||
54 | void PinDlg::setMac( const QString& mac ) | 42 | void PinDlg::setMac( const QString& mac ) |
55 | { | 43 | { |
56 | txtStatus->setText( mac ); | 44 | txtStatus->setText( mac ); |
57 | } | 45 | } |
58 | 46 | ||
59 | QString PinDlg::pin() const | 47 | QString PinDlg::pin() const |
60 | { | 48 | { |
61 | return lnePin->text(); | 49 | return lnePin->text(); |
62 | } | 50 | } |
63 | 51 | ||
64 | void PinDlg::test( const QString& mac ) | 52 | void PinDlg::test( const QString& mac ) |
65 | { | 53 | { |
66 | if (!mac.isEmpty() ) | 54 | if (!mac.isEmpty() ) |
67 | { | 55 | { |
68 | Config cfg("bluepin"); | 56 | Config cfg("bluepin"); |
69 | cfg.setGroup(mac); | 57 | cfg.setGroup(mac); |
70 | lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); | 58 | lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); |
71 | if ( !lnePin->text().isEmpty() ) | ||
72 | { | ||
73 | //QTimer::singleShot(100, this, SLOT(accept() ) ); | ||
74 | } | ||
75 | } | 59 | } |
76 | |||
77 | } | 60 | } |
78 | 61 | ||
79 | QString PinDlg::makeTextFromArgs() | 62 | QString PinDlg::makeTextFromArgs() |
80 | { | 63 | { |
81 | if(qApp->argc() > 2) | 64 | if(qApp->argc() > 2) |
82 | { | 65 | { |
83 | QCString dir(qApp->argv()[1]) ; | 66 | QCString dir(qApp->argv()[1]) ; |
84 | QCString bdaddr(qApp->argv()[2]) ; | 67 | QCString bdaddr(qApp->argv()[2]) ; |
85 | 68 | ||
86 | QCString name; | 69 | QCString name; |
87 | if ( qApp->argc() > 3 ) { | 70 | if ( qApp->argc() > 3 ) { |
88 | name = qApp->argv()[3]; | 71 | name = qApp->argv()[3]; |
@@ -91,35 +74,36 @@ QString PinDlg::makeTextFromArgs() | |||
91 | if (dir == "out" ) { | 74 | if (dir == "out" ) { |
92 | status = QObject::tr("Outgoing connection to "); | 75 | status = QObject::tr("Outgoing connection to "); |
93 | } else | 76 | } else |
94 | status = QObject::tr("Incoming connection from "); | 77 | status = QObject::tr("Incoming connection from "); |
95 | 78 | ||
96 | status += name; | 79 | status += name; |
97 | status += "<br>"; | 80 | status += "<br>"; |
98 | status += "[" + bdaddr + "]"; | 81 | status += "[" + bdaddr + "]"; |
99 | 82 | ||
100 | return status ; | 83 | return status ; |
101 | } | 84 | } |
102 | else | 85 | else |
103 | return QString(); | 86 | return QString::null; |
104 | } | 87 | } |
105 | 88 | ||
106 | QString PinDlg::makeMacFromArgs() | 89 | QString PinDlg::makeMacFromArgs() |
107 | { | 90 | { |
108 | if(qApp->argc() < 3) | 91 | if(qApp->argc() < 3) |
109 | return QString(); | 92 | return QString::null; |
110 | else | 93 | else |
111 | return qApp->argv()[2] ; | 94 | return qApp->argv()[2] ; |
112 | } | 95 | } |
113 | 96 | ||
114 | void PinDlg::accept() | 97 | void PinDlg::accept() |
115 | { | 98 | { |
116 | if ( ckbPin->isChecked() ) | 99 | if ( ckbPin->isChecked() ) |
117 | { | 100 | { |
118 | Config cfg("bluepin"); | 101 | Config cfg("bluepin"); |
119 | cfg.setGroup(m_mac ); | 102 | cfg.setGroup(m_mac ); |
120 | cfg.writeEntryCrypt("pin", lnePin->text() ); | 103 | cfg.writeEntryCrypt("pin", lnePin->text() ); |
121 | } | 104 | } |
122 | printf("PIN:%s\n", lnePin->text().latin1()); | 105 | printf("PIN:%s\n", lnePin->text().latin1()); |
123 | QDialog::accept(); | 106 | QDialog::accept(); |
124 | qApp->quit(); | 107 | qApp->quit(); |
108 | ::exit(0); | ||
125 | } | 109 | } |