From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: 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 --- kresources/blogging/API_Blog.cpp | 121 ++++++ kresources/blogging/API_Blog.h | 162 ++++++++ kresources/blogging/API_Blogger.cpp | 332 ++++++++++++++++ kresources/blogging/API_Blogger.h | 57 +++ kresources/blogging/Makefile.am | 29 ++ kresources/blogging/blogging.desktop | 50 +++ kresources/blogging/bloggingcalendaradaptor.cpp | 259 +++++++++++++ kresources/blogging/bloggingcalendaradaptor.h | 104 +++++ kresources/blogging/bloggingglobals.cpp | 53 +++ kresources/blogging/bloggingglobals.h | 50 +++ kresources/blogging/kcal_resourceblogging.cpp | 93 +++++ kresources/blogging/kcal_resourceblogging.h | 59 +++ .../blogging/kcal_resourceblogging_plugin.cpp | 41 ++ .../blogging/kcal_resourcebloggingconfig.cpp | 41 ++ kresources/blogging/kcal_resourcebloggingconfig.h | 40 ++ kresources/blogging/resourcebloggingsettings.ui | 330 ++++++++++++++++ kresources/blogging/xmlrpcjob.cpp | 430 +++++++++++++++++++++ kresources/blogging/xmlrpcjob.h | 123 ++++++ 18 files changed, 2374 insertions(+) create mode 100644 kresources/blogging/API_Blog.cpp create mode 100644 kresources/blogging/API_Blog.h create mode 100644 kresources/blogging/API_Blogger.cpp create mode 100644 kresources/blogging/API_Blogger.h create mode 100644 kresources/blogging/Makefile.am create mode 100644 kresources/blogging/blogging.desktop create mode 100644 kresources/blogging/bloggingcalendaradaptor.cpp create mode 100644 kresources/blogging/bloggingcalendaradaptor.h create mode 100644 kresources/blogging/bloggingglobals.cpp create mode 100644 kresources/blogging/bloggingglobals.h create mode 100644 kresources/blogging/kcal_resourceblogging.cpp create mode 100644 kresources/blogging/kcal_resourceblogging.h create mode 100644 kresources/blogging/kcal_resourceblogging_plugin.cpp create mode 100644 kresources/blogging/kcal_resourcebloggingconfig.cpp create mode 100644 kresources/blogging/kcal_resourcebloggingconfig.h create mode 100644 kresources/blogging/resourcebloggingsettings.ui create mode 100644 kresources/blogging/xmlrpcjob.cpp create mode 100644 kresources/blogging/xmlrpcjob.h (limited to 'kresources/blogging') diff --git a/kresources/blogging/API_Blog.cpp b/kresources/blogging/API_Blog.cpp new file mode 100644 index 00000000..670cd166 --- /dev/null +++ b/kresources/blogging/API_Blog.cpp @@ -0,0 +1,121 @@ +/*************************************************************************** +* Copyright (C) 2004-05 Reinhold Kainhofer * +* * +* 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. * +***************************************************************************/ +#include "API_Blog.h" +#include +#include + +using namespace KBlog; + +APIBlog::APIBlog( const KURL &url, QObject *parent, const char *name ) : + QObject( parent, name ), + mServerURL( url ), mAppID( QString::null ), mDownloadCount( 20 ) +{} + +APIBlog::~APIBlog() +{} + +void APIBlog::dumpBlog( BlogPosting *blog ) +{ + kdDebug() << "-----------------------------------" << endl; + kdDebug() << "Post " << blog->postID() << " by \"" << + blog->userID() << "\" on " << + blog->dateTime().toString() << endl; + kdDebug() << "Title: " << blog->title() << endl; + kdDebug() << blog->content() <setPostID( postID ); + deletePost( post ); + delete post; +}*/ + +QValueList APIBlog::defaultArgs( const QString &id ) +{ + QValueList args; + args << QVariant( mAppID ); + if ( !id.isNull() ) { + args << QVariant( id ); + } + args << QVariant( mUsername ) + << QVariant( mPassword ); + return args; +} + + +KCal::Journal *APIBlog::journalFromPosting( KBlog::BlogPosting *blog ) +{ + if ( !blog ) return 0; + KCal::Journal *j = new KCal::Journal(); + QDateTime dt = blog->dateTime(); + QDateTime creationDt = blog->creationDateTime(); + QDateTime modificationDt = blog->modificationDateTime(); +kdDebug() << "dt ="<title() << " is " + << blog->dateTime().toString()<setSummary( blog->title() ); + j->setDescription( blog->content() ); + j->setCategories( QStringList( blog->category() ) ); + j->setOrganizer( blog->userID() ); + j->setCustomProperty( "KCalBloggerRes", "UserID", blog->userID() ); + j->setCustomProperty( "KCalBloggerRes", "BlogID", blog->blogID() ); + j->setCustomProperty( "KCalBloggerRes", "PostID", blog->postID() ); + + // TODO: Set the read-only flag in the resource! +// j->setReadOnly( readOnly() ); + + return j; +} + +KBlog::BlogPosting *APIBlog::postingFromJournal( KCal::Journal *journal ) +{ + KBlog::BlogPosting *item = new KBlog::BlogPosting(); + if ( journal && item ) { + item->setContent( journal->description() ); + item->setTitle( journal->summary() ); + item->setCategory( journal->categories().first() ); + item->setDateTime( journal->dtStart() ); + item->setModificationDateTime( journal->lastModified() ); + item->setCreationDateTime( journal->created() ); + item->setUserID( journal->customProperty( "KCalBloggerRes", "UserID" ) ); + item->setBlogID( journal->customProperty( "KCalBloggerRes", "BlogID" ) ); + item->setPostID( journal->customProperty( "KCalBloggerRes", "PostID" ) ); + } + return item; +} + + +#include "API_Blog.moc" diff --git a/kresources/blogging/API_Blog.h b/kresources/blogging/API_Blog.h new file mode 100644 index 00000000..77c27d68 --- /dev/null +++ b/kresources/blogging/API_Blog.h @@ -0,0 +1,162 @@ +/************************************************************************** +* Copyright (C) 2004 by Reinhold Kainhofer * +* * +* 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. * +***************************************************************************/ +#ifndef API_BLOG_H +#define API_BLOG_H + +#include +#include +#include + +#include +#include +#include +#include + +/** +This is the main interface for blog backends +@author ian reinhart geiser, Reinhold Kainhofer +*/ + +namespace KBlog { + +class BlogPosting +{ +public: + BlogPosting() {} + virtual ~BlogPosting() {} + + QString userID() const { return mUserID; } + void setUserID( const QString &userID ) { mUserID = userID; } + + QString blogID() const { return mBlogID; } + void setBlogID( const QString &blogID ) { mBlogID = blogID; } + + QString postID() const { return mPostID; } + void setPostID( const QString &postID ) { assignPostID( postID ); mPostID = postID; } + + QString title() const { return mTitle; } + void setTitle( const QString &title ) { mTitle = title; } + + QString content() const { return mContent; } + void setContent( const QString &content ) { mContent = content; } + + QString category() const { return mCategory; } + void setCategory( const QString &category ) { mCategory = category; } + + QString fingerprint() const { return mFingerprint; } + void setFingerprint( const QString &fp ) { mFingerprint = fp; } + + QDateTime dateTime() const { return mDateTime; } + void setDateTime( const QDateTime &datetime ) { mDateTime = datetime; } + + QDateTime creationDateTime() const { return mCreationDateTime; } + void setCreationDateTime( const QDateTime &datetime ) { mCreationDateTime = datetime; } + + QDateTime modificationDateTime() const { return mModificationDateTime; } + void setModificationDateTime( const QDateTime &datetime ) { mModificationDateTime = datetime; } + + virtual void wasDeleted( bool ) {} + virtual void wasUploaded( bool ) {} + virtual void error( int /*code*/, const QString &/*error*/ ) {} + +protected: + // Override this method to detect the new postID assigned when adding a new post + virtual void assignPostID( const QString &/*postID*/ ) {} + QString mUserID; + QString mBlogID; + QString mPostID; + QString mTitle; + QString mContent; + QString mCategory; + QString mFingerprint; + QDateTime mDateTime; + QDateTime mCreationDateTime; + QDateTime mModificationDateTime; +}; + + +class APIBlog : public QObject +{ + Q_OBJECT + public: + APIBlog( const KURL &server, QObject *parent = 0L, const char *name = 0L ); + virtual ~APIBlog(); + virtual QString interfaceName() const = 0; + + void setAppID( const QString &appID ) { mAppID = appID; } + QString appID() const { return mAppID; } + + void setPassword( const QString &pass ) { mPassword = pass; } + QString password() const { return mPassword; } + + void setUsername( const QString &uname ) { mUsername = uname; } + QString username() const { return mUsername; } + + void setURL( const KURL& url ) { mServerURL = url; } + KURL url() const { return mServerURL; } + + void setDownloadCount( int nr ) { mDownloadCount = nr; } + int downloadCount() const { return mDownloadCount; } + + static void dumpBlog( BlogPosting *blog ); + + + enum blogFunctions { + bloggerGetUserInfo, + bloggerGetUsersBlogs, + bloggerGetRecentPosts, + bloggerNewPost, + bloggerEditPost, + bloggerDeletePost, + bloggerGetPost, + bloggerGetTemplate, + bloggerSetTemplate + }; + + virtual QString getFunctionName( blogFunctions type ) = 0; + virtual QValueList defaultArgs( const QString &id = QString::null ); + + virtual KIO::Job *createUserInfoJob() = 0; + virtual KIO::Job *createListFoldersJob() = 0; + virtual KIO::TransferJob *createListItemsJob( const KURL &url ) = 0; + virtual KIO::TransferJob *createDownloadJob( const KURL &url ) = 0; + virtual KIO::TransferJob *createUploadJob( const KURL &url, KBlog::BlogPosting *posting ) = 0; + virtual KIO::TransferJob *createUploadNewJob( KBlog::BlogPosting *posting ) = 0; + virtual KIO::Job *createRemoveJob( const KURL &url, const QString &postid ) = 0; + + virtual bool interpretUserInfoJob( KIO::Job *job ) = 0; + virtual void interpretListFoldersJob( KIO::Job *job ) = 0; + virtual bool interpretListItemsJob( KIO::Job *job ) = 0; + virtual bool interpretDownloadItemsJob( KIO::Job *job ) = 0; + + static KCal::Journal *journalFromPosting( KBlog::BlogPosting *post ); + static KBlog::BlogPosting *postingFromJournal( KCal::Journal *journal ); + + signals: + // TODO: Connect these + void userInfoRetrieved( const QString &nickname, const QString &userid, const QString &email ); + void folderInfoRetrieved( const QString &id, const QString &name ); + + void itemOnServer( const KURL &remoteURL ); + void itemDownloaded( KCal::Incidence *j, const QString &localID, + const KURL &remoteURL, const QString &fingerprint, + const QString &storageLocation ); + + + protected: + + KURL mServerURL; + QString mPassword; + QString mUsername; + QString mAppID; + int mDownloadCount; +}; + +} +#endif diff --git a/kresources/blogging/API_Blogger.cpp b/kresources/blogging/API_Blogger.cpp new file mode 100644 index 00000000..f30c5620 --- /dev/null +++ b/kresources/blogging/API_Blogger.cpp @@ -0,0 +1,332 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Reinhold Kainhofer + + 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 "API_Blogger.h" +#include "xmlrpcjob.h" +#include + +using namespace KBlog; + +QString APIBlogger::getFunctionName( blogFunctions type ) +{ + switch ( type ) { + case bloggerGetUserInfo: return "blogger.getUserInfo"; + case bloggerGetUsersBlogs: return "blogger.getUsersBlogs"; + case bloggerGetRecentPosts: return "blogger.getRecentPosts"; + case bloggerNewPost: return "blogger.newPost"; + case bloggerEditPost: return "blogger.editPost"; + case bloggerDeletePost: return "blogger.deletePost"; + case bloggerGetPost: return "blogger.getPost"; + case bloggerGetTemplate: return "blogger.getTemplate"; + case bloggerSetTemplate: return "blogger.setTemplate"; + default: return QString::null; + } +} + + + + +KIO::Job *APIBlogger::createUserInfoJob() +{ + kdDebug() << "read user info..." << endl; + QValueList args( defaultArgs() ); + return KIO::xmlrpcCall( mServerURL, getFunctionName( bloggerGetUserInfo ), args, false ); +} + +KIO::Job *APIBlogger::createListFoldersJob() +{ + // TODO: Check if we're already authenticated. If not, do it! +// if ( isValid() ) { + kdDebug() << "Fetch List of Blogs..." << endl; + QValueList args( defaultArgs() ); + return KIO::xmlrpcCall( mServerURL, getFunctionName( bloggerGetUsersBlogs ), args, false ); +// } else { +// warningNotInitialized(); +// return 0; +// } +} + +KIO::TransferJob *APIBlogger::createListItemsJob( const KURL &url ) +{ + // TODO: Check if we're already authenticated. If not, do it! +// if ( isValid() ) { + kdDebug() << "Fetch List of Posts..." << endl; + QValueList args( defaultArgs( url.url() ) ); + args << QVariant( mDownloadCount ); + return KIO::xmlrpcCall( mServerURL, getFunctionName( bloggerGetRecentPosts ), args, false ); +// } else { +// warningNotInitialized(); +// return 0; +// } +} + +KIO::TransferJob *APIBlogger::createDownloadJob( const KURL &url ) +{ +// if ( isValid() ){ + kdDebug() << "Fetch Posting with url " << url.url() << endl; + QValueList args( defaultArgs( url.url() ) ); + return KIO::xmlrpcCall( mServerURL, getFunctionName( bloggerGetPost ), args, false ); +// } else { +// warningNotInitialized(); +// return 0; +// } +} + +KIO::TransferJob *APIBlogger::createUploadJob( const KURL &url, KBlog::BlogPosting *posting ) +{ + if ( !posting ) { + kdDebug() << "APIBlogger::createUploadJob: posting=0" << endl; + return 0; + } +// if ( isValid() ){ + kdDebug() << "Uploading Posting with url " << url.url() << endl; + QValueList args( defaultArgs( posting->postID() ) ); + args << QVariant( posting->content() ); + args << QVariant( /*publish=*/true, 0 ); + return KIO::xmlrpcCall( mServerURL, getFunctionName( bloggerEditPost ), args, false ); +// } else { +// warningNotInitialized(); +// return 0; +// } +} + +KIO::TransferJob *APIBlogger::createUploadNewJob( KBlog::BlogPosting *posting ) +{ + if ( !posting ) { + kdDebug() << "APIBlogger::createUploadNewJob: posting=0" << endl; + return 0; + } +// if ( isValid() ){ + kdDebug() << "Creating new Posting with blogid " << posting->blogID() << " at url " << mServerURL << endl; + QValueList args( defaultArgs( posting->blogID() ) ); + args << QVariant( posting->content() ); + args << QVariant( /*publish=*/true, 0 ); + return KIO::xmlrpcCall( mServerURL, getFunctionName( bloggerNewPost ), args, false ); +// } else { +// warningNotInitialized(); +// return 0; +// } +} + +KIO::Job *APIBlogger::createRemoveJob( const KURL &/*url*/, const QString &postid ) +{ +kdDebug() << "APIBlogger::createRemoveJob: postid=" << postid << endl; +// if ( isValid() ){ + QValueList args( defaultArgs( postid ) ); + args << QVariant( /*publish=*/true, 0 ); + return KIO::xmlrpcCall( mServerURL, getFunctionName( bloggerDeletePost ), args, false ); +// } else { +// warningNotInitialized(); +// return 0; +// } +} + + + + +bool APIBlogger::interpretUserInfoJob( KIO::Job *job ) +{ + // TODO: Implement user authentication +// isValid = true; + KIO::XmlrpcJob *trfjob = dynamic_cast(job); + if ( job->error() || !trfjob ) { + // TODO: Error handling + return false; + } else if ( trfjob ) { + QValueList message( trfjob->response() ); + + kdDebug () << "TOP: " << message[ 0 ].typeName() << endl; + const QValueList posts = message; + QValueList::ConstIterator it = posts.begin(); + QValueList::ConstIterator end = posts.end(); + for ( ; it != end; ++it ) { + kdDebug () << "MIDDLE: " << ( *it ).typeName() << endl; + const QMap postInfo = ( *it ).toMap(); + const QString nickname = postInfo[ "nickname" ].toString(); + const QString userid = postInfo[ "userid" ].toString(); + const QString email = postInfo[ "email" ].toString(); + kdDebug() << "Post " << nickname << " " << userid << " " << email << endl; + // FIXME: How about a BlogUserInfo class??? + emit userInfoRetrieved( nickname, userid, email ); + } + return true; + } + return false; +} + +void APIBlogger::interpretListFoldersJob( KIO::Job *job ) +{ +kdDebug() << "APIBlogger::interpretListFoldersJob" << endl; + KIO::XmlrpcJob *trfjob = dynamic_cast(job); + if ( job->error() || !trfjob ) { + // TODO: Error handling + } else { +kdDebug() << "APIBlogger::interpretListFoldersJob, no error!" << endl; + QValueList message( trfjob->response() ); + kdDebug () << "TOP: " << message[ 0 ].typeName() << endl; + + const QValueList posts = message[ 0 ].toList(); + QValueList::ConstIterator it = posts.begin(); + QValueList::ConstIterator end = posts.end(); + for ( ; it != end; ++it ) { + kdDebug () << "MIDDLE: " << ( *it ).typeName() << endl; + const QMap postInfo = ( *it ).toMap(); + + const QString id( postInfo[ "blogid" ].toString() ); + const QString name( postInfo[ "blogName" ].toString() ); + const QString url( postInfo[ "url" ].toString() ); + + // Use the Blog ID instead of the URL. The ID already indicates the correct blog, and the + // URL for all calls will be the XML-RPC interface, anyway. + if ( !id.isEmpty() && !name.isEmpty() ) { + emit folderInfoRetrieved( id, name ); +kdDebug()<< "Emitting folderInfoRetrieved( id=" << id << ", name=" << name << "); " << endl; + } + } + } +} + +bool APIBlogger::interpretListItemsJob( KIO::Job *job ) +{ + return interpretDownloadItemsJob( job ); +} + +bool APIBlogger::interpretDownloadItemsJob( KIO::Job *job ) +{ + kdDebug(5800)<<"APIBlogger::interpretDownloadItemJob"<(job); + bool success = false; + if ( job->error() || !trfjob ) { + // TODO: Error handling + success = false; + } else { + //array of structs containing ISO.8601 dateCreated, String userid, String postid, String content; + // TODO: Time zone for the dateCreated! + QValueList message( trfjob->response() ); + kdDebug () << "TOP: " << message[ 0 ].typeName() << endl; + + const QValueList postReceived = message[ 0 ].toList(); + QValueList::ConstIterator it = postReceived.begin(); + QValueList::ConstIterator end = postReceived.end(); + success = true; + for ( ; it != end; ++it ) { + BlogPosting posting; + kdDebug () << "MIDDLE: " << ( *it ).typeName() << endl; + const QMap postInfo = ( *it ).toMap(); + if ( readPostingFromMap( &posting, postInfo ) ) { + KCal::Journal *j = journalFromPosting( &posting ); +// dumpBlog( &posting ); + kdDebug() << "Emitting itemOnServer( posting.postID()="<uid(), KURL( posting.postID() ), + posting.fingerprint(), posting.postID() ); + } else { + kdDebug() << "readPostingFromMap failed! " << endl; + success = false; + // TODO: Error handling + } + } + } + return success; +} + + +bool APIBlogger::readPostingFromMap( BlogPosting *post, const QMap &postInfo ) +{ + // FIXME: + if ( !post ) return false; + QStringList mapkeys = postInfo.keys(); + kdDebug() << endl << "Keys: " << mapkeys.join(", ") << endl << endl; + + QString fp( QString::null ); + + QDateTime dt( postInfo[ "dateCreated" ].toDateTime() ); + if ( dt.isValid() && !dt.isNull() ) { + post->setCreationDateTime( dt ); + QString fp = dt.toString( Qt::ISODate ); + } + dt = postInfo[ "postDate" ].toDateTime(); + if ( dt.isValid() && !dt.isNull() ) { + post->setDateTime( dt ); + fp = dt.toString( Qt::ISODate ); + } + dt = postInfo[ "lastModified" ].toDateTime(); + if ( dt.isValid() && !dt.isNull() ) { + post->setModificationDateTime( dt ); + fp = dt.toString( Qt::ISODate ); + } + post->setFingerprint( fp ); + + post->setUserID( postInfo[ "userid" ].toString() ); + post->setPostID( postInfo[ "postid" ].toString() ); + + QString title( postInfo[ "title" ].toString() ); + QString description( postInfo[ "description" ].toString() ); + QString contents( postInfo[ "content" ].toString() ); + QString category; + + // TODO: Extract title and cats from the old-style blogger api without extensions +/* + if ( (title.isEmpty() || description.isEmpty() ) && !contents.isEmpty() ) { + // we don't have both title and description, so use the content (ie. it's an + // old-style blogger api, not the extended drupal api. + + kdDebug() << "No title and description given, so it's an old-style " + "Blogger API without extensions" << endl; + QString catTagOpen = mTemplate.categoryTagOpen(); + QString catTagClose = mTemplate.categoryTagClose(); + QString titleTagOpen = mTemplate.titleTagOpen(); + QString titleTagClose = mTemplate.titleTagClose(); + + int catStart = contents.find( catTagOpen, 0, false ) + catTagOpen.length(); + int catEnd = contents.find( catTagClose, 0, false ); +kdDebug() << " catTagOpen = " << catTagOpen << ", catTagClose = " << catTagClose << ", start - end : " << catStart <<" - " << catEnd << endl; + if ( catEnd > catStart ) { + category = contents.mid( catStart, catEnd - catStart ); + kdDebug() << "Found a category \"" << category << "\"" << endl; + contents = contents.remove( catStart - catTagOpen.length(), + catEnd - catStart + catTagClose.length() + catTagOpen.length() ); + } + int titleStart = contents.find( titleTagOpen, 0, false ) + titleTagOpen.length(); + int titleEnd = contents.find( titleTagClose, 0, false ); +kdDebug() << " titleTagOpen = " << titleTagOpen << ", titleTagClose = " << titleTagClose << ", start - end : " << titleStart <<" - " << titleEnd << endl; + kdDebug() << "Title start and end: " << titleStart << ", " << titleEnd << endl; + if ( titleEnd > titleStart ) { + title = contents.mid( titleStart, titleEnd - titleStart ); + contents = contents.remove( titleStart - titleTagOpen.length(), + titleEnd - titleStart + titleTagClose.length() + titleTagOpen.length() ); + } + kdDebug() << endl << endl << endl << "After treatment of the special tags, we have a content of: "<< endl << contents << endl; + } +*/ + + post->setTitle( title ); + post->setContent( contents ); + if ( !category.isEmpty() ) + post->setCategory( category ); + return true; +} + + + diff --git a/kresources/blogging/API_Blogger.h b/kresources/blogging/API_Blogger.h new file mode 100644 index 00000000..3195b472 --- /dev/null +++ b/kresources/blogging/API_Blogger.h @@ -0,0 +1,57 @@ + /* + This file is part of kdepim. + + Copyright (c) 2004 Reinhold Kainhofer + + 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 API_BLOGGER_H +#define API_BLOGGER_H + +#include "API_Blog.h" + +#include +#include +#include + +namespace KBlog { + +class APIBlogger : public APIBlog +{ + public: + APIBlogger( const KURL &server, QObject *parent = 0L, const char *name = 0L ) : APIBlog( server, parent, name ) {} + QString getFunctionName( blogFunctions type ); + QString interfaceName() const { return "Blogger API 1.0"; } + + + KIO::Job *createUserInfoJob(); + KIO::Job *createListFoldersJob(); + KIO::TransferJob *createListItemsJob( const KURL &url ); + KIO::TransferJob *createDownloadJob( const KURL &url ); + KIO::TransferJob *createUploadJob( const KURL &url, KBlog::BlogPosting *posting ); + KIO::TransferJob *createUploadNewJob( KBlog::BlogPosting *posting ); + KIO::Job *createRemoveJob( const KURL &url, const QString &postid ); + + bool interpretUserInfoJob( KIO::Job *job ); + void interpretListFoldersJob( KIO::Job *job ); + bool interpretListItemsJob( KIO::Job *job ); + bool interpretDownloadItemsJob( KIO::Job *job ); + protected: + bool readPostingFromMap( BlogPosting *post, const QMap &postInfo ); +}; + +} +#endif diff --git a/kresources/blogging/Makefile.am b/kresources/blogging/Makefile.am new file mode 100644 index 00000000..b1572436 --- /dev/null +++ b/kresources/blogging/Makefile.am @@ -0,0 +1,29 @@ +INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/kresources/lib -I../lib -I$(top_srcdir)/kresources/blogging/libkblog/ $(all_includes) + +lib_LTLIBRARIES = libkcal_blogging.la +kde_module_LTLIBRARIES = kcal_blogging.la + +libkcal_blogging_la_SOURCES = API_Blog.cpp API_Blogger.cpp xmlrpcjob.cpp \ + bloggingglobals.cpp \ + bloggingcalendaradaptor.cpp \ + kcal_resourceblogging.cpp kcal_resourcebloggingconfig.cpp +libkcal_blogging_la_LDFLAGS = $(KDE_RPATH) $(all_libraries) \ + -version-info 1:0:0 -no-undefined +libkcal_blogging_la_LIBADD = \ + ../lib/libkgroupwarebase.la \ + $(top_builddir)/libkcal/libkcal.la $(top_builddir)/libkdepim/libkdepim.la + + +kcal_blogging_la_SOURCES = kcal_resourceblogging_plugin.cpp +kcal_blogging_la_LDFLAGS = $(all_libraries) -module -no-undefined $(KDE_PLUGIN) +kcal_blogging_la_LIBADD = libkcal_blogging.la + +kcal_servicedir = $(kde_servicesdir)/kresources/kcal +kcal_service_DATA = blogging.desktop + +METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp -o $(podir)/kres_blogging.pot + +kcal_resourceblogging.lo: ../lib/kresources_groupwareprefs.h diff --git a/kresources/blogging/blogging.desktop b/kresources/blogging/blogging.desktop new file mode 100644 index 00000000..061b0634 --- /dev/null +++ b/kresources/blogging/blogging.desktop @@ -0,0 +1,50 @@ +[Desktop Entry] +Name=Journals as Blogs on a Server +Name[af]=Joernale as Blogs op 'n bediener +Name[bg]=Дневници и блогове +Name[ca]=Diaris com a blocs en un servidor +Name[cs]=Deníky jako blogy na serveru +Name[da]=Journaler som www-blogger på en server +Name[de]=Journaleinträge als Blogs auf einem Server +Name[el]=Εφημερίδες ως Blogs σε έναν εξυπηρετητή +Name[es]=Diarios, como bitácoras en un servidor +Name[et]=Päevik veebipäevikuna serveris +Name[eu]=Egunkariak blog moduan zerbitzarian +Name[fa]=نشریه‌ها به عنوان وب‌نوشتها روی یک کارساز +Name[fi]=Päiväkirjat blogeina palvelimella +Name[fr]=Journaux (blogs) sur un serveur +Name[fy]=Journalen as blochs op in tsjinner +Name[gl]=Xornais como Bitácoras nun Servidor +Name[hu]=Naplók blogként tárolása a kiszolgálón +Name[is]=Dagbækur sem blogg á þjóni +Name[it]=Diari come blog su un server +Name[ja]=サーバ上のブログとしてのジャーナル +Name[ka]=ბლოგისმაგვარი ჟურნალები სერვერზე +Name[kk]=Сервердегі күнделік блог ретінде +Name[km]=ទិនានុប្បវត្តិ​ជា​កំណត់ហេតុ​បណ្ដាញ​នៅ​លើ​ម៉ាស៊ីន​បម្រើ +Name[lt]=Dienynai kaip Blog'ai serveryje +Name[ms]=Jurnal sebagai Blog pada pelayan +Name[nb]=Dagbok som blogg på en tjener +Name[nds]=Daagbookindräag as Blog op en Server +Name[ne]=सर्भरमा बल्गका रुपका पत्रिका +Name[nl]=Journalen als blogs op een server +Name[nn]=Dagbøker som bloggar på ein tenar +Name[pl]=Dzienniki jako blogi na serwerze +Name[pt]=Diários como 'Blogs' num Servidor +Name[pt_BR]=Diários como Blogs em um Servidor +Name[ru]=Журналы (блоги) на сервере +Name[sk]=Žurnály ako blogy na serveri +Name[sl]=Dnevniki kot spletni dnevniki (blogi) na strežniku +Name[sr]=Дневници као блогови на серверу +Name[sr@Latn]=Dnevnici kao blogovi na serveru +Name[sv]=Journaler som webbloggar på en server +Name[ta]=சேவகனில் பேச்சுரைகள் பத்திரிககளாக உள்ளன +Name[tr]=Web Günlüğü gibi, bir Sunucuya yazar +Name[uk]=Журнали як веб-щоденники на сервері +Name[zh_CN]=日记作为服务器上的博客日志 +Name[zh_TW]=日誌做為伺服器上的部落格 +X-KDE-Library=kcal_blogging +Type=Service +ServiceTypes=KResources/Plugin +X-KDE-ResourceFamily=calendar +X-KDE-ResourceType=blogging diff --git a/kresources/blogging/bloggingcalendaradaptor.cpp b/kresources/blogging/bloggingcalendaradaptor.cpp new file mode 100644 index 00000000..25245278 --- /dev/null +++ b/kresources/blogging/bloggingcalendaradaptor.cpp @@ -0,0 +1,259 @@ +/* + This file is part of kdepim. + + Copyright (c) 2005 Reinhold Kainhofer + + 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 "bloggingcalendaradaptor.h" +#include "bloggingglobals.h" +#include +#include + +#include +#include +#include + +#include + +using namespace KCal; + +// That terribly long app key was generated at +// http://www.blogger.com/developers/api/1_docs/register.html +// for the "KDE-Pim libkcal blogging resource". +// TODO: +/*QString BloggingCalendarAdaptor::mAppID = + QString("20ffffffd7ffffffc5ffffffbdffffff87ffffffb72d39fffffffe5c4bfffff" + "fcfffffff80ffffffd4665cfffffff375ffffff88ffffff871a0cffffff8029"); +*/ + + +BloggingUploadItem::BloggingUploadItem( KBlog::APIBlog *api, CalendarAdaptor *adaptor, KCal::Incidence *incidence, KPIM::GroupwareUploadItem::UploadType type ) + : GroupwareUploadItem( type ), mPosting( 0 ), mAPI( 0 ) +{ + Journal* j = dynamic_cast( incidence ); + if ( api && j && adaptor ) { + mItemType = KPIM::FolderLister::Journal; + + setUrl( j->customProperty( adaptor->identifier(), "storagelocation" ) ); + setUid( j->uid() ); + + mPosting = api->postingFromJournal( j ); + mAPI = api; + } +} + +BloggingUploadItem::~BloggingUploadItem() +{ + delete mPosting; +} + +KIO::TransferJob *BloggingUploadItem::createUploadJob( KPIM::GroupwareDataAdaptor *adaptor, const KURL &baseurl ) +{ +kdDebug()<<"BloggingUploadItem::createUploadJob, adaptor="<setURL( baseurl ); + return mAPI->createUploadJob( url(), mPosting ); +} + +KIO::TransferJob *BloggingUploadItem::createUploadNewJob( KPIM::GroupwareDataAdaptor *adaptor, const KURL &baseurl ) +{ +kdDebug()<<"BloggingUploadItem::createUploadNewJob"<setURL( baseurl ); + return mAPI->createUploadNewJob( mPosting ); +} + + + + + + +BloggingCalendarAdaptor::BloggingCalendarAdaptor() : mAPI( 0 ), mAuthenticated( false ) +{ +} + + +KBlog::APIBlog *BloggingCalendarAdaptor::api() const +{ + return mAPI; +} + +void BloggingCalendarAdaptor::setAPI( KBlog::APIBlog *api ) +{ + delete mAPI; + mAPI = api; + mAuthenticated = false; + connect( api, SIGNAL( userInfoRetrieved( const QString &, const QString &, + const QString & ) ), + SLOT( slotUserInfoRetrieved( const QString &, const QString &, + const QString & ) ) ); + connect( api, SIGNAL( folderInfoRetrieved( const QString &, const QString & ) ), + SLOT( slotFolderInfoRetrieved( const QString&, const QString & ) ) ); + connect( api, SIGNAL( itemOnServer( const KURL & ) ), + SIGNAL( itemOnServer( const KURL & ) ) ); + connect( api, SIGNAL( itemDownloaded( KCal::Incidence *, const QString &, + const KURL &, const QString &, const QString & ) ), + SLOT( calendarItemDownloaded( KCal::Incidence *, const QString &, + const KURL &, const QString &, const QString & ) ) ); + +} + +KPIM::GroupwareUploadItem *BloggingCalendarAdaptor::newUploadItem( KCal::Incidence*it, + KPIM::GroupwareUploadItem::UploadType type ) +{ + return new BloggingUploadItem( mAPI, this, it, type ); +} + + + +void BloggingCalendarAdaptor::slotFolderInfoRetrieved( const QString &id, const QString &name ) +{ + emit folderInfoRetrieved( KURL(id), name, KPIM::FolderLister::Journal ); +} + +void BloggingCalendarAdaptor::slotUserInfoRetrieved( const QString &/*nick*/, + const QString &/*user*/, const QString &/*email*/ ) +{ +kdDebug() << "BloggingCalendarAdaptor::slotUserInfoRetrieved"<setURL( url ); + } +} + +void BloggingCalendarAdaptor::setUser( const QString &user ) +{ + CalendarAdaptor::setUser( user ); + if ( mAPI ) { + mAPI->setUsername( user ); + } +} + +void BloggingCalendarAdaptor::setPassword( const QString &password ) +{ + CalendarAdaptor::setPassword( password ); + if ( mAPI ) { + mAPI->setPassword( password ); + } +} + +void BloggingCalendarAdaptor::setUserPassword( KURL & ) +{ + kdDebug(5800) << "BloggingCalendarAdaptor::setUserPassword" << endl; +} + + + +KIO::Job *BloggingCalendarAdaptor::createLoginJob( const KURL &url, + const QString &user, + const QString &password ) +{ + if ( mAPI ) { + mAPI->setURL( url ); + mAPI->setUsername( user ); + mAPI->setPassword( password ); + return mAPI->createUserInfoJob(); + } else return 0; +} + +KIO::Job *BloggingCalendarAdaptor::createListFoldersJob( const KURL &/*url*/ ) +{ + if ( mAPI ) { + return mAPI->createListFoldersJob(); + } else return 0; +} + +KIO::TransferJob *BloggingCalendarAdaptor::createListItemsJob( const KURL &url ) +{ + if ( mAPI ) { + return mAPI->createListItemsJob( url ); + } else return 0; +} + +KIO::TransferJob *BloggingCalendarAdaptor::createDownloadJob( const KURL &url, + KPIM::FolderLister::ContentType ctype ) +{ + if ( mAPI && (ctype & KPIM::FolderLister::Journal) ) { + return mAPI->createDownloadJob( url ); + } else return 0; +} + +KIO::Job *BloggingCalendarAdaptor::createRemoveJob( const KURL &url, + KPIM::GroupwareUploadItem *deleteItem ) +{ +kdDebug()<<"BloggingCalendarAdaptor::createRemoveJob( " << url.url() << ", ..)" << endl; + if ( mAPI && deleteItem ) { + return mAPI->createRemoveJob( url, deleteItem->url().url() ); + } else return 0; +} + + + + +bool BloggingCalendarAdaptor::interpretLoginJob( KIO::Job *job ) +{ +kdDebug()<<"BloggingCalendarAdaptor::interpretLoginJob"<interpretUserInfoJob( job ); +kdDebug() << "authenticated=" << mAuthenticated << endl; + return mAuthenticated; + } else return false; +} + + +void BloggingCalendarAdaptor::interpretListFoldersJob( KIO::Job *job, KPIM::FolderLister * ) +{ +kdDebug() << "BloggingCalendarAdaptor::interpretListFoldersJob" << endl; + if ( mAPI && job ) { + mAPI->interpretListFoldersJob( job ); + } +} + + +bool BloggingCalendarAdaptor::interpretListItemsJob( KIO::Job *job, + const QString &/*jobData*/ ) +{ + if ( mAPI ) { + return mAPI->interpretListItemsJob( job ); + } else { + return false; + } +} + + +bool BloggingCalendarAdaptor::interpretDownloadItemsJob( KIO::Job *job, + const QString &/*jobData*/ ) +{ + if ( mAPI ) { + return mAPI->interpretDownloadItemsJob( job ); + } else { + return false; + } +} + +#include "bloggingcalendaradaptor.moc" diff --git a/kresources/blogging/bloggingcalendaradaptor.h b/kresources/blogging/bloggingcalendaradaptor.h new file mode 100644 index 00000000..b078a744 --- /dev/null +++ b/kresources/blogging/bloggingcalendaradaptor.h @@ -0,0 +1,104 @@ + /* + This file is part of kdepim. + + Copyright (C) 2004-05 Reinhold Kainhofer + + 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 KCAL_BLOGGINGCALENDARADAPTOR_H +#define KCAL_BLOGGINGCALENDARADAPTOR_H + +#include "calendaradaptor.h" +#include "groupwareuploadjob.h" +#include "API_Blog.h" +#include + +namespace KIO { +class Job; +} + +namespace KCal { + +class BloggingUploadItem : public KPIM::GroupwareUploadItem +{ + public: + BloggingUploadItem( KBlog::APIBlog *api, CalendarAdaptor *adaptor, KCal::Incidence *incidence, UploadType type ); + virtual ~BloggingUploadItem(); + virtual KIO::TransferJob *createUploadNewJob( + KPIM::GroupwareDataAdaptor *adaptor, const KURL &baseurl ); + virtual KIO::TransferJob *createUploadJob( + KPIM::GroupwareDataAdaptor *adaptor, const KURL &url ); + + protected: + BloggingUploadItem( UploadType type ) : KPIM::GroupwareUploadItem( type ) {} + KBlog::BlogPosting *mPosting; + KBlog::APIBlog *mAPI; +}; + +class BloggingCalendarAdaptor : public CalendarAdaptor +{ +Q_OBJECT + public: + BloggingCalendarAdaptor(); + QValueList supportedTypes() + { + QValueList types; + types << KPIM::FolderLister::Journal; + return types; + } + + QCString identifier() const { return "KCalResourceBlogging"; } + long flags() const { return GWResNeedsLogon; } + + void setBaseURL( const KURL &url ); + void setUser( const QString &user ); + void setPassword( const QString &password ); + // We don't want to set the username / pw for the URL! + void setUserPassword( KURL &url ); + + KBlog::APIBlog *api() const; + void setAPI( KBlog::APIBlog *api ); + + KIO::Job *createLoginJob( const KURL &url, const QString &user, + const QString &password ); + KIO::Job *createListFoldersJob( const KURL &url ); + KIO::TransferJob *createListItemsJob( const KURL &url ); + KIO::TransferJob *createDownloadJob( const KURL &url, + KPIM::FolderLister::ContentType ctype ); + KIO::Job *createRemoveJob( const KURL &url, KPIM::GroupwareUploadItem *deleteItem ); + + bool interpretLoginJob( KIO::Job *job ); + void interpretListFoldersJob( KIO::Job *job, KPIM::FolderLister * ); + bool interpretListItemsJob( KIO::Job *job, const QString &jobData ); + bool interpretDownloadItemsJob( KIO::Job *job, const QString &jobData ); + + public slots: + void slotFolderInfoRetrieved( const QString &id, const QString &name ); + void slotUserInfoRetrieved( const QString &nick, const QString &user, + const QString &email ); + + protected: + KPIM::GroupwareUploadItem *newUploadItem( KCal::Incidence*it, + KPIM::GroupwareUploadItem::UploadType type ); + + KBlog::APIBlog *mAPI; + bool mAuthenticated; + static QString mAppID; +}; + +} + +#endif diff --git a/kresources/blogging/bloggingglobals.cpp b/kresources/blogging/bloggingglobals.cpp new file mode 100644 index 00000000..fae91610 --- /dev/null +++ b/kresources/blogging/bloggingglobals.cpp @@ -0,0 +1,53 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Reinhold Kainhofer + + 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 "bloggingglobals.h" + +QString BloggingGlobals::mAppID = QString("20ffffffd7ffffffc5ffffffbdffffff87ffffffb72d39fffffffe5c4bffffffcfffffff80ffffffd4665cfffffff375ffffff88ffffff871a0cffffff8029"); + +QString BloggingGlobals::getFunctionName( blogFunctions type ) +{ + switch ( type ) { + case bloggerGetUserInfo: return "blogger.getUserInfo"; + case bloggerGetUsersBlogs: return "blogger.getUsersBlogs"; + case bloggerGetRecentPosts: return "blogger.getRecentPosts"; + case bloggerNewPost: return "blogger.newPost"; + case bloggerEditPost: return "blogger.editPost"; + case bloggerDeletePost: return "blogger.deletePost"; + case bloggerGetPost: return "blogger.getPost"; + case bloggerGetTemplate: return "blogger.getTemplate"; + case bloggerSetTemplate: return "blogger.setTemplate"; + default: return QString::null; + } +} + +QValueList BloggingGlobals::defaultArgs( const QString &user, const QString &pw, const QString &id ) +{ + QValueList args; + args << QVariant( mAppID ); + if ( !id.isNull() ) { + args << QVariant( id ); + } + args << QVariant( user ) + << QVariant( pw ); + return args; +} + diff --git a/kresources/blogging/bloggingglobals.h b/kresources/blogging/bloggingglobals.h new file mode 100644 index 00000000..7d6ed786 --- /dev/null +++ b/kresources/blogging/bloggingglobals.h @@ -0,0 +1,50 @@ + /* + This file is part of kdepim. + + Copyright (c) 2005 Reinhold Kainhofer + + 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 BLOGGINGGLOBALS_H +#define BLOGGINGGLOBALS_H + +#include +#include +#include + +class BloggingGlobals +{ + public: + BloggingGlobals() {} + + enum blogFunctions { + bloggerGetUserInfo, + bloggerGetUsersBlogs, + bloggerGetRecentPosts, + bloggerNewPost, + bloggerEditPost, + bloggerDeletePost, + bloggerGetPost, + bloggerGetTemplate, + bloggerSetTemplate + }; + + static QString getFunctionName( blogFunctions type ); + static QValueList defaultArgs( const QString &user, const QString &pw, const QString &id = QString::null ); + static QString mAppID; +}; + +#endif diff --git a/kresources/blogging/kcal_resourceblogging.cpp b/kresources/blogging/kcal_resourceblogging.cpp new file mode 100644 index 00000000..bffce10d --- /dev/null +++ b/kresources/blogging/kcal_resourceblogging.cpp @@ -0,0 +1,93 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Reinhold Kainhofer > + + 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 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 "bloggingcalendaradaptor.h" +#include "API_Blogger.h" + +#include "kcal_resourceblogging.h" +#include + +using namespace KCal; + +KBlog::APIBlog *ResourceBlogging::mAPI = 0; + +ResourceBlogging::ResourceBlogging() + : ResourceGroupwareBase() +{ + init(); +} + +ResourceBlogging::ResourceBlogging( const KConfig *config ) + : ResourceGroupwareBase( config ) +{ + init(); + if ( config ) readConfig( config ); +} + +void ResourceBlogging::init() +{ + setType( "ResourceBlogging" ); + setPrefs( createPrefs() ); + setFolderLister( new KPIM::FolderLister( KPIM::FolderLister::Calendar ) ); + BloggingCalendarAdaptor *ad = new BloggingCalendarAdaptor(); + setAdaptor( ad ); + ad->setAPI( new KBlog::APIBlogger( prefs()->url(), this ) ); + + ResourceGroupwareBase::init(); +} + +void ResourceBlogging::readConfig( const KConfig *config ) +{ + BloggingCalendarAdaptor *ad = dynamic_cast( adaptor() ); + ResourceGroupwareBase::readConfig( config ); + if ( ad && prefs() ) { + ad->setUser( prefs()->user() ); + ad->setPassword( prefs()->password() ); + ad->setBaseURL( prefs()->url() ); + } +// QString url = config->readEntry( "URL" ); +// mUrl = KURL( url ); + +// mServerAPI = config->readNumEntry( "ServerAPI" ); +// mTemplate.setCategoryTagOpen( config->readEntry( "CategoryTagOpen", "" ) ); +// mTemplate.setCategoryTagClose( config->readEntry( "CategoryTagClose", "" ) ); +// mTemplate.setTitleTagOpen( config->readEntry( "TitleTagOpen", "" ) ); +// mTemplate.setTitleTagClose( config->readEntry( "TitleTagClose", "" ) ); + +} + +void ResourceBlogging::writeConfig( KConfig *config ) +{ + kdDebug(5800) << "ResourceBlogging::writeConfig()" << endl; + + ResourceCalendar::writeConfig( config ); + +// config->writeEntry( "URL", mUrl.url() ); +// config->writeEntry( "ServerAPI", mServerAPI ); +// config->writeEntry( "CategoryTagOpen", mTemplate.categoryTagOpen() ); +// config->writeEntry( "CategoryTagClose", mTemplate.categoryTagClose() ); +// config->writeEntry( "TitleTagOpen", mTemplate.titleTagOpen() ); +// config->writeEntry( "TitleTagClose", mTemplate.titleTagClose() ); + + ResourceGroupwareBase::writeConfig( config ); +} + + +#include "kcal_resourceblogging.moc" diff --git a/kresources/blogging/kcal_resourceblogging.h b/kresources/blogging/kcal_resourceblogging.h new file mode 100644 index 00000000..2563b66e --- /dev/null +++ b/kresources/blogging/kcal_resourceblogging.h @@ -0,0 +1,59 @@ + /* + This file is part of kdepim. + + Copyright (c) 2004 Reinhold Kainhofer + + 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 KCAL_RESOURCEBLOGGING_H +#define KCAL_RESOURCEBLOGGING_H + +#include +#include + +namespace KBlog { +class APIBlog; +} + +namespace KCal { + +/** + This class provides a resource for accessing blogs on a blogging server as journals +*/ +class KDE_EXPORT ResourceBlogging : public ResourceGroupwareBase +{ + Q_OBJECT + public: + ResourceBlogging(); + ResourceBlogging( const KConfig * ); + + void readConfig( const KConfig *config ); + void writeConfig( KConfig *config ); + + bool addEvent( Event* ) { return false; } + bool addTodo( Todo * ) { return false; } + bool deleteEvent( Event* ) { return false; } + bool deleteTodo( Todo * ) { return false; } + static KBlog::APIBlog *api() { return mAPI; } + + protected: + void init(); + static KBlog::APIBlog *mAPI; +}; + +} + +#endif diff --git a/kresources/blogging/kcal_resourceblogging_plugin.cpp b/kresources/blogging/kcal_resourceblogging_plugin.cpp new file mode 100644 index 00000000..108d5e89 --- /dev/null +++ b/kresources/blogging/kcal_resourceblogging_plugin.cpp @@ -0,0 +1,41 @@ +/* + This file is part of kdepim. + + Copyright (c) 2004 Reinhold Kainhofer + + 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 "kcal_resourceblogging.h" +#include "kcal_resourcebloggingconfig.h" + +#include +#include + +using namespace KCal; + +typedef KRES::PluginFactory< ResourceBlogging, ResourceBloggingConfig > BloggingFactory; +//K_EXPORT_COMPONENT_FACTORY( kcal_blogging, BloggingFactory ) + +extern "C" +{ + void *init_kcal_blogging() + { + KGlobal::locale()->insertCatalogue( "kdepimresources" ); + KGlobal::locale()->insertCatalogue( "kres_blogging" ); + return new BloggingFactory; + } +} diff --git a/kresources/blogging/kcal_resourcebloggingconfig.cpp b/kresources/blogging/kcal_resourcebloggingconfig.cpp new file mode 100644 index 00000000..6e234828 --- /dev/null +++ b/kresources/blogging/kcal_resourcebloggingconfig.cpp @@ -0,0 +1,41 @@ +/* + This file is part of kdepim. + + Copyright (c) 2005 Reinhold Kainhofer + + 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 "kcal_resourcebloggingconfig.h" + +#include +#include + +using namespace KCal; + +ResourceBloggingConfig::ResourceBloggingConfig( QWidget *parent, const char *name ) : ResourceGroupwareBaseConfig( parent, name ) +{ +} + +void ResourceBloggingConfig::saveSettings( KRES::Resource *resource ) +{ + if ( resource && !resource->readOnly() ) { + KMessageBox::information( this, i18n("Currently, the blogging resource is only read-only. You will not be able to add journals to this resource or upload any changes to the server."), i18n("Read-Only"), "AutoSetReadOnly"); + resource->setReadOnly( true ); + } + ResourceGroupwareBaseConfig::saveSettings( resource ); +} + +#include "kcal_resourcebloggingconfig.moc" diff --git a/kresources/blogging/kcal_resourcebloggingconfig.h b/kresources/blogging/kcal_resourcebloggingconfig.h new file mode 100644 index 00000000..a7a7a4b0 --- /dev/null +++ b/kresources/blogging/kcal_resourcebloggingconfig.h @@ -0,0 +1,40 @@ +/* + This file is part of kdepim. + + Copyright (c) 2005 Reinhold Kainhofer + + 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 KCAL_RESOURCEBLOGGINGCONFIG_H +#define KCAL_RESOURCEBLOGGINGCONFIG_H + +#include +#include + +namespace KCal { + +class KDE_EXPORT ResourceBloggingConfig : public ResourceGroupwareBaseConfig +{ + Q_OBJECT + public: + ResourceBloggingConfig( QWidget *parent = 0, const char *name = 0 ); + + public slots: + virtual void saveSettings( KRES::Resource *resource ); +}; + +} + +#endif diff --git a/kresources/blogging/resourcebloggingsettings.ui b/kresources/blogging/resourcebloggingsettings.ui new file mode 100644 index 00000000..6dbb64b0 --- /dev/null +++ b/kresources/blogging/resourcebloggingsettings.ui @@ -0,0 +1,330 @@ + +ResourceBloggingSettings +Ian Reinhart Geiser <geiseri@kde.org> + + + ResourceBloggingSettings + + + + 0 + 0 + 363 + 289 + + + + + unnamed + + + + layout12 + + + + unnamed + + + + textLabel1_4 + + + false + + + + 4 + 5 + 0 + 0 + + + + Service: + + + + + + Custom + + + + + Blogger.com + + + + mServiceType + + + false + + + + + + + groupBox2 + + + Server Settings + + + + unnamed + + + + textLabel1 + + + + 4 + 5 + 0 + 0 + + + + URL: + + + + + textLabel9 + + + Username: + + + + + mUser + + + + + textLabel10 + + + Password: + + + + + mURL + + + http://www.kdedevelopers.com/xmlrpc.php + + + true + + + + + mPassword + + + Password + + + + + textLabel4_2 + + + + 4 + 5 + 0 + 0 + + + + Server API: + + + + + + Blogger API + + + + + Drupal API + + + + + metaWeblog API + + + + + Moveable Type API + + + + mServerAPI + + + true + + + + + + + groupBox3 + + + Templates + + + + unnamed + + + + mCloseTitle + + + + 1 + 0 + 0 + 0 + + + + </TITLE> + + + + + textLabel7_2 + + + Title tags: + + + + + mOpenTitle + + + + 1 + 0 + 0 + 0 + + + + <TITLE> + + + + + mOpenCategory + + + + 1 + 0 + 0 + 0 + + + + 2 + + + <CATEGORY> + + + + + textLabel8_2 + + + + 4 + 1 + 0 + 0 + + + + Category tags: + + + + + mCloseCategory + + + + 1 + 0 + 0 + 0 + + + + </CATEGORY> + + + + + + + spacer4_2 + + + Vertical + + + Expanding + + + + 20 + 84 + + + + + + + + + mServiceType + mURL + mUser + mPassword + mServerAPI + mOpenTitle + mCloseTitle + mOpenCategory + mCloseCategory + + + + kcombobox.h + klineedit.h + kurlrequester.h + klineedit.h + kpushbutton.h + klineedit.h + kcombobox.h + klineedit.h + klineedit.h + klineedit.h + klineedit.h + + diff --git a/kresources/blogging/xmlrpcjob.cpp b/kresources/blogging/xmlrpcjob.cpp new file mode 100644 index 00000000..76bee44f --- /dev/null +++ b/kresources/blogging/xmlrpcjob.cpp @@ -0,0 +1,430 @@ +/* This file is part of the KDE libraries + Copyright (C) 2004 Reinhold Kainhofer + + Based on the davjob: + Copyright (C) 2002 Jan-Pascal van Best + XML-RPC specific parts taken from the xmlrpciface: + Copyright (C) 2003 - 2004 by Frerich Raabe + Tobias Koenig + + + 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 "xmlrpcjob.h" + +#include +#include + +#include +#include +#include +#include +#include + + +#define KIO_ARGS QByteArray packedArgs; \ + QDataStream stream( packedArgs, IO_WriteOnly ); stream + +using namespace KIO; + +namespace KIO { + class XMLRPCResult + { + friend class XmlrpcJob; + public: + XMLRPCResult() {} + bool success() const { return m_success; } + int errorCode() const { return m_errorCode; } + QString errorString() const { return m_errorString; } + QValueList data() const { return m_data; } + private: + bool m_success; + int m_errorCode; + QString m_errorString; + QValueList m_data; + }; +} + +class XmlrpcJob::XmlrpcJobPrivate +{ +public: +// QByteArray savedStaticData; +}; + + +XmlrpcJob::XmlrpcJob( const KURL& url, const QString& method, + const QValueList ¶ms, bool showProgressInfo) + : TransferJob( url, KIO::CMD_SPECIAL, QByteArray(), QByteArray(), + showProgressInfo ) +{ + d = new XmlrpcJobPrivate; + // We couldn't set the args when calling the parent constructor, + // so do it now. + QDataStream stream( m_packedArgs, IO_WriteOnly ); + stream << (int)1 << url; +kdDebug()<<"XMLrpcJob::url="<savedStaticData = staticData.copy(); + } + addMetaData( "UserAgent", "KDE XML-RPC TransferJob" ); + addMetaData( "content-type", "Content-Type: text/xml; charset=utf-8" ); + addMetaData( "ConnectTimeout", "50" ); +} + +XmlrpcJob::~XmlrpcJob() +{ + delete d; + d = 0; +} + +QString XmlrpcJob::markupCall( const QString &cmd, + const QValueList &args ) +{ +kdDebug()<<"XmlrpcJob::markupCall, cmd="<\r\n\r\n"; + + markup += "" + cmd + "\r\n"; + + if ( !args.isEmpty() ) + { + markup += "\r\n"; + QValueList::ConstIterator it = args.begin(); + QValueList::ConstIterator end = args.end(); + for ( ; it != end; ++it ) + markup += "\r\n" + marshal( *it ) + "\r\n"; + markup += "\r\n"; + } + + markup += "\r\n"; + + return markup; +} + + + + + +void XmlrpcJob::slotData( const QByteArray& data ) +{ +kdDebug()<<"XmlrpcJob::slotData()"<> s_cmd; + istream >> s_url; + istream >> s_method; + // PROPFIND + if ( (s_cmd == 7) && (s_method == (int)KIO::HTTP_POST) ) { + m_packedArgs.truncate(0); + QDataStream stream( m_packedArgs, IO_WriteOnly ); + stream << (int)7 << m_redirectionURL << (int)KIO::HTTP_POST; + } + } else */ + + kdDebug() << "\033[35;40mResult: " << m_str_response << "\033[0;0m" << endl; + QDomDocument doc; + QString errMsg; + int errLine, errCol; + if ( doc.setContent( m_str_response, false, &errMsg, &errLine, &errCol ) ) { + if ( isMessageResponse( doc ) ) { + m_response = parseMessageResponse( doc ).data(); + m_responseType = XMLRPCMessageResponse; + } else if ( isFaultResponse( doc ) ) { + // TODO: Set the error of the job + m_response.clear(); + m_response << QVariant( parseFaultResponse( doc ).errorString() ); + m_responseType = XMLRPCFaultResponse; + } else { + // TODO: Set the error of the job + m_response.clear(); + m_response << QVariant( i18n( "Unknown type of XML markup received. " + "Markup: \n %1" ).arg( m_str_response ) ); + m_responseType = XMLRPCUnknownResponse; + } + + } else { + // TODO: if we can't parse the XML response, set the correct error message! +// emit fault( -1, i18n( "Received invalid XML markup: %1 at %2:%3" ) +// .arg( errMsg ).arg( errLine ).arg( errCol ), m_id ); + } + + TransferJob::slotFinished(); +// TODO: Redirect: if( d ) staticData = d->savedStaticData.copy(); +// Need to send XMLRPC request to this host too +} + + + + + +bool XmlrpcJob::isMessageResponse( const QDomDocument &doc ) +{ + return doc.documentElement().firstChild().toElement() + .tagName().lower() == "params"; +} + +XMLRPCResult XmlrpcJob::parseMessageResponse( const QDomDocument &doc ) +{ + XMLRPCResult response; + response.m_success = true; + + QDomNode paramNode = doc.documentElement().firstChild().firstChild(); + while ( !paramNode.isNull() ) { + response.m_data << demarshal( paramNode.firstChild().toElement() ); + paramNode = paramNode.nextSibling(); + } + + return response; +} + + + + + +bool XmlrpcJob::isFaultResponse( const QDomDocument &doc ) +{ + return doc.documentElement().firstChild().toElement() + .tagName().lower() == "fault"; +} + +XMLRPCResult XmlrpcJob::parseFaultResponse( const QDomDocument &doc ) +{ + XMLRPCResult response; + response.m_success = false; + + QDomNode errorNode = doc.documentElement().firstChild().firstChild(); + const QVariant errorVariant = demarshal( errorNode.toElement() ); + response.m_errorCode = errorVariant.toMap() [ "faultCode" ].toInt(); + response.m_errorString = errorVariant.toMap() [ "faultString" ].toString(); + + return response; +} + + + + + +QString XmlrpcJob::marshal( const QVariant &arg ) +{ + switch ( arg.type() ) + { + case QVariant::String: + case QVariant::CString: + return "" + arg.toString() + "\r\n"; + case QVariant::Int: + return "" + QString::number( arg.toInt() ) + + "\r\n"; + case QVariant::Double: + return "" + QString::number( arg.toDouble() ) + + "\r\n"; + case QVariant::Bool: + { + QString markup = ""; + markup += arg.toBool() ? "1" : "0"; + markup += "\r\n"; + return markup; + } + case QVariant::ByteArray: + return "" + KCodecs::base64Encode( arg.toByteArray() ) + + "\r\n"; + case QVariant::DateTime: + return "" + + arg.toDateTime().toString( Qt::ISODate ) + + "\r\n"; + case QVariant::List: + { + QString markup = "\r\n"; + const QValueList args = arg.toList(); + QValueList::ConstIterator it = args.begin(); + QValueList::ConstIterator end = args.end(); + for ( ; it != end; ++it ) + markup += marshal( *it ); + markup += "\r\n"; + return markup; + } + case QVariant::Map: + { + QString markup = "\r\n"; + QMap map = arg.toMap(); + QMap::ConstIterator it = map.begin(); + QMap::ConstIterator end = map.end(); + for ( ; it != end; ++it ) + { + markup += "\r\n"; + markup += "" + it.key() + "\r\n"; + markup += marshal( it.data() ); + markup += "\r\n"; + } + markup += "\r\n"; + return markup; + } + default: + kdWarning() << "Failed to marshal unknown variant type: " + << arg.type() << endl; + }; + return QString::null; +} + +QVariant XmlrpcJob::demarshal( const QDomElement &elem ) +{ + Q_ASSERT( elem.tagName().lower() == "value" ); + + if ( !elem.hasChildNodes() ) { + // it doesn't have child nodes, so no explicit type name was given, + // i.e. here comes the value instead of + // here comes the value + // Assume in that case: + // Actually, the element will still have a child node, so this will not help here. + // The dirty hack is at the end of this method. +kdDebug()<<"XmlrpcJob::demarshal: No child nodes, assume type=string. Text: "<= 0 ) { + // It's in the format 20041120T...., so adjust it to correct + // ISO 8601 Format 2004-11-20T..., else QDateTime::fromString won't work: + text = text.insert( 6, '-' ); + text = text.insert( 4, '-' ); + } + return QVariant( QDateTime::fromString( text, Qt::ISODate ) ); + + } else if ( typeName == "array" ) { + + QValueList values; + QDomNode valueNode = typeElement.firstChild().firstChild(); + while ( !valueNode.isNull() ) { + values << demarshal( valueNode.toElement() ); + valueNode = valueNode.nextSibling(); + } + return QVariant( values ); + + } else if ( typeName == "struct" ) { + + QMap map; + QDomNode memberNode = typeElement.firstChild(); + while ( !memberNode.isNull() ) { + const QString key = memberNode.toElement().elementsByTagName( "name" ).item( 0 ).toElement().text(); + const QVariant data = demarshal( memberNode.toElement().elementsByTagName( "value" ).item( 0 ).toElement() ); + map[ key ] = data; + memberNode = memberNode.nextSibling(); + } + return QVariant( map ); + + } else { + + kdWarning() << "Cannot demarshal unknown type " << typeName << ", text= " << typeElement.text() << endl; + // FIXME: This is just a workaround, for the issue mentioned at the beginning of this method. + return QVariant( elem.text() ); + } + + return QVariant(); +} + + + + + +/* Convenience methods */ + +XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const QString &method, const QValueList ¶ms, bool showProgressInfo ) +{ + if ( url.isEmpty() ) { + kdWarning() << "Cannot execute call to " << method << ": empty server URL" << endl; + return 0; + } + XmlrpcJob *job = new XmlrpcJob( url, method, params, showProgressInfo ); +// job->addMetaData( "xmlrpcDepth", depth ); + + return job; +} + +XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const QString &method, + const QVariant &arg, bool showProgressInfo ) +{ + QValueList args; + args << arg; + return KIO::xmlrpcCall( url, method, args, showProgressInfo ); +} + +XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const QString &method, + const QStringList &arg, bool showProgressInfo ) +{ + QValueList args; + QStringList::ConstIterator it = arg.begin(); + QStringList::ConstIterator end = arg.end(); + for ( ; it != end; ++it ) + args << QVariant( *it ); + return KIO::xmlrpcCall( url, method, args, showProgressInfo ); +} + +template +XmlrpcJob* KIO::xmlrpcCall( const KURL& url, const QString &method, + const QValueList&arg, bool showProgressInfo ) +{ + QValueList args; + + typename QValueList::ConstIterator it = arg.begin(); + typename QValueList::ConstIterator end = arg.end(); + for ( ; it != end; ++it ) + args << QVariant( *it ); + return KIO::xmlrpcCall( url, method, args, showProgressInfo ); +} + +#include "xmlrpcjob.moc" diff --git a/kresources/blogging/xmlrpcjob.h b/kresources/blogging/xmlrpcjob.h new file mode 100644 index 00000000..cd657aa3 --- /dev/null +++ b/kresources/blogging/xmlrpcjob.h @@ -0,0 +1,123 @@ +// -*- c++ -*- +/* This file is part of the KDE libraries + Copyright (C) 2004 Reinhold Kainhofer + Based on the davjob: + Copyright (C) 2002 Jan-Pascal van Best + + 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 __kio_xmlrpcjob_h__ +#define __kio_xmlrpcjob_h__ + +#include + +#include +#include +#include + +#include +#include + +namespace KIO { + + class XMLRPCResult; + +/** + * The transfer job pumps data into and/or out of a Slave. + * Data is sent to the slave on request of the slave ( dataReq ). + * If data coming from the slave can not be handled, the + * reading of data from the slave should be suspended. + * @see KIO::xmlrpcCall() + * @since 3.4 + */ +class XmlrpcJob : public TransferJob { +Q_OBJECT + + public: + /** Indicates the response type of the call + */ + enum XMLRPCResponseType { + XMLRPCMessageResponse, + XMLRPCFaultResponse, + XMLRPCUnknownResponse + }; + /** + * Use KIO::xmlrpcPropFind(), KIO::xmlrpcPropPatch() and + * KIO::xmlrpcSearch() to create a new XmlrpcJob. + */ + XmlrpcJob( const KURL& url, const QString& method, + const QValueList ¶ms, bool showProgressInfo ); + virtual ~XmlrpcJob(); + /** + * Returns the response as a QDomDocument. + * @return the response document + */ + QValueList &response() { return m_response; } + /** + * Returns the type of the response. + * @return the type of the response + */ + XMLRPCResponseType responseType() const { return m_responseType; } + + static QString markupCall( const QString &cmd, + const QValueList &args ); + protected slots: + virtual void slotFinished(); + virtual void slotData( const QByteArray &data); + + protected: + static QString marshal( const QVariant &arg ); + static QVariant demarshal( const QDomElement &e ); + + static bool isMessageResponse( const QDomDocument &doc ); + static bool isFaultResponse( const QDomDocument &doc ); + + static XMLRPCResult parseMessageResponse( const QDomDocument &doc ); + static XMLRPCResult parseFaultResponse( const QDomDocument &doc ); + + + private: + class XmlrpcJobPrivate; + XmlrpcJobPrivate *d; + QString m_str_response; + QValueList m_response; + XMLRPCResponseType m_responseType; +}; + +/** + * Creates a XmlrpcJob that calls a @p method of the API at the given @p url. + * + * @param url the URL of the XML-RPC Interface of the server + * @param method the name of the method to call + * @param params the arguments (as QValueList) for the method call. + * @param showProgressInfo true to show progress information + * @return the new XmlrpcJob + */ +XmlrpcJob* xmlrpcCall( const KURL& url, const QString &method, + const QValueList ¶ms, + bool showProgressInfo = true ); + +XmlrpcJob* xmlrpcCall( const KURL& url, const QString &method, + const QVariant &arg, bool showProgressInfo = true ); +XmlrpcJob* xmlrpcCall( const KURL& url, const QString &method, + const QStringList &arg, bool showProgressInfo = true ); +template +XmlrpcJob* xmlrpcCall( const KURL& url, const QString &method, + const QValueList&arg,bool showProgressInfo = true ); +} + +#endif -- cgit v1.2.3