Remove wireless disconnect callback.
Make an interruptable sleep so the USB connection can be aborted more quickly. Updated translations.
This commit is contained in:
		@@ -1,6 +1,6 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<!DOCTYPE TS>
 | 
			
		||||
<TS version="2.0" language="es_ES">
 | 
			
		||||
<TS version="2.1" language="es_ES">
 | 
			
		||||
<context>
 | 
			
		||||
    <name>BackupItem</name>
 | 
			
		||||
    <message>
 | 
			
		||||
@@ -73,7 +73,7 @@
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/forms/backupmanagerform.ui" line="122"/>
 | 
			
		||||
        <location filename="../../src/forms/backupmanagerform.cpp" line="230"/>
 | 
			
		||||
        <location filename="../../src/forms/backupmanagerform.cpp" line="231"/>
 | 
			
		||||
        <source>Filter</source>
 | 
			
		||||
        <translation>Filtro</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
@@ -93,7 +93,7 @@
 | 
			
		||||
        <translation>Uso de disco en respaldos: %1</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/forms/backupmanagerform.cpp" line="197"/>
 | 
			
		||||
        <location filename="../../src/forms/backupmanagerform.cpp" line="198"/>
 | 
			
		||||
        <source> - (Launcher only)</source>
 | 
			
		||||
        <translation> - (Solo lanzador LiveArea)</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
@@ -120,12 +120,12 @@
 | 
			
		||||
        <translation>No se pudo inicializar VitaMTP</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/clientmanager.cpp" line="112"/>
 | 
			
		||||
        <location filename="../../src/clientmanager.cpp" line="114"/>
 | 
			
		||||
        <source>Cannot refresh the database while is in use</source>
 | 
			
		||||
        <translation>No se puede actualizar la base de datos mientras se encuentre en uso</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/clientmanager.cpp" line="114"/>
 | 
			
		||||
        <location filename="../../src/clientmanager.cpp" line="116"/>
 | 
			
		||||
        <source>No PS Vita system has been registered</source>
 | 
			
		||||
        <translation>Nigún sistema PS Vita ha sido registrado</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
@@ -137,8 +137,8 @@
 | 
			
		||||
        <translation type="obsolete">Conectado a </translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/cmaclient.cpp" line="127"/>
 | 
			
		||||
        <location filename="../../src/cmaclient.cpp" line="130"/>
 | 
			
		||||
        <location filename="../../src/cmaclient.cpp" line="135"/>
 | 
			
		||||
        <location filename="../../src/cmaclient.cpp" line="138"/>
 | 
			
		||||
        <source>Connected to %1 (PS Vita)</source>
 | 
			
		||||
        <translation>Conectado a %1 (PS Vita)</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
@@ -330,9 +330,13 @@
 | 
			
		||||
        <translation>Cerrando...</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/mainwidget.cpp" line="80"/>
 | 
			
		||||
        <source>Stopping QCMA...</source>
 | 
			
		||||
        <translation>Deteniendo QCMA...</translation>
 | 
			
		||||
        <translation type="obsolete">Deteniendo QCMA...</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/mainwidget.cpp" line="80"/>
 | 
			
		||||
        <source>Stopping QCMA (disconnect your PS Vita)</source>
 | 
			
		||||
        <translation>Deteniendo QCMA (desconecte su PS Vita)</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/mainwidget.cpp" line="96"/>
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,6 @@
 | 
			
		||||
<?xml version="1.0" encoding="utf-8"?>
 | 
			
		||||
<!DOCTYPE TS>
 | 
			
		||||
<TS version="2.0" language="ja_JP">
 | 
			
		||||
<TS version="2.1" language="ja_JP">
 | 
			
		||||
<context>
 | 
			
		||||
    <name>BackupItem</name>
 | 
			
		||||
    <message>
 | 
			
		||||
@@ -73,7 +73,7 @@
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/forms/backupmanagerform.ui" line="122"/>
 | 
			
		||||
        <location filename="../../src/forms/backupmanagerform.cpp" line="230"/>
 | 
			
		||||
        <location filename="../../src/forms/backupmanagerform.cpp" line="231"/>
 | 
			
		||||
        <source>Filter</source>
 | 
			
		||||
        <translation type="unfinished"></translation>
 | 
			
		||||
    </message>
 | 
			
		||||
@@ -93,7 +93,7 @@
 | 
			
		||||
        <translation>バックアップディスク使用容量: %1</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/forms/backupmanagerform.cpp" line="197"/>
 | 
			
		||||
        <location filename="../../src/forms/backupmanagerform.cpp" line="198"/>
 | 
			
		||||
        <source> - (Launcher only)</source>
 | 
			
		||||
        <translation> - (LiveArea専用)</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
