[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/krss
From: Frank Osterfeld <frank.osterfeld () kdemail ! net>
Date: 2009-06-22 17:40:46
Message-ID: 1245692446.624138.11097.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 985382 by osterfeld:
improve error reporting for addFeed, move private slots to Private
M +32 -25 libkrss/netfeedcreatejob.cpp
M +8 -10 libkrss/netfeedcreatejob.h
M +3 -1 resources/libkrssresource/org.kde.krss.xml
M +14 -11 resources/libkrssresource/rssresourcebase.cpp
M +1 -1 resources/libkrssresource/rssresourcebase.h
--- trunk/playground/pim/krss/libkrss/netfeedcreatejob.cpp #985381:985382
@@ -25,27 +25,33 @@
namespace KRss {
-class NetFeedCreateJobPrivate
+class NetFeedCreateJob::Private
{
+ NetFeedCreateJob* const q;
public:
-
- explicit NetFeedCreateJobPrivate( const QString &xmlUrl, const QString \
&subscriptionLabel,
- const QString &resourceIdentifier )
- : m_xmlUrl( xmlUrl ), m_subscriptionLabel( subscriptionLabel ),
- m_resourceIdentifier( resourceIdentifier )
+ explicit Private( const QString &xmlUrl,
+ const QString &subscriptionLabel,
+ const QString &resourceIdentifier,
+ NetFeedCreateJob* qq )
+ : q( qq ), m_xmlUrl( xmlUrl ), m_subscriptionLabel( subscriptionLabel ),
+ m_resourceIdentifier( resourceIdentifier ), id(0)
{
}
+ void doStart();
+ void slotCallFinished( const QVariantMap& );
+
const QString m_xmlUrl;
const QString m_subscriptionLabel;
const QString m_resourceIdentifier;
+ Feed::Id id;
};
} // namespace KRss
NetFeedCreateJob::NetFeedCreateJob( const QString &xmlUrl, const QString \
&subscriptionLabel,
const QString &resourceIdentifier, QObject \
*parent ) :
- KJob( parent ), d( new NetFeedCreateJobPrivate( xmlUrl, subscriptionLabel, \
resourceIdentifier ) ) + KJob( parent ), d( new Private( xmlUrl, \
subscriptionLabel, resourceIdentifier, this ) ) {
}
@@ -72,34 +78,35 @@
return QString();
}
-void NetFeedCreateJob::doStart()
+void NetFeedCreateJob::Private::doStart()
{
- org::kde::krss *interface = new org::kde::krss( "org.freedesktop.Akonadi.Agent." \
+ d->m_resourceIdentifier, "/KRss",
- QDBusConnection::sessionBus(), \
this ); + org::kde::krss *interface = new org::kde::krss( \
"org.freedesktop.Akonadi.Agent." + m_resourceIdentifier, "/KRss", + \
QDBusConnection::sessionBus(), q );
// don't block, set callbacks instead
QList<QVariant> argumentList;
- argumentList << qVariantFromValue( d->m_xmlUrl ) << qVariantFromValue( \
d->m_subscriptionLabel ); + argumentList << qVariantFromValue( m_xmlUrl ) << \
qVariantFromValue( m_subscriptionLabel );
if ( !interface->callWithCallback( QLatin1String( "addFeed" ), argumentList,
- this, SLOT( slotCallFinished( qlonglong ) ), SLOT( \
slotCallFailed() ) ) ) {
- setError( DBusCallQueueingFailed );
- setErrorText( "Failed to place a D-Bus call");
- emitResult();
+ q, SLOT( slotCallFinished(QVariantMap) ) ) ) {
+ q->setError( DBusCallQueueingFailed );
+ q->setErrorText( "Failed to place a D-Bus call");
+ q->emitResult();
}
}
-void NetFeedCreateJob::slotCallFinished( qlonglong id )
+void NetFeedCreateJob::Private::slotCallFinished( const QVariantMap& res )
{
- kDebug() << "D-Bus call returned:" << id;
-
- emitResult();
+ const int error = res.value( "error" ).toInt();
+ if ( error ) {
+ const QString errorString = res.value( "errorString" ).toString();
+ q->setError( FeedCreationFailed );
+ q->setErrorText( errorString );
+ q->emitResult();
+ return;
+ }
+ id = res.value( "feedId" ).toLongLong();
+ q->emitResult();
}
-void NetFeedCreateJob::slotCallFailed()
-{
- setError( FeedCreationFailed );
- setErrorText( "Failed to add a new feed to the resource" );
- emitResult();
-}
#include "netfeedcreatejob.moc"
--- trunk/playground/pim/krss/libkrss/netfeedcreatejob.h #985381:985382
@@ -19,13 +19,14 @@
#define KRSS_NETFEEDCREATEJOB_H
#include "krss_export.h"
+#include "feed.h"
#include <KJob>
+#include <QVariantMap>
+
namespace KRss {
-class NetFeedCreateJobPrivate;
-
class KRSS_EXPORT NetFeedCreateJob : public KJob
{
Q_OBJECT
@@ -45,16 +46,13 @@
void start();
QString errorString() const;
+ Feed::Id feedId() const;
-private Q_SLOTS:
-
- void doStart();
- void slotCallFinished( qlonglong id );
- void slotCallFailed();
-
private:
-
- NetFeedCreateJobPrivate * const d;
+ class Private;
+ Private * const d;
+ Q_PRIVATE_SLOT( d, void doStart() )
+ Q_PRIVATE_SLOT( d, void slotCallFinished( const QVariantMap& ) )
};
} // namespace KRss
--- trunk/playground/pim/krss/resources/libkrssresource/org.kde.krss.xml \
#985381:985382 @@ -23,7 +23,9 @@
<signal name="fetchQueueFinished">
</signal>
<method name="addFeed">
- <arg type="x" direction="out"/>
+ <arg type="a{sv}" direction="out">
+ <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" \
value="QVariantMap"/> + </arg>
<arg name="xmlUrl" type="s" direction="in"/>
<arg name="subscriptionLabel" type="s" direction="in"/>
</method>
--- trunk/playground/pim/krss/resources/libkrssresource/rssresourcebase.cpp \
#985381:985382 @@ -140,12 +140,15 @@
changeCommitted( item );
}
-KRss::Feed::Id RssResourceBase::addFeed( const QString &xmlUrl, const QString \
&subscriptionLabel ) +QVariantMap RssResourceBase::addFeed( const QString &xmlUrl, \
const QString &subscriptionLabel ) {
FeedCreateJob * const backendJob = feedCreateJob();
if ( !backendJob ) {
emit warning( i18n( "Creating a feed: not implemented" ) );
- return KRss::Feed::Id();
+ QVariantMap res;
+ res.insert( QLatin1String("errorString"),
+ i18n( "Creating a feed: not implemented" ) );
+ return res;
}
FeedCollectionCreateJob * const job = new FeedCollectionCreateJob( xmlUrl, this \
); @@ -157,7 +160,7 @@
// send the reply later
setDelayedReply( true );
d->m_replies.insert( job, QDBusContext::message().createReply() );
- return KRss::Feed::Id();
+ return QVariantMap();
}
void RssResourceBase::fetchFeed( const KRss::Feed::Id& id )
@@ -422,18 +425,18 @@
// return the remote id to the caller
Q_ASSERT( d->m_replies.contains( job ) );
QDBusMessage replyMessage = d->m_replies.take( job );
-
+ QVariantMap res;
if ( job->error() ) {
- kWarning() << "Failed to create a new feed";
- kWarning() << job->errorString();
- replyMessage << Feed::Id();
- }
- else {
+ kWarning() << "Failed to create a new feed: "<< job->errorString();
+ res.insert( "feedId", Feed::Id() );
+ res.insert( "errorString", job->errorString() );
+ res.insert( "error", job->error() );
+ } else {
const FeedCollectionCreateJob * const cjob = qobject_cast<const \
FeedCollectionCreateJob*>( job ); Q_ASSERT( cjob );
- replyMessage << cjob->feedCollection().id();
+ res.insert( "feedId", cjob->feedCollection().id() );
}
-
+ replyMessage << res;
QDBusConnection::sessionBus().send( replyMessage );
}
--- trunk/playground/pim/krss/resources/libkrssresource/rssresourcebase.h \
#985381:985382 @@ -60,7 +60,7 @@
void configure( WId windowId );
// D-Bus interface
- KRss::Feed::Id addFeed( const QString& xmlUrl, const QString& subscriptionLabel \
); + QVariantMap addFeed( const QString& xmlUrl, const QString& subscriptionLabel \
); void fetchFeed( const KRss::Feed::Id& id );
void abortFetch( const KRss::Feed::Id& id );
bool removeFeed( const KRss::Feed::Id& id );
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic