refactor libs into non-gui and gui parts
authorKonrad Rosenbaum <konrad@silmor.de>
Thu, 12 Dec 2013 19:22:24 +0000 (20:22 +0100)
committerKonrad Rosenbaum <konrad@silmor.de>
Thu, 12 Dec 2013 19:22:24 +0000 (20:22 +0100)
59 files changed:
.gitignore
basics.pri [new file with mode: 0644]
iface/iface.pri [new file with mode: 0644]
iface/iface.pro [new file with mode: 0644]
iface/libs.pri [new file with mode: 0644]
iface/misc/boxwrapper.cpp [new file with mode: 0644]
iface/misc/boxwrapper.h [new file with mode: 0644]
iface/misc/cleanup.h [moved from src/misc/cleanup.h with 89% similarity]
iface/misc/formula.cpp [moved from src/misc/formula.cpp with 100% similarity]
iface/misc/formula.h [moved from src/misc/formula.h with 74% similarity]
iface/misc/misc.cpp [moved from src/misc/misc.cpp with 100% similarity]
iface/misc/misc.h [moved from src/misc/misc.h with 95% similarity]
iface/misc/misc.pri [new file with mode: 0644]
iface/msinterface.cpp [moved from src/iface/msinterface.cpp with 73% similarity]
iface/msinterface.h [moved from src/iface/msinterface.h with 83% similarity]
iface/sslexception.cpp [moved from src/iface/sslexception.cpp with 99% similarity]
iface/sslexception.h [moved from src/iface/sslexception.h with 92% similarity]
iface/templates/templates.cpp [moved from src/templates/templates.cpp with 91% similarity]
iface/templates/templates.h [moved from src/templates/templates.h with 89% similarity]
iface/templates/templates.pri [new file with mode: 0644]
iface/wext/MOAddress [moved from src/wext/MOAddress with 100% similarity]
iface/wext/MOCustomer [moved from src/wext/MOCustomer with 100% similarity]
iface/wext/MOCustomerInfo [moved from src/wext/MOCustomerInfo with 100% similarity]
iface/wext/MOEvent [moved from src/wext/MOEvent with 100% similarity]
iface/wext/MOOrder [moved from src/wext/MOOrder with 100% similarity]
iface/wext/MOOrderInfo [moved from src/wext/MOOrderInfo with 100% similarity]
iface/wext/MOTicket [moved from src/wext/MOTicket with 100% similarity]
iface/wext/MOVoucher [moved from src/wext/MOVoucher with 100% similarity]
iface/wext/MTransaction [moved from src/wext/MTransaction with 100% similarity]
iface/wext/address.cpp [moved from src/wext/address.cpp with 100% similarity]
iface/wext/address.h [moved from src/wext/address.h with 87% similarity]
iface/wext/customer.cpp [moved from src/wext/customer.cpp with 100% similarity]
iface/wext/customer.h [moved from src/wext/customer.h with 88% similarity]
iface/wext/customerinfo.cpp [moved from src/wext/customerinfo.cpp with 100% similarity]
iface/wext/customerinfo.h [moved from src/wext/customerinfo.h with 84% similarity]
iface/wext/event.cpp [moved from src/wext/event.cpp with 100% similarity]
iface/wext/event.h [moved from src/wext/event.h with 92% similarity]
iface/wext/order.cpp [moved from src/wext/order.cpp with 100% similarity]
iface/wext/order.h [moved from src/wext/order.h with 97% similarity]
iface/wext/orderinfo.h [moved from src/wext/orderinfo.h with 91% similarity]
iface/wext/ticket.cpp [moved from src/wext/ticket.cpp with 100% similarity]
iface/wext/ticket.h [moved from src/wext/ticket.h with 93% similarity]
iface/wext/transaction.cpp [new file with mode: 0644]
iface/wext/transaction.h [moved from src/wext/transaction.h with 58% similarity]
iface/wext/voucher.h [moved from src/wext/voucher.h with 89% similarity]
iface/wext/wext.pri [moved from src/wext/wext.pri with 100% similarity]
mainapp/mainapp.pro
pack
src/iface/iface.pri [deleted file]
src/libs.pri
src/main.cpp
src/misc/misc.pri
src/misc/waitcursor.cpp
src/smoke.pro
src/templates/templatedlg.cpp
src/templates/templatedlg.h
src/templates/templates.pri
src/wext/transaction.cpp [deleted file]
wob/magicsmoke.wolf

index b1d7698..8aa7caa 100644 (file)
@@ -15,7 +15,7 @@ object_script*
 
 #generated sources, translations, docu
 doc/wob
-src/wob
+iface/wob
 www/inc/wob
 *.qm
 doc/source-cpp/
