1 | /* |
2 | This file is part of the kblog library. |
3 | |
4 | Copyright (c) 2006-2007 Christian Weilbach <christian_weilbach@web.de> |
5 | Copyright (c) 2007 Mike McQuaid <mike@mikemcquaid.com> |
6 | |
7 | This library is free software; you can redistribute it and/or |
8 | modify it under the terms of the GNU Library General Public |
9 | License as published by the Free Software Foundation; either |
10 | version 2 of the License, or (at your option) any later version. |
11 | |
12 | This library is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | Library General Public License for more details. |
16 | |
17 | You should have received a copy of the GNU Library General Public License |
18 | along with this library; see the file COPYING.LIB. If not, write to |
19 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 | Boston, MA 02110-1301, USA. |
21 | */ |
22 | |
23 | #ifndef KBLOG_BLOGMEDIA_H |
24 | #define KBLOG_BLOGMEDIA_H |
25 | |
26 | #include <kblog/kblog_export.h> |
27 | |
28 | #include <QtCore/QtAlgorithms> |
29 | |
30 | class KUrl; |
31 | |
32 | namespace KBlog { |
33 | |
34 | class BlogMediaPrivate; |
35 | |
36 | /** |
37 | @brief |
38 | A class that represents a media object on the server. |
39 | |
40 | @code |
41 | KBlog::BlogMedia *media = new BlogMedia(); |
42 | post->setMimetype( "some_mimetype" ); |
43 | post->setData( some_qbytestream ); |
44 | @endcode |
45 | |
46 | @author Christian Weilbach \<christian_weilbach\@web.de\> |
47 | */ |
48 | class KBLOG_EXPORT BlogMedia |
49 | { |
50 | |
51 | public: |
52 | /** |
53 | Default constructor. Creates an empty BlogMedia object. |
54 | */ |
55 | explicit BlogMedia(); |
56 | |
57 | /** |
58 | Copy Constructor needed for list handling. |
59 | */ |
60 | BlogMedia( const BlogMedia &media ); |
61 | |
62 | /** |
63 | Virtual default destructor. |
64 | */ |
65 | virtual ~BlogMedia(); |
66 | |
67 | /** |
68 | Returns the wished name. This is most likely the filename on the server side |
69 | (at least with wordpress). |
70 | |
71 | @return The wished name on the server. |
72 | @see setName( const QString& ) |
73 | */ |
74 | QString name() const; |
75 | |
76 | /** |
77 | Sets the name. This will most likely be the filename on the server side |
78 | (at least with wordpress). |
79 | @param name The whished name for the object. |
80 | |
81 | @see name() |
82 | */ |
83 | void setName( const QString &name ); |
84 | |
85 | /** |
86 | Returns the server side url. |
87 | |
88 | @return The url on the server. |
89 | @see setUrl( const KUrl& ) |
90 | */ |
91 | KUrl url() const; |
92 | |
93 | /** |
94 | Sets the url of the server side object. Note: You should *not* set this |
95 | on your own normally. It is used internally in MetaWeblog. |
96 | @param url The whished name for the object. |
97 | |
98 | @see url() |
99 | */ |
100 | void setUrl( const KUrl &url ); |
101 | |
102 | /** |
103 | Returns the mimetype. |
104 | |
105 | @return The mimetype of the object |
106 | @see setMimetype( const QString& ) |
107 | */ |
108 | QString mimetype() const; |
109 | |
110 | /** |
111 | Set the mimtype. |
112 | @param mimetype This is the mimetype. |
113 | |
114 | @see mimetype() |
115 | */ |
116 | void setMimetype( const QString &mimetype ); |
117 | |
118 | /** |
119 | Returns the data of the file. |
120 | @return The data. |
121 | |
122 | @see setData( const QByteArray& ) |
123 | */ |
124 | QByteArray data() const; |
125 | |
126 | /** |
127 | Set the data of the file. |
128 | @param data This is the data stream. |
129 | |
130 | @see data() |
131 | */ |
132 | void setData( const QByteArray &data ); |
133 | |
134 | /** |
135 | The different possible status. At the moment you cannot do |
136 | much with media objects. |
137 | */ |
138 | enum Status { |
139 | /** Status of freshly constructed media object on the client side. */ |
140 | New, |
141 | /** Status of a media object successfully created on the server. */ |
142 | Created, |
143 | /** Status when an error on uploading has occurred. */ |
144 | Error |
145 | }; |
146 | |
147 | /** |
148 | Returns the status. |
149 | @return This is the status. |
150 | |
151 | @see setStatus( Status ) |
152 | */ |
153 | Status status() const; |
154 | |
155 | /** |
156 | Set the status. Note: You should *not* set this on your own |
157 | it is used mostly internally. |
158 | @param status This is the status. |
159 | |
160 | @see status() |
161 | */ |
162 | void setStatus( Status status ); |
163 | |
164 | /** |
165 | Returns the error string. |
166 | @return The error string. |
167 | @see setError( const QString& ) |
168 | */ |
169 | QString error() const; |
170 | |
171 | /** |
172 | Set the error of the object. |
173 | @param error This is the error string. |
174 | |
175 | @see error() |
176 | */ |
177 | void setError( const QString &error ); |
178 | |
179 | /** |
180 | Overloaded for QList handling. |
181 | @param media The media file to copy. |
182 | */ |
183 | BlogMedia &operator=( const BlogMedia &media ); |
184 | |
185 | /** |
186 | The swap operator. |
187 | */ |
188 | void swap( BlogMedia &other ) { |
189 | qSwap( this->d_ptr, other.d_ptr ); |
190 | } |
191 | |
192 | private: |
193 | BlogMediaPrivate *d_ptr; //krazy:exclude=dpointer can't constify due to bic and swap being declared inline |
194 | }; |
195 | |
196 | } //namespace KBlog |
197 | |
198 | #endif |
199 | |