it finally compiles, but is completely useless so far!
authorkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 12 Jul 2009 18:48:55 +0000 (18:48 +0000)
committerkonrad <konrad@6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33>
Sun, 12 Jul 2009 18:48:55 +0000 (18:48 +0000)
git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@287 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33

37 files changed:
src/customer.cpp
src/customer.h
src/event.cpp
src/event.h
src/eventedit.cpp
src/eventedit.h
src/eventsummary.cpp
src/eventsummary.h
src/host.cpp
src/host.h
src/moneylog.cpp
src/moneylog.h
src/msinterface.h
src/order.cpp
src/order.h
src/orderwin.cpp
src/orderwin.h
src/overview.cpp
src/overview.h
src/phpscan.pri
src/room.cpp [deleted file]
src/room.h [deleted file]
src/shipping.cpp
src/shipping.h
src/smoke.pro
src/templates.cpp
src/templates.h
src/ticketrender.cpp
src/user.cpp
src/user.h
src/wbase/WTransaction.cpp
src/wbase/WTransaction.h
wob/customer.wolf
wob/event.wolf
wob/order.wolf
wob/user.wolf
woc/qtout.cpp

index 5fcc512..1a93a2d 100644 (file)
@@ -11,7 +11,7 @@
 //
 
 #include "customer.h"
-#include "webrequest.h"
+#include "msinterface.h"
 
 #include <QBoxLayout>
 #include <QCheckBox>
 #include <QStandardItemModel>
 #include <QTextEdit>
 
-MCustomer::MCustomer(MWebRequest*r)
-{
-       m_req=r;
-       m_id=-1;
-       m_iscomplete=false;
-}
-
-MCustomer::MCustomer(MWebRequest*r,const QDomElement&el)
-{
-       m_req=r;
-       m_iscomplete=false;
-       scanXml(el);
-}
-
-MCustomer::MCustomer(MWebRequest*r,qint64 i)
-{
-       m_req=r;
-       m_iscomplete=false;
-       m_id=i;
-       getUpdate();
-}
-
-void MCustomer::scanXml(const QDomElement&el)
-{
-       //get basic information
-       bool b;
-       m_id=el.attribute("id","-1").toInt(&b);
-       if(!b)m_id=-1;
-       m_name=el.attribute("name");
-       //scan for details
-       m_iscomplete=false;
-       QDomNodeList nl;
-       nl=el.elementsByTagName("Contact");
-       if(nl.size()>0){
-               m_contact=nl.at(0).toElement().text();
-       }
-       nl=el.elementsByTagName("Address");
-       if(nl.size()>0){
-               m_address=nl.at(0).toElement().text();
-       }
-       m_mail=el.attribute("mail");
-       nl=el.elementsByTagName("Comment");
-       if(nl.size()>0){
-               m_comment=nl.at(0).toElement().text();
-       }
-}
-
-void MCustomer::getUpdate()
-{
-       if(m_id<0)return;
-       if(m_req==0){
-               qDebug("Warning: trying to call MCustomer::getUpdate without MWebRequest!");
-               return;
-       }
-       if(!m_req->request("getcustomer",QString::number(m_id).toAscii()))return;
-       QDomDocument doc;
-       if(!doc.setContent(m_req->responseBody()))return;
-       QDomElement root=doc.documentElement();
-       scanXml(root);
-}
-
-MCustomer::MCustomer(const MCustomer&c)
-{
-       m_req=c.m_req;
-       m_id=c.m_id;
-       m_name=c.m_name;
-       m_address=c.m_address;
-       m_contact=c.m_contact;
-       m_mail=c.m_mail;
-       m_comment=c.m_comment;
-       m_iscomplete=c.m_iscomplete;
-}
+#define req (MSInterface::instance())
 
-MCustomer& MCustomer::operator=(const MCustomer&c)
+MCustomer::MCustomer(qint64 i)
 {
-       m_req=c.m_req;
-       m_id=c.m_id;
-       m_name=c.m_name;
-       m_address=c.m_address;
-       m_contact=c.m_contact;
-       m_mail=c.m_mail;
-       m_comment=c.m_comment;
-       m_iscomplete=c.m_iscomplete;
-       return *this;
-}
-
-qint64 MCustomer::customerID()
-{
-       return m_id;
+       MTGetCustomer gc=req->queryGetCustomer(i);
+       if(gc.stage()==gc.Success)
+               operator=(gc.getcustomer().value());
 }
 
 bool MCustomer::isValid()
 {
-       return m_id>-1;
-}
-
-QString MCustomer::name()
-{
-       return m_name;
-}
-
-QString MCustomer::getNameAddress()
-{
-       return m_name+"\n"+address();
-}
-
-QString MCustomer::address()
-{
-       if(!m_iscomplete)getUpdate();
-       return m_address;
+       //TODO: reconsider isValid
+       return id()>-1;
 }
 
-QString MCustomer::contact()
+QString MCustomer::address(int i)
 {
-       if(!m_iscomplete)getUpdate();
-       return m_contact;
+       if(i<0)return "";
+       QList<MOAddress>adrs=addresses();
+       if(i>=adrs.size())return "";
+       QString ret;
+       MOAddress adr=adrs[i];
+       if(adr.name().isNull())ret=name();
+       else ret=adr.name().value();
+       ret+="\n";
+       if(!adr.company().isNull())ret+=adr.company().value()+"\n";
+       if(!adr.addr1().isNull())ret+=adr.addr1().value()+"\n";
+       if(!adr.addr2().isNull())ret+=adr.addr2().value()+"\n";
+       if(!adr.city().isNull())ret+=adr.city().value()+"\n";
+       if(!adr.state().isNull())ret+=adr.state().value()+"\n";
+       if(!adr.zipcode().isNull())ret+=adr.zipcode().value()+"\n";
+       if(!adr.country().isNull())ret+=adr.country().value().name();
+       return ret;
 }
 
-QString MCustomer::mail()
-{
-       if(!m_iscomplete)getUpdate();
-       return m_mail;
-}
-
-QString MCustomer::comment()
-{
-       if(!m_iscomplete)getUpdate();
-       return m_comment;
-}
-
-void MCustomer::setName(QString n){m_name=n;}
-void MCustomer::setAddress(QString a){m_address=a;}
-void MCustomer::setContact(QString c){m_contact=c;}
-void MCustomer::setComment(QString c){m_comment=c;}
-
-void MCustomer::save()
-{
-       if(m_req==0){
-               qDebug("Warning: trying to call MCustomer::save without MWebRequest!");
-               return;
-       }
-       //create XML
-       QDomDocument doc;
-       QDomElement cse=doc.createElement("Customer");
-       cse.setAttribute("id",m_id);
-       cse.setAttribute("name",m_name);
-       QDomElement el=doc.createElement("Address");
-       el.appendChild(doc.createTextNode(m_address));
-       cse.appendChild(el);
-       el=doc.createElement("Contact");
-       el.appendChild(doc.createTextNode(m_contact));
-       cse.appendChild(el);
-       el=doc.createElement("Comment");
-       el.appendChild(doc.createTextNode(m_comment));
-       cse.appendChild(el);
-       doc.appendChild(cse);
-       //request
-       if(!m_req->request("setcustomer",doc.toByteArray()))return;
-       //check result code
-       if(m_req->responseStatus()!=MWebRequest::Ok)return;
-       m_id=m_req->responseBody().trimmed().toInt();
-}
 
 /*********************************************************/
 
