You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
4.1 KiB
122 lines
4.1 KiB
15 years ago
|
/***************************************************************************
|
||
|
* Copyright (C) 2004-05 Reinhold Kainhofer <reinhold@kainhofer.com> *
|
||
|
* *
|
||
|
* This program is free software; you can redistribute it and/or modify *
|
||
|
* it under the terms of the GNU General Public License as published by *
|
||
|
* the Free Software Foundation; either version 2 of the License, or *
|
||
|
* (at your option) any later version. *
|
||
|
***************************************************************************/
|
||
|
#include "API_Blog.h"
|
||
|
#include <kdebug.h>
|
||
15 years ago
|
#include <tqvariant.h>
|
||
15 years ago
|
|
||
|
using namespace KBlog;
|
||
|
|
||
14 years ago
|
APIBlog::APIBlog( const KURL &url, TQObject *parent, const char *name ) :
|
||
|
TQObject( parent, name ),
|
||
14 years ago
|
mServerURL( url ), mAppID( TQString() ), mDownloadCount( 20 )
|
||
15 years ago
|
{}
|
||
|
|
||
|
APIBlog::~APIBlog()
|
||
|
{}
|
||
|
|
||
|
void APIBlog::dumpBlog( BlogPosting *blog )
|
||
|
{
|
||
|
kdDebug() << "-----------------------------------" << endl;
|
||
|
kdDebug() << "Post " << blog->postID() << " by \"" <<
|
||
|
blog->userID() << "\" on " <<
|
||
|
blog->dateTime().toString() << endl;
|
||
|
kdDebug() << "Title: " << blog->title() << endl;
|
||
|
kdDebug() << blog->content() <<endl;
|
||
|
kdDebug() << "-----------------------------------" << endl;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/*void APIBlog::setTemplateTags( const BlogTemplate& Template )
|
||
|
{
|
||
|
mTemplate = Template;
|
||
|
}
|
||
|
BlogTemplate APIBlog::templateTags() const
|
||
|
{
|
||
|
return mTemplate;
|
||
|
}*/
|
||
|
|
||
15 years ago
|
/*void APIBlog::deletePost( const TQString &postID )
|
||
15 years ago
|
{
|
||
|
BlogPosting *post = new BlogPosting();
|
||
|
post->setPostID( postID );
|
||
|
deletePost( post );
|
||
|
delete post;
|
||
|
}*/
|
||
|
|
||
15 years ago
|
TQValueList<TQVariant> APIBlog::defaultArgs( const TQString &id )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQValueList<TQVariant> args;
|
||
|
args << TQVariant( mAppID );
|
||
15 years ago
|
if ( !id.isNull() ) {
|
||
15 years ago
|
args << TQVariant( id );
|
||
15 years ago
|
}
|
||
15 years ago
|
args << TQVariant( mUsername )
|
||
|
<< TQVariant( mPassword );
|
||
15 years ago
|
return args;
|
||
|
}
|
||
|
|
||
|
|
||
|
KCal::Journal *APIBlog::journalFromPosting( KBlog::BlogPosting *blog )
|
||
|
{
|
||
|
if ( !blog ) return 0;
|
||
|
KCal::Journal *j = new KCal::Journal();
|
||
15 years ago
|
TQDateTime dt = blog->dateTime();
|
||
|
TQDateTime creationDt = blog->creationDateTime();
|
||
|
TQDateTime modificationDt = blog->modificationDateTime();
|
||
14 years ago
|
kdDebug() << "dt ="<<dt.toString( TQt::ISODate ) << endl;
|
||
|
kdDebug() << "creationDt ="<<creationDt.toString( TQt::ISODate ) << endl;
|
||
|
kdDebug() << "modificationDt="<<modificationDt.toString( TQt::ISODate ) << endl;
|
||
15 years ago
|
if ( dt.isValid() && !dt.isNull() ) {
|
||
|
j->setDtStart( dt );
|
||
|
} else if ( creationDt.isValid() && !creationDt.isNull() ) {
|
||
|
j->setDtStart( creationDt );
|
||
|
} else if ( modificationDt.isValid() && !modificationDt.isNull() ) {
|
||
|
j->setDtStart( modificationDt );
|
||
|
}
|
||
|
|
||
|
j->setCreated( blog->creationDateTime() );
|
||
|
j->setLastModified( blog->modificationDateTime() );
|
||
|
j->setFloats( false );
|
||
|
kdDebug() << "Date for blog " << blog->title() << " is "
|
||
|
<< blog->dateTime().toString()<<endl;
|
||
|
j->setSummary( blog->title() );
|
||
|
j->setDescription( blog->content() );
|
||
15 years ago
|
j->setCategories( TQStringList( blog->category() ) );
|
||
15 years ago
|
j->setOrganizer( blog->userID() );
|
||
|
j->setCustomProperty( "KCalBloggerRes", "UserID", blog->userID() );
|
||
|
j->setCustomProperty( "KCalBloggerRes", "BlogID", blog->blogID() );
|
||
|
j->setCustomProperty( "KCalBloggerRes", "PostID", blog->postID() );
|
||
|
|
||
|
// TODO: Set the read-only flag in the resource!
|
||
|
// j->setReadOnly( readOnly() );
|
||
|
|
||
|
return j;
|
||
|
}
|
||
|
|
||
|
KBlog::BlogPosting *APIBlog::postingFromJournal( KCal::Journal *journal )
|
||
|
{
|
||
|
KBlog::BlogPosting *item = new KBlog::BlogPosting();
|
||
|
if ( journal && item ) {
|
||
|
item->setContent( journal->description() );
|
||
|
item->setTitle( journal->summary() );
|
||
|
item->setCategory( journal->categories().first() );
|
||
|
item->setDateTime( journal->dtStart() );
|
||
|
item->setModificationDateTime( journal->lastModified() );
|
||
|
item->setCreationDateTime( journal->created() );
|
||
|
item->setUserID( journal->customProperty( "KCalBloggerRes", "UserID" ) );
|
||
|
item->setBlogID( journal->customProperty( "KCalBloggerRes", "BlogID" ) );
|
||
|
item->setPostID( journal->customProperty( "KCalBloggerRes", "PostID" ) );
|
||
|
}
|
||
|
return item;
|
||
|
}
|
||
|
|
||
|
|
||
|
#include "API_Blog.moc"
|