Read hostname and pin from config file if available.
This commit is contained in:
@@ -41,11 +41,13 @@ bool DeviceCapability::exchangeInfo(vita_device_t *device)
|
|||||||
vita_info.protocolVersion, VITAMTP_PROTOCOL_MAX_VERSION);
|
vita_info.protocolVersion, VITAMTP_PROTOCOL_MAX_VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString hostname = QHostInfo::localHostName();
|
QSettings settings;
|
||||||
|
QString hostname = settings.value("hostName", QHostInfo::localHostName()).toString();
|
||||||
|
|
||||||
int protocol_version = ::getVitaProtocolVersion();
|
int protocol_version = ::getVitaProtocolVersion();
|
||||||
|
|
||||||
qDebug() << "Sending Qcma protocol version:" << protocol_version;
|
qDebug() << "Sending Qcma protocol version:" << protocol_version;
|
||||||
|
qDebug() << "Identifying as" << hostname;
|
||||||
|
|
||||||
const initiator_info_t *pc_info = VitaMTP_Data_Initiator_New(hostname.toUtf8().data(), protocol_version);
|
const initiator_info_t *pc_info = VitaMTP_Data_Initiator_New(hostname.toUtf8().data(), protocol_version);
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ CmaBroadcast::CmaBroadcast(QObject *obj_parent) :
|
|||||||
settings.setValue("guid", uuid);
|
settings.setValue("guid", uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
hostname = QHostInfo::localHostName();
|
hostname = settings.value("hostName", QHostInfo::localHostName()).toString();
|
||||||
setAvailable();
|
setAvailable();
|
||||||
|
|
||||||
socket = new QUdpSocket(this);
|
socket = new QUdpSocket(this);
|
||||||
|
|||||||
@@ -187,13 +187,30 @@ 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
|
// save the device name in a temporal variable, just in case the pin is rejected
|
||||||
tempOnlineId = QString(info->name);
|
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;
|
|
||||||
|
QString staticPin = QSettings().value("staticPin").toString();
|
||||||
|
|
||||||
|
int pin;
|
||||||
|
|
||||||
|
if(!staticPin.isNull() && staticPin.length() == 8) {
|
||||||
|
bool ok;
|
||||||
|
pin = staticPin.toInt(&ok);
|
||||||
|
|
||||||
|
if(!ok) {
|
||||||
|
pin = rand() % 10000 * 10000 | rand() % 10000;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
pin = rand() % 10000 * 10000 | rand() % 10000;
|
||||||
|
}
|
||||||
|
|
||||||
QTextStream out(stdout);
|
QTextStream out(stdout);
|
||||||
out << "Your registration PIN for " << info->name << " is: ";
|
out << "Your registration PIN for " << info->name << " is: ";
|
||||||
out.setFieldWidth(8);
|
out.setFieldWidth(8);
|
||||||
out.setPadChar('0');
|
out.setPadChar('0');
|
||||||
out << pin << endl;
|
out << pin << endl;
|
||||||
|
|
||||||
|
qDebug("PIN: %08i", pin);
|
||||||
|
|
||||||
*p_err = 0;
|
*p_err = 0;
|
||||||
emit this_object->receivedPin(info->name, pin);
|
emit this_object->receivedPin(info->name, pin);
|
||||||
return pin;
|
return pin;
|
||||||
|
|||||||
Reference in New Issue
Block a user