From: konrad Date: Fri, 15 Jan 2010 19:57:47 +0000 (+0000) Subject: converted to using external woc and wbases X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=b36d67fc999f491b62f35cea8ca1e3b921b719fb;p=web%2Fkonrad%2Fsmoke.git converted to using external woc and wbases git-svn-id: https://silmor.de/svn/softmagic/smoke/trunk@425 6e3c4bff-ac9f-4ac1-96c5-d2ea494d3e33 --- diff --git a/Makefile.mingw b/Makefile.mingw index 1bdb717..3df73d6 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -24,11 +24,11 @@ DOXYGEN = doxygen all: server client wob: woc - cd wob ; ../woc/woc magicsmoke.wolf + cd wob ; ../pack/woc/woc magicsmoke.wolf woc: - cd woc ; $(QMAKE) - cd woc ; $(MAKE) + cd pack/woc ; $(QMAKE) + cd pack/woc ; $(MAKE) server: wob @@ -48,4 +48,4 @@ sdoc: $(DOXYGEN) Doxyfile-cpp #tell Make that the rules above are symbolic: -.PHONY: woc wob server client sdoc zip \ No newline at end of file +.PHONY: woc wob server client sdoc zip diff --git a/Makefile.unix b/Makefile.unix index 2bf8f47..7a77aeb 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -24,14 +24,17 @@ DOXYGEN = doxygen all: server client wob: woc - cd wob ; ../woc/woc magicsmoke.wolf + cd wob ; ../pack/woc/woc magicsmoke.wolf woc: - cd woc; $(QMAKE) && $(MAKE) + cd pack/woc; $(QMAKE) && $(MAKE) + +wbase: + cd pack/qtbase; $(QMAKE) && $(MAKE) server: wob -client: wob zip +client: wob zip wbase cd src ; $(QMAKE) && $(MAKE) zip: @@ -48,8 +51,9 @@ clean: rm -rf zip/Makefile* zip/*.o zip/*.a rm -rf src/.ctmp src/Makefile* src/msmoke src/core* rm -rf src/wob www/inc/wob doc/wob wob/core* - rm -rf woc/.ctmp woc/woc woc/core* woc/Makefile* + rm -rf pack/woc/.ctmp pack/woc/woc pack/woc/core* pack/woc/Makefile* + rm -rf pack/qtbase/.ctmp pack/qtbase/libqwbase* pack/qtbase/Makefile* rm -rf doc/source-php doc/source-cpp #tell Make that the rules above are symbolic: -.PHONY: woc wob server client sdoc zip +.PHONY: woc wob server client sdoc zip wbase diff --git a/README b/README index 3306361..fd0440f 100644 --- a/README +++ b/README @@ -3,7 +3,8 @@ Magic Smoke Ticket Sale System - README Magic Smoke was written to keep track of tickets for events (like concerts or theatric plays), sell them online or through retailers. It does not keep -your books or handle any financial transactions. +your books or handle any financial transactions (except for the ability to +track whether tickets are paid). This is NOT a system for support tickets. @@ -14,7 +15,7 @@ See the HTML files in the doc directory for more information. Copyrights ----------- -(c) Konrad Rosenbaum, 2007-9 +(c) Konrad Rosenbaum, 2007-2010 (c) Peter Keller, 2007/8 Directory doc: @@ -23,15 +24,12 @@ invariant sections, but will be relicensed when SFDL is released by the FSF. See COPYING.FDL for details. (COPYING.SFDL contains the current draft of SFDL as a preview, but is currently not binding.) -Directories src, woc, mkdist: +Directories src, mkdist: The CPP-source files are licensed under GPLv3 or at your option any newer version of the license. See COPYING.GPL for details. -Directory zip -The ZIP code used by this program was copied from LinTouch and is licensed -under LGPL v.2.1. See src/zip/README and src/zip/COPYING for details. The -source has been adapted by Konrad Rosenbaum to work with Qt 4.x instead of -Qt 3.x. +Directories zip, pack: +See the README files in there for details. Directory www, wob: The web-code (PHP files) and object meta files (*.wolf) are licensed under diff --git a/doc/prog_woc.html b/doc/prog_woc.html deleted file mode 100644 index 66823d4..0000000 --- a/doc/prog_woc.html +++ /dev/null @@ -1,282 +0,0 @@ - -Web Object Compiler - -

