diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch) | |
tree | 67208f7c145782a7e90b123b982ca78d88cc2c87 /kode/kwsdl/tests | |
download | tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kode/kwsdl/tests')
22 files changed, 2094 insertions, 0 deletions
diff --git a/kode/kwsdl/tests/Makefile.am b/kode/kwsdl/tests/Makefile.am new file mode 100644 index 000000000..fbd398ee6 --- /dev/null +++ b/kode/kwsdl/tests/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = google diff --git a/kode/kwsdl/tests/google/Makefile.am b/kode/kwsdl/tests/google/Makefile.am new file mode 100644 index 000000000..171f0c5cb --- /dev/null +++ b/kode/kwsdl/tests/google/Makefile.am @@ -0,0 +1,9 @@ +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/libkdepim $(all_includes) +METASOURCES = AUTO + +bin_PROGRAMS = googletest + +googletest_SOURCES = main.cc googlesearch.cc transport.cpp resultelementarray.cpp directorycategoryarray.cpp googlesearchresult.cpp directorycategory.cpp resultelement.cpp serializer.cpp googlesearchservice.cpp +googletest_LDADD = -lkdecore -lkio +googletest_LDFLAGS = $(all_libraries) $(KDE_RPATH) + diff --git a/kode/kwsdl/tests/google/README b/kode/kwsdl/tests/google/README new file mode 100644 index 000000000..cfe831598 --- /dev/null +++ b/kode/kwsdl/tests/google/README @@ -0,0 +1,8 @@ +This application shows how easy it is to use a web service with +code, generated by kwsdl_compiler. + +Only the files main.cc, googlesearch.cc and googlesearch.hh are +written manually, all other files were created by + + kwsdl_compiler -d kwsdl/tests/google/ GoogleSearch.wsdl + diff --git a/kode/kwsdl/tests/google/directorycategory.cpp b/kode/kwsdl/tests/google/directorycategory.cpp new file mode 100644 index 000000000..87f9c5f1a --- /dev/null +++ b/kode/kwsdl/tests/google/directorycategory.cpp @@ -0,0 +1,64 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "directorycategory.h" + +#include <serializer.h> +#include <qstring.h> + +void DirectoryCategory::setFullViewableName( QString* fullViewableName ) +{ + mFullViewableName = fullViewableName; +} + +QString*DirectoryCategory::fullViewableName() const +{ + return mFullViewableName; +} + +void DirectoryCategory::setSpecialEncoding( QString* specialEncoding ) +{ + mSpecialEncoding = specialEncoding; +} + +QString*DirectoryCategory::specialEncoding() const +{ + return mSpecialEncoding; +} + +DirectoryCategory::DirectoryCategory() +{ + mFullViewableName = 0; + mSpecialEncoding = 0; +} + +DirectoryCategory::~DirectoryCategory() +{ + delete mFullViewableName; + mFullViewableName = 0; + delete mSpecialEncoding; + mSpecialEncoding = 0; +} + + diff --git a/kode/kwsdl/tests/google/directorycategory.h b/kode/kwsdl/tests/google/directorycategory.h new file mode 100644 index 000000000..0ce1c417d --- /dev/null +++ b/kode/kwsdl/tests/google/directorycategory.h @@ -0,0 +1,44 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef DIRECTORYCATEGORY_H +#define DIRECTORYCATEGORY_H + +class QString; + +class DirectoryCategory +{ + public: + void setFullViewableName( QString* fullViewableName ); + QString*fullViewableName() const; + void setSpecialEncoding( QString* specialEncoding ); + QString*specialEncoding() const; + DirectoryCategory(); + ~DirectoryCategory(); + + private: + QString*mFullViewableName; + QString*mSpecialEncoding; +}; + +#endif diff --git a/kode/kwsdl/tests/google/directorycategoryarray.cpp b/kode/kwsdl/tests/google/directorycategoryarray.cpp new file mode 100644 index 000000000..724cf26cf --- /dev/null +++ b/kode/kwsdl/tests/google/directorycategoryarray.cpp @@ -0,0 +1,52 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "directorycategoryarray.h" + +#include <serializer.h> +#include <directorycategory.h> +#include <qptrlist.h> + +void DirectoryCategoryArray::setItems( QPtrList<DirectoryCategory>* items ) +{ + mItems = items; +} + +QPtrList<DirectoryCategory>*DirectoryCategoryArray::items() const +{ + return mItems; +} + +DirectoryCategoryArray::DirectoryCategoryArray() +{ + mItems = 0; +} + +DirectoryCategoryArray::~DirectoryCategoryArray() +{ + delete mItems; + mItems = 0; +} + + diff --git a/kode/kwsdl/tests/google/directorycategoryarray.h b/kode/kwsdl/tests/google/directorycategoryarray.h new file mode 100644 index 000000000..db19d9bfa --- /dev/null +++ b/kode/kwsdl/tests/google/directorycategoryarray.h @@ -0,0 +1,43 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef DIRECTORYCATEGORYARRAY_H +#define DIRECTORYCATEGORYARRAY_H + +#include <qptrlist.h> + +class DirectoryCategory; + +class DirectoryCategoryArray +{ + public: + void setItems( QPtrList<DirectoryCategory>* items ); + QPtrList<DirectoryCategory>*items() const; + DirectoryCategoryArray(); + ~DirectoryCategoryArray(); + + private: + QPtrList<DirectoryCategory>*mItems; +}; + +#endif diff --git a/kode/kwsdl/tests/google/googlesearch.cc b/kode/kwsdl/tests/google/googlesearch.cc new file mode 100644 index 000000000..2e1374b47 --- /dev/null +++ b/kode/kwsdl/tests/google/googlesearch.cc @@ -0,0 +1,94 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "googlesearch.hh" +#include "resultelement.h" +#include "resultelementarray.h" + +GoogleSearch::GoogleSearch() + : QObject( 0, "" ) +{ + connect( &mService, SIGNAL( doGetCachedPageResponse( QByteArray* ) ), + this, SLOT( cachedPageResult( QByteArray* ) ) ); + connect( &mService, SIGNAL( doSpellingSuggestionResponse( QString* ) ), + this, SLOT( spellingSuggestionResult( QString* ) ) ); + connect( &mService, SIGNAL( doGoogleSearchResponse( GoogleSearchResult* ) ), + this, SLOT( googleSearchResult( GoogleSearchResult* ) ) ); + + mKey = ""; +} + +void GoogleSearch::cachedPage( const QString &url ) +{ + mService.doGetCachedPage( new QString( mKey ), new QString( url ) ); +} + +void GoogleSearch::spellingSuggestion( const QString &phrase ) +{ + mService.doSpellingSuggestion( new QString( mKey ), new QString( phrase ) ); +} + +void GoogleSearch::googleSearch( const QString &query, int start, int maxResults, bool filter, + const QString &restrict, bool safeSearch, const QString &lr, const QString &ie, + const QString &oe ) +{ + mService.doGoogleSearch( new QString( mKey ), new QString( query ), new int( start ), new int( maxResults ), + new bool( filter ), new QString( restrict ), new bool( safeSearch ), new QString( lr ), + new QString( ie ), new QString( oe ) ); +} + +void GoogleSearch::cachedPageResult( QByteArray *array ) +{ + qDebug( "--------------- Cached Page Results ---------------------" ); + qDebug( "%s", array->data() ); + qDebug( "---------------------------------------------------------" ); + + delete array; +} + +void GoogleSearch::spellingSuggestionResult( QString *word ) +{ + qDebug( "--------------- Spelling Suggestion ---------------------" ); + qDebug( "%s", word->latin1() ); + qDebug( "---------------------------------------------------------" ); + + delete word; +} + +void GoogleSearch::googleSearchResult( GoogleSearchResult *result ) +{ + qDebug( "--------------------- Search Results ---------------------" ); + ResultElementArray *array = result->resultElements(); + QPtrList<ResultElement> *list = array->items(); + QPtrListIterator<ResultElement> it( *list ); + while ( it.current() != 0 ) { + qDebug( "%s: %s", it.current()->summary()->latin1(), it.current()->uRL()->latin1() ); + ++it; + } + qDebug( "---------------------------------------------------------" ); + + delete result; +} + +#include "googlesearch.moc" diff --git a/kode/kwsdl/tests/google/googlesearch.hh b/kode/kwsdl/tests/google/googlesearch.hh new file mode 100644 index 000000000..21aed9574 --- /dev/null +++ b/kode/kwsdl/tests/google/googlesearch.hh @@ -0,0 +1,60 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#ifndef GOOGLESEARCH_H +#define GOOGLESEARCH_H + +#include <qobject.h> +#include "googlesearchservice.h" + +class GoogleSearch : public QObject +{ + Q_OBJECT + + public: + GoogleSearch(); + + void cachedPage( const QString &url ); + void spellingSuggestion( const QString &phrase ); + void googleSearch( const QString &query, + int start, + int maxResults, + bool filter, + const QString &restrict, + bool safeSearch, + const QString &lr, + const QString &ie, + const QString &oe ); + + private slots: + void cachedPageResult( QByteArray* ); + void spellingSuggestionResult( QString* ); + void googleSearchResult( GoogleSearchResult* ); + + private: + QString mKey; + GoogleSearchService mService; +}; + +#endif diff --git a/kode/kwsdl/tests/google/googlesearchresult.cpp b/kode/kwsdl/tests/google/googlesearchresult.cpp new file mode 100644 index 000000000..2d3ce11e2 --- /dev/null +++ b/kode/kwsdl/tests/google/googlesearchresult.cpp @@ -0,0 +1,183 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "googlesearchresult.h" + +#include <serializer.h> +#include <qstring.h> +#include <resultelementarray.h> +#include <directorycategoryarray.h> + +void GoogleSearchResult::setDocumentFiltering( bool* documentFiltering ) +{ + mDocumentFiltering = documentFiltering; +} + +bool*GoogleSearchResult::documentFiltering() const +{ + return mDocumentFiltering; +} + +void GoogleSearchResult::setSearchComments( QString* searchComments ) +{ + mSearchComments = searchComments; +} + +QString*GoogleSearchResult::searchComments() const +{ + return mSearchComments; +} + +void GoogleSearchResult::setEstimatedTotalResultsCount( int* estimatedTotalResultsCount ) +{ + mEstimatedTotalResultsCount = estimatedTotalResultsCount; +} + +int*GoogleSearchResult::estimatedTotalResultsCount() const +{ + return mEstimatedTotalResultsCount; +} + +void GoogleSearchResult::setEstimateIsExact( bool* estimateIsExact ) +{ + mEstimateIsExact = estimateIsExact; +} + +bool*GoogleSearchResult::estimateIsExact() const +{ + return mEstimateIsExact; +} + +void GoogleSearchResult::setResultElements( ResultElementArray* resultElements ) +{ + mResultElements = resultElements; +} + +ResultElementArray*GoogleSearchResult::resultElements() const +{ + return mResultElements; +} + +void GoogleSearchResult::setSearchQuery( QString* searchQuery ) +{ + mSearchQuery = searchQuery; +} + +QString*GoogleSearchResult::searchQuery() const +{ + return mSearchQuery; +} + +void GoogleSearchResult::setStartIndex( int* startIndex ) +{ + mStartIndex = startIndex; +} + +int*GoogleSearchResult::startIndex() const +{ + return mStartIndex; +} + +void GoogleSearchResult::setEndIndex( int* endIndex ) +{ + mEndIndex = endIndex; +} + +int*GoogleSearchResult::endIndex() const +{ + return mEndIndex; +} + +void GoogleSearchResult::setSearchTips( QString* searchTips ) +{ + mSearchTips = searchTips; +} + +QString*GoogleSearchResult::searchTips() const +{ + return mSearchTips; +} + +void GoogleSearchResult::setDirectoryCategories( DirectoryCategoryArray* directoryCategories ) +{ + mDirectoryCategories = directoryCategories; +} + +DirectoryCategoryArray*GoogleSearchResult::directoryCategories() const +{ + return mDirectoryCategories; +} + +void GoogleSearchResult::setSearchTime( double* searchTime ) +{ + mSearchTime = searchTime; +} + +double*GoogleSearchResult::searchTime() const +{ + return mSearchTime; +} + +GoogleSearchResult::GoogleSearchResult() +{ + mDocumentFiltering = 0; + mSearchComments = 0; + mEstimatedTotalResultsCount = 0; + mEstimateIsExact = 0; + mResultElements = 0; + mSearchQuery = 0; + mStartIndex = 0; + mEndIndex = 0; + mSearchTips = 0; + mDirectoryCategories = 0; + mSearchTime = 0; +} + +GoogleSearchResult::~GoogleSearchResult() +{ + delete mDocumentFiltering; + mDocumentFiltering = 0; + delete mSearchComments; + mSearchComments = 0; + delete mEstimatedTotalResultsCount; + mEstimatedTotalResultsCount = 0; + delete mEstimateIsExact; + mEstimateIsExact = 0; + delete mResultElements; + mResultElements = 0; + delete mSearchQuery; + mSearchQuery = 0; + delete mStartIndex; + mStartIndex = 0; + delete mEndIndex; + mEndIndex = 0; + delete mSearchTips; + mSearchTips = 0; + delete mDirectoryCategories; + mDirectoryCategories = 0; + delete mSearchTime; + mSearchTime = 0; +} + + diff --git a/kode/kwsdl/tests/google/googlesearchresult.h b/kode/kwsdl/tests/google/googlesearchresult.h new file mode 100644 index 000000000..542fb6864 --- /dev/null +++ b/kode/kwsdl/tests/google/googlesearchresult.h @@ -0,0 +1,73 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef GOOGLESEARCHRESULT_H +#define GOOGLESEARCHRESULT_H + +class QString; +class ResultElementArray; +class DirectoryCategoryArray; + +class GoogleSearchResult +{ + public: + void setDocumentFiltering( bool* documentFiltering ); + bool*documentFiltering() const; + void setSearchComments( QString* searchComments ); + QString*searchComments() const; + void setEstimatedTotalResultsCount( int* estimatedTotalResultsCount ); + int*estimatedTotalResultsCount() const; + void setEstimateIsExact( bool* estimateIsExact ); + bool*estimateIsExact() const; + void setResultElements( ResultElementArray* resultElements ); + ResultElementArray*resultElements() const; + void setSearchQuery( QString* searchQuery ); + QString*searchQuery() const; + void setStartIndex( int* startIndex ); + int*startIndex() const; + void setEndIndex( int* endIndex ); + int*endIndex() const; + void setSearchTips( QString* searchTips ); + QString*searchTips() const; + void setDirectoryCategories( DirectoryCategoryArray* directoryCategories ); + DirectoryCategoryArray*directoryCategories() const; + void setSearchTime( double* searchTime ); + double*searchTime() const; + GoogleSearchResult(); + ~GoogleSearchResult(); + + private: + bool*mDocumentFiltering; + QString*mSearchComments; + int*mEstimatedTotalResultsCount; + bool*mEstimateIsExact; + ResultElementArray*mResultElements; + QString*mSearchQuery; + int*mStartIndex; + int*mEndIndex; + QString*mSearchTips; + DirectoryCategoryArray*mDirectoryCategories; + double*mSearchTime; +}; + +#endif diff --git a/kode/kwsdl/tests/google/googlesearchservice.cpp b/kode/kwsdl/tests/google/googlesearchservice.cpp new file mode 100644 index 000000000..555850713 --- /dev/null +++ b/kode/kwsdl/tests/google/googlesearchservice.cpp @@ -0,0 +1,208 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "googlesearchservice.h" + +#include <serializer.h> + +void GoogleSearchService::doGetCachedPage( QString* key, QString* url ) +{ + 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 ); + QDomElement method = doc.createElement( "ns1:doGetCachedPage" ); + method.setAttribute( "xmlns:ns1", "urn:GoogleSearch" ); + method.setAttribute( "SOAP-ENV:encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/" ); + body.appendChild( method ); + + Serializer::marshal( doc, method, "key", key ); + delete key; + Serializer::marshal( doc, method, "url", url ); + delete url; + qDebug( "%s", doc.toString().latin1() ); + mDoGetCachedPageTransport->query( doc.toString() ); +} + +void GoogleSearchService::doGetCachedPageResponseSlot( const QString &xml ) +{ + QDomDocument doc; + QString errorMsg; + int column, row; + + qDebug( "%s", xml.latin1() ); + + if ( !doc.setContent( xml, true, &errorMsg, &row, &column ) ) { + qDebug( "Unable to parse xml: %s (%d:%d)", errorMsg.latin1(), row, column ); + return; + } + + QByteArray* value = new QByteArray; + QDomElement envelope = doc.documentElement(); + QDomElement body = envelope.firstChild().toElement(); + QDomElement method = body.firstChild().toElement(); + Serializer::demarshal( method.firstChild().toElement(), value ); + + emit doGetCachedPageResponse( value ); +} + +void GoogleSearchService::doSpellingSuggestion( QString* key, QString* phrase ) +{ + 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 ); + QDomElement method = doc.createElement( "ns1:doSpellingSuggestion" ); + method.setAttribute( "xmlns:ns1", "urn:GoogleSearch" ); + method.setAttribute( "SOAP-ENV:encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/" ); + body.appendChild( method ); + + Serializer::marshal( doc, method, "key", key ); + delete key; + Serializer::marshal( doc, method, "phrase", phrase ); + delete phrase; + qDebug( "%s", doc.toString().latin1() ); + mDoSpellingSuggestionTransport->query( doc.toString() ); +} + +void GoogleSearchService::doSpellingSuggestionResponseSlot( const QString &xml ) +{ + QDomDocument doc; + QString errorMsg; + int column, row; + + qDebug( "%s", xml.latin1() ); + + if ( !doc.setContent( xml, true, &errorMsg, &row, &column ) ) { + qDebug( "Unable to parse xml: %s (%d:%d)", errorMsg.latin1(), row, column ); + return; + } + + QString* value = new QString; + QDomElement envelope = doc.documentElement(); + QDomElement body = envelope.firstChild().toElement(); + QDomElement method = body.firstChild().toElement(); + Serializer::demarshal( method.firstChild().toElement(), value ); + + emit doSpellingSuggestionResponse( value ); +} + +void GoogleSearchService::doGoogleSearch( QString* key, QString* q, int* start, int* maxResults, bool* filter, QString* restrict, bool* safeSearch, QString* lr, QString* ie, QString* oe ) +{ + 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 ); + QDomElement method = doc.createElement( "ns1:doGoogleSearch" ); + method.setAttribute( "xmlns:ns1", "urn:GoogleSearch" ); + method.setAttribute( "SOAP-ENV:encodingStyle", "http://schemas.xmlsoap.org/soap/encoding/" ); + body.appendChild( method ); + + Serializer::marshal( doc, method, "key", key ); + delete key; + Serializer::marshal( doc, method, "q", q ); + delete q; + Serializer::marshal( doc, method, "start", start ); + delete start; + Serializer::marshal( doc, method, "maxResults", maxResults ); + delete maxResults; + Serializer::marshal( doc, method, "filter", filter ); + delete filter; + Serializer::marshal( doc, method, "restrict", restrict ); + delete restrict; + Serializer::marshal( doc, method, "safeSearch", safeSearch ); + delete safeSearch; + Serializer::marshal( doc, method, "lr", lr ); + delete lr; + Serializer::marshal( doc, method, "ie", ie ); + delete ie; + Serializer::marshal( doc, method, "oe", oe ); + delete oe; + qDebug( "%s", doc.toString().latin1() ); + mDoGoogleSearchTransport->query( doc.toString() ); +} + +void GoogleSearchService::doGoogleSearchResponseSlot( const QString &xml ) +{ + QDomDocument doc; + QString errorMsg; + int column, row; + + qDebug( "%s", xml.latin1() ); + + if ( !doc.setContent( xml, true, &errorMsg, &row, &column ) ) { + qDebug( "Unable to parse xml: %s (%d:%d)", errorMsg.latin1(), row, column ); + return; + } + + GoogleSearchResult* value = new GoogleSearchResult; + QDomElement envelope = doc.documentElement(); + QDomElement body = envelope.firstChild().toElement(); + QDomElement method = body.firstChild().toElement(); + Serializer::demarshal( method.firstChild().toElement(), value ); + + emit doGoogleSearchResponse( value ); +} + +GoogleSearchService::GoogleSearchService() +{ + mDoGetCachedPageTransport = new Transport( "http://api.google.com/search/beta2" ); + connect( mDoGetCachedPageTransport, SIGNAL( result( const QString& ) ), + this, SLOT( doGetCachedPageResponseSlot( const QString& ) ) ); + mDoSpellingSuggestionTransport = new Transport( "http://api.google.com/search/beta2" ); + connect( mDoSpellingSuggestionTransport, SIGNAL( result( const QString& ) ), + this, SLOT( doSpellingSuggestionResponseSlot( const QString& ) ) ); + mDoGoogleSearchTransport = new Transport( "http://api.google.com/search/beta2" ); + connect( mDoGoogleSearchTransport, SIGNAL( result( const QString& ) ), + this, SLOT( doGoogleSearchResponseSlot( const QString& ) ) ); +} + +GoogleSearchService::~GoogleSearchService() +{ + delete mDoGetCachedPageTransport; + mDoGetCachedPageTransport = 0; + delete mDoSpellingSuggestionTransport; + mDoSpellingSuggestionTransport = 0; + delete mDoGoogleSearchTransport; + mDoGoogleSearchTransport = 0; +} + + +#include "googlesearchservice.moc" + diff --git a/kode/kwsdl/tests/google/googlesearchservice.h b/kode/kwsdl/tests/google/googlesearchservice.h new file mode 100644 index 000000000..cc8bef027 --- /dev/null +++ b/kode/kwsdl/tests/google/googlesearchservice.h @@ -0,0 +1,60 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef GOOGLESEARCHSERVICE_H +#define GOOGLESEARCHSERVICE_H + +#include <qobject.h> +#include <qstring.h> +#include <transport.h> +#include <qcstring.h> +#include <googlesearchresult.h> + +class GoogleSearchService : public QObject +{ + Q_OBJECT + + public: + void doGetCachedPage( QString* key, QString* url ); + void doSpellingSuggestion( QString* key, QString* phrase ); + void doGoogleSearch( QString* key, QString* q, int* start, int* maxResults, bool* filter, QString* restrict, bool* safeSearch, QString* lr, QString* ie, QString* oe ); + GoogleSearchService(); + ~GoogleSearchService(); + + signals: + void doGetCachedPageResponse( QByteArray* value ); + void doSpellingSuggestionResponse( QString* value ); + void doGoogleSearchResponse( GoogleSearchResult* value ); + + private slots: + void doGetCachedPageResponseSlot( const QString &xml ); + void doSpellingSuggestionResponseSlot( const QString &xml ); + void doGoogleSearchResponseSlot( const QString &xml ); + + private: + Transport*mDoGetCachedPageTransport; + Transport*mDoSpellingSuggestionTransport; + Transport*mDoGoogleSearchTransport; +}; + +#endif diff --git a/kode/kwsdl/tests/google/main.cc b/kode/kwsdl/tests/google/main.cc new file mode 100644 index 000000000..fd4b82462 --- /dev/null +++ b/kode/kwsdl/tests/google/main.cc @@ -0,0 +1,23 @@ +#include <kaboutdata.h> +#include <kapplication.h> +#include <kcmdlineargs.h> +#include <kmdcodec.h> + +#include "googlesearch.hh" + +int main( int argc, char **argv ) +{ + KAboutData aboutData( "kgooglesearch", "KDE Google Search", "0.1", "", KAboutData::License_GPL ); + aboutData.addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); + + KCmdLineArgs::init( argc, argv, &aboutData ); + + KApplication app( false, false ); + + GoogleSearch search; + + search.googleSearch( "foobar", 0, 10, true, "", false, "", "latin1", "latin1" ); + search.spellingSuggestion( "guugel" ); + + return app.exec(); +} diff --git a/kode/kwsdl/tests/google/resultelement.cpp b/kode/kwsdl/tests/google/resultelement.cpp new file mode 100644 index 000000000..b02b8ca44 --- /dev/null +++ b/kode/kwsdl/tests/google/resultelement.cpp @@ -0,0 +1,156 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "resultelement.h" + +#include <serializer.h> +#include <qstring.h> +#include <directorycategory.h> + +void ResultElement::setSummary( QString* summary ) +{ + mSummary = summary; +} + +QString*ResultElement::summary() const +{ + return mSummary; +} + +void ResultElement::setURL( QString* uRL ) +{ + mURL = uRL; +} + +QString*ResultElement::uRL() const +{ + return mURL; +} + +void ResultElement::setSnippet( QString* snippet ) +{ + mSnippet = snippet; +} + +QString*ResultElement::snippet() const +{ + return mSnippet; +} + +void ResultElement::setTitle( QString* title ) +{ + mTitle = title; +} + +QString*ResultElement::title() const +{ + return mTitle; +} + +void ResultElement::setCachedSize( QString* cachedSize ) +{ + mCachedSize = cachedSize; +} + +QString*ResultElement::cachedSize() const +{ + return mCachedSize; +} + +void ResultElement::setRelatedInformationPresent( bool* relatedInformationPresent ) +{ + mRelatedInformationPresent = relatedInformationPresent; +} + +bool*ResultElement::relatedInformationPresent() const +{ + return mRelatedInformationPresent; +} + +void ResultElement::setHostName( QString* hostName ) +{ + mHostName = hostName; +} + +QString*ResultElement::hostName() const +{ + return mHostName; +} + +void ResultElement::setDirectoryCategory( DirectoryCategory* directoryCategory ) +{ + mDirectoryCategory = directoryCategory; +} + +DirectoryCategory*ResultElement::directoryCategory() const +{ + return mDirectoryCategory; +} + +void ResultElement::setDirectoryTitle( QString* directoryTitle ) +{ + mDirectoryTitle = directoryTitle; +} + +QString*ResultElement::directoryTitle() const +{ + return mDirectoryTitle; +} + +ResultElement::ResultElement() +{ + mSummary = 0; + mURL = 0; + mSnippet = 0; + mTitle = 0; + mCachedSize = 0; + mRelatedInformationPresent = 0; + mHostName = 0; + mDirectoryCategory = 0; + mDirectoryTitle = 0; +} + +ResultElement::~ResultElement() +{ + delete mSummary; + mSummary = 0; + delete mURL; + mURL = 0; + delete mSnippet; + mSnippet = 0; + delete mTitle; + mTitle = 0; + delete mCachedSize; + mCachedSize = 0; + delete mRelatedInformationPresent; + mRelatedInformationPresent = 0; + delete mHostName; + mHostName = 0; + delete mDirectoryCategory; + mDirectoryCategory = 0; + delete mDirectoryTitle; + mDirectoryTitle = 0; +} + + diff --git a/kode/kwsdl/tests/google/resultelement.h b/kode/kwsdl/tests/google/resultelement.h new file mode 100644 index 000000000..4a24f7291 --- /dev/null +++ b/kode/kwsdl/tests/google/resultelement.h @@ -0,0 +1,66 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef RESULTELEMENT_H +#define RESULTELEMENT_H + +class QString; +class DirectoryCategory; + +class ResultElement +{ + public: + void setSummary( QString* summary ); + QString*summary() const; + void setURL( QString* uRL ); + QString*uRL() const; + void setSnippet( QString* snippet ); + QString*snippet() const; + void setTitle( QString* title ); + QString*title() const; + void setCachedSize( QString* cachedSize ); + QString*cachedSize() const; + void setRelatedInformationPresent( bool* relatedInformationPresent ); + bool*relatedInformationPresent() const; + void setHostName( QString* hostName ); + QString*hostName() const; + void setDirectoryCategory( DirectoryCategory* directoryCategory ); + DirectoryCategory*directoryCategory() const; + void setDirectoryTitle( QString* directoryTitle ); + QString*directoryTitle() const; + ResultElement(); + ~ResultElement(); + + private: + QString*mSummary; + QString*mURL; + QString*mSnippet; + QString*mTitle; + QString*mCachedSize; + bool*mRelatedInformationPresent; + QString*mHostName; + DirectoryCategory*mDirectoryCategory; + QString*mDirectoryTitle; +}; + +#endif diff --git a/kode/kwsdl/tests/google/resultelementarray.cpp b/kode/kwsdl/tests/google/resultelementarray.cpp new file mode 100644 index 000000000..f356f0101 --- /dev/null +++ b/kode/kwsdl/tests/google/resultelementarray.cpp @@ -0,0 +1,52 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "resultelementarray.h" + +#include <serializer.h> +#include <qptrlist.h> +#include <resultelement.h> + +void ResultElementArray::setItems( QPtrList<ResultElement>* items ) +{ + mItems = items; +} + +QPtrList<ResultElement>*ResultElementArray::items() const +{ + return mItems; +} + +ResultElementArray::ResultElementArray() +{ + mItems = 0; +} + +ResultElementArray::~ResultElementArray() +{ + delete mItems; + mItems = 0; +} + + diff --git a/kode/kwsdl/tests/google/resultelementarray.h b/kode/kwsdl/tests/google/resultelementarray.h new file mode 100644 index 000000000..2d63fe4dd --- /dev/null +++ b/kode/kwsdl/tests/google/resultelementarray.h @@ -0,0 +1,43 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef RESULTELEMENTARRAY_H +#define RESULTELEMENTARRAY_H + +#include <qptrlist.h> + +class ResultElement; + +class ResultElementArray +{ + public: + void setItems( QPtrList<ResultElement>* items ); + QPtrList<ResultElement>*items() const; + ResultElementArray(); + ~ResultElementArray(); + + private: + QPtrList<ResultElement>*mItems; +}; + +#endif diff --git a/kode/kwsdl/tests/google/serializer.cpp b/kode/kwsdl/tests/google/serializer.cpp new file mode 100644 index 000000000..595666fab --- /dev/null +++ b/kode/kwsdl/tests/google/serializer.cpp @@ -0,0 +1,627 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "serializer.h" + +#include <kmdcodec.h> +#include <resultelementarray.h> +#include <directorycategoryarray.h> +#include <googlesearchresult.h> +#include <directorycategory.h> +#include <resultelement.h> + +QString Serializer::marshalValue( const QString* value ) +{ + return *value; +} + +void Serializer::demarshalValue( const QString &str, QString *value ) +{ + *value = str; +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const QString* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:string" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, QString* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const bool* value ) +{ + return (*value ? "true" : "false"); +} + +void Serializer::demarshalValue( const QString &str, bool *value ) +{ + *value = (str.lower() == "true" ? true : false); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const bool* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:boolean" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, bool* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const float* value ) +{ + return QString::number( *value ); +} + +void Serializer::demarshalValue( const QString &str, float *value ) +{ + *value = str.toFloat(); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const float* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:TODO" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, float* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const int* value ) +{ + return QString::number( *value ); +} + +void Serializer::demarshalValue( const QString &str, int *value ) +{ + *value = str.toInt(); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const int* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:int" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, int* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const unsigned int* value ) +{ + return QString::number( *value ); +} + +void Serializer::demarshalValue( const QString &str, unsigned int *value ) +{ + *value = str.toUInt(); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const unsigned int* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:unsignedByte" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, unsigned int* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const double* value ) +{ + return QString::number( *value ); +} + +void Serializer::demarshalValue( const QString &str, double *value ) +{ + *value = str.toDouble(); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const double* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:double" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, double* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const char* value ) +{ + return QString( QChar( *value ) ); +} + +void Serializer::demarshalValue( const QString &str, char *value ) +{ + *value = str[ 0 ].latin1(); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const char* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:byte" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, char* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const unsigned char* value ) +{ + return QString( QChar( *value ) ); +} + +void Serializer::demarshalValue( const QString &str, unsigned char *value ) +{ + *value = str[ 0 ].latin1(); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const unsigned char* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:unsignedByte" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, unsigned char* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const short* value ) +{ + return QString::number( *value ); +} + +void Serializer::demarshalValue( const QString &str, short *value ) +{ + *value = str.toShort(); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const short* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:short" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, short* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const QByteArray* value ) +{ + return QString::fromUtf8( KCodecs::base64Encode( *value ) ); +} + +void Serializer::demarshalValue( const QString &str, QByteArray *value ) +{ + *value = KCodecs::base64Decode( str.utf8() ); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const QByteArray* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:base64Binary" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, QByteArray* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const QDateTime* value ) +{ + return value->toString( Qt::ISODate ); +} + +void Serializer::demarshalValue( const QString &str, QDateTime *value ) +{ + *value = QDateTime::fromString( str, Qt::ISODate ); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const QDateTime* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:dateTime" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, QDateTime* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +QString Serializer::marshalValue( const QDate* value ) +{ + return value->toString( Qt::ISODate ); +} + +void Serializer::demarshalValue( const QString &str, QDate *value ) +{ + *value = QDate::fromString( str, Qt::ISODate ); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const QDate* value ) +{ + QDomElement element = doc.createElement( name ); + element.setAttribute( "xsi:type", "xsd:date" ); + element.appendChild( doc.createTextNode( Serializer::marshalValue( value ) ) ); + parent.appendChild( element ); +} + +void Serializer::demarshal( const QDomElement &element, QDate* value ) +{ + Serializer::demarshalValue( element.text(), value ); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const ResultElementArray* value ) +{ + QDomElement root = doc.createElement( name ); + root.setAttribute( "xsi:type", "ns1:ResultElementArray" ); + parent.appendChild( root ); + if ( value->items() ) { + const QPtrList<ResultElement>* list = value->items(); + + QDomElement element = doc.createElement( name ); + element.setAttribute( "xmlns:ns1", "http://schemas.xmlsoap.org/soap/encoding/" ); + element.setAttribute( "xsi:type", "ns1:Array" ); + element.setAttribute( "ns1:arrayType", "ns1:ResultElement[" + QString::number( list->count() ) + "]" ); + parent.appendChild( element ); + + QPtrListIterator<ResultElement> it( *list ); + while ( it.current() != 0 ) { + Serializer::marshal( doc, element, "item", it.current() ); + ++it; + } + } +} + +void Serializer::demarshal( const QDomElement &parent, ResultElementArray* value ) +{ + QPtrList<ResultElement>* itemsList = new QPtrList<ResultElement>(); + itemsList->setAutoDelete( true ); + QDomNode node = parent.firstChild(); + while ( !node.isNull() ) { + QDomElement element = node.toElement(); + if ( !element.isNull() ) { + if ( element.tagName() == "item" ) { + ResultElement *item = new ResultElement; + Serializer::demarshal( element, item ); + itemsList->append( item ); + } + } + node = node.nextSibling(); + } + + value->setItems( itemsList ); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const DirectoryCategoryArray* value ) +{ + QDomElement root = doc.createElement( name ); + root.setAttribute( "xsi:type", "ns1:DirectoryCategoryArray" ); + parent.appendChild( root ); + if ( value->items() ) { + const QPtrList<DirectoryCategory>* list = value->items(); + + QDomElement element = doc.createElement( name ); + element.setAttribute( "xmlns:ns1", "http://schemas.xmlsoap.org/soap/encoding/" ); + element.setAttribute( "xsi:type", "ns1:Array" ); + element.setAttribute( "ns1:arrayType", "ns1:DirectoryCategory[" + QString::number( list->count() ) + "]" ); + parent.appendChild( element ); + + QPtrListIterator<DirectoryCategory> it( *list ); + while ( it.current() != 0 ) { + Serializer::marshal( doc, element, "item", it.current() ); + ++it; + } + } +} + +void Serializer::demarshal( const QDomElement &parent, DirectoryCategoryArray* value ) +{ + QPtrList<DirectoryCategory>* itemsList = new QPtrList<DirectoryCategory>(); + itemsList->setAutoDelete( true ); + QDomNode node = parent.firstChild(); + while ( !node.isNull() ) { + QDomElement element = node.toElement(); + if ( !element.isNull() ) { + if ( element.tagName() == "item" ) { + DirectoryCategory *item = new DirectoryCategory; + Serializer::demarshal( element, item ); + itemsList->append( item ); + } + } + node = node.nextSibling(); + } + + value->setItems( itemsList ); +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const GoogleSearchResult* value ) +{ + QDomElement root = doc.createElement( name ); + root.setAttribute( "xsi:type", "ns1:GoogleSearchResult" ); + parent.appendChild( root ); + if ( value->documentFiltering() ) { + Serializer::marshal( doc, root, "documentFiltering", value->documentFiltering() ); + } + if ( value->searchComments() ) { + Serializer::marshal( doc, root, "searchComments", value->searchComments() ); + } + if ( value->estimatedTotalResultsCount() ) { + Serializer::marshal( doc, root, "estimatedTotalResultsCount", value->estimatedTotalResultsCount() ); + } + if ( value->estimateIsExact() ) { + Serializer::marshal( doc, root, "estimateIsExact", value->estimateIsExact() ); + } + if ( value->resultElements() ) { + Serializer::marshal( doc, root, "resultElements", value->resultElements() ); + } + if ( value->searchQuery() ) { + Serializer::marshal( doc, root, "searchQuery", value->searchQuery() ); + } + if ( value->startIndex() ) { + Serializer::marshal( doc, root, "startIndex", value->startIndex() ); + } + if ( value->endIndex() ) { + Serializer::marshal( doc, root, "endIndex", value->endIndex() ); + } + if ( value->searchTips() ) { + Serializer::marshal( doc, root, "searchTips", value->searchTips() ); + } + if ( value->directoryCategories() ) { + Serializer::marshal( doc, root, "directoryCategories", value->directoryCategories() ); + } + if ( value->searchTime() ) { + Serializer::marshal( doc, root, "searchTime", value->searchTime() ); + } +} + +void Serializer::demarshal( const QDomElement &parent, GoogleSearchResult* value ) +{ + QDomNode node = parent.firstChild(); + while ( !node.isNull() ) { + QDomElement element = node.toElement(); + if ( !element.isNull() ) { + if ( element.tagName() == "documentFiltering" ) { + bool* item = new bool; + Serializer::demarshal( element, item ); + value->setDocumentFiltering( item ); + } + if ( element.tagName() == "searchComments" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setSearchComments( item ); + } + if ( element.tagName() == "estimatedTotalResultsCount" ) { + int* item = new int; + Serializer::demarshal( element, item ); + value->setEstimatedTotalResultsCount( item ); + } + if ( element.tagName() == "estimateIsExact" ) { + bool* item = new bool; + Serializer::demarshal( element, item ); + value->setEstimateIsExact( item ); + } + if ( element.tagName() == "resultElements" ) { + ResultElementArray* item = new ResultElementArray; + Serializer::demarshal( element, item ); + value->setResultElements( item ); + } + if ( element.tagName() == "searchQuery" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setSearchQuery( item ); + } + if ( element.tagName() == "startIndex" ) { + int* item = new int; + Serializer::demarshal( element, item ); + value->setStartIndex( item ); + } + if ( element.tagName() == "endIndex" ) { + int* item = new int; + Serializer::demarshal( element, item ); + value->setEndIndex( item ); + } + if ( element.tagName() == "searchTips" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setSearchTips( item ); + } + if ( element.tagName() == "directoryCategories" ) { + DirectoryCategoryArray* item = new DirectoryCategoryArray; + Serializer::demarshal( element, item ); + value->setDirectoryCategories( item ); + } + if ( element.tagName() == "searchTime" ) { + double* item = new double; + Serializer::demarshal( element, item ); + value->setSearchTime( item ); + } + } + node = node.nextSibling(); + } + +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const DirectoryCategory* value ) +{ + QDomElement root = doc.createElement( name ); + root.setAttribute( "xsi:type", "ns1:DirectoryCategory" ); + parent.appendChild( root ); + if ( value->fullViewableName() ) { + Serializer::marshal( doc, root, "fullViewableName", value->fullViewableName() ); + } + if ( value->specialEncoding() ) { + Serializer::marshal( doc, root, "specialEncoding", value->specialEncoding() ); + } +} + +void Serializer::demarshal( const QDomElement &parent, DirectoryCategory* value ) +{ + QDomNode node = parent.firstChild(); + while ( !node.isNull() ) { + QDomElement element = node.toElement(); + if ( !element.isNull() ) { + if ( element.tagName() == "fullViewableName" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setFullViewableName( item ); + } + if ( element.tagName() == "specialEncoding" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setSpecialEncoding( item ); + } + } + node = node.nextSibling(); + } + +} + +void Serializer::marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const ResultElement* value ) +{ + QDomElement root = doc.createElement( name ); + root.setAttribute( "xsi:type", "ns1:ResultElement" ); + parent.appendChild( root ); + if ( value->summary() ) { + Serializer::marshal( doc, root, "summary", value->summary() ); + } + if ( value->uRL() ) { + Serializer::marshal( doc, root, "URL", value->uRL() ); + } + if ( value->snippet() ) { + Serializer::marshal( doc, root, "snippet", value->snippet() ); + } + if ( value->title() ) { + Serializer::marshal( doc, root, "title", value->title() ); + } + if ( value->cachedSize() ) { + Serializer::marshal( doc, root, "cachedSize", value->cachedSize() ); + } + if ( value->relatedInformationPresent() ) { + Serializer::marshal( doc, root, "relatedInformationPresent", value->relatedInformationPresent() ); + } + if ( value->hostName() ) { + Serializer::marshal( doc, root, "hostName", value->hostName() ); + } + if ( value->directoryCategory() ) { + Serializer::marshal( doc, root, "directoryCategory", value->directoryCategory() ); + } + if ( value->directoryTitle() ) { + Serializer::marshal( doc, root, "directoryTitle", value->directoryTitle() ); + } +} + +void Serializer::demarshal( const QDomElement &parent, ResultElement* value ) +{ + QDomNode node = parent.firstChild(); + while ( !node.isNull() ) { + QDomElement element = node.toElement(); + if ( !element.isNull() ) { + if ( element.tagName() == "summary" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setSummary( item ); + } + if ( element.tagName() == "URL" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setURL( item ); + } + if ( element.tagName() == "snippet" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setSnippet( item ); + } + if ( element.tagName() == "title" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setTitle( item ); + } + if ( element.tagName() == "cachedSize" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setCachedSize( item ); + } + if ( element.tagName() == "relatedInformationPresent" ) { + bool* item = new bool; + Serializer::demarshal( element, item ); + value->setRelatedInformationPresent( item ); + } + if ( element.tagName() == "hostName" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setHostName( item ); + } + if ( element.tagName() == "directoryCategory" ) { + DirectoryCategory* item = new DirectoryCategory; + Serializer::demarshal( element, item ); + value->setDirectoryCategory( item ); + } + if ( element.tagName() == "directoryTitle" ) { + QString* item = new QString; + Serializer::demarshal( element, item ); + value->setDirectoryTitle( item ); + } + } + node = node.nextSibling(); + } + +} + + diff --git a/kode/kwsdl/tests/google/serializer.h b/kode/kwsdl/tests/google/serializer.h new file mode 100644 index 000000000..d2db93d87 --- /dev/null +++ b/kode/kwsdl/tests/google/serializer.h @@ -0,0 +1,103 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#ifndef SERIALIZER_H +#define SERIALIZER_H + +#include <qcstring.h> +#include <qdom.h> +#include <qdatetime.h> +#include <qstring.h> +#include <qptrlist.h> + +class ResultElementArray; +class DirectoryCategoryArray; +class GoogleSearchResult; +class DirectoryCategory; +class ResultElement; + +class Serializer +{ + public: + static QString marshalValue( const QString* value ); + static void demarshalValue( const QString &str, QString *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const QString* value ); + static void demarshal( const QDomElement &element, QString* value ); + static QString marshalValue( const bool* value ); + static void demarshalValue( const QString &str, bool *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const bool* value ); + static void demarshal( const QDomElement &element, bool* value ); + static QString marshalValue( const float* value ); + static void demarshalValue( const QString &str, float *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const float* value ); + static void demarshal( const QDomElement &element, float* value ); + static QString marshalValue( const int* value ); + static void demarshalValue( const QString &str, int *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const int* value ); + static void demarshal( const QDomElement &element, int* value ); + static QString marshalValue( const unsigned int* value ); + static void demarshalValue( const QString &str, unsigned int *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const unsigned int* value ); + static void demarshal( const QDomElement &element, unsigned int* value ); + static QString marshalValue( const double* value ); + static void demarshalValue( const QString &str, double *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const double* value ); + static void demarshal( const QDomElement &element, double* value ); + static QString marshalValue( const char* value ); + static void demarshalValue( const QString &str, char *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const char* value ); + static void demarshal( const QDomElement &element, char* value ); + static QString marshalValue( const unsigned char* value ); + static void demarshalValue( const QString &str, unsigned char *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const unsigned char* value ); + static void demarshal( const QDomElement &element, unsigned char* value ); + static QString marshalValue( const short* value ); + static void demarshalValue( const QString &str, short *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const short* value ); + static void demarshal( const QDomElement &element, short* value ); + static QString marshalValue( const QByteArray* value ); + static void demarshalValue( const QString &str, QByteArray *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const QByteArray* value ); + static void demarshal( const QDomElement &element, QByteArray* value ); + static QString marshalValue( const QDateTime* value ); + static void demarshalValue( const QString &str, QDateTime *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const QDateTime* value ); + static void demarshal( const QDomElement &element, QDateTime* value ); + static QString marshalValue( const QDate* value ); + static void demarshalValue( const QString &str, QDate *value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const QDate* value ); + static void demarshal( const QDomElement &element, QDate* value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const ResultElementArray* value ); + static void demarshal( const QDomElement &parent, ResultElementArray* value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const DirectoryCategoryArray* value ); + static void demarshal( const QDomElement &parent, DirectoryCategoryArray* value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const GoogleSearchResult* value ); + static void demarshal( const QDomElement &parent, GoogleSearchResult* value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const DirectoryCategory* value ); + static void demarshal( const QDomElement &parent, DirectoryCategory* value ); + static void marshal( QDomDocument &doc, QDomElement &parent, const QString &name, const ResultElement* value ); + static void demarshal( const QDomElement &parent, ResultElement* value ); + +}; + +#endif diff --git a/kode/kwsdl/tests/google/transport.cpp b/kode/kwsdl/tests/google/transport.cpp new file mode 100644 index 000000000..4f4583ba2 --- /dev/null +++ b/kode/kwsdl/tests/google/transport.cpp @@ -0,0 +1,75 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "transport.h" + +#include <kdebug.h> + +Transport::Transport( const QString &url ) +{ + mUrl = url; +} + +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", "KWSDL" ); + 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 ) { + kdWarning() << "Error occurred " << job->errorText() << endl; + kdWarning() << mData << endl; + return; + } + + emit result( QString::fromUtf8( mData.data(), mData.size() ) ); +} + + +#include "transport.moc" + diff --git a/kode/kwsdl/tests/google/transport.h b/kode/kwsdl/tests/google/transport.h new file mode 100644 index 000000000..b39d6e82c --- /dev/null +++ b/kode/kwsdl/tests/google/transport.h @@ -0,0 +1,50 @@ +/* + This file is part of KDE. + + 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. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ +#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 ); + + private slots: + void slotData( KIO::Job*, const QByteArray &data ); + void slotResult( KIO::Job* job ); + + private: + QString mUrl; + QByteArray mData; +}; + +#endif |