1 | /* |
2 | This file is part of the kblog library. |
3 | |
4 | Copyright (c) 2007-2009 Christian Weilbach <christian_weilbach@web.de> |
5 | |
6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. |
10 | |
11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
19 | Boston, MA 02110-1301, USA. |
20 | */ |
21 | |
22 | #ifndef KBLOG_WORDPRESSBUGGY_H |
23 | #define KBLOG_WORDPRESSBUGGY_H |
24 | |
25 | #include <kblog/movabletype.h> |
26 | |
27 | class KUrl; |
28 | |
29 | /** |
30 | @file |
31 | This file is part of the for accessing Blog Servers |
32 | and defines the WordpressBuggy class. |
33 | |
34 | @author Christian Weilbach \<christian_weilbach\@web.de\> |
35 | */ |
36 | |
37 | namespace KBlog { |
38 | |
39 | class WordpressBuggyPrivate; |
40 | /** |
41 | @brief |
42 | A class that can be used for access to blogs (Wordpress, Drupal <5.6 |
43 | and most likely many more) which simply use the yyyyMMddThh:mm:ss |
44 | dateTime.iso8601 format stated on http://www.xmlrpc.com. This is only an example for |
45 | an ISO-8601 compatible format, but many blogs seem to assume exactly this format. |
46 | This class is needed because KXmlRpc::Client only has support for the extended |
47 | format yyyy-MM-ddThh:mm:ss which is also standard conform and makes more sense than |
48 | the mixture above. This class reimplements createPost and modifyPost from scratch |
49 | to send the dateTime in a compatible format (yyyyMMddThh:mm:ss). |
50 | |
51 | The rest of the code is inherited from MovableType, as it does not use the dateTime |
52 | format. |
53 | The name is because this problem was first discovered with Wordpress. |
54 | |
55 | @code |
56 | Blog* myblog = new WordpressBuggy("http://example.com/xmlrpc/gateway.php"); |
57 | myblog->setUsername( "some_user_id" ); |
58 | myblog->setPassword( "YoURFunnyPAsSwoRD" ); |
59 | myblog->setBlogId( "1" ); // can be caught by listBlogs() |
60 | KBlog::BlogPost *post = new BlogPost(); |
61 | post->setTitle( "This is the title." ); |
62 | post->setContent( "Here is some the content..." ); |
63 | myblog->createPost( post ); |
64 | @endcode |
65 | |
66 | @author Christian Weilbach \<christian_weilbach\@web.de\> |
67 | */ |
68 | class KBLOG_EXPORT WordpressBuggy : public MovableType |
69 | { |
70 | Q_OBJECT |
71 | public: |
72 | /** |
73 | Create an object for WordpressBuggy |
74 | @param server is the url for the xmlrpc gateway. |
75 | @param parent is the parent object. |
76 | */ |
77 | explicit WordpressBuggy( const KUrl &server, QObject *parent = 0 ); |
78 | |
79 | /** |
80 | Destroy the object. |
81 | */ |
82 | virtual ~WordpressBuggy(); |
83 | |
84 | /** |
85 | Create a new post on server. |
86 | @param post is send to the server. |
87 | */ |
88 | void createPost( KBlog::BlogPost *post ); |
89 | |
90 | /** |
91 | Modify a post on server. |
92 | @param post The post to be modified on the server. |
93 | You need to set its id correctly. |
94 | |
95 | @see BlogPost::setPostId( const QString& ) |
96 | @see modifiedPost( KBlog::BlogPost* ) |
97 | */ |
98 | void modifyPost( KBlog::BlogPost *post ); |
99 | |
100 | /** |
101 | Returns the of the inherited object. |
102 | */ |
103 | QString interfaceName() const; |
104 | |
105 | protected: |
106 | /** |
107 | Constructor needed for private inheritance. |
108 | */ |
109 | WordpressBuggy( const KUrl &server, WordpressBuggyPrivate &dd, QObject *parent = 0 ); |
110 | |
111 | private: |
112 | Q_DECLARE_PRIVATE( WordpressBuggy ) |
113 | Q_PRIVATE_SLOT( d_func(), void slotCreatePost( KJob * ) ) |
114 | Q_PRIVATE_SLOT( d_func(), void slotModifyPost( KJob * ) ) |
115 | }; |
116 | |
117 | } //namespace KBlog |
118 | #endif |
119 | |