@@ -120,12 +120,12 @@
 | 
			
		||||
        <translation type="unfinished"></translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/clientmanager.cpp" line="112"/>
 | 
			
		||||
        <location filename="../../src/clientmanager.cpp" line="114"/>
 | 
			
		||||
        <source>Cannot refresh the database while is in use</source>
 | 
			
		||||
        <translation>使用中にはデータベースを更新できません</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/clientmanager.cpp" line="114"/>
 | 
			
		||||
        <location filename="../../src/clientmanager.cpp" line="116"/>
 | 
			
		||||
        <source>No PS Vita system has been registered</source>
 | 
			
		||||
        <translation type="unfinished"></translation>
 | 
			
		||||
    </message>
 | 
			
		||||
@@ -137,8 +137,8 @@
 | 
			
		||||
        <translation type="obsolete">次のデバイスに接続しました </translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/cmaclient.cpp" line="127"/>
 | 
			
		||||
        <location filename="../../src/cmaclient.cpp" line="130"/>
 | 
			
		||||
        <location filename="../../src/cmaclient.cpp" line="135"/>
 | 
			
		||||
        <location filename="../../src/cmaclient.cpp" line="138"/>
 | 
			
		||||
        <source>Connected to %1 (PS Vita)</source>
 | 
			
		||||
        <translation type="unfinished"></translation>
 | 
			
		||||
    </message>
 | 
			
		||||
@@ -331,9 +331,13 @@
 | 
			
		||||
        <translation>終了しています...</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/mainwidget.cpp" line="80"/>
 | 
			
		||||
        <source>Stopping QCMA...</source>
 | 
			
		||||
        <translation>QCMAを停止しています...</translation>
 | 
			
		||||
        <translation type="obsolete">QCMAを停止しています...</translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/mainwidget.cpp" line="80"/>
 | 
			
		||||
        <source>Stopping QCMA (disconnect your PS Vita)</source>
 | 
			
		||||
        <translation type="unfinished"></translation>
 | 
			
		||||
    </message>
 | 
			
		||||
    <message>
 | 
			
		||||
        <location filename="../../src/mainwidget.cpp" line="96"/>
 | 
			
		||||
 
 | 
			
		||||
@@ -65,7 +65,7 @@ void ClientManager::start()
 | 
			
		||||
    connect(&db, SIGNAL(updated(int)), this, SLOT(databaseUpdated(int)));
 | 
			
		||||
    connect(&progress, SIGNAL(canceled()), &db, SLOT(cancelOperation()), Qt::DirectConnection);
 | 
			
		||||
 | 
			
		||||
    thread_count = 2;
 | 
			
		||||
    thread_count = 0;
 | 
			
		||||
    qDebug("Starting cma threads");
 | 
			
		||||
    CmaClient *client;
 | 
			
		||||
 | 
			
		||||
@@ -84,6 +84,7 @@ void ClientManager::start()
 | 
			
		||||
 | 
			
		||||
    client->moveToThread(usb_thread);
 | 
			
		||||
    usb_thread->start();
 | 
			
		||||
    thread_count++;
 | 
			
		||||
 | 
			
		||||
    wireless_thread = new QThread();
 | 
			
		||||
    client = new CmaClient();
 | 
			
		||||
@@ -102,6 +103,7 @@ void ClientManager::start()
 | 
			
		||||
 | 
			
		||||
    client->moveToThread(wireless_thread);
 | 
			
		||||
    wireless_thread->start();
 | 
			
		||||
    thread_count++;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ClientManager::refreshDatabase()
 | 
			
		||||
 
 | 
			
		||||
@@ -34,14 +34,14 @@
 | 
			
		||||
 | 
			
		||||
QMutex CmaClient::mutex;
 | 
			
		||||
QMutex CmaClient::runner;
 | 
			
		||||
QMutex CmaClient::cancel;
 | 
			
		||||
QWaitCondition CmaClient::usbcondition;
 | 
			
		||||
QMutex CmaClient::usbwait;
 | 
			
		||||
QSemaphore CmaClient::sema;
 | 
			
		||||
 | 
			
		||||
QString CmaClient::tempOnlineId = QString();
 | 
			
		||||
 | 
			
		||||
bool CmaClient::is_active = false;
 | 
			
		||||
bool CmaClient::in_progress = false;
 | 
			
		||||
int CmaClient::is_cancelled = false;
 | 
			
		||||
 | 
			
		||||
CmaClient *CmaClient::this_object = NULL;
 | 
			
		||||
 | 
			
		||||
