commit 47b89cfa61d1defa43a70e7de92d707b8d824cf4 Author: Josef Rokos Date: Sat Jan 7 22:44:24 2017 +0100 Initial commit diff --git a/EetCpp.pro b/EetCpp.pro new file mode 100644 index 0000000..7ff1968 --- /dev/null +++ b/EetCpp.pro @@ -0,0 +1,4 @@ +TEMPLATE = subdirs + +SUBDIRS += libEet \ + eetsend \ No newline at end of file diff --git a/eetsend/.gitignore b/eetsend/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/eetsend/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/eetsend/eetsend.pro b/eetsend/eetsend.pro new file mode 100644 index 0000000..f1353dd --- /dev/null +++ b/eetsend/eetsend.pro @@ -0,0 +1,19 @@ +QT += core +QT -= gui + +CONFIG += c++11 + +TARGET = eetsend +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + +SOURCES += main.cpp + +win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../libEet/release/ -lEetCpp +else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../libEet/debug/ -lEetCpp +else:unix: LIBS += -L$$OUT_PWD/../libEet/ -lEetCpp + +INCLUDEPATH += $$PWD/../libEet +DEPENDPATH += $$PWD/../libEet diff --git a/eetsend/main.cpp b/eetsend/main.cpp new file mode 100644 index 0000000..3e47923 --- /dev/null +++ b/eetsend/main.cpp @@ -0,0 +1,23 @@ +#include + +#include + +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + + EetRequest request; + + request.setCelkTrzba(1); + request.setCerpZuct(2); + request.setCestSluz(3); + request.setIdPokl("id pokladny"); + request.setIdProvoz("id provoz"); + request.setDicPopl("CZ1234567"); + request.setCelkTrzba(100); + + EetSender sender; + sender.sendRequest(&request); + + return a.exec(); +} diff --git a/libEet/eetcpp.cpp b/libEet/eetcpp.cpp new file mode 100644 index 0000000..757c91f --- /dev/null +++ b/libEet/eetcpp.cpp @@ -0,0 +1,6 @@ +#include "eetcpp.h" + + +EetCpp::EetCpp() +{ +} diff --git a/libEet/eetcpp.h b/libEet/eetcpp.h new file mode 100644 index 0000000..b9ffcfc --- /dev/null +++ b/libEet/eetcpp.h @@ -0,0 +1,16 @@ +#ifndef EETCPP_H +#define EETCPP_H + +#include "eetcpp_global.h" + +#include "eetrequest.h" +#include "eetsender.h" + +class EETCPPSHARED_EXPORT EetCpp +{ + +public: + EetCpp(); +}; + +#endif // EETCPP_H diff --git a/libEet/eetcpp_global.h b/libEet/eetcpp_global.h new file mode 100644 index 0000000..dc6429c --- /dev/null +++ b/libEet/eetcpp_global.h @@ -0,0 +1,12 @@ +#ifndef EETCPP_GLOBAL_H +#define EETCPP_GLOBAL_H + +#include + +#if defined(EETCPP_LIBRARY) +# define EETCPPSHARED_EXPORT Q_DECL_EXPORT +#else +# define EETCPPSHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // EETCPP_GLOBAL_H diff --git a/libEet/eetrequest.cpp b/libEet/eetrequest.cpp new file mode 100644 index 0000000..4145dd8 --- /dev/null +++ b/libEet/eetrequest.cpp @@ -0,0 +1,404 @@ +#include "eetrequest.h" + +EetRequest::EetRequest(QObject *parent) : QObject(parent) +{ + m_prvniZaslani = true; + m_produkcni = false; + + m_rezim = STANDARD; +} + +QDateTime EetRequest::datOdesl() const +{ + return m_datOdesl; +} + +void EetRequest::setDatOdesl(const QDateTime &datOdesl) +{ + m_datOdesl = datOdesl; +} + +QString EetRequest::datOdeslStr() const +{ + return m_datOdesl.toTimeSpec(Qt::OffsetFromUTC).toString(Qt::ISODate); +} + +QTimeZone EetRequest::datOdeslZone() const +{ + return m_datOdeslZone; +} + +void EetRequest::setDatOdeslZone(const QTimeZone &datOdeslZone) +{ + m_datOdeslZone = datOdeslZone; +} + +bool EetRequest::prvniZaslani() const +{ + return m_prvniZaslani; +} + +void EetRequest::setPrvniZaslani(bool prvniZaslani) +{ + m_prvniZaslani = prvniZaslani; +} + +QString EetRequest::prvniZaslaniStr() const +{ + return m_prvniZaslani ? "true" : "false"; +} + +QUuid EetRequest::uuidZpravy() const +{ + return m_uuidZpravy; +} + +void EetRequest::setUuidZpravy(const QUuid &uuidZpravy) +{ + m_uuidZpravy = uuidZpravy; +} + +QString EetRequest::uuidZpravyStr() const +{ + QString ret = m_uuidZpravy.toString(); + ret = ret.replace(0, 1, ""); + ret = ret.replace(ret.size() - 1, 1, ""); + + return ret; +} + +bool EetRequest::produkcni() const +{ + return m_produkcni; +} + +void EetRequest::setProdukcni(bool produkcni) +{ + m_produkcni = produkcni; +} + +QString EetRequest::produkcniStr() const +{ + return m_produkcni ? "true" : "false"; +} + +QString EetRequest::dicPopl() const +{ + return m_dicPopl.isNull() ? NULL_VAL : QString(*m_dicPopl.data()); +} + +void EetRequest::setDicPopl(const QString &dicPopl) +{ + m_dicPopl = QSharedPointer(new QString(dicPopl)); +} + +QString EetRequest::dicPoverujiciho() const +{ + return m_dicPoverujiciho.isNull() ? NULL_VAL : QString(*m_dicPoverujiciho.data()); +} + +void EetRequest::setDicPoverujiciho(const QString &dicPoverujiciho) +{ + m_dicPoverujiciho = QSharedPointer(new QString(dicPoverujiciho)); +} + +QString EetRequest::idProvoz() const +{ + return m_idProvoz; +} + +void EetRequest::setIdProvoz(const QString &idProvoz) +{ + m_idProvoz = idProvoz; +} + +QString EetRequest::idPokl() const +{ + return m_idPokl; +} + +void EetRequest::setIdPokl(const QString &idPokl) +{ + m_idPokl = idPokl; +} + +QString EetRequest::poradCis() const +{ + return m_poradCis; +} + +void EetRequest::setPoradCis(const QString &poradCis) +{ + m_poradCis = poradCis; +} + +QDateTime EetRequest::datTrzby() const +{ + return m_datTrzby; +} + +void EetRequest::setDatTrzby(const QDateTime &datTrzby) +{ + m_datTrzby = datTrzby; +} + +QString EetRequest::datTrzbyStr() const +{ + return m_datTrzby.toTimeSpec(Qt::OffsetFromUTC).toString(Qt::ISODate); +} + +QTimeZone EetRequest::datTrzbyZone() const +{ + return m_datTrzbyZone; +} + +void EetRequest::setDatTrzbyZone(const QTimeZone &datTrzbyZone) +{ + m_datTrzbyZone = datTrzbyZone; +} + +double EetRequest::celkTrzba() const +{ + return m_celkTrzba.isNull() ? 0 : *m_celkTrzba.data(); +} + +void EetRequest::setCelkTrzba(double celkTrzba) +{ + m_celkTrzba = QSharedPointer(new double); + *m_celkTrzba.data() = celkTrzba; +} + +QString EetRequest::celkTrzbaStr() const +{ + return m_celkTrzba.isNull() ? NULL_VAL : QString::number(*m_celkTrzba.data(), 'f', 2); +} + +double EetRequest::zaklNepodlDph() const +{ + return m_zaklNepodlDph.isNull() ? 0 : *m_zaklNepodlDph.data(); +} + +void EetRequest::setZaklNepodlDph(double zaklNepodlDph) +{ + m_zaklNepodlDph = QSharedPointer(new double); + *m_zaklNepodlDph.data() = zaklNepodlDph; +} + +QString EetRequest::zaklNepodlDphStr() const +{ + return m_zaklNepodlDph.isNull() ? NULL_VAL : QString::number(*m_zaklNepodlDph.data(), 'f', 2); +} + +double EetRequest::zaklDan1() const +{ + return m_zaklDan1.isNull() ? 0 : *m_zaklDan1.data(); +} + +void EetRequest::setZaklDan1(double zaklDan1) +{ + m_zaklDan1 = QSharedPointer(new double); + *m_zaklDan1.data() = zaklDan1; +} + +QString EetRequest::zaklDan1Str() const +{ + return m_zaklDan1.isNull() ? NULL_VAL : QString::number(*m_zaklDan1.data(), 'f', 2); +} + +double EetRequest::dan1() const +{ + return m_dan1.isNull() ? 0 : *m_dan1.data(); +} + +void EetRequest::setDan1(double dan1) +{ + m_dan1 = QSharedPointer(new double); + *m_dan1.data() = dan1; +} + +QString EetRequest::dan1Str() const +{ + return m_dan1.isNull() ? NULL_VAL : QString::number(*m_dan1.data(), 'f', 2); +} + +double EetRequest::zaklDan2() const +{ + return m_zaklDan2.isNull() ? 0 : *m_zaklDan2.data(); +} + +void EetRequest::setZaklDan2(double zaklDan2) +{ + m_zaklDan2 = QSharedPointer(new double); + *m_zaklDan2.data() = zaklDan2; +} + +QString EetRequest::zaklDan2Str() const +{ + return m_zaklDan2.isNull() ? NULL_VAL : QString::number(*m_zaklDan2.data(), 'f', 2); +} + +double EetRequest::dan2() const +{ + return m_dan2.isNull() ? 0 : *m_dan2.data(); +} + +void EetRequest::setDan2(double dan2) +{ + m_dan2 = QSharedPointer(new double); + *m_dan2.data() = dan2; +} + +QString EetRequest::dan2Str() const +{ + return m_dan2.isNull() ? NULL_VAL : QString::number(*m_dan2.data(), 'f', 2); +} + +double EetRequest::zaklDan3() const +{ + return m_zaklDan3.isNull() ? 0 : *m_zaklDan3.data(); +} + +void EetRequest::setZaklDan3(double zaklDan3) +{ + m_zaklDan3 = QSharedPointer(new double); + *m_zaklDan3.data() = zaklDan3; +} + +QString EetRequest::zaklDan3Str() const +{ + return m_zaklDan3.isNull() ? NULL_VAL : QString::number(*m_zaklDan3.data(), 'f', 2); +} + +QString EetRequest::dan3Str() const +{ + return m_dan3.isNull() ? NULL_VAL : QString::number(*m_dan3.data(), 'f', 2); +} + +double EetRequest::dan3() const +{ + return m_dan3.isNull() ? 0 : *m_dan3.data(); +} + +void EetRequest::setDan3(double dan3) +{ + m_dan3 = QSharedPointer(new double); + *m_dan3.data() = dan3; +} + +double EetRequest::cestSluz() const +{ + return m_cestSluz.isNull() ? 0 : *m_cestSluz.data(); +} + +void EetRequest::setCestSluz(double cestSluz) +{ + m_cestSluz = QSharedPointer(new double); + *m_cestSluz.data() = cestSluz; +} + +QString EetRequest::cestSluzStr() const +{ + return m_cestSluz.isNull() ? NULL_VAL : QString::number(*m_cestSluz.data(), 'f', 2); +} + +double EetRequest::pouzitZboz1() const +{ + return m_pouzitZboz1.isNull() ? 0 : *m_pouzitZboz1.data(); +} + +void EetRequest::setPouzitZboz1(double pouzitZboz1) +{ + m_pouzitZboz1 = QSharedPointer(new double); + *m_pouzitZboz1.data() = pouzitZboz1; +} + +QString EetRequest::pouzitZboz1Str() const +{ + return m_pouzitZboz1.isNull() ? NULL_VAL : QString::number(*m_pouzitZboz1.data(), 'f', 2); +} + +double EetRequest::pouzitZboz2() const +{ + return m_pouzitZboz2.isNull() ? 0 : *m_pouzitZboz2.data(); +} + +void EetRequest::setPouzitZboz2(double pouzitZboz2) +{ + m_pouzitZboz2 = QSharedPointer(new double); + *m_pouzitZboz2.data() = pouzitZboz2; +} + +QString EetRequest::pouzitZboz2Str() const +{ + return m_pouzitZboz2.isNull() ? NULL_VAL : QString::number(*m_pouzitZboz2.data(), 'f', 2); +} + +double EetRequest::pouzitZboz3() const +{ + return m_pouzitZboz3.isNull() ? 0 : *m_pouzitZboz3.data(); +} + +void EetRequest::setPouzitZboz3(double pouzitZboz3) +{ + m_pouzitZboz3 = QSharedPointer(new double); + *m_pouzitZboz3.data() = pouzitZboz3; +} + +QString EetRequest::pouzitZboz3Str() const +{ + return m_pouzitZboz3.isNull() ? NULL_VAL : QString::number(*m_pouzitZboz3.data(), 'f', 2); +} + +double EetRequest::urcenoCerpZuct() const +{ + return m_urcenoCerpZuct.isNull() ? 0 : *m_urcenoCerpZuct.data(); +} + +void EetRequest::setUrcenoCerpZuct(double urcenoCerpZuct) +{ + m_urcenoCerpZuct = QSharedPointer(new double); + *m_urcenoCerpZuct.data() = urcenoCerpZuct; +} + +QString EetRequest::urcenoCerpZuctStr() const +{ + return m_urcenoCerpZuct.isNull() ? NULL_VAL : QString::number(*m_urcenoCerpZuct.data(), 'f', 2); +} + +double EetRequest::cerpZuct() const +{ + return m_cerpZuct.isNull() ? 0 : *m_cerpZuct.data(); +} + +void EetRequest::setCerpZuct(double cerpZuct) +{ + m_cerpZuct = QSharedPointer(new double); + *m_cerpZuct.data() = cerpZuct; +} + +QString EetRequest::cerpZuctStr() const +{ + return m_cerpZuct.isNull() ? NULL_VAL : QString::number(*m_cerpZuct.data(), 'f', 2); +} + +EetRequest::EetRezim EetRequest::rezim() const +{ + return m_rezim; +} + +void EetRequest::setRezim(const EetRequest::EetRezim &rezim) +{ + m_rezim = rezim; +} + +QString EetRequest::rezimStr() const +{ + switch (m_rezim) { + case ZJEDNODUSENY: + return "1"; + case STANDARD: + return "0"; + default: + return "0"; + } +} diff --git a/libEet/eetrequest.h b/libEet/eetrequest.h new file mode 100644 index 0000000..bff64c6 --- /dev/null +++ b/libEet/eetrequest.h @@ -0,0 +1,186 @@ +#ifndef EETREQUEST_H +#define EETREQUEST_H + +#include +#include +#include +#include +#include + +#include "eetcpp_global.h" + +#define NULL_VAL "__NULL__" + +class EETCPPSHARED_EXPORT EetRequest : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString dat_odesl READ datOdeslStr) + Q_PROPERTY(QString prvni_zaslani READ prvniZaslaniStr) + Q_PROPERTY(QString uuid_zpravy READ uuidZpravyStr) + Q_PROPERTY(QString produkcni READ produkcniStr) + Q_PROPERTY(QString dic_popl READ dicPopl) + Q_PROPERTY(QString dic_poverujiciho READ dicPoverujiciho) + Q_PROPERTY(QString id_provoz READ idProvoz) + Q_PROPERTY(QString id_pokl READ idPokl) + Q_PROPERTY(QString porad_cis READ poradCis) + Q_PROPERTY(QString dat_trzby READ datTrzbyStr) + Q_PROPERTY(QString celk_trzba READ celkTrzbaStr) + Q_PROPERTY(QString zakl_nepodl_dph READ zaklNepodlDphStr) + Q_PROPERTY(QString zakl_dan1 READ zaklDan1Str) + Q_PROPERTY(QString zakl_dan2 READ zaklDan2Str) + Q_PROPERTY(QString zakl_dan3 READ zaklDan3Str) + Q_PROPERTY(QString dan1 READ dan1Str) + Q_PROPERTY(QString dan2 READ dan2Str) + Q_PROPERTY(QString dan3 READ dan3Str) + Q_PROPERTY(QString cest_sluz READ cestSluzStr) + Q_PROPERTY(QString pouzit_zboz1 READ pouzitZboz1Str) + Q_PROPERTY(QString pouzit_zboz2 READ pouzitZboz2Str) + Q_PROPERTY(QString pouzit_zboz3 READ pouzitZboz3Str) + Q_PROPERTY(QString urceno_cerp_zuct READ urcenoCerpZuctStr) + Q_PROPERTY(QString cerp_zuct READ cerpZuctStr) + Q_PROPERTY(QString rezim READ rezimStr) +public: + explicit EetRequest(QObject *parent = 0); + + enum EetRezim { + ZJEDNODUSENY = 0, + STANDARD + }; + + QDateTime datOdesl() const; + void setDatOdesl(const QDateTime &datOdesl); + QString datOdeslStr() const; + + QTimeZone datOdeslZone() const; + void setDatOdeslZone(const QTimeZone &datOdeslZone); + QString datOdeslZoneStr() const; + + bool prvniZaslani() const; + void setPrvniZaslani(bool prvniZaslani); + QString prvniZaslaniStr() const; + + QUuid uuidZpravy() const; + void setUuidZpravy(const QUuid &uuidZpravy); + QString uuidZpravyStr() const; + + bool produkcni() const; + void setProdukcni(bool produkcni); + QString produkcniStr() const; + + QString dicPopl() const; + void setDicPopl(const QString &dicPopl); + + QString dicPoverujiciho() const; + void setDicPoverujiciho(const QString &dicPoverujiciho); + + QString idProvoz() const; + void setIdProvoz(const QString &idProvoz); + + QString idPokl() const; + void setIdPokl(const QString &idPokl); + + QString poradCis() const; + void setPoradCis(const QString &poradCis); + + QDateTime datTrzby() const; + void setDatTrzby(const QDateTime &datTrzby); + QString datTrzbyStr() const; + + QTimeZone datTrzbyZone() const; + void setDatTrzbyZone(const QTimeZone &datTrzbyZone); + + double celkTrzba() const; + void setCelkTrzba(double celkTrzba); + QString celkTrzbaStr() const; + + double zaklNepodlDph() const; + void setZaklNepodlDph(double zaklNepodlDph); + QString zaklNepodlDphStr() const; + + double zaklDan1() const; + void setZaklDan1(double zaklDan1); + QString zaklDan1Str() const; + + double dan1() const; + void setDan1(double dan1); + QString dan1Str() const; + + double zaklDan2() const; + void setZaklDan2(double zaklDan2); + QString zaklDan2Str() const; + + double dan2() const; + void setDan2(double dan2); + QString dan2Str() const; + + double zaklDan3() const; + void setZaklDan3(double zaklDan3); + QString zaklDan3Str() const; + + double dan3() const; + void setDan3(double dan3); + QString dan3Str() const; + + double cestSluz() const; + void setCestSluz(double cestSluz); + QString cestSluzStr() const; + + double pouzitZboz1() const; + void setPouzitZboz1(double pouzitZboz1); + QString pouzitZboz1Str() const; + + double pouzitZboz2() const; + void setPouzitZboz2(double pouzitZboz2); + QString pouzitZboz2Str() const; + + double pouzitZboz3() const; + void setPouzitZboz3(double pouzitZboz3); + QString pouzitZboz3Str() const; + + double urcenoCerpZuct() const; + void setUrcenoCerpZuct(double urcenoCerpZuct); + QString urcenoCerpZuctStr() const; + + double cerpZuct() const; + void setCerpZuct(double cerpZuct); + QString cerpZuctStr() const; + + EetRezim rezim() const; + void setRezim(const EetRezim &rezim); + QString rezimStr() const; + +private: + QDateTime m_datOdesl; + QTimeZone m_datOdeslZone; + bool m_prvniZaslani; + QUuid m_uuidZpravy; + bool m_produkcni; + QSharedPointer m_dicPopl; + QSharedPointer m_dicPoverujiciho; + QString m_idProvoz; + QString m_idPokl; + QString m_poradCis; + QDateTime m_datTrzby; + QTimeZone m_datTrzbyZone; + QSharedPointer m_celkTrzba; + QSharedPointer m_zaklNepodlDph; + QSharedPointer m_zaklDan1; + QSharedPointer m_dan1; + QSharedPointer m_zaklDan2; + QSharedPointer m_dan2; + QSharedPointer m_zaklDan3; + QSharedPointer m_dan3; + QSharedPointer m_cestSluz; + QSharedPointer m_pouzitZboz1; + QSharedPointer m_pouzitZboz2; + QSharedPointer m_pouzitZboz3; + QSharedPointer m_urcenoCerpZuct; + QSharedPointer m_cerpZuct; + EetRezim m_rezim; + +signals: + +public slots: +}; + +#endif // EETREQUEST_H diff --git a/libEet/eetsender.cpp b/libEet/eetsender.cpp new file mode 100644 index 0000000..565a022 --- /dev/null +++ b/libEet/eetsender.cpp @@ -0,0 +1,16 @@ +#include "eetsender.h" + +#include + +EetSender::EetSender(QObject *parent) : QObject(parent) +{ + +} + +void EetSender::sendRequest(EetRequest *request) +{ + EetTemplate tempBody(BODY_TEMPLATE); + QString strBody = tempBody.fillTemplate(request); + + qDebug() << strBody; +} diff --git a/libEet/eetsender.h b/libEet/eetsender.h new file mode 100644 index 0000000..a38d677 --- /dev/null +++ b/libEet/eetsender.h @@ -0,0 +1,23 @@ +#ifndef EETSENDER_H +#define EETSENDER_H + +#include + +#include "eetcpp_global.h" +#include "eetrequest.h" +#include "eettemplate.h" + +class EETCPPSHARED_EXPORT EetSender : public QObject +{ + Q_OBJECT +public: + explicit EetSender(QObject *parent = 0); + + void sendRequest(EetRequest *request); + +signals: + +public slots: +}; + +#endif // EETSENDER_H diff --git a/libEet/eettemplate.cpp b/libEet/eettemplate.cpp new file mode 100644 index 0000000..5bbee5f --- /dev/null +++ b/libEet/eettemplate.cpp @@ -0,0 +1,80 @@ +#include "eettemplate.h" + +#include +#include + +EetTemplate::EetTemplate(QObject *parent) : QObject(parent) +{ +} + +EetTemplate::EetTemplate(const QString &tmp, QObject *parent) : QObject(parent) +{ + QFile tmpFile(tmp); + tmpFile.open(QFile::ReadOnly | QFile::Text); + + QTextStream stream(&tmpFile); + m_template = stream.readAll(); +} + +QString EetTemplate::fillTemplate(EetRequest *request) +{ + return fillTemplateInternal(request, nullptr); +} + +QString EetTemplate::fillTemplate(QMap map) +{ + return fillTemplateInternal(nullptr, &map); +} + +QString EetTemplate::fillTemplateInternal(EetRequest *request, QMap *map) +{ + QString ret; + QString phStart; + + if (request != nullptr) + { + phStart = "@{"; + } + else + { + phStart = "${"; + } + + for (int i = 0; i < m_template.size(); i++) + { + QChar c = m_template[i]; + if (!m_template.mid(i).startsWith(phStart)) + { + ret += c; + continue; + } + + int p = m_template.indexOf("}", i + 2); + if (p < 0) + { + return ret; + } + + QString var = m_template.mid(i + 2, p - i - 2); + QString value; + + if (request != nullptr) + { + value = request->property(var.toStdString().c_str()).toString(); + } + else + { + value = map->value(var, NULL_VAL); + } + + if (value != NULL_VAL) + { + QString attrib = QString("%1=\"%2\"").arg(var, value); + ret += attrib; + } + + i = p; + } + + return ret; +} diff --git a/libEet/eettemplate.h b/libEet/eettemplate.h new file mode 100644 index 0000000..4b8f986 --- /dev/null +++ b/libEet/eettemplate.h @@ -0,0 +1,33 @@ +#ifndef EETTEMPLATE_H +#define EETTEMPLATE_H + +#include +#include +#include + +#include "eetrequest.h" + +#define BODY_TEMPLATE ":/res/template_body.txt" +#define REQUEST_TEMPLATE ":/res/template_request.txt" +#define SIGNATURE_TEMPLATE ":/res/template_signature.txt" + +class EetTemplate : public QObject +{ + Q_OBJECT +public: + explicit EetTemplate(QObject *parent = 0); + EetTemplate(const QString &tmp, QObject *parent = 0); + + QString fillTemplate(EetRequest *request); + QString fillTemplate(QMap map); + +signals: + +public slots: + +private: + QString m_template; + QString fillTemplateInternal(EetRequest *request, QMap *map); +}; + +#endif // EETTEMPLATE_H diff --git a/libEet/libEet.pro b/libEet/libEet.pro new file mode 100644 index 0000000..baa674f --- /dev/null +++ b/libEet/libEet.pro @@ -0,0 +1,33 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2017-01-07T15:25:00 +# +#------------------------------------------------- + +QT += network xml + +QT -= gui + +TARGET = EetCpp +TEMPLATE = lib + +DEFINES += EETCPP_LIBRARY + +SOURCES += eetcpp.cpp \ + eetrequest.cpp \ + eettemplate.cpp \ + eetsender.cpp + +HEADERS += eetcpp.h\ + eetcpp_global.h \ + eetrequest.h \ + eettemplate.h \ + eetsender.h + +unix { + target.path = /usr/lib + INSTALLS += target +} + +RESOURCES += \ + resource.qrc diff --git a/libEet/res/template_body.txt b/libEet/res/template_body.txt new file mode 100644 index 0000000..aee8361 --- /dev/null +++ b/libEet/res/template_body.txt @@ -0,0 +1,10 @@ + + + + + + ${pkp} + ${bkp} + + + \ No newline at end of file diff --git a/libEet/res/template_request.txt b/libEet/res/template_request.txt new file mode 100644 index 0000000..e1597f2 --- /dev/null +++ b/libEet/res/template_request.txt @@ -0,0 +1,36 @@ + + + + + ${certb64} + + + + + + + + + + + + ${digest} + + + ${signature} + + + + + + + + + ${soap:Body} + diff --git a/libEet/res/template_signature.txt b/libEet/res/template_signature.txt new file mode 100644 index 0000000..a4ecfe4 --- /dev/null +++ b/libEet/res/template_signature.txt @@ -0,0 +1,13 @@ + + + + + + + + + + + ${digest} + + \ No newline at end of file diff --git a/libEet/resource.qrc b/libEet/resource.qrc new file mode 100644 index 0000000..27534ae --- /dev/null +++ b/libEet/resource.qrc @@ -0,0 +1,7 @@ + + + res/template_body.txt + res/template_request.txt + res/template_signature.txt + +