diff --git a/CMakeLists.txt b/CMakeLists.txt index 54ada3525..ac7d2ff32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ) diff --git a/groupware_types.cpp b/groupware_types.cpp new file mode 100644 index 000000000..ff95eeb22 --- /dev/null +++ b/groupware_types.cpp @@ -0,0 +1,81 @@ +/* + Copyright (c) 2007 Montel Laurent + Copyright (c) 2008 Volker Krause + + 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 +#include + +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 >(); + qDBusRegisterMetaType< KMail::CustomHeader >(); + qDBusRegisterMetaType< KMail::CustomHeader::List >(); +} diff --git a/kmail_util.h b/groupware_types.h similarity index 76% rename from kmail_util.h rename to groupware_types.h index 70ebf182d..125af2caf 100644 --- a/kmail_util.h +++ b/groupware_types.h @@ -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 -#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 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 List; + }; + + /** + Register D-Bus types. + */ + void registerGroupwareTypes(); } +typedef QMap Quint32QStringMap; + Q_DECLARE_METATYPE( KMail::SubResource ) -Q_DECLARE_METATYPE( QList ) +Q_DECLARE_METATYPE( KMail::SubResource::List ) Q_DECLARE_METATYPE( KMail::StorageFormat ) -typedef QMap Quint32QStringMap; Q_DECLARE_METATYPE( Quint32QStringMap ) -typedef QMap QByteArrayStringMap; -Q_DECLARE_METATYPE( QByteArrayStringMap) +Q_DECLARE_METATYPE( KMail::CustomHeader ) +Q_DECLARE_METATYPE( KMail::CustomHeader::List ) #endif diff --git a/kmailicalifaceimpl.cpp b/kmailicalifaceimpl.cpp index a56cad555..02061c1ed 100644 --- a/kmailicalifaceimpl.cpp +++ b/kmailicalifaceimpl.cpp @@ -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 >(); - qDBusRegisterMetaType< QMap >(); +/* qDBusRegisterMetaType< QList >(); + qDBusRegisterMetaType< QMap >();*/ + 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& 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::ConstIterator ith = customHeaders.begin(); - const QMap::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& 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::ConstIterator ith = customHeaders.begin(); - const QMap::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. diff --git a/kmailicalifaceimpl.h b/kmailicalifaceimpl.h index ca4716bfc..e13c4b2c5 100644 --- a/kmailicalifaceimpl.h +++ b/kmailicalifaceimpl.h @@ -48,7 +48,7 @@ #include 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& 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& customHeaders, + const KMail::CustomHeader::List& customHeaders, const QStringList& attachmentURLs, const QStringList& attachmentNames, const QStringList& attachmentMimetypes ); diff --git a/kmkernel.cpp b/kmkernel.cpp index 6bed70ed7..8e1e48cee 100644 --- a/kmkernel.cpp +++ b/kmkernel.cpp @@ -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 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; diff --git a/org.kde.kmail.groupware.xml b/org.kde.kmail.groupware.xml index bb3768750..affd18c75 100644 --- a/org.kde.kmail.groupware.xml +++ b/org.kde.kmail.groupware.xml @@ -55,7 +55,6 @@ - @@ -76,13 +75,12 @@ - - + - + @@ -95,7 +93,7 @@ - + diff --git a/tests/dbustest.cpp b/tests/dbustest.cpp index 490711486..c486d0d82 100644 --- a/tests/dbustest.cpp +++ b/tests/dbustest.cpp @@ -3,8 +3,8 @@ #include #include #include -#include +#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 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 :"<