• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

blogilo

  • sources
  • kde-4.14
  • kdepim
  • blogilo
  • src
bilboblog.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Blogilo, A KDE Blogging Client
3 
4  Copyright (C) 2008-2010 Mehrdad Momeny <mehrdad.momeny@gmail.com>
5  Copyright (C) 2008-2010 Golnaz Nilieh <g382nilieh@gmail.com>
6 
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.
14 
15 
16  This program is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with this program; if not, see http://www.gnu.org/licenses/
23 */
24 
25 #include "bilboblog.h"
26 #include "dbman.h"
27 #include <kblog/wordpressbuggy.h>
28 #include "blogger.h"
29 #include <KDebug>
30 
31 #include <QApplication>
32 
33 
34 class BilboBlog::Private
35 {
36 public:
37  Private()
38  : kblog(0)
39  {}
40  KUrl mUrl;
41  QString mBlogUrl;
42  QString mBlogid;
43  QString mUsername;
44  QString mPassword;
45  QString mTitle;
46  QString mStylePath;
47  ApiType mApi;
48  int mId;//id in DB
49  Qt::LayoutDirection mDir;
50  QString mLocalDirectory;
51  bool mError;
52  QHash<QString, bool> mSupportedFeatures;
53  KBlog::Blog *kblog;
54  QMap<QString, QString> mAuthData;
55 };
56 
57 BilboBlog::BilboBlog( QObject *parent )
58  : QObject( parent ), d(new Private)
59 {
60  d->mError = false;
61  setApi(BLOGGER1_API);
62 }
63 
64 BilboBlog::BilboBlog( const BilboBlog &blog)
65  : QObject( qApp ), d(new Private)
66 {
67  d->mUrl = blog.url();
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();
73  setApi( blog.api() );
74  d->mId = blog.id();
75  d->mDir = blog.direction();
76  d->mLocalDirectory = blog.localDirectory();
77  d->mError = blog.isError();
78 }
79 
80 BilboBlog::~BilboBlog()
81 {
82  delete d;
83 }
84 
85 KBlog::Blog* BilboBlog::blogBackend()
86 {
87  if(!d->kblog){
88  switch ( api() ) {
89  case BilboBlog::BLOGGER1_API:
90  d->kblog = new KBlog::Blogger1( url(), this );
91  break;
92  case BilboBlog::METAWEBLOG_API:
93  d->kblog = new KBlog::MetaWeblog( url(), this );
94  break;
95  case BilboBlog::MOVABLETYPE_API:
96  d->kblog = new KBlog::MovableType( url(), this );
97  break;
98  case BilboBlog::WORDPRESSBUGGY_API:
99  d->kblog = new KBlog::WordpressBuggy( url(), this );
100  break;
101  case BilboBlog::BLOGGER_API:
102  d->kblog = new KBlog::Blogger( url(), this );
103  qobject_cast<KBlog::Blogger*>(d->kblog)->setApiKey( QLatin1String("508396175529-icqp62q8t6st41gjv1du100fol6renq4.apps.googleusercontent.com") );
104  qobject_cast<KBlog::Blogger*>(d->kblog)->setSecretKey( QLatin1String("JFPDXYmGIuM601vhgVGv0Dlx") );
105  break;
106  }
107  d->kblog->setUserAgent( QLatin1String(APPNAME), QLatin1String(VERSION) );
108  d->kblog->setUsername( username() );
109  d->kblog->setPassword( password() );
110  d->kblog->setBlogId( blogid() );
111  }
112  return d->kblog;
113 }
114 
115 bool BilboBlog::isError() const
116 {
117  return d->mError;
118 }
119 
120 void BilboBlog::setError(bool isError)
121 {
122  d->mError = isError;
123 }
124 
125 KUrl BilboBlog::url() const
126 {
127  return d->mUrl;
128 }
129 
130 void BilboBlog::setUrl( const KUrl &url )
131 {
132  d->mUrl = url;
133 }
134 
135 QString BilboBlog::blogid() const
136 {
137  return d->mBlogid;
138 }
139 
140 void BilboBlog::setBlogId( const QString &url )
141 {
142  d->mBlogid = url;
143 }
144 
145 QString BilboBlog::username() const
146 {
147  return d->mUsername;
148 }
149 
150 void BilboBlog::setUsername( const QString &username )
151 {
152  d->mUsername = username;
153 }
154 
155 QString BilboBlog::password() const
156 {
157  return d->mPassword;
158 }
159 
160 void BilboBlog::setPassword( const QString &password )
161 {
162  d->mPassword = password;
163 }
164 
165 QString BilboBlog::title() const
166 {
167  return d->mTitle;
168 }
169 
170 void BilboBlog::setTitle( const QString &title )
171 {
172  d->mTitle = title;
173 }
174 
175 BilboBlog::ApiType BilboBlog::api() const
176 {
177  return d->mApi;
178 }
179 
180 void BilboBlog::setApi( const ApiType api )
181 {
182  d->mApi = api;
183  switch(api) {
184  case BLOGGER1_API:
185  d->mSupportedFeatures[QLatin1String("uploadMedia")] = false;
186  d->mSupportedFeatures[QLatin1String("category")] = false;
187  d->mSupportedFeatures[QLatin1String("tag")] = false;
188  break;
189  case METAWEBLOG_API:
190  d->mSupportedFeatures[QLatin1String("uploadMedia")] = true;
191  d->mSupportedFeatures[QLatin1String("category")] = true;
192  d->mSupportedFeatures[QLatin1String("tag")] = false;
193  break;
194  case MOVABLETYPE_API:
195  d->mSupportedFeatures[QLatin1String("uploadMedia")] = true;
196  d->mSupportedFeatures[QLatin1String("category")] = true;
197  d->mSupportedFeatures[QLatin1String("tag")] = true;
198  break;
199  case WORDPRESSBUGGY_API:
200  d->mSupportedFeatures[QLatin1String("uploadMedia")] = true;
201  d->mSupportedFeatures[QLatin1String("category")] = true;
202  d->mSupportedFeatures[QLatin1String("tag")] = true;
203  break;
204  case BLOGGER_API:
205  d->mSupportedFeatures[QLatin1String("uploadMedia")] = false;
206  d->mSupportedFeatures[QLatin1String("category")] = false;
207  d->mSupportedFeatures[QLatin1String("tag")] = true;
208  break;
209  default:
210  d->mSupportedFeatures[QLatin1String("uploadMedia")] = false;
211  d->mSupportedFeatures[QLatin1String("category")] = false;
212  d->mSupportedFeatures[QLatin1String("tag")] = false;
213  break;
214  }
215 }
216 
217 int BilboBlog::id() const
218 {
219  return d->mId;
220 }
221 
222 void BilboBlog::setId( const int id )
223 {
224  d->mId = id;
225 }
226 
227 Qt::LayoutDirection BilboBlog::direction() const
228 {
229  return d->mDir;
230 }
231 
232 void BilboBlog::setDirection( const Qt::LayoutDirection dir )
233 {
234  d->mDir = dir;
235 }
236 
237 QString BilboBlog::localDirectory() const
238 {
239  return d->mLocalDirectory;
240 }
241 
242 void BilboBlog::setLocalDirectory( const QString &directory )
243 {
244  d->mLocalDirectory = directory;
245 }
246 
247 QString BilboBlog::blogUrl() const
248 {
249  if(d->mBlogUrl.isEmpty())
250  return d->mUrl.prettyUrl();
251  else
252  return d->mBlogUrl;
253 }
254 
255 void BilboBlog::setBlogUrl(const QString &blogUrl)
256 {
257  d->mBlogUrl = blogUrl;
258 }
259 
260 bool BilboBlog::supportUploadMedia() const
261 {
262  return d->mSupportedFeatures[QLatin1String("uploadMedia")];
263 }
264 
265 bool BilboBlog::supportCategory() const
266 {
267  return d->mSupportedFeatures[QLatin1String("category")];
268 }
269 
270 bool BilboBlog::supportTag() const
271 {
272  return d->mSupportedFeatures[QLatin1String("tag")];
273 }
274 
275 void BilboBlog::setAuthData( const QMap<QString, QString>& authData )
276 {
277  d->mAuthData = authData;
278 }
279 
280 QMap<QString, QString> BilboBlog::authData() const
281 {
282  return d->mAuthData;
283 }
284 
BilboBlog::blogBackend
KBlog::Blog * blogBackend()
Definition: bilboblog.cpp:85
APPNAME
static const char APPNAME[]
Definition: constants.h:37
BilboBlog::setApi
void setApi(const ApiType)
Definition: bilboblog.cpp:180
BilboBlog::METAWEBLOG_API
Definition: bilboblog.h:45
BilboBlog::password
QString password() const
Definition: bilboblog.cpp:155
BilboBlog::BLOGGER_API
Definition: bilboblog.h:45
BilboBlog::localDirectory
QString localDirectory() const
Definition: bilboblog.cpp:237
BilboBlog::setTitle
void setTitle(const QString &)
Definition: bilboblog.cpp:170
QMap< QString, QString >
BilboBlog::isError
bool isError() const
Definition: bilboblog.cpp:115
BilboBlog::supportUploadMedia
bool supportUploadMedia() const
Definition: bilboblog.cpp:260
BilboBlog::title
QString title() const
Definition: bilboblog.cpp:165
BilboBlog::BilboBlog
BilboBlog(QObject *parent=0)
Definition: bilboblog.cpp:57
BilboBlog::supportTag
bool supportTag() const
Definition: bilboblog.cpp:270
BilboBlog::WORDPRESSBUGGY_API
Definition: bilboblog.h:45
BilboBlog::setAuthData
void setAuthData(const QMap< QString, QString > &authData)
Definition: bilboblog.cpp:275
BilboBlog::blogid
QString blogid() const
Definition: bilboblog.cpp:135
BilboBlog::setId
void setId(const int)
Definition: bilboblog.cpp:222
BilboBlog
Blog definition class!
Definition: bilboblog.h:40
VERSION
static const char VERSION[]
Constants.
Definition: constants.h:36
BilboBlog::setDirection
void setDirection(const Qt::LayoutDirection)
Definition: bilboblog.cpp:232
blogger.h
This file is part of the for accessing Blog Servers from the Google's Blogger and BlogPost service an...
BilboBlog::setPassword
void setPassword(const QString &)
Definition: bilboblog.cpp:160
BilboBlog::~BilboBlog
~BilboBlog()
Definition: bilboblog.cpp:80
QHash< QString, bool >
BilboBlog::setUsername
void setUsername(const QString &)
Definition: bilboblog.cpp:150
QObject
BilboBlog::username
QString username() const
Definition: bilboblog.cpp:145
BilboBlog::supportCategory
bool supportCategory() const
Definition: bilboblog.cpp:265
QString
bilboblog.h
BilboBlog::setUrl
void setUrl(const KUrl &)
Definition: bilboblog.cpp:130
dbman.h
BilboBlog::authData
QMap< QString, QString > authData() const
Definition: bilboblog.cpp:280
BilboBlog::direction
Qt::LayoutDirection direction() const
Definition: bilboblog.cpp:227
BilboBlog::id
int id() const
Definition: bilboblog.cpp:217
QLatin1String
KBlog::Blogger
A class that can be used for access to Google blogs.
Definition: blogger.h:65
BilboBlog::setLocalDirectory
void setLocalDirectory(const QString &)
Definition: bilboblog.cpp:242
BilboBlog::BLOGGER1_API
Definition: bilboblog.h:45
BilboBlog::setError
void setError(bool isError)
Definition: bilboblog.cpp:120
BilboBlog::ApiType
ApiType
Definition: bilboblog.h:44
BilboBlog::MOVABLETYPE_API
Definition: bilboblog.h:45
BilboBlog::url
KUrl url() const
returns blog xmlrpc Url! For http://bilbo.wordpress.com : it's url() is http://bilbo.wordpress.com/xmlrpc.php and it's blogUrl() is http://bilbo.wordpress.com/
Definition: bilboblog.cpp:125
BilboBlog::blogUrl
QString blogUrl() const
return Blog Actual Url! For http://bilbo.wordpress.com : it's url() is http://bilbo.wordpress.com/xmlrpc.php and it's blogUrl() is http://bilbo.wordpress.com/
Definition: bilboblog.cpp:247
BilboBlog::api
ApiType api() const
Definition: bilboblog.cpp:175
BilboBlog::setBlogId
void setBlogId(const QString &)
Definition: bilboblog.cpp:140
BilboBlog::setBlogUrl
void setBlogUrl(const QString &blogUrl)
Definition: bilboblog.cpp:255
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:16 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

blogilo

Skip menu "blogilo"
  • Main Page
  • Namespace List
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal