summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-07-13 19:34:46 (UTC)
committer mickeyl <mickeyl>2004-07-13 19:34:46 (UTC)
commita309681894af2632f9db2fcc252a058f218a82b2 (patch) (side-by-side diff)
treeea4e36b019cdc25c1043e5e3d000fbaacca71596
parent03930fa4871365efb6438b74b3a68f8f06aa7e4f (diff)
downloadopie-a309681894af2632f9db2fcc252a058f218a82b2.zip
opie-a309681894af2632f9db2fcc252a058f218a82b2.tar.gz
opie-a309681894af2632f9db2fcc252a058f218a82b2.tar.bz2
convert blue-pin to be quicklaunchable. patch courtesy Thomas Themel.
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/net/opietooth/blue-pin/main.cc3
-rw-r--r--noncore/net/opietooth/blue-pin/pindlg.cc61
-rw-r--r--noncore/net/opietooth/blue-pin/pindlg.h15
3 files changed, 77 insertions, 2 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,24 +1,27 @@
#include <stdio.h>
#include <stdlib.h>
#include <qpe/qpeapplication.h>
+#include <opie2/oapplicationfactory.h>
#include "pindlg.h"
+using namespace Opie::Core;
+OPIE_EXPORT_APP( OApplicationFactory<OpieTooth::PinDlg> )
int main( int argc, char* argv[] )
{
if (argc < 2 ) {
printf("ERR\n");
exit(0);
}
QCString dir(argv[1] );
QCString bdaddr( argv[2] );
QCString name;
if ( argc > 3 ) {
name = argv[3];
}
QPEApplication a(argc, argv );
QString status;
if (dir == "out" ) {
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
@@ -10,55 +10,116 @@
#include <qlabel.h>
#include <qlineedit.h>
/* STD */
#include <stdio.h>
using namespace OpieTooth;
PinDlg::PinDlg( const QString& status,
const QString& mac, QWidget* parent,
const char* name )
: PinDlgBase( parent, name, WType_Modal )
{
m_mac = mac;
test( mac );
txtStatus->setText(status);
+ if(!m_mac.isEmpty())
QPEApplication::showDialog( this );
}
+PinDlg::PinDlg(QWidget* parent,
+ const char* name,
+ Qt::WFlags f )
+ : PinDlgBase( parent, name, f )
+{
+ m_mac = makeMacFromArgs();
+
+ if(m_mac.isEmpty())
+ {
+ // can't obtain MAC
+ printf("ERR\n");
+ qApp->quit();
+ }
+ else
+ {
+ test( m_mac );
+ txtStatus->setText(makeTextFromArgs());
+ QPEApplication::showDialog( this ) ;
+ }
+}
+
PinDlg::~PinDlg()
{}
+
void PinDlg::setMac( const QString& mac )
{
txtStatus->setText( mac );
}
+
QString PinDlg::pin() const
{
return lnePin->text();
}
void PinDlg::test( const QString& mac )
{
if (!mac.isEmpty() )
{
Config cfg("bluepin");
cfg.setGroup(mac);
lnePin->setText(cfg.readEntryCrypt("pin", QString::null ) );
if ( !lnePin->text().isEmpty() )
{
//QTimer::singleShot(100, this, SLOT(accept() ) );
}
+ }
}
+QString PinDlg::makeTextFromArgs()
+{
+ if(qApp->argc() > 2)
+ {
+ QCString dir(qApp->argv()[1]) ;
+ QCString bdaddr(qApp->argv()[2]) ;
+
+ QCString name;
+ if ( qApp->argc() > 3 ) {
+ name = qApp->argv()[3];
+ }
+ QString status;
+ if (dir == "out" ) {
+ status = QObject::tr("Outgoing connection to ");
+ } else
+ status = QObject::tr("Incoming connection from ");
+
+ status += name;
+ status += "<br>";
+ status += "[" + bdaddr + "]";
+
+ return status ;
}
+ else
+ return QString();
+}
+
+QString PinDlg::makeMacFromArgs()
+{
+ if(qApp->argc() < 3)
+ return QString();
+ else
+ return qApp->argv()[2] ;
+}
+
void PinDlg::accept()
{
if ( ckbPin->isChecked() )
{
Config cfg("bluepin");
cfg.setGroup(m_mac );
cfg.writeEntryCrypt("pin", lnePin->text() );
}
+ printf("PIN:%s\n", lnePin->text().latin1());
QDialog::accept();
+ qApp->quit();
}
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 @@
#include <qdialog.h>
#include "pindlgbase.h"
namespace OpieTooth {
class PinDlg : public PinDlgBase {
Q_OBJECT
public:
- PinDlg(const QString& text,
- const QString& mac,
+ PinDlg(const QString& text="",
+ const QString& mac="",
QWidget* parent = 0,
const char* name= 0 );
+
+ PinDlg(QWidget* parent,
+ const char* name,
+ Qt::WFlags f );
+
~PinDlg();
void setMac( const QString& );
QString pin() const;
+ static QString appName() { return QString::fromLatin1("bluepin") ; }
+
private:
void test( const QString& mac );
+
+ QString makeTextFromArgs();
+ QString makeMacFromArgs();
+
QString m_mac;
protected slots:
void accept();
};
};