Web Object Compiler

- -In a classic three-tier architecture (see below) there are two interface layers: data and communication. -The Web Object Compiler (woc) helps implementing these three-tier architecture interfaces.

- - - - - - - - - - -
Layer 3Client Presentation Layer
Communication InterfaceServer Abstraction Layer
Network Protocol (eg. HTTP)
Communication Abstraction Layer
Layer 2Server Business Logic
Data InterfaceDatabase Abstraction Layer
DB-Protocol (eg. LibMySQL)
Layer 1Database (eg. MySQL)
-Three Tier Architecture

- -

Overall File Format

- -Woc translates Web Object Language Files (*.wolf) into PHP or C++/Qt code. The wolf files are simple XML syntax.

- -Each wolf file must be enclosed in the <Wolf> and </Wolf> tags. The first few statements inside must describe the project itself: - -

-<Wolf>
-  <Doc>Documentation...</Doc>
-  <Project baseDir=".." wobDir="wob"/>
-  <Version comm="0100" needcomm="0100" humanReadable="1.1 alpha" svnTarget="."/>
-</Wolf>
-
- -Above the <Project> tag tells woc what the overall project directory is (relative to its current working directory) and where, relative to the baseDir, it will find all wolf files.

- -The <Doc> tag can be used to create project documentation. Each tag generates one paragraph. HTML can be embedded by escaping the "<" character as "&lt;".

- -The <Version> tag describes the communication protocol: - - - - - - - - -
AttributeDescription
commthe communication protocol described by this wolf file
needcommthe minimum communication protocol this wolf file is compatible with (attention: the processor uses ASCII string comparison, not int comparison)
humanReadablethe version number shown to the user
svnTargetif given: woc will call SVN to find out which repository revision was used
svnExeexecutable to call for subversion (default: svn)

- -The Include tag can be used to include other wolf files in the processing: -

-<Include file="user.wolf"/>
-

- -

Attribute Types

- -Boolean attributes in wolf files allow integers (0 is false, non-zere is true) or the explicit strings "yes", "true", "on" for true and "no", "false", "off" for false.

- -Integers can be entered in C notation - if it starts with 1 through 9 it is decimal, if it starts with 0 it is octal, if it starts with 0x it is hexadecimal. All integers are interpreted by woc - the generated source will always contain decimal numbers.

- -Woc is case-sensitive. - -

Chosing Outputs

- -Outputs should be declared after the basics have been declared, but before any tables, classes or transactions are declared. - -
-<QtClientOutput sourceDir="src" subDir="wob" priInclude="wob.pri"/>
-<PHPServerOutput sourceDir="www" subDir="inc/wob" extension=".php" clean="yes"/>
-<HtmlOutput sourceDir="doc" subDir="wob"/>
-
- -The attribute "sourceDir" tells woc which directory (above baseDir) is the root source directory for each sub-project, the "subDir" attribute tells it which subdirectory below the sourceDir should be used for woc's generated output. The attribute "clean" tells woc to first delete all files from that sub-directory before starting the generator. Multiple generators of the same type can be used.

- -The QtClientOutput tag tells woc to create a generator for a Qt based client - the priInclude attribute tells woc which name it should give to the QMake include for its generated output.

- -The PHPServerOutput tag tells woc to create a generator for a PHP based server. The "extension" attribute tells woc which file extension to use for the generated files (default is .php). Woc will automatically create a "autoload" (plus extension) file that should be included from the main body of the PHP project to load the automatically generated classes.

- -The HtmlOutput tag tells woc where to generate API documentation. - -

Database Abstraction Layer

- -The Database Abstraction Layer is the servers lower bound towards the database. It is a simple translation of the database structure into usable PHP objects. The woc compiler generates one class per table.

- -One of the first statements is the manifest for the database schema: - -