diff --git a/basics.pri b/basics.pri
new file mode 100644 (file)
index 0000000..b014e21
--- /dev/null
@@ -0,0 +1,37 @@
+#basic compile settings
+
+#put everything here:
+DESTDIR = $$PWD/bin
+
+#hide classes that are not explicitly exported
+# this is default on Windows, we have it here to have all systems behave the same way
+CONFIG += hide_symbols
+#use PRL files (link info)
+CONFIG += create_prl link_prl 
+#put debug symbols in separate file (on linux)
+CONFIG += separate_debug_info
+#enable C++-11 features
+CONFIG += c++11
+
+#compilation output:
+OBJECTS_DIR = .ctmp
+MOC_DIR = .ctmp
+RCC_DIR = .ctmp
+
+#make sure libs are found
+LIBS += -L$$PWD/bin
+
+#protect the stack
+QMAKE_CFLAGS += -fstack-protector-all -Wstack-protector
+QMAKE_CXXFLAGS += -fstack-protector-all -Wstack-protector
+
+#ASLR for windows  
+win32 {
+  QMAKE_LFLAGS +=  -Wl,--nxcompat -Wl,--dynamicbase
+  LIBS += -lssp
+}
+
+linux-g++* {
+  #make sure we find our libs
+  QMAKE_LFLAGS += -Wl,-rpath,\'\$$ORIGIN\'
+}
diff --git a/iface/iface.pri b/iface/iface.pri
new file mode 100644 (file)
index 0000000..5036fe0
--- /dev/null
@@ -0,0 +1,11 @@
+#Include PRI for the interface library non-GUI parts
+
+LIBS += -lmagicsmoke-iface
+INCLUDEPATH += \
+        $$PWD/../iface/wob \
+        $$PWD/../iface/wext \
+        $$PWD/../iface/misc \
+        $$PWD/../iface/templates \
+        $$PWD/../iface
+
+include ($$PWD/libs.pri)
diff --git a/iface/iface.pro b/iface/iface.pro
new file mode 100644 (file)
index 0000000..bf315e2
--- /dev/null
@@ -0,0 +1,25 @@
+TEMPLATE = lib
+TARGET = magicsmoke-iface
+VERSION =
+QT-=gui
+
+#make sure exports are ok
+DEFINES += MSIFACE_EXPORT=Q_DECL_EXPORT
+
+include (../basics.pri)
+include (libs.pri)
+
+include (wob/wob.pri)
+include (wext/wext.pri)
+include (misc/misc.pri)
+include (templates/templates.pri)
+
+HEADERS += \
+       msinterface.h \
+       sslexception.h
+
+SOURCES += \
+       msinterface.cpp \
+       sslexception.cpp
+
+INCLUDEPATH += $$PWD
\ No newline at end of file
diff --git a/iface/libs.pri b/iface/libs.pri
new file mode 100644 (file)
index 0000000..1cd0c66
--- /dev/null
@@ -0,0 +1,18 @@
+# Libraries for Magic Smoke by (c) Konrad Rosenbaum, 2007-2013
+
+# PACK library
+LIBS += -lqwbase
+INCLUDEPATH += $$PWD/../pack/qtbase/include
+
+# Time Zone DB library
+LIBS += -lQtTzData
+INCLUDEPATH += $$PWD/../tzone/include
+
+# ELAM library
+include($$PWD/../taurus/elam.pri)
+
+# Chester DPtr library
+include($$PWD/../taurus/chester.pri)
+
+#make sure the correct Qt DLLs are used
+QT += xml network script
diff --git a/iface/misc/boxwrapper.cpp b/iface/misc/boxwrapper.cpp
new file mode 100644 (file)
index 0000000..8b26a3e
--- /dev/null
@@ -0,0 +1,69 @@
+//
+// C++ Implementation: Message Box Wrapper
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2013
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#include "boxwrapper.h"
+#include <QDebug>
+
+MBoxWrapper::Wrapper MBoxWrapper::mwarn=nullptr;
+
+void MBoxWrapper::warning(QString title, QString text)
+{
+        if(mwarn!=nullptr)
+                mwarn(title,text);
+        else
+                qDebug()<<"Hidden Box Warning:"<<title<<text;
+}
+
+void MBoxWrapper::setWarning(Wrapper w)
+{
+        mwarn=w;
+}
+
+static MProgressWrapper::Factory prgfac=nullptr;
+class MProgressWrapperDebug:public MProgressWrapper
+{
+        QString label;
+        int min=0,max=0,val=0;
+        void output()
+        {
+                const double cur=val-min;
+                const double span=max-min;
+                qDebug()<<"Progress of"<<label<<"at"<<val<<"of"<<max<<"("<<(cur*100./span)<<"%)";
+        }
+        public:
+                MProgressWrapperDebug(QString l):label(l){}
+                virtual void setLabelText(QString l){label=l;}
+                virtual void setCancelButtonText(QString){}
+                virtual void cancel(){}
+                virtual void setRange(int mi,int ma){
+                        min=mi;max=ma;
+                        if(min>max)min=max;
+                        setValue(val);
+                }
+                virtual void setValue(int v)
+                {
+                        int old=val;
+                        val=v;
+                        if(val<min)val=min;
+                        if(val>max)val=max;
+                        if(val!=old)output();
+                }
+};
+
+
+MProgressWrapper* MProgressWrapper::create(QString label, QString buttonlabel)
+{
+        if(prgfac==nullptr)return new MProgressWrapperDebug(label);
+        else return prgfac(label,buttonlabel);
+}
+
+void MProgressWrapper::setFactory(Factory f)
+{
+        prgfac=f;
+}
diff --git a/iface/misc/boxwrapper.h b/iface/misc/boxwrapper.h
new file mode 100644 (file)
index 0000000..56fbf9c
--- /dev/null
@@ -0,0 +1,50 @@
+//
+// C++ Interface: Message Box Wrapper
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2013
+//
+// Copyright: See README/COPYING.GPL files that come with this distribution
+//
+//
+
+#ifndef MSINTERFACE_BOXWRAPPER_H
+#define MSINTERFACE_BOXWRAPPER_H
+
+#include <QString>
+#include <QObject>
+#include <functional>
+
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
+
+class MSIFACE_EXPORT MBoxWrapper
+{
+        public:
+                typedef std::function<void(QString,QString)>Wrapper;
+                
+                static void warning(QString title,QString text);
+                static void setWarning(Wrapper);
+        private:
+                static Wrapper mwarn;
+                MBoxWrapper()=default;
+};
+
+class MSIFACE_EXPORT MProgressWrapper:public QObject
+{
+        Q_OBJECT
+        public:
+                typedef std::function<MProgressWrapper*(QString,QString)>Factory;
+                static void setFactory(Factory);
+                
+                static MProgressWrapper* create(QString label,QString buttonlabel=QString());
+        public slots:
+                virtual void setLabelText(QString)=0;
+                virtual void setCancelButtonText(QString)=0;
+                virtual void cancel()=0;
+                virtual void setRange(int,int)=0;
+                virtual void setValue(int)=0;
+};
+
+#endif
similarity index 89%
rename from src/misc/cleanup.h
rename to iface/misc/cleanup.h
index 76e81cc..d7a6f39 100644 (file)
 
 #include <functional>
 
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
 ///clean-up function: executes a lambda expression when it is destructed (i.e. when the instance leaves its scope
