#generated sources, translations, docu
doc/wob
-src/wob
+iface/wob
www/inc/wob
*.qm
doc/source-cpp/
--- /dev/null
+#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\'
+}
--- /dev/null
+#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)
--- /dev/null
+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
--- /dev/null
+# 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
--- /dev/null
+//
+// 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;
+}
--- /dev/null
+//
+// 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
#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:
#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);
#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;
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:
--- /dev/null
+HEADERS += \
+ $$PWD/misc.h \
+ $$PWD/boxwrapper.h \
+ $$PWD/formula.h
+
+SOURCES += \
+ $$PWD/misc.cpp \
+ $$PWD/boxwrapper.cpp \
+ $$PWD/formula.cpp
+
+INCLUDEPATH += $$PWD
//
#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()
{
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;
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
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;
}
//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."));
}
}
#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)
///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*/
#include "sslexception.h"
#include <QDebug>
-#include <QDialog>
+// #include <QDialog>
#include <QDomDocument>
#include <QDomElement>
#include <QDomNodeList>
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*/
* 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;
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)
}
//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();
//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]))
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;
#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*/
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&);
/**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;
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;
--- /dev/null
+HEADERS += \
+ $$PWD/templates.h
+
+SOURCES += \
+ $$PWD/templates.cpp
+
+INCLUDEPATH += $$PWD
\ No newline at end of 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)
#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)
#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)
#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)
#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)
#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)
#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)
--- /dev/null
+//
+// 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);
+}
// 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());
#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)
#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-* {
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++* {
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)
-Subproject commit de50ef2ddfebf8bf0dc96540d03c51de0213d2a8
+Subproject commit e06319c7261d4189e8bcef16ed50b9739e6e13a5
+++ /dev/null
-HEADERS += \
- iface/msinterface.h \
- iface/sslexception.h
-
-SOURCES += \
- iface/msinterface.cpp \
- iface/sslexception.cpp
-
-INCLUDEPATH += ./iface
\ No newline at end of file
# 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
-}
#include <QLocale>
#include <QMenu>
#include <QMessageBox>
+#include <QProgressDialog>
#include <QSettings>
#include <QSignalMapper>
#include <QTranslator>
#include <ELAM/Engine>
#include "misc.h"
#include <Aurora>
+#include "boxwrapper.h"
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"
.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();
//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()){
}
//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);
}
QString MApplication::dataDir()
{
- return ::dataDir;
+ return MSInterface::appDataDir();
}
void MApplication::initProfile()
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
// 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>
{
QApplication::restoreOverrideCursor();
}
+
+static int transactionCursor()
+{
+ MTransaction::setStartStopActions(
+ []{QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));},
+ []{QApplication::restoreOverrideCursor();}
+ );
+}
+
+static int tcdummy=transactionCursor();
\ No newline at end of file
TEMPLATE = lib
TARGET = magicsmoke
-DESTDIR = $$PWD/../bin
VERSION =
#Localization
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
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
-}
// 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;
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)
{
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!*/
$$PWD/ticketrender.h \
$$PWD/office.h \
$$PWD/labeldlg.h \
- $$PWD/templates.h \
$$PWD/templatedlg.h \
$$PWD/ticketedit.h \
$$PWD/odfedit.h
$$PWD/ticketrender.cpp \
$$PWD/office.cpp \
$$PWD/labeldlg.cpp \
- $$PWD/templates.cpp \
$$PWD/templatedlg.cpp \
$$PWD/ticketedit.cpp \
$$PWD/odfedit.cpp
+++ /dev/null
-//
-// 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){}
-->
<Wolf>
<Doc>These files describe the database schema and communication protocol of MagicSmoke.</Doc>
- <Doc>&copy; Konrad Rosenbaum, 2009-2011
+ <Doc>&copy; Konrad Rosenbaum, 2009-2013
<br/>these files are protected under the GNU AGPLv3 or at your option any newer
</Doc>
<!-- generic settings -->
<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"/ -->