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#include "blog.h"
25#include "blog_p.h"
26#include "blogpost_p.h"
27
28#include <kdeversion.h>
29
30#include <KDebug>
31
32using namespace KBlog;
33
34Blog::Blog( const KUrl &server, QObject *parent, const QString &applicationName,
35 const QString &applicationVersion ) :
36 QObject( parent ), d_ptr( new BlogPrivate )
37{
38 Q_UNUSED( server );
39 d_ptr->q_ptr = this;
40 setUserAgent( applicationName, applicationVersion );
41}
42
43Blog::Blog( const KUrl &server, BlogPrivate &dd, QObject *parent,
44 const QString &applicationName, const QString &applicationVersion )
45 : QObject( parent ), d_ptr( &dd )
46{
47 Q_UNUSED( server );
48 d_ptr->q_ptr = this;
49 setUserAgent( applicationName, applicationVersion );
50}
51
52Blog::~Blog()
53{
54 kDebug() << "~Blog()";
55 delete d_ptr;
56}
57
58QString Blog::userAgent() const
59{
60 Q_D( const Blog );
61 return d->mUserAgent;
62}
63
64void Blog::setUserAgent( const QString &applicationName,
65 const QString &applicationVersion )
66{
67 Q_D( Blog );
68 QString userAgent;
69 if ( !applicationName.isEmpty() &&
70 !applicationVersion.isEmpty() ) {
71 userAgent = QLatin1Char('(') + applicationName + QLatin1Char('/') + applicationVersion + QLatin1String(") KDE-KBlog/");
72 } else {
73 userAgent = QLatin1String("KDE-KBlog/");
74 }
75 userAgent += QLatin1String(KDE_VERSION_STRING);
76 d->mUserAgent = userAgent;
77}
78
79void Blog::setPassword( const QString &pass )
80{
81 Q_D( Blog );
82 d->mPassword = pass;
83}
84
85QString Blog::password() const
86{
87 Q_D( const Blog );
88 return d->mPassword;
89}
90
91QString Blog::username() const
92{
93 Q_D( const Blog );
94 return d->mUsername;
95}
96
97void Blog::setUsername( const QString &username )
98{
99 Q_D( Blog );
100 d->mUsername = username;
101}
102
103void Blog::setBlogId( const QString &blogId )
104{
105 Q_D( Blog );
106 d->mBlogId = blogId;
107}
108
109QString Blog::blogId() const
110{
111 Q_D( const Blog );
112 return d->mBlogId;
113}
114
115void Blog::setUrl( const KUrl &url )
116{
117 Q_D( Blog );
118 d->mUrl = url;
119}
120
121KUrl Blog::url() const
122{
123 Q_D( const Blog );
124 return d->mUrl;
125}
126
127void Blog::setTimeZone( const KTimeZone &tz )
128{
129 Q_D( Blog );
130 d->mTimeZone = tz;
131}
132
133KTimeZone Blog::timeZone()
134{
135 Q_D( const Blog );
136 return d->mTimeZone;
137}
138
139BlogPrivate::BlogPrivate() : q_ptr(0)
140{
141}
142
143BlogPrivate::~BlogPrivate()
144{
145 kDebug() << "~BlogPrivate()";
146}
147