@@ -58,13 +58,14 @@ void CmaClient::connectUsb()
 | 
			
		||||
    qDebug("Starting usb_thread: 0x%016" PRIxPTR, (uintptr_t)QThread::currentThreadId());
 | 
			
		||||
 | 
			
		||||
    setActive(true);
 | 
			
		||||
    usbwait.lock();
 | 
			
		||||
 | 
			
		||||
    do {
 | 
			
		||||
        if((vita = VitaMTP_Get_First_USB_Vita()) !=NULL) {
 | 
			
		||||
            processNewConnection(vita);
 | 
			
		||||
        } else {
 | 
			
		||||
            //TODO: replace this with an event-driven setup
 | 
			
		||||
            Sleeper::msleep(2000);
 | 
			
		||||
            usbcondition.wait(&usbwait, 2000);
 | 
			
		||||
            mutex.lock();
 | 
			
		||||
            if(in_progress) {
 | 
			
		||||
                sema.acquire();
 | 
			
		||||
@@ -91,15 +92,22 @@ void CmaClient::connectWireless()
 | 
			
		||||
    setActive(true);
 | 
			
		||||
 | 
			
		||||
    do {
 | 
			
		||||
        if((vita = VitaMTP_Get_First_Wireless_Vita(&host, 0, CC::cancelCallback, CC::deviceRegistered, CC::generatePin, CC::registrationComplete)) != NULL) {
 | 
			
		||||
        if((vita = VitaMTP_Get_First_Wireless_Vita(&host, 0, CC::deviceRegistered, CC::generatePin, CC::registrationComplete)) != NULL) {
 | 
			
		||||
            processNewConnection(vita);
 | 
			
		||||
        } else {
 | 
			
		||||
            Sleeper::msleep(2000);
 | 
			
		||||
            mutex.lock();
 | 
			
		||||
            if(in_progress) {
 | 
			
		||||
                sema.acquire();
 | 
			
		||||
            }
 | 
			
		||||
            mutex.unlock();;
 | 
			
		||||
            mutex.unlock();
 | 
			
		||||
 | 
			
		||||
            // if is active then something happened while setting the socket, wait a little and try again
 | 
			
		||||
            if(isActive()) {
 | 
			
		||||
                qDebug("Error getting wireless connection");
 | 
			
		||||
                Sleeper::sleep(2000);
 | 
			
		||||
            } else {
 | 
			
		||||
                qDebug("Wireless connection cancelled by the user");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    } while(isActive());
 | 
			
		||||
 | 
			
		||||
@@ -171,12 +179,6 @@ int CmaClient::generatePin(wireless_vita_info_t *info, int *p_err)
 | 
			
		||||
    return pin;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CmaClient::cancelCallback()
 | 
			
		||||
{
 | 
			
		||||
    QMutexLocker locker(&cancel);
 | 
			
		||||
    return is_cancelled;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CmaClient::enterEventLoop(vita_device_t *device)
 | 
			
		||||
{
 | 
			
		||||
    vita_event_t event;
 | 
			
		||||
@@ -227,9 +229,8 @@ int CmaClient::stop()
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
    CmaClient::setActive(false);
 | 
			
		||||
    cancel.lock();
 | 
			
		||||
    is_cancelled = true;
 | 
			
		||||
    cancel.unlock();
 | 
			
		||||
    VitaMTP_Cancel_Get_Wireless_Vita();
 | 
			
		||||
    usbcondition.wakeAll();
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,6 +28,7 @@
 | 
			
		||||
#include <QObject>
 | 
			
		||||
#include <QSemaphore>
 | 
			
		||||
#include <QString>
 | 
			
		||||
#include <QWaitCondition>
 | 
			
		||||
 | 
			
		||||
#include <vitamtp.h>
 | 
			
		||||
 | 
			
		||||
@@ -59,11 +60,11 @@ private:
 | 
			
		||||
    //TODO: move all the control variables to the client manager class
 | 
			
		||||
    static bool is_active;
 | 
			
		||||
    static bool in_progress;
 | 
			
		||||
    static int is_cancelled;
 | 
			
		||||
    static CmaClient *this_object;
 | 
			
		||||
    static QMutex mutex;
 | 
			
		||||
    static QMutex runner;
 | 
			
		||||
    static QMutex cancel;
 | 
			
		||||
    static QMutex usbwait;
 | 
			
		||||
    static QWaitCondition usbcondition;
 | 
			
		||||
    static QSemaphore sema;
 | 
			
		||||
 | 
			
		||||
signals:
 | 
			
		||||
 
 | 
			
		||||
@@ -77,7 +77,7 @@ void MainWidget::dialogResult(int result)
 | 
			
		||||
void MainWidget::stopServer()
 | 
			
		||||
{
 | 
			
		||||
    setTrayTooltip(tr("Shutting down..."));
 | 
			
		||||
    receiveMessage(tr("Stopping QCMA..."));
 | 
			
		||||
    receiveMessage(tr("Stopping QCMA (disconnect your PS Vita)"));
 | 
			
		||||
    manager.stop();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user