- share the custom D-Bus type code between KMail and the resources

- rename kmail_util.h to actually reflect its content
- a{ays} is apparently not supported, so let's try a(ays) instead, we
  don't really need a map here anyway
- prepare the Kolab resource to use the generated interface instead
  doing manual calls

svn path=/trunk/KDE/kdepim/; revision=785303
wilder-work
Volker Krause 18 years ago
parent aad0caae12
commit f162ce751a
  1. 1
      CMakeLists.txt
  2. 81
      groupware_types.cpp
  3. 39
      groupware_types.h
  4. 24
      kmailicalifaceimpl.cpp
  5. 6
      kmailicalifaceimpl.h
  6. 6
      kmkernel.cpp
  7. 8
      org.kde.kmail.groupware.xml
  8. 6
      tests/dbustest.cpp

@ -226,6 +226,7 @@ set(kmailprivate_LIB_SRCS
scalix.cpp
messageactions.cpp
statusbarlabel.cpp
groupware_types.cpp
)
qt4_add_dbus_adaptor( kmailprivate_LIB_SRCS ${CMAKE_BINARY_DIR}/kmail/org.kde.kmail.kmail.xml kmkernel.h KMKernel )

@ -0,0 +1,81 @@
/*
Copyright (c) 2007 Montel Laurent <montel@kde.org>
Copyright (c) 2008 Volker Krause <vkrause@kde.org>
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.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "groupware_types.h"
#include <QDBusArgument>
#include <QDBusMetaType>
const QDBusArgument &operator<<(QDBusArgument &arg, const KMail::SubResource &subResource)
{
arg.beginStructure();
arg << subResource.location << subResource.label << subResource.writable << subResource.alarmRelevant;
arg.endStructure();
return arg;
}
const QDBusArgument &operator>>(const QDBusArgument &arg, KMail::SubResource &subResource)
{
arg.beginStructure();
arg >> subResource.location >> subResource.label >> subResource.writable >> subResource.alarmRelevant;
arg.endStructure();
return arg;
}
const QDBusArgument &operator<<(QDBusArgument &arg, const KMail::StorageFormat &format)
{
arg.beginStructure();
qint32 i = format;
arg << i;
arg.endStructure();
return arg;
}
const QDBusArgument &operator>>(const QDBusArgument &arg, KMail::StorageFormat &format)
{
arg.beginStructure();
arg >> format;
arg.endStructure();
return arg;
}
const QDBusArgument &operator<<( QDBusArgument &arg, const KMail::CustomHeader &header )
{
arg.beginStructure();
arg << header.name << header.value;
arg.endStructure();
return arg;
}
const QDBusArgument &operator>>( const QDBusArgument &arg, KMail::CustomHeader &header )
{
arg.beginStructure();
arg >> header.name >> header.value;
arg.endStructure();
return arg;
}
void KMail::registerGroupwareTypes()
{
qDBusRegisterMetaType< KMail::SubResource >();
qDBusRegisterMetaType< KMail::SubResource::List >();
qDBusRegisterMetaType< QMap<quint32,QString> >();
qDBusRegisterMetaType< KMail::CustomHeader >();
qDBusRegisterMetaType< KMail::CustomHeader::List >();
}

@ -27,12 +27,16 @@
* you do not wish to do so, delete this exception statement from
* your version.
*/
#ifndef KMAILUTILS_H
#define KMAILUTILS_H
#ifndef KMAIL_GROUPWARETYPES_H
#define KMAIL_GROUPWARETYPES_H
#include <QMetaType>
#define DBUS_KMAIL "org.kde.kmail"
#define KMAIL_DBUS_SERVICE "org.kde.kmail"
#define KMAIL_DBUS_GROUPWARE_PATH "/Groupware"
#define KMAIL_DBUS_GROUPWARE_INTERFACE "org.kde.kmail.groupware"
namespace KMail {
struct SubResource {
@ -46,6 +50,8 @@ namespace KMail {
QString label; // shown to the user
bool writable;
bool alarmRelevant;
typedef QList<SubResource> List;
};
/// The format of the mails containing other contents than actual mail
@ -57,14 +63,33 @@ namespace KMail {
/// This bitfield indicates which changes have been made in a folder, at syncing time.
enum FolderChanges { NoChange = 0, ContentsChanged = 1, ACLChanged = 2 };
/** Custom header structure, consisting of the header name and value. */
struct CustomHeader
{
CustomHeader() {}
CustomHeader( const QByteArray &n, const QString &v ) :
name( n ), value( v ) {}
QByteArray name;
QString value;
typedef QList<CustomHeader> List;
};
/**
Register D-Bus types.
*/
void registerGroupwareTypes();
}
typedef QMap<quint32, QString> Quint32QStringMap;
Q_DECLARE_METATYPE( KMail::SubResource )
Q_DECLARE_METATYPE( QList<KMail::SubResource> )
Q_DECLARE_METATYPE( KMail::SubResource::List )
Q_DECLARE_METATYPE( KMail::StorageFormat )
typedef QMap<quint32, QString> Quint32QStringMap;
Q_DECLARE_METATYPE( Quint32QStringMap )
typedef QMap<QByteArray, QString> QByteArrayStringMap;
Q_DECLARE_METATYPE( QByteArrayStringMap)
Q_DECLARE_METATYPE( KMail::CustomHeader )
Q_DECLARE_METATYPE( KMail::CustomHeader::List )
#endif

@ -140,6 +140,7 @@ ExtraFolder::~ExtraFolder()
folder->close("kmailicaliface::extrafolder");
}
#if 0
const QDBusArgument &operator<<(QDBusArgument &arg, const SubResource &subResource)
{
arg.beginStructure();
@ -173,6 +174,7 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, StorageFormat &format)
arg.endStructure();
return arg;
}
#endif
/*
@ -208,8 +210,9 @@ KMailICalIfaceImpl::~KMailICalIfaceImpl()
void KMailICalIfaceImpl::registerWithDBus()
{
qDBusRegisterMetaType< QList<KMail::SubResource> >();
qDBusRegisterMetaType< QMap<quint32,QString> >();
/* qDBusRegisterMetaType< QList<KMail::SubResource> >();
qDBusRegisterMetaType< QMap<quint32,QString> >();*/
KMail::registerGroupwareTypes();
QDBusConnection::sessionBus().registerObject( "/Groupware", this, QDBusConnection::ExportAdaptors );
new GroupwareAdaptor( this );
}
@ -449,7 +452,7 @@ static void setXMLContentTypeHeader( KMMessage *msg, const QString &plainTextBod
quint32 KMailICalIfaceImpl::addIncidenceKolab( KMFolder& folder,
const QString& subject,
const QString& plainTextBody,
const QMap<QByteArray, QString>& customHeaders,
const KMail::CustomHeader::List& customHeaders,
const QStringList& attachmentURLs,
const QStringList& attachmentNames,
const QStringList& attachmentMimetypes )
@ -465,11 +468,8 @@ quint32 KMailICalIfaceImpl::addIncidenceKolab( KMFolder& folder,
msg->setSubject( subject );
msg->setAutomaticFields( true );
QMap<QByteArray, QString>::ConstIterator ith = customHeaders.begin();
const QMap<QByteArray, QString>::ConstIterator ithEnd = customHeaders.end();
for ( ; ith != ithEnd ; ++ith ) {
msg->setHeaderField( ith.key(), ith.value() );
}
foreach ( const CustomHeader header, customHeaders )
msg->setHeaderField( header.name, header.value );
// In case of the ical format, simply add the plain text content with the
// right content type
if ( storageFormat( &folder ) == StorageXML ) {
@ -813,7 +813,7 @@ quint32 KMailICalIfaceImpl::update( const QString& resource,
quint32 sernum,
const QString& subject,
const QString& plainTextBody,
const QMap<QByteArray, QString>& customHeaders,
const KMail::CustomHeader::List& customHeaders,
const QStringList& attachmentURLs,
const QStringList& attachmentMimetypes,
const QStringList& attachmentNames,
@ -848,10 +848,8 @@ quint32 KMailICalIfaceImpl::update( const QString& resource,
// Message found - make a copy and update it:
KMMessage* newMsg = new KMMessage( *msg );
newMsg->setSubject( subject );
QMap<QByteArray, QString>::ConstIterator ith = customHeaders.begin();
const QMap<QByteArray, QString>::ConstIterator ithEnd = customHeaders.begin();
for ( ; ith != ithEnd ; ++ith )
newMsg->setHeaderField( ith.key(), ith.value() );
foreach ( const CustomHeader header, customHeaders )
newMsg->setHeaderField( header.name, header.value );
newMsg->setParent( 0 ); // workaround strange line in KMMsgBase::assign. newMsg is not in any folder yet.
// Note that plainTextBody isn't used in this branch. We assume it's still valid from when the mail was created.

@ -48,7 +48,7 @@
#include <kfoldertree.h>
using KPIM::KFolderTreeItem;
#include "kmfoldertype.h"
#include "kmail_util.h"
#include "groupware_types.h"
class KMFolder;
class KMMessage;
@ -113,7 +113,7 @@ public:
quint32 sernum,
const QString& subject,
const QString& plainTextBody,
const QMap<QByteArray, QString>& customHeaders,
const KMail::CustomHeader::List& customHeaders,
const QStringList& attachmentURLs,
const QStringList& attachmentMimetypes,
const QStringList& attachmentNames,
@ -299,7 +299,7 @@ private:
quint32 addIncidenceKolab( KMFolder& folder,
const QString& subject,
const QString& plainTextBody,
const QMap<QByteArray, QString>& customHeaders,
const KMail::CustomHeader::List& customHeaders,
const QStringList& attachmentURLs,
const QStringList& attachmentNames,
const QStringList& attachmentMimetypes );

@ -85,7 +85,7 @@ using KWallet::Wallet;
#include "kmailinterface.h"
#include "folderadaptor.h"
#include "kmail_util.h"
#include "groupware_types.h"
static KMKernel * mySelf = 0;
@ -992,7 +992,7 @@ QString KMKernel::getFolder( const QString& vpath )
void KMKernel::raise()
{
QDBusInterface iface( DBUS_KMAIL, "/MainApplication",
QDBusInterface iface( KMAIL_DBUS_SERVICE, "/MainApplication",
"org.kde.KUniqueApplication",
QDBusConnection::sessionBus());
QDBusReply<int> reply;
@ -1458,7 +1458,7 @@ void KMKernel::cleanupImapFolders()
{
KMFolderNode *node = *it;
if (node->isDir() || ((acct = the_acctMgr->find(node->id()))
&& ( acct->type() == KAccount::Imap ))
&& ( acct->type() == KAccount::Imap ))
|| !the_acctMgr->isEnabled( node->id() ))
{
++it;

@ -55,7 +55,6 @@
</method>
<method name="storageFormat">
<arg name="resource" type="s" direction="in"/>
<!-- ### Shouldn't that be just 'i'? -->
<arg type="(i)" direction="out"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="KMail::StorageFormat"/>
</method>
@ -76,13 +75,12 @@
<arg name="sernum" type="u" direction="in"/>
<arg name="subject" type="s" direction="in"/>
<arg name="plainTextBody" type="s" direction="in"/>
<!-- FIXME should be a{ays} but qdbusxml2cpp considers that invalid -->
<arg name="customHeaders" type="a{ss}" direction="in"/>
<arg name="customHeaders" type="a(ays)" direction="in"/>
<arg name="attachmentURLs" type="as" direction="in"/>
<arg name="attachmentMimetypes" type="as" direction="in"/>
<arg name="attachmentNames" type="as" direction="in"/>
<arg name="deletedAttachments" type="as" direction="in"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In4" value="const QMap&lt;QByteArray, QString&gt; &amp;"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.In4" value="const QList&lt;KMail::CustomHeader&gt; &amp;"/>
</method>
<method name="incidencesKolab">
<arg type="a{us}" direction="out"/>
@ -95,7 +93,7 @@
<method name="subresourcesKolab">
<arg type="a(ssbb)" direction="out"/>
<arg name="contentsType" type="s" direction="in"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="QList&lt;KMail::SubResource&gt;"/>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="KMail::SubResource::List"/>
</method>
</interface>
</node>

@ -3,8 +3,8 @@
#include <kdebug.h>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <kmail_util.h>
#include "groupware_types.h"
#include "kmailinterface.h"
#include "mailcomposerinterface.h"
#include "aboutdata.h"
@ -21,7 +21,7 @@ int main(int argc,char **argv)
KCmdLineArgs::init(argc, argv, &aboutData);
KApplication app;
OrgKdeKmailKmailInterface kmailInterface( DBUS_KMAIL, "/KMail", QDBusConnection::sessionBus());
OrgKdeKmailKmailInterface kmailInterface( KMAIL_DBUS_SERVICE, "/KMail", QDBusConnection::sessionBus());
kmailInterface.openComposer( "to 1","","","First test","simple openComp call",0);
QDBusReply<QDBusObjectPath> composerDbusPath = kmailInterface.openComposer("to 2","","","Second test", "DBUS ref call",0);
@ -34,7 +34,7 @@ int main(int argc,char **argv)
QDBusObjectPath composerPath = composerDbusPath;
kDebug()<<"composerPath :"<<composerPath.path();
OrgKdeKmailMailcomposerInterface kmailComposerInterface( DBUS_KMAIL, composerPath.path(), QDBusConnection::sessionBus());
OrgKdeKmailMailcomposerInterface kmailComposerInterface( KMAIL_DBUS_SERVICE, composerPath.path(), QDBusConnection::sessionBus());
QByteArray data = "BEGIN:VCALENDAR\nEND:VCALENDAR";
kmailComposerInterface.addAttachment("test.ics","7bit",data,"text","calendar","method",

Loading…
Cancel
Save