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 /kresources/blogging/API_Blog.h | |
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 'kresources/blogging/API_Blog.h')
-rw-r--r-- | kresources/blogging/API_Blog.h | 162 |
1 files changed, 162 insertions, 0 deletions
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 <reinhold@kainhofer.com> * +* * +* 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 <kurl.h> +#include <kio/job.h> +#include <libkcal/journal.h> + +#include <qobject.h> +#include <qstring.h> +#include <qvaluelist.h> +#include <qdatetime.h> + +/** +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<QVariant> 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 |