From f6b7d4775710c3e96a2138a39d31e423a6862470 Mon Sep 17 00:00:00 2001 From: codestation Date: Sun, 1 Sep 2013 02:25:03 -0430 Subject: [PATCH] Add registration callback to close the PIN dialog properly. --- clientmanager.cpp | 2 +- cmaclient.cpp | 12 +++++++++++- cmaclient.h | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/clientmanager.cpp b/clientmanager.cpp index a93be90..0d34d35 100644 --- a/clientmanager.cpp +++ b/clientmanager.cpp @@ -82,7 +82,7 @@ void ClientManager::start() connect(wireless_thread, SIGNAL(finished()), this, SLOT(threadStopped())); connect(wireless_thread, SIGNAL(finished()), client, SLOT(deleteLater())); - connect(client, SIGNAL(deviceConnected(QString)), &pinForm, SLOT(hide())); + connect(client, SIGNAL(pinComplete()), &pinForm, SLOT(hide())); connect(client, SIGNAL(deviceConnected(QString)), this, SIGNAL(deviceConnected(QString))); connect(client, SIGNAL(deviceDisconnected()), this, SIGNAL(deviceDisconnected())); connect(client, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase())); diff --git a/cmaclient.cpp b/cmaclient.cpp index 19897d6..a31bf91 100644 --- a/cmaclient.cpp +++ b/cmaclient.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -79,10 +80,13 @@ void CmaClient::connectWireless() wireless_host_info_t host = {NULL, NULL, NULL, QCMA_REQUEST_PORT}; typedef CmaClient CC; + QTime now = QTime::currentTime(); + qsrand(now.msec()); + qDebug() << "Starting wireless_thread:" << QThread::currentThreadId(); do { - if((vita = VitaMTP_Get_First_Wireless_Vita(&host, 0, CC::cancelCallback, CC::deviceRegistered, CC::generatePin)) != NULL) { + if((vita = VitaMTP_Get_First_Wireless_Vita(&host, 0, CC::cancelCallback, CC::deviceRegistered, CC::generatePin, CC::registrationComplete)) != NULL) { processNewConnection(vita); } else { Sleeper::msleep(2000); @@ -125,6 +129,12 @@ void CmaClient::processNewConnection(vita_device_t *device) sema.release(); } +void CmaClient::registrationComplete() +{ + qDebug("Registration completed"); + emit this_object->pinComplete(); +} + int CmaClient::deviceRegistered(const char *deviceid) { qDebug("Got connection request from %s", deviceid); diff --git a/cmaclient.h b/cmaclient.h index b9c45b8..569b4b3 100644 --- a/cmaclient.h +++ b/cmaclient.h @@ -51,6 +51,7 @@ private: static int deviceRegistered(const char *deviceid); static int generatePin(wireless_vita_info_t *info, int *p_err); static int cancelCallback(); + static void registrationComplete(); CmaBroadcast broadcast; @@ -67,6 +68,7 @@ private: signals: void newEvent(vita_event_t event); void receivedPin(QString, int); + void pinComplete(); void deviceDetected(); void deviceConnected(QString); void deviceDisconnected();