2 This file is part of Blogilo, A KDE Blogging Client
4 Copyright (C) 2008-2010 Mehrdad Momeny <mehrdad.momeny@gmail.com>
5 Copyright (C) 2008-2010 Golnaz Nilieh <g382nilieh@gmail.com>
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of
10 the License or (at your option) version 3 or any later version
11 accepted by the membership of KDE e.V. (or its successor approved
12 by the membership of KDE e.V.), which shall act as a proxy
13 defined in Section 14 of version 3 of the license.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, see http://www.gnu.org/licenses/
24 #include "bilboblog.h"
25 #include "blogilo-version.h"
27 #include <kblog/wordpressbuggy.h>
28 #ifdef HAVE_GAPIBLOGGER_SUPPORT
32 #include <QApplication>
34 class Q_DECL_HIDDEN
BilboBlog::Private
49 Qt::LayoutDirection mDir
;
50 QString mLocalDirectory
;
52 QHash
<QString
, bool> mSupportedFeatures
;
54 QMap
<QString
, QString
> mAuthData
;
57 BilboBlog::BilboBlog(QObject
*parent
)
58 : QObject(parent
), d(new Private
)
64 BilboBlog::BilboBlog(const BilboBlog
&blog
)
65 : QObject(qApp
), d(new Private
)
68 d
->mBlogUrl
= blog
.blogUrl();
69 d
->mBlogid
= blog
.blogid();
70 d
->mUsername
= blog
.username();
71 d
->mPassword
= blog
.password();
72 d
->mTitle
= blog
.title();
75 d
->mDir
= blog
.direction();
76 d
->mLocalDirectory
= blog
.localDirectory();
77 d
->mError
= blog
.isError();
80 BilboBlog::~BilboBlog()
85 KBlog::Blog
*BilboBlog::blogBackend()
89 case BilboBlog::BLOGGER1_API
:
90 d
->kblog
= new KBlog::Blogger1(url(), this);
92 case BilboBlog::METAWEBLOG_API
:
93 d
->kblog
= new KBlog::MetaWeblog(url(), this);
95 case BilboBlog::MOVABLETYPE_API
:
96 d
->kblog
= new KBlog::MovableType(url(), this);
98 case BilboBlog::WORDPRESSBUGGY_API
:
99 d
->kblog
= new KBlog::WordpressBuggy(url(), this);
101 case BilboBlog::BLOGGER_API
:
102 #ifdef HAVE_GAPIBLOGGER_SUPPORT
103 d
->kblog
= new KBlog::Blogger(url(), this);
104 qobject_cast
<KBlog::Blogger
*>(d
->kblog
)->setApiKey(QStringLiteral("508396175529-icqp62q8t6st41gjv1du100fol6renq4.apps.googleusercontent.com"));
105 qobject_cast
<KBlog::Blogger
*>(d
->kblog
)->setSecretKey(QStringLiteral("JFPDXYmGIuM601vhgVGv0Dlx"));
111 d
->kblog
->setUserAgent(QLatin1String(APPNAME
), QStringLiteral(BLOGILO_VERSION
));
112 d
->kblog
->setUsername(username());
113 d
->kblog
->setPassword(password());
114 d
->kblog
->setBlogId(blogid());
119 bool BilboBlog::isError() const
124 void BilboBlog::setError(bool isError
)
129 QUrl
BilboBlog::url() const
134 void BilboBlog::setUrl(const QUrl
&url
)
139 QString
BilboBlog::blogid() const
144 void BilboBlog::setBlogId(const QString
&url
)
149 QString
BilboBlog::username() const
154 void BilboBlog::setUsername(const QString
&username
)
156 d
->mUsername
= username
;
159 QString
BilboBlog::password() const
164 void BilboBlog::setPassword(const QString
&password
)
166 d
->mPassword
= password
;
169 QString
BilboBlog::title() const
174 void BilboBlog::setTitle(const QString
&title
)
179 BilboBlog::ApiType
BilboBlog::api() const
184 void BilboBlog::setApi(const ApiType api
)
189 d
->mSupportedFeatures
[QStringLiteral("uploadMedia")] = false;
190 d
->mSupportedFeatures
[QStringLiteral("category")] = false;
191 d
->mSupportedFeatures
[QStringLiteral("tag")] = false;
194 d
->mSupportedFeatures
[QStringLiteral("uploadMedia")] = true;
195 d
->mSupportedFeatures
[QStringLiteral("category")] = true;
196 d
->mSupportedFeatures
[QStringLiteral("tag")] = false;
198 case MOVABLETYPE_API
:
199 d
->mSupportedFeatures
[QStringLiteral("uploadMedia")] = true;
200 d
->mSupportedFeatures
[QStringLiteral("category")] = true;
201 d
->mSupportedFeatures
[QStringLiteral("tag")] = true;
203 case WORDPRESSBUGGY_API
:
204 d
->mSupportedFeatures
[QStringLiteral("uploadMedia")] = true;
205 d
->mSupportedFeatures
[QStringLiteral("category")] = true;
206 d
->mSupportedFeatures
[QStringLiteral("tag")] = true;
209 d
->mSupportedFeatures
[QStringLiteral("uploadMedia")] = false;
210 d
->mSupportedFeatures
[QStringLiteral("category")] = false;
211 d
->mSupportedFeatures
[QStringLiteral("tag")] = true;
214 d
->mSupportedFeatures
[QStringLiteral("uploadMedia")] = false;
215 d
->mSupportedFeatures
[QStringLiteral("category")] = false;
216 d
->mSupportedFeatures
[QStringLiteral("tag")] = false;
221 int BilboBlog::id() const
226 void BilboBlog::setId(const int id
)
231 Qt::LayoutDirection
BilboBlog::direction() const
236 void BilboBlog::setDirection(const Qt::LayoutDirection dir
)
241 QString
BilboBlog::localDirectory() const
243 return d
->mLocalDirectory
;
246 void BilboBlog::setLocalDirectory(const QString
&directory
)
248 d
->mLocalDirectory
= directory
;
251 QString
BilboBlog::blogUrl() const
253 if (d
->mBlogUrl
.isEmpty()) {
254 return d
->mUrl
.toDisplayString();
260 void BilboBlog::setBlogUrl(const QString
&blogUrl
)
262 d
->mBlogUrl
= blogUrl
;
265 bool BilboBlog::supportUploadMedia() const
267 return d
->mSupportedFeatures
[QStringLiteral("uploadMedia")];
270 bool BilboBlog::supportCategory() const
272 return d
->mSupportedFeatures
[QStringLiteral("category")];
275 bool BilboBlog::supportTag() const
277 return d
->mSupportedFeatures
[QStringLiteral("tag")];
280 void BilboBlog::setAuthData(const QMap
<QString
, QString
> &authData
)
282 d
->mAuthData
= authData
;
285 QMap
<QString
, QString
> BilboBlog::authData() const