-<DataBase instance="dbInst" schema="dbSchema" version="00.01"/>
-
- -The attribute "instance" tells woc what variable name it should use for the database connection instance, likewise "schema" tells woc which variable represents the database schema (usually an instance of WobSchema, which is generated by woc). The "version" attribute tells woc which database schema version is described in this wolf file.

- -For each database table woc needs a description of that table: - -

-<Table name="ticket" backup="yes" base="BarcodeTable">
-  <Column name="ticketid" type="string:32" primarykey="yes"/>
-  <Column name="eventid" type="int32" foreignkey="event:eventid"/>
-  <Column name="price" type="int32" notnull="yes"/>
-  <Column name="status" type="enum32" notnull="yes">
-    <Value name="Reserved" value="0x301"/> <!--dec: 769-->
-    <Value name="Cancelled" value="0x4"/> <!--dec: 4-->
-    <Value name="MaskUsable" value="0x300"/> <!--dec: 768-->
-  </Column>
-  <Column name="orderid" type="int32" foreignkey="order:orderid" notnull="yes"/>
-</Table>
-
- -Table attributes: - - - - - -
AttributeDescription
namethe name of the table, the generated class will be Wttablename
backupbool, contains whether the table is in the backup routine (default: false)
baseoptional, contains the class that this tables class is derived from, the base class must be derived from WobTable (default is to derive from WobTable directly)

- -The Table tag can have Doc subtags to embed documentation.

- -Column attributes: - - - - - - - - - -
AttributeDescription
namethe name of the column in the database
typethe type of the column, this must be a woc type which is then translated into SQL by woc
notnull, nullbool, marks the column to (not) allow NULL values, only one of the two attributes is allowed, currently the default is to allow NULL, but this may change in the future
foreignkeydeclares a reference to a foreign key column, the syntax is "foreigntablename:column" - the table that is referenced must be declared before the current one
uniquebool, declares the column UNIQUE
primarykeybool, tells woc that this column is part of the primary key (multiple columns may be part of the primary key)
defaultdeclares a default value for the column (currently defaults for enums must be given as integer)

- -Column Types: - - - - - - - - - -
AttributeDescription
string:int, stringa string column (SQL: VARCHAR), if the :int is given the column will have that maximum length assigned, if it is not given the database maximum is used; most databases support VARCHARs up to 255 characters
int32, int64a 32-bit/64-bit integer type
enum, enum32, enum64a 32bit/64bit (enum=enum32) integer interpreted as enumeration, the column must contain "Value" tags to declare the valid values
boola boolean column (the SQL representation may vary per database system)
seq32, seq64a 32bit/64bit integer that counts up automatically (ie. that has a sequence attached to it) - this is usually only used for primary keys
texta large text field
blobbinary large object

- -All names in table descriptions must follow a very strict syntax in order to be compatible with as many database systems as possible. Woc allows names that start with letters and contain only letters, underscored and digits.

- -The Value tags for enum types function similar to enums in C++. If a value attribute is given that value is assigned to the enum symbol, if no value is given the previous one is increased by one (the first value is 0).

- -Columns can be documented by adding the description directly to the Column tag or by embedding it with a Doc tag inside the Column tag. Enum values can be documented by embedding the description between <Value> and </Value>.

- -

Communication Abstraction Layer

- -The Communication Abstraction Layer is the servers upper bound towards the client. It hides the complexities of serializing data onto the network transport protocol by providing communication classes that do this automatically. The configuration of this layer is split into two major components: communication classes and transactions. While the communication classes describe what data can be transported over the connection, the transactions describe what operations can be performed.

- -

Communication Classes

- -An example class can be seen here: - -
-<Class name="Ticket">
-  <Enum name="TicketState" refColumn="ticket:status"/>
-  <Property name="ticketid" type="astring" id="yes"/>
-  <Property name="eventid" type="int"/>
-  <Property name="price" type="int"/>
-  <Property name="status" type="TicketState"/>
-  <Property name="orderid" type="int"/>
-  
-  <ToXml name="inOrder">ticketid eventid price status</ToXml>
-  <ToXml name="Full">ticketid eventid price status orderid</ToXml>
-  
-  <Mapping table="ticket">
-    <Map column="ticketid"/>
-    <Map column="price"/>
-    <Map column="eventid"/>
-    <Map column="status"/>
-    <Map column="orderid" property="orderid"/>
-  </Mapping>
-</Class>
-
- -The "name" attribute of the Class tag gives the communication class a name by which it can be referenced. The language converters will prefix it with "WO" to make it unique and postfix it with "Abstract" if the class is declared abstract - in this case the user must derive the non-abstract class to make it usable.

