summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-05-06 19:19:00 (UTC)
committer korovkin <korovkin>2006-05-06 19:19:00 (UTC)
commitdc719be35432469c24dd8d10136c1ea25c6861d2 (patch) (unidiff)
tree6b4e970c2118a695a89ee4c46ac16fc68ec3bf4f
parent2d9247d6c2917fd967d0d01d4d9aa6de4fb820f1 (diff)
downloadopie-dc719be35432469c24dd8d10136c1ea25c6861d2.zip
opie-dc719be35432469c24dd8d10136c1ea25c6861d2.tar.gz
opie-dc719be35432469c24dd8d10136c1ea25c6861d2.tar.bz2
Added reject function to a Cancel button.
Added "AC" == "Backspace" button.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/blue-pin/pindlg.cc22
-rw-r--r--noncore/net/opietooth/blue-pin/pindlg.h5
2 files changed, 25 insertions, 2 deletions
diff --git a/noncore/net/opietooth/blue-pin/pindlg.cc b/noncore/net/opietooth/blue-pin/pindlg.cc
index 3db6095..b03ae7d 100644
--- a/noncore/net/opietooth/blue-pin/pindlg.cc
+++ b/noncore/net/opietooth/blue-pin/pindlg.cc
@@ -1,119 +1,141 @@
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#include <qpushbutton.h> 12#include <qpushbutton.h>
13 13
14/* STD */ 14/* STD */
15#include <stdio.h> 15#include <stdio.h>
16 16
17using namespace OpieTooth; 17using namespace OpieTooth;
18 18
19PinDlg::PinDlg(QWidget* parent, 19PinDlg::PinDlg(QWidget* parent,
20 const char* name, 20 const char* name,
21 Qt::WFlags f ) 21 Qt::WFlags f )
22 : PinDlgBase( parent, name, f ) 22 : PinDlgBase( parent, name, f )
23{ 23{
24 m_mac = makeMacFromArgs(); 24 m_mac = makeMacFromArgs();
25 25
26 if(m_mac.isEmpty()) 26 if(m_mac.isEmpty())
27 { 27 {
28 // can't obtain MAC 28 // can't obtain MAC
29 printf("ERR\n"); 29 printf("ERR\n");
30 ::exit(0); 30 ::exit(0);
31 } 31 }
32 else 32 else
33 { 33 {
34 test( m_mac ); 34 test( m_mac );
35 txtStatus->setText(makeTextFromArgs()); 35 txtStatus->setText(makeTextFromArgs());
36 QPEApplication::showDialog( this , false) ; 36 QPEApplication::showDialog( this , false) ;
37 } 37 }
38} 38}
39 39
40PinDlg::~PinDlg() 40PinDlg::~PinDlg()
41{} 41{}
42 42
43void PinDlg::setMac( const QString& mac ) 43void PinDlg::setMac( const QString& mac )
44{ 44{
45 txtStatus->setText( mac ); 45 txtStatus->setText( mac );
46} 46}
47 47
48QString PinDlg::pin() const 48QString PinDlg::pin() const
49{ 49{
50 return lnePin->text(); 50 return lnePin->text();
51} 51}
52 52
53void PinDlg::test( const QString& mac ) 53void PinDlg::test( const QString& mac )
54{ 54{
55 if (!mac.isEmpty() ) 55 if (!mac.isEmpty() )
56 { 56 {
57 Config cfg("bluepin"); 57 Config cfg("bluepin");
58 cfg.setGroup(mac); 58 cfg.setGroup(mac);
59 lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) ); 59 lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) );
60 } 60 }
61} 61}
62 62
63QString PinDlg::makeTextFromArgs() 63QString PinDlg::makeTextFromArgs()
64{ 64{
65 if(qApp->argc() > 2) 65 if(qApp->argc() > 2)
66 { 66 {
67 QCString dir(qApp->argv()[1]) ; 67 QCString dir(qApp->argv()[1]) ;
68 QCString bdaddr(qApp->argv()[2]) ; 68 QCString bdaddr(qApp->argv()[2]) ;
69 69
70 QCString name; 70 QCString name;
71 if ( qApp->argc() > 3 ) { 71 if ( qApp->argc() > 3 ) {
72 name = qApp->argv()[3]; 72 name = qApp->argv()[3];
73 } 73 }
74 QString status; 74 QString status;
75 if (dir == "out" ) { 75 if (dir == "out" ) {
76 status = QObject::tr("Outgoing connection to "); 76 status = QObject::tr("Outgoing connection to ");
77 } else 77 } else
78 status = QObject::tr("Incoming connection from "); 78 status = QObject::tr("Incoming connection from ");
79 79
80 status += name; 80 status += name;
81 status += "<br>"; 81 status += "<br>";
82 status += "[" + bdaddr + "]"; 82 status += "[" + bdaddr + "]";
83 83
84 return status ; 84 return status ;
85 } 85 }
86 else 86 else
87 return QString::null; 87 return QString::null;
88} 88}
89 89
90QString PinDlg::makeMacFromArgs() 90QString PinDlg::makeMacFromArgs()
91{ 91{
92 if(qApp->argc() < 3) 92 if(qApp->argc() < 3)
93 return QString::null; 93 return QString::null;
94 else 94 else
95 return qApp->argv()[2] ; 95 return qApp->argv()[2] ;
96} 96}
97 97
98/*
99 * Add a number to the PIN number
100 */
98void PinDlg::addnum() 101void PinDlg::addnum()
99{ 102{
100 if( sender()->inherits( "QPushButton") ) { 103 if( sender()->inherits( "QPushButton") ) {
101 const QPushButton* btn = static_cast<const QPushButton*> (sender()); 104 const QPushButton* btn = static_cast<const QPushButton*> (sender());
102 lnePin->setText(lnePin->text() + btn->text()); 105 lnePin->setText(lnePin->text() + btn->text());
103 } 106 }
104} 107}
105 108
109/*
110 * Delete a number from the end of the line
111 */
112void PinDlg::delnum()
113{
114 if( sender()->inherits( "QPushButton") ) {
115 const QPushButton* btn = static_cast<const QPushButton*> (sender());
116 lnePin->setText(lnePin->text().remove(lnePin->text().length() - 1, 1));
117 }
118}
119
106void PinDlg::accept() 120void PinDlg::accept()
107{ 121{
108 if ( ckbPin->isChecked() ) 122 if ( ckbPin->isChecked() )
109 { 123 {
110 Config cfg("bluepin"); 124 Config cfg("bluepin");
111 cfg.setGroup(m_mac ); 125 cfg.setGroup(m_mac );
112 cfg.writeEntryCrypt("pin", lnePin->text() ); 126 cfg.writeEntryCrypt("pin", lnePin->text() );
113 } 127 }
114 printf("PIN:%s\n", lnePin->text().latin1()); 128 printf("PIN:%s\n", lnePin->text().latin1());
115 QDialog::accept(); 129 QDialog::accept();
116 qApp->quit(); 130 qApp->quit();
117 ::exit(0); 131 ::exit(0);
118} 132}
119 133
134void PinDlg::reject()
135{
136 printf("ERR\n");
137 QDialog::reject();
138 qApp->quit();
139 ::exit(0);
140}
141
diff --git a/noncore/net/opietooth/blue-pin/pindlg.h b/noncore/net/opietooth/blue-pin/pindlg.h
index 1817aa8..8557010 100644
--- a/noncore/net/opietooth/blue-pin/pindlg.h
+++ b/noncore/net/opietooth/blue-pin/pindlg.h
@@ -1,34 +1,35 @@
1 1
2 2
3#include <qdialog.h> 3#include <qdialog.h>
4#include "pindlgbase.h" 4#include "pindlgbase.h"
5 5
6namespace OpieTooth { 6namespace 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(QWidget* parent = 0,const char* name = 0, Qt::WFlags f = 0); 13 PinDlg(QWidget* parent = 0,const char* name = 0, Qt::WFlags f = 0);
14 14
15 ~PinDlg(); 15 ~PinDlg();
16 void setMac( const QString& ); 16 void setMac( const QString& );
17 QString pin() const; 17 QString pin() const;
18 18
19 static QString appName() { return QString::fromLatin1("bluepin") ; } 19 static QString appName() { return QString::fromLatin1("bluepin") ; }
20 20
21 private: 21 private:
22 void test( const QString& mac ); 22 void test( const QString& mac );
23 23
24 QString makeTextFromArgs(); 24 QString makeTextFromArgs();
25 QString makeMacFromArgs(); 25 QString makeMacFromArgs();
26 26
27 QString m_mac; 27 QString m_mac;
28 28
29 protected slots: 29 protected slots:
30 void accept(); 30 void accept();
31 void addnum(); 31 void reject();
32 32 void addnum();
33 void delnum();
33 }; 34 };
34}; 35};