[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdepim/akonadi/resources
From: Volker Krause <volker.krause () rwth-aachen ! de>
Date: 2006-09-27 18:19:42
Message-ID: 1159381182.168869.29680.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 589191 by vkrause:
Use a delayed D-Bus reply for requestItemDelivery().
Unfortunately this requires a hand-edited adaptor :-(
M +3 -1 include/resource.h
M +13 -0 include/resourcebase.h
M +9 -20 src/ical/icalresource.cpp
M +3 -4 src/ical/icalresource.h
M +1 -1 src/knut/knutresource.cpp
M +1 -1 src/knut/knutresource.h
M +1 -1 src/lib/CMakeLists.txt
A src/lib/resourceadaptor.cpp [License: GENERATED FILE]
A src/lib/resourceadaptor.h [License: GENERATED FILE]
M +27 -0 src/lib/resourcebase.cpp
--- trunk/KDE/kdepim/akonadi/resources/include/resource.h #589190:589191
@@ -26,6 +26,8 @@
#include <kdepim_export.h>
+class QDBusMessage;
+
namespace PIM {
/**
@@ -89,7 +91,7 @@
* @param type The type of the data that shall be put, either a full object or
* just a lightweight version.
*/
- virtual bool requestItemDelivery( const QString & uid, const QString &remoteId, \
const QString & collection, int type ) = 0; + virtual bool requestItemDelivery( \
const QString & uid, const QString &remoteId, const QString & collection, int type, \
const QDBusMessage& msg ) = 0;
/**
* This method is called whenever the resource shall show its configuration \
dialog
--- trunk/KDE/kdepim/akonadi/resources/include/resourcebase.h #589190:589191
@@ -32,6 +32,7 @@
namespace PIM {
+class Job;
class JobQueue;
/**
@@ -239,9 +240,21 @@
*/
JobQueue* queue();
+ /**
+ Call this method from in requestItemDelivery(). It will generate an \
appropriate + D-Bus reply as soon as the given job has finished.
+ @param job The job which actually delivers the item.
+ @param msg The D-Bus message requesting the delivery.
+ */
+ bool deliverItem( PIM::Job* job, const QDBusMessage &msg );
+
private:
static QString parseArguments( int, char** );
+ private slots:
+ void slotDeliveryDone( PIM::Job* job );
+
+ private:
class Private;
Private* const d;
};
--- trunk/KDE/kdepim/akonadi/resources/src/ical/icalresource.cpp #589190:589191
@@ -32,6 +32,7 @@
#include <klocale.h>
#include <QDebug>
+#include <QDBusConnection>
using namespace PIM;
using namespace KCal;
@@ -51,36 +52,24 @@
delete mCalendar;
}
-void ICalResource::done( PIM::Job * job )
-{
- if ( job->error() ) {
- error( "Error while creating item: " + job->errorText() );
- } else {
- qDebug() << "Done!";
- }
- job->deleteLater();
-}
-
void PIM::ICalResource::setParameters(const QByteArray &path, const QByteArray \
&filename, const QByteArray &mimetype ) {
}
-bool ICalResource::requestItemDelivery( const QString & uid, const QString \
&remoteId, const QString & collection, int type ) +bool \
ICalResource::requestItemDelivery( const QString & uid, const QString &remoteId, \
const QString & collection, int type, const QDBusMessage &msg ) {
Incidence *incidence = mCalendar->incidence( remoteId );
if ( !incidence ) {
error( QString("Incidence with uid '%1' not found!").arg( remoteId ) );
return false;
- }
+ } else {
+ ICalFormat format;
+ QByteArray data = format.toString( incidence ).toUtf8();
- ICalFormat format;
- QByteArray data = format.toString( incidence ).toUtf8();
-
- ItemStoreJob *job = new ItemStoreJob( DataReference( uid, remoteId ), queue() );
- job->setData( data );
- connect( job, SIGNAL(done(PIM::Job*)), SLOT(done(PIM::Job*)) );
-
- return true;
+ ItemStoreJob *job = new ItemStoreJob( DataReference( uid, remoteId ), queue() );
+ job->setData( data );
+ return deliverItem( job, msg );
+ }
}
void PIM::ICalResource::synchronize()
--- trunk/KDE/kdepim/akonadi/resources/src/ical/icalresource.h #589190:589191
@@ -21,6 +21,7 @@
#define MAILDIR_H
#include <resourcebase.h>
+#include <QDBusMessage>
namespace KCal {
class CalendarLocal;
@@ -33,6 +34,7 @@
class ICalResource : public ResourceBase
{
Q_OBJECT
+
public:
ICalResource( const QString &id );
~ICalResource();
@@ -40,15 +42,12 @@
void setParameters(const QByteArray &path, const QByteArray &filename, const \
QByteArray &mimetype );
public Q_SLOTS:
- virtual bool requestItemDelivery( const QString & uid,const QString &remoteId, \
const QString & collection, int type ); + virtual bool requestItemDelivery( const \
QString & uid,const QString &remoteId, const QString & collection, int type, const \
QDBusMessage &msg ); virtual void synchronize();
protected:
virtual void aboutToQuit();
- private Q_SLOTS:
- void done(PIM::Job* job);
-
private:
KCal::CalendarLocal *mCalendar;
--- trunk/KDE/kdepim/akonadi/resources/src/knut/knutresource.cpp #589190:589191
@@ -70,7 +70,7 @@
mSyncTimer->start( 2000 );
}
-bool KnutResource::requestItemDelivery( const QString&, const QString&, const \
QString&, int ) +bool KnutResource::requestItemDelivery( const QString&, const \
QString&, const QString&, int, const QDBusMessage& ) {
return false;
}
--- trunk/KDE/kdepim/akonadi/resources/src/knut/knutresource.h #589190:589191
@@ -35,7 +35,7 @@
~KnutResource();
public Q_SLOTS:
- virtual bool requestItemDelivery( const QString&, const QString&, const \
QString&, int ); + virtual bool requestItemDelivery( const QString&, const \
QString&, const QString&, int, const QDBusMessage& );
virtual void configure();
virtual bool setConfiguration( const QString& );
--- trunk/KDE/kdepim/akonadi/resources/src/lib/CMakeLists.txt #589190:589191
@@ -15,13 +15,13 @@
)
set( akonadiresources_automoc_LIB_SRC
+ resourceadaptor.cpp
)
set( akonadiresources_manualmoc_LIB_SRC
../../include/resource.h
../../include/resourcebase.h
)
-qt4_add_dbus_adaptor( akonadiresources_automoc_LIB_SRC \
../../include/org.kde.Akonadi.Resource.xml resourcebase.h PIM::Resource ) \
qt4_add_dbus_interfaces( akonadiresources_automoc_LIB_SRC \
../../../server/interfaces/org.kde.Akonadi.Tracer.xml )
qt4_wrap_cpp(akonadiresources_LIB_SRC ${akonadiresources_manualmoc_LIB_SRC})
--- trunk/KDE/kdepim/akonadi/resources/src/lib/resourcebase.cpp #589190:589191
@@ -20,8 +20,10 @@
*/
#include <QtCore/QDir>
+#include <QtCore/QHash>
#include <QtCore/QTimer>
#include <QtGui/QApplication>
+#include <QtDBus/QtDBus>
#include <signal.h>
#include <stdlib.h>
@@ -33,6 +35,8 @@
#include "tracerinterface.h"
+#include <libakonadi/job.h>
+
using namespace PIM;
static ResourceBase *sResourceBase = 0;
@@ -73,6 +77,7 @@
QSettings *mSettings;
JobQueue *queue;
+ QHash<PIM::Job*,QDBusMessage> pendingReplys;
};
QString ResourceBase::Private::defaultReadyMessage() const
@@ -318,3 +323,25 @@
{
return d->queue;
}
+
+bool PIM::ResourceBase::deliverItem(PIM::Job * job, const QDBusMessage & msg)
+{
+ msg.setDelayedReply( true );
+ d->pendingReplys.insert( job, msg.createReply() );
+ connect( job, SIGNAL(done(PIM::Job*)), SLOT(slotDeliveryDone(PIM::Job*)) );
+ return false;
+}
+
+void PIM::ResourceBase::slotDeliveryDone(PIM::Job * job)
+{
+ Q_ASSERT( d->pendingReplys.contains( job ) );
+ QDBusMessage reply = d->pendingReplys.take( job );
+ if ( job->error() ) {
+ error( "Error while creating item: " + job->errorText() );
+ reply << false;
+ } else {
+ reply << true;
+ }
+ QDBusConnection::sessionBus().send( reply );
+ job->deleteLater();
+}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic