Diffstat (limited to 'noncore/net/opietooth/blue-pin/pindlg.cc') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/blue-pin/pindlg.cc | 63 |
1 files changed, 62 insertions, 1 deletions
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 | |||
@@ -20,21 +20,45 @@ PinDlg::PinDlg( const QString& status, | |||
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 ) |
@@ -45,20 +69,57 @@ void PinDlg::test( const QString& mac ) | |||
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 | } |