- -Class attributes: - - - - -
AttributeDescription
namethe name of the class
abstract(optional) marks the class abstract

- -The Enum tag defines a local enumeration. In most cases they will simply reference an enumeration that has already been defined in a database table with a refColumn attribute (syntax: table:column), but it may also locally define its values by using the same Value tags used for database enums.

- -The Property tag defines a property of the class that can be read and written to: - - - - - - -
AttributeDescription
namethe name of the property
abstract(optional) marks the property abstract - this automatically makes the class abstract and the user has to overwrite the getter and setter methods
id(optional, default=no) marks the property to identify the instance in a cache
type(mandatory) defines the type of the property, see below

- -Property types: - - - - - -the name of an enum defined in the same class is possible, local storage is as integer, transport is as string equalling the symbolic name of the value in an attribute - - -
TypeDescription
intan integer - it is at least a 32bit signed type; it is transported as attribute
astringa string that can be safely stored in a XML attribute
stringa string that is transported as element and can reach any length
EnumName
ClassNamethe name of a defined class makes the property an instance of that class; they are transported as sub-elements of this class
List:*prefixing the type with "List:" makes the property a list of that type - any of the above types can be made into lists; on transport list values are always serialized as elements

- -The Mapping tag can be used to provide a shortcut cast between a database table type and the communication class type. This is provided for the trivial case in which no transformations between the database query result and the transport data is necessary. If the property attribute is ommitted a property with the same name as the listed column is looked for.

- -The ToXml tag provides valid serializations. Each serialization must have a name - the language converters prefix them with "toString" and "toXml" to build a method names. The text of the tag simply lists all properties that should be contained in the serialization separated by spaces. Properties that are communication classes (or lists thereof) must also list the proper serialization function of that communication class, eg. Order serialized thus: - -

-<ToXml name="Full">orderid customerid seller amountpaid state amountdue tickets/inOrder vouchers/inOrder</ToXml>
-
- -Above the property "tickets" is a list of Ticket and "inOrder" is a serialization defined above for Ticket.

- -Classes can be documented by adding Doc subtags. Properties can be documented by adding the description directly into the Property tag. Enum values can be documented by adding the description directly into the Value tag. - - -

Transactions

- -
-<Transaction name="GetTicket">
-  <Input>
-    <Var name="ticketid" type="astring"/>
-    <Call lang="php" method="getTicketFunction"/>
-  </Input>
-  <Output>
-    <Var name="ticket" type="Ticket/Full"/>
-  </Output>
-</Transaction>
-
- -Each transaction must have a name that identifies it. This name is used in the wire protocol to correctly identify the currently requested transaction. - -Transaction attributes: - - - - -
AttributeDescription
namethe name of the transaction
mode(optional, default=checked) can be used to require less restrictive privileges, see below for values

- -Transaction modes: - - - - - -
ModeDescription
checkedthe default mode: the session must be authenticated and the user must have the privilege to execute this query
auththe session must be authenticated, but no special privilege is required; this can for example be used for the logout function or a function query information about the session itself
openno session is necessary for this to work; usually this is only done for login

- -Input defines the input parameters (Var tag) of the transaction (ie. what is sent to the server) and what function is called (Call tag) once the transaction has been checked and authenticated.

- -Output defines the data (Var tag) sent back to the client.

- -Var attributes: - - - - -
AttributeDescription
namethe name of the variable
typetype of the attribute; all types allowed for class properties (except enums) are allowed here

- -Call attributes: - - - - -
AttributeDescription
langthe language binding this refers to (currently only "php")
methodthe function to call - it must take exactly one argument: the transaction object

- -Transactions are represented as classes. On the client side they are used to execute the query and to represent the result. On the server side they internally verify the input and authenticate the transaction and are then used to take and encode the output or possible error conditions.

