Activate download of json-configuration files.
This commit is contained in:
		
							
								
								
									
										45
									
								
								update.cpp
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								update.cpp
									
									
									
									
									
								
							@@ -29,11 +29,7 @@
 | 
				
			|||||||
#include <QMap>
 | 
					#include <QMap>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define UPDATE_OPKG                 (1)
 | 
					#define UPDATE_OPKG                 (1)
 | 
				
			||||||
#define UPDATE_DC                   (1)
 | 
					#define UPDATE_DC                   (0)
 | 
				
			||||||
#define UPDATE_PRINTER_TEMPLATES    (1)
 | 
					 | 
				
			||||||
#define UPDATE_CASH_TEMPLATE        (1)
 | 
					 | 
				
			||||||
#define UPDATE_CONF_TEMPLATE        (1)
 | 
					 | 
				
			||||||
#define UPDATE_DEVICE_TEMPLATE      (1)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const QMap<QString, int> baudrateMap = {
 | 
					static const QMap<QString, int> baudrateMap = {
 | 
				
			||||||
  {"1200"   ,   0}, {"9600"   ,   1}, {"19200"  ,   2}, {"38400"  ,   3},
 | 
					  {"1200"   ,   0}, {"9600"   ,   1}, {"19200"  ,   2}, {"38400"  ,   3},
 | 
				
			||||||
@@ -852,13 +848,12 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
 | 
				
			|||||||
                        qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
 | 
					                        qInfo() << "dc-firmware-version (NOT UPDATED)" << versions[1];
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
                res = updateBinaryRes;
 | 
					                res = updateBinaryRes;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
 | 
					#endif
 | 
				
			||||||
                && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
 | 
					        if (fToWorkOn.contains("DC2C_print", Qt::CaseInsensitive)
 | 
				
			||||||
 | 
					         && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
 | 
				
			||||||
            res = true;
 | 
					            res = true;
 | 
				
			||||||
#if UPDATE_PRINTER_TEMPLATES == 1
 | 
					 | 
				
			||||||
            int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
 | 
					            int i = fToWorkOn.indexOf("DC2C_print", Qt::CaseInsensitive);
 | 
				
			||||||
            int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
 | 
					            int const templateIdx = fToWorkOn.mid(i).midRef(10, 2).toInt();
 | 
				
			||||||
            if ((templateIdx < 1) || (templateIdx > 32)) {
 | 
					            if ((templateIdx < 1) || (templateIdx > 32)) {
 | 
				
			||||||
@@ -866,50 +861,46 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
 | 
				
			|||||||
                res = false;
 | 
					                res = false;
 | 
				
			||||||
            } else {
 | 
					            } else {
 | 
				
			||||||
                if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
 | 
					                if ((res = updatePrinterTemplate(templateIdx, fToWorkOn))) {
 | 
				
			||||||
                    qInfo() << "downloaded printer template"<< fToWorkOn;
 | 
					                    Utils::printInfoMsg(
 | 
				
			||||||
 | 
					                        QString("DOWNLOADED PRINTER TEMPLATE %1 WITH INDEX=%2")
 | 
				
			||||||
 | 
					                            .arg(fToWorkOn)
 | 
				
			||||||
 | 
					                            .arg(templateIdx));
 | 
				
			||||||
                    ++displayIndex;
 | 
					                    ++displayIndex;
 | 
				
			||||||
                    emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
 | 
					                    emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
 | 
				
			||||||
                          + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
 | 
					                          + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
 | 
				
			||||||
                            Worker::UPDATE_STEP_DONE);
 | 
					                            Worker::UPDATE_STEP_DONE);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
        } else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
 | 
					        } else if (fToWorkOn.contains("DC2C_cash", Qt::CaseInsensitive)
 | 
				
			||||||
                && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
 | 
					                && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
 | 
				
			||||||
            res = true;
 | 
					            res = true;
 | 
				
			||||||
#if UPDATE_CASH_TEMPLATE == 1
 | 
					 | 
				
			||||||
            if ((res = updateCashConf(fToWorkOn))) {
 | 
					            if ((res = updateCashConf(fToWorkOn))) {
 | 
				
			||||||
                Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
 | 
					                Utils::printInfoMsg(QString("DOWNLOADED CASH TEMPLATE %1").arg(fToWorkOn));
 | 
				
			||||||
                ++displayIndex;
 | 
					                ++displayIndex;
 | 
				
			||||||
                emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
 | 
					                emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
 | 
				
			||||||
                      + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
 | 
					                      + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
 | 
				
			||||||
                        Worker::UPDATE_STEP_DONE);
 | 
					                        Worker::UPDATE_STEP_DONE);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
        } else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
 | 
					        } else if (fToWorkOn.contains("DC2C_conf", Qt::CaseInsensitive)
 | 
				
			||||||
                && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
 | 
					                && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
 | 
				
			||||||
            res = true;
 | 
					            res = true;
 | 
				
			||||||
#if UPDATE_CONF_TEMPLATE == 1
 | 
					 | 
				
			||||||
            if ((res= updateConfig(fToWorkOn))) {
 | 
					            if ((res= updateConfig(fToWorkOn))) {
 | 
				
			||||||
                qInfo() << "downloaded config template"<< fToWorkOn;
 | 
					                Utils::printInfoMsg(QString("DOWNLOADED CONFIG TEMPLATE %1").arg(fToWorkOn));
 | 
				
			||||||
                ++displayIndex;
 | 
					                ++displayIndex;
 | 
				
			||||||
                emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
 | 
					                emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
 | 
				
			||||||
                      + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
 | 
					                      + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
 | 
				
			||||||
                        Worker::UPDATE_STEP_DONE);
 | 
					                        Worker::UPDATE_STEP_DONE);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
        } else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
 | 
					        } else if (fToWorkOn.contains("DC2C_device", Qt::CaseInsensitive)
 | 
				
			||||||
                && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
 | 
					                && fToWorkOn.endsWith(".json", Qt::CaseInsensitive)) {
 | 
				
			||||||
            res = true;
 | 
					            res = true;
 | 
				
			||||||
#if UPDATE_DEVICE_TEMPLATE == 1
 | 
					 | 
				
			||||||
            if ((res = updateDeviceConf(fToWorkOn))) {
 | 
					            if ((res = updateDeviceConf(fToWorkOn))) {
 | 
				
			||||||
                qInfo() << "downloaded device template"<< fToWorkOn;
 | 
					                Utils::printInfoMsg(QString("DOWNLOADED DEVICE TEMPLATE %1").arg(fToWorkOn));
 | 
				
			||||||
                ++displayIndex;
 | 
					                ++displayIndex;
 | 
				
			||||||
                emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(2, ' ') + QString(")")
 | 
					                emit m_worker->appendText(QString("\n(") + QString("%1").arg(displayIndex).rightJustified(3, ' ') + QString(")")
 | 
				
			||||||
                      + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
 | 
					                      + QString(" Update ") + QFileInfo(fToWorkOn).fileName(),
 | 
				
			||||||
                        Worker::UPDATE_STEP_DONE);
 | 
					                        Worker::UPDATE_STEP_DONE);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
 | 
					            qCritical() << "UNKNOWN JSON FILE NAME" << fToWorkOn;
 | 
				
			||||||
            res = false;
 | 
					            res = false;
 | 
				
			||||||
@@ -922,12 +913,8 @@ bool Update::doUpdate(int &displayIndex, QStringList const &filesToWorkOn) {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    } // for (it = openLines.cbegin(); it != openLines.end(); ++it) {
 | 
					    } // for (it = openLines.cbegin(); it != openLines.end(); ++it) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    //m_hw->dc_autoRequest(true);  // ALWAYS turn autoRequest ON
 | 
					    m_hw->dc_autoRequest(true);  // ALWAYS turn autoRequest ON
 | 
				
			||||||
    //qDebug() << "SET AUTO-REQUEST=TRUE";
 | 
					    qDebug() << "SET AUTO-REQUEST=TRUE";
 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (serialOpened) {
 | 
					 | 
				
			||||||
        m_hw->dc_closeSerial();
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return res;
 | 
					    return res;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user