1/*
2 This file is part of the kblog library.
3
4 Copyright (c) 2004 Reinhold Kainhofer <reinhold@kainhofer.com>
5 Copyright (c) 2006-2007 Christian Weilbach <christian_weilbach@web.de>
6 Copyright (c) 2007 Mike McQuaid <mike@mikemcquaid.com>
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details.
17
18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA.
22*/
23
24#ifndef KBLOG_BLOGGER1_H
25#define KBLOG_BLOGGER1_H
26
27#include <kblog/blog.h>
28
29class KUrl;
30
31/**
32 @file
33 This file is part of the for accessing Blog Servers
34 and defines the Blogger1 class.
35
36 @author Reinhold Kainhofer \<reinhold\@kainhofer.com\>
37 @author Christian Weilbach \<christian_weilbach\@web.de\>
38*/
39
40namespace KBlog {
41
42class Blogger1Private;
43
44/**
45 @brief
46 A class that can be used for access to Blogger 1.0 blogs.
47 Almost every blog server supports Blogger 1.0. Compared to
48 MetaWeblog it is not as functional and is obsolete on blogspot.com
49 compared to GData which uses Atom instead of Xml-Rpc.
50
51 @code
52 Blog* myblog = new Blogger1("http://example.com/xmlrpc/gateway.php");
53 myblog->setUsername( "some_user_id" );
54 myblog->setPassword( "YoUrFunnYPasSword" );
55 myblog->setBlogId( "1" ); // can be caught by listBlogs()
56 KBlog::BlogPost *post = new BlogPost();
57 post->setTitle( "This is the title." );
58 post->setContent( "Here is some the content..." );
59 myblog->createPost( post );
60 @endcode
61
62 @author Christian Weilbach \<christian_weilbach\@web.de\>
63 @author Reinhold Kainhofer \<reinhold\@kainhofer.com\>
64*/
65class KBLOG_EXPORT Blogger1 : public Blog
66{
67 Q_OBJECT
68 public:
69 /**
70 Create an object for Blogger 1.0
71
72 @param server is the url for the xmlrpc gateway.
73 @param parent the parent object.
74 */
75 explicit Blogger1( const KUrl &server, QObject *parent = 0 );
76
77 /**
78 Destroy the object.
79 */
80 virtual ~Blogger1();
81
82 /**
83 Returns the of the inherited object.
84 */
85 QString interfaceName() const;
86
87 /**
88 Set the Url of the server.
89
90 @param server is the server Url.
91 */
92 void setUrl( const KUrl &server );
93
94 /**
95 Get information about the user from the blog. Note: This is not
96 supported on the server side.
97 @see void fetchedUserInfo( const QMap\<QString,QString\>& )
98 */
99 virtual void fetchUserInfo();
100
101 /**
102 List the blogs available for this authentication on the server.
103 @see void listedBlogs( const QList\<QMap\<QString,QString\> \>& )
104 */
105 virtual void listBlogs();
106
107 /**
108 List recent posts on the server. The status of the posts will be Fetched.
109
110 @param number The number of posts to fetch. Latest first.
111
112 @see void listedRecentPosts( QList\<KBlog::BlogPost> & )
113 @see void fetchPost( KBlog::BlogPost *post )
114 @see BlogPost::Status
115 */
116 void listRecentPosts( int number );
117
118 /**
119 Fetch a post from the server.
120
121 @param post is the post. Note: Its id has to be set
122 appropriately.
123
124 @see BlogPost::setPostId( const QString& )
125 @see fetchedPost( KBlog::BlogPost *post )
126 */
127 void fetchPost( KBlog::BlogPost *post );
128
129 /**
130 Modify a post on server.
131
132 @param post is used to send the modified post including
133 the correct postId from it to the server.
134
135 @see void modifiedPost( KBlog::BlogPost *post )
136 */
137 void modifyPost( KBlog::BlogPost *post );
138
139 /**
140 Create a new post on server.
141
142 @param post is sent to the server.
143
144 @see createdPost( KBlog::BlogPost *post )
145 */
146 void createPost( KBlog::BlogPost *post );
147
148 /**
149 Remove a post from the server.
150
151 @param post is the post. Note: Its id has to be set
152 appropriately.
153
154 @see BlogPost::setPostId( const QString& )
155 @see removedPost( KBlog::BlogPost *post )
156 */
157 void removePost( KBlog::BlogPost *post );
158
159 Q_SIGNALS:
160
161 /**
162 This signal is emitted when a listBlogs() job fetches the blog
163 information from the blogging server.
164
165 @param blogsList The list of maps, in which each maps corresponds to
166 a blog on the server. Each map has the keys id and name.
167
168 @see listBlogs()
169 */
170 void listedBlogs( const QList<QMap<QString,QString> >& blogsList );
171
172 /**
173 This signal is emitted when a fetchUserInfo() job fetches the blog
174 information from the blogging server.
175
176 @param userInfo The map with the keys: nickname,
177 userid, url, email, lastname, firstname. Note: Not all keys are
178 supported by all servers.
179
180 @see fetchUserInfo()
181 */
182 void fetchedUserInfo( const QMap<QString,QString> &userInfo );
183
184 protected:
185 /**
186 Constructor needed for private inheritance.
187 */
188 Blogger1( const KUrl &server, Blogger1Private &dd, QObject *parent = 0 );
189
190 private:
191 Q_DECLARE_PRIVATE( Blogger1 )
192 Q_PRIVATE_SLOT( d_func(),
193 void slotFetchUserInfo( const QList<QVariant> &, const QVariant & ) )
194 Q_PRIVATE_SLOT( d_func(),
195 void slotListBlogs( const QList<QVariant> &, const QVariant & ) )
196 Q_PRIVATE_SLOT( d_func(),
197 void slotListRecentPosts( const QList<QVariant> &, const QVariant & ) )
198 Q_PRIVATE_SLOT( d_func(),
199 void slotFetchPost( const QList<QVariant> &, const QVariant & ) )
200 Q_PRIVATE_SLOT( d_func(),
201 void slotCreatePost( const QList<QVariant> &, const QVariant & ) )
202 Q_PRIVATE_SLOT( d_func(),
203 void slotModifyPost( const QList<QVariant> &, const QVariant & ) )
204 Q_PRIVATE_SLOT( d_func(),
205 void slotRemovePost( const QList<QVariant> &, const QVariant & ) )
206 Q_PRIVATE_SLOT( d_func(),
207 void slotError( int, const QString &, const QVariant & ) )
208};
209
210} //namespace KBlog
211#endif
212