Receive the onlineId earlier so it can be shown in the connection popup.

USB: save the device name after exchanging capability info.
WiFi: save the device name used in the device pairing phrase.
This commit is contained in:
codestation
2013-12-25 21:46:42 -04:30
parent 12b0ad997e
commit e9d46005dc
6 changed files with 32 additions and 15 deletions

View File

@@ -113,3 +113,8 @@ capability_info_t *DeviceCapability::generate_pc_capability_info()
pc_capabilities->functions = functions[0];
return pc_capabilities;
}
DeviceCapability::~DeviceCapability()
{
VitaMTP_Data_Free_VitaInfo(&vita_info);
}

View File

@@ -26,20 +26,20 @@ class DeviceCapability
{
public:
explicit DeviceCapability() {}
~DeviceCapability();
bool exchangeInfo(vita_device_t *device);
//TODO: vita_info_t doesn't retrieve this info, update vitamtp to get it
const char *getVersion() {
return "";
return vita_info.responderVersion;
}
const char *getProtocol() {
return "";
int getProtocolVersion() {
return vita_info.protocolVersion;
}
const char *getOnlineId() {
return "PS Vita";
return vita_info.onlineId;
}
const char *getModelInfo() {
return "";
return vita_info.modelInfo;
}
private:

View File

@@ -37,6 +37,8 @@ QMutex CmaClient::runner;
QMutex CmaClient::cancel;
QSemaphore CmaClient::sema;
QString CmaClient::tempOnlineId = QString();
bool CmaClient::is_active = false;
bool CmaClient::in_progress = false;
int CmaClient::is_cancelled = false;
@@ -117,8 +119,17 @@ void CmaClient::processNewConnection(vita_device_t *device)
if(!vita_info.exchangeInfo(device)) {
qCritical("Error while exchanging info with the vita");
} else {
QSettings settings;
// Conection successful, inform the user
emit deviceConnected(QString(tr("Connected to ")) + vita_info.getOnlineId());
if(vita_info.getOnlineId() != NULL) {
settings.setValue("lastOnlineId", vita_info.getOnlineId());
emit deviceConnected(QString(tr("Connected to %1 (PS Vita)")).arg(vita_info.getOnlineId()));
} else {
QString onlineId = settings.value("lastOnlineId", "default").toString();
emit deviceConnected(QString(tr("Connected to %1 (PS Vita)")).arg(onlineId));
}
enterEventLoop(device);
}
@@ -135,7 +146,9 @@ void CmaClient::processNewConnection(vita_device_t *device)
void CmaClient::registrationComplete()
{
QSettings settings;
qDebug("Registration completed");
settings.setValue("lastOnlineId", tempOnlineId);
emit this_object->pinComplete();
}
@@ -148,6 +161,8 @@ int CmaClient::deviceRegistered(const char *deviceid)
int CmaClient::generatePin(wireless_vita_info_t *info, int *p_err)
{
// save the device name in a temporal variable, just in case the pin is rejected
tempOnlineId = QString(info->name);
qDebug("Registration request from %s (MAC: %s)", info->name, info->mac_addr);
int pin = rand() % 10000 * 10000 | rand() % 10000;
qDebug("Your registration PIN for %s is: %08d", info->name, pin);

View File

@@ -54,6 +54,7 @@ private:
static void registrationComplete();
CmaBroadcast broadcast;
static QString tempOnlineId;
//TODO: move all the control variables to the client manager class
static bool is_active;

View File

@@ -609,12 +609,6 @@ void CmaEvent::vitaEventGetSettingInfo(vita_event_t *event, int eventId)
QSettings settings;
// Always refresh the account name
if(qstrcmp(settingsinfo->current_account.userName, "mtpr3InvalidUserName") != 0) {
// wewt, the Vita didn't go full retard again
settings.setValue("lastOnlineId", settingsinfo->current_account.userName);
}
if(settings.value("lastAccountId").toString() != settingsinfo->current_account.accountId) {
db->setUUID(settingsinfo->current_account.accountId);
// set the database to be updated ASAP

View File

@@ -51,8 +51,6 @@ void BackupManagerForm::setupForm()
connect(ui->backupComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(loadBackupListing(int)));
ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
ui->tableWidget->horizontalHeader()->hide();
// the the account name when vitamtp returns this value
ui->accountBox->addItem(QSettings().value("lastOnlineId", tr("Default account")).toString());
}
void BackupManagerForm::removeEntry(BackupItem *item)
@@ -99,6 +97,10 @@ void BackupManagerForm::loadBackupListing(int index)
bool sys_dir;
int img_width;
//TODO: load all the accounts in the combobox
ui->accountBox->clear();
ui->accountBox->addItem(QSettings().value("lastOnlineId", tr("Default account")).toString());
if(index < 0) {
index = ui->backupComboBox->currentIndex();
}