summaryrefslogtreecommitdiffstats
path: root/kode/kwsdl/kung
diff options
context:
space:
mode:
Diffstat (limited to 'kode/kwsdl/kung')
-rw-r--r--kode/kwsdl/kung/Makefile.am12
-rw-r--r--kode/kwsdl/kung/binaryinputfield.cpp186
-rw-r--r--kode/kwsdl/kung/binaryinputfield.h83
-rw-r--r--kode/kwsdl/kung/boolinputfield.cpp81
-rw-r--r--kode/kwsdl/kung/boolinputfield.h54
-rw-r--r--kode/kwsdl/kung/complexbaseinputfield.cpp155
-rw-r--r--kode/kwsdl/kung/complexbaseinputfield.h41
-rw-r--r--kode/kwsdl/kung/conversationmanager.h37
-rw-r--r--kode/kwsdl/kung/dateinputfield.cpp81
-rw-r--r--kode/kwsdl/kung/dateinputfield.h55
-rw-r--r--kode/kwsdl/kung/dispatcher.cpp153
-rw-r--r--kode/kwsdl/kung/dispatcher.h58
-rw-r--r--kode/kwsdl/kung/doubleinputfield.cpp94
-rw-r--r--kode/kwsdl/kung/doubleinputfield.h55
-rw-r--r--kode/kwsdl/kung/enuminputfield.cpp86
-rw-r--r--kode/kwsdl/kung/enuminputfield.h55
-rw-r--r--kode/kwsdl/kung/generalconversationmanager.cpp51
-rw-r--r--kode/kwsdl/kung/generalconversationmanager.h43
-rw-r--r--kode/kwsdl/kung/inputdialog.cpp32
-rw-r--r--kode/kwsdl/kung/inputdialog.h33
-rw-r--r--kode/kwsdl/kung/inputfield.cpp102
-rw-r--r--kode/kwsdl/kung/inputfield.h146
-rw-r--r--kode/kwsdl/kung/inputfieldfactory.cpp123
-rw-r--r--kode/kwsdl/kung/inputfieldfactory.h69
-rw-r--r--kode/kwsdl/kung/integerinputfield.cpp132
-rw-r--r--kode/kwsdl/kung/integerinputfield.h55
-rw-r--r--kode/kwsdl/kung/listinputfield.cpp189
-rw-r--r--kode/kwsdl/kung/listinputfield.h80
-rw-r--r--kode/kwsdl/kung/loader.cpp89
-rw-r--r--kode/kwsdl/kung/loader.h55
-rw-r--r--kode/kwsdl/kung/main.cpp64
-rw-r--r--kode/kwsdl/kung/outputdialog.cpp30
-rw-r--r--kode/kwsdl/kung/outputdialog.h33
-rw-r--r--kode/kwsdl/kung/pageinputfield.cpp107
-rw-r--r--kode/kwsdl/kung/pageinputfield.h51
-rw-r--r--kode/kwsdl/kung/simplebaseinputfield.cpp120
-rw-r--r--kode/kwsdl/kung/simplebaseinputfield.h41
-rw-r--r--kode/kwsdl/kung/stringinputfield.cpp100
-rw-r--r--kode/kwsdl/kung/stringinputfield.h55
-rw-r--r--kode/kwsdl/kung/timeinputfield.cpp81
-rw-r--r--kode/kwsdl/kung/timeinputfield.h55
-rw-r--r--kode/kwsdl/kung/transport.cpp69
-rw-r--r--kode/kwsdl/kung/transport.h47
-rw-r--r--kode/kwsdl/kung/wsclconversationmanager.cpp50
-rw-r--r--kode/kwsdl/kung/wsclconversationmanager.h43
45 files changed, 3431 insertions, 0 deletions
diff --git a/kode/kwsdl/kung/Makefile.am b/kode/kwsdl/kung/Makefile.am
new file mode 100644
index 00000000..1906ec1c
--- /dev/null
+++ b/kode/kwsdl/kung/Makefile.am
@@ -0,0 +1,12 @@
+INCLUDES = -I$(top_srcdir) -I.. -I$(top_srcdir)/kode -I$(top_srcdir)/kode/kwsdl -I$(top_srcdir)/libkdepim $(all_includes)
+
+bin_PROGRAMS = kung
+kung_LDFLAGS = $(all_libraries) $(KDE_RPATH)
+kung_SOURCES = binaryinputfield.cpp boolinputfield.cpp complexbaseinputfield.cpp dateinputfield.cpp dispatcher.cpp \
+ doubleinputfield.cpp enuminputfield.cpp generalconversationmanager.cpp \
+ inputdialog.cpp inputfield.cpp inputfieldfactory.cpp \
+ integerinputfield.cpp listinputfield.cpp loader.cpp main.cpp outputdialog.cpp pageinputfield.cpp simplebaseinputfield.cpp \
+ stringinputfield.cpp timeinputfield.cpp transport.cpp wsclconversationmanager.cpp
+kung_LDADD = ../schema/libschema.la ../wscl/libwscl.la ../libwsdl.la -lkparts
+
+METASOURCES = AUTO
diff --git a/kode/kwsdl/kung/binaryinputfield.cpp b/kode/kwsdl/kung/binaryinputfield.cpp
new file mode 100644
index 00000000..f83e55b1
--- /dev/null
+++ b/kode/kwsdl/kung/binaryinputfield.cpp
@@ -0,0 +1,186 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <kfiledialog.h>
+#include <kio/netaccess.h>
+#include <kmdcodec.h>
+#include <kmessagebox.h>
+#include <kmimemagic.h>
+#include <klocale.h>
+#include <kparts/part.h>
+#include <kparts/componentfactory.h>
+#include <ktempfile.h>
+
+#include <qfile.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qpushbutton.h>
+#include <qwidget.h>
+
+#include <schema/simpletype.h>
+
+#include "binaryinputfield.h"
+
+BinaryInputField::BinaryInputField( const QString &name, const QString &typeName, const Schema::SimpleType *type )
+ : SimpleInputField( name, type ),
+ mValue( 0 ), mTypeName( typeName )
+{
+}
+
+void BinaryInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "BinaryInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ setData( element.text() );
+}
+
+void BinaryInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ QDomElement element = document.createElement( mName );
+ element.setAttribute( "xsi:type", "xsd:" + mTypeName );
+ QDomText text = document.createTextNode( data() );
+ element.appendChild( text );
+
+ parent.appendChild( element );
+}
+
+void BinaryInputField::setData( const QString &data )
+{
+ KCodecs::base64Decode( data.utf8(), mValue );
+}
+
+QString BinaryInputField::data() const
+{
+ QByteArray data = KCodecs::base64Encode( mValue, false );
+ return QString::fromUtf8( data.data(), data.size() );
+}
+
+QWidget *BinaryInputField::createWidget( QWidget *parent )
+{
+ mInputWidget = new BinaryWidget( parent );
+
+ if ( !mValue.isEmpty() )
+ mInputWidget->setData( mValue );
+
+ return mInputWidget;
+}
+
+void BinaryInputField::valueChanged( const QByteArray &value )
+{
+ mValue = value;
+
+ emit modified();
+}
+
+
+BinaryWidget::BinaryWidget( QWidget *parent )
+ : QWidget( parent, "BinaryWidget" ),
+ mMainWidget( 0 )
+{
+ mLayout = new QGridLayout( this, 3, 2, 11, 6 );
+
+ mLoadButton = new QPushButton( i18n( "Load..." ), this );
+ mSaveButton = new QPushButton( i18n( "Save..." ), this );
+ mSaveButton->setEnabled( false );
+
+ mLayout->addWidget( mLoadButton, 0, 1 );
+ mLayout->addWidget( mSaveButton, 1, 1 );
+
+ connect( mLoadButton, SIGNAL( clicked() ), SLOT( load() ) );
+ connect( mSaveButton, SIGNAL( clicked() ), SLOT( save() ) );
+}
+
+void BinaryWidget::setData( const QByteArray &data )
+{
+ KMimeMagic magic;
+ QString mimetype;
+
+ delete mMainWidget;
+
+ KMimeMagicResult *result = magic.findBufferType( data );
+ if ( result->isValid() )
+ mimetype = result->mimeType();
+
+ if ( !mimetype.isEmpty() ) {
+ KParts::ReadOnlyPart *part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, QString::null, this, 0, this, 0 );
+ if ( part ) {
+ KTempFile file;
+ file.file()->writeBlock( data );
+ file.close();
+ part->openURL( KURL( file.name() ) );
+ mMainWidget = part->widget();
+ } else {
+ mMainWidget = new QLabel( i18n( "No part found for visualization of mimetype %1" ).arg( mimetype ), this );
+ }
+
+ mData = data;
+ mSaveButton->setEnabled( true );
+ } else {
+ mMainWidget = new QLabel( i18n( "Got data of unknown mimetype" ), this );
+ }
+
+ mLayout->addMultiCellWidget( mMainWidget, 0, 2, 0, 0 );
+ mMainWidget->show();
+}
+
+void BinaryWidget::load()
+{
+ KURL url = KFileDialog::getOpenURL( QString(), QString(), this );
+ if ( url.isEmpty() )
+ return;
+
+ QString tempFile;
+ if ( KIO::NetAccess::download( url, tempFile, this ) ) {
+ QFile file( tempFile );
+ if ( !file.open( IO_ReadOnly ) ) {
+ KMessageBox::error( this, i18n( "Unable to open file %1" ).arg( url.url() ) );
+ return;
+ }
+
+ QByteArray data = file.readAll();
+ setData( data );
+
+ file.close();
+ KIO::NetAccess::removeTempFile( tempFile );
+
+ emit valueChanged( data );
+ } else
+ KMessageBox::error( this, KIO::NetAccess::lastErrorString() );
+}
+
+void BinaryWidget::save()
+{
+ KURL url = KFileDialog::getSaveURL( QString(), QString(), this );
+ if ( url.isEmpty() )
+ return;
+
+ KTempFile tempFile;
+ tempFile.file()->writeBlock( mData );
+ tempFile.close();
+
+ if ( !KIO::NetAccess::upload( tempFile.name(), url, this ) )
+ KMessageBox::error( this, KIO::NetAccess::lastErrorString() );
+}
+
+#include "binaryinputfield.moc"
diff --git a/kode/kwsdl/kung/binaryinputfield.h b/kode/kwsdl/kung/binaryinputfield.h
new file mode 100644
index 00000000..eeb721d5
--- /dev/null
+++ b/kode/kwsdl/kung/binaryinputfield.h
@@ -0,0 +1,83 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef BINARY_INPUTFIELD_H
+#define BINARY_INPUTFIELD_H
+
+#include <qwidget.h>
+
+#include "inputfield.h"
+
+class BinaryWidget;
+class QGridLayout;
+class QPushButton;
+
+class BinaryInputField : public SimpleInputField
+{
+ Q_OBJECT
+
+ public:
+ BinaryInputField( const QString &name, const QString &typeName, const Schema::SimpleType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+
+ private slots:
+ void valueChanged( const QByteArray &value );
+
+ private:
+ BinaryWidget *mInputWidget;
+
+ QByteArray mValue;
+ QString mTypeName;
+};
+
+class BinaryWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ BinaryWidget( QWidget *parent );
+
+ void setData( const QByteArray &data );
+
+ signals:
+ void valueChanged( const QByteArray &data );
+
+ private slots:
+ void load();
+ void save();
+
+ private:
+ QByteArray mData;
+
+ QGridLayout *mLayout;
+ QPushButton *mLoadButton;
+ QPushButton *mSaveButton;
+ QWidget* mMainWidget;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/boolinputfield.cpp b/kode/kwsdl/kung/boolinputfield.cpp
new file mode 100644
index 00000000..69e0e8e0
--- /dev/null
+++ b/kode/kwsdl/kung/boolinputfield.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qcheckbox.h>
+
+#include "boolinputfield.h"
+
+BoolInputField::BoolInputField( const QString &name, const Schema::SimpleType *type )
+ : SimpleInputField( name, type ),
+ mValue( false )
+{
+}
+
+void BoolInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "BoolInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ setData( element.text() );
+}
+
+void BoolInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ QDomElement element = document.createElement( mName );
+ element.setAttribute( "xsi:type", "xsd:boolean" );
+ QDomText text = document.createTextNode( data() );
+ element.appendChild( text );
+
+ parent.appendChild( element );
+}
+
+void BoolInputField::setData( const QString &data )
+{
+ mValue = ( data.lower() == "true" );
+}
+
+QString BoolInputField::data() const
+{
+ return ( mValue ? "true" : "false" );
+}
+
+QWidget *BoolInputField::createWidget( QWidget *parent )
+{
+ mInputWidget = new QCheckBox( parent );
+
+ mInputWidget->setChecked( mValue );
+
+ connect( mInputWidget, SIGNAL( toggled( bool ) ),
+ this, SLOT( inputChanged( bool ) ) );
+
+ return mInputWidget;
+}
+
+void BoolInputField::inputChanged( bool value )
+{
+ mValue = value;
+
+ emit modified();
+}
+
+#include "boolinputfield.moc"
diff --git a/kode/kwsdl/kung/boolinputfield.h b/kode/kwsdl/kung/boolinputfield.h
new file mode 100644
index 00000000..1ba5347b
--- /dev/null
+++ b/kode/kwsdl/kung/boolinputfield.h
@@ -0,0 +1,54 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef BOOL_INPUTFIELD_H
+#define BOOL_INPUTFIELD_H
+
+#include <qobject.h>
+
+#include "inputfield.h"
+
+class QCheckBox;
+
+class BoolInputField : public SimpleInputField
+{
+ Q_OBJECT
+
+ public:
+ BoolInputField( const QString &name, const Schema::SimpleType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+
+ private slots:
+ void inputChanged( bool );
+
+ private:
+ QCheckBox *mInputWidget;
+ bool mValue;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/complexbaseinputfield.cpp b/kode/kwsdl/kung/complexbaseinputfield.cpp
new file mode 100644
index 00000000..26434940
--- /dev/null
+++ b/kode/kwsdl/kung/complexbaseinputfield.cpp
@@ -0,0 +1,155 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qgroupbox.h>
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include <schema/complextype.h>
+
+#include "inputfieldfactory.h"
+
+#include "complexbaseinputfield.h"
+
+ComplexBaseInputField::ComplexBaseInputField( const QString &name, const Schema::ComplexType *type )
+ : ComplexInputField( name, type )
+{
+ Schema::Element::List elements = type->elements();
+ Schema::Element::List::ConstIterator elemIt;
+ for ( elemIt = elements.begin(); elemIt != elements.end(); ++elemIt ) {
+ bool isList = ((*elemIt).maxOccurs() == UNBOUNDED);
+ InputField *field = InputFieldFactory::self()->createField( (*elemIt).name(), (*elemIt).typeName(), isList );
+ if ( !field ) {
+ qDebug( "ComplexBaseInputField: Unable to create field of type %s", type->baseTypeName().latin1() );
+ } else {
+ appendChild( field );
+ }
+ }
+
+ Schema::Attribute::List attributes = type->attributes();
+ Schema::Attribute::List::ConstIterator attrIt;
+ for ( attrIt = attributes.begin(); attrIt != attributes.end(); ++attrIt ) {
+ InputField *field = InputFieldFactory::self()->createField( (*attrIt).name(), (*attrIt).typeName() );
+ if ( !field ) {
+ qDebug( "ComplexBaseInputField: Unable to create field of type %s", type->baseTypeName().latin1() );
+ } else {
+ appendChild( field );
+ }
+ }
+}
+
+void ComplexBaseInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "ComplexBaseInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ // elements
+ if ( mType->isArray() ) {
+ InputField *field = childField( "item" );
+ field->setXMLData( element );
+ } else {
+ QDomNode node = element.firstChild();
+ while ( !node.isNull() ) {
+ QDomElement child = node.toElement();
+ if ( !child.isNull() ) {
+ InputField *field = childField( child.tagName() );
+ if ( !field ) {
+ qDebug( "ComplexBaseInputField: Child field %s does not exists", child.tagName().latin1() );
+ } else {
+ field->setXMLData( child );
+ }
+ }
+
+ node = node.nextSibling();
+ }
+ }
+
+ // attributes
+ QDomNamedNodeMap nodes = element.attributes();
+ for ( uint i = 0; i < nodes.count(); ++i ) {
+ QDomNode node = nodes.item( i );
+ QDomAttr attr = node.toAttr();
+
+ InputField *field = childField( attr.name() );
+ if ( !field ) {
+ qDebug( "ComplexBaseInputField: Child field %s does not exists", attr.name().latin1() );
+ } else {
+ field->setData( attr.value() );
+ }
+ }
+}
+
+void ComplexBaseInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ QDomElement element = document.createElement( mName );
+
+ Schema::Element::List elements = mType->elements();
+ Schema::Element::List::ConstIterator elemIt;
+ for ( elemIt = elements.begin(); elemIt != elements.end(); ++elemIt ) {
+ InputField *field = childField( (*elemIt).name() );
+ if ( !field ) {
+ qDebug( "ComplexBaseInputField: No child found" );
+ } else {
+ field->xmlData( document, element );
+ }
+ }
+
+ Schema::Attribute::List attributes = mType->attributes();
+ Schema::Attribute::List::ConstIterator attrIt;
+ for ( attrIt = attributes.begin(); attrIt != attributes.end(); ++attrIt ) {
+ InputField *field = childField( (*attrIt).name() );
+ if ( !field ) {
+ qDebug( "ComplexBaseInputField: No child found" );
+ } else {
+ element.setAttribute( field->name(), field->data() );
+ }
+ }
+
+ parent.appendChild( element );
+}
+
+void ComplexBaseInputField::setData( const QString& )
+{
+}
+
+QString ComplexBaseInputField::data() const
+{
+ return QString();
+}
+
+QWidget *ComplexBaseInputField::createWidget( QWidget *parent )
+{
+ QGroupBox *inputWidget = new QGroupBox( mName, parent );
+ inputWidget->setColumnLayout( 0, Qt::Horizontal );
+ QGridLayout *layout = new QGridLayout( inputWidget->layout(), 2, 2, 6 );
+
+ InputField::List::Iterator it;
+ int row = 0;
+ for ( it = mFields.begin(); it != mFields.end(); ++it, ++row ) {
+ QLabel *label = new QLabel( (*it)->name(), inputWidget );
+ layout->addWidget( label, row, 0 );
+ layout->addWidget( (*it)->createWidget( inputWidget ), row, 1 );
+ }
+
+ return inputWidget;
+}
diff --git a/kode/kwsdl/kung/complexbaseinputfield.h b/kode/kwsdl/kung/complexbaseinputfield.h
new file mode 100644
index 00000000..e8d563ae
--- /dev/null
+++ b/kode/kwsdl/kung/complexbaseinputfield.h
@@ -0,0 +1,41 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef COMPLEXBASE_INPUTFIELD_H
+#define COMPLEXBASE_INPUTFIELD_H
+
+#include "inputfield.h"
+
+class ComplexBaseInputField : public ComplexInputField
+{
+ public:
+ ComplexBaseInputField( const QString &name, const Schema::ComplexType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+};
+
+#endif
diff --git a/kode/kwsdl/kung/conversationmanager.h b/kode/kwsdl/kung/conversationmanager.h
new file mode 100644
index 00000000..6ef403c7
--- /dev/null
+++ b/kode/kwsdl/kung/conversationmanager.h
@@ -0,0 +1,37 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef CONVERSATIONMANAGER_H
+#define CONVERSATIONMANAGER_H
+
+#include <qstringlist.h>
+
+class ConversationManager
+{
+ public:
+ /**
+ Returns a list of all actions which can be called after the
+ current action with a special condition.
+ */
+ virtual QStringList nextActions( const QString &currentAction, const QString &condition = QString() ) = 0;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/dateinputfield.cpp b/kode/kwsdl/kung/dateinputfield.cpp
new file mode 100644
index 00000000..ff60da20
--- /dev/null
+++ b/kode/kwsdl/kung/dateinputfield.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <kdatepicker.h>
+
+#include "dateinputfield.h"
+
+DateInputField::DateInputField( const QString &name, const Schema::SimpleType *type )
+ : SimpleInputField( name, type ),
+ mValue( QDate::currentDate() )
+{
+}
+
+void DateInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "DateInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ setData( element.text() );
+}
+
+void DateInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ QDomElement element = document.createElement( mName );
+ element.setAttribute( "xsi:type", "xsd:date" );
+ QDomText text = document.createTextNode( data() );
+ element.appendChild( text );
+
+ parent.appendChild( element );
+}
+
+void DateInputField::setData( const QString &data )
+{
+ mValue = QDate::fromString( data, Qt::ISODate );
+}
+
+QString DateInputField::data() const
+{
+ return mValue.toString( Qt::ISODate );
+}
+
+QWidget *DateInputField::createWidget( QWidget *parent )
+{
+ mInputWidget = new KDatePicker( parent );
+
+ mInputWidget->setDate( mValue );
+
+ connect( mInputWidget, SIGNAL( dateChanged( QDate ) ),
+ this, SLOT( inputChanged( QDate ) ) );
+
+ return mInputWidget;
+}
+
+void DateInputField::inputChanged( QDate date )
+{
+ mValue = date;
+
+ emit modified();
+}
+
+#include "dateinputfield.moc"
diff --git a/kode/kwsdl/kung/dateinputfield.h b/kode/kwsdl/kung/dateinputfield.h
new file mode 100644
index 00000000..a42e2210
--- /dev/null
+++ b/kode/kwsdl/kung/dateinputfield.h
@@ -0,0 +1,55 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef DATE_INPUTFIELD_H
+#define DATE_INPUTFIELD_H
+
+#include <qdatetime.h>
+#include <qobject.h>
+
+#include "inputfield.h"
+
+class KDatePicker;
+
+class DateInputField : public SimpleInputField
+{
+ Q_OBJECT
+
+ public:
+ DateInputField( const QString &name, const Schema::SimpleType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+
+ private slots:
+ void inputChanged( QDate );
+
+ private:
+ KDatePicker *mInputWidget;
+ QDate mValue;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/dispatcher.cpp b/kode/kwsdl/kung/dispatcher.cpp
new file mode 100644
index 00000000..79f6bd94
--- /dev/null
+++ b/kode/kwsdl/kung/dispatcher.cpp
@@ -0,0 +1,153 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qapplication.h>
+#include <qtimer.h>
+#include <qwidget.h>
+
+#include <kinputdialog.h>
+#include <klocale.h>
+#include <kmessagebox.h>
+
+#include "generalconversationmanager.h"
+#include "inputdialog.h"
+#include "inputfieldfactory.h"
+#include "outputdialog.h"
+#include "pageinputfield.h"
+#include "transport.h"
+
+#include "dispatcher.h"
+
+Dispatcher::Dispatcher()
+ : QObject( 0, "Dispatcher" ),
+ mConversationManager( 0 )
+{
+}
+
+Dispatcher::~Dispatcher()
+{
+ delete mConversationManager;
+ mConversationManager = 0;
+}
+
+void Dispatcher::setWSDL( const KWSDL::WSDL &wsdl )
+{
+ mWSDL = wsdl;
+
+ InputFieldFactory::self()->setTypes( mWSDL.types() );
+
+ mConversationManager = new GeneralConversationManager( mWSDL );
+
+ mTransport = new Transport( mWSDL.service().ports().first().mLocation );
+ connect( mTransport, SIGNAL( result( const QString& ) ),
+ this, SLOT( result( const QString& ) ) );
+ connect( mTransport, SIGNAL( error( const QString& ) ),
+ this, SLOT( error( const QString& ) ) );
+}
+
+void Dispatcher::run()
+{
+ nextMessage();
+}
+
+void Dispatcher::nextMessage()
+{
+ if ( !mConversationManager ) {
+ qDebug( "No conversation manager set... aborting" );
+ return;
+ }
+
+ QStringList items = mConversationManager->nextActions( mLastMessage, QString() );
+
+ mCurrentMessage = QString();
+ if ( items.count() > 1 ) {
+ mCurrentMessage = KInputDialog::getItem( i18n( "Select a functionality of the service:" ), i18n( "Functions" ),
+ items );
+ } else
+ mCurrentMessage = items.first();
+
+ if ( mCurrentMessage.isEmpty() ) {
+ qApp->quit();
+ return;
+ }
+
+ KWSDL::Message message = mWSDL.findMessage( mCurrentMessage );
+ InputField *field = new PageInputField( message.name(), message );
+ QWidget *page = field->createWidget( 0 );
+
+ InputDialog dlg( page, 0 );
+ if ( dlg.exec() ) {
+ QDomDocument doc( "kwsdl" );
+ doc.appendChild( doc.createProcessingInstruction( "xml", "version=\"1.0\" encoding=\"UTF-8\"" ) );
+ QDomElement env = doc.createElement( "SOAP-ENV:Envelope" );
+ env.setAttribute( "xmlns:SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/" );
+ env.setAttribute( "xmlns:xsi", "http://www.w3.org/1999/XMLSchema-instance" );
+ env.setAttribute( "xmlns:xsd", "http://www.w3.org/1999/XMLSchema" );
+ doc.appendChild( env );
+
+ QDomElement body = doc.createElement( "SOAP-ENV:Body" );
+ env.appendChild( body );
+
+ field->xmlData( doc, body );
+
+ QDomElement method = body.firstChild().toElement();
+ QString nameSpace = mWSDL.findBindingOperation( "", message.name() ).input().nameSpace();
+ method.setAttribute( "xmlns:ns1", "urn:GoogleSearch" );
+ method.setAttribute( "SOAP-ENV:encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/" );
+ body.appendChild( method );
+
+ if ( mTransport ) {
+ qDebug( "%s", doc.toString( 2 ).latin1() );
+ mTransport->query( doc.toString( 2 ) );
+ }
+ } else
+ qApp->quit();
+}
+
+void Dispatcher::result( const QString &xml )
+{
+ qDebug( "Got data %s", xml.latin1() );
+
+ KWSDL::Message message = mWSDL.findOutputMessage( mCurrentMessage );
+ InputField *field = new PageInputField( message.name(), message );
+
+ QDomDocument doc;
+ doc.setContent( xml, true );
+
+ field->setXMLData( doc.documentElement().firstChild().firstChild().toElement() );
+ QWidget *page = field->createWidget( 0 );
+
+ OutputDialog dlg( page, 0 );
+ dlg.exec();
+
+ mLastMessage = mCurrentMessage;
+
+ QTimer::singleShot( 0, this, SLOT( nextMessage() ) );
+}
+
+void Dispatcher::error( const QString &errorMsg )
+{
+ KMessageBox::error( 0, errorMsg );
+
+ QTimer::singleShot( 0, this, SLOT( nextMessage() ) );
+}
+
+#include "dispatcher.moc"
diff --git a/kode/kwsdl/kung/dispatcher.h b/kode/kwsdl/kung/dispatcher.h
new file mode 100644
index 00000000..892635d5
--- /dev/null
+++ b/kode/kwsdl/kung/dispatcher.h
@@ -0,0 +1,58 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef DISPATCHER_H
+#define DISPATCHER_H
+
+#include <qobject.h>
+
+#include <kwsdl/wsdl.h>
+
+class ConversationManager;
+class Transport;
+
+class Dispatcher : public QObject
+{
+ Q_OBJECT
+
+ public:
+ Dispatcher();
+ ~Dispatcher();
+
+ void setWSDL( const KWSDL::WSDL &wsdl );
+
+ void run();
+
+ private slots:
+ void nextMessage();
+ void result( const QString &xml );
+ void error( const QString &errorMsg );
+
+ private:
+ KWSDL::WSDL mWSDL;
+
+ QString mCurrentMessage;
+ QString mLastMessage;
+ ConversationManager *mConversationManager;
+ Transport *mTransport;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/doubleinputfield.cpp b/kode/kwsdl/kung/doubleinputfield.cpp
new file mode 100644
index 00000000..4c19abf9
--- /dev/null
+++ b/kode/kwsdl/kung/doubleinputfield.cpp
@@ -0,0 +1,94 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <knuminput.h>
+
+#include <schema/simpletype.h>
+
+#include "doubleinputfield.h"
+
+DoubleInputField::DoubleInputField( const QString &name, const QString &typeName, const Schema::SimpleType *type )
+ : SimpleInputField( name, type ),
+ mValue( 0 ), mTypeName( typeName )
+{
+}
+
+void DoubleInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "DoubleInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ setData( element.text() );
+}
+
+void DoubleInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ QDomElement element = document.createElement( mName );
+ element.setAttribute( "xsi:type", "xsd:" + mTypeName );
+ QDomText text = document.createTextNode( data() );
+ element.appendChild( text );
+
+ parent.appendChild( element );
+}
+
+void DoubleInputField::setData( const QString &data )
+{
+ mValue = data.toDouble();
+}
+
+QString DoubleInputField::data() const
+{
+ return QString::number( mValue );
+}
+
+QWidget *DoubleInputField::createWidget( QWidget *parent )
+{
+ mInputWidget = new KDoubleSpinBox( parent );
+
+ if ( mType ) {
+ if ( mType->facetType() & Schema::SimpleType::MININC )
+ mInputWidget->setMinValue( mType->facetMinimumInclusive() );
+ if ( mType->facetType() & Schema::SimpleType::MINEX )
+ mInputWidget->setMinValue( mType->facetMinimumExclusive() + 1 );
+ if ( mType->facetType() & Schema::SimpleType::MAXINC )
+ mInputWidget->setMaxValue( mType->facetMaximumInclusive() );
+ if ( mType->facetType() & Schema::SimpleType::MAXEX )
+ mInputWidget->setMaxValue( mType->facetMaximumExclusive() - 1 );
+ }
+
+ mInputWidget->setValue( mValue );
+
+ connect( mInputWidget, SIGNAL( valueChanged( double ) ),
+ this, SLOT( inputChanged( double ) ) );
+
+ return mInputWidget;
+}
+
+void DoubleInputField::inputChanged( double value )
+{
+ mValue = value;
+
+ emit modified();
+}
+
+#include "doubleinputfield.moc"
diff --git a/kode/kwsdl/kung/doubleinputfield.h b/kode/kwsdl/kung/doubleinputfield.h
new file mode 100644
index 00000000..f1eeb789
--- /dev/null
+++ b/kode/kwsdl/kung/doubleinputfield.h
@@ -0,0 +1,55 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef DOUBLE_INPUTFIELD_H
+#define DOUBLE_INPUTFIELD_H
+
+#include <qobject.h>
+
+#include "inputfield.h"
+
+class KDoubleSpinBox;
+
+class DoubleInputField : public SimpleInputField
+{
+ Q_OBJECT
+
+ public:
+ DoubleInputField( const QString &name, const QString &typeName, const Schema::SimpleType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+
+ private slots:
+ void inputChanged( double );
+
+ private:
+ KDoubleSpinBox *mInputWidget;
+ double mValue;
+ QString mTypeName;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/enuminputfield.cpp b/kode/kwsdl/kung/enuminputfield.cpp
new file mode 100644
index 00000000..61ff328d
--- /dev/null
+++ b/kode/kwsdl/kung/enuminputfield.cpp
@@ -0,0 +1,86 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <kcombobox.h>
+
+#include <schema/simpletype.h>
+
+#include "enuminputfield.h"
+
+EnumInputField::EnumInputField( const QString &name, const Schema::SimpleType *type )
+ : SimpleInputField( name, type )
+{
+ mEnums = type->facetEnums();
+
+ mValue = mEnums.first();
+}
+
+void EnumInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "EnumInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ setData( element.text() );
+}
+
+void EnumInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ QDomElement element = document.createElement( mName );
+ element.setAttribute( "xsi:type", "xsd:string" );
+ QDomText text = document.createTextNode( data() );
+ element.appendChild( text );
+
+ parent.appendChild( element );
+}
+
+void EnumInputField::setData( const QString &data )
+{
+ mValue = data;
+}
+
+QString EnumInputField::data() const
+{
+ return mValue;
+}
+
+QWidget *EnumInputField::createWidget( QWidget *parent )
+{
+ mInputWidget = new KComboBox( parent );
+
+ mInputWidget->insertStringList( mEnums );
+ mInputWidget->setCurrentItem( mEnums.findIndex( mValue ) );
+
+ connect( mInputWidget, SIGNAL( activated( int ) ),
+ this, SLOT( inputChanged( int ) ) );
+
+ return mInputWidget;
+}
+
+void EnumInputField::inputChanged( int value )
+{
+ mValue = mEnums[ value ];
+
+ emit modified();
+}
+
+#include "enuminputfield.moc"
diff --git a/kode/kwsdl/kung/enuminputfield.h b/kode/kwsdl/kung/enuminputfield.h
new file mode 100644
index 00000000..40369273
--- /dev/null
+++ b/kode/kwsdl/kung/enuminputfield.h
@@ -0,0 +1,55 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef ENUM_INPUTFIELD_H
+#define ENUM_INPUTFIELD_H
+
+#include <qobject.h>
+
+#include "inputfield.h"
+
+class KComboBox;
+
+class EnumInputField : public SimpleInputField
+{
+ Q_OBJECT
+
+ public:
+ EnumInputField( const QString &name, const Schema::SimpleType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+
+ private slots:
+ void inputChanged( int );
+
+ private:
+ KComboBox *mInputWidget;
+ QString mValue;
+ QStringList mEnums;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/generalconversationmanager.cpp b/kode/kwsdl/kung/generalconversationmanager.cpp
new file mode 100644
index 00000000..266eca3b
--- /dev/null
+++ b/kode/kwsdl/kung/generalconversationmanager.cpp
@@ -0,0 +1,51 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "generalconversationmanager.h"
+
+GeneralConversationManager::GeneralConversationManager( const KWSDL::WSDL &wsdl )
+ : mWSDL( wsdl )
+{
+ const KWSDL::Service::Port::List servicePorts = mWSDL.service().ports();
+ KWSDL::Service::Port::List::ConstIterator it;
+ for ( it = servicePorts.begin(); it != servicePorts.end(); ++it ) {
+ KWSDL::Binding binding = mWSDL.findBinding( (*it).mBinding );
+
+ KWSDL::Port port = mWSDL.findPort( binding.type() );
+ const KWSDL::Port::Operation::List operations = port.operations();
+ KWSDL::Port::Operation::List::ConstIterator opIt;
+ for ( opIt = operations.begin(); opIt != operations.end(); ++opIt ) {
+ mInputMessages.append( mWSDL.findMessage( (*opIt).input() ) );
+ mOutputMessages.append( mWSDL.findMessage( (*opIt).output() ) );
+ }
+ }
+}
+
+QStringList GeneralConversationManager::nextActions( const QString&, const QString& )
+{
+ QStringList actions;
+
+ KWSDL::Message::List::ConstIterator it;
+ for ( it = mInputMessages.begin(); it != mInputMessages.end(); ++it )
+ actions.append( (*it).name() );
+
+ return actions;
+}
diff --git a/kode/kwsdl/kung/generalconversationmanager.h b/kode/kwsdl/kung/generalconversationmanager.h
new file mode 100644
index 00000000..2f029757
--- /dev/null
+++ b/kode/kwsdl/kung/generalconversationmanager.h
@@ -0,0 +1,43 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef GENERAL_CONVERSATIONMANAGER_H
+#define GENERAL_CONVERSATIONMANAGER_H
+
+#include <kwsdl/wsdl.h>
+
+#include "conversationmanager.h"
+
+class GeneralConversationManager : public ConversationManager
+{
+ public:
+ GeneralConversationManager( const KWSDL::WSDL &wsdl );
+
+ virtual QStringList nextActions( const QString &currentAction, const QString &condition = QString() );
+
+ private:
+ KWSDL::WSDL mWSDL;
+
+ KWSDL::Message::List mInputMessages;
+ KWSDL::Message::List mOutputMessages;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/inputdialog.cpp b/kode/kwsdl/kung/inputdialog.cpp
new file mode 100644
index 00000000..2885fdc4
--- /dev/null
+++ b/kode/kwsdl/kung/inputdialog.cpp
@@ -0,0 +1,32 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <klocale.h>
+
+#include "inputdialog.h"
+
+InputDialog::InputDialog( QWidget *page, QWidget *parent )
+ : KDialogBase( Swallow, "", Ok | Cancel, Ok, parent, "", true, true )
+{
+ setMainWidget( page );
+
+ setButtonText( Ok, i18n( "Send" ) );
+}
diff --git a/kode/kwsdl/kung/inputdialog.h b/kode/kwsdl/kung/inputdialog.h
new file mode 100644
index 00000000..10b107c3
--- /dev/null
+++ b/kode/kwsdl/kung/inputdialog.h
@@ -0,0 +1,33 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef INPUTDIALOG_H
+#define INPUTDIALOG_H
+
+#include <kdialogbase.h>
+
+class InputDialog : public KDialogBase
+{
+ public:
+ InputDialog( QWidget *page, QWidget *parent );
+};
+
+#endif
diff --git a/kode/kwsdl/kung/inputfield.cpp b/kode/kwsdl/kung/inputfield.cpp
new file mode 100644
index 00000000..d4efcbe4
--- /dev/null
+++ b/kode/kwsdl/kung/inputfield.cpp
@@ -0,0 +1,102 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <schema/complextype.h>
+#include <schema/simpletype.h>
+
+#include "inputfield.h"
+
+InputField::InputField( const QString &name )
+ : QObject( 0, QString( "InputField( %1 )" ).arg( name ).latin1() ),
+ mName( name )
+{
+}
+
+InputField::~InputField()
+{
+ InputField::List::Iterator it;
+ for ( it = mFields.begin(); it != mFields.end(); ++it )
+ delete *it;
+
+ mFields.clear();
+}
+
+QString InputField::name() const
+{
+ return mName;
+}
+
+void InputField::appendChild( InputField *field )
+{
+ mFields.append( field );
+}
+
+void InputField::removeChild( InputField *field )
+{
+ mFields.remove( field );
+}
+
+InputField *InputField::childField( const QString &name ) const
+{
+ InputField::List::ConstIterator it;
+ for ( it = mFields.begin(); it != mFields.end(); ++it )
+ if ( (*it)->name() == name )
+ return *it;
+
+ return 0;
+}
+
+InputField::List InputField::childFields() const
+{
+ return mFields;
+}
+
+SimpleInputField::SimpleInputField( const QString &name, const Schema::SimpleType *type )
+ : InputField( name ), mType( 0 )
+{
+ if ( type ) {
+ mType = new Schema::SimpleType();
+ *mType = *type;
+ }
+}
+
+SimpleInputField::~SimpleInputField()
+{
+ delete mType;
+ mType = 0;
+}
+
+ComplexInputField::ComplexInputField( const QString &name, const Schema::ComplexType *type )
+ : InputField( name ), mType( 0 )
+{
+ if ( type ) {
+ mType = new Schema::ComplexType();
+ *mType = *type;
+ }
+}
+
+ComplexInputField::~ComplexInputField()
+{
+ delete mType;
+ mType = 0;
+}
+
+#include "inputfield.moc"
diff --git a/kode/kwsdl/kung/inputfield.h b/kode/kwsdl/kung/inputfield.h
new file mode 100644
index 00000000..71030bda
--- /dev/null
+++ b/kode/kwsdl/kung/inputfield.h
@@ -0,0 +1,146 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef INPUTFIELD_H
+#define INPUTFIELD_H
+
+#include <qdom.h>
+#include <qobject.h>
+#include <qstring.h>
+#include <qvaluelist.h>
+
+class QWidget;
+
+namespace Schema {
+class SimpleType;
+class ComplexType;
+}
+
+/**
+ Abstract base class for all kinds of input fields.
+ */
+class InputField : public QObject
+{
+ Q_OBJECT
+
+ public:
+ typedef QValueList<InputField*> List;
+
+ /**
+ Constructs a input field.
+ */
+ InputField( const QString &name );
+
+ /**
+ Destructor.
+ */
+ virtual ~InputField();
+
+ /**
+ Returns the name of the field.
+ */
+ QString name() const;
+
+ /**
+ Sets the xml data of this field.
+ */
+ virtual void setXMLData( const QDomElement &element ) = 0;
+
+ /**
+ Returns the xml value of this field.
+ */
+ virtual void xmlData( QDomDocument &document, QDomElement &parent ) = 0;
+
+ /**
+ Sets the plain data of this field as string.
+ */
+ virtual void setData( const QString &data ) = 0;
+
+ /**
+ Returns the data of this field as string.
+ */
+ virtual QString data() const = 0;
+
+ /**
+ Returns a pointer to a new created input widget which can be used to
+ to modify the value.
+ */
+ virtual QWidget *createWidget( QWidget *parent ) = 0;
+
+ /**
+ Add a child field.
+ */
+ virtual void appendChild( InputField *field );
+
+ /**
+ Removes a child field.
+ */
+ virtual void removeChild( InputField *field );
+
+ /**
+ Returns a field with the given name or 0 when no field with this name
+ exists.
+ */
+ virtual InputField *childField( const QString &name ) const;
+
+ /**
+ Returns a list of all child fields.
+ */
+ virtual InputField::List childFields() const;
+
+ signals:
+ /**
+ This signal is emitted whenever the value is changed by the user.
+ */
+ void modified();
+
+ protected:
+ QString mName;
+ InputField::List mFields;
+};
+
+/**
+ Abstract base class for simple input fields like text or number input.
+ */
+class SimpleInputField : public InputField
+{
+ public:
+ SimpleInputField( const QString &name, const Schema::SimpleType *type );
+ ~SimpleInputField();
+
+ protected:
+ Schema::SimpleType *mType;
+};
+
+/**
+ Abstract base class for complex input fields like pages, lists or tables.
+ */
+class ComplexInputField : public InputField
+{
+ public:
+ ComplexInputField( const QString &name, const Schema::ComplexType *type );
+ ~ComplexInputField();
+
+ protected:
+ Schema::ComplexType *mType;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/inputfieldfactory.cpp b/kode/kwsdl/kung/inputfieldfactory.cpp
new file mode 100644
index 00000000..43a844c6
--- /dev/null
+++ b/kode/kwsdl/kung/inputfieldfactory.cpp
@@ -0,0 +1,123 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <kstaticdeleter.h>
+
+#include <schema/types.h>
+
+#include "binaryinputfield.h"
+#include "boolinputfield.h"
+#include "complexbaseinputfield.h"
+#include "dateinputfield.h"
+#include "doubleinputfield.h"
+#include "enuminputfield.h"
+#include "integerinputfield.h"
+#include "listinputfield.h"
+#include "simplebaseinputfield.h"
+#include "stringinputfield.h"
+#include "timeinputfield.h"
+
+#include "inputfieldfactory.h"
+
+InputFieldFactory *InputFieldFactory::mSelf = 0;
+static KStaticDeleter<InputFieldFactory> inputFieldFactoryDeleter;
+
+InputFieldFactory::InputFieldFactory()
+{
+}
+
+InputFieldFactory::~InputFieldFactory()
+{
+}
+
+void InputFieldFactory::setTypes( const Schema::Types &types )
+{
+ mTypes = types;
+}
+
+InputField *InputFieldFactory::createField( const QString &name, const QString &typeName, bool isList )
+{
+ Schema::SimpleType::List simpleTypes = mTypes.simpleTypes();
+ Schema::SimpleType::List::ConstIterator simpleIt;
+ for ( simpleIt = simpleTypes.begin(); simpleIt != simpleTypes.end(); ++simpleIt ) {
+ if ( (*simpleIt).name() == typeName ) {
+ if ( isList )
+ return new ListInputField( name, typeName, 0 );
+ else
+ return new SimpleBaseInputField( name, &(*simpleIt) );
+ }
+ }
+
+ Schema::ComplexType::List complexTypes = mTypes.complexTypes();
+ Schema::ComplexType::List::ConstIterator complexIt;
+ for ( complexIt = complexTypes.begin(); complexIt != complexTypes.end(); ++complexIt ) {
+ if ( (*complexIt).name() == typeName ) {
+ if ( isList )
+ return new ListInputField( name, typeName, 0 );
+ else
+ return new ComplexBaseInputField( name, &(*complexIt) );
+ }
+ }
+
+ return createBasicField( name, typeName, 0, isList );
+}
+
+InputField *InputFieldFactory::createBasicField( const QString &name, const QString &typeName,
+ const Schema::SimpleType *type, bool isList )
+{
+ if ( isList )
+ return new ListInputField( name, typeName, 0 );
+
+ if ( typeName == "string" || typeName == "language" ) {
+ if ( type && type->facetType() & Schema::SimpleType::ENUM )
+ return new EnumInputField( name, type );
+ else
+ return new StringInputField( name, typeName, type );
+ } else if ( typeName == "int" || typeName == "unsignedInt" ||
+ typeName == "byte" || typeName == "unsignedByte" ||
+ typeName == "integer" || typeName == "positiveInteger" || typeName == "negativeInteger" ||
+ typeName == "nonNegativeInteger" || typeName == "nonPositiveInteger" ||
+ typeName == "long" || typeName == "unsignedLong" ||
+ typeName == "short" || typeName == "unsignedShort" ) {
+ return new IntegerInputField( name, typeName, type );
+ } else if ( typeName == "double" || typeName == "float" || typeName == "decimal" ) {
+ return new DoubleInputField( name, typeName, type );
+ } else if ( typeName == "boolean" ) {
+ return new BoolInputField( name, type );
+ } else if ( typeName == "date" ) {
+ return new DateInputField( name, type );
+ } else if ( typeName == "time" ) {
+ return new TimeInputField( name, type );
+ } else if ( typeName == "base64Binary" ) {
+ return new BinaryInputField( name, typeName, type );
+ } else {
+ qDebug( "InputFieldFactory: Unknown type %s", typeName.latin1() );
+ return 0;
+ }
+}
+
+InputFieldFactory* InputFieldFactory::self()
+{
+ if ( !mSelf )
+ inputFieldFactoryDeleter.setObject( mSelf, new InputFieldFactory() );
+
+ return mSelf;
+}
diff --git a/kode/kwsdl/kung/inputfieldfactory.h b/kode/kwsdl/kung/inputfieldfactory.h
new file mode 100644
index 00000000..2c1e30eb
--- /dev/null
+++ b/kode/kwsdl/kung/inputfieldfactory.h
@@ -0,0 +1,69 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef INPUTFIELD_FACTORY_H
+#define INPUTFIELD_FACTORY_H
+
+#include "inputfield.h"
+
+#include <schema/types.h>
+
+namespace Schema {
+class SimpleType;
+};
+
+/**
+ Factory class, which creates InputFields for a given type.
+ */
+class InputFieldFactory
+{
+ public:
+ /**
+ Destructor.
+ */
+ ~InputFieldFactory();
+
+ /**
+ Creates an input field of the given type with the given name.
+ */
+ InputField *createField( const QString &name, const QString &typeName, bool isList = false );
+
+ /**
+ Creates an input field of the given type with the given name.
+ */
+ InputField *createBasicField( const QString &name, const QString &typeName, const Schema::SimpleType *type, bool isList = false );
+
+ /**
+ Sets the types description, so that the factory can pass
+ them to the input fields.
+ */
+ void setTypes( const Schema::Types &types );
+
+ static InputFieldFactory* self();
+
+ private:
+ InputFieldFactory();
+
+ static InputFieldFactory *mSelf;
+ Schema::Types mTypes;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/integerinputfield.cpp b/kode/kwsdl/kung/integerinputfield.cpp
new file mode 100644
index 00000000..a0613682
--- /dev/null
+++ b/kode/kwsdl/kung/integerinputfield.cpp
@@ -0,0 +1,132 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <knuminput.h>
+
+#include <schema/simpletype.h>
+
+#include <limits.h>
+
+#include "integerinputfield.h"
+
+IntegerInputField::IntegerInputField( const QString &name, const QString &typeName, const Schema::SimpleType *type )
+ : SimpleInputField( name, type ),
+ mValue( 0 ), mTypeName( typeName )
+{
+}
+
+void IntegerInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "IntegerInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ setData( element.text() );
+}
+
+void IntegerInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ QDomElement element = document.createElement( mName );
+ element.setAttribute( "xsi:type", "xsd:" + mTypeName );
+ QDomText text = document.createTextNode( data() );
+ element.appendChild( text );
+
+ parent.appendChild( element );
+}
+
+void IntegerInputField::setData( const QString &data )
+{
+ mValue = data.toInt();
+}
+
+QString IntegerInputField::data() const
+{
+ return QString::number( mValue );
+}
+
+QWidget *IntegerInputField::createWidget( QWidget *parent )
+{
+ mInputWidget = new KIntSpinBox( parent );
+
+ // basic restrictions
+ if ( mTypeName == "byte" ) {
+ mInputWidget->setMinValue( CHAR_MIN );
+ mInputWidget->setMaxValue( CHAR_MAX );
+ } else if ( mTypeName == "unsignedByte" ) {
+ mInputWidget->setMinValue( 0 );
+ mInputWidget->setMaxValue( UCHAR_MAX );
+ } else if ( mTypeName == "integer" || mTypeName == "int" ) {
+ mInputWidget->setMinValue( INT_MIN );
+ mInputWidget->setMaxValue( INT_MAX );
+ } else if ( mTypeName == "positiveInteger" ) {
+ mInputWidget->setMinValue( 1 );
+ mInputWidget->setMaxValue( UINT_MAX );
+ } else if ( mTypeName == "negativeInteger" ) {
+ mInputWidget->setMinValue( INT_MIN );
+ mInputWidget->setMaxValue( -1 );
+ } else if ( mTypeName == "nonNegativeInteger" || mTypeName == "unsignedInt" ) {
+ mInputWidget->setMinValue( 0 );
+ mInputWidget->setMaxValue( UINT_MAX );
+ } else if ( mTypeName == "nonPositiveInteger" ) {
+ mInputWidget->setMinValue( INT_MIN );
+ mInputWidget->setMaxValue( 0 );
+ } else if ( mTypeName == "long" ) {
+ mInputWidget->setMinValue( LONG_MIN );
+ mInputWidget->setMaxValue( LONG_MAX );
+ } else if ( mTypeName == "unsignedlong" ) {
+ mInputWidget->setMinValue( 0 );
+ mInputWidget->setMaxValue( ULONG_MAX );
+ } else if ( mTypeName == "short" ) {
+ mInputWidget->setMinValue( SHRT_MIN );
+ mInputWidget->setMaxValue( SHRT_MAX );
+ } else if ( mTypeName == "unsignedShort" ) {
+ mInputWidget->setMinValue( 0 );
+ mInputWidget->setMaxValue( USHRT_MAX );
+ }
+
+ if ( mType ) {
+ if ( mType->facetType() & Schema::SimpleType::MININC )
+ mInputWidget->setMinValue( mType->facetMinimumInclusive() );
+ if ( mType->facetType() & Schema::SimpleType::MINEX )
+ mInputWidget->setMinValue( mType->facetMinimumExclusive() + 1 );
+ if ( mType->facetType() & Schema::SimpleType::MAXINC )
+ mInputWidget->setMaxValue( mType->facetMaximumInclusive() );
+ if ( mType->facetType() & Schema::SimpleType::MAXEX )
+ mInputWidget->setMaxValue( mType->facetMaximumExclusive() - 1 );
+ }
+
+ mInputWidget->setValue( mValue );
+
+ connect( mInputWidget, SIGNAL( valueChanged( int ) ),
+ this, SLOT( inputChanged( int ) ) );
+
+ return mInputWidget;
+}
+
+void IntegerInputField::inputChanged( int value )
+{
+ mValue = value;
+
+ emit modified();
+}
+
+#include "integerinputfield.moc"
diff --git a/kode/kwsdl/kung/integerinputfield.h b/kode/kwsdl/kung/integerinputfield.h
new file mode 100644
index 00000000..6576aa1d
--- /dev/null
+++ b/kode/kwsdl/kung/integerinputfield.h
@@ -0,0 +1,55 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef INTEGER_INPUTFIELD_H
+#define INTEGER_INPUTFIELD_H
+
+#include <qobject.h>
+
+#include "inputfield.h"
+
+class KIntSpinBox;
+
+class IntegerInputField : public SimpleInputField
+{
+ Q_OBJECT
+
+ public:
+ IntegerInputField( const QString &name, const QString &typeName, const Schema::SimpleType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+
+ private slots:
+ void inputChanged( int );
+
+ private:
+ KIntSpinBox *mInputWidget;
+ int mValue;
+ QString mTypeName;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/listinputfield.cpp b/kode/kwsdl/kung/listinputfield.cpp
new file mode 100644
index 00000000..a812df6a
--- /dev/null
+++ b/kode/kwsdl/kung/listinputfield.cpp
@@ -0,0 +1,189 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qlayout.h>
+#include <qlistbox.h>
+#include <qpushbutton.h>
+
+#include <klocale.h>
+
+#include <schema/simpletype.h>
+
+#include "inputdialog.h"
+#include "inputfieldfactory.h"
+#include "outputdialog.h"
+
+#include "listinputfield.h"
+
+ListInputField::ListInputField( const QString &name, const QString &typeName, const Schema::SimpleType *type )
+ : SimpleInputField( name, type ), mTypeName( typeName )
+{
+}
+
+void ListInputField::setXMLData( const QDomElement &element )
+{
+ InputField::List::Iterator it;
+ for ( it = mFields.begin(); it != mFields.end(); ++it ) {
+ delete *it;
+ }
+ mFields.clear();
+
+ QDomNode node = element.firstChild();
+ while ( !node.isNull() ) {
+ QDomElement child = node.toElement();
+ if ( !child.isNull() ) {
+ InputField *field = InputFieldFactory::self()->createField( name(), mTypeName );
+ if ( field ) {
+ field->setXMLData( child );
+ appendChild( field );
+ } else
+ qDebug( "ListInputField: Unable to create field of type %s", mTypeName.latin1() );
+ }
+
+ node = node.nextSibling();
+ }
+}
+
+void ListInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ InputField::List::Iterator it;
+ for ( it = mFields.begin(); it != mFields.end(); ++it ) {
+ (*it)->xmlData( document, parent );
+ }
+}
+
+void ListInputField::setData( const QString& )
+{
+}
+
+QString ListInputField::data() const
+{
+ return QString();
+}
+
+QWidget *ListInputField::createWidget( QWidget *parent )
+{
+ mInputWidget = new ListWidget( this, name(), mTypeName, parent );
+
+ return mInputWidget;
+}
+
+
+ListWidget::ListWidget( InputField *parentField, const QString &name, const QString &type, QWidget *parent )
+ : QWidget( parent ),
+ mParentField( parentField ), mName( name ), mType( type )
+{
+ QGridLayout *layout = new QGridLayout( this, 4, 2, 11, 6 );
+
+ mView = new QListBox( this );
+ layout->addMultiCellWidget( mView, 0, 3, 0, 0 );
+
+ mAddButton = new QPushButton( i18n( "Add" ), this );
+ layout->addWidget( mAddButton, 0, 1 );
+
+ mEditButton = new QPushButton( i18n( "Edit..." ), this );
+ layout->addWidget( mEditButton, 1, 1 );
+
+ mRemoveButton = new QPushButton( i18n( "Remove" ), this );
+ layout->addWidget( mRemoveButton, 2, 1 );
+
+ connect( mAddButton, SIGNAL( clicked() ), SLOT( add() ) );
+ connect( mEditButton, SIGNAL( clicked() ), SLOT( edit() ) );
+ connect( mRemoveButton, SIGNAL( clicked() ), SLOT( remove() ) );
+
+ update();
+}
+
+void ListWidget::update()
+{
+ int pos = mView->currentItem();
+ mView->clear();
+
+ const InputField::List fields = mParentField->childFields();
+ InputField::List::ConstIterator it;
+ for ( it = fields.begin(); it != fields.end(); ++it )
+ mView->insertItem( (*it)->name() );
+
+ mView->setCurrentItem( pos );
+
+ updateButtons();
+}
+
+void ListWidget::add()
+{
+ InputField *field = InputFieldFactory::self()->createField( mName, mType );
+ if ( !field ) {
+ qDebug( "ListInputField: Unable to create field of type %s", mType.latin1() );
+ return;
+ }
+
+ InputDialog dlg( field->createWidget( this ), this );
+ if ( dlg.exec() ) {
+ mParentField->appendChild( field );
+
+ update();
+ } else
+ delete field;
+}
+
+void ListWidget::edit()
+{
+ int pos = mView->currentItem();
+
+ if ( pos == -1 )
+ return;
+
+ InputField *field = mParentField->childFields()[ pos ];
+ if ( !field )
+ return;
+
+ OutputDialog dlg( field->createWidget( this ), this );
+ dlg.exec();
+
+ update();
+}
+
+void ListWidget::remove()
+{
+ int pos = mView->currentItem();
+
+ if ( pos == -1 )
+ return;
+
+ InputField *field = mParentField->childFields()[ pos ];
+ if ( !field )
+ return;
+
+ mParentField->removeChild( field );
+ delete field;
+
+ update();
+}
+
+void ListWidget::updateButtons()
+{
+ bool enabled = (mParentField->childFields().count() > 0);
+
+ mEditButton->setEnabled( enabled );
+ mRemoveButton->setEnabled( enabled );
+}
+
+#include "listinputfield.moc"
diff --git a/kode/kwsdl/kung/listinputfield.h b/kode/kwsdl/kung/listinputfield.h
new file mode 100644
index 00000000..3b3779e2
--- /dev/null
+++ b/kode/kwsdl/kung/listinputfield.h
@@ -0,0 +1,80 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef LIST_INPUTFIELD_H
+#define LIST_INPUTFIELD_H
+
+#include <qwidget.h>
+
+#include "inputfield.h"
+
+class ListWidget;
+class QListBox;
+class QPushButton;
+
+class ListInputField : public SimpleInputField
+{
+ Q_OBJECT
+
+ public:
+ ListInputField( const QString &name, const QString &typeName, const Schema::SimpleType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+
+ private:
+ ListWidget *mInputWidget;
+ QString mTypeName;
+};
+
+class ListWidget : public QWidget
+{
+ Q_OBJECT
+
+ public:
+ ListWidget( InputField *parentField, const QString &name, const QString &type, QWidget *parent );
+
+ void update();
+
+ private slots:
+ void add();
+ void edit();
+ void remove();
+
+ private:
+ void updateButtons();
+
+ InputField *mParentField;
+ QString mName;
+ QString mType;
+
+ QListBox *mView;
+ QPushButton *mAddButton;
+ QPushButton *mEditButton;
+ QPushButton *mRemoveButton;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/loader.cpp b/kode/kwsdl/kung/loader.cpp
new file mode 100644
index 00000000..1b13549f
--- /dev/null
+++ b/kode/kwsdl/kung/loader.cpp
@@ -0,0 +1,89 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qfile.h>
+
+#include <schema/fileprovider.h>
+
+#include "dispatcher.h"
+
+#include "loader.h"
+
+Loader::Loader()
+ : QObject( 0, "KWSDL::Loader" )
+{
+}
+
+void Loader::setWSDLUrl( const QString &wsdlUrl )
+{
+ mWSDLUrl = wsdlUrl;
+ mWSDLBaseUrl = mWSDLUrl.left( mWSDLUrl.findRev( '/' ) );
+
+ mParser.setSchemaBaseUrl( mWSDLBaseUrl );
+}
+
+void Loader::run()
+{
+ download();
+}
+
+void Loader::download()
+{
+ Schema::FileProvider provider;
+
+ QString fileName;
+ if ( provider.get( mWSDLUrl, fileName ) ) {
+ QFile file( fileName );
+ if ( !file.open( IO_ReadOnly ) ) {
+ qDebug( "Unable to download wsdl file %s", mWSDLUrl.latin1() );
+ provider.cleanUp();
+ return;
+ }
+
+ QString errorMsg;
+ int errorLine, errorCol;
+ QDomDocument doc;
+ if ( !doc.setContent( &file, true, &errorMsg, &errorLine, &errorCol ) ) {
+ qDebug( "%s at (%d,%d)", errorMsg.latin1(), errorLine, errorCol );
+ return;
+ }
+
+ parse( doc.documentElement() );
+
+ provider.cleanUp();
+ }
+}
+
+void Loader::parse( const QDomElement &element )
+{
+ mParser.parse( element );
+ execute();
+}
+
+void Loader::execute()
+{
+ mDispatcher = new Dispatcher;
+ mDispatcher->setWSDL( mParser.wsdl() );
+
+ mDispatcher->run();
+}
+
+#include "loader.moc"
diff --git a/kode/kwsdl/kung/loader.h b/kode/kwsdl/kung/loader.h
new file mode 100644
index 00000000..2229eb23
--- /dev/null
+++ b/kode/kwsdl/kung/loader.h
@@ -0,0 +1,55 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef LOADER_H
+#define LOADER_H
+
+#include <kwsdl/parser.h>
+
+class Dispatcher;
+
+class Loader : public QObject
+{
+ Q_OBJECT
+
+ public:
+ Loader();
+
+ void setWSDLUrl( const QString &wsdlUrl );
+
+ public slots:
+ void run();
+
+ private slots:
+ void download();
+ void parse( const QDomElement& );
+ void execute();
+
+ private:
+ QString mWSDLUrl;
+
+ KWSDL::Parser mParser;
+ QString mWSDLBaseUrl;
+
+ Dispatcher *mDispatcher;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/main.cpp b/kode/kwsdl/kung/main.cpp
new file mode 100644
index 00000000..92de443f
--- /dev/null
+++ b/kode/kwsdl/kung/main.cpp
@@ -0,0 +1,64 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <kaboutdata.h>
+#include <kapplication.h>
+#include <kcmdlineargs.h>
+#include <kdebug.h>
+#include <klocale.h>
+
+#include <qtimer.h>
+
+#include "loader.h"
+
+static const KCmdLineOptions options[] =
+{
+ { "+wsdl", I18N_NOOP( "Location of WSDL file" ), 0 },
+ KCmdLineLastOption
+};
+
+int main( int argc, char **argv )
+{
+ KAboutData aboutData( "kung", I18N_NOOP( "KDE WSDL Interpreter" ), "0.1",
+ I18N_NOOP( "KDE WSDL Interpreter" ),
+ KAboutData::License_LGPL );
+
+ aboutData.addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" );
+
+ KCmdLineArgs::init( argc, argv, &aboutData );
+ KCmdLineArgs::addCmdLineOptions( options );
+
+ KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
+
+ if ( args->count() == 0 ) {
+ kdError() << "No WSDL file given." << endl;
+ return 1;
+ }
+
+ KApplication app;
+
+ Loader loader;
+ loader.setWSDLUrl( args->url( 0 ).path() );
+
+ QTimer::singleShot( 0, &loader, SLOT( run() ) );
+
+ return app.exec();
+}
diff --git a/kode/kwsdl/kung/outputdialog.cpp b/kode/kwsdl/kung/outputdialog.cpp
new file mode 100644
index 00000000..7a04db47
--- /dev/null
+++ b/kode/kwsdl/kung/outputdialog.cpp
@@ -0,0 +1,30 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <klocale.h>
+
+#include "outputdialog.h"
+
+OutputDialog::OutputDialog( QWidget *page, QWidget *parent )
+ : KDialogBase( Swallow, "", Ok, Ok, parent, "", true, true )
+{
+ setMainWidget( page );
+}
diff --git a/kode/kwsdl/kung/outputdialog.h b/kode/kwsdl/kung/outputdialog.h
new file mode 100644
index 00000000..e671e084
--- /dev/null
+++ b/kode/kwsdl/kung/outputdialog.h
@@ -0,0 +1,33 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef OUTPUTDIALOG_H
+#define OUTPUTDIALOG_H
+
+#include <kdialogbase.h>
+
+class OutputDialog : public KDialogBase
+{
+ public:
+ OutputDialog( QWidget *page, QWidget *parent );
+};
+
+#endif
diff --git a/kode/kwsdl/kung/pageinputfield.cpp b/kode/kwsdl/kung/pageinputfield.cpp
new file mode 100644
index 00000000..36a5b02d
--- /dev/null
+++ b/kode/kwsdl/kung/pageinputfield.cpp
@@ -0,0 +1,107 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qlabel.h>
+#include <qlayout.h>
+
+#include "inputfieldfactory.h"
+
+#include "pageinputfield.h"
+
+PageInputField::PageInputField( const QString &name, const KWSDL::Message &message )
+ : InputField( name ),
+ mMessage( message )
+{
+ KWSDL::Message::Part::List parts = message.parts();
+ KWSDL::Message::Part::List::ConstIterator it;
+ for ( it = parts.begin(); it != parts.end(); ++it ) {
+ InputField *field = InputFieldFactory::self()->createField( (*it).name(), (*it).type() );
+ if ( !field ) {
+ qDebug( "PageInputField: Unable to create input field for %s (%s)", (*it).name().latin1(), (*it).type().latin1() );
+ } else {
+ appendChild( field );
+ }
+ }
+}
+
+void PageInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "PageInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ QDomNode node = element.firstChild();
+ while ( !node.isNull() ) {
+ QDomElement child = node.toElement();
+ if ( !child.isNull() ) {
+ InputField *field = childField( child.tagName() );
+ if ( !field ) {
+ qDebug( "PageInputField: Child field %s does not exists", child.tagName().latin1() );
+ } else {
+ field->setXMLData( child );
+ }
+ }
+
+ node = node.nextSibling();
+ }
+}
+
+void PageInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ QDomElement element = document.createElement( "ns1:" + mName );
+
+ InputField::List::Iterator it;
+ for ( it = mFields.begin(); it != mFields.end(); ++it )
+ (*it)->xmlData( document, element );
+
+ parent.appendChild( element );
+}
+
+void PageInputField::setData( const QString& )
+{
+}
+
+QString PageInputField::data() const
+{
+ return QString();
+}
+
+QWidget *PageInputField::createWidget( QWidget *parent )
+{
+ QWidget *mInputWidget = new QWidget( parent, "PageInputWidget" );
+ QGridLayout *layout = new QGridLayout( mInputWidget, 2, 2, 11, 6 );
+
+ InputField::List::Iterator it;
+ int row = 0;
+ for ( it = mFields.begin(); it != mFields.end(); ++it, ++row ) {
+ QLabel *label = new QLabel( (*it)->name(), mInputWidget );
+ label->setAlignment( Qt::AlignTop );
+ layout->addWidget( label, row, 0 );
+ layout->addWidget( (*it)->createWidget( mInputWidget ), row, 1 );
+ }
+
+ layout->setRowStretch( ++row, 1 );
+
+ return mInputWidget;
+}
+
+#include "pageinputfield.moc"
diff --git a/kode/kwsdl/kung/pageinputfield.h b/kode/kwsdl/kung/pageinputfield.h
new file mode 100644
index 00000000..c63e97ae
--- /dev/null
+++ b/kode/kwsdl/kung/pageinputfield.h
@@ -0,0 +1,51 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef PAGE_INPUTFIELD_H
+#define PAGE_INPUTFIELD_H
+
+#include <qobject.h>
+
+#include <kwsdl/message.h>
+
+#include "inputfield.h"
+
+class PageInputField : public InputField
+{
+ Q_OBJECT
+
+ public:
+ PageInputField( const QString &name, const KWSDL::Message &message );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+
+ private:
+ QWidget *mInputWidget;
+ const KWSDL::Message mMessage;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/simplebaseinputfield.cpp b/kode/kwsdl/kung/simplebaseinputfield.cpp
new file mode 100644
index 00000000..f9cb1bd5
--- /dev/null
+++ b/kode/kwsdl/kung/simplebaseinputfield.cpp
@@ -0,0 +1,120 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <schema/simpletype.h>
+
+#include "inputfieldfactory.h"
+
+#include "simplebaseinputfield.h"
+
+SimpleBaseInputField::SimpleBaseInputField( const QString &name, const Schema::SimpleType *type )
+ : SimpleInputField( name, type )
+{
+ if ( type->subType() == Schema::SimpleType::TypeRestriction ) {
+ InputField *field = InputFieldFactory::self()->createBasicField( name, type->baseTypeName(), type );
+ if ( !field ) {
+ qDebug( "SimpleBaseInputField: Unable to create field of type %s", type->baseTypeName().latin1() );
+ } else {
+ appendChild( field );
+ }
+ } else {
+ qDebug( "SimpleBaseInputField: Unsupported subtype" );
+ }
+}
+
+void SimpleBaseInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "SimpleBaseInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
+ InputField *field = childField( element.tagName() );
+ if ( !field ) {
+ qDebug( "SimpleBaseInputField: Child field %s does not exists", element.tagName().latin1() );
+ } else {
+ field->setXMLData( element );
+ }
+ } else {
+ qDebug( "SimpleBaseInputField: Unsupported subtype" );
+ }
+}
+
+void SimpleBaseInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
+ InputField *field = mFields.first();
+ if ( !field ) {
+ qDebug( "SimpleBaseInputField: No child found" );
+ } else {
+ field->xmlData( document, parent );
+ }
+ } else {
+ qDebug( "SimpleBaseInputField: Unsupported subtype" );
+ }
+}
+
+void SimpleBaseInputField::setData( const QString &data )
+{
+ if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
+ InputField *field = mFields.first();
+ if ( !field ) {
+ qDebug( "SimpleBaseInputField: No child found" );
+ } else {
+ field->setData( data );
+ }
+ } else {
+ qDebug( "SimpleBaseInputField: Unsupported subtype" );
+ }
+}
+
+QString SimpleBaseInputField::data() const
+{
+ if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
+ InputField *field = mFields.first();
+ if ( !field ) {
+ qDebug( "SimpleBaseInputField: No child found" );
+ } else {
+ field->data();
+ }
+ } else {
+ qDebug( "SimpleBaseInputField: Unsupported subtype" );
+ }
+
+ return QString();
+}
+
+QWidget *SimpleBaseInputField::createWidget( QWidget *parent )
+{
+ if ( mType->subType() == Schema::SimpleType::TypeRestriction ) {
+ InputField *field = mFields.first();
+ if ( !field ) {
+ qDebug( "SimpleBaseInputField: No child found" );
+ return 0;
+ } else {
+ return field->createWidget( parent );
+ }
+ } else {
+ qDebug( "SimpleBaseInputField: Unsupported subtype" );
+ return 0;
+ }
+}
diff --git a/kode/kwsdl/kung/simplebaseinputfield.h b/kode/kwsdl/kung/simplebaseinputfield.h
new file mode 100644
index 00000000..7af65ab3
--- /dev/null
+++ b/kode/kwsdl/kung/simplebaseinputfield.h
@@ -0,0 +1,41 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef SIMPLEBASE_INPUTFIELD_H
+#define SIMPLEBASE_INPUTFIELD_H
+
+#include "inputfield.h"
+
+class SimpleBaseInputField : public SimpleInputField
+{
+ public:
+ SimpleBaseInputField( const QString &name, const Schema::SimpleType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+};
+
+#endif
diff --git a/kode/kwsdl/kung/stringinputfield.cpp b/kode/kwsdl/kung/stringinputfield.cpp
new file mode 100644
index 00000000..e0dc10cc
--- /dev/null
+++ b/kode/kwsdl/kung/stringinputfield.cpp
@@ -0,0 +1,100 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <qlineedit.h>
+#include <qvalidator.h>
+
+#include <schema/simpletype.h>
+
+#include "stringinputfield.h"
+
+StringInputField::StringInputField( const QString &name, const QString &typeName, const Schema::SimpleType *type )
+ : SimpleInputField( name, type ),
+ mTypeName( typeName )
+{
+}
+
+void StringInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "StringInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ setData( element.text() );
+}
+
+void StringInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ QDomElement element = document.createElement( mName );
+ element.setAttribute( "xsi:type", "xsd:" + mTypeName );
+ QDomText text = document.createTextNode( data() );
+ element.appendChild( text );
+
+ parent.appendChild( element );
+}
+
+void StringInputField::setData( const QString &data )
+{
+ mValue = data;
+}
+
+QString StringInputField::data() const
+{
+ return mValue;
+}
+
+QWidget *StringInputField::createWidget( QWidget *parent )
+{
+ mInputWidget = new QLineEdit( parent );
+
+ if ( mType ) {
+ if ( mType->facetType() & Schema::SimpleType::LENGTH ) // TODO: using QValidator here?
+ mInputWidget->setMaxLength( mType->facetLength() );
+
+ if ( mType->facetType() & Schema::SimpleType::MINLEN ) {
+ // TODO: using QValidator here?
+ // mInputWidget->setMaxLength( type->facetMinimumLength() );
+ }
+
+ if ( mType->facetType() & Schema::SimpleType::MAXLEN )
+ mInputWidget->setMaxLength( mType->facetMaximumLength() );
+
+ if ( mType->facetType() & Schema::SimpleType::PATTERN )
+ mInputWidget->setValidator( new QRegExpValidator( mType->facetPattern(), mInputWidget ) );
+ }
+
+ mInputWidget->setText( mValue );
+
+ connect( mInputWidget, SIGNAL( textChanged( const QString& ) ),
+ this, SLOT( inputChanged( const QString& ) ) );
+
+ return mInputWidget;
+}
+
+void StringInputField::inputChanged( const QString &text )
+{
+ mValue = text;
+
+ emit modified();
+}
+
+#include "stringinputfield.moc"
diff --git a/kode/kwsdl/kung/stringinputfield.h b/kode/kwsdl/kung/stringinputfield.h
new file mode 100644
index 00000000..2713dded
--- /dev/null
+++ b/kode/kwsdl/kung/stringinputfield.h
@@ -0,0 +1,55 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef STRING_INPUTFIELD_H
+#define STRING_INPUTFIELD_H
+
+#include <qobject.h>
+
+#include "inputfield.h"
+
+class QLineEdit;
+
+class StringInputField : public SimpleInputField
+{
+ Q_OBJECT
+
+ public:
+ StringInputField( const QString &name, const QString &typeName, const Schema::SimpleType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+
+ private slots:
+ void inputChanged( const QString& );
+
+ private:
+ QLineEdit *mInputWidget;
+ QString mValue;
+ QString mTypeName;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/timeinputfield.cpp b/kode/kwsdl/kung/timeinputfield.cpp
new file mode 100644
index 00000000..0864b8c1
--- /dev/null
+++ b/kode/kwsdl/kung/timeinputfield.cpp
@@ -0,0 +1,81 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include <ktimewidget.h>
+
+#include "timeinputfield.h"
+
+TimeInputField::TimeInputField( const QString &name, const Schema::SimpleType *type )
+ : SimpleInputField( name, type ),
+ mValue( QTime::currentTime() )
+{
+}
+
+void TimeInputField::setXMLData( const QDomElement &element )
+{
+ if ( mName != element.tagName() ) {
+ qDebug( "TimeInputField: Wrong dom element passed: expected %s, got %s", mName.latin1(), element.tagName().latin1() );
+ return;
+ }
+
+ setData( element.text() );
+}
+
+void TimeInputField::xmlData( QDomDocument &document, QDomElement &parent )
+{
+ QDomElement element = document.createElement( mName );
+ element.setAttribute( "xsi:type", "xsd:time" );
+ QDomText text = document.createTextNode( data() );
+ element.appendChild( text );
+
+ parent.appendChild( element );
+}
+
+void TimeInputField::setData( const QString &data )
+{
+ mValue = QTime::fromString( data, Qt::ISODate );
+}
+
+QString TimeInputField::data() const
+{
+ return mValue.toString( Qt::ISODate );
+}
+
+QWidget *TimeInputField::createWidget( QWidget *parent )
+{
+ mInputWidget = new KTimeWidget( parent );
+
+ mInputWidget->setTime( mValue );
+
+ connect( mInputWidget, SIGNAL( valueChanged( const QTime& ) ),
+ this, SLOT( inputChanged( const QTime& ) ) );
+
+ return mInputWidget;
+}
+
+void TimeInputField::inputChanged( const QTime &time )
+{
+ mValue = time;
+
+ emit modified();
+}
+
+#include "timeinputfield.moc"
diff --git a/kode/kwsdl/kung/timeinputfield.h b/kode/kwsdl/kung/timeinputfield.h
new file mode 100644
index 00000000..6edf9540
--- /dev/null
+++ b/kode/kwsdl/kung/timeinputfield.h
@@ -0,0 +1,55 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef TIME_INPUTFIELD_H
+#define TIME_INPUTFIELD_H
+
+#include <qdatetime.h>
+#include <qobject.h>
+
+#include "inputfield.h"
+
+class KTimeWidget;
+
+class TimeInputField : public SimpleInputField
+{
+ Q_OBJECT
+
+ public:
+ TimeInputField( const QString &name, const Schema::SimpleType *type );
+
+ virtual void setXMLData( const QDomElement &element );
+ virtual void xmlData( QDomDocument &document, QDomElement &parent );
+
+ virtual void setData( const QString &data );
+ virtual QString data() const;
+
+ virtual QWidget *createWidget( QWidget *parent );
+
+ private slots:
+ void inputChanged( const QTime& );
+
+ private:
+ KTimeWidget *mInputWidget;
+ QTime mValue;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/transport.cpp b/kode/kwsdl/kung/transport.cpp
new file mode 100644
index 00000000..5cb414c9
--- /dev/null
+++ b/kode/kwsdl/kung/transport.cpp
@@ -0,0 +1,69 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+
+#include "transport.h"
+
+#include <kdebug.h>
+
+Transport::Transport( const QString &url )
+{
+ mUrl = url;
+ qDebug( "url=%s", url.latin1() );
+}
+
+void Transport::query( const QString &xml )
+{
+ mData.truncate( 0 );
+
+ QByteArray postData;
+ QDataStream stream( postData, IO_WriteOnly );
+ stream.writeRawBytes( xml.utf8(), xml.utf8().length() );
+
+ KIO::TransferJob* job = KIO::http_post( KURL( mUrl ), postData, false );
+ if ( !job ) {
+ kdWarning() << "Unable to create KIO job for " << mUrl << endl;
+ return;
+ }
+
+ job->addMetaData( "UserAgent", "KDE Kung" );
+ job->addMetaData( "content-type", "Content-Type: text/xml; charset=utf-8" );
+
+ connect( job, SIGNAL( data( KIO::Job*, const QByteArray& ) ), this, SLOT( slotData( KIO::Job*, const QByteArray& ) ) );
+ connect( job, SIGNAL( result( KIO::Job* ) ), this, SLOT( slotResult( KIO::Job* ) ) );
+}
+
+void Transport::slotData( KIO::Job*, const QByteArray &data )
+{
+ unsigned int oldSize = mData.size();
+ mData.resize( oldSize + data.size() );
+ memcpy( mData.data() + oldSize, data.data(), data.size() );
+}
+
+void Transport::slotResult( KIO::Job* job )
+{
+ if ( job->error() != 0 )
+ emit error( job->errorText() );
+ else
+ emit result( QString::fromUtf8( mData.data(), mData.size() ) );
+}
+
+
+#include "transport.moc"
+
diff --git a/kode/kwsdl/kung/transport.h b/kode/kwsdl/kung/transport.h
new file mode 100644
index 00000000..5b7662fe
--- /dev/null
+++ b/kode/kwsdl/kung/transport.h
@@ -0,0 +1,47 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+*/
+#ifndef TRANSPORT_H
+#define TRANSPORT_H
+
+#include <qobject.h>
+#include <kio/job.h>
+
+class Transport : public QObject
+{
+ Q_OBJECT
+
+ public:
+ Transport( const QString &url );
+ void query( const QString &xml );
+
+ signals:
+ void result( const QString &xml );
+ void error( const QString &errorMsg );
+
+ private slots:
+ void slotData( KIO::Job*, const QByteArray &data );
+ void slotResult( KIO::Job* job );
+
+ private:
+ QString mUrl;
+ QByteArray mData;
+};
+
+#endif
diff --git a/kode/kwsdl/kung/wsclconversationmanager.cpp b/kode/kwsdl/kung/wsclconversationmanager.cpp
new file mode 100644
index 00000000..c553edee
--- /dev/null
+++ b/kode/kwsdl/kung/wsclconversationmanager.cpp
@@ -0,0 +1,50 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#include "wsclconversationmanager.h"
+
+WSCLConversationManager::WSCLConversationManager()
+{
+}
+
+WSCLConversationManager::WSCLConversationManager( const WSCL::Conversation &conversation )
+ : mConversation( conversation )
+{
+}
+
+void WSCLConversationManager::setConversation( const WSCL::Conversation &conversation )
+{
+ mConversation = conversation;
+}
+
+QStringList WSCLConversationManager::nextActions( const QString &currentAction, const QString &condition )
+{
+ WSCL::Transition::List transitions = mConversation.transitions();
+ WSCL::Transition::List::ConstIterator it;
+ for ( it = transitions.begin(); it != transitions.end(); ++it ) {
+ if ( (*it).sourceInteraction() == currentAction ) {
+ if ( (*it).sourceInteractionCondition() == condition )
+ return (*it).destinationInteraction();
+ }
+ }
+
+ return QStringList();
+}
diff --git a/kode/kwsdl/kung/wsclconversationmanager.h b/kode/kwsdl/kung/wsclconversationmanager.h
new file mode 100644
index 00000000..eb02ab70
--- /dev/null
+++ b/kode/kwsdl/kung/wsclconversationmanager.h
@@ -0,0 +1,43 @@
+/*
+ This file is part of Kung.
+
+ Copyright (c) 2005 Tobias Koenig <tokoe@kde.org>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+*/
+
+#ifndef WSCL_CONVERSATIONMANAGER_H
+#define WSCL_CONVERSATIONMANAGER_H
+
+#include <wscl/conversation.h>
+
+#include "conversationmanager.h"
+
+class WSCLConversationManager : public ConversationManager
+{
+ public:
+ WSCLConversationManager();
+ WSCLConversationManager( const WSCL::Conversation &conversation );
+
+ void setConversation( const WSCL::Conversation &conversation );
+
+ QStringList nextActions( const QString &currentAction, const QString &condition = QString() );
+
+ private:
+ WSCL::Conversation mConversation;
+};
+
+#endif