Only index the database when a valid uuid is present.

Refresh the database when a PS Vita is connected.
This commit is contained in:
codestation
2013-12-19 20:53:27 -04:30
parent ee9237197d
commit b67af3b9d2
4 changed files with 18 additions and 6 deletions

View File

@@ -106,8 +106,13 @@ void ClientManager::start()
void ClientManager::refreshDatabase() void ClientManager::refreshDatabase()
{ {
if(!db.reload()) { bool prepared;
if(!db.reload(prepared)) {
if(prepared) {
emit messageSent(tr("Cannot refresh the database while is in use")); emit messageSent(tr("Cannot refresh the database while is in use"));
} else {
emit messageSent(tr("No PS Vita system has been registered"));
}
} else { } else {
progress.show(); progress.show();
} }

View File

@@ -174,6 +174,7 @@ void CmaClient::enterEventLoop(vita_device_t *device)
eventLoop.moveToThread(&thread); eventLoop.moveToThread(&thread);
connect(&thread, SIGNAL(started()), &eventLoop, SLOT(process())); connect(&thread, SIGNAL(started()), &eventLoop, SLOT(process()));
connect(&eventLoop, SIGNAL(refreshDatabase()), this, SIGNAL(refreshDatabase()), Qt::DirectConnection);
connect(&eventLoop, SIGNAL(finishedEventLoop()), &thread, SLOT(quit()), Qt::DirectConnection); connect(&eventLoop, SIGNAL(finishedEventLoop()), &thread, SLOT(quit()), Qt::DirectConnection);
thread.start(); thread.start();

View File

@@ -58,10 +58,17 @@ void Database::setUUID(const QString uuid)
QSettings().setValue("lastAccountId", uuid); QSettings().setValue("lastAccountId", uuid);
} }
bool Database::reload() bool Database::reload(bool &prepared)
{ {
if(mutex.tryLock()) { if(mutex.tryLock()) {
if(CMARootObject::uuid != "ffffffffffffffff") {
timer->start(); timer->start();
prepared = true;
} else {
mutex.unlock();
prepared = false;
return false;
}
return true; return true;
} else { } else {
return false; return false;
@@ -127,7 +134,6 @@ int Database::create()
case VITA_OHFI_PSPSAVE: case VITA_OHFI_PSPSAVE:
case VITA_OHFI_PSXAPP: case VITA_OHFI_PSXAPP:
case VITA_OHFI_PSMAPP: case VITA_OHFI_PSMAPP:
obj->initObject(settings.value("appsPath").toString()); obj->initObject(settings.value("appsPath").toString());
} }

View File

@@ -42,7 +42,7 @@ public:
explicit Database(); explicit Database();
~Database(); ~Database();
bool reload(); bool reload(bool &prepared);
void setUUID(const QString uuid); void setUUID(const QString uuid);
void addEntries(CMAObject *root); void addEntries(CMAObject *root);
CMAObject *ohfiToObject(int ohfi); CMAObject *ohfiToObject(int ohfi);