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]; pc_capabilities->functions = functions[0];
return pc_capabilities; return pc_capabilities;
} }
DeviceCapability::~DeviceCapability()
{
VitaMTP_Data_Free_VitaInfo(&vita_info);
}

View File

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

View File

@@ -37,6 +37,8 @@ QMutex CmaClient::runner;
QMutex CmaClient::cancel; QMutex CmaClient::cancel;
QSemaphore CmaClient::sema; QSemaphore CmaClient::sema;
QString CmaClient::tempOnlineId = QString();
bool CmaClient::is_active = false; bool CmaClient::is_active = false;
bool CmaClient::in_progress = false; bool CmaClient::in_progress = false;
int CmaClient::is_cancelled = false; int CmaClient::is_cancelled = false;
@@ -117,8 +119,17 @@ void CmaClient::processNewConnection(vita_device_t *device)
if(!vita_info.exchangeInfo(device)) { if(!vita_info.exchangeInfo(device)) {
qCritical("Error while exchanging info with the vita"); qCritical("Error while exchanging info with the vita");
} else { } else {
QSettings settings;
// Conection successful, inform the user // 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); enterEventLoop(device);
} }
@@ -135,7 +146,9 @@ void CmaClient::processNewConnection(vita_device_t *device)
void CmaClient::registrationComplete() void CmaClient::registrationComplete()
{ {
QSettings settings;
qDebug("Registration completed"); qDebug("Registration completed");
settings.setValue("lastOnlineId", tempOnlineId);
emit this_object->pinComplete(); 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) 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); qDebug("Registration request from %s (MAC: %s)", info->name, info->mac_addr);
int pin = rand() % 10000 * 10000 | rand() % 10000; int pin = rand() % 10000 * 10000 | rand() % 10000;
qDebug("Your registration PIN for %s is: %08d", info->name, pin); qDebug("Your registration PIN for %s is: %08d", info->name, pin);

View File

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

View File

@@ -609,12 +609,6 @@ void CmaEvent::vitaEventGetSettingInfo(vita_event_t *event, int eventId)
QSettings settings; 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) { if(settings.value("lastAccountId").toString() != settingsinfo->current_account.accountId) {
db->setUUID(settingsinfo->current_account.accountId); db->setUUID(settingsinfo->current_account.accountId);
// set the database to be updated ASAP // 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))); connect(ui->backupComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(loadBackupListing(int)));
ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); ui->tableWidget->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
ui->tableWidget->horizontalHeader()->hide(); 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) void BackupManagerForm::removeEntry(BackupItem *item)
@@ -99,6 +97,10 @@ void BackupManagerForm::loadBackupListing(int index)
bool sys_dir; bool sys_dir;
int img_width; 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) { if(index < 0) {
index = ui->backupComboBox->currentIndex(); index = ui->backupComboBox->currentIndex();
} }