[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/kresources/blog
From: Mike Arthur <mike () mikearthur ! co ! uk>
Date: 2007-08-01 3:04:55
Message-ID: 1185937495.865707.17010.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 694907 by mikearthur:
Now working with new API changes across Drupal, LiveJoural and Wordpress.
M +60 -58 resourceblog.cpp
M +13 -24 resourceblog.h
M +28 -24 resourceblogconfig.cpp
M +3 -4 resourceblogconfig.h
--- trunk/KDE/kdepim/kresources/blog/resourceblog.cpp #694906:694907
@@ -22,7 +22,6 @@
#include <QDateTime>
#include <QString>
-#include <KDebug>
#include <KUrl>
#include <KLocale>
@@ -58,6 +57,7 @@
close();
delete mLock;
+ delete mJournalsMap;
}
void ResourceBlog::init()
@@ -69,6 +69,7 @@
setType( "blog" );
mLock = new KABC::Lock( cacheFile() );
+ mJournalsMap = new QMap<QString, Journal *>();
enableChangeNotification();
}
@@ -192,16 +193,18 @@
//FIXME Actually do something? Calculate posts for non-full reload.
if ( fullReload ) {
// TODO: downloadCount = math;
- mJournalsMap.clear();
+ mJournalsMap->clear();
ResourceCached::deleteAllJournals();
}
mAPI->setBlogId( mBlogID );
- connect ( mAPI, SIGNAL( listedPosting( KBlog::BlogPosting & ) ),
- this, SLOT( slotListedPosting( KBlog::BlogPosting & ) ) );
- connect ( mAPI, SIGNAL( listPostingsFinished() ),
- this, SLOT( slotListPostingsFinished() ));
- connect ( mAPI, SIGNAL( error( const KBlog::Blog::ErrorType &, const QString & ) ),
- this, SLOT( slotError( const KBlog::Blog::ErrorType &, const QString & ) ) );
+ connect ( mAPI, SIGNAL( listedRecentPostings(
+ const QList<KBlog::BlogPosting*> & ) ),
+ this, SLOT( slotListedPostings(
+ const QList<KBlog::BlogPosting*> & ) ) );
+ connect ( mAPI, SIGNAL( error( const KBlog::Blog::ErrorType &,
+ const QString & ) ),
+ this, SLOT( slotError( const KBlog::Blog::ErrorType &,
+ const QString & ) ) );
if ( mUseProgressManager ) {
mProgress = KPIM::ProgressManager::createProgressItem(
@@ -221,34 +224,37 @@
return false;
}
-void ResourceBlog::slotListedPosting( KBlog::BlogPosting &blogPosting )
+void ResourceBlog::slotListedPostings(
+ const QList<KBlog::BlogPosting*> &postings )
{
- kDebug( 5800 ) << "ResourceBlog::slotListedPosting()";
- Journal *journalBlog = new Journal();
- QString id = "kblog-" + mUrl.url() + "-" + mUsername + "-" +
- blogPosting.postingId();
- if ( mJournalsMap.value( id ) == 0 ) {
- connect ( mAPI, SIGNAL( createdPosting( QString & ) ),
- this, SLOT( slotCreatedPosting( QString & ) ) );
- connect ( mAPI, SIGNAL( error( const KBlog::Blog::ErrorType &, const QString & ) ),
- this, SLOT( slotError( const KBlog::Blog::ErrorType &, const QString & ) ) );
- journalBlog->setUid( id );
- journalBlog->setSummary( blogPosting.title() );
- journalBlog->setCategories( blogPosting.categories() );
- journalBlog->setDescription( blogPosting.content() );
- journalBlog->setDtStart( blogPosting.creationDateTime() );
- if ( ResourceCached::addJournal( journalBlog ) ) {
- kDebug( 5800 ) << "ResourceBlog::slotListedPosting(): Journal added"
- ;
- mJournalsMap.insert( id, journalBlog );
+ kDebug( 5800 ) << "ResourceBlog::slotListedPostings()";
+ QList<KBlog::BlogPosting*>::const_iterator i;
+ KBlog::BlogPosting* posting;
+ Journal *journalBlog;
+ for (i = postings.constBegin(); i != postings.constEnd(); ++i) {
+ posting = *i;
+ journalBlog = new Journal();
+ QString id = "kblog-" + mUrl.url() + "-" + mUsername + "-" +
+ posting->postingId();
+ if ( mJournalsMap->value( id ) == 0 ) {
+ connect ( mAPI, SIGNAL( createdPosting( QString & ) ),
+ this, SLOT( slotCreatedPosting( QString & ) ) );
+ connect ( mAPI, SIGNAL( error( const KBlog::Blog::ErrorType &,
+ const QString & ) ),
+ this, SLOT( slotError( const KBlog::Blog::ErrorType &,
+ const QString & ) ) );
+ journalBlog->setUid( id );
+ journalBlog->setSummary( posting->title() );
+ journalBlog->setCategories( posting->categories() );
+ journalBlog->setDescription( posting->content() );
+ journalBlog->setDtStart( posting->creationDateTime() );
+ if ( ResourceCached::addJournal( journalBlog ) ) {
+ kDebug( 5800 ) << "ResourceBlog::slotListedPosting(): Journal added";
+ mJournalsMap->insert( id, journalBlog );
+ }
}
}
-}
-void ResourceBlog::slotListPostingsFinished()
-{
- kDebug( 5800 ) << "ResourceBlog::slotListPostingsFinished()";
-
emit resourceChanged( this );
if ( mProgress ) {
@@ -272,13 +278,10 @@
mPostID = id.toInt();
}
-void ResourceBlog::slotBlogInfoRetrieved( const QString &id,
- const QString &name )
+void ResourceBlog::slotBlogInfoRetrieved( const QMap<QString,QString> &blogs )
{
- kDebug( 5800 ) << "ResourceBlog::slotBlogInfoRetrieved( id=" << id <<
- ", name=" << name;
- mBlogsMap.insert( name, id );
- emit signalBlogInfoRetrieved( id, name );
+ kDebug( 5800 ) << "ResourceBlog::slotBlogInfoRetrieved()" << blogs;
+ emit signalBlogInfoRetrieved( blogs );
}
bool ResourceBlog::doSave( bool )
@@ -351,8 +354,10 @@
if ( mAPI ) {
mAPI->setBlogId( mBlogID );
post->setCreationDateTime( date );
- connect ( mAPI, SIGNAL( error( const KBlog::Blog::ErrorType &, const QString & ) ),
- this, SLOT( slotError( const KBlog::Blog::ErrorType &, const QString & ) ) );
+ connect ( mAPI, SIGNAL( error( const KBlog::Blog::ErrorType &,
+ const QString & ) ),
+ this, SLOT( slotError( const KBlog::Blog::ErrorType &,
+ const QString & ) ) );
mAPI->createPosting( post );
return true;
}
@@ -361,32 +366,29 @@
}
bool ResourceBlog::fetchBlogs() {
- if ( mAPI ) {
- connect ( mAPI, SIGNAL( blogInfoRetrieved( const QString &,
- const QString & ) ),
- this, SLOT( slotBlogInfoRetrieved( const QString &,
- const QString & ) ) );
- //Check if we're using Blogger or higher
- //mAPI->listBlogs();
+ KBlog::Blogger1* blogger = qobject_cast<KBlog::Blogger1*>( mAPI );
+ if ( blogger ) {
+ connect ( blogger, SIGNAL( listedBlogs( const QMap<QString,QString> & ) ),
+ this, SLOT( slotBlogInfoRetrieved(
+ const QMap<QString,QString> & ) ) );
+ blogger->listBlogs();
return true;
}
- kError( 5800 ) << "ResourceBlog::fetchBlogs(): Journal not initialised.";
+ kError( 5800 ) << "ResourceBlog::fetchBlogs(): "
+ << "API does not support multiple blogs.";
return false;
}
-bool ResourceBlog::setBlog( const QString &name ) {
- if ( mBlogsMap.contains( name ) ) {
- mBlogID = mBlogsMap.value( name );
- mBlogName = name;
- kDebug( 5800 ) << "ResourceBlog::setBlog( id=" << mBlogID <<
- ", name=" << mBlogName;
- return true;
- }
- return false;
+void ResourceBlog::setBlog( const QString &id, const QString &name ) {
+ mBlogID = id;
+ mBlogName = name;
+ kDebug( 5800 ) << "ResourceBlog::setBlog( id=" << mBlogID <<
+ ", name=" << mBlogName << " )";
}
-QPair<QString, QString> ResourceBlog::blog() {
+QPair<QString, QString> ResourceBlog::blog() const {
return qMakePair( mBlogID, mBlogName );
}
+
#include "resourceblog.moc"
--- trunk/KDE/kdepim/kresources/blog/resourceblog.h #694906:694907
@@ -192,15 +192,15 @@
@return A pair of the blog ID and the blog name.
*/
- QPair<QString, QString> blog();
+ QPair<QString, QString> blog() const;
/**
Updates the blog to post to.
+ @param id The unique ID of the blog.
@param name The name of the blog.
- @return Returns if index of the blog was found from the name.
*/
- bool setBlog( const QString &name );
+ void setBlog( const QString &id, const QString &name );
// Posts cannot be deleted from the server.
bool deleteJournal( Journal *journal )
@@ -245,27 +245,22 @@
Q_SIGNALS:
/**
- Signals an available blog to post to.
+ Signals an available blog(s) to post to.
- @param id The unique ID of the blog.
- @param name The name of the blog.
+ @param blogs A map containing the blogs' ID and description.
*/
- void signalBlogInfoRetrieved( const QString &id, const QString &name );
+ void signalBlogInfoRetrieved( const QMap<QString,QString> &blogs );
protected Q_SLOTS:
/**
- Converts a listed posting to a journal and adds to the cached resource.
+ Converts listed postings to journal entries and adds them to the cached
+ resource.
- @param blogPosting A posting from the blog.
+ @param postings A list of the postings from the blog.
*/
- void slotListedPosting( KBlog::BlogPosting &blogPosting );
+ void slotListedPostings( const QList<KBlog::BlogPosting*> &postings );
/**
- Cleans up after the posting's listing completed.
- */
- void slotListPostingsFinished();
-
- /**
Prints an error on a XML-RPC failure.
@param type The type of the error.
@@ -285,10 +280,9 @@
/**
Updates the local list of available blogs to post to.
- @param id The unique ID of the blog.
- @param name The name of the blog.
+ @param blogs A map containing the blogs' ID and description.
*/
- void slotBlogInfoRetrieved( const QString &id, const QString &name );
+ void slotBlogInfoRetrieved( const QMap<QString,QString> &blogs );
protected:
/**
@@ -354,14 +348,9 @@
/**
The map of created journal objects.
*/
- QHash<QString, Journal *> mJournalsMap;
+ QMap<QString, Journal *> *mJournalsMap;
/**
- The map of possible blogs to post to.
- */
- QHash<QString, QString> mBlogsMap;
-
- /**
Whether the progress of operations are displayed.
*/
bool mUseProgressManager;
--- trunk/KDE/kdepim/kresources/blog/resourceblogconfig.cpp #694906:694907
@@ -22,12 +22,11 @@
#include <QLabel>
#include <QGridLayout>
-#include <klocale.h>
-#include <kdebug.h>
-#include <kdialog.h>
-#include <kurlrequester.h>
-#include <klineedit.h>
-#include <kcombobox.h>
+#include <KLocale>
+#include <KDialog>
+#include <KUrlRequester>
+#include <KLineEdit>
+#include <KComboBox>
#include <kcal/resourcecachedconfig.h>
@@ -115,7 +114,8 @@
resource->setAPI( mAPI->currentText() );
QPair<QString, QString> blog = resource->blog();
if ( !mBlogs->currentText().isEmpty() ) {
- resource->setBlog( mBlogs->currentText() );
+ resource->setBlog( mBlogs->itemData( mBlogs->currentIndex() ).toString(),
+ mBlogs->currentText() );
}
mReloadConfig->saveSettings( resource );
kDebug( 5700 ) << "ResourceBlogConfig::saveSettings(): saved";
@@ -125,13 +125,15 @@
}
}
-void ResourceBlogConfig::slotBlogInfoRetrieved( const QString &id,
- const QString &name )
+void ResourceBlogConfig::slotBlogInfoRetrieved(
+ const QMap<QString, QString> &blogs )
{
- kDebug( 5700 ) << "ResourceBlogConfig::slotBlogInfoRetrieved( id=" << id <<
- ", name=" << name;
- if ( !mBlogs->contains( name ) ) {
- mBlogs->addItem( name );
+ kDebug( 5700 ) << "ResourceBlogConfig::slotBlogInfoRetrieved()";
+ QMap<QString,QString>::const_iterator i;
+ for (i = blogs.constBegin(); i != blogs.constEnd(); ++i) {
+ mBlogs->addItem( i.value(), i.key() );
+ }
+ if ( mBlogs->count() ) {
mBlogs->setEnabled( true );
}
}
@@ -139,17 +141,19 @@
void ResourceBlogConfig::slotBlogAPIChanged( int index )
{
kDebug( 5700 ) << "ResourceBlogConfig::slotBlogAPIChanged";
- if ( !mBlogs->count() ) {
- // TODO Delete
- ResourceBlog *blog = new ResourceBlog();
- blog->setUrl( mUrl->url() );
- blog->setUsername( mUsername->text() );
- blog->setPassword( mPassword->text() );
- blog->setAPI( mAPI->itemText( index ) );
- connect ( blog, SIGNAL( signalBlogInfoRetrieved( const QString &, const QString & ) ),
- this, SLOT( slotBlogInfoRetrieved( const QString &, const QString & ) ) );
- blog->fetchBlogs();
- }
+ //FIXME Delete me somehow?
+ ResourceBlog *blog = new ResourceBlog();
+ blog->setUrl( mUrl->url() );
+ blog->setUsername( mUsername->text() );
+ blog->setPassword( mPassword->text() );
+ blog->setAPI( mAPI->itemText( index ) );
+ connect ( blog, SIGNAL( signalBlogInfoRetrieved(
+ const QMap<QString,QString> & ) ),
+ this, SLOT( slotBlogInfoRetrieved(
+ const QMap<QString,QString> & ) ) );
+ blog->fetchBlogs();
+ mBlogs->clear();
+ mBlogs->setEnabled( false );
}
#include "resourceblogconfig.moc"
--- trunk/KDE/kdepim/kresources/blog/resourceblogconfig.h #694906:694907
@@ -21,8 +21,8 @@
#ifndef KCAL_RESOURCEBLOGCONFIG_H
#define KCAL_RESOURCEBLOGCONFIG_H
-#include <kresources/resource.h>
#include <kresources/configwidget.h>
+
#include "blog_export.h"
#include "resourceblog.h"
@@ -70,10 +70,9 @@
/**
Saves the entered settings from the widget to the blog resource.
- @param id The unique ID for the blog to post to.
- @param name The name for the blog to post to.
+ @param blogs A map containing the blogs' ID and description.
*/
- void slotBlogInfoRetrieved( const QString &id, const QString &name );
+ void slotBlogInfoRetrieved( const QMap<QString,QString> &blogs );
/**
Performs operations on an API change.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic