...converting main app to new iface, does not compile yet
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 27 Mar 2009 07:18:42 +0000 (07:18 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Fri, 27 Mar 2009 07:18:42 +0000 (07:18 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@280 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

29 files changed:
src/eventedit.h
src/eventsummary.cpp
src/eventsummary.h
src/main.cpp
src/main.h
src/mainwindow.cpp
src/msinterface.cpp [new file with mode: 0644]
src/msinterface.h [new file with mode: 0644]
src/overview.cpp
src/overview.h
src/smoke.pro
src/wbase/WInterface.cpp
src/wbase/WInterface.h
src/wbase/WTransaction.cpp
src/webrequest.cpp [deleted file]
src/webrequest.h [deleted file]
src/widgets/centbox.cpp [moved from src/centbox.cpp with 100% similarity]
src/widgets/centbox.h [moved from src/centbox.h with 100% similarity]
src/widgets/checkdlg.cpp [moved from src/checkdlg.cpp with 100% similarity]
src/widgets/checkdlg.h [moved from src/checkdlg.h with 100% similarity]
src/widgets/waitcursor.cpp [new file with mode: 0644]
src/widgets/waitcursor.h [new file with mode: 0644]
src/widgets/widgets.pri [new file with mode: 0644]
wob/event.wolf
wob/magicsmoke.wolf
woc/phpout.cpp
woc/processor.cpp
woc/processor.h
woc/qtout.cpp

index af4e681..d795a9d 100644 (file)
@@ -30,7 +30,7 @@ class MEventEditor:public QDialog
 {
        Q_OBJECT
        public:
-               MEventEditor(QWidget*,MWebRequest*,qint32 id=-1);
+               MEventEditor(QWidget*,qint32 id=-1);
        private slots:
                void writeBack();
                void selectRoom();
@@ -39,7 +39,6 @@ class MEventEditor:public QDialog
                void startTimeChanged(const QDateTime&);
                void endTimeChanged(const QDateTime&);
        private:
-               MWebRequest*req;
                MEvent event;
                QDateTimeEdit*starttime,*endtime;
                QLineEdit*title,*artist,*room,*price,*cancelreason;
index 81f389e..07d6f00 100644 (file)
 #include <QTableView>
 #include <QTextBrowser>
 
-MEventSummary::MEventSummary(QWidget*par,MWebRequest*rq,int eid)
+MEventSummary::MEventSummary(QWidget*par,int eid)
        :QDialog(par),event(rq,eid)
 {
-       req=rq;
        nreserved=ncancelled=ntotaltickets=ntotalmoney=0;
        //get event data
        getSummaryData();
index b5ce8cd..99c956e 100644 (file)
@@ -19,7 +19,6 @@
 #include "order.h"
 #include "odtrender.h"
 
-class MWebRequest;
 class QTableView;
 class QStandardItemModel;
 class QLabel;
@@ -30,7 +29,7 @@ class MEventSummary:public QDialog
        Q_OBJECT
        public:
                /**creates a new summary dialog, requests data from server*/
-               MEventSummary(QWidget*parent,MWebRequest*req,int eventid);
+               MEventSummary(QWidget*parent,int eventid);
                /**deletes MEventSummary*/
                ~MEventSummary();
                
@@ -46,7 +45,6 @@ class MEventSummary:public QDialog
                void getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&);
                
        private:
-               MWebRequest*req;
                int eventid;
                MEvent event;
                int nreserved,ncancelled,ntotaltickets,ntotalmoney;
index f6d1972..3595d95 100644 (file)
@@ -11,7 +11,6 @@
 //
 
 #include <QApplication>
-#include <QCursor>
 #include <QDir>
 #include <QHostInfo>
 #include <QIcon>
 #include "main.h"
 #include "debug.h"
 
-WaitCursor::WaitCursor()
-{
-       QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
-}
-
-WaitCursor::~WaitCursor()
-{
-       QApplication::restoreOverrideCursor();
-}
 
 QString choseLanguage(bool warn)
 {
index bd7eee0..7be4ad9 100644 (file)
@@ -21,14 +21,4 @@ QString choseLanguage(bool warn=true);
 /**contains the directory that is used for external data storage*/
 extern QString dataDir;
 
-/**simple class to show a busy-cursor while an instance of it exists*/
-class WaitCursor
-{
-       public:
-               /**displays a wait cursor (Qt::WaitCursor)*/
-               WaitCursor();
-               /**restores the last normal cursor*/
-               ~WaitCursor();
-};
-
 #endif
index 35cfae5..9ac8dee 100644 (file)
@@ -13,9 +13,9 @@
 #include "keygen.h"
 #include "main.h"
 #include "mainwindow.h"
+#include "msinterface.h"
 #include "office.h"
 #include "overview.h"
-#include "webrequest.h"
 
 #include <QApplication>
 #include <QByteArray>
@@ -205,7 +205,7 @@ void MMainWindow::startLogin()
        //make it impossible for the user to interfere
        setEnabled(false);
        //create request object
-       MWebRequest *mw=new MWebRequest(profiles->itemData(profiles->currentIndex()).toString());
+       MSInterface *mw=new MSInterface(profiles->itemData(profiles->currentIndex()).toString());
        mw->setUrl(serverurl->text());
        if(useproxy->isChecked())
                mw->setProxy(proxyname->text(),proxyport->value(),proxyuser->text(),proxypass->text());
@@ -214,16 +214,16 @@ void MMainWindow::startLogin()
        if(usealterhost->isChecked())hn=alterhostname->text();
        else hn=QSettings().value("hostname").toString();
        if(!mw->login(username->text(),password->text(),hn)){
-               QMessageBox::warning(this,tr("Warning"),tr("Unable to log in. Error: %1").arg(mw->errorString()));
+               QMessageBox::warning(this,tr("Warning"),tr("Unable to log in."));
                mw->deleteLater();
                setEnabled(true);
                return;
        }
        //open window
-       MOverview *mo=new MOverview(mw,profiles->itemData(profiles->currentIndex()).toString());
+       MOverview *mo=new MOverview(profiles->itemData(profiles->currentIndex()).toString());
        mo->show();
        
-       //make sure the application exits after everything is cleaned up
+       //make sure the application exits (only) after everything is cleaned up
        qApp->setQuitOnLastWindowClosed(false);
        connect(mw,SIGNAL(destroyed(QObject*)),qApp,SLOT(quit()));
        
diff --git a/src/msinterface.cpp b/src/msinterface.cpp
new file mode 100644 (file)
index 0000000..92b6eca
--- /dev/null
@@ -0,0 +1,19 @@
+//
+// C++ Implementation: msinterface
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2009
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include "msinterface.h"
+
+MSInterface::MSInterface(QString pid)
+       :MInterface()
+{
+       profileid=pid;
+}
\ No newline at end of file
diff --git a/src/msinterface.h b/src/msinterface.h
new file mode 100644 (file)
index 0000000..1cea735
--- /dev/null
@@ -0,0 +1,36 @@
+//
+// C++ Interface: msinterface
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2009
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_MSINTERFACE_H
+#define MAGICSMOKE_MSINTERFACE_H
+
+#include "MInterface.h"
+
+class MSInterface:public MInterface
+{
+       Q_OBJECT
+       public:
+               MSInterface(QString);
+               
+               static MSInterface* instance(){return qobject_cast<MSInterface*>(MInterface::instance());}
+               
+               bool login(QString,QString,QString);
+               void logout();
+               bool relogin();
+               QString currentUser()const;
+               bool hasRole(QString)const;
+       private:
+               QString profileid;
+};
+
+
+#endif
index 2d0b24a..2e4e4a0 100644 (file)
 #include "eventsummary.h"
 #include "misc.h"
 #include "moneylog.h"
+#include "msinterface.h"
 #include "orderwin.h"
 #include "overview.h"
-#include "webrequest.h"
+
+#include "user.h"
+#include "host.h"
 
 #include <QApplication>
 #include <QBoxLayout>
 #define ORDERUNSENT    4
 #define ORDERRESERVE   8
 
-MOverview::MOverview(MWebRequest*mw,QString pk)
+#define req (MSInterface::instance())
+
+MOverview::MOverview(QString pk)
 {
        profilekey=pk;
-       req=mw;
        setAttribute(Qt::WA_DeleteOnClose);
-       setWindowTitle("MagicSmoke: "+mw->currentUser()+"@"+QSettings().value("profiles/"+pk+"/name").toString());
+       setWindowTitle("MagicSmoke: "+req->currentUser()+"@"+QSettings().value("profiles/"+pk+"/name").toString());
        rtimer.setInterval(QSettings().value("profiles/"+pk+"/refresh",300).toInt()*1000);
        rtimer.start();
        connect(&rtimer,SIGNAL(timeout()),this,SLOT(refreshData()));
@@ -367,22 +371,22 @@ MOverview::MOverview(MWebRequest*mw,QString pk)
 
 void MOverview::updateEvents()
 {
-       QList<MEvent>evl=req->getAllEvents();
+       QList<MOEvent>evl=req->queryGetAllEvents().getevents();
        eventmodel->clear();
        eventmodel->insertColumns(0,6);
        eventmodel->setHorizontalHeaderLabels(QStringList()<<tr("Start Time")<<tr("Title")<<tr("Free")<<tr("Reserved")<<tr("Sold")<<tr("Capacity"));
        QDateTime now=QDateTime::currentDateTime();
        for(int i=0,j=0;i<evl.size();i++){
-               QDateTime stime=QDateTime::fromTime_t(evl[i].startTime());
+               QDateTime stime=QDateTime::fromTime_t(evl[i].start());
                if(stime<now && !showoldevents->isChecked())continue;
                eventmodel->insertRow(j);
-               eventmodel->setData(eventmodel->index(j,0),evl[i].eventId(),Qt::UserRole);
+               eventmodel->setData(eventmodel->index(j,0),evl[i].id().value(),Qt::UserRole);
                eventmodel->setData(eventmodel->index(j,0),stime.toString(tr("ddd MMMM d yyyy, h:mm ap","time format")));
-               eventmodel->setData(eventmodel->index(j,1),evl[i].title());
+               eventmodel->setData(eventmodel->index(j,1),evl[i].title().value());
                eventmodel->setData(eventmodel->index(j,2),evl[i].capacity()-evl[i].amountSold()-evl[i].amountReserved());
-               eventmodel->setData(eventmodel->index(j,3),evl[i].amountReserved());
-               eventmodel->setData(eventmodel->index(j,4),evl[i].amountSold());
-               eventmodel->setData(eventmodel->index(j,5),evl[i].capacity());
+               eventmodel->setData(eventmodel->index(j,3),evl[i].amountReserved().value());
+               eventmodel->setData(eventmodel->index(j,4),evl[i].amountSold().value());
+               eventmodel->setData(eventmodel->index(j,5),evl[i].capacity().value());
                j++;
        }
        eventtable->resizeColumnsToContents();
@@ -408,13 +412,13 @@ void MOverview::relogin()
 {
        setEnabled(false);
        if(!req->relogin())
-               QMessageBox::warning(this,tr("Warning"),tr("I was unable to renew the login at the server, the error was: %1").arg(req->errorString()));
+               QMessageBox::warning(this,tr("Warning"),tr("I was unable to renew the login at the server."));
        setEnabled(true);
 }
 
 void MOverview::newEvent()
 {
-       MEventEditor ed(this,req);
+       MEventEditor ed(this);
        ed.exec();
        updateEvents();
 }
@@ -427,7 +431,7 @@ void MOverview::editEvent()
        QModelIndex idx=eventmodel->index(ilst[0].row(),0);
        id=eventmodel->data(idx,Qt::UserRole).toInt();
        if(id<0)return;
-       MEventEditor ed(this,req,id);
+       MEventEditor ed(this,id);
        ed.exec();
        updateEvents();
 }
@@ -440,7 +444,7 @@ void MOverview::eventSummary()
        QModelIndex idx=eventmodel->index(ilst[0].row(),0);
        id=eventmodel->data(idx,Qt::UserRole).toInt();
        if(id<0)return;
-       MEventSummary ed(this,req,id);
+       MEventSummary ed(this,id);
        ed.exec();
 }
 
@@ -1005,7 +1009,7 @@ void MOverview::cartOrder()
                QMessageBox::warning(this,tr("Error"),tr("The request failed."));
                return;
        }
-       if(req->responseStatus()!=MWebRequest::Ok){
+       if(req->responseStatus()!=MSInterface::Ok){
                QMessageBox::warning(this,tr("Error"),tr("A problem occurred during the order: %1").arg(qApp->translate("php::",req->responseBody())));
                return;
        }
@@ -1183,7 +1187,7 @@ void MOverview::orderByTicket()
                QMessageBox::warning(this,tr("Warning"),tr("Unable to query server."));
                return;
        }
-       if(req->responseStatus()!=MWebRequest::Ok){
+       if(req->responseStatus()!=MSInterface::Ok){
                QMessageBox::warning(this,tr("Warning"),qApp->translate("php::",req->responseBody()));
                return;
        }
@@ -1386,7 +1390,7 @@ void MOverview::deductVoucher()
                QMessageBox::warning(this,tr("Warning"),tr("Request failed."));
                return;
        }
-       if(req->responseStatus()!=MWebRequest::Ok){
+       if(req->responseStatus()!=MSInterface::Ok){
                QMessageBox::warning(this,tr("Warning"),tr("Request failed."));
                return;
        }
@@ -1463,7 +1467,7 @@ void MOverview::webSettings(bool showdlg)
        QSettings set;
        set.beginGroup("profiles/"+profilekey);
        //get settings
-       MWebRequest::LogLevel lvl=MWebRequest::LogLevel(set.value("webloglevel", MWebRequest::LogOnError).toInt());
+       MSInterface::LogLevel lvl=MSInterface::LogLevel(set.value("webloglevel", MSInterface::LogOnError).toInt());
        int timeout=set.value("webtimeout",30).toInt();
        //dialog
        if(showdlg){
@@ -1480,13 +1484,13 @@ void MOverview::webSettings(bool showdlg)
                QComboBox *log;
                gl->addWidget(new QLabel(tr("Log Level:")),1,0);
                gl->addWidget(log=new QComboBox,1,1);
-               log->addItem(tr("Minimal Logging"),MWebRequest::LogMinimal);
-               log->addItem(tr("Log Details on Error"),MWebRequest::LogOnError);
-               log->addItem(tr("Always Log Details"),MWebRequest::LogDetailed);
+               log->addItem(tr("Minimal Logging"),MSInterface::LogMinimal);
+               log->addItem(tr("Log Details on Error"),MSInterface::LogOnError);
+               log->addItem(tr("Always Log Details"),MSInterface::LogDetailed);
                switch(lvl){
-                       case MWebRequest::LogMinimal:log->setCurrentIndex(0);break;
-                       case MWebRequest::LogOnError:log->setCurrentIndex(1);break;
-                       case MWebRequest::LogDetailed:log->setCurrentIndex(2);break;
+                       case MSInterface::LogMinimal:log->setCurrentIndex(0);break;
+                       case MSInterface::LogOnError:log->setCurrentIndex(1);break;
+                       case MSInterface::LogDetailed:log->setCurrentIndex(2);break;
                }
                gl->setRowMinimumHeight(2,15);
                gl->addLayout(hl=new QHBoxLayout,3,0,1,2);
@@ -1498,7 +1502,7 @@ void MOverview::webSettings(bool showdlg)
                connect(p,SIGNAL(clicked()),&d,SLOT(reject()));
                if(d.exec()!=QDialog::Accepted)return;
                //write settings
-               lvl=MWebRequest::LogLevel(log->itemData(log->currentIndex()).toInt());
+               lvl=MSInterface::LogLevel(log->itemData(log->currentIndex()).toInt());
                timeout=tmout->value();
                set.setValue("webloglevel",lvl);
                set.setValue("webtimeout",timeout);
@@ -1520,7 +1524,7 @@ void MOverview::doBackup()
        int gens=set.value("backupgenerations",3).toInt();
        //get data
        bool ok=req->request("backup");
-       if(ok)ok=req->responseStatus()==MWebRequest::Ok;
+       if(ok)ok=req->responseStatus()==MSInterface::Ok;
        if(!ok){
                QMessageBox::warning(this,tr("Warning"),tr("Backup failed with error: %1").arg(req->errorString()));
                return;
@@ -1580,7 +1584,7 @@ void MOverview::moneylogUser()
 
 /**********************************************/
 
-MBackupDialog::MBackupDialog(QWidget*par,QString pk,MWebRequest*req)
+MBackupDialog::MBackupDialog(QWidget*par,QString pk,MSInterface*req)
        :QDialog(par),profilekey(pk)
 {
        QSettings set;
index fa426e9..b3bea8e 100644 (file)
 #include <QDialog>
 #include <QItemDelegate>
 #include <QMainWindow>
-#include <QPointer>
 #include <QTimer>
 
 #include "customer.h"
 
-class MWebRequest;
 class QAction;
 class QCheckBox;
 class QComboBox;
@@ -40,7 +38,7 @@ class MOverview:public QMainWindow
        Q_OBJECT
        public:
                /**construct the window with web-request/session handler and QSettings-key for current profile*/
-               MOverview(MWebRequest*,QString);
+               MOverview(QString);
                ~MOverview();
        protected:
                /**handle closing the window: close the session too*/
@@ -162,8 +160,6 @@ class MOverview:public QMainWindow
                void backupSettings();
                
        private:
-               //my session object
-               QPointer<MWebRequest>req;
                //the profile associated with this session
                QString profilekey;
                //widgets
@@ -222,7 +218,7 @@ class MBackupDialog:public QDialog
 {
        Q_OBJECT
        public:
-               MBackupDialog(QWidget*,QString,MWebRequest*);
+               MBackupDialog(QWidget*,QString);
                
        private slots:
                void getpath();
index 5fb39bd..8be0349 100644 (file)
@@ -28,7 +28,6 @@ SOURCES = \
        mainwindow.cpp \
        hmac.cpp \
        code39.cpp \
-       webrequest.cpp \
        overview.cpp \
        eventedit.cpp \
        event.cpp \
@@ -38,7 +37,6 @@ SOURCES = \
        order.cpp \
        shipping.cpp \
        customer.cpp \
-       checkdlg.cpp \
        eventsummary.cpp \
        odtrender.cpp \
        ticketrender.cpp \
@@ -48,7 +46,6 @@ SOURCES = \
        templates.cpp \
        templatedlg.cpp \
        office.cpp \
-       centbox.cpp \
        moneylog.cpp \
        autoupdate.cpp \
        domquery.cpp
@@ -58,7 +55,6 @@ HEADERS = \
        debug.h \
        mainwindow.h \
        hmac.h \
-       webrequest.h \
        overview.h \
        eventedit.h \
        event.h \
@@ -68,7 +64,6 @@ HEADERS = \
        order.h \
        shipping.h \
        customer.h \
-       checkdlg.h \
        eventsummary.h \
        odtrender.h \
        ticketrender.h \
@@ -78,7 +73,6 @@ HEADERS = \
        templates.h \
        templatedlg.h \
        office.h \
-       centbox.h \
        moneylog.h \
        autoupdate.h \
        domquery.h
@@ -96,6 +90,7 @@ TRANSLATIONS = \
 
 
 include(../zip/zip.pri)
+include(widgets/widgets.pri)
 include(wbase/wbase.pri)
 include(wob/wob.pri)
 
index 04b191d..40d9d43 100644 (file)
@@ -30,6 +30,7 @@ WInterface::WInterface(QString name)
 {
        m_proxyport=0;
        m_wtimeout=30;
+       loglvl=LogOnError;
        QMutexLocker ml(&mtx);
        if(inst.contains(name)){
                delete inst[name];
index 5c3625b..29b2983 100644 (file)
@@ -30,17 +30,11 @@ class WInterface:public QObject
                
                /**returns the URL of the interface*/
                QUrl url()const{return m_url;}
-               /**sets the URL of the interface*/
-               void setUrl(QUrl u){m_url=u;}
                
                /**returns whether the interface uses a proxy*/
                bool useProxy()const{return m_proxyhost!="";}
                /**returns whether the proxy needs authentication*/
                bool useProxyAuth()const{return m_proxyuser!="";}
-               /**resets the proxy settings to no proxy use*/
-               void resetProxy(){m_proxyhost="";m_proxyport=0;m_proxyuser="";m_proxypass="";}
-               /**sets the proxy settings*/
-               void setProxy(QString proxyhost,unsigned short proxyport,QString proxyuser="",QString proxypassword=""){m_proxyhost=proxyhost;m_proxyport=proxyport;m_proxyuser=proxyuser;m_proxypass=proxypassword;}
                /**returns the proxy host name*/
                QString proxyHost()const{return m_proxyhost;}
                /**returns the proxy port*/
@@ -52,8 +46,6 @@ class WInterface:public QObject
                
                /**return timeout in seconds*/
                int webTimeout()const{return m_wtimeout;}
-               /**set timeout for page loads in seconds*/
-               void setWebTimeout(int t){if(t>0)m_wtimeout=t;}
                
                /**get the name for this interface (returns empty string if not registered*/
                QString name()const;
@@ -61,12 +53,41 @@ class WInterface:public QObject
                /**returns the instance registered under that name*/
                static WInterface*instance(QString);
                
+               /**log settings*/
+               enum LogLevel {
+                       /**minimal logging*/
+                       LogMinimal=0,
+                       /**log details on error*/
+                       LogOnError=1,
+                       /**always log details*/
+                       LogDetailed=0xf
+               };
+               
+               /**returns the current log level*/
+               LogLevel logLevel()const{return loglvl;}
+
+       public slots:
+               /**set log level*/
+               void setLogLevel(WInterface::LogLevel l){loglvl=l;}
+               
+               /**set timeout for page loads in seconds*/
+               void setWebTimeout(int t){if(t>0)m_wtimeout=t;}
+               
+               /**resets the proxy settings to no proxy use*/
+               void resetProxy(){m_proxyhost="";m_proxyport=0;m_proxyuser="";m_proxypass="";}
+               /**sets the proxy settings*/
+               void setProxy(QString proxyhost,unsigned short proxyport,QString proxyuser="",QString proxypassword=""){m_proxyhost=proxyhost;m_proxyport=proxyport;m_proxyuser=proxyuser;m_proxypass=proxypassword;}
+       
+               /**sets the URL of the interface*/
+               void setUrl(QUrl u){m_url=u;}
+       
        private:
                static QMap<QString,WInterface*>inst;
                QUrl m_url;
                QString m_proxyhost,m_proxyuser,m_proxypass;
                unsigned short m_proxyport;
                int m_wtimeout;
+               LogLevel loglvl;
 };
 
 #endif
index f5f2eba..232c0a3 100644 (file)
@@ -13,8 +13,7 @@
 #include "WTransaction.h"
 #include "WInterface.h"
 
-//WaitCursor, TODO: refactor this
-#include "main.h"
+#include "waitcursor.h"
 
 #include <QDebug>
 #include <QEventLoop>
diff --git a/src/webrequest.cpp b/src/webrequest.cpp
deleted file mode 100644 (file)
index 2156e87..0000000
+++ /dev/null
@@ -1,649 +0,0 @@
-//
-// C++ Implementation: webrequest
-//
-// Description: 
-//
-//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007
-//
-// Copyright: See README/COPYING files that come with this distribution
-//
-//
-
-#include "hmac.h"
-#include "keygen.h"
-#include "main.h"
-#include "templatedlg.h"
-#include "version.h"
-#include "webrequest.h"
-
-#include <QDir>
-#include <QDomDocument>
-#include <QDomElement>
-#include <QDomNodeList>
-#include <QEventLoop>
-#include <QSettings>
-#include <QTimer>
-
-#include <QtDebug>
-
-static QPointer<MWebRequest>sinst;
-
-MWebRequest::MWebRequest(QString pid)
-       :temp(this,pid)
-{
-       sinst=this;
-       profileid=pid;
-       webtimeout=QSettings().value("profiles/"+pid+"/webtimeout",30).toInt()*1000;
-       loglvl=LogLevel(QSettings().value("profiles/"+pid+"/webloglevel",LogOnError).toInt());
-       finid=0;finerr=fin=false;
-       proxyport=-1;
-       sessiontimeout=0;
-       connect(&req,SIGNAL(requestFinished(int,bool)),this,SLOT(httpFin(int,bool)));
-       QTimer*tm=new QTimer(this);
-       tm->setSingleShot(false);
-       tm->start(10000);
-       connect(tm,SIGNAL(timeout()),this,SLOT(reloginCheck()));
-}
-MWebRequest::~MWebRequest(){}
-
-MWebRequest* MWebRequest::instance(){return sinst;}
-
-QString MWebRequest::dataDir()const
-{
-       QString dd="profile."+profileid;
-       QDir dir(::dataDir);
-       if(!dir.exists(dd))
-               if(!dir.mkpath(dd))
-                       qDebug("Warning: oh dir! Can't create my data directory!");
-       return ::dataDir+"/"+dd;
-}
-
-QString MWebRequest::settingsGroup()const
-{
-       return "profsettings/"+profileid;
-}
-
-MWebRequest::LogLevel MWebRequest::logLevel()const
-{
-       return loglvl;
-}
-
-void MWebRequest::setLogLevel(LogLevel l)
-{
-       loglvl=l;
-}
-
-static inline QString esc(const QByteArray ar)
-{
-       QString r;
-       for(int i=0;i<ar.size();i++){
-               unsigned char a=ar[i];
-               if(a=='\\')r+="\\\\";else
-               if(a=='\n' || a=='\r' || (a>=32 && a<=127))r+=(char)a;
-               else r+="\\x"+QByteArray((char*)&a,1).toHex();
-       }
-       return r;
-}
-
-bool MWebRequest::request(QString hreq,QByteArray data)
-{
-       //show the user we are waiting
-       WaitCursor wc;
-       //set up request
-       QString log;
-       QEventLoop loop(this);
-       connect(this,SIGNAL(requestFinInt()),&loop,SLOT(quit()));
-       int port=url.port();
-       if(port<=0){
-               if(url.scheme().toLower()=="http")port=80;
-               else port=443;
-       }
-       qDebug()<<QString("New HTTP Request %1 URL %2\n\tto host=%3 port=%4 scheme=%5")
-               .arg(hreq)
-               .arg(url.toString())
-               .arg(url.host())
-               .arg(port)
-               .arg(url.scheme());
-       QHttp::ConnectionMode conm;
-       if(url.scheme().toLower()=="http")conm=QHttp::ConnectionModeHttp;
-       else conm=QHttp::ConnectionModeHttps;
-       req.setHost(url.host(),conm,port);
-       if(proxyport>0)req.setProxy(proxyname,proxyport,proxyuser,proxypass);
-       QString pathspec=url.path();if(pathspec=="")pathspec="/";
-       if(url.encodedQuery()!="")pathspec+="?"+url.encodedQuery();
-       QHttpRequestHeader hrh("POST",url.path());
-       QString hostspec=url.host();
-       if(url.port()>0)hostspec+=":"+QString::number(port);
-       hrh.setValue("Host",hostspec);
-       hrh.setValue("X-MagicSmoke-Request",hreq);
-       hrh.setValue("X-MagicSmoke-Session",sessionid);
-       hrh.setContentLength(data.size());
-       hrh.setContentType("application/x-magicsmoke; charset=UTF-8");
-       waitid=req.request(hrh,data);
-       if(loglvl>LogMinimal)
-               log=QString("Request %3 with header:\n%1\n\nRequest Body:\n%2\n<---->\n").arg(hrh.toString()).arg(esc(data)).arg(waitid);
-       qDebug("started req %i",waitid);
-       fin=false;errstr="";
-       rspstatus="";rspdata.clear();
-       //start loop
-       QTimer::singleShot(webtimeout,&loop,SLOT(quit()));
-       loop.exec();
-       //process result
-       if(!fin){
-               //it did not finish yet, caught a timeout.
-               req.abort();
-               errstr="Web Request timed out.";
-               rspstatus="HTTP";
-               qDebug("Request %i timed out.",waitid);
-               if(loglvl&LogOnError)
-                       qDebug()<<log;
-               return false;
-       }
-       //finished with low-level error?
-       if(finerr){
-               errstr="HTTP Error: "+req.errorString();
-               rspstatus="HTTP";
-               log+=QString("Request %2 finished with HTTP level error: %1").arg(errstr).arg(waitid);
-               if(loglvl&LogOnError)
-                       qDebug()<<log;
-               return false;
-       }
-       QHttpResponseHeader rsph=req.lastResponse();
-       //check for high level error
-       if(rsph.statusCode()!=200){
-               errstr="HTTP Error, return code "+QString::number(rsph.statusCode())+" "+rsph.reasonPhrase();
-               rspstatus="HTTP";
-               log+=QString("Request %2 finished with HTTP level error: %1").arg(errstr).arg(waitid);
-               if(loglvl&LogOnError)
-                       qDebug()<<log;
-               return false;
-       }
-       //get data
-       rspdata=req.readAll();
-       rspstatus=rsph.value("x-magicsmoke-status").remove('"').trimmed().toLower();
-       //
-       if(loglvl==LogDetailed){
-               log+=QString ("----->\nHTTP Response %3 Headers:\n%1\nHTTP Response %3 Body:\n%2\n<------------------").arg(rsph.toString()).arg(esc(rspdata)).arg(waitid);
-               qDebug()<<log;
-       }
-       return true;
-}
-
-void MWebRequest::setTimeout(int t)
-{
-       if(t>0)
-               webtimeout=t;
-}
-
-bool MWebRequest::setUrl(QUrl u)
-{
-       QString s=u.scheme().toLower();
-       if(s!="http"&&s!="https")return false;
-       url=u;
-       return true;
-}
-
-void MWebRequest::httpFin(int i,bool e)
-{
-       qDebug("finished req %i",i);
-       if(i!=waitid)return;
-       finid=i;finerr=e;fin=true;
-       emit requestFinInt();
-}
-
-void MWebRequest::setProxy(QString h,quint16 p,QString u,QString pw)
-{
-       proxyname=h;proxyport=p;
-       proxyuser=u;proxypass=pw;
-}
-
-static inline QString calcAuth(QString algo,QString cha,QString pwd)
-{
-       QString ret;
-       if(algo=="md5")
-               return QCryptographicHash::hash(cha.toUtf8()+pwd.toUtf8(),QCryptographicHash::Md5).toHex();
-       if(algo=="sha1")
-               return QCryptographicHash::hash(cha.toUtf8()+pwd.toUtf8(),QCryptographicHash::Sha1).toHex();
-       if(algo=="hmac-md5")
-               return SMHmac::hmac(cha.toUtf8(),pwd.toUtf8(),QCryptographicHash::Md5).toHex();
-       if(algo=="hmac-sha1")
-               return SMHmac::hmac(cha.toUtf8(),pwd.toUtf8(),QCryptographicHash::Sha1).toHex();
-       //unreachable
-       return QByteArray();
-}
-
-bool MWebRequest::login(QString usr,QString pwd,QString hn)
-{
-       user=usr;passwd=pwd;hostname=hn;
-       return doLogin();
-}
-
-bool MWebRequest::doLogin()
-{
-       sessiontimeout=0;
-       //get authentication algo
-       if(!request("serverinfo"))return false;
-       if(rspstatus.toLower()!="ok"){
-               errstr=tr("Unable to get server info.");
-               return false;
-       }
-       QString algo;
-       QDomDocument doc;
-       QString err;int ln,cl;
-       if(!doc.setContent(rspdata,&err,&ln,&cl)){
-               errstr=tr("Error while parsing server info (line %1 col %2): %3").arg(ln).arg(cl).arg(err);
-               return false;
-       }
-       QDomNodeList nl=doc.documentElement().elementsByTagName("AuthAlgorithm");
-       if(nl.size()!=1){
-               errstr=tr("Error in server info: missing authentication algorithm info.");
-               return false;
-       }
-       algo=nl.at(0).toElement().text().trimmed().toLower();
-       if(algo!="md5"&&algo!="sha1"&&algo!="hmac-md5"&&algo!="hmac-sha1"){
-               errstr=tr("The server requested an unsupported hash algorithm: %1.").arg(algo);
-               return false;
-       }
-       //get challenge
-       if(!request("startsession",getRandom(32).toHex()))return false;
-       if(rspstatus.toLower()!="ok"){
-               errstr=tr("Unable to get authentication challenge.");
-               return false;
-       }
-       if(!doc.setContent(rspdata,&err,&ln,&cl)){
-               errstr=tr("Error while parsing session challenge (line %1 col %2): %3").arg(ln).arg(cl).arg(err);
-               return false;
-       }
-       QDomElement del=doc.documentElement();
-       nl=del.elementsByTagName("ID");
-       if(nl.size()!=1){
-               errstr=tr("Error in session challenge: missing session ID.");
-               return false;
-       }
-       sessionid=nl.at(0).toElement().text().trimmed();
-       nl=del.elementsByTagName("HostChallenge");
-       if(nl.size()!=1){
-               errstr=tr("Error in session challenge: missing host challenge.");
-               return false;
-       }
-       QString hcha=nl.at(0).toElement().text().trimmed();
-       nl=del.elementsByTagName("UserChallenge");
-       if(nl.size()!=1){
-               errstr=tr("Error in session challenge: missing user challenge.");
-               return false;
-       }
-       QString ucha=nl.at(0).toElement().text().trimmed();
-       //calculate auth
-       hcha=calcAuth(algo,hcha,QSettings().value("hostkey").toString());
-       ucha=calcAuth(algo,ucha,passwd);
-       //create auth msg
-       QDomDocument adoc("Authenticate");
-       del=adoc.createElement("SessionAuth");
-       QDomElement el=adoc.createElement("HostName");
-       el.appendChild(adoc.createTextNode(hostname));
-       del.appendChild(el);
-       el=adoc.createElement("HostAuth");
-       el.appendChild(adoc.createTextNode(hcha));
-       del.appendChild(el);
-       el=adoc.createElement("UserName");
-       el.appendChild(adoc.createTextNode(user));
-       del.appendChild(el);
-       el=adoc.createElement("UserAuth");
-       el.appendChild(adoc.createTextNode(ucha));
-       del.appendChild(el);
-       adoc.appendChild(del);
-       //authenticate
-       if(!request("sessionauth",adoc.toByteArray()))return false;
-       if(rspstatus.toLower()=="unauthenticated"){
-               errstr=tr("Failed to log in: user/password mismatch, non-allowed host key, or challenge timed out.");
-               return false;
-       }
-       if(rspstatus.toLower()!="ok"){
-               errstr=tr("Unable to authenticate.");
-               return false;
-       }
-       //get timestamps from server
-       QStringList tlst=QString::fromAscii(rspdata).trimmed().split("\n",QString::SkipEmptyParts);
-       qint64 tout=-1,tcur=-1;
-       bool b;
-       if(tlst.size()>=1){
-               tout=tlst[0].trimmed().toInt(&b);
-               if(!b)tout=-1;
-       }
-       if(tlst.size()>=2){
-               tcur=tlst[1].trimmed().toInt(&b);
-               if(!b)tcur=-1;
-       }
-       //correct timeout
-       if(tcur>=0){
-               int toff=QDateTime::currentDateTime().toTime_t()-tcur;
-               tout+=toff;
-       }
-       //store new timeout (don't store if this is less than 5min in the future,
-       // to prevent endless loops)
-       if((tout-300)>QDateTime::currentDateTime().toTime_t())
-               sessiontimeout=tout-30;//safety range of 20s + 10s timer delay
-       //all ok
-       return true;
-}
-
-void MWebRequest::logout()
-{
-       sessiontimeout=0;
-       request("closesession");
-}
-
-bool MWebRequest::relogin()
-{
-       request("closesession");
-       return doLogin();
-}
-
-QString MWebRequest::changeMyPassword(QString o,QString n)
-{
-       //check old
-       if(passwd!=o)return tr("Cannot change password, old password does not match!");
-       //create DOM tree
-       QDomDocument doc;
-       QDomElement el=doc.createElement("SetMyPasswd");
-       el.setAttribute("oldpwd",o);
-       el.setAttribute("newpwd",n);
-       doc.appendChild(el);
-       //request
-       request("setmypasswd",doc.toByteArray());
-       if(responseStatus()==MWebRequest::Ok)return "";
-       else return tr(rspdata.data());
-}
-
-QString MWebRequest::errorString()
-{
-       return errstr;
-}
-
-bool MWebRequest::hasRole(QString r)
-{
-       //get roles
-       if(roles.size()==0){
-               //get roles from server
-               if(!request("getmyroles"))return false;
-               //parse data
-               QStringList rls=QString::fromAscii(rspdata).split("\n",QString::SkipEmptyParts);
-               for(int i=0;i<rls.size();i++){
-                       QString rl=rls[i].trimmed().toLower();
-                       if(rl=="")continue;
-                       roles<<rl;
-               }
-               //if none: put in a dummy to avoid asking again
-               if(roles.size()==0)roles<<" __ none __ ";
-       }
-       //check whether we are admin
-       if(roles.contains("_admin"))return true;
-       //check whether we have role
-       return roles.contains(r.toLower());
-}
-
-QList<MEvent> MWebRequest::getAllEvents()
-{
-       errstr="";
-       if(!request("geteventlist"))return QList<MEvent>();
-       if(responseStatus()!=Ok)return QList<MEvent>();
-       //parse return document
-       QDomDocument doc;
-       QString msg;int ln,cl;
-       if(!doc.setContent(rspdata,&msg,&ln,&cl)){
-               errstr=tr("Error parsing EventList XML data (line %1 column %2): %3").arg(ln).arg(cl).arg(msg);
-               return QList<MEvent>();
-       }
-       QDomElement root=doc.documentElement();
-       QDomNodeList nl=root.elementsByTagName("Event");
-       QList<MEvent>ret;
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               MEvent ev(this,el);
-               if(ev.isValid())ret.append(ev);
-       }
-       return ret;
-}
-
-QList<MRoom> MWebRequest::getAllRooms()
-{
-       errstr="";
-       if(!request("getroomdata","<GetRooms detail=\"basic\"/>"))return QList<MRoom>();
-       if(responseStatus()!=Ok)return QList<MRoom>();
-       //parse return document
-       QDomDocument doc;
-       QString msg;int ln,cl;
-       if(!doc.setContent(rspdata,&msg,&ln,&cl)){
-               errstr=tr("Error parsing RoomList XML data (line %1 column %2): %3").arg(ln).arg(cl).arg(msg);
-               return QList<MRoom>();
-       }
-       QDomElement root=doc.documentElement();
-       QDomNodeList nl=root.elementsByTagName("Room");
-       QList<MRoom>ret;
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               MRoom rm(this,el);
-               if(rm.isValid())ret.append(rm);
-       }
-       return ret;
-}
-
-QList<MUser> MWebRequest::getAllUsers()
-{
-       errstr="";
-       if(!request("getusers",""))return QList<MUser>();
-       if(responseStatus()!=Ok)return QList<MUser>();
-       //parse return document
-       QDomDocument doc;
-       QString msg;int ln,cl;
-       if(!doc.setContent(rspdata,&msg,&ln,&cl)){
-               errstr=tr("Error parsing UserList XML data (line %1 column %2): %3").arg(ln).arg(cl).arg(msg);
-               return QList<MUser>();
-       }
-       QDomElement root=doc.documentElement();
-       QDomNodeList nl=root.elementsByTagName("User");
-       QList<MUser>ret;
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               MUser us(this,el);
-               if(us.isValid())ret.append(us);
-       }
-       return ret;
-}
-
-QList<MHost> MWebRequest::getAllHosts()
-{
-       errstr="";
-       if(!request("gethosts",""))return QList<MHost>();
-       if(responseStatus()!=Ok)return QList<MHost>();
-       //parse return document
-       QDomDocument doc;
-       QString msg;int ln,cl;
-       if(!doc.setContent(rspdata,&msg,&ln,&cl)){
-               errstr=tr("Error parsing HostList XML data (line %1 column %2): %3").arg(ln).arg(cl).arg(msg);
-               return QList<MHost>();
-       }
-       QDomElement root=doc.documentElement();
-       QDomNodeList nl=root.elementsByTagName("Host");
-       QList<MHost>ret;
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               MHost hs(this,el);
-               if(hs.isValid())ret.append(hs);
-       }
-       return ret;
-}
-
-QList<MCustomer> MWebRequest::getAllCustomers()
-{
-       errstr="";
-       if(!request("getcustomerlist",""))return QList<MCustomer>();
-       if(responseStatus()!=Ok)return QList<MCustomer>();
-       //parse return document
-       QDomDocument doc;
-       QString msg;int ln,cl;
-       if(!doc.setContent(rspdata,&msg,&ln,&cl)){
-               errstr=tr("Error parsing CustomerList XML data (line %1 column %2): %3").arg(ln).arg(cl).arg(msg);
-               return QList<MCustomer>();
-       }
-       QDomElement root=doc.documentElement();
-       QDomNodeList nl=root.elementsByTagName("Customer");
-       QList<MCustomer>ret;
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               MCustomer cr(this,el);
-               if(cr.isValid())ret.append(cr);
-       }
-       return ret;
-}
-
-QList<MOrder> MWebRequest::getAllOrders()
-{
-       errstr="";
-       if(!request("getorderlist",""))return QList<MOrder>();
-       if(responseStatus()!=Ok)return QList<MOrder>();
-       //parse return document
-       QDomDocument doc;
-       QString msg;int ln,cl;
-       if(!doc.setContent(rspdata,&msg,&ln,&cl)){
-               errstr=tr("Error parsing OrderList XML data (line %1 column %2): %3").arg(ln).arg(cl).arg(msg);
-               return QList<MOrder>();
-       }
-       QDomElement root=doc.documentElement();
-       QDomNodeList nl=root.elementsByTagName("Order");
-       QList<MOrder>ret;
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               MOrder mo(this,el);
-               if(mo.isValid())ret.append(mo);
-       }
-       return ret;
-}
-
-QList<MShipping> MWebRequest::getAllShipping()
-{
-       if(!hasRole("getshipping"))return QList<MShipping>();
-       errstr="";
-       if(!request("getshipping",""))return QList<MShipping>();
-       if(responseStatus()!=Ok)return QList<MShipping>();
-       //parse return document
-       QDomDocument doc;
-       QString msg;int ln,cl;
-       if(!doc.setContent(rspdata,&msg,&ln,&cl)){
-               errstr=tr("Error parsing ShippingList XML data (line %1 column %2): %3").arg(ln).arg(cl).arg(msg);
-               return QList<MShipping>();
-       }
-       QDomElement root=doc.documentElement();
-       QDomNodeList nl=root.elementsByTagName("ShippingOption");
-       QList<MShipping>ret;
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               MShipping mo(this,el);
-               if(mo.isValid())ret.append(mo);
-       }
-       return ret;
-}
-
-QList<int>MWebRequest::getVoucherPrices()
-{
-       if(!hasRole("getvoucherprices"))return QList<int>();
-       errstr="";
-       if(!request("getvoucherprices",""))return QList<int>();
-       if(responseStatus()!=Ok)return QList<int>();
-       //parse return document
-       QStringList lst=QString::fromAscii(responseBody()).split(" ");
-       QList<int>ret;
-       for(int i=0;i<lst.size();i++){
-               bool b;
-               int r=lst[i].trimmed().toInt(&b);
-               if(b && !ret.contains(r))ret.append(r);
-       }
-       return ret;
-}
-
-QList<MOrder> MWebRequest::getOrdersByEvents(QList<int>evids)
-{
-       errstr="";
-       QString evs;
-       for(int i=0;i<evids.size();i++)
-               evs+=QString::number(evids[i])+" ";
-       if(!request("getordersbyevents",evs.trimmed().toUtf8()))return QList<MOrder>();
-       if(responseStatus()!=Ok)return QList<MOrder>();
-       //parse return document
-       QDomDocument doc;
-       QString msg;int ln,cl;
-       if(!doc.setContent(rspdata,&msg,&ln,&cl)){
-               errstr=tr("Error parsing OrderList XML data (line %1 column %2): %3").arg(ln).arg(cl).arg(msg);
-               return QList<MOrder>();
-       }
-       QDomElement root=doc.documentElement();
-       QDomNodeList nl=root.elementsByTagName("Order");
-       QList<MOrder>ret;
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               MOrder mo(this,el);
-               if(mo.isValid())ret.append(mo);
-       }
-       return ret;
-}
-
-QByteArray MWebRequest::responseBody()
-{
-       return rspdata;
-}
-
-MWebRequest::ResponseStatus MWebRequest::responseStatus()
-{
-       if(rspstatus=="HTTP")
-               return HttpError;
-       if(rspstatus=="ok")
-               return Ok;
-       if(rspstatus=="nonpost")
-               return NonPost;
-       if(rspstatus=="unauthorized")
-               return Unauthorized;
-       if(rspstatus=="notallowed")
-               return NotAllowed;
-       if(rspstatus=="invalidrequest")
-               return InvalidRequest;
-       if(rspstatus=="syntaxerror")
-               return SyntaxError;
-       return Error;
-}
-
-void MWebRequest::reloginCheck()
-{
-       if(sessiontimeout<=0)return;
-       if(sessiontimeout<=QDateTime::currentDateTime().toTime_t())
-               relogin();
-}
-
-QString MWebRequest::hostName()
-{
-       return hostname;
-}
-
-MTemplate MWebRequest::getTemplate(QString f)
-{
-       return temp.getTemplate(f);
-}
-
-void MWebRequest::editTemplates()
-{
-       MTemplateEditor ed(&temp);
-       ed.exec();
-}
-
-void MWebRequest::updateTemplates()
-{
-       temp.updateTemplates(true);
-}
diff --git a/src/webrequest.h b/src/webrequest.h
deleted file mode 100644 (file)
index 39500e5..0000000
+++ /dev/null
@@ -1,197 +0,0 @@
-//
-// C++ Interface: webrequest
-//
-// Description: 
-//
-//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007
-//
-// Copyright: See README/COPYING files that come with this distribution
-//
-//
-
-#ifndef MAGICSMOKE_WEBREQUEST_H
-#define MAGICSMOKE_WEBREQUEST_H
-
-#include <QByteArray>
-#include <QDateTime>
-#include <QHttp>
-#include <QList>
-#include <QObject>
-#include <QPointer>
-#include <QString>
-#include <QUrl>
-
-#include "customer.h"
-#include "event.h"
-#include "host.h"
-#include "order.h"
-#include "room.h"
-#include "shipping.h"
-#include "templates.h"
-#include "user.h"
-
-/**abstraction of requests to the web server, handles sessions and all data transfer; singleton*/
-class MWebRequest:public QObject
-{
-       Q_OBJECT
-       public:
-               MWebRequest(QString profileid);
-               ~MWebRequest();
-               
-               static MWebRequest* instance();
-               
-               /**returns the data directory of this profile; it makes sure the directory exists*/
-               QString dataDir()const;
-               
-               /**returns the settings group of this profile; this group is free to be filled by other entities, it is not used by the webrequest itself or the mainwindow*/
-               QString settingsGroup()const;
-               
-               /**generic request method, use the macro functions if possible; this function blocks until the request either succeeds, times out or fails; returns false if the request failed or timed out*/
-               bool request(QString requestName,QByteArray data=QByteArray());
-               /**returns the body returned by the server for the last request*/
-               QByteArray responseBody();
-               
-               enum ResponseStatus{
-                       /**Everything was ok*/
-                       Ok=0,
-                       /**an unknown error occurred*/
-                       Error=1,
-                       /**the request was not a POST method (should never happen)*/
-                       NonPost=2,
-                       /**the session expired or was never established*/
-                       Unauthorized=3,
-                       /**the user does not have this right*/
-                       NotAllowed=4,
-                       /**the request name was invalid, the request does not exist*/
-                       InvalidRequest=5,
-                       /**the request data had syntactical errors*/
-                       SyntaxError=6,
-                       /**the HTTP transport failed (time out) or the server was unable to execute the script; this code is set in all cases in which request returns false*/
-                       HttpError=100
-               };
-               
-               /**returns the (lower-case) response status of the last request*/
-               ResponseStatus responseStatus();
-               
-               /**returns the last error as string*/
-               QString errorString();
-               
-               /**returns whether the user has a specific role/right*/
-               bool hasRole(QString);
-               
-               /**returns a list of all events (in incomplete state)*/
-               QList<MEvent>getAllEvents();
-               
-               /**returns a list of all rooms (without description, which is loaded dynamically if requested)*/
-               QList<MRoom>getAllRooms();
-               
-               /**returns a list of all users**/
-               QList<MUser>getAllUsers();
-               
-               /**returns a list of all hosts**/
-               QList<MHost>getAllHosts();
-               
-               /**returns a list of all customers*/
-               QList<MCustomer>getAllCustomers();
-               
-               /**returns a list of all orders*/
-               QList<MOrder>getAllOrders();
-               
-               /**returns a list of all available shipping methods*/
-               QList<MShipping>getAllShipping();
-               
-               /**returns valid voucher prices in cents*/
-               QList<int>getVoucherPrices();
-               
-               /**returns a list of all orders that order from one of the specified events*/
-               QList<MOrder>getOrdersByEvents(QList<int>);
-               
-               /**return current host name of this session*/
-               QString hostName();
-               
-               /**returns the requested template as cached locally (see MTemplateStore for details)*/
-               MTemplate getTemplate(QString);
-               
-               /**log settings*/
-               enum LogLevel {
-                       /**minimal logging*/
-                       LogMinimal=0,
-                       /**log details on error*/
-                       LogOnError=1,
-                       /**always log details*/
-                       LogDetailed=0xf
-               };
-               
-               /**returns the current log level*/
-               LogLevel logLevel()const;
-               
-               /**returns currently logged in user*/
-               QString currentUser()const{return user;}
-               
-       public slots:
-               /**set how long to wait for a web request*/
-               void setTimeout(int);
-               /**set URL to connect to*/
-               bool setUrl(QUrl);
-               /**set proxy to be used*/
-               void setProxy(QString,quint16,QString u=QString(),QString p=QString());
-               
-               /**set log level*/
-               void setLogLevel(MWebRequest::LogLevel);
-               
-               /**log in to web server; requires username/password and the local host name as arguments*/
-               bool login(QString user,QString passwd,QString hostname);
-               /**re-log in to web server with previously set values*/
-               bool relogin();
-               /**log out of web server*/
-               void logout();
-               /**change password; returns error string if it fails, empty if it succeeds*/
-               QString changeMyPassword(QString oldpwd,QString newpwd);
-               
-               /**force an update of templates*/
-               void updateTemplates();
-               
-               /**opens the template editor*/
-               void editTemplates();
-               
-       private slots:
-               /**internal: used by wait loop for web requests*/
-               void httpFin(int,bool);
-               /**internal: check whether we need to redo the login*/
-               void reloginCheck();
-               
-       signals:
-               /**internal: used by wait loop for web request*/
-               void requestFinInt();
-               
-       private:
-               //central request object
-               QHttp req;
-               QString proxyname,proxyuser,proxypass;
-               QUrl url;
-               int webtimeout,proxyport;
-               LogLevel loglvl;
-               //login data
-               QString user,passwd,sessionid,hostname;
-               //accounting data
-               QStringList roles;
-               //error data
-               QString errstr;
-               bool finerr,fin;
-               //response data
-               QString rspstatus;
-               QByteArray rspdata;
-               int finid,waitid;
-               //session timeout for relogin
-               qint64 sessiontimeout;
-               //profile name for lookups
-               QString profileid;
-               //template subsystem
-               MTemplateStore temp;
-               
-               /**used by login and relogin to do the actual work*/
-               bool doLogin();
-};
-
-#endif
similarity index 100%
rename from src/centbox.cpp
rename to src/widgets/centbox.cpp
similarity index 100%
rename from src/centbox.h
rename to src/widgets/centbox.h
similarity index 100%
rename from src/checkdlg.cpp
rename to src/widgets/checkdlg.cpp
similarity index 100%
rename from src/checkdlg.h
rename to src/widgets/checkdlg.h
diff --git a/src/widgets/waitcursor.cpp b/src/widgets/waitcursor.cpp
new file mode 100644 (file)
index 0000000..09959b8
--- /dev/null
@@ -0,0 +1,26 @@
+//
+// C++ Implementation: waitcursor
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2009
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#include "waitcursor.h"
+
+#include <QApplication>
+#include <QCursor>
+
+WaitCursor::WaitCursor()
+{
+       QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+}
+
+WaitCursor::~WaitCursor()
+{
+       QApplication::restoreOverrideCursor();
+}
diff --git a/src/widgets/waitcursor.h b/src/widgets/waitcursor.h
new file mode 100644 (file)
index 0000000..fa69615
--- /dev/null
@@ -0,0 +1,27 @@
+//
+// C++ Interface: waitcursor
+//
+// Description: 
+//
+//
+// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2009
+//
+// Copyright: See README/COPYING files that come with this distribution
+//
+//
+
+#ifndef MAGICSMOKE_WAITCURSOR_H
+#define MAGICSMOKE_WAITCURSOR_H
+
+/**simple class to show a busy-cursor while an instance of it exists*/
+class WaitCursor
+{
+       public:
+               /**displays a wait cursor (Qt::WaitCursor)*/
+               WaitCursor();
+               /**restores the last normal cursor*/
+               ~WaitCursor();
+};
+
+
+#endif
diff --git a/src/widgets/widgets.pri b/src/widgets/widgets.pri
new file mode 100644 (file)
index 0000000..5409f0f
--- /dev/null
@@ -0,0 +1,11 @@
+HEADERS += \
+       widgets/waitcursor.h \
+       widgets/centbox.h \
+       widgets/checkdlg.h
+
+SOURCES += \
+       widgets/waitcursor.cpp \
+       widgets/centbox.cpp \
+       widgets/checkdlg.cpp
+
+INCLUDEPATH += ./widgets
\ No newline at end of file
index 03fa4d1..0cb4a3f 100644 (file)
                <!--if not null/empty: event has been cancelled-->
                <Column name="cancelreason" type="string"/>
        </Table>
+       
+       <Class name="Event">
+               <Property name="id" type="int" id="yes"/>
+               <Property name="start" type="int64"/>
+               <Property name="end" type="int64"/>
+               <Property name="capacity" type="int"/>
+               <Property name="defaultprice" type="int"/>
+               <Property name="cancelled" type="bool"/>
+               <Property name="title" type="string"/>
+               <Property name="artist" type="string"/>
+               <Property name="room" type="string"/>
+               <Property name="cancelreason" type="string"/>
+               <Property name="amountSold" type="int"/>
+               <Property name="amountReserved" type="int"/>
+               <ToXml name="Full">id start end capacity defaultprice cancelled title artist room cancelreason</ToXml>
+       </Class>
+       
+       <Transaction name="GetEvent">
+               <Input>
+                       <Var name="eventid" type="int"/>
+               </Input>
+               <Call lang="php" method="GetEventXml2($this);"/>
+               <Output>
+                       <Var name="event" type="Event/Full"/>
+               </Output>
+       </Transaction>
+       
+       <Transaction name="GetAllEvents">
+               <Input/>
+               <Call lang="php" method="GetAllEventsXml2($this);"/>
+               <Output>
+                       <Var name="events" type="List:Event/Full"/>
+               </Output>
+       </Transaction>
 </Wolf>
\ No newline at end of file
index 46e7b4c..0e90d05 100644 (file)
@@ -13,7 +13,7 @@
        <DataBase instance="db" schema="dbScheme" version="00.03"/>
        
        <!-- configure output -->
-       <QtClientOutput sourceDir="src" subDir="wob" priInclude="wob.pri" classPrefix="M"/>
+       <QtClientOutput sourceDir="src" subDir="wob" priInclude="wob.pri" classPrefix="M" clean="yes"/>
        <PHPServerOutput sourceDir="www" subDir="inc/wob" extension=".php" clean="yes">
                <Authenticator isAuthenticated="$::session->isAuthenticated()" hasRole="$::session->canExecute('%')" userName="$::session->getUser()"/>
        </PHPServerOutput>
index 8fbda4a..2eb1d90 100644 (file)
@@ -354,6 +354,9 @@ QString WocPHPServerOut::classPropertyValidator(const WocClass&cls,QString prop)
        if(cls.propertyIsString(prop))
                code+="\treturn true;\n";//TODO: special handling for astring
        else
+       if(cls.propertyIsBool(prop))
+               code+="\treturn is_bool($value);\n";
+       else
        if(cls.propertyIsObject(prop))
                code+="\treturn is_a($value,\"WO"+cls.propertyPlainType(prop)+"\");\n";
        else{
@@ -375,6 +378,11 @@ QString WocPHPServerOut::classPropertyListGetters(const WocClass&cls,QString pro
                code+="\t$ret=array();\n\tforeach($this->prop_"+prop+" as $p)$ret[]=\"\".$p;\n";
                code+="\treturn $ret;\n}\n";
        }else
+       if(cls.propertyIsBool(prop)){
+               code+="public function getstrlist_"+prop+"(){\n";
+               code+="\t$ret=array();\n\tforeach($this->prop_"+prop+" as $p)$ret[]=$p?\"yes\":\"no\";\n";
+               code+="\treturn $ret;\n}\n";
+       }else
        if(cls.propertyIsEnum(prop)){
                code+="public function getstrlist_"+prop+"(){\n";
                code+="\t$ret=array();\n";
@@ -426,11 +434,20 @@ QString WocPHPServerOut::classPropertyListSetters(const WocClass&cls,QString pro
        }else
        if(cls.propertyIsInt(prop)){
                code+="\t$prop=array();\n\tforeach($values as $value)\n";
-               code+="\t\tif(is_numeric($value)){\n\t\t\t$prop=0+$value;\n\t\t}else return false;\n";
+               code+="\t\tif(is_numeric($value)){\n\t\t\t$prop[]=0+$value;\n\t\t}else return false;\n";
                code+="\t$this->prop_"+prop+"=$prop;\n\treturn true;\n";
                acode+="\tif(is_numeric($value)){\n";
                acode+="\t\t$this->prop_"+prop+"=0+$value;\n\t\treturn true;\n\t}else return false;\n";
        }else
+       if(cls.propertyIsBool(prop)){
+               code+="\t$prop=array();\n\tforeach($values as $value)\n";
+               code+="\t\tif(is_bool($value))$prop[]=$value!=false;else\n";
+               code+="\t\tif($value==\"yes\")$prop[]=true;else\n";
+               code+="\t\tif($value==\"no\")$prop[]=false;else return false;\n";
+               code+="\t$this->prop_"+prop+"=$prop;\n\treturn true;\n";
+               acode+="\tif(is_bool($value)){\n";
+               acode+="\t\t$this->prop_"+prop+"=$value!=false;\n\t\treturn true;\n\t}else return false;\n";
+       }else
        if(cls.propertyIsString(prop)){
                code+="\t$prop=array();\n\tforeach($values as $value)$prop[]=\"\".$value;\n";
                code+="\t$this->prop_"+prop+"=$prop;\n\treturn true;\n";
@@ -465,6 +482,8 @@ QString WocPHPServerOut::classPropertyScalarGetters(const WocClass&cls,QString p
        else
        if(cls.propertyIsInt(prop))code+="public function getstr_"+prop+"(){return \"\".$this->prop_"+prop+";}\n";
        else
+       if(cls.propertyIsBool(prop))code+="public function getstr_"+prop+"(){return $this->prop_"+prop+"?\"yes\":\"no\";}\n";
+       else
        if(cls.propertyIsEnum(prop)){
                code+="public function getstr_"+prop+"(){\n\tswitch($this->prop_"+prop+"){\n";
                QList<QPair<QString,int> > ev=cls.enumValues(cls.propertyPlainType(prop));
@@ -500,6 +519,12 @@ QString WocPHPServerOut::classPropertyScalarSetters(const WocClass&cls,QString p
        if(cls.propertyIsInt(prop))
                code+="\tif(is_numeric($value)){\n\t\t$this->prop_"+prop+"=0+$value;\n\t\treturn true;\n\t}else return false;\n";
        else
+       if(cls.propertyIsBool(prop)){
+               code+="\tif(is_bool($value))$this->prop_"+prop+"=$value!=false;else\n";
+               code+="\tif($value==\"yes\")$this->prop_"+prop+"=true;else\n";
+               code+="\tif($value==\"no\")$this->prop_"+prop+"=false;\n\telse return false;\n";
+               code+="\treturn true;\n";
+       }else
        if(cls.propertyIsString(prop))
                code+="\t$this->prop_"+prop+"=\"\".$value;\n\treturn true;\n";
                //TODO: special handling for astring
@@ -576,6 +601,7 @@ QString WocPHPServerOut::classDeserializers(const WocClass&cls,QString cn)
                        }
                }
        }
+       //TODO: use setters
        code+="\treturn new "+cn+"($data);\n}\n";
        return code;
 }
@@ -747,6 +773,7 @@ QString WocPHPServerOut::trnInput(const WocTransaction&trn)
                if(trn.isAttributeType(t)){
                        code+="\t\t$this->ainput[\""+sl[i]+"\"]=$root->getAttribute(\""+sl[i]+"\")";
                        if(trn.isIntType(t))code+="+0";
+                       if(trn.isBoolType(t))code+="==\"yes\"";
                        code+=";\n";
                }else{
                        if(trn.isListType(t)){
@@ -757,6 +784,7 @@ QString WocPHPServerOut::trnInput(const WocTransaction&trn)
                                }else{
                                        code+="\t\t\t$this->ainput[\""+sl[i]+"\"][]=$el->textContent";
                                        if(trn.isIntType(t))code+="+0";
+                                       if(trn.isBoolType(t))code+="==\"yes\"";
                                        code+=";\n";
                                }
                                code+="\t\t}\n";
@@ -834,6 +862,10 @@ QString WocPHPServerOut::trnGetSet(const WocTransaction&trn)
                                code+="\t\tif(is_numeric($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv+0;\n";
                                add+="\tif(is_numeric($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv+0;\n";
                        }else
+                       if(trn.isBoolType(t)){
+                               code+="\t\tif(is_bool($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv!=false;\n";
+                               add+="\tif(is_bool($vv))$this->aoutput[\""+sl[i]+"\"][]=$vv!=false;\n";
+                       }else
                        if(trn.isObjectType(t)){
                                code+="\t\tif(is_a($vv,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"][]=$vv;\n";
                                add+="\tif(is_a($vv,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"][]=$vv;\n";
@@ -847,6 +879,9 @@ QString WocPHPServerOut::trnGetSet(const WocTransaction&trn)
                        if(trn.isIntType(t)){
                                code+="\tif(is_numeric($v))$this->aoutput[\""+sl[i]+"\"]=$v+0;\n";
                        }else
+                       if(trn.isIntType(t)){
+                               code+="\tif(is_bool($v))$this->aoutput[\""+sl[i]+"\"]=$v!=false;\n";
+                       }else
                        if(trn.isObjectType(t)){
                                code+="\tif(is_a($v,\"WO"+trn.plainType(t)+"\"))$this->aoutput[\""+sl[i]+"\"]=$v;\n";
                        }else{
index fff55db..49d12be 100644 (file)
@@ -480,7 +480,7 @@ QString WocClass::propertyPlainType(QString p)const
        else return r;
 }
 
-const QStringList WocClass::attrtypes=QStringList()<<"astring"<<"int";
+const QStringList WocClass::attrtypes=QStringList()<<"astring"<<"int"<<"int32"<<"int64"<<"bool";
 bool WocClass::propertyIsAttribute(QString p)const
 {
        QString t=propertyPlainType(p);
index 209cc9b..07831b4 100644 (file)
@@ -72,7 +72,9 @@ class WocClass
                /**returns whether the property is a list of values (false for scalars)*/
                bool propertyIsList(QString)const;
                /**returns whether the property type is integer*/
-               bool propertyIsInt(QString p)const{return propertyPlainType(p)=="int";}
+               bool propertyIsInt(QString p)const{QString pt=propertyPlainType(p);return pt=="int" || pt=="int32" || pt=="int64";}
+               /**returns whether the property type is boolean*/
+               bool propertyIsBool(QString p)const{return propertyPlainType(p)=="bool";}
                /**returns whether the property type is string*/
                bool propertyIsString(QString p)const{QString pt=propertyPlainType(p);return pt=="string"||pt=="astring";}
                
@@ -253,15 +255,17 @@ class WocTransaction
                        else return "";
                }
                /**returns true if the type is integer*/
-               bool isIntType(QString t)const{return plainType(t)=="int";}
+               bool isIntType(QString t)const{QString pt=plainType(t);return pt=="int" || pt=="int32" || pt=="int64";}
+               /**returns true if the type is boolean*/
+               bool isBoolType(QString t)const{return plainType(t)=="bool";}
                /**returns true if the type is a string*/
                bool isStringType(QString t)const{QString p=plainType(t);return p=="astring"||p=="string";}
                /**returns true if the type is to be encoded as attribute*/
-               bool isAttributeType(QString t)const{return t=="astring"||t=="int";}
+               bool isAttributeType(QString t)const{return t=="astring"||t=="int"||t=="int32"||t=="int64"||t=="bool";}
                /**returns true if the type is to be encoded as element*/
                bool isElementType(QString t)const{return !isAttributeType(t);}
                /**return true if the type is an object type*/
-               bool isObjectType(QString t)const{QString p=plainType(t);return p!="astring"&&p!="string"&&p!="int";}
+               bool isObjectType(QString t)const{QString p=plainType(t);return p!="astring"&&p!="string"&&p!="int"&&p!="int32"&&p!="int64"&&p!="bool";}
        private:
                QString m_name;
                bool m_valid;
index fc4323c..b67e70c 100644 (file)
@@ -62,7 +62,8 @@ WocQtClientOut::WocQtClientOut(QDomElement&el)
        m_pri.write(QByteArray("#AUTOMATICALLY GENERATED FILE - DONT CHANGE!\n"));
        
        //create interface class
-       QString pn=WocProcessor::instance()->projectName();
+       WocProcessor*woc=WocProcessor::instance();
+       QString pn=woc->projectName();
        m_iface.setFileName(m_basedir+"/"+m_subdir+"/"+m_prefix+"Interface.cpp");
        if(!m_iface.open(QIODevice::WriteOnly|QIODevice::Truncate)){
                qDebug("Error: cannot create Qt interface file %s.",m_iface.fileName().toAscii().data());
@@ -83,6 +84,10 @@ WocQtClientOut::WocQtClientOut(QDomElement&el)
        m_iface.write(QString("class "+m_prefix+"Interface:public WInterface\n{\n Q_OBJECT\n").toAscii());
        m_iface.write(QString(" public:\n  "+m_prefix+"Interface(QString name=\""+pn+"\"):WInterface(name){}\n").toAscii());
        m_iface.write(QString("  static "+m_prefix+"Interface*instance(QString name=\""+pn+"\")\n\t{return qobject_cast<"+m_prefix+"Interface*>(WInterface::instance(name));}\n\n").toAscii());
+       m_iface.write(QString("  QString commVersion()const{return \""+woc->verComm()+"\";}\n").toAscii());
+       m_iface.write(QString("  QString needCommVersion()const{return \""+woc->verNeedComm()+"\";}\n").toAscii());
+       m_iface.write(QString("  QString version()const{return \""+woc->verHR()+"\";}\n").toAscii());
+       m_iface.write(QString("  QString svnVersion()const{return \""+woc->svnRevision()+"\";}\n\n").toAscii());
        
        //create all includer
        m_hdr.setFileName(m_basedir+"/"+m_subdir+"/"+m_prefix+"Include.h");
@@ -232,6 +237,7 @@ QString WocQtClientOut::qttype(const WocClass&cls,QString p,bool dolist)
        else r="Nullable<";
        if(cls.propertyIsString(p))r+="QString";else
        if(cls.propertyIsInt(p))r+="qint64";else
+       if(cls.propertyIsBool(p))r+="bool";else
        if(cls.propertyIsObject(p))r+=m_prefix+"O"+cls.propertyPlainType(p);
        else r+=cls.propertyPlainType(p);
        r+=">";
@@ -272,6 +278,9 @@ void WocQtClientOut::classDeserializer(const WocClass&cls,QFile&hdr,QFile&src,QS
                                scd+="\t\tif(b)add"+k[i]+"(ct);\n";
                                scd+="\t\telse throw WDeserializerException(\"Class "+cn+" property "+k[i]+" is integer list, but non-integer was found.\");\n";
                        }else
+                       if(cls.propertyIsBool(k[i])){
+                               scd+="\t\tadd"+k[i]+"(el.text()==\"yes\");\n";
+                       }else
                        if(cls.propertyIsString(k[i])){
                                scd+="\t\tadd"+k[i]+"(el.text());\n";
                        }else
@@ -301,6 +310,9 @@ void WocQtClientOut::classDeserializer(const WocClass&cls,QFile&hdr,QFile&src,QS
                                        scd+="\t\tif(b)set"+k[i]+"(ct);\n";
                                        scd+="\t\telse throw WDeserializerException(\"Class "+cn+" property "+k[i]+" is integer, but non-integer was found.\");\n";
                                }else
+                               if(cls.propertyIsBool(k[i])){
+                                       scd+="\t\tset"+k[i]+"(root.attribute(\""+k[i]+"\")==\"yes\");\n";
+                               }else
                                if(cls.propertyIsString(k[i])){
                                        scd+="\t\tset"+k[i]+"(root.attribute(\""+k[i]+"\"));\n";
                                }else
@@ -384,6 +396,11 @@ void WocQtClientOut::classSerializers(const WocClass&cls,QFile&hdr,QFile&src,QSt
                                        scd+="\t\tel.appendChild(doc.createTextNode(mp_"+prop+"[i]));\n";
                                        scd+="\t\tr.appendChild(el);\n";
                                }else
+                               if(cls.propertyIsBool(prop)){
+                                       scd+="\t\tQDomElement el=doc.createElement(\""+prop+"\");\n";
+                                       scd+="\t\tel.appendChild(doc.createTextNode(mp_"+prop+"[i]?\"yes\":\"no\"));\n";
+                                       scd+="\t\tr.appendChild(el);\n";
+                               }else
                                if(cls.propertyIsInt(prop)){
                                        scd+="\t\tQDomElement el=doc.createElement(\""+prop+"\");\n";
                                        scd+="\t\tel.appendChild(doc.createTextNode(QString::number(mp_"+prop+"[i])));\n";
@@ -398,7 +415,10 @@ void WocQtClientOut::classSerializers(const WocClass&cls,QFile&hdr,QFile&src,QSt
                                //non lists
                                scd+="\tif(!mp_"+prop+".isNull()){\n";
                                if(cls.propertyIsAttribute(prop)){
-                                       scd+="\t\tr.setAttribute(\""+prop+"\",mp_"+prop+".value());\n";
+                                       if(cls.propertyIsBool(prop))
+                                               scd+="\t\tr.setAttribute(\""+prop+"\",mp_"+prop+".value()?\"yes\":\"no\");\n";
+                                       else
+                                               scd+="\t\tr.setAttribute(\""+prop+"\",mp_"+prop+".value());\n";
                                }else{
                                        if(cls.propertyIsObject(prop)){
                                                scd+="\t\tr.appendChild(mp_"+prop+".toXml"+var+"(doc,\""+prop+"\"));\n";
@@ -507,6 +527,11 @@ void WocQtClientOut::newTransaction(const WocTransaction&trn)
        //create copy constructor
        hcd="  public:\n";
        hcd+="\t"+cn+"(const "+cn+"&);\n";
+       //create getters
+       for(int i=0;i<out.size();i++){
+               QString tp=qttype(trn,out[i],Out);
+               hcd+="\t"+tp+" get"+out[i]+"(){return out_"+out[i]+";}\n";
+       }
        //create queries
        scd="";
        //TODO: query should optimize between local & web
@@ -534,7 +559,8 @@ QString WocQtClientOut::qttype(const WocTransaction&trn,QString v,InOut io)
                tp=tp.mid(5);
        }else   r="Nullable<";
        if(tp=="astring" || tp=="string")r+="QString";else
-       if(tp=="int")r+="qint64";
+       if(tp=="int"||tp=="int32"||tp=="int64")r+="qint64";else
+       if(tp=="bool")r+="bool";
        else r+=m_prefix+"O"+tp.split("/",QString::SkipEmptyParts).at(0);
        r+=">";
        return r;