- -Transactions can be documented by adding Doc tags. Inputs and Outputs can be documented by adding the description directly into the Var tags. - - -

Server Abstraction Layer

- -This is the clients lower bound towards the server. It takes care of basic tasks like authentication, communication, serializing and deserializing data and keeping a cache of some important objects. - - - \ No newline at end of file diff --git a/src/libs.pri b/src/libs.pri new file mode 100644 index 0000000..9dbd1cf --- /dev/null +++ b/src/libs.pri @@ -0,0 +1,4 @@ +# Libraries for Magic Smoke by (c) Konrad Rosenbaum, 2007-2010 + +LIBS += -L../zip -lzip -L../pack/qtbase -lqwbase +INCLUDEPATH += ../zip ../pack/qtbase diff --git a/src/misc/domquery.cpp b/src/misc/domquery.cpp deleted file mode 100644 index 056fc2d..0000000 --- a/src/misc/domquery.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// -// C++ Implementation: domquery -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#include "domquery.h" - - -MDomQuery::MDomQuery(const QDomDocument&start,QString path) -{ - construct(start.documentElement(),path); -} - -MDomQuery::MDomQuery(const QDomElement&start,QString path) -{ - construct(start,path); -} - -void MDomQuery::construct(const QDomElement&start,QString path) -{ - //split query - QStringList ql=path.split("/",QString::SkipEmptyParts); - //determine start mode and initialize list - MDomNodeList ndlst; - if(path.startsWith("//")){ - QDomDocument doc=start.ownerDocument(); - if(ql.size()<1){ - qDebug("MDomQuery: // query must not be empty!"); - return; - } - if(ql[0]=="*" || ql[0]=="@*"){ - qDebug("MDomQuery: // query must not start with wildcard * or @*."); - return; - } - if(ql[0].startsWith("@")){ - qDebug("MDomQuery: cannot start with attributes in a // query."); - return; - }else{ - ndlst=doc.elementsByTagName(ql[0]); - ql.removeFirst(); - } - }else - if(path.startsWith("/")){ - QDomElement root=start.ownerDocument().documentElement(); - if(ql.size()<1){ - //hmm, guess what the user really wanted (assume "/ *" ) - m_result<0){ - MDomNodeList lst2; - //parse pattern - if(ql[0].startsWith("@")){ - //attribute handling... - if(ql.size()>1){ - qDebug("MDomQuery: cannot sub-parse attributes."); - return; - } - if(ql[0]=="@*"){ - //get all attributes of all current elements - for(int i=0;i, (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_DOMQUERY_H -#define MAGICSMOKE_DOMQUERY_H - - -#include -#include -#include - -/**Helper class: more flexible version of QDomNodeList*/ -class MDomNodeList:public QList -{ - public: - MDomNodeList(){} - MDomNodeList(const MDomNodeList&l):QList(l){} - MDomNodeList(const QList&l):QList(l){} - MDomNodeList(const QDomNodeList&l){for(int i=0;i -mousereturn all child elements of the current element that are called "mouse" -\@mousereturn all attribute nodes of the current element that are called "mouse" -*returns all child elements of the current element -\@*returns all attributes of the current element -/*returns the root element of the document irrespective of name -/mousereturns the root element of the document if it has the tag name "mouse" or an empty list -/*/mousereturns all elements directly below the root element that are called "mouse" -//mousereturns all elements in the document that are called "mouse" -mouse/\@trap/doorsyntax error, attributes cannot have children - -*/ -class MDomQuery -{ - public: - /**creates the query object and executes the query*/ - MDomQuery(const QDomElement&start,QString path); - - /**creates the query object and executes the query; this is equivalent to calling the query with the document element as starting point*/ - MDomQuery(const QDomDocument&start,QString path); - - /**returns the search result as a single string, if there were multiple matches, they are separated by spaces*/ - QString toString()const; - /**returns the search result as a list of strings, one string element per match*/ - QStringList toStringList()const; - /**returns the result as a list of DOM nodes*/ - MDomNodeList toNodeList()const{return m_result;} - - /**cast to QString: see toString()*/ - operator QString()const{return toString();} - /**cast to QStringList: see toStringList()*/ - operator QStringList()const{return toStringList();} - /**cast to DOM node list: see toNodeList()*/ - operator MDomNodeList()const{return m_result;} - private: - MDomNodeList m_result; - - //helper for constructor - void construct(const QDomElement&start,QString path); -}; - -#endif diff --git a/src/misc/misc.pri b/src/misc/misc.pri index 0f4e172..1be2fbf 100644 --- a/src/misc/misc.pri +++ b/src/misc/misc.pri @@ -1,12 +1,10 @@ HEADERS += \ misc/debug.h \ - misc/misc.h \ - misc/domquery.h + misc/misc.h SOURCES += \ misc/code39.cpp \ misc/debug.cpp \ - misc/misc.cpp \ - misc/domquery.cpp + misc/misc.cpp INCLUDEPATH += ./misc \ No newline at end of file diff --git a/src/smoke.pro b/src/smoke.pro index b3ec9ee..95e15d9 100644 --- a/src/smoke.pro +++ b/src/smoke.pro @@ -5,7 +5,7 @@ TARGET = ../src/msmoke #CONFIG += release CONFIG += debug -CONFIG += qt thread +CONFIG += qt thread link_prl QT += xml network win32-* { @@ -32,9 +32,8 @@ TRANSLATIONS = \ smoke_en.ts -include(zip.pri) +include(libs.pri) include(widgets/widgets.pri) -include(wbase/wbase.pri) include(templates/templates.pri) include(iface/iface.pri) include(misc/misc.pri) diff --git a/src/widgets/waitcursor.cpp b/src/widgets/waitcursor.cpp deleted file mode 100644 index 09959b8..0000000 --- a/src/widgets/waitcursor.cpp +++ /dev/null @@ -1,26 +0,0 @@ -// -// C++ Implementation: waitcursor -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#include "waitcursor.h" - -#include -#include - -WaitCursor::WaitCursor() -{ - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); -} - -WaitCursor::~WaitCursor() -{ - QApplication::restoreOverrideCursor(); -} diff --git a/src/widgets/waitcursor.h b/src/widgets/waitcursor.h deleted file mode 100644 index fa69615..0000000 --- a/src/widgets/waitcursor.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// C++ Interface: waitcursor -// -// Description: -// -// -// Author: Konrad Rosenbaum , (C) 2009 -// -// Copyright: See README/COPYING files that come with this distribution -// -// - -#ifndef MAGICSMOKE_WAITCURSOR_H -#define MAGICSMOKE_WAITCURSOR_H - -/**simple class to show a busy-cursor while an instance of it exists*/ -class WaitCursor -{ - public: - /**displays a wait cursor (Qt::WaitCursor)*/ - WaitCursor(); - /**restores the last normal cursor*/ - ~WaitCursor(); -}; - - -#endif diff --git a/src/widgets/widgets.pri b/src/widgets/widgets.pri index b6ff5eb..f758a46 100644 --- a/src/widgets/widgets.pri +++ b/src/widgets/widgets.pri @@ -1,13 +1,11 @@ HEADERS += \ - widgets/waitcursor.h \ widgets/centbox.h \ widgets/listview.h \ widgets/treeview.h SOURCES += \ - widgets/waitcursor.cpp \ widgets/centbox.cpp \ widgets/listview.cpp \ widgets/treeview.cpp -INCLUDEPATH += ./widgets \ No newline at end of file +INCLUDEPATH += ./widgets diff --git a/src/zip.pri b/src/zip.pri deleted file mode 100644 index dcc373b..0000000 --- a/src/zip.pri +++ /dev/null @@ -1,6 +0,0 @@ -# Include for ZIP-Library from LinTouch Project -# -# Modified for Magic Smoke by (c) Konrad Rosenbaum, 2007 - -LIBS += -L../zip -lzip -INCLUDEPATH += ../zip \ No newline at end of file diff --git a/www/inc/wbase b/www/inc/wbase new file mode 120000 index 0000000..163737d --- /dev/null +++ b/www/inc/wbase @@ -0,0 +1 @@ +../../pack/phpbase \ No newline at end of file