Added selector to override the default protocol version.
This commit is contained in:
@@ -41,7 +41,7 @@ bool DeviceCapability::exchangeInfo(vita_device_t *device)
|
||||
}
|
||||
|
||||
QString hostname = QHostInfo::localHostName();
|
||||
int protocol_version = QSettings().value("protocolVersion", VITAMTP_PROTOCOL_MAX_VERSION).toInt();
|
||||
int protocol_version = getProtocolVersion();
|
||||
const initiator_info_t *pc_info = VitaMTP_Data_Initiator_New(hostname.toUtf8().data(), protocol_version);
|
||||
|
||||
// Next, we send the client's (this program) info (discard the const here)
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "cmabroadcast.h"
|
||||
#include "cmautils.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QHostInfo>
|
||||
@@ -85,7 +86,7 @@ void CmaBroadcast::readPendingDatagrams()
|
||||
void CmaBroadcast::setAvailable()
|
||||
{
|
||||
QMutexLocker locker(&mutex);
|
||||
int protocol_version = QSettings().value("protocolVersion", VITAMTP_PROTOCOL_MAX_VERSION).toInt();
|
||||
int protocol_version = getProtocolVersion();
|
||||
|
||||
reply.clear();
|
||||
reply.insert(0, broadcast_reply
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QImage>
|
||||
#include <QSettings>
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
#include <windows.h>
|
||||
@@ -184,3 +185,51 @@ QString readable_size(qint64 size, bool use_gib)
|
||||
}
|
||||
return QString().setNum(size_f,'f',2) + " " + unit;
|
||||
}
|
||||
|
||||
int getProtocolVersion()
|
||||
{
|
||||
bool useCustom = QSettings().value("useCustomProtocol").toBool();
|
||||
if(useCustom)
|
||||
{
|
||||
bool ok;
|
||||
int protocol = QSettings().value("protocolVersion").toInt(&ok);
|
||||
if(ok && protocol > 0)
|
||||
return protocol;
|
||||
else
|
||||
return VITAMTP_PROTOCOL_MAX_VERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
int protocol;
|
||||
int index = QSettings().value("protocolIndex").toInt();
|
||||
switch(index)
|
||||
{
|
||||
case 0:
|
||||
protocol = VITAMTP_PROTOCOL_FW_3_30;
|
||||
break;
|
||||
case 1:
|
||||
protocol = VITAMTP_PROTOCOL_FW_3_10;
|
||||
break;
|
||||
case 2:
|
||||
protocol = VITAMTP_PROTOCOL_FW_3_00;
|
||||
break;
|
||||
case 3:
|
||||
protocol = VITAMTP_PROTOCOL_FW_2_60;
|
||||
break;
|
||||
case 4:
|
||||
protocol = VITAMTP_PROTOCOL_FW_2_10;
|
||||
break;
|
||||
case 5:
|
||||
protocol = VITAMTP_PROTOCOL_FW_2_00;
|
||||
break;
|
||||
case 6:
|
||||
protocol = VITAMTP_WIRELESS_FW_2_00;
|
||||
break;
|
||||
default:
|
||||
protocol = VITAMTP_PROTOCOL_MAX_VERSION;
|
||||
break;
|
||||
}
|
||||
|
||||
return protocol;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,5 +49,6 @@ bool removeRecursively(const QString &path);
|
||||
QString readable_size(qint64 size, bool use_gib = false);
|
||||
bool getDiskSpace(const QString &dir, quint64 *free, quint64 *total);
|
||||
QByteArray getThumbnail(const QString &path, DataType type, metadata_t *metadata);
|
||||
int getProtocolVersion();
|
||||
|
||||
#endif // UTILS_H
|
||||
|
||||
@@ -62,7 +62,6 @@ void ConfigWidget::connectSignals()
|
||||
connect(mapper, SIGNAL(mapped(int)), this, SLOT(browseBtnPressed(int)));
|
||||
connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect(ui->resetProtocolButton, SIGNAL(clicked()), this, SLOT(resetButtonPressed()));
|
||||
}
|
||||
|
||||
void ConfigWidget::setDefaultData()
|
||||
@@ -100,8 +99,16 @@ void ConfigWidget::setDefaultData()
|
||||
ui->videoSkipCheck->setChecked(settings.value("videoSkip", false).toBool());
|
||||
ui->musicSkipCheck->setChecked(settings.value("musicSkip", false).toBool());
|
||||
|
||||
int protocol_version = settings.value("protocolVersion", VITAMTP_PROTOCOL_MAX_VERSION).toInt();
|
||||
ui->protocolEdit->setText(QString::number(protocol_version));
|
||||
ui->customProtocolCheckBox->setChecked(settings.value("useCustomProtocol", false).toBool());
|
||||
ui->protocolBox->setCurrentIndex(settings.value("protocolIndex", 0).toInt());
|
||||
|
||||
bool ok;
|
||||
int protocol_version = settings.value("protocolVersion", VITAMTP_PROTOCOL_MAX_VERSION).toInt(&ok);
|
||||
|
||||
if(ok && protocol_version > 0)
|
||||
ui->protocolEdit->setText(QString::number(protocol_version));
|
||||
else
|
||||
ui->protocolEdit->setText(QString::number(VITAMTP_PROTOCOL_MAX_VERSION));
|
||||
}
|
||||
|
||||
ConfigWidget::~ConfigWidget()
|
||||
@@ -109,11 +116,6 @@ ConfigWidget::~ConfigWidget()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void ConfigWidget::resetButtonPressed()
|
||||
{
|
||||
ui->protocolEdit->setText(QString::number(VITAMTP_PROTOCOL_MAX_VERSION));
|
||||
}
|
||||
|
||||
void ConfigWidget::browseBtnPressed(int btn)
|
||||
{
|
||||
QString msg;
|
||||
@@ -188,7 +190,17 @@ void ConfigWidget::accept()
|
||||
settings.setValue("photoSkip", ui->photoSkipCheck->isChecked());
|
||||
settings.setValue("videoSkip", ui->videoSkipCheck->isChecked());
|
||||
settings.setValue("musicSkip", ui->musicSkipCheck->isChecked());
|
||||
settings.setValue("protocolVersion", ui->protocolEdit->text().toInt());
|
||||
settings.setValue("useCustomProtocol", ui->customProtocolCheckBox->isChecked());
|
||||
settings.setValue("protocolIndex", ui->protocolBox->currentIndex());
|
||||
|
||||
bool ok;
|
||||
int protocol = ui->protocolEdit->text().toInt(&ok);
|
||||
|
||||
if(ok && protocol > 0)
|
||||
settings.setValue("protocolVersion", protocol);
|
||||
else
|
||||
settings.setValue("protocolVersion", VITAMTP_PROTOCOL_MAX_VERSION);
|
||||
|
||||
settings.sync();
|
||||
|
||||
done(Accepted);
|
||||
|
||||
@@ -48,7 +48,6 @@ private:
|
||||
|
||||
private slots:
|
||||
void browseBtnPressed(int from);
|
||||
void resetButtonPressed();
|
||||
void accept();
|
||||
};
|
||||
|
||||
|
||||
@@ -368,25 +368,82 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4"/>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout_2">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_10">
|
||||
<property name="text">
|
||||
<string>CMA Protocol version</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="protocolBox">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">FW 3.30 - 1900010</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">FW 3.10 - 1800010</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">FW 3.00 - 1700010</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">FW 2.60 - 1600010</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">FW 2.10 - 1500010</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">FW 2.00 - 1400010</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string notr="true">FW 1.00 - 1000000</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="customProtocolCheckBox">
|
||||
<property name="text">
|
||||
<string>Use custom version</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="protocolEdit">
|
||||
<property name="inputMask">
|
||||
<string notr="true">9999999</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetProtocolButton">
|
||||
<property name="text">
|
||||
<string>Reset to default</string>
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
Reference in New Issue
Block a user