-class MCleanup
+class MSIFACE_EXPORT MCleanup
 {
        std::function<void()>m_ptr;
        public:
similarity index 100%
rename from src/misc/formula.cpp
rename to iface/misc/formula.cpp
similarity index 74%
rename from src/misc/formula.h
rename to iface/misc/formula.h
index f6ee17c..7241b47 100644 (file)
 
 #include <ELAM/Engine>
 
-class MElamEngine:public ELAM::Engine
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
+class MSIFACE_EXPORT MElamEngine:public ELAM::Engine
 {
        public:
                MElamEngine(QObject*parent=0);
similarity index 100%
rename from src/misc/misc.cpp
rename to iface/misc/misc.cpp
similarity index 95%
rename from src/misc/misc.h
rename to iface/misc/misc.h
index 2d4c496..685456a 100644 (file)
@@ -22,37 +22,41 @@ class TimeStamp;
 #include <MOServerFormat>
 #include <DPtrBase>
 
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
 /**converts special HTML characters into harmless &-codes, so the text can be included*/
-QString htmlize(QString str);
+QString MSIFACE_EXPORT htmlize(QString str);
 
 /**converts special XML characters into harmless &-codes, so the text can be included*/
-QString xmlize(QString str,QString newline="\n");
+QString MSIFACE_EXPORT xmlize(QString str,QString newline="\n");
 /**converts special XML characters into harmless &-codes, so the text can be included*/
-QByteArray xmlize(QByteArray str,QString newline="\n");
+QByteArray MSIFACE_EXPORT xmlize(QByteArray str,QString newline="\n");
 
 /**converts a cent value into a (localized) string*/
-QString cent2str(qint64 cent,bool localize=true);
+QString MSIFACE_EXPORT cent2str(qint64 cent,bool localize=true);
 
 /**converts a (localized) string back into a cent value (must not contain spaces or extra dots)*/
-qint64 str2cent(QString s,bool fromlocal=true);
+qint64 MSIFACE_EXPORT str2cent(QString s,bool fromlocal=true);
 
 /**converts a unix timestamp into a date*/
-QString unix2date(qint64,bool localize=true);
+QString MSIFACE_EXPORT unix2date(qint64,bool localize=true);
 
 /**converts a unix timestamp into a time (ommitting the date)*/
-QString unix2time(qint64,bool localize=true);
+QString MSIFACE_EXPORT unix2time(qint64,bool localize=true);
 
 /**converts a unix timestamp into a date-time-string*/
-QString unix2dateTime(qint64,bool localize=true);
+QString MSIFACE_EXPORT unix2dateTime(qint64,bool localize=true);
 
 /**return a (localized) regular expression that validates prices*/
-QRegExp priceRegExp(bool localize=true);
+QRegExp MSIFACE_EXPORT priceRegExp(bool localize=true);
 
 ///returns the current directory (the one last used in a file dialog)
-QString currentDir();
+QString MSIFACE_EXPORT currentDir();
 
 ///sets a new current directory (transparently handles files and directories)
-void setCurrentDir(QString);
+void MSIFACE_EXPORT setCurrentDir(QString);
 
 /**localized formatter class for timestamps, numbers and money;
 per default it uses the local translation to format data, but can be overidden;
@@ -95,7 +99,7 @@ Any occurrence of "%%" will be translated to a literal "%" sign.
 
 For example "%w the %d'th of %N in the year of the lord %Y at %a:%I %P" will be formatted as "Sat 19'th of June in the year of the lord 2010 at 8:29 AM".
 */
-class MLocalFormat
+class MSIFACE_EXPORT MLocalFormat
 {
        DECLARE_SHARED_DPTR(d);
        public:
diff --git a/iface/misc/misc.pri b/iface/misc/misc.pri
new file mode 100644 (file)
index 0000000..cbf78ea
--- /dev/null
@@ -0,0 +1,11 @@
+HEADERS += \
+       $$PWD/misc.h \
+       $$PWD/boxwrapper.h \
+       $$PWD/formula.h
+
+SOURCES += \
+       $$PWD/misc.cpp \
+       $$PWD/boxwrapper.cpp \
+       $$PWD/formula.cpp
+
+INCLUDEPATH += $$PWD
similarity index 73%
rename from src/iface/msinterface.cpp
rename to iface/msinterface.cpp
index 6d1e0af..43f9370 100644 (file)
 //
 
 #include "msinterface.h"
-#include "main.h"
 #include "sslexception.h"
 #include "templates.h"
 #include "misc.h"
+#include "boxwrapper.h"
 
 #include "MTGetMyRights"
 #include "MTGetMyRoles"
 #include <QDebug>
 #include <QDir>
 #include <QNetworkReply>
-#include <QMessageBox>
 #include <QSettings>
 #include <QTimer>
 #include <QTranslator>
 #include <MTLogin>
 
+static QString dataDir;
+
+#include <stdlib.h>
+
+#ifdef Q_OS_WIN32
+#define BASEDIRVAR "APPDATA"
+#else
+#define BASEDIRVAR "HOME"
+#endif
+
+QString MSInterface::resolveDir(const QString &dirspec)
+{
+        //resolve pattern
+        const QStringList dirspecl=dirspec.split('/',QString::KeepEmptyParts);
+        bool notfirst=false;
+        QString rdir;
+        for(QString dcom:dirspecl){
+                if(dcom=="$BASE"){
+                        dcom=getenv(BASEDIRVAR);
+                        if(dcom.isEmpty())
+                                qFatal("Cannot determine base application data directory. While resolving %s",dirspec.toLatin1().data());
+                }else if(dcom=="$APP")
+                        dcom=qApp->applicationDirPath();
+                else if(dcom.startsWith("$"))
+                        dcom=getenv(dcom.mid(1).toLatin1().data());
+                //append component
+                if(notfirst)rdir+="/";
+                else notfirst=true;
+                rdir+=dcom;
+        }
+        //make sure it exists
+        if(!QDir::current().mkpath(rdir))
+                qFatal("Unable to create path '%s' for spec '%s'.",rdir.toLatin1().data(),dirspec.toLatin1().data());
+        //return it
+        return rdir;
+}
+
 MSInterface::MSInterface(QString pid)
        :MInterface()
 {
@@ -71,7 +107,7 @@ bool MSInterface::login(QString username,QString passwd)
        m_uname=username;m_passwd=passwd;
        MTLogin lg=MTLogin::query(username,passwd,m_host,m_hostkey);
        if(lg.stage()==lg.Error)
-               QMessageBox::warning(0,tr("Warning"),tr("Login failed: %1").arg(tr(lg.errorString().toLatin1())));
+               MBoxWrapper::warning(tr("Warning"),tr("Login failed: %1").arg(tr(lg.errorString().toLatin1())));
        else
                setSessionId(lg.getsessionid());
        if(lg.stage()!=lg.Success)return false;
@@ -105,21 +141,21 @@ bool MSInterface::checkServer()
                qDebug("caught exception while getting server info (%s): %s",
                 e.component().toLatin1().data(),
                 e.error().toLatin1().data());
-               QMessageBox::warning(0,tr("Error"),tr("Communication problem while talking to the server, see log for details."));
+               MBoxWrapper::warning(tr("Error"),tr("Communication problem while talking to the server, see log for details."));
                return false;
        }
        if(si.stage()!=si.Success){
-               QMessageBox::warning(0,tr("Error"),tr("Communication with server was not successful."));
+               MBoxWrapper::warning(tr("Error"),tr("Communication with server was not successful."));
                return false;
        }
        //is server new enough for me?
        if(si.getServerProtocolVersion().value()<commVersion()){
-               QMessageBox::warning(0,tr("Error"),tr("The server implementation is too old for this client."));
+               MBoxWrapper::warning(tr("Error"),tr("The server implementation is too old for this client."));
                return false;
        }
        //am I new enough for server?
        if(si.getMinimumProtocolVersion().value()>commVersion()){
-               QMessageBox::warning(0,tr("Error"),tr("This client is too old for the server, please upgrade."));
+               MBoxWrapper::warning(tr("Error"),tr("This client is too old for the server, please upgrade."));
                return false;
        }
        //we are ok
@@ -147,13 +183,25 @@ QMap<QString,QString> MSInterface::headers(QString s)const
 QString MSInterface::dataDir()const
 {
        QString dd="profile."+profileid;
-       QDir dir(MApplication::dataDir());
+       QDir dir(appDataDir());
        if(!dir.exists(dd))
                if(!dir.mkpath(dd))
                        qDebug("Warning: oh dir! Can't create my data directory!");
-       return MApplication::dataDir()+"/"+dd;
+       return appDataDir()+"/"+dd;
 }
 
+QString MSInterface::appDataDir()
+{
+        return ::dataDir;
+}
+
+void MSInterface::setAppDataDir(QString d)
+{
+        ::dataDir=resolveDir(d);
+        qDebug()<<"Setting the data directory to"<<::dataDir<<"from"<<d;
+}
+
+
 QString MSInterface::settingsGroup()const
 {
        return "profsettings/"+profileid;
@@ -211,7 +259,7 @@ void MSInterface::sslErrors(QNetworkReply *src,const QList<QSslError>&errs)
        }
        //message box
        if(!didsslerror){
-               QMessageBox::warning(0,tr("Connection Error"),tr("There were problems while authenticating the server. Aborting. Check your configuration."));
+               MBoxWrapper::warning(tr("Connection Error"),tr("There were problems while authenticating the server. Aborting. Check your configuration."));
        }
 }
 
similarity index 83%
rename from src/iface/msinterface.h
rename to iface/msinterface.h
index 8624853..f271ab6 100644 (file)
 
 #define req (MSInterface::instance())
 
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
 
 class MSslExceptions;
 class MTemplateStore;
 
 /**the MagicSmoke specific interface class - enhances the basic interface by some functionality needed in the MagicSmoke context*/
-class MSInterface:public MInterface
+class MSIFACE_EXPORT MSInterface:public MInterface
 {
        Q_OBJECT
        Q_PROPERTY(QString currentUser READ currentUser)
@@ -94,6 +98,18 @@ class MSInterface:public MInterface
                
                ///return all flags of the current user
                QStringList allFlags()const{return userflags;}
+               
+               ///return application main data directory
+               static QString appDataDir();
+
+                ///override the application main data directory
+                static void setAppDataDir(QString);
+
+                ///helper function to resolve directory names with patterns
+                ///the string $BASE is resolved as the content of the environment variable Unix: $HOME or Windows: %APPDIR%
+                ///the string $APP is resolved as the directory the application is installed in
+                ///any other component starting with $ resolves to the environment variable of the same name
+                static QString resolveDir(const QString&dir);
        
        public slots:
                /**logs into the server, returns true on success*/
similarity index 99%
rename from src/iface/sslexception.cpp
rename to iface/sslexception.cpp
index b806b8e..eb1d578 100644 (file)
@@ -13,7 +13,7 @@
 #include "sslexception.h"
 
 #include <QDebug>
-#include <QDialog>
+// #include <QDialog>
 #include <QDomDocument>
 #include <QDomElement>
 #include <QDomNodeList>
similarity index 92%
rename from src/iface/sslexception.h
rename to iface/sslexception.h
index bc7a143..da383e1 100644 (file)
 
 class QWidget;
 
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
 /**Helper class: stores and compares SSL-Exceptions*/
-class MSslExceptions
+class MSIFACE_EXPORT MSslExceptions
 {
        public:
                /**create instance from file in path*/
similarity index 91%
rename from src/templates/templates.cpp
rename to iface/templates/templates.cpp
index 5e10ea1..e3f7773 100644 (file)
  *   each file is stored with complete name, no meta-info
  ***************************/
 
-#include "main.h"
-#include "templatedlg.h"
 #include "templates.h"
 #include "msinterface.h"
+#include "boxwrapper.h"
 
 #include "MTGetTemplateList"
 #include "MTGetTemplate"
 #include <QDomDocument>
 #include <QDomElement>
 #include <QFile>
-#include <QProgressDialog>
 #include <QRegExp>
 #include <QSettings>
 #include <QStringList>
 
+static MTemplate::TemplateChoserFunction templaceChoser(MTemplate::TemplateChoserFunction f=nullptr)
+{
+        static MTemplate::TemplateChoserFunction rf=nullptr;
+        if(f)rf=f;
+        if(rf)return rf;
+        else return [](const QList<MTemplate>&tl){return tl.value(0);};
+}
+
+
 MTemplateStore::MTemplateStore(QString p)
 {
        profileid=p;
@@ -81,9 +88,16 @@ MTemplate MTemplateStore::getTemplate(QString f)
        if(tdir.size()==0)return MTemplate();
        if(tdir.size()==1)return MTemplate(dname+"/"+tdir[0], set.value(tdir[0]+"/checksum").toString(), set.value(tdir[0]+"/description").toString(), set.value(tdir[0]+"/flags").toString());
        //hmm, more than one choice
-       MTemplateChoice c(dname,f,tdir,"templates/"+profileid);
-       if(c.exec()==QDialog::Accepted)return c.choice();
-       else return MTemplate();
+        QList<MTemplate>templst;
+        for(const QString&td:tdir)
+                templst<<MTemplate(dname+"/"+td, set.value(td+"/checksum").toString(), set.value(td+"/description").toString(), set.value(td+"/flags").toString());
+        MTemplate::TemplateChoserFunction tcf=templaceChoser();
+        return tcf(templst);
+}
+
+void MTemplate::setTemplateChoiceFunction(const TemplateChoserFunction &f)
+{
+        templaceChoser(f);
 }
 
 MTemplate MTemplateStore::getTemplateByFile(QString f)
@@ -129,10 +143,10 @@ void MTemplateStore::updateTemplates(bool force)
        }
        
        //display progress dialog
-       QProgressDialog progress(QCoreApplication::translate("MTemplateStore","Retrieving templates from server."),"",0,1);
-       progress.setCancelButton(0);
-       progress.setMinimumDuration(0);
-       progress.setValue(0);
+       MProgressWrapper *progress=MProgressWrapper::create(QCoreApplication::translate("MTemplateStore","Retrieving templates from server."));
+        progress->setRange(0,1);
+       progress->setValue(0);
+        QObject progparent;progress->setParent(&progparent);
        
        //get remote info, assume it is still valid if unable to retrieve it
        MTGetTemplateList gtl=req->queryGetTemplateList();
@@ -158,9 +172,9 @@ void MTemplateStore::updateTemplates(bool force)
        
        //retrieve new files from server
        QStringList nfiles=nfmap.keys();
-       progress.setRange(0,nfiles.size());
+       progress->setRange(0,nfiles.size());
        for(int i=0;i<nfiles.size();i++){
-               progress.setValue(i);
+               progress->setValue(i);
                if(!files.contains(nfiles[i])){
                        //file is not in current cache (or was outdated)
                        if(retrieveFile(dname,nfiles[i]))
@@ -303,23 +317,6 @@ MTemplate::MTemplate(QString fn){m_fname=fn;}
 MTemplate::MTemplate(QString fn,QString chk,QString dsc,QString flg)
 {m_fname=fn;m_checksum=chk;m_descr=dsc;m_flags=flg;}
 
-MTemplate::MTemplate(const MTemplate& t)
-{
-       m_fname=t.m_fname;
-       m_checksum=t.m_checksum;
-       m_descr=t.m_descr;
-       m_flags=t.m_flags;
-}
-
-MTemplate& MTemplate::operator=(const MTemplate&t)
-{
-       m_fname=t.m_fname;
-       m_checksum=t.m_checksum;
-       m_descr=t.m_descr;
-       m_flags=t.m_flags;
-       return *this;
-}
-
 void MTemplate::setFile(const QString& s)
 {
        m_fname=s;
similarity index 89%
rename from src/templates/templates.h
rename to iface/templates/templates.h
index 233e880..b5b1396 100644 (file)
 #define MAGICSMOKE_TEMPLATES_H
 
 #include <QString>
+#include <QList>
+#include <functional>
+
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
 
 /**this class wraps a single template*/
-class MTemplate
+class MSIFACE_EXPORT MTemplate
 {
        public:
                /**creates an invalid template*/
@@ -26,10 +32,10 @@ class MTemplate
                MTemplate(QString fn);
                
                /**copies a template*/
-               MTemplate(const MTemplate&);
+               MTemplate(const MTemplate&)=default;
                
                ///copies a template
-               MTemplate& operator=(const MTemplate&);
+               MTemplate& operator=(const MTemplate&)=default;
                
                ///reinitializes the template from the given file name
                void setFile(const QString&);
@@ -107,6 +113,12 @@ class MTemplate
                
                /**returns the legal template file suffixes (as understood by the client) for a template base name; returns empty if none is legal*/
                static QStringList legalSuffixes(QString);
+                
+                typedef std::function<MTemplate(const QList<MTemplate>&)>TemplateChoserFunction;
+                
+                ///set a function to handle multiple template choices,
+                ///the default is a function that choses the first one
+                static void setTemplateChoiceFunction(const TemplateChoserFunction&);
 
        protected:
                friend class MTemplateStore;
@@ -124,7 +136,7 @@ class MTemplate
 Q_DECLARE_OPERATORS_FOR_FLAGS(MTemplate::Types)
 
 /**this class implements the storage end of the template subsystem, its only instance exists in the webrequest*/
-class MTemplateStore
+class MSIFACE_EXPORT MTemplateStore
 {
        protected:
                friend class MSInterface;
diff --git a/iface/templates/templates.pri b/iface/templates/templates.pri
new file mode 100644 (file)
index 0000000..c7cf1e3
--- /dev/null
@@ -0,0 +1,7 @@
+HEADERS += \
+       $$PWD/templates.h
+
+SOURCES += \
+       $$PWD/templates.cpp
+
+INCLUDEPATH += $$PWD
\ No newline at end of file
similarity index 100%
rename from src/wext/MOAddress
rename to iface/wext/MOAddress
similarity index 100%
rename from src/wext/MOCustomer
rename to iface/wext/MOCustomer
similarity index 100%
rename from src/wext/MOEvent
rename to iface/wext/MOEvent
similarity index 100%
rename from src/wext/MOOrder
rename to iface/wext/MOOrder
similarity index 100%
rename from src/wext/MOOrderInfo
rename to iface/wext/MOOrderInfo
similarity index 100%
rename from src/wext/MOTicket
rename to iface/wext/MOTicket
similarity index 100%
rename from src/wext/MOVoucher
rename to iface/wext/MOVoucher
similarity index 100%
rename from src/wext/address.cpp
rename to iface/wext/address.cpp
similarity index 87%
rename from src/wext/address.h
rename to iface/wext/address.h
index 9dbb650..dccdf97 100644 (file)
 
 #include <QMetaType>
 
-class MOAddress:public MOAddressAbstract
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
+class MSIFACE_EXPORT MOAddress:public MOAddressAbstract
 {
        Q_OBJECT
        WOBJECT(MOAddress)
similarity index 88%
rename from src/wext/customer.h
rename to iface/wext/customer.h
index cebb6e8..7ac7621 100644 (file)
 
 #include "MOCustomerAbstract"
 
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
 class MOCustomerInfo;
 
-class MOCustomer:public MOCustomerAbstract
+class MSIFACE_EXPORT MOCustomer:public MOCustomerAbstract
 {
        Q_OBJECT
        WOBJECT(MOCustomer)
similarity index 84%
rename from src/wext/customerinfo.h
rename to iface/wext/customerinfo.h
index 341e98a..8f635fa 100644 (file)
 #ifndef MAGICSMOKE_MOCUSTOMERI_H
 #define MAGICSMOKE_MOCUSTOMERI_H
 
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
+
 #include "MOCustomerInfoAbstract"
-class MOCustomerInfo:public MOCustomerInfoAbstract
+class MSIFACE_EXPORT MOCustomerInfo:public MOCustomerInfoAbstract
 {
        Q_OBJECT
        WOBJECT(MOCustomerInfo)
similarity index 100%
rename from src/wext/event.cpp
rename to iface/wext/event.cpp
similarity index 92%
rename from src/wext/event.h
rename to iface/wext/event.h
index 00cb1cd..aca5cd0 100644 (file)
 #include <QString>
 #include <MOEventAbstract>
 
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
+
 /**encapsulation of an event, this class wraps the auto-generated event class to provide some convenience methods*/
-class MOEvent:public MOEventAbstract
+class MSIFACE_EXPORT MOEvent:public MOEventAbstract
 {
        Q_OBJECT
        WOBJECT(MOEvent)
similarity index 100%
rename from src/wext/order.cpp
rename to iface/wext/order.cpp
similarity index 97%
rename from src/wext/order.h
rename to iface/wext/order.h
index d00f36f..bf9d1d0 100644 (file)
 
 #include <TimeStamp>
 
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
+
 /**this class represents a complete order*/
-class MOOrder:public MOOrderAbstract
+class MSIFACE_EXPORT MOOrder:public MOOrderAbstract
 {
        Q_OBJECT
        WOBJECT(MOOrder)
similarity index 91%
rename from src/wext/orderinfo.h
rename to iface/wext/orderinfo.h
index 570d018..b6505ea 100644 (file)
 #include "MOOrderInfoAbstract"
 #include "misc.h"
 
-class MOOrderInfo:public MOOrderInfoAbstract
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
+
+class MSIFACE_EXPORT MOOrderInfo:public MOOrderInfoAbstract
 {
        Q_OBJECT
        WOBJECT(MOOrderInfo)
similarity index 100%
rename from src/wext/ticket.cpp
rename to iface/wext/ticket.cpp
similarity index 93%
rename from src/wext/ticket.h
rename to iface/wext/ticket.h
index 7591786..eaf6e81 100644 (file)
 #include "misc.h"
 #include "MOEvent"
 
-class MOTicket:public MOTicketAbstract
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
+
+class MSIFACE_EXPORT MOTicket:public MOTicketAbstract
 {
        Q_OBJECT
        WOBJECT(MOTicket)
diff --git a/iface/wext/transaction.cpp b/iface/wext/transaction.cpp
new file mode 100644 (file)
index 0000000..0dd929c
--- /dev/null
@@ -0,0 +1,46 @@
+//
+// C++ Implementation: MTransaction
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010-2013
+//
+// Copyright: See COPYING.GPL file that comes with this distribution
+//
+//
+
+#include "MTransaction"
+
+#include "cleanup.h"
+
+static QList<MTStartStop>& startFunctions()
+{
+        static QList<MTStartStop>f;
+        return f;
+}
+
+static QList<MTStartStop>& stopFunctions()
+{
+        static QList<MTStartStop>f;
+        return f;
+}
+
+QByteArray MTransaction::executeQuery(QString hreq,QByteArray data)
+{
+       //show the user we are waiting
+       for(MTStartStop f:startFunctions())f();
+        MCleanup c([]{for(MTStartStop f:stopFunctions())f();});
+       //call parent
+       return WTransaction::executeQuery(hreq,data);
+}
+
+MTransaction::MTransaction(QString iface):WTransaction(iface){}
+MTransaction::MTransaction(const WTransaction&t):WTransaction(t){}
+MTransaction::MTransaction(const MTransaction&t):WTransaction(t){}
+
+void MTransaction::setStartStopActions(const MTStartStop& start, const MTStartStop& stop)
+{
+        startFunctions().append(start);
+        stopFunctions().append(stop);
+}
similarity index 58%
rename from src/wext/transaction.h
rename to iface/wext/transaction.h
index e212f7d..e533cdb 100644 (file)
@@ -4,7 +4,7 @@
 // Description: 
 //
 //
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010-2010
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010-2013
 //
 // Copyright: See COPYING.GPL file that comes with this distribution
 //
 #define MSMOKE_MTRANSACTION_H
 
 #include <WTransaction>
+#include <functional>
 
-class MTransaction:public WTransaction{
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
+typedef std::function<void()> MTStartStop;
+
+class MSIFACE_EXPORT MTransaction:public WTransaction{
+        public:
+                ///set actions to be executed at start/stop
+                static void setStartStopActions(const MTStartStop&start,const MTStartStop&stop);
        protected:
                /**internal: construct the transaction*/
                MTransaction(QString iface=QString());
similarity index 89%
rename from src/wext/voucher.h
rename to iface/wext/voucher.h
index 70f6a9d..aa93bf8 100644 (file)
 #include "MOVoucherAbstract"
 #include "misc.h"
 
-class MOVoucher:public MOVoucherAbstract
+#ifndef MSIFACE_EXPORT
+#define MSIFACE_EXPORT Q_DECL_IMPORT
+#endif
+
+
+class MSIFACE_EXPORT MOVoucher:public MOVoucherAbstract
 {
        Q_OBJECT
        WOBJECT(MOVoucher)
similarity index 100%
rename from src/wext/wext.pri
rename to iface/wext/wext.pri
index 5e1ac0c..1b2ba3f 100644 (file)
@@ -1,9 +1,8 @@
 #Project File for MagicSmoke
-# (c) Konrad Rosenbaum, 2007-2011
+# (c) Konrad Rosenbaum, 2007-2013
 
 TEMPLATE = app
 TARGET = magicsmoke
-DESTDIR = $$PWD/../bin
 
 #add the icon for windoze
 win32-* {
@@ -11,19 +10,13 @@ win32-* {
  RC_FILE += win.rc
 }
 
-#compilation output:
-OBJECTS_DIR = .ctmp
-MOC_DIR = .ctmp
-RCC_DIR = .ctmp
-
 #main source files
 SOURCES = main.cpp
 INCLUDEPATH += . ../src
 
 #make sure dependencies are found
 DEPENDPATH += $$INCLUDEPATH
-LIBS += -L$$PWD/../bin -lmagicsmoke
-include (../src/libs.pri)
+LIBS += -lmagicsmoke
 
 #security features
 linux-g++* {
@@ -31,15 +24,7 @@ linux-g++* {
   QMAKE_CFLAGS += -fPIE
   QMAKE_CXXFLAGS += -fPIE
   QMAKE_LFLAGS += -pie
-  #make sure we find our libs
-  QMAKE_LFLAGS += -Wl,-rpath,\'\$$ORIGIN\'
 }
-#protect the stack
-QMAKE_CFLAGS += -fstack-protector-all -Wstack-protector
-QMAKE_CXXFLAGS += -fstack-protector-all -Wstack-protector
 
-#ASLR for windows  
-win32 {
-  QMAKE_LFLAGS +=  -Wl,--nxcompat -Wl,--dynamicbase
-  LIBS += -lssp
-}
+include (../basics.pri)
+include (../src/libs.pri)
diff --git a/pack b/pack
index de50ef2..e06319c 160000 (submodule)
--- a/pack
+++ b/pack
@@ -1 +1 @@
-Subproject commit de50ef2ddfebf8bf0dc96540d03c51de0213d2a8
+Subproject commit e06319c7261d4189e8bcef16ed50b9739e6e13a5
diff --git a/src/iface/iface.pri b/src/iface/iface.pri
deleted file mode 100644 (file)
index 6dfac48..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-HEADERS += \
-       iface/msinterface.h \
-       iface/sslexception.h
-
-SOURCES += \
-       iface/msinterface.cpp \
-       iface/sslexception.cpp
-
-INCLUDEPATH += ./iface
\ No newline at end of file
index a52b7ea..8e1aded 100644 (file)
@@ -3,30 +3,12 @@
 # ZIP library
 include($$PWD/../taurus/zip.pri)
 
-# PACK library
-LIBS += -lqwbase
-INCLUDEPATH += $$PWD/../pack/qtbase/include
-
-# Time Zone DB library
-LIBS += -lQtTzData
-INCLUDEPATH += $$PWD/../tzone/include
-
-# ELAM library
-include($$PWD/../taurus/elam.pri)
-
-# Chester DPtr library
-include($$PWD/../taurus/chester.pri)
+# MagicSmoke Interface
+include ($$PWD/../iface/iface.pri)
 
 # Aurora Updater library
 include($$PWD/../taurus/aurora.pri)
 
 #make sure the correct Qt DLLs are used
-CONFIG += qt thread link_prl separate_debug_info
 QT += xml network script scripttools
 QT += widgets printsupport
-
-#activate C++11 for g++
-gcc {
-  message("detected GCC, activating C++11 with GNU extensions")
-  QMAKE_CXXFLAGS += -std=gnu++11
-}
index 9a7d1a9..5a3e34e 100644 (file)
@@ -22,6 +22,7 @@
 #include <QLocale>
 #include <QMenu>
 #include <QMessageBox>
+#include <QProgressDialog>
 #include <QSettings>
 #include <QSignalMapper>
 #include <QTranslator>
@@ -40,6 +41,7 @@
 #include <ELAM/Engine>
 #include "misc.h"
 #include <Aurora>
+#include "boxwrapper.h"
 
 QString choseLanguage(bool warn)
 {
@@ -69,42 +71,42 @@ QString choseLanguage(bool warn)
        return lang;
 }
 
-static QString dataDir;
-
-#include <stdlib.h>
-
-#ifdef Q_OS_WIN32
-#define BASEDIRVAR "APPDATA"
-#else
-#define BASEDIRVAR "HOME"
-#endif
-
-static inline QString resolveDir(const QString &dirspec)
+class MProgressWrapperGui:public MProgressWrapper
 {
-        //resolve pattern
-        const QStringList dirspecl=dirspec.split('/',QString::KeepEmptyParts);
-        bool notfirst=false;
-        QString rdir;
-        for(QString dcom:dirspecl){
-                if(dcom=="$BASE"){
-                        dcom=getenv(BASEDIRVAR);
-                        if(dcom.isEmpty())
-                                qFatal("Cannot determine base application data directory. While resolving %s",dirspec.toLatin1().data());
-                }else if(dcom=="$APP")
-                        dcom=qApp->applicationDirPath();
-                else if(dcom.startsWith("$"))
-                        dcom=getenv(dcom.mid(1).toLatin1().data());
-                //append component
-                if(notfirst)rdir+="/";
-                else notfirst=true;
-                rdir+=dcom;
-        }
-        //make sure it exists
-        if(!QDir::current().mkpath(rdir))
-                qFatal("Unable to create path '%s' for spec '%s'.",rdir.toLatin1().data(),dirspec.toLatin1().data());
-        //return it
-        return rdir;
-}
+        QProgressDialog*pd;
+        public:
+                MProgressWrapperGui(QString label,QString button)
+                {
+                        pd=new QProgressDialog(label,button,0,0);
+                        pd->setMinimumDuration(0);
+                        pd->show();
+                }
+                ~MProgressWrapperGui()
+                {
+                        if(pd)pd->deleteLater();
+                        pd=0;
+                }
+                virtual void setLabelText(QString l)
+                {
+                        pd->setLabelText(l);
+                }
+                virtual void setCancelButtonText(QString t)
+                {
+                        pd->setCancelButtonText(t);
+                }
+                virtual void cancel()
+                {
+                        pd->cancel();
+                }
+                virtual void setRange(int mi,int ma)
+                {
+                        pd->setRange(mi,ma);
+                }
+                virtual void setValue(int v)
+                {
+                        pd->setValue(v);
+                }
+};
 
 #ifndef HOMEPAGE_BASEURL
 #define HOMEPAGE_BASEURL "http://smoke.silmor.de"
@@ -127,7 +129,7 @@ void MApplication::aboutMS()
                        .arg(HOMEPAGE_BASEURL) //%2
                        .arg(MSInterface::staticVersionInfo(WOb::VersionRootURL)) //%3
                        .arg(MSInterface::staticVersionInfo(WOb::VersionNumber)) //%4
-                       .arg(ifc?ifc->dataDir(): ::dataDir)
+                       .arg(ifc?ifc->dataDir(): dataDir())
                );
        mb.setStandardButtons(QMessageBox::Ok);
        mb.exec();
@@ -286,6 +288,12 @@ MApplication::MApplication(int&ac,char**av)
         //install event filter for random generator
         installEventFilter(ef=new EFilter);
         
+        //init GUI wrappers
+        MBoxWrapper::setWarning([](QString title,QString text){QMessageBox::warning(nullptr,title,text);});
+        MProgressWrapper::setFactory([](QString label,QString button)->MProgressWrapper*{
+                return new MProgressWrapperGui(label,button);
+        });
+        
         //check parameters
 //         qDebug()<<"arguments"<<arguments();
         for(const QString& param:arguments()){
@@ -297,22 +305,21 @@ MApplication::MApplication(int&ac,char**av)
         }
         
         //data directory
-        if(::dataDir.isEmpty())
+        if(dataDir().isEmpty())
                 setDataDir("$BASE/.magicSmoke2");
 }
 
 void MApplication::setConfigDir(QString d)
 {
         QSettings::setDefaultFormat(QSettings::IniFormat);
-        const QString cdir=resolveDir(d);
+        const QString cdir=MSInterface::resolveDir(d);
         QSettings::setPath(QSettings::IniFormat,QSettings::UserScope,cdir);
         qDebug()<<"Setting the config directory to"<<cdir<<"from"<<d;
 }
 
 void MApplication::setDataDir(QString d)
 {
-        ::dataDir=resolveDir(d);
-        qDebug()<<"Setting the data directory to"<<::dataDir<<"from"<<d;
+        MSInterface::setAppDataDir(d);
 }
 
 
@@ -424,7 +431,7 @@ void MApplication::updaterFailed()
 
 QString MApplication::dataDir()
 {
-        return ::dataDir;
+        return MSInterface::appDataDir();
 }
 
 void MApplication::initProfile()
index 9739a91..229639f 100644 (file)
@@ -1,18 +1,14 @@
 HEADERS += \
        $$PWD/debug.h \
-       $$PWD/misc.h \
        $$PWD/waitcursor.h \
        $$PWD/sclock.h \
-       $$PWD/formula.h \
        $$PWD/dommodel.h
 
 SOURCES += \
        $$PWD/code39.cpp \
        $$PWD/debug.cpp \
-       $$PWD/misc.cpp \
        $$PWD/waitcursor.cpp \
        $$PWD/sclock.cpp \
-       $$PWD/formula.cpp \
        $$PWD/dommodel.cpp
 
 INCLUDEPATH += $$PWD
index 270e885..a43dbad 100644 (file)
@@ -4,13 +4,14 @@
 // Description: 
 //
 //
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2009-2011
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2009-2013
 //
 // Copyright: See README/COPYING.GPL files that come with this distribution
 //
 //
 
 #include "waitcursor.h"
+#include <MTransaction>
 
 #include <QApplication>
 #include <QCursor>
@@ -24,3 +25,13 @@ WaitCursor::~WaitCursor()
 {
        QApplication::restoreOverrideCursor();
 }
+
+static int transactionCursor()
+{
+        MTransaction::setStartStopActions(
+                []{QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));},
+                []{QApplication::restoreOverrideCursor();}
+        );
+}
+
+static int tcdummy=transactionCursor();
\ No newline at end of file
index 996ce1a..6e91bc0 100644 (file)
@@ -3,7 +3,6 @@
 
 TEMPLATE = lib
 TARGET = magicsmoke
-DESTDIR = $$PWD/../bin
 VERSION = 
 
 #Localization
@@ -12,15 +11,6 @@ TRANSLATIONS = \
        smoke_de_SAX.ts \
        smoke_en.ts
 
-#hide classes that are not explicitly exported
-# this is default on Windows, we have it here to have all systems behave the same way
-CONFIG += hide_symbols
-
-#compilation output:
-OBJECTS_DIR = .ctmp
-MOC_DIR = .ctmp
-RCC_DIR = .ctmp
-
 #main source files
 SOURCES = main.cpp
 HEADERS = main.h
@@ -39,28 +29,16 @@ DEFINES += HOMEPAGE_BASEURL=\\\"http://smoke.silmor.de\\\"
 RESOURCES += images/files.qrc
 
 #libraries, modules, stuff...
-include(libs.pri)
 include(widgets/widgets.pri)
 include(templates/templates.pri)
-include(iface/iface.pri)
 include(misc/misc.pri)
 include(crypto/crypto.pri)
 include(dialogs/dialogs.pri)
 include(mwin/mwin.pri)
 include(script/script.pri)
 
-#build generated stuff last
-include(wext/wext.pri)
-include(wob/wob.pri)
+include (../basics.pri)
+include (libs.pri)
 
 #make sure dependencies are found
 DEPENDPATH += $$INCLUDEPATH
-LIBS += -L$$PWD/../bin
-
-#protect the stack
-QMAKE_CFLAGS += -fstack-protector-all -Wstack-protector
-QMAKE_CXXFLAGS += -fstack-protector-all -Wstack-protector
-win32 {
-  QMAKE_LFLAGS +=  -Wl,--nxcompat
-  LIBS += -lssp
-}
index ff720f5..00680df 100644 (file)
@@ -4,7 +4,7 @@
 // Description: 
 //
 //
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008-2011
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2008-2013
 //
 // Copyright: See README/COPYING.GPL files that come with this distribution
 //
 #include <QStandardItemModel>
 #include <QTreeView>
 
-MTemplateChoice::MTemplateChoice(const QString&cd,const QString&tname,const QStringList&choices,const QString&sg)
-       :sgroup(sg),cachedir(cd)
+MTemplateChoice::MTemplateChoice(const QList<MTemplate>&tl)
+       :templst(tl)
 {
        setWindowTitle(tr("Chose Template"));
        setSizeGripEnabled(true);
        QVBoxLayout *vl;
        setLayout(vl=new QVBoxLayout);
-       vl->addWidget(new QLabel(tr("Please chose a variant of template %1:").arg(tname)));
+       vl->addWidget(new QLabel(tr("Please chose a variant of template %1:").arg(templst.value(0).fileName())));
        vl->addWidget(box=new QComboBox);
        box->setEditable(false);
-       QSettings set;
-       set.beginGroup(sg);
-       for(int i=0;i<choices.size();i++){
-               QStringList vs=choices[i].split(",");
-               QString v,d;
-               if(vs.size()>1)v=vs[1];
-               else v=tr("(default)","default template pseudo-variant");
-               d=set.value(choices[i]+"/description").toString();
-               box->addItem(v+": "+d,choices[i]);
+       for(const MTemplate&tmp:templst){
+               box->addItem(tmp.fileName()+": "+tmp.description());
        }
        vl->addStretch(1);
        QHBoxLayout *hl;
@@ -60,14 +53,20 @@ MTemplateChoice::MTemplateChoice(const QString&cd,const QString&tname,const QStr
 
 MTemplate MTemplateChoice::choice()const
 {
-       QString fn=box->itemData(box->currentIndex()).toString();
-       QSettings set;
-       set.beginGroup(sgroup+"/"+fn);
-       return MTemplate(cachedir+"/"+fn, set.value("checksum").toString(), set.value("description").toString(), set.value("flags").toString());
+        return templst.value(box->currentIndex());
 }
 
-
-
+static inline int initTemplateChoser()
+{
+        MTemplate::setTemplateChoiceFunction([](const QList<MTemplate>&tl)->MTemplate{
+                MTemplateChoice tc(tl);
+                if(tc.exec()==QDialog::Accepted)
+                        return tc.choice();
+                return MTemplate();
+        });
+        return 0;
+}
+static int dummy=initTemplateChoser();
 /**************************************************************/
 
 MTemplateEditor::MTemplateEditor(MTemplateStore*s)
index 640689d..316980d 100644 (file)
@@ -29,15 +29,15 @@ class MTemplateChoice:public QDialog
 {
        Q_OBJECT
        public:
-               MTemplateChoice(const QString&,const QString&,const QStringList&,const QString&);
+               MTemplateChoice(const QList<MTemplate>&);
                
                ///returns the choice made by the user
                MTemplate choice()const;
        private:
                //selection box
                QComboBox*box;
-               //settings group where to find data
-               QString sgroup,cachedir;
+               //data
+               QList<MTemplate>templst;
 };
 
 /**lets the user add and remove templates and variants to/from the database; used by MWebRequest!*/
index 9790050..cb72c6f 100644 (file)
@@ -3,7 +3,6 @@ HEADERS += \
        $$PWD/ticketrender.h \
        $$PWD/office.h \
        $$PWD/labeldlg.h \
-       $$PWD/templates.h \
        $$PWD/templatedlg.h \
        $$PWD/ticketedit.h \
        $$PWD/odfedit.h
@@ -13,7 +12,6 @@ SOURCES += \
        $$PWD/ticketrender.cpp \
        $$PWD/office.cpp \
        $$PWD/labeldlg.cpp \
-       $$PWD/templates.cpp \
        $$PWD/templatedlg.cpp \
        $$PWD/ticketedit.cpp \
        $$PWD/odfedit.cpp
diff --git a/src/wext/transaction.cpp b/src/wext/transaction.cpp
deleted file mode 100644 (file)
index cc54f0b..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-//
-// C++ Implementation: MTransaction
-//
-// Description: 
-//
-//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2010-2011
-//
-// Copyright: See COPYING.GPL file that comes with this distribution
-//
-//
-
-#include "MTransaction"
-#include "waitcursor.h"
-
-QByteArray MTransaction::executeQuery(QString hreq,QByteArray data)
-{
-       //show the user we are waiting
-       WaitCursor wc;
-       //call parent
-       return WTransaction::executeQuery(hreq,data);
-}
-
-MTransaction::MTransaction(QString iface):WTransaction(iface){}
-MTransaction::MTransaction(const WTransaction&t):WTransaction(t){}
-MTransaction::MTransaction(const MTransaction&t):WTransaction(t){}
index 5728acb..3893bcf 100644 (file)
@@ -8,7 +8,7 @@
   -->
 <Wolf>
        <Doc>These files describe the database schema and communication protocol of MagicSmoke.</Doc>
-       <Doc>&amp;copy; Konrad Rosenbaum, 2009-2011
+       <Doc>&amp;copy; Konrad Rosenbaum, 2009-2013
        &lt;br/>these files are protected under the GNU AGPLv3 or at your option any newer
        </Doc>
        <!-- generic settings -->
@@ -17,7 +17,7 @@
        <Include file="db/db.wolf"/>
        
        <!-- configure output -->
-       <QtClientOutput sourceDir="src" subDir="wob" priInclude="wob.pri" classPrefix="M" clean="yes" transactionBase="MTransaction" scriptable="yes"/>
+       <QtClientOutput sourceDir="iface" subDir="wob" priInclude="wob.pri" classPrefix="M" clean="yes" transactionBase="MTransaction" scriptable="yes" enableExport="yes"/>
        <PHPServerOutput sourceDir="www" subDir="inc/wob" extension=".php" clean="yes" transactionBase="MSmokeTransaction"/>
        <HtmlOutput sourceDir="doc" subDir="wob" clean="yes"/>
        <!-- SchemaOutput sourceDir="wob" filename="test.xsd" compound="cmp.xsd"/ -->