-MCustomerListDialog::MCustomerListDialog(MWebRequest*r,QWidget*par,bool isselect,qint64 presel)
+MCustomerListDialog::MCustomerListDialog(QWidget*par,bool isselect,qint64 presel)
        :QDialog(par)
 {
-       m_req=r;
        if(isselect)
                setWindowTitle(tr("Select a Customer"));
        else
@@ -225,10 +97,10 @@ MCustomerListDialog::MCustomerListDialog(MWebRequest*r,QWidget*par,bool isselect
        connect(p,SIGNAL(clicked()),this,SLOT(editCustomer()));
        vl2->addWidget(p=new QPushButton(tr("Create new...")),0);
        connect(p,SIGNAL(clicked()),this,SLOT(newCustomer()));
-       p->setEnabled(m_req->hasRole("setcustomer"));
+       p->setEnabled(req->hasRole("setcustomer"));
        vl2->addWidget(p=new QPushButton(tr("Delete...")),0);
        connect(p,SIGNAL(clicked()),this,SLOT(deleteCustomer()));
-       p->setEnabled(m_req->hasRole("deletecustomer"));
+       p->setEnabled(req->hasRole("deletecustomer"));
        vl2->addStretch(2);
        vl->addSpacing(15);
        vl->addLayout(hl=new QHBoxLayout,0);
@@ -257,14 +129,19 @@ void MCustomerListDialog::updateList(int nid)
                        nid=m_proxymodel->data(idx,Qt::UserRole).toInt();
        }
        //go to server
-       m_list=m_req->getAllCustomers();
+       MTGetAllCustomerNames gac=req->queryGetAllCustomerNames();
+       if(gac.stage()!=gac.Success)return;
+       m_list.clear();
+       QList<MOCustomer>cl=gac.getcustomers();
+       for(int i=0;i<cl.size();i++)
+               m_list.append(cl[i]);
        //update widget
        m_listmodel->clear();
        m_listmodel->insertRows(0,m_list.size());
        m_listmodel->insertColumn(0);
        for(int i=0;i<m_list.size();i++){
                QModelIndex idx=m_listmodel->index(i,0);
-               m_listmodel->setData(idx,m_list[i].name());
+               m_listmodel->setData(idx,m_list[i].name().value());
                m_listmodel->setData(idx,i,Qt::UserRole);
        }
        m_listmodel->sort(0);
@@ -274,7 +151,7 @@ void MCustomerListDialog::updateList(int nid)
                QModelIndex idx=m_proxymodel->index(i,0);
                int j=m_proxymodel->data(idx,Qt::UserRole).toInt();
                if(j<0 || j>=m_list.size())continue;
-               if(nid==m_list[j].customerID()){
+               if(nid==m_list[j].id()){
                        m_listview->setCurrentIndex(idx);
                        break;
                }
@@ -294,13 +171,13 @@ MCustomer MCustomerListDialog::getCustomer()
 
 void MCustomerListDialog::newCustomer()
 {
-       MCustomerDialog cd(MCustomer(m_req),this);
+       MCustomerDialog cd(MCustomer(),this);
        if(cd.exec()==QDialog::Accepted)
-               updateList(cd.getCustomer().customerID());
+               updateList(cd.getCustomer().id());
 }
 void MCustomerListDialog::editCustomer()
 {
-       //get selection
+       //1get selection
        QModelIndex idx=m_listview->currentIndex();
        if(!idx.isValid())return;
        //return object
@@ -345,14 +222,15 @@ void MCustomerListDialog::deleteCustomer()
        connect(p,SIGNAL(clicked()),&d,SLOT(reject()));
        if(d.exec()!=QDialog::Accepted)return;
        //compose request
-       QString rd=QString::number(m_list[dusr].customerID());
+       QString rd=QString::number(m_list[dusr].id());
        if(cb->isChecked()){
                int musr=m_listmodel->data(m_listmodel->index(cm->currentIndex(),0),Qt::UserRole).toInt();
                rd+=" ";
-               rd+=QString::number(m_list[musr].customerID());
+               rd+=QString::number(m_list[musr].id());
        }
        //delete it
-       if(!m_req->request("deletecustomer",rd.toAscii())){
+       /*TODO
+       if(!req->request("deletecustomer",rd.toAscii())){
                QMessageBox::warning(this,tr("Error"),tr("Failed to delete customer."));
                return;
        }
@@ -362,6 +240,7 @@ void MCustomerListDialog::deleteCustomer()
        }
        //update view
        updateList();
+       */
 }
 
 
@@ -389,11 +268,11 @@ MCustomerDialog::MCustomerDialog(MCustomer c,QWidget*par)
        m_cont->setPlainText(m_cust.contact());
        gl->setRowMinimumHeight(++lc,10);
        gl->addWidget(new QLabel(tr("Web-Login/eMail:")),++lc,0);
-       gl->addWidget(m_mail=new QLabel(m_cust.mail()),lc,1);
+       gl->addWidget(m_mail=new QLabel(m_cust.email()),lc,1);
        gl->setRowMinimumHeight(++lc,10);
        gl->addWidget(new QLabel(tr("Comment:")),++lc,0,1,2);
        gl->addWidget(m_comm=new QTextEdit,++lc,0,1,2);
-       m_comm->setPlainText(m_cust.comment());
+       m_comm->setPlainText(m_cust.comments());
        gl->setRowMinimumHeight(++lc,15);
        QHBoxLayout*hl;
        gl->addLayout(hl=new QHBoxLayout,++lc,0,1,2);
@@ -409,15 +288,16 @@ MCustomerDialog::MCustomerDialog(MCustomer c,QWidget*par)
 MCustomer MCustomerDialog::getCustomer()
 {
        //copy data from input fields
-       m_cust.setName(m_name->text());
-       m_cust.setAddress(m_addr->toPlainText());
-       m_cust.setContact(m_cont->toPlainText());
-       m_cust.setComment(m_comm->toPlainText());
+       m_cust.setname(m_name->text());
+       //TODO: redo address editing
+       //m_cust.setaddress(m_addr->toPlainText());
+       m_cust.setcontact(m_cont->toPlainText());
+       m_cust.setcomments(m_comm->toPlainText());
        return m_cust;
 }
 
 void MCustomerDialog::save()
-{
+{/*TODO:
        getCustomer();
-       m_cust.save();
+       m_cust.save();*/
 }
index 4bf7282..d123af7 100644 (file)
 #include <QDialog>
 #include <QList>
 
-class MWebRequest;
-class QDomElement;
+#include "MOCustomer.h"
 
-class MCustomer
+/**this class expands on MOCustomer to add some convenience methods*/
+class MCustomer:public MOCustomer
 {
        public:
                /**creates an empty/invalid customer*/
-               MCustomer(MWebRequest*r=0);
+               MCustomer(){}
                /**fetches customer from the Database*/
-               MCustomer(MWebRequest*,qint64);
-               /**creates a customer from XML*/
-               MCustomer(MWebRequest*,const QDomElement&);
+               MCustomer(qint64);
                /**copies a customer*/
-               MCustomer(const MCustomer&);
+               MCustomer(const MCustomer&c):MOCustomer(c){}
+               MCustomer(const MOCustomer&c):MOCustomer(c){}
                
                /**copies a customer*/
-               MCustomer& operator=(const MCustomer&);
-               
-               /**returns the ID of this customer or -1 if it is invalid*/
-               qint64 customerID();
+               MCustomer& operator=(const MCustomer&c){MOCustomer::operator=(c);return *this;}
+               MCustomer& operator=(const MOCustomer&c){MOCustomer::operator=(c);return *this;}
                
                /**returns whether the customer is valid*/
                bool isValid();
                
-               /**returns the customers name*/
-               QString name();
-               
-               /**sets the name of the customer*/
-               void setName(QString);
-               
                /**returns the address of the customer*/
-               QString address();
-               
-               /**sets the address of the customer*/
-               void setAddress(QString);
-               
-               /**returns the contact information*/
-               QString contact();
-               
-               /**sets the contact info of the customer*/
-               void setContact(QString);
-               
-               /**returns the login-mail-address for the web-interface*/
-               QString mail();
-               
-               /**returns the comment data*/
-               QString comment();
-               
-               /**sets the comment for the customer*/
-               void setComment(QString);
-               
-               /**returns the customers name and address*/
-               QString getNameAddress();
-               
-               /**saves the data back to the server; this does not transfer web-login data*/
-               void save();
-               
-       private:
-               qint64 m_id;
-               QString m_name,m_address,m_contact,m_mail,m_comment;
-               bool m_iscomplete;
-               MWebRequest*m_req;
-               
-               /**internal: requests data update*/
-               void getUpdate();
-               
-               /**internal helper: scan XML data*/
-               void scanXml(const QDomElement&);
+               QString address(int i=0);
 };
 
 class QListView;
@@ -98,7 +53,7 @@ class MCustomerListDialog:public QDialog
        Q_OBJECT
        public:
                /**creates a new customer list dialog; expects a usable webrequest object and a parent, if isselect is set to true it offers a select button, if selected is set to a matching customerID it will be pre-selected*/
-               MCustomerListDialog(MWebRequest*,QWidget*,bool isselect=false,qint64 selected=-1);
+               MCustomerListDialog(QWidget*,bool isselect=false,qint64 selected=-1);
                
                /**returns the selected customer*/
                MCustomer getCustomer();
@@ -117,7 +72,6 @@ class MCustomerListDialog:public QDialog
                QStandardItemModel*m_listmodel;
                QSortFilterProxyModel*m_proxymodel;
                QLineEdit*m_filter;
-               MWebRequest*m_req;
                
                /**updates internal list*/
                void updateList(int id=-1);
index ba75490..fe1a8a6 100644 (file)
 //
 
 #include "event.h"
-#include "webrequest.h"
 
 #include <QCoreApplication>
-#include <QDomDocument>
-#include <QDomElement>
+#include <QDateTime>
+#include <QRegExp>
+#include <QStringList>
 
-MEvent::MEvent(MWebRequest*r,int id)
-{
-       req=r;
-       eventid=id;
-       refresh();
-}
-
-MEvent::MEvent()
-{
-       req=0;
-       eventid=-1;
-       m_starttime=m_endtime=m_capacity=m_defaultprice=0;
-       m_sold=m_reserved=-1;
-       m_valid=m_complete=false;
-}
-
-MEvent::MEvent(MWebRequest*r,QDomElement&el)
-{
-       req=r;
-       m_starttime=QDateTime::currentDateTime().toTime_t();
-       m_endtime=m_starttime+3600;
-       m_capacity=10;
-       m_sold=m_reserved=-1;
-       m_defaultprice=100;
-       m_valid=false;
-       m_roomid=m_title=m_artist=m_description=m_cancelreason="";
-       m_valid=true;
-       m_complete=false;
-       bool b;
-       eventid=el.attribute("id","x").toInt(&b);
-       if(!b)eventid=-1;
-       else initFromElement(el);
-}
-
-MEvent::MEvent(const MEvent&e)
-{
-       operator=(e);
-}
-
-MEvent& MEvent::operator=(const MEvent&e)
-{
-       req=e.req;
-       eventid=e.eventid;
-       m_title=e.m_title;
-       m_artist=e.m_artist;
-       m_description=e.m_description;
-       m_starttime=e.m_starttime;
-       m_endtime=e.m_endtime;
-       m_roomid=e.m_roomid;
-       m_capacity=e.m_capacity;
-       m_sold=e.m_sold;
-       m_reserved=e.m_reserved;
-       m_defaultprice=e.m_defaultprice;
-       m_cancelreason=e.m_cancelreason;
-       m_valid=e.m_valid;
-       m_complete=e.m_complete;
-       return *this;
-}
-
-void MEvent::refresh()
-{
-       m_starttime=QDateTime::currentDateTime().toTime_t();
-       m_endtime=m_starttime+3600;
-       m_capacity=10;
-       m_sold=m_reserved=-1;
-       m_defaultprice=100;
-       m_valid=false;
-       m_roomid=m_title=m_artist=m_description=m_cancelreason="";
-       m_valid=true;
-       m_complete=false;
-       if(eventid>=0){
-               //get data from server
-               if(!req->request("geteventdata",QString::number(eventid).toAscii())){
-                       m_valid=false;
-                       return;
-               }
-               //check server response state
-               if(req->responseStatus()!=MWebRequest::Ok){
-                       m_valid=false;
-                       return;
-               }
-               //parse data
-               QDomDocument doc;
-               if(!doc.setContent(req->responseBody())){
-                       m_valid=false;
-                       return;
-               }
-               QDomElement root=doc.documentElement();
-               //search for this event
-               QDomNodeList nl=root.elementsByTagName("Event");
-               for(int i=0;i<nl.size();i++){
-                       //filter
-                       QDomElement el=nl.at(i).toElement();
-                       if(el.isNull())continue;
-                       bool b;
-                       int eid=el.attribute("id","x").toInt(&b);
-                       if(eid!=eventid || !b)continue;
-                       initFromElement(el);
-               }
-       }
-}
+#include "msinterface.h"
 
-void MEvent::initFromElement(QDomElement&el)
+MEvent::MEvent(qint64 i)
 {
-       //get attribute data
-       m_starttime=el.attribute("start","0").toInt();
-       m_endtime=el.attribute("end","0").toInt();
-       m_capacity=el.attribute("capacity","0").toInt();
-       m_sold=el.attribute("sold","-1").toInt();
-       m_reserved=el.attribute("reserved","-1").toInt();
-       m_defaultprice=el.attribute("defaultprice","0").toInt();
-       bool iscancel=el.attribute("cancelled","false")=="true";
-       //get title (if element exists this is a complete list, otherwise only preview)
-       QDomNodeList nl2=el.elementsByTagName("Title");
-       if(nl2.size()>0){
-               m_complete=true;
-               QDomElement el2=nl2.at(0).toElement();
-               if(!el2.isNull())
-                       m_title=el2.text();
-       }else{
-               //incomplete event, break here
-               m_complete=false;
-               m_title=el.text().trimmed();
-               return;
-       }
-       //get artist
-       nl2=el.elementsByTagName("Artist");
-       if(nl2.size()>0){
-               QDomElement el2=nl2.at(0).toElement();
-               if(!el2.isNull())
-                       m_artist=el2.text();
-       }
-       //get description
-       nl2=el.elementsByTagName("Description");
-       if(nl2.size()>0){
-               QDomElement el2=nl2.at(0).toElement();
-               if(!el2.isNull())
-                       m_description=el2.text();
-       }
-       //get room
-       nl2=el.elementsByTagName("Room");
-       if(nl2.size()>0){
-               QDomElement el2=nl2.at(0).toElement();
-               if(!el2.isNull())
-                       m_roomid=el2.text().trimmed();
-       }
-       //get cancel reason
-       nl2=el.elementsByTagName("CancelReason");
-       if(nl2.size()>0){
-               QDomElement el2=nl2.at(0).toElement();
-               if(!el2.isNull())
-                       m_cancelreason=el2.text().trimmed();
-       }
-       if(iscancel){
-               if(m_cancelreason=="")m_cancelreason=" ";
-       }else{
-               m_cancelreason="";
-       }
-}
-
-MEvent::~MEvent()
-{}
-
-QString MEvent::save()
-{
-       //do not attempt to save invalid or incomplete data
-       if(!m_valid || !m_complete)return QCoreApplication::translate("MEvent","Event is not complete, cannot save.");
-       //create XML
-       QDomDocument doc;
-       QDomElement root=doc.createElement("Event");
-       if(eventid>=0)root.setAttribute("id",eventid);
-       else root.setAttribute("id","new");
-       root.setAttribute("start",m_starttime);
-       root.setAttribute("end",m_endtime);
-       root.setAttribute("capacity",m_capacity);
-       root.setAttribute("defaultprice",m_defaultprice);
-       root.setAttribute("cancelled",isCancelled()?"true":"false");
-       QDomElement el=doc.createElement("Title");
-       el.appendChild(doc.createTextNode(m_title));
-       root.appendChild(el);
-       el=doc.createElement("Artist");
-       el.appendChild(doc.createTextNode(m_artist));
-       root.appendChild(el);
-       el=doc.createElement("Description");
-       el.appendChild(doc.createTextNode(m_description));
-       root.appendChild(el);
-       el=doc.createElement("Room");
-       el.appendChild(doc.createTextNode(m_roomid));
-       root.appendChild(el);
-       if(isCancelled()){
-               el=doc.createElement("CancelReason");
-               el.appendChild(doc.createTextNode(m_cancelreason));
-               root.appendChild(el);
-       }
-       doc.appendChild(root);
-       //call
-       req->request("seteventdata",doc.toByteArray());
-       //get new ID
-       if(req->responseStatus()==MWebRequest::Ok){
-               QString r=QString::fromAscii(req->responseBody()).trimmed();
-               bool b;
-               int eid=r.toInt(&b);
-               if(b && eid>=0)eventid=eid;
-               return "";
-       }else{
-               return req->errorString()+" ";
-       }
+       MTGetEvent ge=MSInterface::instance()->queryGetEvent(i);
+       if(ge.stage()==ge.Success)
+               operator=(ge.getevent().value());
 }
 
 QRegExp MEvent::priceRegExp()const
@@ -233,49 +33,34 @@ QRegExp MEvent::priceRegExp()const
 
 QString MEvent::priceString()const
 {
-       QString ret=QString::number(m_defaultprice/100);
+       qint64 dp=defaultprice();
+       QString ret=QString::number(dp/100);
        ret+=QCoreApplication::translate("MEvent",".","price decimal dot");
-       ret+=QString::number((m_defaultprice/10)%10);
-       ret+=QString::number(m_defaultprice%10);
+       ret+=QString::number((dp/10)%10);
+       ret+=QString::number(dp%10);
        return ret;
 }
 
-void MEvent::setCancelled(bool ic,QString cr)
-{
-       if(ic){
-               m_cancelreason=cr.trimmed();
-               if(m_cancelreason=="")m_cancelreason=" ";
-       }else
-               m_cancelreason="";
-}
-
-void MEvent::setPrice(QString str)
-{
-       QStringList ps=str.split(QCoreApplication::translate("MEvent",".","price decimal dot"));
-       int prc=0;
-       if(ps.size()>=1)prc=ps[0].toInt()*100;
-       if(ps.size()>=2)prc+=ps[1].toInt();
-       m_defaultprice=prc;
-}
-
 QString MEvent::startTimeString()const
 {
-        return QDateTime::fromTime_t(m_starttime).toString(QCoreApplication::translate("MEvent","yyyy-MM-dd hh:mm ap","date/time format"));
+        return QDateTime::fromTime_t(start()).toString(QCoreApplication::translate("MEvent","yyyy-MM-dd hh:mm ap","date/time format"));
 }
 
 QString MEvent::startDateString()const
 {
-        return QDateTime::fromTime_t(m_starttime).toString(QCoreApplication::translate("MEvent","yyyy-MM-dd","date format"));
+        return QDateTime::fromTime_t(start()).toString(QCoreApplication::translate("MEvent","yyyy-MM-dd","date format"));
 }
 
 QString MEvent::endTimeString()const
 {
-        return QDateTime::fromTime_t(m_endtime).toString(QCoreApplication::translate("MEvent","yyyy-MM-dd hh:mm ap","date/time format"));
+        return QDateTime::fromTime_t(end()).toString(QCoreApplication::translate("MEvent","yyyy-MM-dd hh:mm ap","date/time format"));
 }
 
-bool MEvent::cancelEvent(QString cr)
+void MEvent::setdefaultprice(QString str)
 {
-       QByteArray rq=QByteArray::number(eventid)+"\n"+cr.toUtf8();
-       if(!req->request("cancelevent",rq))return false;
-       return req->responseStatus()==MWebRequest::Ok;
+       QStringList ps=str.split(QCoreApplication::translate("MEvent",".","price decimal dot"));
+       qint64 prc=0;
+       if(ps.size()>=1)prc=ps[0].toInt()*100;
+       if(ps.size()>=2)prc+=ps[1].toInt();
+       setdefaultprice(prc);
 }
index 64d019e..c684946 100644 (file)
 #define EVENT_H
 
 #include <QString>
+#include <MOEvent.h>
 
-class MWebRequest;
-class QDomElement;
-
-/**encapsulation of an event, this class handles all there is to know about events and how to communicate with the database*/
-class MEvent
+/**encapsulation of an event, this class wraps the auto-generated event class to provide some convenience methods*/
+class MEvent:public MOEvent
 {
        public:
                /**creates an invalid event*/
-               MEvent();
-               /**creates an event by ID, the constructor asks the server/database for details*/
-               MEvent(MWebRequest*,int);
-               /**creates an event via a DOM-element, used by WebRequest::getAllEvents*/
-               MEvent(MWebRequest*,QDomElement&);
+               MEvent():MOEvent(){}
+               /**copies an event*/
+               MEvent(const MEvent&e):MOEvent(e){}
                /**copies an event*/
-               MEvent(const MEvent&);
+               MEvent(const MOEvent&e):MOEvent(e){}
+               /**get event directly from server*/
+               MEvent(qint64);
                /**destructs an event*/
-               ~MEvent();
+               ~MEvent(){}
                
                /**copies the event*/
-               MEvent& operator=(const MEvent&);
+               MEvent& operator=(const MEvent&e){MOEvent::operator=(e);return *this;}
                
                /**updates data from the database, can be used to upgrade an incomplete event to a complete one*/
-               void refresh();
+               //void refresh();
                
                /**saves all data back to the database, it returns an empty string on success, it does not do anything if the event is invalid or incomplete*/
-               QString save();
-               
-               /**returns the database ID of the event, a valid event will always have an ID >=0*/
-               int eventId()const{return eventid;}
+               //QString save();
                
-               /**returns the title of the event*/
-               QString title()const{return m_title;}
-               /**returns the artist of the event*/
-               QString artist()const{return m_artist;}
-               /**returns the description of the event (HTML)*/
-               QString description()const{return m_description;}
-               /**returns the start time of the event as Unix timestamp*/
-               int startTime()const{return m_starttime;}
-               /**returns the end time of the event as Unix timestamp*/
-               int endTime()const{return m_endtime;}
                /**returns the start time of the event as localized string*/
                QString startTimeString()const;
                /**returns the start date as localized string*/
@@ -62,66 +47,23 @@ class MEvent
                /**returns the end time of the event as localized string*/
                QString endTimeString()const;
                /**returns the room of the event, the room must be one out of the list of valid rooms*/
-               QString room()const{return m_roomid;}
-               /**returns the amount of tickets than can be sold for this event, initially this should be a copy of the rooms capacity*/
-               int capacity()const{return m_capacity;}
-               /**returns how many tickets have been sold (if not available: -1)*/
-               int amountSold()const{return m_sold;}
-               /**returns how many tickets have been reserved (if not available: -1)*/
-               int amountReserved()const{return m_reserved;}
-               /**returns the normal price of tickets in cent*/
-               int price()const{return m_defaultprice;}
-               /**returns whether the event is cancelled*/
-               bool isCancelled()const{return !m_cancelreason.isEmpty();}
-               /**returns the reason why the event is cancelled*/
-               QString cancelReason()const{return m_cancelreason.trimmed();}
-               
-               void setTitle(QString t){m_title=t;}
-               void setArtist(QString t){m_artist=t;}
-               void setDescription(QString t){m_description=t;}
-               void setRoom(QString t){m_roomid=t;}
-               void setStartTime(int t){m_starttime=t;}
-               void setEndTime(int t){m_endtime=t;}
-               void setCapacity(int c){m_capacity=c;}
-               void setPrice(int p){if(p>=0)m_defaultprice=p;}
-               void setPrice(QString);
-               void setCancelled(bool,QString cr=QString());
                
                /**returns the price as a localized string*/
                QString priceString()const;
                /**returns the local regular expression for prices*/
                QRegExp priceRegExp()const;
                
+               /**set the price as string*/
+               void setdefaultprice(QString);
+               
+               //inherit alternative definition
+               inline void setdefaultprice(qint64 p){MOEvent::setdefaultprice(p);}
+               
                /**returns whether the event is valid. an event can be invalid if it is uninitialized (negative ID) or the server request failed*/
-               bool isValid()const{return m_valid;}
-               /**returns whether the data stored in this event object is complete - this depends on the amount of data sent by the server*/
-               bool isComplete()const{return m_complete;}
-               /**forces the event to believe it is valid and complete; used for saving new events*/
-               void makeValid(){m_valid=true;m_complete=true;}
+               //bool isValid()const{return m_valid;}
                
                /**requests to cancel the event from the DB; expects reason as argument; returns true on success*/
-               bool cancelEvent(QString);
-       private:
-               //used by both constructors:
-               void initFromElement(QDomElement&);
-       
-               MWebRequest*req;
-               int eventid;
-               //display data
-               QString m_title,m_artist,m_description;
-               //timing and location
-               int m_starttime,m_endtime;
-               QString m_roomid;
-               //initially a copy from room, can be adjusted
-               int m_capacity;
-               //contains amount of sold/reserved tickets if available; -1 otherwise
-               int m_sold,m_reserved;
-               //default pricing in cents
-               int m_defaultprice;
-               //if not null/empty: event has been cancelled
-               QString m_cancelreason;
-               //holds whether the loaded data is valid
-               bool m_valid,m_complete;
+               //bool cancelEvent(QString);
 };
 
 #endif
index 0397b39..3c4b663 100644 (file)
@@ -11,7 +11,6 @@
 //
 
 #include "eventedit.h"
-#include "webrequest.h"
 
 #include <QBoxLayout>
 #include <QCheckBox>
 #include <QTextEdit>
 #include <QTimer>
 
-MEventEditor::MEventEditor(QWidget*w,MWebRequest*r,qint32 id)
-       :QDialog(w),event(r,id)
+#include <msinterface.h>
+#include <MTGetEvent.h>
+
+#define req (MSInterface::instance())
+
+MEventEditor::MEventEditor(QWidget*w,qint64 id)
+       :QDialog(w)
 {
-       if(!event.isValid()){
+       MTGetEvent ge=MTGetEvent::query(id);
+       if(ge.stage()!=ge.Success){
                QMessageBox::warning(this,tr("Warning"),tr("Unable to load event from server."));
                //make myself disappear immediately
                QTimer::singleShot(1,this,SLOT(reject()));
                //no point in setting up widgets
                return;
        }
+       event=ge.getevent().value();
        setWindowTitle(tr("Event Editor"));
-       req=r;
        
        QGridLayout*gl;
        QVBoxLayout*vl;
@@ -53,7 +58,7 @@ MEventEditor::MEventEditor(QWidget*w,MWebRequest*r,qint32 id)
        gl->addWidget(lab=new QLabel(tr("ID:")),lctr,0);
        lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
        gl->addWidget(eventid=new QLabel,lctr,1);
-       eventid->setText(QString::number(event.eventId()));
+       eventid->setText(QString::number(event.id()));
        
        gl->addWidget(lab=new QLabel(tr("Title:")),++lctr,0);
        lab->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
@@ -75,7 +80,7 @@ MEventEditor::MEventEditor(QWidget*w,MWebRequest*r,qint32 id)
        gl->addWidget(starttime=new QDateTimeEdit,lctr,1);
        starttime->setDisplayFormat(tr("ddd MMMM d yyyy, h:mm ap","time format"));
        starttime->setCalendarPopup(true);
-       starttime->setDateTime(QDateTime::fromTime_t(event.startTime()));
+       starttime->setDateTime(QDateTime::fromTime_t(event.start()));
        connect(starttime,SIGNAL(dateTimeChanged(const QDateTime&)),this,SLOT(startTimeChanged(const QDateTime&)));
        
        gl->addWidget(lab=new QLabel(tr("End Time:")),++lctr,0);
@@ -83,7 +88,7 @@ MEventEditor::MEventEditor(QWidget*w,MWebRequest*r,qint32 id)
        gl->addWidget(endtime=new QDateTimeEdit,lctr,1);
        endtime->setDisplayFormat(tr("ddd MMMM d yyyy, h:mm ap","time format"));
        endtime->setCalendarPopup(true);
-       endtime->setDateTime(QDateTime::fromTime_t(event.endTime()));
+       endtime->setDateTime(QDateTime::fromTime_t(event.end()));
        connect(endtime,SIGNAL(dateTimeChanged(const QDateTime&)),this,SLOT(endTimeChanged(const QDateTime&)));
        
        gl->addWidget(lab=new QLabel(tr("Room/Place:")),++lctr,0);
@@ -108,11 +113,11 @@ MEventEditor::MEventEditor(QWidget*w,MWebRequest*r,qint32 id)
        price->setText(event.priceString());
        
        gl->addWidget(cancelcheck=new QCheckBox(tr("Event Cancelled:")),++lctr,0);
-       cancelcheck->setChecked(event.isCancelled());
+       cancelcheck->setChecked(event.cancelled());
        cancelcheck->setEnabled(false);
        gl->addWidget(cancelreason=new QLineEdit,lctr,1);
-       cancelreason->setEnabled(event.isCancelled());
-       cancelreason->setText(event.cancelReason());
+       cancelreason->setEnabled(event.cancelled());
+       cancelreason->setText(event.cancelreason());
        connect(cancelcheck,SIGNAL(toggled(bool)),cancelreason,SLOT(setEnabled(bool)));
        
        vl->addStretch();
@@ -129,27 +134,29 @@ MEventEditor::MEventEditor(QWidget*w,MWebRequest*r,qint32 id)
 void MEventEditor::writeBack()
 {
        //copy contents to event
-       event.setTitle(title->text());
-       event.setStartTime(starttime->dateTime().toTime_t());
-       event.setEndTime(endtime->dateTime().toTime_t());
-       event.setArtist(artist->text());
-       event.setRoom(room->text());
-       event.setPrice(price->text());
-       event.setCancelled(cancelcheck->isChecked(),cancelreason->text());
-       event.setDescription(description->toPlainText());
-       event.setCapacity(capacity->value());
+       event.settitle(title->text());
+       event.setstart(starttime->dateTime().toTime_t());
+       event.setend(endtime->dateTime().toTime_t());
+       event.setartist(artist->text());
+       event.setroom(room->text());
+       event.setdefaultprice(price->text());
+       event.setcancelled(cancelcheck->isChecked());
+       event.setcancelreason(cancelreason->text());
+       event.setdescription(description->toPlainText());
+       event.setcapacity(capacity->value());
        //send to server
+       /*TODO
        event.makeValid();
        QString r=event.save();
        if(r!=""){
                QMessageBox::warning(this,tr("Warning"),tr("Problem while uploading event: %s").arg(r));
        }else
-               accept();
+               accept();*/
 }
 
 void MEventEditor::selectRoom()
 {
-       QList<MRoom>rlst=req->getAllRooms();
+       QList<MORoom>rlst=req->queryGetAllRooms().getrooms();
        QDialog d;
        d.setWindowTitle(tr("Select a Room"));
        QVBoxLayout*vl;
@@ -157,7 +164,7 @@ void MEventEditor::selectRoom()
        QListWidget*rlstw;
        vl->addWidget(rlstw=new QListWidget,10);
        for(int i=0;i<rlst.size();i++)
-               rlstw->addItem(rlst[i].roomId());
+               rlstw->addItem(rlst[i].id());
        QHBoxLayout*hl;
        vl->addLayout(hl=new QHBoxLayout,0);
        hl->addStretch(10);
@@ -177,14 +184,14 @@ void MEventEditor::selectRoom()
 }
 
 void MEventEditor::newRoom()
-{
+{/*TODO
        QString rid=QInputDialog::getText(this,tr("New Room"),tr("Name of new room:"));
        if(rid!=""){
                MRoom rm(req,rid);
                rm.makeValid();
                rm.save();
                room->setText(rid);
-       }
+       }*/
 }
 
 void MEventEditor::startTimeChanged(const QDateTime&st)
index d795a9d..bd183a7 100644 (file)
@@ -17,7 +17,6 @@
 
 #include "event.h"
 
-class MWebRequest;
 class QCheckBox;
 class QDateTime;
 class QDateTimeEdit;
@@ -30,7 +29,7 @@ class MEventEditor:public QDialog
 {
        Q_OBJECT
        public:
-               MEventEditor(QWidget*,qint32 id=-1);
+               MEventEditor(QWidget*,qint64 id=-1);
        private slots:
                void writeBack();
                void selectRoom();
index 07d6f00..ba5206c 100644 (file)
@@ -13,7 +13,7 @@
 #include "eventsummary.h"
 #include "misc.h"
 #include "odtrender.h"
-#include "webrequest.h"
+#include "msinterface.h"
 
 #include <QBoxLayout>
 #include <QDomDocument>
 #include <QTableView>
 #include <QTextBrowser>
 
-MEventSummary::MEventSummary(QWidget*par,int eid)
-       :QDialog(par),event(rq,eid)
+#define req (MSInterface::instance())
+
+MEventSummary::MEventSummary(QWidget*par,qint64 eid)
+       :QDialog(par),event(eid)
 {
        nreserved=ncancelled=ntotaltickets=ntotalmoney=0;
        //get event data
@@ -112,12 +114,12 @@ void MEventSummary::getOrderData()
 {
        if(orderids.size()==orders.size())return;
        for(int i=0;i<orderids.size();i++){
-               orders.insert(orderids[i],MOrder(req,orderids[i]));
+               orders.insert(orderids[i],MOrder(orderids[i]));
        }
 }
 
 void MEventSummary::getSummaryData()
-{
+{/*TODO:
        if(!req->request("eventsummary",QString::number(event.eventId()).toAscii()))return;
        if(req->responseStatus()!=MWebRequest::Ok)return;
        QDomDocument doc;
@@ -161,11 +163,11 @@ void MEventSummary::getSummaryData()
                                orderids.append(oid);
                }
        }
-       qSort(orderids);
+       qSort(orderids);*/
 }
 
 void MEventSummary::print()
-{
+{/*TODO:
        MTemplate tf=req->getTemplate("eventsummary");
        if(!tf.isValid()){
                QMessageBox::warning(this,tr("Warning"),tr("Unable to get template file (eventsummary). Giving up."));
@@ -175,11 +177,11 @@ void MEventSummary::print()
        connect(&rend,SIGNAL(getVariable(QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getVariable(QString,MOdtRenderer::VarType&,QVariant&)));
        connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&)));
        connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)));
-       rend.renderToPrinter();
+       rend.renderToPrinter();*/
 }
 
 void MEventSummary::saveas()
-{
+{/*TODO:
        MTemplate tf=req->getTemplate("eventsummary");
        if(!tf.isValid()){
                QMessageBox::warning(this,tr("Warning"),tr("Unable to get template file (eventsummary). Giving up."));
@@ -201,26 +203,26 @@ void MEventSummary::saveas()
        connect(&rend,SIGNAL(getVariable(QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getVariable(QString,MOdtRenderer::VarType&,QVariant&)));
        connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&)));
        connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)));
-       rend.renderToFile(fname);
+       rend.renderToFile(fname);*/
 }
 
 void MEventSummary::getVariable(QString varname,MOdtRenderer::VarType&av,QVariant&value)
 {
        if(varname=="TITLE")
-               value=event.title();
+               value=event.title().value();
        else
        if(varname=="ARTIST")
-               value=event.artist();
+               value=event.artist().value();
        else
        if(varname=="ROOM")
-               value=event.room();
+               value=event.room().value();
        else
        if(varname=="START"){
-               value=event.startTime();
+               value=event.start().value();
                av=MOdtRenderer::DateTimeVar;
        }else
        if(varname=="CAPACITY"){
-               value=event.capacity();
+               value=event.capacity().value();
                av=MOdtRenderer::IntVar;
        }else
        if(varname=="RESERVED"){
@@ -264,7 +266,7 @@ void MEventSummary::getVariable(QString varname,MOdtRenderer::VarType&av,QVarian
                av=MOdtRenderer::IntVar;
        }else
        if(varname=="EVENTPRICE"){
-               value=event.price();
+               value=event.defaultprice().value();
                av=MOdtRenderer::MoneyVar;
        }
 }
@@ -323,12 +325,12 @@ void MEventSummary::getLoopVariable(QString loopname,int iteration,QString varna
                //paranoia check
                if(!orders.contains(oid))return;
                
-               if(varname=="CUSTOMERID")value=QString::number(orders[oid].customerID());else
-               if(varname=="CUSTOMER")value=orders[oid].customer().name();else
+               if(varname=="CUSTOMERID")value=QString::number(orders[oid].orderid());else
+               if(varname=="CUSTOMER")value=orders[oid].customer().name().value();else
                if(varname=="FULLPRICE"){
-                       value=orders[oid].totalPrice();
+                       value=orders[oid].totalprice().value();
                        av=MOdtRenderer::MoneyVar;
-               }else
+               }/*TODO: else
                if(varname=="SHIPPING")value=orders[oid].shipping().description();else
                if(varname=="SHIPPINGCOST"){
                        value=orders[oid].shipping().price();
@@ -375,6 +377,6 @@ void MEventSummary::getLoopVariable(QString loopname,int iteration,QString varna
                                value=prc;
                                av=MOdtRenderer::MoneyVar;
                        }
-               }
+               }*/
        }
 }
index 99c956e..0333550 100644 (file)
@@ -29,7 +29,7 @@ class MEventSummary:public QDialog
        Q_OBJECT
        public:
                /**creates a new summary dialog, requests data from server*/
-               MEventSummary(QWidget*parent,int eventid);
+               MEventSummary(QWidget*parent,qint64 eventid);
                /**deletes MEventSummary*/
                ~MEventSummary();
                
index 000927c..601357a 100644 (file)
 //
 
 #include "host.h"
-#include "webrequest.h"
 #include "keygen.h"
+#include "msinterface.h"
 
 #include <QCoreApplication>
-#include <QDomElement>
 #include <QRegExp>
 
-MHost::MHost(MWebRequest*r,QDomElement&e)
-{
-       req=r;
-       m_hostid=e.attribute("name").trimmed();
-       m_key=e.text().trimmed();
-}
-
-MHost::MHost(MWebRequest*r,QString n,QString k)
-{
-       req=r;
-       m_hostid=n;
-       m_key=k;
-}
-
-MHost::MHost()
-{
-       req=0;
-}
+#define req (MSInterface::instance())
 
-MHost::MHost(const MHost&u)
+MHost::MHost(QString n,QString k)
 {
-       req=u.req;
-       m_hostid=u.m_hostid;
-       m_key=u.m_key;
+       setname(n);
+       setkey(k);
 }
 
-QString MHost::hostId()
-{
-       return m_hostid;
-}
-
-QString MHost::hostKey()
-{
-       return m_key;
-}
-
-bool MHost::isValid()
-{
-       return QRegExp("[A-Za-z0-9_]+").exactMatch(m_hostid);
-}
 
 int MHost::newKey()
 {
        int r=getEntropy();
-       m_key=getRandom(40).toHex();
+       setkey(QString(getRandom(40).toHex()));
        if(r<(40*8))return r;
        else return 40*8;
 }
@@ -71,50 +38,22 @@ bool MHost::create()
 {
        //do not attempt to save invalid or incomplete data
        if(!isValid())return false;
-       //create XML
-       QDomDocument doc;
-       QDomElement root=doc.createElement("Hosts");
-       QDomElement el=doc.createElement("Host");
-       el.setAttribute("name",m_hostid);
-       el.appendChild(doc.createTextNode(m_key));
-       root.appendChild(el);
-       doc.appendChild(root);
-       //call
-       req->request("addhost",doc.toByteArray());
+       MTSetHost ch=req->querySetHost(name(),key());
        //check success
-       if(req->responseStatus()==MWebRequest::Ok){
-               //TODO: check response content for myself, return false if not found
-               return true;
-       }else{
-               return false;
-       }
+       return ch.stage()==ch.Success;
 }
 
 bool MHost::save()
 {
        //do not attempt to save invalid or incomplete data
        if(!isValid())return false;
-       //create XML
-       QDomDocument doc;
-       QDomElement root=doc.createElement("Hosts");
-       QDomElement el=doc.createElement("Host");
-       el.setAttribute("name",m_hostid);
-       el.appendChild(doc.createTextNode(m_key));
-       root.appendChild(el);
-       doc.appendChild(root);
-       //call
-       req->request("sethost",doc.toByteArray());
+       MTSetHost ch=req->querySetHost(name(),key());
        //check success
-       if(req->responseStatus()==MWebRequest::Ok){
-               //TODO: check response content for myself, return false if not found
-               return true;
-       }else{
-               return false;
-       }
+       return ch.stage()==ch.Success;
 }
 
 void MHost::deleteHost()
 {
        if(!isValid())return;
-       req->request("deletehost",m_hostid.toUtf8());
+       req->queryDeleteHost(name());
 }
index 065acff..9d3fc8e 100644 (file)
 #define MAGICSMOKE_HOST_H
 
 #include <QString>
+#include <MOHost.h>
 
-class MWebRequest;
-class QDomElement;
-
-class MHost
+/**this class wraps MOHost and adds some convenience methods*/
+class MHost:public MOHost
 {
        public:
                /**create invalid host*/
-               MHost();
+               MHost():MOHost(){}
                /**create host by name*/
-               MHost(MWebRequest*,QString,QString k=QString());
-               /**create host from XML element*/
-               MHost(MWebRequest*,QDomElement&);
+               MHost(QString,QString k=QString());
                /**copy host*/
-               MHost(const MHost&);
+               MHost(const MHost&h):MOHost(h){}
                
                /**returns host name*/
-               QString hostId();
+               QString hostId(){return name();}
                
                /**returns host key (fetches it from DB if not known yet)*/
-               QString hostKey();
+               QString hostKey(){return key();}
                
                /**checks host name*/
-               bool isValid();
+               bool isValid(){return name().value()!="";}
                
                /**creates new host key for this host; returns number of entropy bits*/
                int newKey();
@@ -50,10 +47,6 @@ class MHost
                
                /**deletes host from database*/
                void deleteHost();
-               
-       private:
-               MWebRequest*req;
-               QString m_hostid,m_key;
 };
 
 #endif
index c77ab1e..98846a5 100644 (file)
 //
 
 #include "moneylog.h"
-#include "webrequest.h"
+#include "msinterface.h"
 #include "misc.h"
 
 #include <QBoxLayout>
 #include <QPushButton>
 #include <QTextEdit>
 
-MMoneyLog::MMoneyLog(QWidget*pa,MWebRequest*req,QString q)
+MMoneyLog::MMoneyLog(QWidget*pa,QString q)
        :QDialog(pa)
 {
        //set title
@@ -41,6 +41,7 @@ MMoneyLog::MMoneyLog(QWidget*pa,MWebRequest*req,QString q)
        connect(p,SIGNAL(clicked()),this,SLOT(accept()));
        
        //query
+       /*TODO
        if(req->request("moneylog",q.toAscii())){
                if(req->responseStatus()==MWebRequest::Ok){
                        text->setPlainText(QString::fromUtf8(req->responseBody()));
@@ -49,5 +50,5 @@ MMoneyLog::MMoneyLog(QWidget*pa,MWebRequest*req,QString q)
                }
        }else{
                text->setHtml("<h1>Low Level Error</h1>Request failed.");
-       }
+       }*/
 }
\ No newline at end of file
index dbce7e3..fbdc415 100644 (file)
 
 #include <QDialog>
 
-class MWebRequest;
 
 class MMoneyLog:public QDialog
 {
        Q_OBJECT
        public:
-               MMoneyLog(QWidget*,MWebRequest*req,QString);
+               MMoneyLog(QWidget*,QString);
 };
 
 
index 1cea735..bf7b04c 100644 (file)
@@ -23,11 +23,13 @@ class MSInterface:public MInterface
                
                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;
+               bool login(QString,QString,QString){return false;}
+               void logout(){}
+               bool relogin(){return false;}
+               QString currentUser()const{return "";}
+               bool hasRole(QString)const{return false;}
+               QString dataDir()const{return "/tmp/blah";}
+               QString settingsGroup()const{return "nosuchgroup";}
        private:
                QString profileid;
 };
index 0ad8987..ce823a0 100644 (file)
 
 #include "misc.h"
 #include "order.h"
-#include "webrequest.h"
+
+#include "msinterface.h"
 
 #include <QCoreApplication>
 #include <QDomElement>
 #include <QMessageBox>
 
-MOrder::MOrder()
-{
-       req=0;
-       m_orderid=m_customer=-1;
-       m_price=m_paid=m_otime=m_stime=0;
-       m_status=Invalid;
-       m_complete=false;
-}
-
-MOrder::MOrder(MWebRequest*r,qint32 id)
-{
-       req=r;
-       getFromDB(id);
-}
-
-MOrder::MOrder(MWebRequest*r,const QDomElement&e)
-{
-       req=r;
-       parseXml(e);
-}
-
-MOrder::MOrder(const MOrder&o)
-{
-       operator=(o);
-}
-
-MOrder& MOrder::operator=(const MOrder&o)
-{
-       req=o.req;
-       m_orderid=o.m_orderid;
-       m_customer=o.m_customer;
-       m_price=o.m_price;
-       m_paid=o.m_paid;
-       m_status=o.m_status;
-       m_otime=o.m_otime;
-       m_stime=o.m_stime;
-       m_complete=o.m_complete;
-       m_tickets=o.m_tickets;
-       m_seller=o.m_seller;
-       m_deladdress=o.m_deladdress;
-       m_comment=o.m_comment;
-       m_vouchers=o.m_vouchers;
-       m_shipping=o.m_shipping;
-       return *this;
-}
+#define req (MSInterface::instance())
 
-int MOrder::orderID()const
+MOrder::MOrder(qint64 id)
 {
-       return m_orderid;
+       MTGetOrder go=req->queryGetOrder(id);
+       if(go.stage()==go.Success)
+               operator=(go.getorder().value());
 }
 
 bool MOrder::isValid()const
 {
-       return m_status!=Invalid;
-}
-
-int MOrder::customerID()const
-{
-       return m_customer;
+       //TODO: redefine isValid
+       return true;
 }
 
 MCustomer MOrder::customer()const
 {
-       return MCustomer(req,m_customer);
-}
-
-MOrder::OrderStatus MOrder::orderStatus()const
-{
-       return m_status;
-}
-
-bool MOrder::isStored()const
-{
-       return (m_status&Mask)==MaskIsStored;
-}
-
-bool MOrder::isCheck()const
-{
-       return (m_status&Mask)==MaskIsChecked;
+       return MCustomer(customerid());
 }
 
 bool MOrder::isReservation()const
 {
-       return m_status==Reserved;
+       return state()==Reserved;
 }
 
 bool MOrder::canOrder()const
 {
-       return m_status==CheckOk || m_status==CheckOrderOnly;
+       //TODO:redefine canOrder
+       //return m_status==CheckOk || m_status==CheckOrderOnly;
+       return true;
 }
 
 bool MOrder::canReserve()const{return canOrder();}
 
 bool MOrder::canSell()const
 {
-       return m_status==CheckOk || m_status==CheckSaleOnly;
+       //TODO: redefine canSell
+       //return m_status==CheckOk || m_status==CheckSaleOnly;
+       return true;
 }
 
 QString MOrder::orderStatusString()const
 {
-       switch(m_status){
-               case Placed:return QCoreApplication::translate("MOrder","placed","state");
-               case Sent:return QCoreApplication::translate("MOrder","sent","state");
-               case Cancelled:return QCoreApplication::translate("MOrder","cancelled","state");
-               case Closed:return QCoreApplication::translate("MOrder","closed","state");
-               case Reserved:return QCoreApplication::translate("MOrder","reserved","state");
-               case CheckOk:return QCoreApplication::translate("MOrder","check: ok","state");
-               case CheckSaleOnly:return QCoreApplication::translate("MOrder","check: sale only","state");
-               case CheckOrderOnly:return QCoreApplication::translate("MOrder","check: order only","state");
-               case CheckFail:return QCoreApplication::translate("MOrder","check: failed","state");
-               default:return QCoreApplication::translate("MOrder","invalid","state");
-       }
-}
-
-int MOrder::totalPrice()const
-{
-       return m_price;
+       return OrderState2str(state());
 }
 
 QString MOrder::totalPriceString(int off)const
 {
-       return cent2str(m_price+off);
-}
-
-int MOrder::amountPaid()const
-{
-       return m_paid;
+       return cent2str(totalprice()+off);
 }
 
 QString MOrder::amountPaidString(int off)const
 {
-       return cent2str(m_paid+off);
+       return cent2str(amountpaid()+off);
 }
 
 bool MOrder::needsPayment()const
 {
-       if(m_status==Placed || m_status==Sent)
-               if(m_paid<m_price)return true;
+       if(state()==Placed || state()==Sent)
+               if(amountpaid()<totalprice())return true;
        return false;
 }
 
 bool MOrder::needsRefund()const
 {
-       if(m_status==Cancelled)
-               return m_paid>0;
-       if(m_status==Placed || m_status==Sent)
-               return m_paid>m_price;
+       if(state()==Cancelled)
+               return amountpaid()>0;
+       if(state()==Placed || state()==Sent)
+               return amountpaid()>totalprice();
        return false;
 }
 
 int MOrder::amountToPay()const
 {
-       if(m_status==Placed || m_status==Sent)
-               if(m_paid<m_price)return m_price-m_paid;
+       if(state()==Placed || state()==Sent)
+               if(amountpaid()<totalprice())return totalprice()-amountpaid();
        return 0;
 }
 
 int MOrder::amountToRefund()const
 {
-       if(m_status==Cancelled)
-               return m_paid;
-       if(m_status==Placed || m_status==Sent)
-               if(m_paid>m_price)
-                       return m_paid-m_price;
+       if(state()==Cancelled)
+               return amountpaid();
+       if(state()==Placed || state()==Sent)
+               if(amountpaid()>totalprice())
+                       return amountpaid()-totalprice();
        return 0;
 }
 
@@ -198,116 +121,12 @@ QString MOrder::amountToRefundStr(int off)const
 bool MOrder::isSent()const
 {
        //only in placed mode there is a need for action, hence in all other modes we assume sent
-       return m_status!=Placed;
-}
-
-void MOrder::getFromDB(qint32 i)
-{
-       if(!req)return;
-       if(i<0)return;
-       //request
-       if(!req->request("getorder",QByteArray::number(i)))return;
-       if(req->responseStatus()!=MWebRequest::Ok)return;
-       //parse
-       QDomDocument doc;
-       if(!doc.setContent(req->responseBody())){
-               qDebug("Unable to parse response to getorder request.");
-               return;
-       }
-       parseXml(doc.documentElement());
-}
-
-void MOrder::parseXml(const QDomElement&e)
-{
-       //reset
-       m_complete=false;
-       m_otime=m_stime=0;
-       m_seller="";
-       m_deladdress="";
-       m_comment="";
-       m_tickets.clear();
-       m_vouchers.clear();
-       m_shipping=MShipping();
-       //Basics
-       bool b;
-       m_orderid=e.attribute("id","-1").toInt(&b);
-       if(!b){
-               m_orderid=m_customer=-1;
-               m_price=m_paid=0;
-               m_status=Invalid;
-               return;
-       }
-       m_customer=e.attribute("customer","-1").toInt(&b);
-       if(!b)m_customer=-1;
-       m_price=e.attribute("totalprice","0").toInt();
-       m_paid=e.attribute("paid","0").toInt();
-       QString st=e.attribute("status");
-       if(st=="placed")m_status=Placed;else
-       if(st=="sent")m_status=Sent;else
-       if(st=="cancelled")m_status=Cancelled;else
-       if(st=="reserved")m_status=Reserved;else
-       if(st=="closed")m_status=Closed;else
-       if(st=="ok")m_status=CheckOk;else
-       if(st=="saleonly")m_status=CheckSaleOnly;else
-       if(st=="orderonly")m_status=CheckOrderOnly;else
-       if(st=="fail")m_status=CheckFail;
-       else m_status=Invalid;
-       //complete stuff
-       if(e.hasAttribute("seller"))m_complete=true;
-       m_otime=e.attribute("ordertime","0").toInt();
-       m_stime=e.attribute("senttime","0").toInt();
-       m_seller=e.attribute("seller");
-       QDomNodeList nl=e.elementsByTagName("DeliveryAddress");
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               m_deladdress=el.text();
-       }
-       nl=e.elementsByTagName("Comment");
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               m_comment=el.text();
-       }
-       nl=e.elementsByTagName("Ticket");
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               MTicket tick(req,el);
-               if(tick.isValid()){
-                       tick.setOrderID(m_orderid);
-                       m_tickets.append(tick);
-               }
-       }
-       nl=e.elementsByTagName("Voucher");
-       for(int i=0;i<nl.size();i++){
-               QDomElement el=nl.at(i).toElement();
-               if(el.isNull())continue;
-               MVoucher vou(req,el);
-               if(vou.isValid()){
-                       vou.setOrderID(m_orderid);
-                       m_vouchers.append(vou);
-               }
-       }
-       nl=e.elementsByTagName("Shipping");
-       if(nl.size()<1)m_shipping=MShipping();
-       else m_shipping=MShipping(req,nl.at(0).toElement());
+       return state()!=Placed;
 }
 
-void MOrder::makeComplete()
-{
-       //already complete?
-       if(m_complete)return;
-       //sanity check: it does not make sense to check invalid or checked orders
-       if(m_status&Mask != MaskIsStored)return;
-       if(m_orderid<0)return;
-       if(!req)return;
-       //go to database
-       getFromDB(m_orderid);
-}
 
 void MOrder::pruneInvalid()
-{
+{/*TODO
        //tickets
        QList<MTicket>ntc;
        for(int i=0;i<m_tickets.size();i++)
@@ -331,232 +150,76 @@ void MOrder::pruneInvalid()
                        nvc.append(m_vouchers[i]);
        m_vouchers=nvc;
        //shipping info?
-       if(m_shipping.id()<0)m_shipping=MShipping();
-}
-
-/**************
- * below this line we need to make sure the order is completed before we return results
- */
-
-QDateTime MOrder::orderDateTime()
-{
-       makeComplete();
-       return QDateTime::fromTime_t(m_otime);
+       if(m_shipping.id()<0)m_shipping=MShipping();*/
 }
 
 QString MOrder::orderDateTimeStr()
 {
-       makeComplete();
-       if(m_otime==0)return "";
-       return QDateTime::fromTime_t(m_otime).toString(QCoreApplication::translate("MOrder","yyyy-MM-dd hh:mm ap","date/time format"));
+       if(ordertime()==0)return "";
+       return QDateTime::fromTime_t(ordertime()).toString(QCoreApplication::translate("MOrder","yyyy-MM-dd hh:mm ap","date/time format"));
 }
 
 QDate MOrder::orderDate()
 {
-       makeComplete();
-       return QDateTime::fromTime_t(m_otime).date();
+       return QDateTime::fromTime_t(ordertime()).date();
 }
 
 QString MOrder::orderDateStr()
 {
-       makeComplete();
-       if(m_otime==0)return "";
-       return QDateTime::fromTime_t(m_otime).toString(QCoreApplication::translate("MOrder","yyyy-MM-dd","date format"));
+       if(ordertime()==0)return "";
+       return QDateTime::fromTime_t(ordertime()).toString(QCoreApplication::translate("MOrder","yyyy-MM-dd","date format"));
 }
 
 QDateTime MOrder::sentDateTime()
 {
-       makeComplete();
-       return QDateTime::fromTime_t(m_stime);
+       return QDateTime::fromTime_t(senttime());
 }
 
 QString MOrder::sentDateTimeStr()
 {
-       makeComplete();
-       if(m_stime==0)return "";
-       return QDateTime::fromTime_t(m_stime).toString(QCoreApplication::translate("MOrder","yyyy-MM-dd hh:mm ap","date/time format"));
+       if(senttime()==0)return "";
+       return QDateTime::fromTime_t(senttime()).toString(QCoreApplication::translate("MOrder","yyyy-MM-dd hh:mm ap","date/time format"));
 }
 
 QDate MOrder::sentDate()
 {
-       makeComplete();
-       return QDateTime::fromTime_t(m_stime).date();
+       return QDateTime::fromTime_t(senttime()).date();
 }
 
 QString MOrder::sentDateStr()
 {
-       makeComplete();
-       if(m_stime==0)return "";
-       return QDateTime::fromTime_t(m_stime).toString(QCoreApplication::translate("MOrder","yyyy-MM-dd","date format"));
-}
-
-QString MOrder::seller()
-{
-       makeComplete();
-       return m_seller;
-}
-
-QString MOrder::deliveryAddress()
-{
-       makeComplete();
-       return m_deladdress;
-}
-
-QString MOrder::comment()
-{
-       makeComplete();
-       return m_comment;
-}
-
-QList<MTicket> MOrder::tickets()
-{
-       makeComplete();
-       return m_tickets;
-}
-
-void MOrder::setAmountPaid(int p)
-{
-       m_paid=p;
-}
-
-void MOrder::updateTicketPrice(QString tid,int price)
-{
-       for(int i=0;i<m_tickets.size();i++){
-               if(m_tickets[i].ticketID()==tid){
-                       int op=m_tickets[i].amountToPay();
-                       m_tickets[i].updatePrice(price);
-                       int np=m_tickets[i].amountToPay();
-                       m_price+=np-op;
-               }
-       }
-}
-
-QString MOrder::ticketReturn(QString tid)
-{
-       for(int i=0;i<m_tickets.size();i++){
-               if(m_tickets[i].ticketID()==tid){
-                       int op=m_tickets[i].amountToPay();
-                       QString r=m_tickets[i].ticketReturn();
-                       int np=m_tickets[i].amountToPay();
-                       m_price+=np-op;
-                       return r;
-               }
-       }
-       return QT_TRANSLATE_NOOP("MOrder","This ticket is not part of this order.");
-}
-
-QList<MVoucher> MOrder::vouchers(){return m_vouchers;}
-
-MShipping MOrder::shipping(){return m_shipping;}
-
-QString MOrder::sendShipping(MShipping s)
-{
-       if(!req)return QCoreApplication::translate("MOrder","Cannot query DB, don't know it.");
-       //construct XML
-       QDomDocument doc;
-       QDomElement el=doc.createElement("OrderChangeShipping");
-       el.setAttribute("orderid",m_orderid);
-       if(s.isValid()){
-               el.setAttribute("type",s.id());
-               el.setAttribute("price",s.price());
-       }
-       doc.appendChild(el);
-       //send
-       if(!req->request("orderchangeshipping",doc.toByteArray()))
-               return QCoreApplication::translate("MOrder","Cannot update shipping: error while sending.");
-       if(req->responseStatus()!=MWebRequest::Ok)
-               return QCoreApplication::translate("php::",req->responseBody());
-       QDomDocument rsp;
-       rsp.setContent(req->responseBody().trimmed());
-       parseXml(rsp.documentElement());
-       return "";
-}
-
-QString MOrder::voucherReturn(QString tid)
-{
-       for(int i=0;i<m_vouchers.size();i++){
-               if(m_vouchers[i].voucherID()==tid){
-                       int op=m_vouchers[i].price();
-                       QString r=m_vouchers[i].voucherReturn();
-                       int np=m_vouchers[i].price();
-                       m_price+=np-op;
-                       return r;
-               }
-       }
-       return QT_TRANSLATE_NOOP("MOrder","This voucher is not part of this order.");
+       if(senttime()==0)return "";
+       return QDateTime::fromTime_t(senttime()).toString(QCoreApplication::translate("MOrder","yyyy-MM-dd","date format"));
 }
 
-MOrder MOrder::createOrder(QString type)
-{
-       ///////////////
-       //create order xml
-       QDomDocument doc;
-       QDomElement root=doc.createElement("Order");
-       root.setAttribute("customer",m_customer);
-       //is there a delivery address
-       if(m_deladdress!=""){
-               QDomElement da=doc.createElement("DeliveryAddress");
-               da.appendChild(doc.createTextNode(m_deladdress));
-               root.appendChild(da);
-       }
-       //is there a comment?
-       if(m_comment!=""){
-               QDomElement cc=doc.createElement("Comment");
-               cc.appendChild(doc.createTextNode(m_comment));
-               root.appendChild(cc);
-       }
-       //scan tickets
-       for(int i=0;i<m_tickets.size();i++){
-               m_tickets[i].xmlForOrder(doc,root);
-       }
-       //scan vouchers
-       for(int i=0;i<m_vouchers.size();i++){
-               m_vouchers[i].xmlForOrder(doc,root);
-       }
-       //shipping
-       if(m_shipping.isValid()){
-               QDomElement si=doc.createElement("Shipping");
-               si.setAttribute("price",m_shipping.price());
-               si.setAttribute("type",m_shipping.id());
-               root.appendChild(si);
-       }
-       //finalize
-       doc.appendChild(root);
-       //send
-       if(req->request(type,doc.toByteArray())==false){
-               QMessageBox::warning(0,QCoreApplication::translate("MOrder","Error"),QCoreApplication::translate("MOrder","The request failed."));
-               return MOrder();
-       }
-       if(req->responseStatus()!=MWebRequest::Ok){
-               QMessageBox::warning(0,QCoreApplication::translate("MOrder","Error"),QCoreApplication::translate("MOrder","A problem occurred during the order: %1").arg(QCoreApplication::translate("MOrder",req->responseBody())));
-               return MOrder();
-       }
-       //parse result
-       QDomDocument rdoc;
-       rdoc.setContent(req->responseBody());
-       return MOrder(req,rdoc.documentElement());
+MOrder MOrder::createOrder()
+{/*TODO */
+       return MOrder();
 }
 
 MOrder MOrder::createSale()
-{
-       return createOrder("createsale");
+{//TODO
+       //return createOrder("createsale");
+       return MOrder();
 }
 
 MOrder MOrder::createReservation()
-{
-       return createOrder("createreservedorder");
+{//TODO
+       //return createOrder("createreservedorder");
+       return MOrder();
 }
 
 bool MOrder::cancelOrder()
-{
+{/*TODO
        if(!req->request("cancelorder",QByteArray::number(m_orderid)))return false;
        bool r=req->responseStatus()==MWebRequest::Ok;
        if(r)m_status=Cancelled;
-       return r;
+       return r;*/
+       return false;
 }
 
 bool MOrder::shipOrder(QDateTime tm)
-{
+{/*TODO
        QByteArray rq=QByteArray::number(m_orderid);
        if(req->hasRole("_explicitshipdate")){
                rq+="\n";
@@ -568,11 +231,12 @@ bool MOrder::shipOrder(QDateTime tm)
                m_status=Sent;
                m_stime=req->responseBody().trimmed().toInt();
        }
-       return r;
+       return r;*/
+       return false;
 }
 
 bool MOrder::sendComment(QString nc)
-{
+{/*TODO
        //make sure we are in a sane state
        makeComplete();
        if(!req || m_orderid<0)return false;
@@ -588,11 +252,12 @@ bool MOrder::sendComment(QString nc)
                m_comment=nc;
                return true;
        }else
-               return false;
+               return false;*/
+       return false;
 }
 
 bool MOrder::reservationToOrder(QString cmd)
-{
+{/*TODO
        //make sure we are in a sane state
        makeComplete();
        if(!req || m_orderid<0)return false;
@@ -602,16 +267,18 @@ bool MOrder::reservationToOrder(QString cmd)
                m_status=Placed;
                return true;
        }else
-               return false;
+               return false;*/
+       return false;
 }
 
 bool MOrder::reservationToSale()
-{
+{/*TODO
        if(reservationToOrder("reservationtosale")){
                m_status=Sent;
                m_paid=m_price;
                return true;
-       }else return false;
+       }else return false;*/
+       return false;
 }
 
 /******************************************************************************
@@ -620,163 +287,68 @@ bool MOrder::reservationToSale()
 
 MTicket::MTicket()
 {
-       req=0;
-       m_eventid=m_orderid=-1;
-       m_price=0;
-       m_status=Invalid;
        m_paystate=PSUnknown;
 }
 
-MTicket::MTicket(MWebRequest*r,QString t)
+MTicket::MTicket(QString t)
 {
-       req=r;
-       m_eventid=m_orderid=-1;
-       m_price=0;
-       m_status=Invalid;
        m_paystate=PSUnknown;
-       if(!req->request("getticket",t.toAscii()))return;
-       if(req->responseStatus()!=MWebRequest::Ok)return;
-       QDomDocument doc;
-       if(!doc.setContent(req->responseBody()))return;
-       scanXml(doc.documentElement());
+       MTGetTicket gt=req->queryGetTicket(t);
+       if(gt.stage()==gt.Success){
+               MOTicket::operator=(gt.getticket().value());
+       }
 }
 
-MTicket::MTicket(MWebRequest*r,const QDomElement&e)
+MTicket::MTicket(const MTicket&t)
+       :MOTicket(t)
 {
-       req=r;
-       m_paystate=PSUnknown;
-       scanXml(e);
-}
-
-void MTicket::scanXml(const QDomElement&e)
-{
-       m_eventid=e.attribute("event","-1").toInt();
-       m_orderid=e.attribute("order","-1").toInt();
-       m_id=e.attribute("id");
-       m_price=e.attribute("price","0").toInt();
-       QString st=e.attribute("status");
-       if(st=="bought")m_status=Bought;else
-       if(st=="refund")m_status=Refund;else
-       if(st=="used")m_status=Used;else
-       if(st=="reserved")m_status=Reserved;else
-       if(st=="ok")m_status=CheckOk;else
-       if(st=="saleonly")m_status=CheckSaleOnly;else
-       if(st=="orderonly")m_status=CheckOrderOnly;else
-       if(st=="toolate")m_status=CheckFailTooLate;else
-       if(st=="exhausted")m_status=CheckFailExhausted;else
-       if(st=="cancelled")m_status=CheckFailCancelled;else
-       if(st=="invalid")m_status=CheckFailEventInvalid;
-       else m_status=Invalid;
-       st=e.attribute("orderpaystate");
-       if(st=="none")m_paystate=PSNone;else
-       if(st=="cancelled")m_paystate=PSCancelled;else
-       if(st=="ok")m_paystate=PSOk;else
-       if(st=="needpayment")m_paystate=PSNeedPayment;else
-       if(st=="needrefund")m_paystate=PSNeedRefund;
-       else m_paystate=PSUnknown;
-}
-
-void MTicket::xmlForOrder(QDomDocument&doc,QDomElement&root)
-{
-       QDomElement tc=doc.createElement("Ticket");
-       tc.setAttribute("event",m_eventid);
-       tc.setAttribute("price",m_price);
-       root.appendChild(tc);
+       m_paystate=t.m_paystate;
 }
 
-MTicket::MTicket(const MTicket&t)
+MTicket::MTicket(const MOTicket&t)
+       :MOTicket(t)
 {
-       operator=(t);
+       m_paystate=PSUnknown;
 }
 
 MTicket& MTicket::operator=(const MTicket&t)
 {
-       req=t.req;
-       m_eventid=t.m_eventid;
-       m_orderid=t.m_orderid;
-       m_price=t.m_price;
-       m_status=t.m_status;
-       m_id=t.m_id;
+       MOTicket::operator=(t);
        m_paystate=t.m_paystate;
        return *this;
 }
 
 bool MTicket::isValid()const
 {
-       return m_status!=Invalid;
-}
-
-QString MTicket::ticketID()const
-{
-       return m_id;
-}
-
-qint32 MTicket::orderID()const
-{
-       return m_orderid;
-}
-
-int MTicket::price()const
-{
-       return m_price;
+       //TODO: redo this method
+       return true;
 }
 
 QString MTicket::priceString(int off)const
 {
-       int mp=m_price+off;
-       return QString::number(mp/100)+QCoreApplication::translate("MTicket",".","decimal dot")+QString().sprintf("%02d",mp%100);
-}
-
-qint32 MTicket::eventID()const
-{
-       return m_eventid;
+       qint64 mp=price()+off;
+       return QString::number(mp/100)+QCoreApplication::translate("MTicket",".","decimal dot")+QString().sprintf("%02Ld",mp%100);
 }
 
 MEvent MTicket::event()const
 {
-       if(m_status==Invalid)return MEvent();
-       if(m_eventid<0)return MEvent();
-       if(!m_event.isValid())
-               m_event=MEvent(req,m_eventid);
+       if(!isValid())return MEvent();
+       if(eventid()<0)return MEvent();
+       //TODO: reconsider if
+       //if(!m_event.isValid())
+               m_event=req->queryGetEvent(eventid()).getevent().value();
        return m_event;
 }
 
-MTicket::TicketStatus MTicket::status()const
-{
-       return m_status;
-}
-
-bool MTicket::isStored()const
-{
-       return (m_status&Mask)==MaskIsStored;
-}
-
-bool MTicket::isCheck()const
-{
-       return (m_status&Mask)==MaskIsChecked;
-}
-
 QString MTicket::statusString()const
 {
-       switch(m_status){
-               case Bought:return QCoreApplication::translate("MTicket","bought","ticket state");
-               case Refund:return QCoreApplication::translate("MTicket","to refund","ticket state");
-               case Used:return QCoreApplication::translate("MTicket","used","ticket state");
-               case Reserved:return QCoreApplication::translate("MTicket","reserved","ticket state");
-               case CheckOk:return QCoreApplication::translate("MTicket","ok","ticket state");
-               case CheckSaleOnly:return QCoreApplication::translate("MTicket","sale only","ticket state");
-               case CheckOrderOnly:return QCoreApplication::translate("MTicket","order only","ticket state");
-               case CheckFailTooLate:return QCoreApplication::translate("MTicket","too late: event over","ticket state");
-               case CheckFailExhausted:return QCoreApplication::translate("MTicket","no more tickets","ticket state");
-               case CheckFailCancelled:return QCoreApplication::translate("MTicket","event cancelled","ticket state");
-               case CheckFailEventInvalid:return QCoreApplication::translate("MTicket","no such event","ticket state");
-               default:return QCoreApplication::translate("MTicket","invalid","ticket state");
-       }
+       return TicketState2str(status());
 }
 
 
 MTicket::PaymentStatus MTicket::paymentStatus()
 {
+       /*TODO
        if(m_paystate!=PSUnknown)return m_paystate;
        if(!isValid())return PSUnknown;
        if(!req->request("getticket",m_id.toAscii()))return PSUnknown;
@@ -784,56 +356,54 @@ MTicket::PaymentStatus MTicket::paymentStatus()
        QDomDocument doc;
        if(!doc.setContent(req->responseBody()))return PSUnknown;
        scanXml(doc.documentElement());
+       */
        return m_paystate;
 }
 
 QString MTicket::markUsed()
-{
+{/*TODO
        if(!req->request("useticket",m_id.toAscii()))return QCoreApplication::translate("MTicket","Cannot execute request.");
        if(req->responseStatus()==MWebRequest::Ok)return "";
-       return QCoreApplication::translate("MTicket",req->responseBody().data());
-}
-
-void MTicket::setOrderID(qint32 o)
-{
-       m_orderid=o;
+       return QCoreApplication::translate("MTicket",req->responseBody().data());*/
+       return "";
 }
 
 void MTicket::updatePrice(int p)
 {
-       if(p<0 || p==m_price)return;
+       if(p<0 || p==price())return;
        //it only makes sense to contact the DB if it can be found there
+       /*TODO
        if(isStored()){
                if(req==0)return;
                //send request
                QByteArray rq=m_id.toAscii()+"\n"+QByteArray::number(p);
                if(!req->request("changeticketprice",rq))return;
                if(req->responseStatus()!=MWebRequest::Ok)return;
-       }
+       }*/
        //update locally
-       m_price=p;
+       setprice(p);
 }
 
 QString MTicket::ticketReturn()
-{
+{/*TODO
        if(!isStored())return QT_TRANSLATE_NOOP("MTicket","Ticket is not stored, can't return it.");
        if(!req->request("ticketreturn",m_id.toUtf8()))
                return QT_TRANSLATE_NOOP("MTicket","Failed to execute request");
        if(req->responseStatus()!=MWebRequest::Ok)
                return QString::fromUtf8(req->responseBody());
-       m_status=Refund;
+       m_status=Refund;*/
        return "";
 }
 
-int MTicket::amountToPay()const
+/*int MTicket::amountToPay()const
 {
-       if(m_status==Bought || m_status==Used)return m_price;
+       if(status()==Bought || status()==Used)return price();
        else return 0;
-}
+}*/
 
 bool MTicket::isToBePaid()const
 {
-       if(m_status==Bought || m_status==Used)return true;
+       if(status()==Bought || status()==Used)return true;
        else return false;
 }
 
@@ -842,107 +412,34 @@ bool MTicket::isToBePaid()const
  * Voucher
  ******************************************************************************/
 
-MVoucher::MVoucher()
-{
-       req=0;
-       m_price=m_value=0;
-       m_orderid=-1;
-       isused=false;
-}
-
-MVoucher::MVoucher(MWebRequest*r,const QDomElement&e)
-{
-       req=r;
-       parseXml(e);
-}
-
-MVoucher::MVoucher(MWebRequest*r,QString v)
-{
-       req=0;
-       m_price=m_value=0;
-       m_orderid=-1;
-       isused=false;
-       if(!r->request("getvoucher",v.toUtf8()))return;
-       if(r->responseStatus()!=MWebRequest::Ok)return;
-       QDomDocument doc;
-       if(!doc.setContent(r->responseBody().trimmed()))return;
-       parseXml(doc.documentElement());
-       req=r;
-}
-
-void MVoucher::parseXml(const QDomElement&e)
-{
-       m_id=e.attribute("id");
-       m_price=e.attribute("price","0").toInt();
-       m_value=e.attribute("value","0").toInt();
-       isused=e.attribute("used","0").toInt()!=0;
-       xmlstate=e.text().trimmed();
-       m_orderid=-1;
-}
-
-MVoucher::MVoucher(const MVoucher&v)
-{
-       operator=(v);
-}
-
-MVoucher& MVoucher::operator=(const MVoucher&v)
+MVoucher::MVoucher(QString v)
 {
-       req=v.req;
-       m_id=v.m_id;
-       m_price=v.m_price;
-       m_value=v.m_value;
-       isused=v.isused;
-       m_orderid=v.m_orderid;
-       xmlstate=v.xmlstate;
-       return *this;
+       MTGetVoucher gv=req->queryGetVoucher(v);
+       if(gv.stage()==gv.Success)
+               operator=(gv.getvoucher().value());
 }
 
-QString MVoucher::voucherID()const{return m_id;}
-
-int MVoucher::price()const{return m_price;}
-QString MVoucher::priceString(int off)const{return cent2str(m_price+off);}
-int MVoucher::value()const{return m_value;}
-QString MVoucher::valueString(int off)const{return cent2str(m_value+off);}
-
-bool MVoucher::isValid()const{return req!=0 && m_id!="";}
-
-bool MVoucher::isUsed()const{return isused;}
+QString MVoucher::priceString(int off)const{return cent2str(price()+off);}
+QString MVoucher::valueString(int off)const{return cent2str(value()+off);}
 
-bool MVoucher::isCancelled()const{return m_price==0 && m_value==0;}
+bool MVoucher::isValid()const{return voucherid().value()!="";}
 
-bool MVoucher::isEmpty()const{return m_value==0;}
+bool MVoucher::isCancelled()const{return price()==0 && value()==0;}
 
-QString MVoucher::xmlState()const{return xmlstate;}
+bool MVoucher::isEmpty()const{return value()==0;}
 
 QString MVoucher::statusString()const
 {
-       if(!req)return QCoreApplication::translate("MVoucher","invalid");
-       if(xmlstate!="")return QCoreApplication::translate("php::",xmlstate.toAscii());
-       if(isCancelled())return QCoreApplication::translate("MVoucher","cancelled");
-       if(isEmpty())return QCoreApplication::translate("MVoucher","empty");
-       if(isUsed())return QCoreApplication::translate("MVoucher","used");
-       else return QCoreApplication::translate("MVoucher","unused");
-}
-
-void MVoucher::setOrderID(int o){m_orderid=o;}
-
-int MVoucher::orderID()const{return m_orderid;}
-
-void MVoucher::xmlForOrder(QDomDocument&doc,QDomElement&root)
-{
-       QDomElement vx=doc.createElement("Voucher");
-       vx.setAttribute("value",m_value);
-       vx.setAttribute("price",m_price);
-       root.appendChild(vx);
+       return VoucherState2str(status());
 }
 
 QString MVoucher::voucherReturn()
-{
+{/*TODO
        if(!req)return QT_TRANSLATE_NOOP("MVoucher","Voucher is not stored, can't return it.");
        if(!req->request("cancelvoucher",m_id.toUtf8()))
                return QT_TRANSLATE_NOOP("MVoucher","Failed to execute request");
        if(req->responseStatus()!=MWebRequest::Ok)
                return QString::fromUtf8(req->responseBody());
-       m_value=m_price=0;
+       m_value=m_price=0;*/
        return "";
 }
index 170de63..610ac84 100644 (file)
 #include "event.h"
 #include "shipping.h"
 
+#include "MOTicket.h"
+#include "MOVoucher.h"
+#include "MOOrder.h"
+
 class MWebRequest;
 class QDomDocument;
 class QDomElement;
 
 /**this class represents a single ticket*/
-class MTicket
+class MTicket:public MOTicket
 {
        public:
                /**creates an invalid ticket*/
                MTicket();
                /**gets the ticket from the database*/
-               MTicket(MWebRequest*,QString);
-               /**creates a ticket from XML*/
-               MTicket(MWebRequest*,const QDomElement&);
+               MTicket(QString);
                /**copies a ticket*/
                MTicket(const MTicket&);
+               MTicket(const MOTicket&);
                
                /**copies the ticket*/
                MTicket& operator=(const MTicket&);
@@ -44,73 +47,15 @@ class MTicket
                /**returns whether the ticket is valid*/
                bool isValid()const;
                
-               /**returns the ID of the ticket*/
-               QString ticketID()const;
-               
-               /**returns the ID of the order this ticket belongs to (-1 if it is invalid or does not belong to an order)*/
-               qint32 orderID()const;
-               
-               /**returns the price of the ticket (in cent)*/
-               int price()const;
-               
                /**returns the price of the ticket as localized string*/
                QString priceString(int offsetvalue=0)const;
                
-               /**returns the amount that is to be paid for this ticket; this is identical to the price if the ticket is bought or used, it is zero otherwise*/
-               int amountToPay()const;
-               
                /**returns whether the ticket is to be paid (ie. it is bought or already used)*/
                bool isToBePaid()const;
                
-               /**returns the ID of the event the ticket belongs to*/
-               qint32 eventID()const;
-               
                /**returns the event for this ticket (queries DB once)*/
                MEvent event()const;
                
-               /**represents the status of a ticket*/
-               enum TicketStatus{
-                       /**the ticket object is invalid*/
-                       Invalid=0,
-                       /**Mask to find out whether the ticket is stored or has a check status*/
-                       Mask=0xf0,
-                       /**Flag: the ticket is stored in the DB (status&Mask==MaskIsStored)*/
-                       MaskIsStored=0x10,
-                       /**the ticket has been bought, but not yet used*/
-                       Bought=0x10,
-                       /**the ticket has been refunded or needs refund (eg. after the event was cancelled)*/
-                       Refund=0x11,
-                       /**the ticket has been used*/
-                       Used=0x12,
-                       /**the ticket has been reserved by a seller*/
-                       Reserved=0x13,
-                       /**Flag: the ticket has been checked only (status&Mask==MaskIsChecked)*/
-                       MaskIsChecked=0x20,
-                       /**check status: the ticket can be ordered*/
-                       CheckOk=0x20,
-                       /**check status: the ticket can only be sold, not ordered for later delivery*/
-                       CheckSaleOnly=0x21,
-                       /**check status: this ticket can be ordered for later delivery, but not sold*/
-                       CheckOrderOnly=0x22,
-                       /**check status: the ticket order fails, because order times are over*/
-                       CheckFailTooLate=0x23,
-                       /**check status: the ticket order fails, because there are not enough tickets left*/
-                       CheckFailExhausted=0x24,
-                       /**check status: the ticket order fails, because the event was cancelled*/
-                       CheckFailCancelled=0x25,
-                       /**check status: the ticket order fails, because the event does not exist*/
-                       CheckFailEventInvalid=0x26
-               };
-               
-               /**returns the status of the ticket*/
-               TicketStatus status()const;
-               
-               /**returns whether this order is stored in the DB*/
-               bool isStored()const;
-               
-               /**returns whether this order object is the result of a check operation*/
-               bool isCheck()const;
-               
                /**returns the ticket status as string*/
                QString statusString()const;
                
@@ -142,162 +87,68 @@ class MTicket
                /**attempts to return the ticket; returns empty string on success, error message on failure*/
                QString ticketReturn();
                
-       protected:
-               friend class MOrder;
-               /**sets the order-ID of the ticket, used by MOrder*/
-               void setOrderID(qint32);
-               /**used by createOrder to generate XML elements for each ticket*/
-               void xmlForOrder(QDomDocument&,QDomElement&);
-               
        private:
-               MWebRequest*req;
-               qint32 m_eventid,m_orderid,m_price;
-               TicketStatus m_status;
                PaymentStatus m_paystate;
-               QString m_id;
                mutable MEvent m_event;
-               
-               /**helper: scan XML data*/
-               void scanXml(const QDomElement&);
 };
 
 /**this class represents a voucher*/
-class MVoucher
+class MVoucher:public MOVoucher
 {
        public:
                /**create empty/invalid voucher*/
-               MVoucher();
-               /**create voucher from XML*/
-               MVoucher(MWebRequest*,const QDomElement&);
-               /**retrieve voucher from DB*/
-               MVoucher(MWebRequest*,QString);
+               MVoucher(){}
+               MVoucher(QString);
                /**copy voucher*/
-               MVoucher(const MVoucher&);
+               MVoucher(const MVoucher&v):MOVoucher(v){}
+               MVoucher(const MOVoucher&v):MOVoucher(v){}
                
                /**copy voucher*/
-               MVoucher& operator=(const MVoucher&);
+               MVoucher& operator=(const MVoucher&v){MOVoucher::operator=(v);return *this;}
+               MVoucher& operator=(const MOVoucher&v){MOVoucher::operator=(v);return *this;}
                
-               /**returns the ID of the voucher*/
-               QString voucherID()const;
-               
-               /**returns the price in cent of the voucher (what it costs)*/
-               int price()const;
                /**returns the price of the voucher as string*/
                QString priceString(int off=0)const;
-               /**returns the remaining value in cent of the voucher (what it is worth)*/
-               int value()const;
                /**returns the remaining value of the voucher as string*/
                QString valueString(int off=0)const;
                
                /**returns whether this is a valid voucher object*/
                bool isValid()const;
                
-               /**returns whether the voucher has already been used*/
-               bool isUsed()const;
-               
                /**returns whether the voucher is cancelled*/
                bool isCancelled()const;
                
                /**returns whether the voucher is empty, ie. its remaining value is zero*/
                bool isEmpty()const;
                
-               /**for order validation: returns the validation result of the voucher (empty string = ok)*/
-               QString xmlState()const;
-               
                /**returns a status string for the voucher for displaying*/
                QString statusString()const;
                
-               /**Returns the ID of the order this voucher belongs to (only when retrieved with an order)*/
-               int orderID()const;
-               
                /**attempts to return the voucher; returns empty string on success, error message on failure*/
                QString voucherReturn();
-               
-       protected:
-               friend class MOrder;
-               /**sets the order-ID of the ticket, used by MOrder*/
-               void setOrderID(qint32);
-               /**used by createOrder to generate XML elements for each ticket*/
-               void xmlForOrder(QDomDocument&,QDomElement&);
-       
-       private:
-               MWebRequest*req;
-               QString m_id;
-               qint32 m_price,m_value,m_orderid;
-               bool isused;
-               QString xmlstate;
-               
-               //helper: parses XML
-               void parseXml(const QDomElement&);
 };
 
 /**this class represents a complete order*/
-class MOrder
+class MOrder:public MOOrder
 {
        public:
                /**create invalid order*/
-               MOrder();
+               MOrder(){}
                /**create order by id*/
-               MOrder(MWebRequest*,qint32);
-               /**create order from XML element*/
-               MOrder(MWebRequest*,const QDomElement&);
+               MOrder(qint64);
                /**copy order*/
-               MOrder(const MOrder&);
+               MOrder(const MOrder&o):MOOrder(o){}
                
                /**copies the order*/
-               MOrder& operator=(const MOrder&);
-               
-               /**returns the order ID (-1 for invalid orders or after a simple check)*/
-               int orderID()const;
+               MOrder& operator=(const MOrder&o){MOOrder::operator=(o);return *this;}
+               MOrder& operator=(const MOOrder&o){MOOrder::operator=(o);return *this;}
                
                /**returns whether the order is valid (it comes from the DB and it has been understood by the parser)*/
                bool isValid()const;
                
-               /**returns the customer ID*/
-               int customerID()const;
-               
                /**returns a customer object (calls database!)*/
                MCustomer customer()const;
                
-               /**status*/
-               enum OrderStatus{
-                       /**the order is invalid (not a DB state)*/
-                       Invalid=0,
-                       /**mask code to find general status of the order*/
-                       Mask=0xf0,
-                       /**status codes that have this bit (status&Mask==MaskIsStored) set are stored in the DB*/
-                       MaskIsStored=0x10,
-                       /**the order has been placed, nothing is delivered or paid*/
-                       Placed=0x10,
-                       /**the tickets/vouchers have been shipped*/
-                       Sent=0x11,
-                       /**the order was cancelled*/
-                       Cancelled=0x12,
-                       /**the order is closed (currently unused state)*/
-                       Closed=0x13,
-                       /**the order is reserved*/
-                       Reserved=0x14,
-                       /**status codes that have this bit (status&Mask==MaskIsChecked) set are checked only*/
-                       MaskIsChecked=0x20,
-                       /**check status: this order would pass*/
-                       CheckOk=0x20,
-                       /**check status: this order can be sold, but not ordered for later delivery*/
-                       CheckSaleOnly=0x21,
-                       /**check status: this order can be ordered for later delivery, but not sold*/
-                       CheckOrderOnly=0x22,
-                       /**check status: the order fails*/
-                       CheckFail=0x23
-               };
-               
-               /**returns the status of the order*/
-               OrderStatus orderStatus()const;
-               
-               /**returns whether this order is stored in the DB*/
-               bool isStored()const;
-               
-               /**returns whether this order object is the result of a check operation*/
-               bool isCheck()const;
-               
                /**returns whether this order is a reservation*/
                bool isReservation()const;
                
@@ -314,15 +165,9 @@ class MOrder
                QString orderStatusString()const;
                
                /**returns how much money needs to be paid in total for this order, in cents*/
-               int totalPrice()const;
-               
-               /**returns how much money needs to be paid in total for this order, in cents*/
                QString totalPriceString(int offsetvalue=0)const;
                
                /**returns how much money has already been paid for this order, in cents*/
-               int amountPaid()const;
-               
-               /**returns how much money has already been paid for this order, in cents*/
                QString amountPaidString(int offsetvalue=0)const;
                
                /**returns whether there is anything left to pay*/
@@ -346,9 +191,6 @@ class MOrder
                /**returns whether the tickets of this order have already been shipped*/
                bool isSent()const;
                
-               /**returns the order date+time*/
-               QDateTime orderDateTime();
-               
                /**returns the order date+time as string*/
                QString orderDateTimeStr();
                
@@ -370,41 +212,8 @@ class MOrder
                /**returns the shipping date only as string*/
                QString sentDateStr();
                
-               /**returns the seller of this order*/
-               QString seller();
-               
-               /**returns the delivery address (empty string if none is set)*/
-               QString deliveryAddress();
-               
-               /**returns the comment of the order (empty string if none set)*/
-               QString comment();
-               
-               /**returns the list of tickets of this order*/
-               QList<MTicket> tickets();
-               
-               /**used by payment and refund routines: updates the amount paid for this instance*/
-               void setAmountPaid(int);
-               
-               /**used to update the price of a ticket, calls DB*/
-               void updateTicketPrice(QString,int);
-               
-               /**used to cancel/return a ticket from this order; returns empty string on success, error message on failure*/
-               QString ticketReturn(QString);
-               
-               /**used to cancel/return a voucher from this order; returns empty string on success, error message on failure*/
-               QString voucherReturn(QString);
-               
-               /**returns the list of vouchers of this order*/
-               QList<MVoucher> vouchers();
-               
-               /**returns the shipping method of this order*/
-               MShipping shipping();
-               
-               /**sends a new shipping method to the DB and updates the order object; returns empty string on success, error string otherwise*/
-               QString sendShipping(MShipping);
-               
                /**create a new order in the DB; returns it*/
-               MOrder createOrder(QString type="createorder");
+               MOrder createOrder();
                
                /**create a sale in the DB; returns it*/
                MOrder createSale();
@@ -429,25 +238,6 @@ class MOrder
                
                /**if the order is in check state yet: prune invalid objects*/
                void pruneInvalid();
-       
-       private:
-               MWebRequest*req;
-               int m_orderid,m_customer,m_price,m_paid,m_otime,m_stime;
-               OrderStatus m_status;
-               QString m_seller,m_deladdress,m_comment;
-               bool m_complete;
-               QList<MTicket> m_tickets;
-               QList<MVoucher> m_vouchers;
-               MShipping m_shipping;
-               
-               /**internal: requests the order from the database*/
-               void getFromDB(qint32);
-               
-               /**internal: parse XML*/
-               void parseXml(const QDomElement&);
-               
-               /**internal: makes sure the order is completely retrieved*/
-               void makeComplete();
 };
 
 #endif
index 1f7f69e..945b9e5 100644 (file)
@@ -18,7 +18,7 @@
 #include "odtrender.h"
 #include "orderwin.h"
 #include "ticketrender.h"
-#include "webrequest.h"
+#include "msinterface.h"
 
 #include <QApplication>
 #include <QBoxLayout>
 
 #include <math.h>
 
-MOrderWindow::MOrderWindow(QWidget*par,MWebRequest*r,const MOrder&o)
-       :QMainWindow(par),req(r),m_order(o)
+#define req (MSInterface::instance())
+
+MOrderWindow::MOrderWindow(QWidget*par,const MOrder&o)
+       :QMainWindow(par),m_order(o)
 {
        setWindowTitle(tr("Order Details"));
        setAttribute(Qt::WA_DeleteOnClose);
@@ -62,10 +64,11 @@ MOrderWindow::MOrderWindow(QWidget*par,MWebRequest*r,const MOrder&o)
        m->addAction(tr("Ma&ke Reservation..."),this,SLOT(createReservation()))
         ->setEnabled(req->hasRole("createreservedorder")&&o.canReserve());
        m->addAction(tr("&Prune and recheck..."),this,SLOT(recheckOrder()))
-        ->setEnabled(o.orderID()<0);
+        ->setEnabled(o.orderid()<0);
        m->addSeparator();
        m->addAction(tr("C&ancel Order..."),this,SLOT(cancelOrder()))
-        ->setEnabled(req->hasRole("cancelorder")&&o.isStored());
+       //FIXME
+        ->setEnabled(req->hasRole("cancelorder")/*&&o.isStored()*/);
        m->addAction(tr("&Mark Order as Shipped..."),this,SLOT(shipOrder()))
         ->setEnabled(req->hasRole("ordershipped"));
        m->addSeparator();
@@ -86,7 +89,7 @@ MOrderWindow::MOrderWindow(QWidget*par,MWebRequest*r,const MOrder&o)
        m->addAction(tr("&Close"),this,SLOT(close()));
        
        m=mb->addMenu(tr("&Payment"));
-       m->setEnabled(o.isStored());
+       //FIXME: m->setEnabled(o.isStored());
        m->addAction(tr("Receive &Payment..."),this,SLOT(payment()))
         ->setEnabled(req->hasRole("orderpay"));
        m->addAction(tr("&Refund..."),this,SLOT(refund()))
@@ -95,7 +98,7 @@ MOrderWindow::MOrderWindow(QWidget*par,MWebRequest*r,const MOrder&o)
         ->setEnabled(req->hasRole("usevoucher"));
         
        m=mb->addMenu(tr("P&rinting"));
-       m->setEnabled(o.isStored());
+       //FIXME: m->setEnabled(o.isStored());
        m->addAction(tr("Print &Bill..."),this,SLOT(printBill()));
        m->addAction(tr("Save Bill &as file..."),this,SLOT(saveBill()));
        m->addSeparator();
@@ -114,16 +117,16 @@ MOrderWindow::MOrderWindow(QWidget*par,MWebRequest*r,const MOrder&o)
        int rw=0;
        QLabel*lab;
        gl->addWidget(new QLabel(tr("Order ID:")),rw,0);
-       gl->addWidget(m_orderid=new QLabel(QString::number(m_order.orderID())),rw,1);
+       gl->addWidget(m_orderid=new QLabel(QString::number(m_order.orderid())),rw,1);
        gl->addWidget(new QLabel(tr("Order Date:")),++rw,0);
        gl->addWidget(m_orderdate=new QLabel(m_order.orderDateTimeStr()),rw,1);
        gl->addWidget(new QLabel(tr("Shipping Date:")),++rw,0);
        gl->addWidget(m_sentdate=new QLabel(m_order.sentDateTimeStr()),rw,1);
        gl->addWidget(new QLabel(tr("Customer:")),++rw,0);
-       gl->addWidget(new QLabel(m_order.customer().getNameAddress()),rw,1);
+       gl->addWidget(new QLabel(m_order.customer().address()),rw,1);
        gl->addWidget(new QLabel(tr("Delivery Address:")),++rw,0);
-       gl->addWidget(lab=new QLabel(m_order.deliveryAddress()),rw,1);
-       lab->setWordWrap(true);
+       //FIXME:gl->addWidget(lab=new QLabel(m_order.deliveryAddress()),rw,1);
+       //lab->setWordWrap(true);
        gl->addWidget(new QLabel(tr("Sold by:")),++rw,0);
        gl->addWidget(new QLabel(m_order.seller()),rw,1);
        gl->addWidget(new QLabel(tr("Total Price:")),++rw,0);
@@ -133,11 +136,13 @@ MOrderWindow::MOrderWindow(QWidget*par,MWebRequest*r,const MOrder&o)
        gl->addWidget(new QLabel(tr("Order State:")),++rw,0);
        gl->addWidget(m_state=new QLabel(m_order.orderStatusString()),rw,1);
        gl->addWidget(new QLabel(tr("Shipping Method:")),++rw,0);
-       gl->addWidget(m_shipmeth=new QLabel(m_order.shipping().description()),rw,1);
+       //FIXME:
+       gl->addWidget(m_shipmeth=new QLabel(/*m_order.shipping().description()*/"ship?"),rw,1);
        gl->addWidget(new QLabel(tr("Shipping Costs:")),++rw,0);
-       gl->addWidget(m_shipprice=new QLabel(m_order.shipping().priceString()),rw,1);
+       gl->addWidget(m_shipprice=new QLabel(/*m_order.shipping().priceString()*/),rw,1);
        gl->addWidget(new QLabel(tr("Order Comment:")),++rw,0);
-       gl->addWidget(m_comment=lab=new QLabel(m_order.comment()),rw,1);
+       //FIXME:
+       gl->addWidget(m_comment=lab=new QLabel(/*m_order.comment()*/"comment?"),rw,1);
        lab->setWordWrap(true);
        gl->setColumnStretch(0,0);
        gl->setColumnStretch(1,10);
@@ -164,8 +169,8 @@ static const int ITEM_TICKET=1;
 static const int ITEM_VOUCHER=2;
 
 void MOrderWindow::updateTable()
-{
-       QList<MTicket> tickets=m_order.tickets();
+{/*TODO:
+       QList<MOTicket> tickets=m_order.tickets();
        QList<MEvent> events;
        if(tickets.size()>0)
                events=req->getAllEvents();
@@ -195,7 +200,7 @@ void MOrderWindow::updateTable()
                m_model->setData(m_model->index(i+off,3),vouchers[i].statusString());
                m_model->setData(m_model->index(i+off,4),vouchers[i].priceString());
        }
-       m_table->resizeColumnsToContents();
+       m_table->resizeColumnsToContents();*/
 }
 
 void MOrderWindow::setChanged()
@@ -210,10 +215,10 @@ bool MOrderWindow::isChanged()const
 
 void MOrderWindow::itemView()
 {
-       QList<MTicket>tickets=m_order.tickets();
-       QList<MVoucher>vouchers=m_order.vouchers();
+       QList<MOTicket>tickets=m_order.tickets();
+       QList<MOVoucher>vouchers=m_order.vouchers();
        if(tickets.size()<1 && vouchers.size()<1)return;
-       MOrderItemView tv(this,req,tickets,vouchers);
+       MOrderItemView tv(this,tickets,vouchers);
        tv.exec();
 }
 
@@ -229,17 +234,17 @@ void MOrderWindow::printCurrentItem()
        //find ticket/voucher
        if(type==ITEM_TICKET){
                QList<MTicket>ticks;
-               QList<MTicket>tickets=m_order.tickets();
+               QList<MOTicket>tickets=m_order.tickets();
                for(int i=0;i<tickets.size();i++)
-                       if(tickets[i].ticketID()==id && tickets[i].isValid())
+                       if(tickets[i].ticketid().value()==id && MTicket(tickets[i]).isValid())
                                ticks<<tickets[i];
                printTickets(ticks);
        }else
        if(type==ITEM_VOUCHER){
                QList<MVoucher>vouchs;
-               QList<MVoucher>vouchers=m_order.vouchers();
+               QList<MOVoucher>vouchers=m_order.vouchers();
                for(int i=0;i<vouchers.size();i++)
-                       if(vouchers[i].voucherID()==id && vouchers[i].isValid())
+                       if(vouchers[i].voucherid().value()==id && MVoucher(vouchers[i]).isValid())
                                vouchs<<vouchers[i];
                printVouchers(vouchs);
        }
@@ -248,16 +253,18 @@ void MOrderWindow::printCurrentItem()
 
 void MOrderWindow::printTickets()
 {
-       printTickets(m_order.tickets());
+       //FIXME:
+       //printTickets(m_order.tickets());
 }
 
 void MOrderWindow::printVouchers()
 {
-       printVouchers(m_order.vouchers());
+       //FIXME
+       //printVouchers(m_order.vouchers());
 }
 
 void MOrderWindow::printTickets(QList<MTicket> ticketsin)
-{
+{/*TODO
        //reduce ticket list to usable ones
        QList<MTicket> tickets;
        for(int i=0;i<ticketsin.size();i++){
@@ -294,11 +301,11 @@ void MOrderWindow::printTickets(QList<MTicket> ticketsin)
                        printer.newPage();
                }
                render.render(tickets[i],printer,&painter,p);
-       }
+       }*/
 }
 
 void MOrderWindow::printVouchers(QList<MVoucher> vouchersin)
-{
+{/*TODO
        //reduce voucher list to usable ones
        QList<MVoucher>vouchers;
        for(int i=0;i<vouchersin.size();i++){
@@ -335,7 +342,7 @@ void MOrderWindow::printVouchers(QList<MVoucher> vouchersin)
                        printer.newPage();
                }
                render.render(vouchers[i],printer,&painter,p);
-       }
+       }*/
 }
 
 void MOrderWindow::restorePrinter(QPrinter&prn,QString key)
@@ -382,7 +389,7 @@ void MOrderWindow::storePrinter(QPrinter&prn,QString key)
 }
 
 void MOrderWindow::printBill()
-{
+{/*TODO
        //get template
        MTemplate tf=req->getTemplate("bill");
        if(!tf.isValid()){
@@ -403,11 +410,11 @@ void MOrderWindow::printBill()
        connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&)));
        connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)));
        rend.renderToPrinter();
-       donePrintBuffer();
+       donePrintBuffer();*/
 }
 
 void MOrderWindow::saveBill()
-{
+{/*TODO
        //get template
        MTemplate tf=req->getTemplate("bill");
        if(!tf.isValid()){
@@ -441,11 +448,11 @@ void MOrderWindow::saveBill()
        connect(&rend,SIGNAL(getLoopIterations(QString,int&)),this,SLOT(getLoopIterations(QString,int&)));
        connect(&rend,SIGNAL(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)),this,SLOT(getLoopVariable(QString,int,QString,MOdtRenderer::VarType&,QVariant&)));
        rend.renderToFile(fname);
-       donePrintBuffer();
+       donePrintBuffer();*/
 }
 
 void MOrderWindow::getVariable(QString vn,MOdtRenderer::VarType& av,QVariant&value)
-{
+{/*TODO
        if(vn=="ORDERDATE"){
                value=m_order.orderDateTime().toTime_t();
                av=MOdtRenderer::DateVar;
@@ -511,7 +518,7 @@ void MOrderWindow::getVariable(QString vn,MOdtRenderer::VarType& av,QVariant&val
        if(vn=="SHIPPINGPRICE"){
                value=m_order.shipping().price();
                av=MOdtRenderer::MoneyVar;
-       }
+       }*/
 }
 
 void MOrderWindow::getLoopIterations(QString loopname,int&iterations)
@@ -528,52 +535,52 @@ void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,MOdtRender
                if(it<0 || it>=tickets.size())return;
                
                if(vn=="PRICE"){
-                       value=tickets[it].price();
+                       value=tickets[it].price().value();
                        av=MOdtRenderer::MoneyVar;
                }else
-               if(vn=="ID")value=tickets[it].ticketID();else
-               if(vn=="TITLE")value=tickets[it].event().title();else
-               if(vn=="ARTIST")value=tickets[it].event().artist();else
+               if(vn=="ID")value=tickets[it].ticketid().value();else
+               if(vn=="TITLE")value=tickets[it].event().title().value();else
+               if(vn=="ARTIST")value=tickets[it].event().artist().value();else
                if(vn=="DATE"){
-                       value=tickets[it].event().startTime();
+                       value=tickets[it].event().start().value();
                        av=MOdtRenderer::DateVar;
                }else
                if(vn=="STARTTIME"){
-                       value=tickets[it].event().startTime();
+                       value=tickets[it].event().start().value();
                        av=MOdtRenderer::DateTimeVar;
                }else
                if(vn=="ENDTIME"){
-                       value=tickets[it].event().endTime();
+                       value=tickets[it].event().end().value();
                        av=MOdtRenderer::DateTimeVar;
                }else
-               if(vn=="ROOM")value=tickets[it].event().room();
+               if(vn=="ROOM")value=tickets[it].event().room().value();
        }else if(loopname=="ACCTICKETS"){
                QList<TickInfo> &tickets=printBuffer.tickinfo;
                if(it<0 || it>=tickets.size())return;
                
                if(vn=="PRICE"){
-                       value=tickets[it].proto.price();
+                       value=tickets[it].proto.price().value();
                        av=MOdtRenderer::MoneyVar;
                }else
                if(vn=="FULLPRICE"){
-                       value=tickets[it].proto.price()*tickets[it].amount;
+                       value=tickets[it].proto.price().value()*tickets[it].amount;
                        av=MOdtRenderer::MoneyVar;
                }else
-               if(vn=="TITLE")value=tickets[it].proto.event().title();else
-               if(vn=="ARTIST")value=tickets[it].proto.event().artist();else
+               if(vn=="TITLE")value=tickets[it].proto.event().title().value();else
+               if(vn=="ARTIST")value=tickets[it].proto.event().artist().value();else
                if(vn=="DATE"){
-                       value=tickets[it].proto.event().startTime();
+                       value=tickets[it].proto.event().start().value();
                        av=MOdtRenderer::DateVar;
                }else
                if(vn=="STARTTIME"){
-                       value=tickets[it].proto.event().startTime();
+                       value=tickets[it].proto.event().start().value();
                        av=MOdtRenderer::DateTimeVar;
                }else
                if(vn=="ENDTIME"){
-                       value=tickets[it].proto.event().endTime();
+                       value=tickets[it].proto.event().end().value();
                        av=MOdtRenderer::DateTimeVar;
                }else
-               if(vn=="ROOM")value=tickets[it].proto.event().room();else
+               if(vn=="ROOM")value=tickets[it].proto.event().room().value();else
                if(vn=="AMOUNT"){
                        value=tickets[it].amount;
                        av=MOdtRenderer::IntVar;
@@ -582,14 +589,14 @@ void MOrderWindow::getLoopVariable(QString loopname,int it,QString vn,MOdtRender
                if(it<0 || it>=printBuffer.vouchers.size())return;
                
                if(vn=="PRICE"){
-                       value=printBuffer.vouchers[it].price();
+                       value=printBuffer.vouchers[it].price().value();
                        av=MOdtRenderer::MoneyVar;
                }else
                if(vn=="VALUE"){
-                       value=printBuffer.vouchers[it].value();
+                       value=printBuffer.vouchers[it].value().value();
                        av=MOdtRenderer::MoneyVar;
                }else
-               if(vn=="ID")value=printBuffer.vouchers[it].voucherID();
+               if(vn=="ID")value=printBuffer.vouchers[it].voucherid().value();
        }else if(loopname=="ADDRESSLINES"){
                QStringList lst=m_order.customer().address().split("\n");
                if(it<0 || it>=lst.size())return;
@@ -607,13 +614,13 @@ void MOrderWindow::donePrintBuffer()
 
 static inline bool compare(const MTicket&a,const MTicket&b)
 {
-       if(a.eventID()!=b.eventID())return false;
+       if(a.eventid()!=b.eventid())return false;
        if(a.price()!=b.price())return false;
        return true;
 }
 
 void MOrderWindow::initPrintBuffer()
-{
+{/*TODO:
        //clear
        donePrintBuffer();
        //get tickets (only valid ones)
@@ -638,11 +645,11 @@ void MOrderWindow::initPrintBuffer()
        QList<MVoucher>vlst=m_order.vouchers();
        for(int i=0;i<vlst.size();i++)
                if(!vlst[i].isCancelled())
-                       printBuffer.vouchers.append(vlst[i]);
+                       printBuffer.vouchers.append(vlst[i]);*/
 }
 
 void MOrderWindow::payment()
-{
+{/*TODO
        if(!m_order.isValid())return;
        //get value
        bool ok;
@@ -660,11 +667,11 @@ void MOrderWindow::payment()
                return;
        }
        m_order.setAmountPaid(req->responseBody().trimmed().toInt());
-       m_paid->setText(m_order.amountPaidString());
+       m_paid->setText(m_order.amountPaidString());*/
 }
 
 void MOrderWindow::payvoucher()
-{
+{/*TODO
        if(!m_order.isValid())return;
        //get voucher
        bool ok;
@@ -693,11 +700,11 @@ void MOrderWindow::payvoucher()
        }
        if(sl.size()>0){
                QMessageBox::information(this,tr("Voucher Info"),tr("Remaining value of this voucher: %1").arg(cent2str(sl[0].toInt())));
-       }
+       }*/
 }
 
 void MOrderWindow::refund()
-{
+{/*TODO
        if(!m_order.isValid())return;
        //get value
        bool ok;
@@ -715,11 +722,11 @@ void MOrderWindow::refund()
                return;
        }
        m_order.setAmountPaid(req->responseBody().trimmed().toInt());
-       m_paid->setText(m_order.amountPaidString());
+       m_paid->setText(m_order.amountPaidString());*/
 }
 
 void MOrderWindow::changeItem()
-{
+{/*TODO
        if(!m_order.isValid())return;
        //get ticket selection
        QModelIndexList lst=m_table->selectionModel()->selectedIndexes();
@@ -730,7 +737,7 @@ void MOrderWindow::changeItem()
        int type=m_model->data(idx,Qt::UserRole).toInt();
        if(type==ITEM_TICKET){
                //find ticket
-               QList<MTicket>tickets=m_order.tickets();
+               QList<MOTicket>tickets=m_order.tickets();
                MTicket tick;
                for(int i=0;i<tickets.size();i++)
                        if(tickets[i].ticketID()==id)
@@ -742,17 +749,17 @@ void MOrderWindow::changeItem()
                if(!ok)return;
                if(pay<0)return;
                //submit
-               m_order.updateTicketPrice(tick.ticketID(),pay);
+               m_order.updateTicketPrice(tick.ticketid(),pay);
        }else{
                QMessageBox::warning(this,tr("Warning"),tr("Cannot change this item type."));
                return;
        }
        m_total->setText(m_order.totalPriceString());
-       updateTable();
+       updateTable();*/
 }
 
 void MOrderWindow::itemReturn()
-{
+{/*TODO
        if(!m_order.isValid())return;
        //get ticket selection
        QModelIndexList lst=m_table->selectionModel()->selectedIndexes();
@@ -803,11 +810,11 @@ void MOrderWindow::itemReturn()
                updateTable();
                if(r!="")QMessageBox::warning(this,tr("Warning"),trUtf8(r.toUtf8()));
        }else
-               QMessageBox::warning(this,tr("Warning"),tr("Cannot return this item type."));
+               QMessageBox::warning(this,tr("Warning"),tr("Cannot return this item type."));*/
 }
 
 void MOrderWindow::cancelOrder()
-{
+{/*TODO
        if(QMessageBox::question(this,tr("Cancel Order?"),tr("Cancel this order now?"),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)!=QMessageBox::Yes)return;
        if(m_order.orderStatus()!=MOrder::Placed && m_order.orderStatus()!=MOrder::Reserved){
                QMessageBox::warning(this,tr("Warning"),tr("Cannot cancel this order: it is in the wrong state."));
@@ -816,11 +823,11 @@ void MOrderWindow::cancelOrder()
        if(!m_order.cancelOrder()){
                QMessageBox::warning(this,tr("Warning"),tr("Failed to cancel this order."));
        }else
-               m_state->setText(m_order.orderStatusString());
+               m_state->setText(m_order.orderStatusString());*/
 }
 
 void MOrderWindow::createOrder(Create mode)
-{
+{/*TODO
        MOrder ord;
        //handle reservation changes specially
        if(m_order.orderStatus()==MOrder::Reserved){
@@ -845,7 +852,7 @@ void MOrderWindow::createOrder(Create mode)
        MOrderWindow *ow=new MOrderWindow(parentWidget(),req,ord);
        ow->show();
        //undisplay self
-       close();
+       close();*/
 }
 
 void MOrderWindow::createSale()
@@ -859,7 +866,7 @@ void MOrderWindow::createReservation()
 }
 
 void MOrderWindow::recheckOrder()
-{
+{/*TODO
        //prune
        m_order.pruneInvalid();
        //now check
@@ -870,11 +877,11 @@ void MOrderWindow::recheckOrder()
        MOrderWindow *ow=new MOrderWindow(parentWidget(),req,ord);
        ow->show();
        //undisplay self
-       close();
+       close();*/
 }
 
 void MOrderWindow::shipOrder()
-{
+{/*TODO
        if(QMessageBox::question(this,tr("Mark as shipped?"),tr("Mark this order as shipped now?"),QMessageBox::Yes|QMessageBox::No,QMessageBox::Yes)==QMessageBox::Yes){
                QDateTime tm=QDateTime::currentDateTime();
                if(req->hasRole("_explicitshipdate")){
@@ -901,11 +908,11 @@ void MOrderWindow::shipOrder()
                m_order.shipOrder(tm);
                m_state->setText(m_order.orderStatusString());
                m_sentdate->setText(m_order.sentDateTimeStr());
-       }
+       }*/
 }
 
 void MOrderWindow::changeComment()
-{
+{/*TODO
        //create editor dialog
        QString cmt=m_order.comment();
        QDialog d;
@@ -929,11 +936,11 @@ void MOrderWindow::changeComment()
        //send to server
        m_order.sendComment(cmt=te->toPlainText());
        //reset display
-       m_comment->setText(cmt);
+       m_comment->setText(cmt);*/
 }
 
 void MOrderWindow::changeShipping()
-{
+{/*TODO
        //create editor dialog
        MShippingChange d(this,req,m_order.shipping());
        //get status
@@ -943,19 +950,19 @@ void MOrderWindow::changeShipping()
        //reset display
        m_shipmeth->setText(m_order.shipping().description());
        m_shipprice->setText(m_order.shipping().priceString());
-       m_total->setText(m_order.totalPriceString());
+       m_total->setText(m_order.totalPriceString());*/
 }
 
 void MOrderWindow::moneyLogOrder()
 {
-       if(m_order.orderID()<0)return;
-       MMoneyLog ml(this,req,"order\n"+QString::number(m_order.orderID()));
+       if(m_order.orderid()<0)return;
+       MMoneyLog ml(this,"order\n"+QString::number(m_order.orderid()));
        ml.exec();
 }
 
 void MOrderWindow::moneyLogVoucher()
 {
-       if(m_order.orderID()<0)return;
+       if(m_order.orderid()<0)return;
        //get selection
        if(!m_order.isValid())return;
        //get ticket selection
@@ -966,7 +973,7 @@ void MOrderWindow::moneyLogVoucher()
        if(id=="")return;
        int type=m_model->data(idx,Qt::UserRole).toInt();
        if(type==ITEM_VOUCHER){
-               MMoneyLog ml(this,req,"voucher\n"+id);
+               MMoneyLog ml(this,"voucher\n"+id);
                ml.exec();
        }else
                QMessageBox::warning(this,tr("Warning"),tr("This is not a voucher, cannot show the money log."));
@@ -975,11 +982,10 @@ void MOrderWindow::moneyLogVoucher()
 
 /*************************************************************************************/
 
-MOrderItemView::MOrderItemView(QWidget*w,MWebRequest*r,QList<MTicket>t,QList<MVoucher>v)
+MOrderItemView::MOrderItemView(QWidget*w,QList<MOTicket>t,QList<MOVoucher>v)
        :QDialog(w),tickets(t),vouchers(v)
 {
        setWindowTitle(tr("Preview Tickets"));
-       req=r;
        
        QVBoxLayout*vl;
        setLayout(vl=new QVBoxLayout);
@@ -987,25 +993,28 @@ MOrderItemView::MOrderItemView(QWidget*w,MWebRequest*r,QList<MTicket>t,QList<MVo
        vl->addWidget(cb=new QComboBox,0);
        cb->setEditable(false);
        for(int i=0;i<tickets.size();i++)
-               cb->addItem(tr("Ticket: ")+tickets[i].ticketID());
+               cb->addItem(tr("Ticket: ")+tickets[i].ticketid());
        for(int i=0;i<vouchers.size();i++)
-               cb->addItem(tr("Voucher: ")+vouchers[i].voucherID());
+               cb->addItem(tr("Voucher: ")+vouchers[i].voucherid());
        vl->addWidget(disp=new QLabel,10);
        //get the templates
+       /*TODO
        trender=new MTicketRenderer(req->getTemplate("ticket"));
        vrender=new MVoucherRenderer(req->getTemplate("voucher"));
+       */
        changeItem(0);
        connect(cb,SIGNAL(currentIndexChanged(int)),this,SLOT(changeItem(int)));
 }
 
 MOrderItemView::~MOrderItemView()
 {
-       delete trender;
-       delete vrender;
+       //FIXME
+       //delete trender;
+       //delete vrender;
 }
 
 void MOrderItemView::changeItem(int idx)
-{
+{/*TODO
        //ticket or voucher?
        if(idx<tickets.size()){
                QSizeF sz=trender->labelSize(*disp);
@@ -1021,21 +1030,21 @@ void MOrderItemView::changeItem(int idx)
                if(!vrender->render(vouchers[idx-tickets.size()],tick))
                        qDebug("unable to render");
                disp->setPixmap(tick);
-       }
+       }*/
 }
 
 
 /*************************************************************************************/
 
-MShippingChange::MShippingChange(QWidget*pa,MWebRequest*r,MShipping s)
+MShippingChange::MShippingChange(QWidget*pa,MOShipping s)
        :QDialog(pa)
 {
-       req=r;
-       all=req->getAllShipping();
+       all=req->queryGetAllShipping().getshipping();
        setWindowTitle(tr("Change Shipping Method"));
        
        int cid=-1;
-       if(s.isValid())cid=s.id();
+       //FIXME:
+       //if(s.isValid())cid=s.id();
        
        QGridLayout*gl;
        setLayout(gl=new QGridLayout);
@@ -1055,7 +1064,7 @@ MShippingChange::MShippingChange(QWidget*pa,MWebRequest*r,MShipping s)
        connect(p,SIGNAL(clicked()),this,SLOT(reject()));
        
        prc->setRange(0,1000000000);//hmm, even in Yen this should be big enough
-       prc->setValue(s.price());
+       prc->setValue(s.cost());
        prc->setEnabled(req->hasRole("orderchangeshipping"));
        
        opt->addItem(tr("(None)","shipping method"));
@@ -1069,12 +1078,12 @@ MShippingChange::MShippingChange(QWidget*pa,MWebRequest*r,MShipping s)
        connect(opt,SIGNAL(currentIndexChanged(int)),this,SLOT(changeItem(int)));
 }
 
-MShipping MShippingChange::selection()const
+MOShipping MShippingChange::selection()const
 {
        int cid=opt->currentIndex();
-       if(cid==0)return MShipping();
-       MShipping cp=all[cid-1];
-       cp.setPrice(price());
+       if(cid==0)return MOShipping();
+       MOShipping cp=all[cid-1];
+       cp.setcost(price());
        return cp;
 }
 
@@ -1086,5 +1095,5 @@ int MShippingChange::price()const
 void MShippingChange::changeItem(int cid)
 {
        if(cid==0)prc->setValue(0);
-       else prc->setValue(all[cid-1].price());
+       else prc->setValue(all[cid-1].cost());
 }
index 010595d..dd902ed 100644 (file)
 #include <QMainWindow>
 #include "order.h"
 #include "odtrender.h"
+#include "MOShipping.h"
 
 class QLabel;
 class QTableView;
 class QStandardItemModel;
-class MWebRequest;
 
 /**displays an order and allows the user to execute several commands on it*/
 class MOrderWindow:public QMainWindow
@@ -28,7 +28,7 @@ class MOrderWindow:public QMainWindow
        Q_OBJECT
        public:
                /**creates the order window*/
-               MOrderWindow(QWidget*,MWebRequest*,const MOrder&);
+               MOrderWindow(QWidget*,const MOrder&);
                
                /**returns whether the order has been changed by this window*/
                bool isChanged()const;
@@ -109,7 +109,6 @@ class MOrderWindow:public QMainWindow
                void moneyLogVoucher();
        
        private:
-               MWebRequest*req;
                MOrder m_order;
                bool m_changed;
                QLabel *m_orderid,*m_orderdate,*m_sentdate,*m_state,*m_paid,*m_total,*m_comment,
@@ -147,15 +146,14 @@ class MOrderItemView:public QDialog
 {
        Q_OBJECT
        public:
-               MOrderItemView(QWidget*,MWebRequest*,QList<MTicket>,QList<MVoucher>);
+               MOrderItemView(QWidget*,QList<MOTicket>,QList<MOVoucher>);
                ~MOrderItemView();
                
        private slots:
                void changeItem(int);
        private:
-               MWebRequest*req;
-               QList<MTicket> tickets;
-               QList<MVoucher> vouchers;
+               QList<MOTicket> tickets;
+               QList<MOVoucher> vouchers;
                QLabel*disp;
                MTicketRenderer*trender;
                MVoucherRenderer*vrender;
@@ -170,10 +168,10 @@ class MShippingChange:public QDialog
        Q_OBJECT
        public:
                /**creates the dialog*/
-               MShippingChange(QWidget*,MWebRequest*,MShipping);
+               MShippingChange(QWidget*,MOShipping);
                
                /**returns the selected shipping option, including corrected price*/
-               MShipping selection()const;
+               MOShipping selection()const;
                /**returns the entered price in cent*/
                int price()const;
                
@@ -181,8 +179,7 @@ class MShippingChange:public QDialog
                /**internal: updates price when new option is selected*/
                void changeItem(int);
        private:
-               MWebRequest*req;
-               QList<MShipping> all;
+               QList<MOShipping> all;
                QComboBox*opt;
                MCentSpinBox*prc;
 };
index 96a08d6..bce24d5 100644 (file)
@@ -560,22 +560,22 @@ void MOverview::editUserDescription()
 }
 
 void MOverview::editUserRoles()
-{
+{/*TODO
        //get selection
        QModelIndex sel=usertable->currentIndex();
        if(!sel.isValid())return;
        //get uname & descr
        QString name=usermodel->data(usermodel->index(sel.row(),0)).toString();
        //...
-       MUser usr(req,name);
+       MOUser usr(req,name);
        MCheckList acl=usr.getRoles();
        MCheckDialog cd(this,acl,"Edit ACL of user "+name);
        if(cd.exec()==QDialog::Accepted)
-               usr.setRoles(cd.getCheckList());
+               usr.setRoles(cd.getCheckList());*/
 }
 
 void MOverview::editUserHosts()
-{
+{/*TODO
        //get selection
        QModelIndex sel=usertable->currentIndex();
        if(!sel.isValid())return;
@@ -586,20 +586,20 @@ void MOverview::editUserHosts()
        MCheckList acl=usr.getHosts();
        MCheckDialog cd(this,acl,"Edit hosts of user "+name);
        if(cd.exec()==QDialog::Accepted)
-               usr.setHosts(cd.getCheckList());
+               usr.setHosts(cd.getCheckList());*/
 }
 
 void MOverview::setMyPassword()
-{
+{/*TODO
        MPasswordChange pc(this);
        if(pc.exec()==QDialog::Accepted){
                QString e=req->changeMyPassword(pc.oldPassword(),pc.newPassword());
                if(e!="")
                        QMessageBox::warning(this,tr("Warning"),tr("Error setting password: %1").arg(e));
-       }
+       }*/
 }
 void MOverview::setUserPassword()
-{
+{/*TODO
        //get selection
        QModelIndex sel=usertable->currentIndex();
        if(!sel.isValid())return;
@@ -615,11 +615,11 @@ void MOverview::setUserPassword()
        }
        //...
        MUser usr(req,name);
-       usr.changePassword(p);
+       usr.changePassword(p);*/
 }
 
 void MOverview::updateHosts()
-{
+{/*TODO
        bool foundThis=false;
        QString thisHost=req->hostName();
        QList<MHost>hsl=req->getAllHosts();
@@ -634,11 +634,11 @@ void MOverview::updateHosts()
                        foundThis=true;
        }
        hosttable->resizeColumnsToContents();
-       thishostbutton->setEnabled(!foundThis && req->hasRole("addhost"));
+       thishostbutton->setEnabled(!foundThis && req->hasRole("addhost"));*/
 }
 
 void MOverview::newHost()
-{
+{/*TODO
        //get Host Name
        QString hname;
        do{
@@ -656,18 +656,18 @@ void MOverview::newHost()
        }
        hst.create();
        //update
-       updateHosts();
+       updateHosts();*/
 }
 
 void MOverview::addThisHost()
-{
+{/*TODO
        MHost hst(req,req->hostName(),QSettings().value("hostkey").toString());
        hst.create();
-       updateHosts();
+       updateHosts();*/
 }
 
 void MOverview::deleteHost()
-{
+{/*TODO
        //get selection
        QModelIndex sel=hosttable->currentIndex();
        if(!sel.isValid())return;
@@ -677,11 +677,11 @@ void MOverview::deleteHost()
        if(QMessageBox::question(this,tr("Delete this Host?"),tr("Really delete host '%1'?").arg(name),QMessageBox::Yes|QMessageBox::No)!=QMessageBox::Yes)return;
        //delete it
        MHost(req,name).deleteHost();
-       updateHosts();
+       updateHosts();*/
 }
 
 void MOverview::changeHostKey()
-{
+{/*TODO
        //get selection
        QModelIndex sel=hosttable->currentIndex();
        if(!sel.isValid())return;
@@ -698,11 +698,11 @@ void MOverview::changeHostKey()
        }
        hst.save();
        //update
-       updateHosts();
+       updateHosts();*/
 }
 
 void MOverview::importHost()
-{
+{/*TODO
        QStringList fn;
        QFileDialog fdlg(this,tr("Import Key from File"),QString(),"Magic Smoke Host Key (*.mshk)");
        fdlg.setDefaultSuffix("mshk");
@@ -746,11 +746,11 @@ void MOverview::importHost()
        //save
        MHost hst(req,hname,key);
        hst.create();
-       updateHosts();
+       updateHosts();*/
 }
 
 void MOverview::exportHost()
-{
+{/*TODO
        //get selection
        QModelIndex sel=hosttable->currentIndex();
        if(!sel.isValid())return;
@@ -778,7 +778,7 @@ void MOverview::exportHost()
        QString chk=QCryptographicHash::hash(key.toAscii(),QCryptographicHash::Md5).toHex();
        QString out="MagicSmokeHostKey\n"+name+"\n"+key+"\n"+chk;
        fd.write(out.toAscii());
-       fd.close();
+       fd.close();*/
 }
 
 
@@ -798,11 +798,11 @@ void MOverview::initCart()
 }
 
 void MOverview::setCustomer()
-{
+{/*TODO
        MCustomerListDialog mcl(req,this,true,customer.customerID());
        if(mcl.exec()!=QDialog::Accepted)return;
        customer=mcl.getCustomer();
-       cartcustomer->setText(customer.getNameAddress());
+       cartcustomer->setText(customer.getNameAddress());*/
 }
 
 static const int CART_TICKET=1;
@@ -877,7 +877,7 @@ void MOverview::eventOrderTicket()
 }
 
 void MOverview::cartAddVoucher()
-{
+{/*TODO
        //create voucher selection dialog
        QDialog dlg;
        dlg.setWindowTitle(tr("Select Voucher"));
@@ -933,7 +933,7 @@ void MOverview::cartAddVoucher()
                cartmodel->setData(cartmodel->index(cr,0),CART_VOUCHER,CART_TYPEROLE);
                cartmodel->setData(cartmodel->index(cr,1),tr("Voucher (price: %1, value %2)").arg(cent2str(price)).arg(cent2str(value)));
                carttable->resizeColumnsToContents();
-       }
+       }*/
 }
 
 void MOverview::cartRemoveItem()
@@ -960,7 +960,7 @@ void MOverview::cartOrder()
        //create order
        QDomDocument doc;
        QDomElement root=doc.createElement("Order");
-       root.setAttribute("customer",customer.customerID());
+       root.setAttribute("customer",customer.id());
        //is there a delivery address
        QString s=cartaddr->toPlainText().trimmed();
        if(s!=""){
@@ -1010,6 +1010,7 @@ void MOverview::cartOrder()
        //finalize
        doc.appendChild(root);
        //send
+       /*TODO
        if(req->request("checkorder",doc.toByteArray())==false){
                QMessageBox::warning(this,tr("Error"),tr("The request failed."));
                return;
@@ -1025,24 +1026,24 @@ void MOverview::cartOrder()
        MOrderWindow *ow=new MOrderWindow(this,req,MOrder(req,rdoc.documentElement()));
        ow->show();
        //empty the cart
-       initCart();
+       initCart();*/
 }
 
 void MOverview::customerMgmt()
-{
+{/*TODO
        MCustomerListDialog mcl(req,this);
-       mcl.exec();
+       mcl.exec();*/
 }
 
 void MOverview::editShipping()
-{
+{/*TODO
        MShippingEditor se(req,this);
        se.exec();
-       updateShipping();
+       updateShipping();*/
 }
 
 void MOverview::tabChanged()
-{
+{/*TODO
        QWidget*w=tab->currentWidget();
        if(w==entrancetab){
                //fill combobox from eventmodel
@@ -1062,11 +1063,11 @@ void MOverview::tabChanged()
                //set focus on scanner
                entrancescan->setFocus(Qt::OtherFocusReason);
                entrancescan->setText("");
-       }
+       }*/
 }
 
 void MOverview::entranceValidate()
-{
+{/*TODO
        //get event ID
        int ci=entranceevent->currentIndex();
        if(ci<0)return;
@@ -1124,7 +1125,7 @@ void MOverview::entranceValidate()
        
        entrancelabel->setPalette(pal);
        entrancescan->setFocus(Qt::OtherFocusReason);
-       entrancescan->setText("");
+       entrancescan->setText("");*/
 }
 
 //helper: finds out whether an order should be printed.
@@ -1139,7 +1140,7 @@ static inline bool candoUpdateOrders(int omode,const MOrder&ord)
 }
 
 void MOverview::updateOrders()
-{
+{/*TODO
        ordermodel->clear();
        ordermodel->setHorizontalHeaderLabels(QStringList()<<tr("Status")<<tr("Total")<<tr("Paid")<<tr("Customer"));
        int omode=ordermode->itemData(ordermode->currentIndex()).toInt();
@@ -1163,11 +1164,11 @@ void MOverview::updateOrders()
                                ordermodel->setData(ordermodel->index(cl,3),cust[j].name());
                cl++;
        }
-       ordertable->resizeColumnsToContents();
+       ordertable->resizeColumnsToContents();*/
 }
 
 void MOverview::orderDetails()
-{
+{/*TODO
        //get selected order
        int id;
        QModelIndexList ilst=ordertable->selectionModel()->selectedIndexes();
@@ -1178,11 +1179,11 @@ void MOverview::orderDetails()
        //open order window
        MOrderWindow *om=new MOrderWindow(this,req,MOrder(req,id));
        om->setAttribute(Qt::WA_DeleteOnClose);
-       om->show();
+       om->show();*/
 }
 
 void MOverview::orderByTicket()
-{
+{/*TODO
        //get selected order
        bool ok;
        QString tid=QInputDialog::getText(this,tr("Enter Ticket"),tr("Please enter the ID of one of the tickets of the order you seek:"),QLineEdit::Normal,"",&ok);
@@ -1204,11 +1205,11 @@ void MOverview::orderByTicket()
        //open order window
        MOrderWindow *om=new MOrderWindow(this,req,MOrder(req,id));
        om->setAttribute(Qt::WA_DeleteOnClose);
-       om->show();
+       om->show();*/
 }
 
 void MOverview::orderByEvent()
-{
+{/*TODO
        //display selection dialog
        QDialog d(this);
        d.setWindowTitle(tr("Select Event"));
@@ -1262,11 +1263,11 @@ void MOverview::orderByEvent()
                        if(cust[j].customerID()==cid)
                                ordermodel->setData(ordermodel->index(cl,3),cust[j].name());
        }
-       ordermode->setCurrentIndex(ordermode->count()-1);
+       ordermode->setCurrentIndex(ordermode->count()-1);*/
 }
 
 void MOverview::orderByCustomer()
-{
+{/*TODO
        //display selection dialog
        MCustomerListDialog mcl(req,this,true);
        //wait for user
@@ -1301,11 +1302,11 @@ void MOverview::orderByCustomer()
                //count up
                cl++;
        }
-       ordermode->setCurrentIndex(ordermode->count()-1);
+       ordermode->setCurrentIndex(ordermode->count()-1);*/
 }
 
 void MOverview::orderByOrder()
-{
+{/*TODO
        //ask for OrderID
        bool ok;
        int oid=QInputDialog::getInteger(this,tr("Enter Order ID"),tr("Please enter the ID of the order you want to display:"),0,0,2147483647,1,&ok);
@@ -1317,11 +1318,11 @@ void MOverview::orderByOrder()
                return;
        }
        MOrderWindow *ow=new MOrderWindow(this,req,ord);
-       ow->show();
+       ow->show();*/
 }
 
 void MOverview::ticketReturn()
-{
+{/*TODO
        //get ticket
        bool ok;
        QString tid=QInputDialog::getText(this,tr("Return Ticket"),tr("Please enter the ticket ID to return:"),QLineEdit::Normal,"",&ok);
@@ -1338,11 +1339,11 @@ void MOverview::ticketReturn()
        }
        //submit
        QString r=tick.ticketReturn();
-       if(r!="")QMessageBox::warning(this,tr("Warning"),trUtf8(r.toUtf8()));
+       if(r!="")QMessageBox::warning(this,tr("Warning"),trUtf8(r.toUtf8()));*/
 }
 
 void MOverview::voucherReturn()
-{
+{/*TODO
        //get ticket
        bool ok;
        QString tid=QInputDialog::getText(this,tr("Return Voucher"),tr("Please enter the voucher ID to return:"),QLineEdit::Normal,"",&ok);
@@ -1359,11 +1360,11 @@ void MOverview::voucherReturn()
        }
        //submit
        QString r=vouc.voucherReturn();
-       if(r!="")QMessageBox::warning(this,tr("Warning"),trUtf8(r.toUtf8()));
+       if(r!="")QMessageBox::warning(this,tr("Warning"),trUtf8(r.toUtf8()));*/
 }
 
 void MOverview::deductVoucher()
-{
+{/*TODO
        //get voucher ID and amount
        QDialog d;
        d.setWindowTitle(tr("Deduct from Voucher"));
@@ -1403,7 +1404,7 @@ void MOverview::deductVoucher()
        int tak=-1,rem=-1;
        if(sl.size()>0)tak=sl[0].trimmed().toInt();
        if(sl.size()>1)rem=sl[1].trimmed().toInt();
-       QMessageBox::information(this,tr("Deducted from Voucher"),tr("Value taken from voucher: %1\nValue remaining on voucher: %2").arg(cent2str(tak)).arg(cent2str(rem)));
+       QMessageBox::information(this,tr("Deducted from Voucher"),tr("Value taken from voucher: %1\nValue remaining on voucher: %2").arg(cent2str(tak)).arg(cent2str(rem)));*/
 }
 
 void MOverview::refreshData()
@@ -1514,11 +1515,12 @@ void MOverview::webSettings(bool showdlg)
        }
        //reset webrequest
        req->setLogLevel(lvl);
-       req->setTimeout(timeout*1000);
+       //TODO: implement setTimeout
+       //req->setTimeout(timeout*1000);
 }
 
 void MOverview::doBackup()
-{
+{/*TODO
        baktimer.stop();
        //sanity check
        if(!req->hasRole("backup"))return;
@@ -1552,11 +1554,11 @@ void MOverview::doBackup()
                int tm=set.value("backupinterval",0).toInt()*86400000;
                if(tm)baktimer.start(tm);
        }else
-               QMessageBox::warning(this,tr("Warning"),tr("Cannot create backup file."));
+               QMessageBox::warning(this,tr("Warning"),tr("Cannot create backup file."));*/
 }
 
 void MOverview::backupSettings()
-{
+{/*TODO
        //show dialog
        MBackupDialog d(this,profilekey,req);
        d.exec();
@@ -1569,27 +1571,27 @@ void MOverview::backupSettings()
                else btm-=iv;
                //start timer
                baktimer.start(btm*1000);
-       }
+       }*/
 }
 
 void MOverview::moneylogVoucher()
-{
+{/*TODO
        QString vid=QInputDialog::getText(this,tr("Voucher ID"),tr("Please enter voucher ID to show log:"));
        if(vid!="")
-               MMoneyLog(this,req,"voucher\n"+vid).exec();
+               MMoneyLog(this,req,"voucher\n"+vid).exec();*/
 }
 
 void MOverview::moneylogUser()
-{
+{/*TODO
        QString vid=QInputDialog::getText(this,tr("User"),tr("Please enter login name of user to show log:"));
        if(vid!="")
-               MMoneyLog(this,req,"user\n"+vid).exec();
+               MMoneyLog(this,req,"user\n"+vid).exec();*/
 }
 
 
 /**********************************************/
 
-MBackupDialog::MBackupDialog(QWidget*par,QString pk,MSInterface*req)
+MBackupDialog::MBackupDialog(QWidget*par,QString pk)
        :QDialog(par),profilekey(pk)
 {
        QSettings set;
index b3bea8e..dfd5a43 100644 (file)
@@ -32,6 +32,8 @@ class QStandardItemModel;
 class QTabWidget;
 class QTableView;
 
+class MSInterface;
+
 /**Main Overview Window*/
 class MOverview:public QMainWindow
 {
index c7adfe9..7452b1c 100644 (file)
 #use genphpscan.sh to regenerate it!
 
 HEADERS += \
+../www/wob.php \
+../www/index.php \
+../www/machine.php \
+../www/admin.php \
+../www/test.php \
+../www/info.php \
+../www/inc/loader_nonadmin.php \
+../www/inc/listing.php \
+../www/inc/rendering/event_listing.php \
+../www/inc/rendering/cart_listing.php \
+../www/inc/rendering/submit.php \
+../www/inc/rendering/order_listing.php \
+../www/inc/loader.php \
+../www/inc/classes/websession.php \
+../www/inc/classes/customer.php \
+../www/inc/classes/voucher.php \
+../www/inc/classes/parser.php \
+../www/inc/classes/random.php \
+../www/inc/classes/error.php \
+../www/inc/classes/room.php \
+../www/inc/classes/ticket.php \
+../www/inc/classes/autoload.php \
+../www/inc/classes/cart.php \
+../www/inc/classes/event.php \
+../www/inc/classes/order.php \
+../www/inc/classes/language_manager.php \
+../www/inc/classes/config_manager.php \
+../www/inc/wbase/schema.php \
+../www/inc/wbase/table.php \
+../www/inc/wbase/autoload.php \
+../www/inc/wbase/object.php \
+../www/inc/wbase/transaction.php \
+../www/inc/wbase/exception.php \
 ../www/inc/db/db_mysql.php \
 ../www/inc/db/db_scheme.php \
-../www/inc/db/db.php \
 ../www/inc/db/autoload.php \
-../www/inc/wob/wt_cart_ticket.php \
-../www/inc/wob/wt_users.php \
+../www/inc/db/db.php \
+../www/inc/tr.php \
+../www/inc/wob/wtr_GetAllCustomerNames.php \
+../www/inc/wob/wtr_CreateUser.php \
+../www/inc/wob/schema.php \
+../www/inc/wob/wt_order.php \
+../www/inc/wob/wt_session.php \
+../www/inc/wob/wt_event.php \
 ../www/inc/wob/wt_cart.php \
-../www/inc/wob/wo_Voucher.php \
-../www/inc/wob/wt_host.php \
+../www/inc/wob/wo_User.php \
+../www/inc/wob/wtr_SetUserDescription.php \
+../www/inc/wob/wtr_GetAllHostNames.php \
+../www/inc/wob/wo_HostAcl.php \
 ../www/inc/wob/wt_room.php \
-../www/inc/wob/wt_moneylog.php \
+../www/inc/wob/wtr_GetAllShipping.php \
 ../www/inc/wob/wt_customer.php \
-../www/inc/wob/wtr_Login.php \
 ../www/inc/wob/wo_CartVoucher.php \
-../www/inc/wob/wt_webuser.php \
-../www/inc/wob/wt_shipping.php \
-../www/inc/wob/wt_websession.php \
-../www/inc/wob/wt_voucher.php \
-../www/inc/wob/wt_event.php \
+../www/inc/wob/wo_Shipping.php \
+../www/inc/wob/wt_host.php \
+../www/inc/wob/wt_country.php \
+../www/inc/wob/wo_Country.php \
+../www/inc/wob/wt_userhosts.php \
+../www/inc/wob/wtr_GetUserRoles.php \
+../www/inc/wob/wo_Ticket.php \
+../www/inc/wob/wt_config.php \
+../www/inc/wob/wtr_SetUserRoles.php \
+../www/inc/wob/wtr_ChangePassword.php \
+../www/inc/wob/wtr_DeleteUser.php \
+../www/inc/wob/wo_Voucher.php \
+../www/inc/wob/wtr_GetTicket.php \
+../www/inc/wob/wtr_CancelEvent.php \
+../www/inc/wob/wo_Host.php \
 ../www/inc/wob/wo_CartOrder.php \
-../www/inc/wob/wt_order.php \
+../www/inc/wob/wo_UserRole.php \
+../www/inc/wob/wt_cart_voucher.php \
+../www/inc/wob/wt_voucher.php \
+../www/inc/wob/wo_CartTicket.php \
+../www/inc/wob/wt_ticket.php \
+../www/inc/wob/wtr_GetAllRooms.php \
+../www/inc/wob/wt_moneylog.php \
+../www/inc/wob/wtr_ServerInfo.php \
+../www/inc/wob/wtr_Login.php \
+../www/inc/wob/wtr_GetVoucher.php \
+../www/inc/wob/wt_users.php \
+../www/inc/wob/wtr_GetAllHosts.php \
+../www/inc/wob/wtr_GetCustomer.php \
+../www/inc/wob/wt_cart_ticket.php \
+../www/inc/wob/wtr_GetOrder.php \
+../www/inc/wob/wtr_SetHost.php \
+../www/inc/wob/wt_template.php \
+../www/inc/wob/wo_Room.php \
+../www/inc/wob/wtr_GetEvent.php \
+../www/inc/wob/wt_shipping.php \
+../www/inc/wob/wt_address.php \
+../www/inc/wob/wtr_GetMyRoles.php \
+../www/inc/wob/wtr_GetAllUsers.php \
 ../www/inc/wob/autoload.php \
-../www/inc/wob/wt_session.php \
+../www/inc/wob/wo_Address.php \
+../www/inc/wob/wo_Customer.php \
+../www/inc/wob/wt_websession.php \
+../www/inc/wob/wtr_GetAllEvents.php \
 ../www/inc/wob/wo_Order.php \
 ../www/inc/wob/transaction.php \
-../www/inc/wob/wt_template.php \
-../www/inc/wob/wt_userhosts.php \
-../www/inc/wob/wo_User.php \
+../www/inc/wob/wtr_SetUserHosts.php \
+../www/inc/wob/wtr_GetUserHosts.php \
 ../www/inc/wob/wt_userrole.php \
-../www/inc/wob/wo_Ticket.php \
-../www/inc/wob/wo_CartTicket.php \
-../www/inc/wob/wt_cart_voucher.php \
-../www/inc/wob/wtr_GetMyRoles.php \
-../www/inc/wob/wtr_GetTicket.php \
-../www/inc/wob/wtr_ServerInfo.php \
-../www/inc/wob/wt_config.php \
-../www/inc/wob/schema.php \
-../www/inc/wob/wt_ticket.php \
-../www/inc/wbase/exception.php \
-../www/inc/wbase/object.php \
-../www/inc/wbase/autoload.php \
-../www/inc/wbase/transaction.php \
-../www/inc/wbase/table.php \
-../www/inc/wbase/schema.php \
-../www/inc/loader_nonadmin.php \
-../www/inc/listing.php \
+../www/inc/wob/wo_Event.php \
+../www/inc/wob/wtr_DeleteHost.php \
+../www/inc/global_variables.php \
+../www/inc/global_functions.php \
 ../www/inc/machine/cauth_hash.php \
-../www/inc/machine/version.php \
-../www/inc/machine/host.php \
 ../www/inc/machine/cauth_mhash.php \
-../www/inc/machine/autoload.php \
-../www/inc/machine/session.php \
-../www/inc/machine/template.php \
+../www/inc/machine/host.php \
+../www/inc/machine/version.php \
 ../www/inc/machine/cauth_string.php \
-../www/inc/global_variables.php \
-../www/inc/loader.php \
-../www/inc/global_functions.php \
-../www/inc/tr.php \
-../www/inc/rendering/event_listing.php \
-../www/inc/rendering/cart_listing.php \
-../www/inc/rendering/submit.php \
-../www/inc/rendering/order_listing.php \
-../www/inc/classes/random.php \
-../www/inc/classes/parser.php \
-../www/inc/classes/customer.php \
-../www/inc/classes/language_manager.php \
-../www/inc/classes/ticket.php \
-../www/inc/classes/event.php \
-../www/inc/classes/order.php \
-../www/inc/classes/config_manager.php \
-../www/inc/classes/cart.php \
-../www/inc/classes/room.php \
-../www/inc/classes/voucher.php \
-../www/inc/classes/autoload.php \
-../www/inc/classes/websession.php \
-../www/inc/classes/error.php \
-../www/test.php \
-../www/admin.php \
+../www/inc/machine/template.php \
+../www/inc/machine/session.php \
+../www/inc/machine/autoload.php \
 ../www/config.php \
-../www/machine.php \
-../www/index.php \
-../www/wob.php \
 
diff --git a/src/room.cpp b/src/room.cpp
deleted file mode 100644 (file)
index ef8fd84..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-//
-// C++ Implementation: room
-//
-// Description: 
-//
-//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007
-//
-// Copyright: See README/COPYING files that come with this distribution
-//
-//
-
-#include "room.h"
-#include "webrequest.h"
-
-#include <QtXml>
-
-MRoom::MRoom(MWebRequest*r,QDomElement&el)
-{
-       req=r;
-       m_valid=m_complete=false;
-       m_capacity=0;
-       initFromElement(el);
-}
-
-MRoom::MRoom(MWebRequest*r,QString rn)
-{
-       req=r;
-       m_roomid=rn;
-       refresh();
-}
-
-void MRoom::refresh()
-{
-       m_valid=m_complete=false;
-       m_capacity=0;
-       //request
-       QDomDocument doc1;
-       QDomElement root=doc1.createElement("GetRooms");
-       root.setAttribute("detail","full");
-       QDomElement el=doc1.createElement("Room");
-       el.appendChild(doc1.createTextNode(m_roomid));
-       root.appendChild(el);
-       doc1.appendChild(root);
-       if(req->request("getroomdata",doc1.toByteArray())){
-               if(req->responseStatus()!=MWebRequest::Ok)return;
-               QDomDocument doc2;
-               if(!doc2.setContent(req->responseBody()))return;
-               root=doc2.documentElement();
-               QDomNodeList nl=root.elementsByTagName("Room");
-               for(int i=0;i<nl.size();i++){
-                       el=nl.at(i).toElement();
-                       if(el.isNull())continue;
-                       QDomNodeList nl2=el.elementsByTagName("ID");
-                       if(nl2.size()<1)continue;
-                       if(nl2.at(0).toElement().text()==m_roomid)
-                               initFromElement(el);
-               }
-       }
-}
-
-void MRoom::initFromElement(QDomElement&el)
-{
-       bool b;
-       m_valid=true;
-       int cap=el.attribute("capacity","x").trimmed().toInt(&b);
-       if(b && cap>=0)m_capacity=cap;
-       else m_valid=false;
-       QDomNodeList nl=el.elementsByTagName("ID");
-       if(nl.size()>0){
-               m_roomid=nl.at(0).toElement().text();
-               if(m_roomid=="")m_valid=false;
-       }else
-               m_valid=false;
-       nl=el.elementsByTagName("Description");
-       if(nl.size()>0){
-               m_description=nl.at(0).toElement().text();
-               m_complete=true;
-       }else
-               m_complete=false;
-}
-
-void MRoom::save()
-{
-       if(!m_valid || !m_complete)return;
-       QDomDocument doc;
-       QDomElement root=doc.createElement("RoomData");
-       QDomElement room=doc.createElement("Room");
-       room.setAttribute("capacity",m_capacity);
-       QDomElement el=doc.createElement("ID");
-       el.appendChild(doc.createTextNode(m_roomid));
-       room.appendChild(el);
-       el=doc.createElement("Description");
-       el.appendChild(doc.createTextNode(m_description));
-       room.appendChild(el);
-       root.appendChild(room);
-       doc.appendChild(root);
-       req->request("setroomdata",doc.toByteArray());
-}
diff --git a/src/room.h b/src/room.h
deleted file mode 100644 (file)
index 630046d..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-//
-// C++ Interface: room
-//
-// Description: 
-//
-//
-// Author: Konrad Rosenbaum <konrad@silmor.de>, (C) 2007
-//
-// Copyright: See README/COPYING files that come with this distribution
-//
-//
-
-#ifndef ROOM_H
-#define ROOM_H
-
-#include <QString>
-
-class MWebRequest;
-class QDomElement;
-
-class MRoom
-{
-       public:
-               MRoom(MWebRequest*,QDomElement&);
-               MRoom(MWebRequest*,QString);
-               
-               QString roomId()const{return m_roomid;}
-               QString description()const{return m_description;}
-               int capacity()const{return m_capacity;}
-               
-               void setDescription(QString s){m_description=s;}
-               void setCapacity(int c){if(c>=0)m_capacity=c;}
-               
-               bool isValid()const{return m_valid;}
-               bool isComplete()const{return m_complete;}
-               void makeValid(){m_valid=m_complete=true;}
-               
-               void save();
-               void refresh();
-               
-       private:
-               void initFromElement(QDomElement&);
-               MWebRequest*req;
-               QString m_roomid,m_description;
-               int m_capacity;
-               bool m_valid,m_complete;
-};
-
-#endif
index 0796ca4..574912a 100644 (file)
 
 #include "misc.h"
 #include "shipping.h"
-#include "webrequest.h"
 #include "centbox.h"
 
+#include "MOShipping.h"
+
+#include "msinterface.h"
+
 #include <QApplication>
 #include <QDomDocument>
 #include <QDomElement>
 #include <QInputDialog>
 #include <QBoxLayout>
 
-MShipping::MShipping(MWebRequest*r)
-{
-       req=r;
-       m_id=-1;
-       m_price=0;
-       m_web=m_any=false;
-}
-
-MShipping::MShipping(MWebRequest*r,const QDomElement&e)
-{
-       req=r;
-       bool b;
-       m_id=e.attribute("type","-1").toInt(&b);
-       if(!b)m_id=-1;
-       m_price=e.attribute("price","0").toInt();
-       m_web=e.attribute("web","0")=="1";
-       m_any=e.attribute("anyUser","0")=="1";
-       m_descr=e.text();
-}
-MShipping::MShipping(const MShipping&s)
-{
-       req=s.req;
-       m_id=s.m_id;
-       m_price=s.m_price;
-       m_web=s.m_web;
-       m_any=s.m_any;
-       m_descr=s.m_descr;
-}
-MShipping& MShipping::operator=(const MShipping&s)
-{
-       req=s.req;
-       m_id=s.m_id;
-       m_price=s.m_price;
-       m_web=s.m_web;
-       m_any=s.m_any;
-       m_descr=s.m_descr;
-       return *this;
-}
-
-bool MShipping::isValid()const
-{
-       return req && m_id>=0;
-}
-
-int MShipping::id()const{return m_id;}
-int MShipping::price()const{return m_price;}
-
-QString MShipping::priceString(int off)const
-{
-       return cent2str(m_price+off);
-}
-
-bool MShipping::webUsable()const{return m_web;}
-bool MShipping::anyUserCanUse()const{return m_any;}
-
-bool MShipping::canUse()const
-{
-       if(m_any)return true;
-       if(!req)return false;
-       return req->hasRole("_anyshipping");
-}
+#define req (MSInterface::instance())
 
-QString MShipping::description()const{return m_descr;}
-
-void MShipping::setPrice(int p)
-{
-       if(p>=0)m_price=p;
-}
-
-void MShipping::setWebUsable(bool b){m_web=b;}
-
-void MShipping::setAnyUserCanUse(bool b){m_any=b;}
-
-void MShipping::setDescription(QString d){m_descr=d;}
-
-bool MShipping::save(bool asnew)
-{
-       if(!req)return false;
-       //create XML
-       QDomDocument doc;
-       QDomElement el=doc.createElement("ShippingOption");
-       if(isValid()&&!asnew)el.setAttribute("type",m_id);
-       el.setAttribute("price",m_price);
-       el.setAttribute("web",m_web?"1":"0");
-       el.setAttribute("anyUser",m_any?"1":"0");
-       el.appendChild(doc.createTextNode(m_descr));
-       doc.appendChild(el);
-       //execute request
-       if(!req->request("setshipping",doc.toByteArray()))return false;
-       if(req->responseStatus()!=MWebRequest::Ok)return false;
-       //get result
-       bool b;
-       int id=QString::fromAscii(req->responseBody()).trimmed().toInt(&b);
-       if(b && id>=0)m_id=id;
-       return true;
-}
-
-/******************************************************************************************/
-
-MShippingEditor::MShippingEditor(MWebRequest*r,QWidget*par)
+MShippingEditor::MShippingEditor(QWidget*par)
        :QDialog(par)
 {
-       req=r;
-       all=req->getAllShipping();
+       all=req->queryGetAllShipping().getshipping();
        setWindowTitle(tr("Edit Shipping Options"));
        
        QHBoxLayout*hl;
@@ -169,17 +74,17 @@ void MShippingEditor::updateTable()
        model->insertRows(0,all.size());
        model->setHorizontalHeaderLabels(QStringList()<<tr("ID")<<tr("Description")<<tr("Price")<<tr("Web")<<tr("Any User"));
        for(int i=0;i<all.size();i++){
-               model->setData(model->index(i,0),all[i].id());
-               model->setData(model->index(i,1),all[i].description());
-               model->setData(model->index(i,2),all[i].priceString());
-               model->setData(model->index(i,3),all[i].webUsable()?tr("Yes"):tr("No"));
-               model->setData(model->index(i,4),all[i].anyUserCanUse()?tr("Yes"):tr("No"));
+               model->setData(model->index(i,0),all[i].id().value());
+               model->setData(model->index(i,1),all[i].description().value());
+               model->setData(model->index(i,2),cent2str(all[i].cost()));
+               model->setData(model->index(i,3),all[i].canuseweb().value()?tr("Yes"):tr("No"));
+               model->setData(model->index(i,4),all[i].canallusers().value()?tr("Yes"):tr("No"));
        }
        table->resizeColumnsToContents();
 }
 
 void MShippingEditor::changeDescription()
-{
+{/*TODO
        //find item
        QModelIndexList lst=table->selectionModel()->selectedIndexes();
        if(lst.size()<1)return;
@@ -195,11 +100,11 @@ void MShippingEditor::changeDescription()
                return;
        }
        all[idx.row()]=s;
-       updateTable();
+       updateTable();*/
 }
 
 void MShippingEditor::changePrice()
-{
+{/*TODO
        //find item
        QModelIndexList lst=table->selectionModel()->selectedIndexes();
        if(lst.size()<1)return;
@@ -216,10 +121,10 @@ void MShippingEditor::changePrice()
                return;
        }
        all[idx.row()]=s;
-       updateTable();
+       updateTable();*/
 }
 void MShippingEditor::changeAvail()
-{
+{/*TODO
        //find item
        QModelIndexList lst=table->selectionModel()->selectedIndexes();
        if(lst.size()<1)return;
@@ -241,10 +146,10 @@ void MShippingEditor::changeAvail()
                return;
        }
        all[idx.row()]=s;
-       updateTable();
+       updateTable();*/
 }
 void MShippingEditor::addNew()
-{
+{/*TODO
        //get data
        //TODO: use a single dialog
        QString dsc=QInputDialog::getText(this,tr("Shipping Option Description"),tr("Please select a new description for this new shipping option:"));
@@ -269,11 +174,11 @@ void MShippingEditor::addNew()
                return;
        }
        all.append(s);
-       updateTable();
+       updateTable();*/
 }
 
 void MShippingEditor::deleteShip()
-{
+{/*TODO
        //find item
        QModelIndexList lst=table->selectionModel()->selectedIndexes();
        if(lst.size()<1)return;
@@ -289,5 +194,5 @@ void MShippingEditor::deleteShip()
                return;
        }
        all.removeAt(idx.row());
-       updateTable();
+       updateTable();*/
 }
index f0be5b4..58815aa 100644 (file)
 #include <QString>
 #include <QDialog>
 
-class QDomElement;
-class MWebRequest;
-
-/**this class represents a shipping type*/
-class MShipping
-{
-       public:
-               /**creates an invalid (empty) shipping type; if the MWebRequest pointer is given the object can later be saved to the DB*/
-               MShipping(MWebRequest*r=0);
-               /**creates a shipping type from XML*/
-               MShipping(MWebRequest*,const QDomElement&);
-               /**copies a shipping type*/
-               MShipping(const MShipping&);
-               /**copies a shipping type*/
-               MShipping& operator=(const MShipping&);
-               
-               /**returns whether the shipping type is valid*/
-               bool isValid()const;
-               
-               /**returns the ID of the shipping type*/
-               int id()const;
-               
-               /**returns the price (cent) of the type*/
-               int price()const;
-               
-               /**returns the price as string*/
-               QString priceString(int off=0)const;
-               
-               /**returns whether the type is usable via web interface*/
-               bool webUsable()const;
-               
-               /**returns whether the type is usable by any user*/
-               bool anyUserCanUse()const;
-               
-               /**returns whether the currently open session/user can use it*/
-               bool canUse()const;
-               
-               /**returns the description of the type*/
-               QString description()const;
-               
-               /**changes the price (does not write to the DB, use save())*/
-               void setPrice(int);
-               
-               /**changes whether web users can use it (does not write to the DB, use save())*/
-               void setWebUsable(bool);
-               
-               /**change whether any user can use it (does not write to the DB, use save())*/
-               void setAnyUserCanUse(bool);
-               
-               /**change the description (does not write to the DB, use save())*/
-               void setDescription(QString);
-               
-               /**save data to the database (if the object did not come from the DB or if asnew is true it will be created); returns true on success*/
-               bool save(bool asnew=false);
-       private:
-               MWebRequest*req;
-               int m_id,m_price;
-               bool m_web,m_any;
-               QString m_descr;
-};
-
 class QStandardItemModel;
 class QTableView;
 
+#include "MOShipping.h"
+
 class MShippingEditor:public QDialog
 {
        Q_OBJECT
        public:
-               MShippingEditor(MWebRequest*,QWidget*);
+               MShippingEditor(QWidget*);
        
        private slots:
                void changeDescription();
@@ -95,8 +36,7 @@ class MShippingEditor:public QDialog
                void updateTable();
                
        private:
-               MWebRequest*req;
-               QList<MShipping>all;
+               QList<MOShipping>all;
                QStandardItemModel*model;
                QTableView*table;
 };
index 8be0349..5283ee5 100644 (file)
@@ -31,7 +31,6 @@ SOURCES = \
        overview.cpp \
        eventedit.cpp \
        event.cpp \
-       room.cpp \
        user.cpp \
        host.cpp \
        order.cpp \
@@ -48,7 +47,8 @@ SOURCES = \
        office.cpp \
        moneylog.cpp \
        autoupdate.cpp \
-       domquery.cpp
+       domquery.cpp \
+       msinterface.cpp
 
 HEADERS = \
        keygen.h \
@@ -58,7 +58,6 @@ HEADERS = \
        overview.h \
        eventedit.h \
        event.h \
-       room.h \
        user.h \
        host.h \
        order.h \
@@ -75,7 +74,8 @@ HEADERS = \
        office.h \
        moneylog.h \
        autoupdate.h \
-       domquery.h
+       domquery.h \
+       msinterface.h
 
 #some PHP files are listed in this file to scan them for translatable items
 #use genphpscan.sh to regenerate it.
index f0bd492..3642310 100644 (file)
@@ -28,7 +28,7 @@
 #include "main.h"
 #include "templatedlg.h"
 #include "templates.h"
-#include "webrequest.h"
+#include "msinterface.h"
 
 #include <QCoreApplication>
 #include <QDateTime>
 #include <QSettings>
 #include <QStringList>
 
+#define req (MSInterface::instance())
 
-MTemplateStore::MTemplateStore(MWebRequest*r,QString p)
+MTemplateStore::MTemplateStore(QString p)
 {
-       req=r;
        profileid=p;
 }
 
@@ -84,7 +84,7 @@ struct STemp{
 };
 
 void MTemplateStore::updateTemplates(bool force)
-{
+{/*TODO
        //basics
        QString dname=req->dataDir()+"/templates/";
        QSettings set;
@@ -170,11 +170,11 @@ void MTemplateStore::updateTemplates(bool force)
                STemp s=fmap[files[i]];
                set.setValue(s.fname+"/checksum",s.checksum);
                set.setValue(s.fname+"/description",s.descr);
-       }
+       }*/
 }
 
 bool MTemplateStore::retrieveFile(QString dname,QString fn)
-{
+{/*TODO
        //request
        if(!req->request("gettemplate",fn.toUtf8()))return false;
        if(req->responseStatus()!=MWebRequest::Ok)return false;
@@ -183,10 +183,11 @@ bool MTemplateStore::retrieveFile(QString dname,QString fn)
        if(!f.open(QIODevice::WriteOnly|QIODevice::Truncate))return false;
        f.write(req->responseBody());
        return true;
+       */return false;
 }
 
 bool MTemplateStore::setTemplate(QString n,QString f)
-{
+{/*TODO
        //very rough sanity check
        QRegExp fregexp("[a-z0-9_\\.,]+");
        if(!fregexp.exactMatch(n))return false;
@@ -208,11 +209,11 @@ bool MTemplateStore::setTemplate(QString n,QString f)
        set.setValue("templates/"+profileid+"/lastupdate",0);
        QFile(req->dataDir()+"/templates/"+n).remove();
        //return success
-       return true;
+       return true;*/return false;
 }
 
 bool MTemplateStore::deleteTemplate(QString n)
-{
+{/*TODO
        //very rough sanity check
        QRegExp fregexp("[a-z0-9_\\.,]+");
        if(!fregexp.exactMatch(n))return false;
@@ -225,11 +226,11 @@ bool MTemplateStore::deleteTemplate(QString n)
        QSettings set;
        set.remove("templates/"+profileid+"/"+n);
        QFile(req->dataDir()+"/templates/"+n).remove();
-       return true;
+       return true;*/return false;
 }
 
 bool MTemplateStore::setTemplateDescription(QString n,QString d)
-{
+{/*TODO
        //very rough sanity check
        QRegExp fregexp("[a-z0-9_\\.,]+");
        if(!fregexp.exactMatch(n))return false;
@@ -247,7 +248,7 @@ bool MTemplateStore::setTemplateDescription(QString n,QString d)
        //update internal description
        set.setValue("description",d);
        //return success
-       return true;
+       return true;*/return false;
 }
 
 QList<MTemplate> MTemplateStore::allTemplates()
index b4a2d29..08e5aa4 100644 (file)
@@ -15,8 +15,6 @@
 
 #include <QString>
 
-class MWebRequest;
-
 /**this class wraps a single template*/
 class MTemplate
 {
@@ -107,10 +105,10 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(MTemplate::Types)
 class MTemplateStore
 {
        protected:
-               friend class MWebRequest;
+               //FIXME friend class MWebRequest;
                friend class MTemplateEditor;
                /**instantiates the template subsystem*/
-               MTemplateStore(MWebRequest*,QString);
+               MTemplateStore(QString);
                
                /**stores a specific template*/
                bool setTemplate(QString templatename,QString localfile);
@@ -139,7 +137,6 @@ class MTemplateStore
                MTemplate getTemplate(QString);
                
        private:
-               MWebRequest*req;
                QString profileid;
 };
 
index f4503c3..37ec766 100644 (file)
@@ -470,7 +470,7 @@ class MTicketLabel:public MLabel
 
 QString MTicketLabel::getVariable(QString var)const
 {
-       if(var=="TICKETID"||var=="BARCODE")return tick.ticketID();
+       if(var=="TICKETID"||var=="BARCODE")return tick.ticketid();
        if(var=="PRICE")return tick.priceString();
        if(var=="DATETIME")return tick.event().startTimeString();
        if(var=="ROOM")return tick.event().room();
@@ -496,7 +496,7 @@ class MVoucherLabel:public MLabel
 
 QString MVoucherLabel::getVariable(QString var)const
 {
-       if(var=="VOUCHERID"||var=="BARCODE")return vouc.voucherID();
+       if(var=="VOUCHERID"||var=="BARCODE")return vouc.voucherid();
        if(var=="PRICE")return vouc.priceString();
        if(var=="VALUE")return vouc.valueString();
        return "";
index 7716009..e16afb8 100644 (file)
 //
 
 #include "user.h"
-#include "webrequest.h"
+#include "msinterface.h"
 
 #include <QCoreApplication>
 #include <QDomElement>
 #include <QRegExp>
 
-MUser::MUser(MWebRequest*r,QDomElement&e)
-{
-       req=r;
-       m_userid=e.attribute("name").trimmed();
-       m_descr=e.text().trimmed();
-}
-
-MUser::MUser(MWebRequest*r,QString n)
-{
-       req=r;
-       m_userid=n;
-}
-
-MUser::MUser()
-{
-       req=0;
-}
-
-MUser::MUser(const MUser&u)
-{
-       req=u.req;
-       m_userid=u.m_userid;
-       m_descr=u.m_descr;
-}
-
-QString MUser::userId()
-{
-       return m_userid;
-}
-
-QString MUser::description()
-{
-       return m_descr;
-}
+#define req (MSInterface::instance())
 
 bool MUser::isValid()
 {
-       return QRegExp("[A-Za-z0-9_\\.,:-]+").exactMatch(m_userid);
+       return QRegExp("[A-Za-z0-9_\\.,:-]+").exactMatch(name().value());
 }
 
 bool MUser::create(QString pwd)
 {
        //do not attempt to save invalid or incomplete data
        if(!isValid())return false;
-       //create XML
-       QDomDocument doc;
-       QDomElement root=doc.createElement("Users");
-       QDomElement el=doc.createElement("User");
-       el.setAttribute("name",m_userid);
-       el.setAttribute("passwd",pwd);
-       el.appendChild(doc.createTextNode(m_descr));
-       root.appendChild(el);
-       doc.appendChild(root);
        //call
-       req->request("adduser",doc.toByteArray());
+       MTCreateUser cu=req->queryCreateUser(name(),pwd);
        //check success
-       if(req->responseStatus()==MWebRequest::Ok){
-               //TODO: check response content for myself, return false if not found
+       if(cu.stage()==cu.Success){
+               operator=(cu.getuser().value());
                return true;
        }else{
                return false;
@@ -85,16 +43,10 @@ bool MUser::changePassword(QString pwd)
 {
        //do not attempt to save invalid or incomplete data
        if(!isValid())return false;
-       //create XML
-       QDomDocument doc;
-       QDomElement el=doc.createElement("SetPasswd");
-       el.setAttribute("user",m_userid);
-       el.setAttribute("newpwd",pwd);
-       doc.appendChild(el);
        //call
-       req->request("setpasswd",doc.toByteArray());
+       MTChangePassword cp=req->queryChangePassword(name(),pwd);
        //check success
-       if(req->responseStatus()==MWebRequest::Ok){
+       if(cp.stage()==cp.Success){
                return true;
        }else{
                return false;
@@ -104,31 +56,22 @@ bool MUser::changePassword(QString pwd)
 QString MUser::deleteUser(QString replace)
 {
        if(!isValid())return QCoreApplication::translate("MUser","User not valid: cannot delete.");
-       QByteArray rplc;
-       if(replace.trimmed()!="")rplc="\n"+replace.trimmed().toUtf8();
-       bool b=req->request("deleteuser",m_userid.toUtf8()+rplc);
-       b&=req->responseStatus()==MWebRequest::Ok;
-       if(!b)return " "+QCoreApplication::translate("php::",req->responseBody());
-       else return QString();
+       MTDeleteUser du=req->queryDeleteUser(name(),replace);
+       if(du.stage()!=du.Success)
+               return " "+QCoreApplication::translate("php::",du.errorString().toAscii());
+       else
+               return QString();
 }
 
 bool MUser::setDescription(QString d)
 {
-       m_descr=d;
        //do not attempt to save invalid or incomplete data
        if(!isValid())return false;
-       //create XML
-       QDomDocument doc;
-       QDomElement root=doc.createElement("Users");
-       QDomElement el=doc.createElement("User");
-       el.setAttribute("name",m_userid);
-       el.appendChild(doc.createTextNode(m_descr));
-       root.appendChild(el);
-       doc.appendChild(root);
        //call
-       req->request("setuserdescription",doc.toByteArray());
+       MTSetUserDescription sud=req->querySetUserDescription(name(),d);
        //check success
-       if(req->responseStatus()==MWebRequest::Ok){
+       if(sud.stage()==sud.Success){
+               setdescription(d);
                return true;
        }else{
                return false;
@@ -138,20 +81,13 @@ bool MUser::setDescription(QString d)
 MCheckList MUser::getRoles()
 {
        //call
-       req->request("getuseracl",m_userid.toUtf8());
+       MTGetUserRoles gr=req->queryGetUserRoles(name());
        //check success
        MCheckList ret;
-       if(req->responseStatus()==MWebRequest::Ok){
-               QDomDocument doc;
-               if(!doc.setContent(req->responseBody()))return ret;
-               QDomNodeList nl=doc.documentElement().elementsByTagName("Role");
-               for(int i=0;i<nl.size();i++){
-                       QDomElement el=nl.at(i).toElement();
-                       if(el.isNull())continue;
-                       QString name=el.attribute("name");
-                       bool set=el.attribute("set","0").toInt();
-                       ret.addItem(new MAcl(name,set));
-               }
+       if(gr.stage()==gr.Success){
+               QList<MOUserRole>lr=gr.getroles();
+               for(int i=0;i<lr.size();i++)
+                       ret.addItem(new MAcl(lr[i].username(),lr[i].isset()));
        }
        return ret;
 }
@@ -159,38 +95,29 @@ MCheckList MUser::getRoles()
 bool MUser::setRoles(const MCheckList&cl)
 {
        //create DOM
-       QDomDocument doc;
-       QDomElement root=doc.createElement("ACL");
-       root.setAttribute("user",m_userid);
+       QList<MOUserRole>lr;
        for(int i=0;i<cl.size();i++){
-               QDomElement el=doc.createElement("Role");
-               el.setAttribute("name",cl[i].key());
-               el.setAttribute("set",cl[i].isSet()?"1":"0");
-               root.appendChild(el);
+               MOUserRole ur;
+               ur.setusername(cl[i].key());
+               ur.setisset(cl[i].isSet());
+               lr.append(ur);
        }
-       doc.appendChild(root);
        //request
-       req->request("setuseracl",doc.toByteArray());
-       if(req->responseStatus()==MWebRequest::Ok)return true;
+       MTSetUserRoles sur=req->querySetUserRoles(name(),lr);
+       if(sur.stage()==sur.Success)return true;
        else return false;
 }
 
 MCheckList MUser::getHosts()
 {
        //call
-       req->request("getuserhosts",m_userid.toUtf8());
+       MTGetUserHosts gh=req->queryGetUserHosts(name());
        //check success
        MCheckList ret;
-       if(req->responseStatus()==MWebRequest::Ok){
-               QDomDocument doc;
-               if(!doc.setContent(req->responseBody()))return ret;
-               QDomNodeList nl=doc.documentElement().elementsByTagName("Host");
-               for(int i=0;i<nl.size();i++){
-                       QDomElement el=nl.at(i).toElement();
-                       if(el.isNull())continue;
-                       QString name=el.attribute("name");
-                       bool set=el.attribute("set","0").toInt();
-                       ret.addItem(new MUserHost(name,set));
+       if(gh.stage()==gh.Success){
+               QList<MOHostAcl> hl=gh.gethosts();
+               for(int i=0;i<hl.size();i++){
+                       ret.addItem(new MUserHost(hl[i]));
                }
        }
        return ret;
@@ -199,19 +126,16 @@ MCheckList MUser::getHosts()
 bool MUser::setHosts(const MCheckList&cl)
 {
        //create DOM
-       QDomDocument doc;
-       QDomElement root=doc.createElement("Hosts");
-       root.setAttribute("user",m_userid);
+       QList<MOHostAcl> hal;
        for(int i=0;i<cl.size();i++){
-               QDomElement el=doc.createElement("Host");
-               el.setAttribute("name",cl[i].key());
-               el.setAttribute("set",cl[i].isSet()?"1":"0");
-               root.appendChild(el);
+               MOHostAcl ha;
+               ha.sethostname(cl[i].key());
+               ha.setisset(cl[i].isSet());
+               hal.append(ha);
        }
-       doc.appendChild(root);
        //request
-       req->request("setuserhosts",doc.toByteArray());
-       if(req->responseStatus()==MWebRequest::Ok)return true;
+       MTSetUserHosts suh=req->querySetUserHosts(name(),hal);
+       if(suh.stage()==suh.Success)return true;
        else return false;
 }
 
@@ -292,6 +216,12 @@ MUserHost::MUserHost(QString h,bool s)
        m_set=s;
 }
 
+MUserHost::MUserHost(const MOHostAcl&a)
+{
+       m_host=a.hostname();
+       m_set=a.isset();
+}
+
 QString MUserHost::host()const
 {
        return m_host;
index 7e564be..98bae85 100644 (file)
 
 #include "checkdlg.h"
 
-class MWebRequest;
-class QDomElement;
+#include "MOUser.h"
 
-class MUser
+class MUser:public MOUser
 {
        public:
                /**create invalid user*/
-               MUser();
+               MUser():MOUser(){}
                /**create user by name*/
-               MUser(MWebRequest*,QString);
-               /**create user from XML element*/
-               MUser(MWebRequest*,QDomElement&);
+               MUser(QString i){setname(i);}
                /**copy user*/
-               MUser(const MUser&);
+               MUser(const MUser&u):MOUser(u){}
                
-               /**returns user name*/
-               QString userId();
-               /**returns user description*/
-               QString description();
+               /**copy user*/
+               MUser& operator=(const MOUser&u){MOUser::operator=(u);return *this;}
                
                /**checks user name*/
                bool isValid();
@@ -63,10 +58,6 @@ class MUser
                
                /**change the password of this user; returns whether successful*/
                bool changePassword(QString);
-               
-       private:
-               MWebRequest*req;
-               QString m_userid,m_descr;
 };
 
 /**overwrites MCheckItem to represent an ACL item for the user*/
@@ -97,6 +88,7 @@ class MAcl:public MCheckItem
                bool m_set;
 };
 
+class MOHostAcl;
 /**overwrites MCheckItem to represent a host item for the user*/
 class MUserHost:public MCheckItem
 {
@@ -104,6 +96,7 @@ class MUserHost:public MCheckItem
                MUserHost();
                MUserHost(const MUserHost&);
                MUserHost(QString,bool);
+               MUserHost(const MOHostAcl&);
                
                /**returns the host this item represents*/
                virtual QString host()const;
index 232c0a3..aba27a7 100644 (file)
 
 WTransaction::WTransaction(QString ifc)
 {
-       m_haserror=false;
+       m_stage=Uninitialized;
+       m_qsource=None;
        m_httpid=-1;
        m_iface=ifc;
 }
 WTransaction::WTransaction(const WTransaction&t)
        :QObject()
 {
-       m_haserror=t.m_haserror;
+       m_stage=t.m_stage;
+       m_qsource=t.m_qsource;
        m_errstr=t.m_errstr;
        m_errtype=t.m_errtype;
        m_iface=t.m_iface;
@@ -56,13 +58,14 @@ QByteArray WTransaction::executeQuery(QString hreq,QByteArray data)
        //show the user we are waiting
        WaitCursor wc;
        //set up request
+       m_qsource=Web;
        QString log;
        QEventLoop loop(this);
        connect(this,SIGNAL(webFinished()),&loop,SLOT(quit()));
        WInterface *iface=WInterface::instance(m_iface);
        if(!iface){
                qDebug("Error: transaction cannot find interface.");
-               m_haserror=true;
+               m_stage=Error;
                m_errtype="_iface";
                return QByteArray();
        }
@@ -103,7 +106,7 @@ QByteArray WTransaction::executeQuery(QString hreq,QByteArray data)
        loop.exec();
        m_httpid=-1;
        //process result
-       if(m_haserror && m_errtype=="_timeout"){
+       if(m_stage==Error && m_errtype=="_timeout"){
                //it did not finish yet, caught a timeout.
                req.abort();
                m_errstr="Web Request timed out.";
@@ -113,7 +116,7 @@ QByteArray WTransaction::executeQuery(QString hreq,QByteArray data)
                return QByteArray();
        }else
        //finished with low-level error?
-       if(m_haserror){
+       if(m_stage==Error){
                m_errstr="HTTP Error: "+req.errorString();
                log+=QString("Request %2 finished with HTTP level error: %1").arg(m_errstr).arg(m_httpid);
                //TODO: if(loglvl&LogOnError)
@@ -125,7 +128,7 @@ QByteArray WTransaction::executeQuery(QString hreq,QByteArray data)
        if(rsph.statusCode()!=200){
                m_errstr="HTTP Error, return code "+QString::number(rsph.statusCode())+" "+rsph.reasonPhrase();
                m_errtype="_HTTP";
-               m_haserror=true;
+               m_stage=Error;
                log+=QString("Request %2 finished with HTTP level error: %1").arg(m_errstr).arg(m_httpid);
                //TODO: if(loglvl&LogOnError)
                        qDebug()<<log;
@@ -138,6 +141,7 @@ QByteArray WTransaction::executeQuery(QString hreq,QByteArray data)
                log+=QString ("----->\nHTTP Response %3 Headers:\n%1\nHTTP Response %3 Body:\n%2\n<------------------").arg(rsph.toString()).arg(esc(rspdata)).arg(m_httpid);
                qDebug()<<log;
        //}
+       if(m_stage!=Error)m_stage=Success;
        return rspdata;
 }
 
@@ -145,7 +149,7 @@ void WTransaction::webTimeout()
 {
        if(m_httpid<0)return;
        qDebug("web timeout");
-       m_haserror=true;
+       m_stage=Error;
        m_errtype="_timeout";
        emit webFinished();
 }
@@ -155,7 +159,7 @@ void WTransaction::webReady(int i,bool e)
        qDebug("finished req %i",i);
        if(i!=m_httpid)return;
        if(e){
-               m_haserror=true;
+               m_stage=Error;
                m_errtype="_web";
        }
        emit webFinished();
index 98303d0..162c989 100644 (file)
@@ -23,7 +23,13 @@ class WTransaction:public QObject
 {
        Q_OBJECT
        public:
-               bool hasError()const{return m_haserror;}
+               enum Stage {Uninitialized,Success,Error};
+               enum QuerySource{None,Buffer,Web};
+               
+               Stage stage()const{return m_stage;}
+               QuerySource querySource()const{return m_qsource;}
+               
+               bool hasError()const{return m_stage==Error;}
                QString errorType()const{return m_errtype;}
                QString errorString()const{return m_errstr;}
        protected:
@@ -37,7 +43,8 @@ class WTransaction:public QObject
        signals:
                void webFinished();
        private:
-               bool m_haserror;
+               Stage m_stage;
+               QuerySource m_qsource;
                QString m_errtype,m_errstr,m_iface;
                int m_httpid;
 };
index 05ba216..e68c10d 100644 (file)
@@ -7,18 +7,87 @@
   - see COPYING.AGPL for details
   -->
 <Wolf>
+       <Table name="country">
+               <Column name="countryid" type="string:3" primarykey="yes"/>
+               <Column name="countryname" type="string:64" notnull="yes"/>
+               <!-- TODO: add shipping info -->
+               <Preset><V col="countryid" val="de"/><V col="countryname" val="Germany"/></Preset>
+               <Preset><V col="countryid" val="at"/><V col="countryname" val="Austria"/></Preset>
+               <Preset><V col="countryid" val="ch"/><V col="countryname" val="Switzerland"/></Preset>
+       </Table>
        <Table name="customer" backup="yes">
-              <Column name="customerid" type="seq32" primarykey="yes"/>
+               <Column name="customerid" type="seq32" primarykey="yes"/>
                //contact data
                <Column name="name" type="string" notnull="yes"/>
-               <Column name="address" type="text"/>
                <Column name="contact" type="string"/> <!-- //phone or something -->
                <Column name="comments" type="text"/>
-       </Table>
-       <Table name="webuser" backup="yes">
                //online login data
-               <Column name="email" type="string" primarykey="yes"/>
-               <Column name="customerid" type="int32" unique="yes" notnull="yes" foreignkey="customer:customerid"/>
-               <Column name="passwd" type="string:64"/> <!-- salted SHA-1 hash of passwd -->
+               <Column name="email" type="string" null="yes"/>
+               <Column name="passwd" type="string:64" null="yes"/> <!-- salted SHA-1 hash of passwd -->
        </Table>
+       <Table name="address" backup="yes">
+               <Column name="addressid" type="seq64" primarykey="yes"/>
+               <Column name="customerid" type="int32" foreignkey="customer:customerid" notnull="yes"/>
+               <Column name="name" type="string" null="yes"/>
+               <Column name="company" type="string" null="yes"/>
+               <Column name="addr1" type="string" notnull="yes"/>
+               <Column name="addr2" type="string" null="yes"/>
+               <Column name="city" type="string:64" notnull="yes"/>
+               <Column name="state" type="string:32" null="yes"/>
+               <Column name="zipcode" type="string:32" notnull="yes"/>
+               <Column name="country" type="string:3" notnull="yes" foreignkey="country:countryid"/>
+               <Column name="deleted" type="bool" notnull="yes" default="0"/>
+       </Table>
+       
+       <Class name="Country">
+               <Property name="id" type="astring"/>
+               <Property name="name" type="astring"/>
+               <ToXml name="Full">id name</ToXml>
+       </Class>
+       <Class name="Address">
+               <Property name="addressid" type="int64"/>
+               <Property name="customerid" type="int32"/>
+               <Property name="name" type="string"/>
+               <Property name="company" type="string"/>
+               <Property name="addr1" type="string"/>
+               <Property name="addr2" type="string"/>
+               <Property name="city" type="string"/>
+               <Property name="state" type="string"/>
+               <Property name="zipcode" type="string"/>
+               <Property name="countryid" type="astring"/>
+               <Property name="deleted" type="bool"/>
+               
+               <Property name="country" type="Country"/>
+               
+               <ToXml name="Full">addressid customerid name company addr1 addr2 city state zipcode countryid deleted country/Full</ToXml>
+       </Class>
+       <Class name="Customer">
+               <Property name="id" type="int"/>
+               <Property name="name" type="string"/>
+               <Property name="contact" type="string"/>
+               <Property name="comments" type="string"/>
+               //online login data
+               <Property name="email" type="string"/>
+               <Property name="passwd" type="string"/>
+               
+               <Property name="addresses" type="List:Address"/>
+               <ToXml name="Full">id name contact comments email passwd addresses/Full</ToXml>
+               <ToXml name="Short">id name</ToXml>
+       </Class>
+       
+       <Transaction name="GetCustomer">
+               <Input>
+                       <Var name="customerid" type="int"/>
+               </Input>
+               <Output>
+                       <Var name="customer" type="Customer/Full"/>
+               </Output>
+       </Transaction>
+       
+       <Transaction name="GetAllCustomerNames">
+               <Input/>
+               <Output>
+                       <Var name="customers" type="List:Customer/Short"/>
+               </Output>
+       </Transaction>
 </Wolf>
\ No newline at end of file
index b513865..2f1bcc2 100644 (file)
                <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>
+               <Property name="description" type="string"/>
+               <ToXml name="Full">id start end capacity defaultprice cancelled title artist room cancelreason description</ToXml>
+       </Class>
+       
+       <Class name="Room">
+              <Property name="id" type="string"/>
+              <Property name="capacity" type="int"/>
+              <Property name="description" type="string"/>
+              <ToXml name="Full">id capacity description</ToXml>
        </Class>
        
        <Transaction name="GetEvent">
                </Input>
                <Output/>
        </Transaction>
+       
+       <Transaction name="GetAllRooms">
+               <Input/>
+               <Output>
+                       <Var name="rooms" type="List:Room/Full"/>
+               </Output>
+       </Transaction>
 </Wolf>
\ No newline at end of file
index 08702fb..5da609c 100644 (file)
                <Property name="value" type="int"/>
                <Property name="price" type="int" optional="1"/>
                <Property name="status" type="VoucherState" optional="1"/>
+               <Property name="isused" type="bool"/>
                
                <ToXml name="Full">voucherid value price status</ToXml>
                <ToXml name="inOrder">voucherid value price status</ToXml>
        </Class>
        
-       <Class name="Order" abstract="yes">
+       <Transaction name="GetVoucher">
+               <Input>
+                       <Var name="voucherid" type="astring"/>
+               </Input>
+               <Output>
+                       <Var name="voucher" type="Voucher/Full"/>
+               </Output>
+       </Transaction>
+       
+       <!-- this class used to be abstract="yes" - dunno why.-->
+       <Class name="Order">
                <Enum name="OrderState" refColumn="order:status" />
                
                <Property name="orderid" type="int"/>
                <Property name="amountpaid" type="int"/>
                <Property name="state" type="OrderState"/>
                
-               <Property name="amountdue" type="int" abstract="yes"/>
+               <Property name="amountdue" type="int"/><!-- abstract="yes"? -->
+               
+               <Property name="totalprice" type="int"/>
+               <Property name="ordertime" type="int64"/>
+               <Property name="senttime" type="int64"/>
                <!-- etc.pp. -->
                
                <ToXml name="Short">orderid customerid seller amountpaid state amountdue</ToXml>
                <ToXml name="Full">orderid customerid seller amountpaid state amountdue tickets/inOrder vouchers/inOrder</ToXml>
        </Class>
        
+       <Transaction name="GetOrder">
+               <Input>
+                       <Var name="orderid" type="int"/>
+               </Input>
+               <Output>
+                       <Var name="order" type="Order/Full"/>
+               </Output>
+       </Transaction>
+       
        <Class name="Shipping">
               <Property name="id" type="int32" id="yes"/>
               <Property name="cost" type="int32"/> <!--default cost of this shipping type-->
index 8638141..c8a9544 100644 (file)
                <ToXml name="NoPwd">name description</ToXml>
        </Class>
        
+       <Class name="Host">
+               <Property name="name" type="string"/>
+               <!-- if hostkey is NULL it is a special host (_any, _anon, _online) -->
+               <Property name="key" type="string" />
+               <ToXml name="Full">name key</ToXml>
+       </Class>
+       
        <Transaction name="GetAllUsers">
                <Input/>
                <Output>
                        <Var name="username" type="astring"/>
                        <Var name="password" type="string"/>
                </Input>
+               <Output>
+                       <Var name="user" type="User/Full"/>
+               </Output>
+       </Transaction>
+       
+       <Transaction name="ChangePassword">
+               <Input>
+                       <Var name="username" type="astring"/>
+                       <Var name="password" type="string"/>
+               </Input>
                <Output/>
        </Transaction>
        
                        <Var name="description" type="string"/>
                </Input>
        </Transaction>
+       
+       <Class name="UserRole">
+               <Property name="username" type="astring"/>
+               <Property name="isset" type="bool"/>
+               <ToXml name="Full">username isset</ToXml>
+       </Class>
+       
+       <Transaction name="GetUserRoles">
+               <Input>
+                       <Var name="username" type="astring"/>
+               </Input>
+               <Output>
+                       <Var name="roles" type="List:UserRole/Full"/>
+               </Output>
+       </Transaction>
+       
+       <Transaction name="SetUserRoles">
+               <Input>
+                       <Var name="username" type="astring"/>
+                       <Var name="roles" type="List:UserRole/Full"/>
+               </Input>
+               <Output/>
+       </Transaction>
+       
+       <Transaction name="GetAllHostNames">
+               <Input/>
+               <Output>
+                       <Var name="hostnames" type="List:string"/>
+               </Output>
+       </Transaction>
+       
+       <Transaction name="GetAllHosts">
+               <Input/>
+               <Output>
+                       <Var name="hosts" type="List:Host/Full"/>
+               </Output>
+       </Transaction>
+       
+       <Transaction name="SetHost">
+               <Input>
+                       <Var name="name" type="astring"/>
+                       <Var name="key" type="string"/>
+               </Input>
+               <Output/>
+       </Transaction>
+       
+       <Transaction name="DeleteHost">
+               <Input>
+                       <Var name="name" type="astring"/>
+               </Input>
+               <Output/>
+       </Transaction>
+       
+       <Class name="HostAcl">
+               <Property name="hostname" type="astring"/>
+               <Property name="isset" type="bool"/>
+               <ToXml name="Full">hostname isset</ToXml>
+       </Class>
+       
+       <Transaction name="GetUserHosts">
+               <Input>
+                       <Var name="username" type="astring"/>
+               </Input>
+               <Output>
+                       <Var name="hosts" type="List:HostAcl/Full"/>
+               </Output>
+       </Transaction>
+       
+       <Transaction name="SetUserHosts">
+               <Input>
+                       <Var name="username" type="astring"/>
+                       <Var name="hosts" type="List:HostAcl/Full"/>
+               </Input>
+               <Output/>
+       </Transaction>
 </Wolf>
\ No newline at end of file
index b67e70c..d697e7e 100644 (file)
@@ -421,7 +421,7 @@ void WocQtClientOut::classSerializers(const WocClass&cls,QFile&hdr,QFile&src,QSt
                                                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";
+                                               scd+="\t\tr.appendChild(mp_"+prop+".value().toXml"+var+"(doc,\""+prop+"\"));\n";
                                        }else
                                        if(cls.propertyIsString(prop)){
                                                scd+="\t\tQDomElement el=doc.createElement(\""+prop+"\");\n";
@@ -553,16 +553,20 @@ void WocQtClientOut::newTransaction(const WocTransaction&trn)
 QString WocQtClientOut::qttype(const WocTransaction&trn,QString v,InOut io)
 {
        QString tp=io==In?trn.inputType(v):trn.outputType(v);
-       QString r;
+       QString r,e;
        if(tp.startsWith("List:")){
-               r="QList<";
+               r="QList<";e=">";
                tp=tp.mid(5);
-       }else   r="Nullable<";
+       }else
+               if(io==Out){
+                       r="Nullable<";
+                       e=">";
+               }
        if(tp=="astring" || tp=="string")r+="QString";else
        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+=">";
+       r+=e;r+=" ";
        return r;
 }