Use ETX instead of OTX (also as a file extension).

This commit is contained in:
rotorman
2021-12-31 10:53:08 +01:00
committed by Raphael Coeffic
parent 20961e460b
commit 89517d8bd8
29 changed files with 103 additions and 99 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ set(storage_NAMES
hexeeprom
categorized
sdcard
otx
etx
yaml
)
@@ -18,13 +18,13 @@
* GNU General Public License for more details.
*/
#include "otx.h"
#include "etx.h"
#include "miniz.c"
#include <QFile>
#define MZ_ALLOCATION_SIZE (32*1024)
bool OtxFormat::load(RadioData & radioData)
bool EtxFormat::load(RadioData & radioData)
{
QFile file(filename);
@@ -40,7 +40,7 @@ bool OtxFormat::load(RadioData & radioData)
// open zip file
memset(&zip_archive, 0, sizeof(zip_archive));
if (!mz_zip_reader_init_mem(&zip_archive, archiveContents.data(), archiveContents.size(), 0)) {
qDebug() << tr("Error opening OTX archive %1").arg(filename);
qDebug() << tr("Error opening ETX archive %1").arg(filename);
return false;
}
@@ -49,13 +49,13 @@ bool OtxFormat::load(RadioData & radioData)
return result;
}
bool OtxFormat::write(const RadioData & radioData)
bool EtxFormat::write(const RadioData & radioData)
{
qDebug() << "Saving to archive" << filename;
memset(&zip_archive, 0, sizeof(zip_archive));
if (!mz_zip_writer_init_heap(&zip_archive, 0, MZ_ALLOCATION_SIZE)) {
setError(tr("Error initializing OTX archive writer"));
setError(tr("Error initializing ETX archive writer"));
return false;
}
@@ -76,12 +76,12 @@ bool OtxFormat::write(const RadioData & radioData)
}
}
else {
setError(tr("Error creating OTX file %1:\n%2.").arg(filename).arg(file.errorString()));
setError(tr("Error creating ETX file %1:\n%2.").arg(filename).arg(file.errorString()));
result = false;
}
}
else {
setError(tr("Error creating OTX archive"));
setError(tr("Error creating ETX archive"));
result = false;
}
}
@@ -90,7 +90,7 @@ bool OtxFormat::write(const RadioData & radioData)
return result;
}
bool OtxFormat::loadFile(QByteArray & filedata, const QString & filename)
bool EtxFormat::loadFile(QByteArray & filedata, const QString & filename)
{
size_t size;
void * data = mz_zip_reader_extract_file_to_heap(&zip_archive, qPrintable(filename), &size, 0);
@@ -105,10 +105,10 @@ bool OtxFormat::loadFile(QByteArray & filedata, const QString & filename)
return true;
}
bool OtxFormat::writeFile(const QByteArray & filedata, const QString & filename)
bool EtxFormat::writeFile(const QByteArray & filedata, const QString & filename)
{
if (!mz_zip_writer_add_mem(&zip_archive, filename.toStdString().c_str(), filedata.data(), filedata.size(), MZ_DEFAULT_LEVEL)) {
setError(tr("Error adding %1 to OTX archive").arg(filename));
setError(tr("Error adding %1 to ETX archive").arg(filename));
return false;
}
@@ -18,8 +18,8 @@
* GNU General Public License for more details.
*/
#ifndef _OTX_H_
#define _OTX_H_
#ifndef _ETX_H_
#define _ETX_H_
#include "categorized.h"
@@ -29,17 +29,17 @@
#include "miniz.c"
#undef MINIZ_HEADER_FILE_ONLY
class OtxFormat : public CategorizedStorageFormat
class EtxFormat : public CategorizedStorageFormat
{
Q_DECLARE_TR_FUNCTIONS(OtxFormat)
Q_DECLARE_TR_FUNCTIONS(EtxFormat)
public:
OtxFormat(const QString & filename):
EtxFormat(const QString & filename):
CategorizedStorageFormat(filename)
{
}
virtual QString name() { return "otx"; }
virtual QString name() { return "etx"; }
virtual bool load(RadioData & radioData);
virtual bool write(const RadioData & radioData);
@@ -50,4 +50,4 @@ class OtxFormat : public CategorizedStorageFormat
mz_zip_archive zip_archive;
};
#endif // _OTX_H_
#endif // _ETX_H_
+7 -7
View File
@@ -305,11 +305,11 @@ bool FirmwareInterface::seekSplash(QByteArray sps, QByteArray spe, int size)
return false;
}
#define OTX_SPS_9X "SPS\0\200\100"
#define OTX_SPS_TARANIS "SPS\0\324\100"
#define OTX_SPS_SIZE 6
#define OTX_SPE "SPE"
#define OTX_SPE_SIZE 4
#define ETX_SPS_9X "SPS\0\200\100"
#define ETX_SPS_TARANIS "SPS\0\324\100"
#define ETX_SPS_SIZE 6
#define ETX_SPE "SPE"
#define ETX_SPE_SIZE 4
void FirmwareInterface::seekSplash()
{
@@ -342,11 +342,11 @@ void FirmwareInterface::seekSplash()
return;
}
if (seekSplash(QByteArray(OTX_SPS_9X, OTX_SPS_SIZE), QByteArray(OTX_SPE, OTX_SPE_SIZE), 1024)) {
if (seekSplash(QByteArray(ETX_SPS_9X, ETX_SPS_SIZE), QByteArray(ETX_SPE, ETX_SPE_SIZE), 1024)) {
return;
}
if (seekSplash(QByteArray(OTX_SPS_TARANIS, OTX_SPS_SIZE), QByteArray(OTX_SPE, OTX_SPE_SIZE), RLE_SPLASH_MAX_SIZE)) {
if (seekSplash(QByteArray(ETX_SPS_TARANIS, ETX_SPS_SIZE), QByteArray(ETX_SPE, ETX_SPE_SIZE), RLE_SPLASH_MAX_SIZE)) {
splashWidth = SPLASHX9D_WIDTH;
splashHeight = SPLASHX9D_HEIGHT;
splash_format = QImage::Format_Indexed8;
+4 -2
View File
@@ -20,7 +20,7 @@
#include "bineeprom.h"
#include "eepe.h"
#include "otx.h"
#include "etx.h"
#include "sdcard.h"
#include "yaml.h"
#include "firmwareinterface.h"
@@ -42,6 +42,8 @@ StorageType getStorageType(const QString & filename)
return STORAGE_TYPE_XML;
else if (suffix == "OTX")
return STORAGE_TYPE_OTX;
else if (suffix == "ETX")
return STORAGE_TYPE_ETX;
else if (suffix == "YML")
return STORAGE_TYPE_YML;
else
@@ -63,7 +65,7 @@ void registerStorageFactories()
registerStorageFactory(new DefaultStorageFactory<BinEepromFormat>("bin"));
registerStorageFactory(new DefaultStorageFactory<EepeFormat>("eepe"));
registerStorageFactory(new DefaultStorageFactory<HexEepromFormat>("hex"));
registerStorageFactory(new DefaultStorageFactory<OtxFormat>("otx"));
registerStorageFactory(new DefaultStorageFactory<EtxFormat>("etx"));
registerStorageFactory(new DefaultStorageFactory<YamlFormat>("yml"));
registerStorageFactory(new SdcardStorageFactory());
}
+2 -1
View File
@@ -37,7 +37,8 @@ enum StorageType
STORAGE_TYPE_XML,
STORAGE_TYPE_SDCARD,
STORAGE_TYPE_OTX,
STORAGE_TYPE_YML
STORAGE_TYPE_YML,
STORAGE_TYPE_ETX
};
StorageType getStorageType(const QString & filename);