SVN commit 680017 by mlaurent: Port dbus++ M +56 -44 kmailconnectionadaptor.cpp --- trunk/KDE/kdepim/kresources/kolab/shared/kmailconnectionadaptor.cpp #680016:680017 @@ -43,9 +43,15 @@ #include using namespace Kolab; +typedef QList QListKmailSubResource; +typedef QMap Quint32StringMap; +typedef QMap ByteArrayStringMap; +Q_DECLARE_METATYPE(ByteArrayStringMap) Q_DECLARE_METATYPE(KMail::SubResource ) -Q_DECLARE_METATYPE(QList ) +Q_DECLARE_METATYPE(QListKmailSubResource ) +Q_DECLARE_METATYPE(Quint32StringMap) +Q_DECLARE_METATYPE(KMail::StorageFormat ) const QDBusArgument &operator<<(QDBusArgument &arg, const KMail::SubResource &subResource) { @@ -63,12 +69,33 @@ return arg; } +const QDBusArgument &operator<<(QDBusArgument &arg, const KMail::StorageFormat &format) +{ + arg.beginStructure(); + quint32 foo = format; + arg << foo; + arg.endStructure(); + return arg; +} + +const QDBusArgument &operator>>(const QDBusArgument &arg, KMail::StorageFormat &format) +{ + arg.beginStructure(); + quint32 foo = format; + arg >> foo; + arg.endStructure(); + return arg; +} + static void registerTypes() { static bool registered = false; if (!registered) { qDBusRegisterMetaType(); - qDBusRegisterMetaType< QList >(); + qDBusRegisterMetaType< QListKmailSubResource >(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); + qDBusRegisterMetaType(); registered = true; } } @@ -112,10 +139,7 @@ //TODO verify interface qDebug()<<" dbusService :"< Quint32StringMap; - //Q_DECLARE_METATYPE(Quint32StringMap) - //qDBusRegisterMetaType(); - //TODO verify if it connected. + registerTypes(); QDBusConnection dbus = QDBusConnection::sessionBus(); dbus.connect( DBUS_KMAIL, "/GroupWare", "org.kde.kmail.groupware", "incidenceAdded", this, SLOT(fromKMailAddIncidence(QString,QString,quint32,int,QString) ) ); @@ -227,16 +251,10 @@ return false; registerTypes(); - QDBusReply r = mKmailGroupwareInterface->call( "subresourcesKolab", contentsType ); + QDBusReply r = mKmailGroupwareInterface->call( "subresourcesKolab", contentsType ); if ( r.isValid() ) { - // QVariantList args = r; - //QVariantList::ConstIterator it = r.constBegin(); - //QVariantList::ConstIterator end = r.constEnd(); - //for ( ; it != end; ++it) - { - //lst<< *it, - } + lst = r; } return (mKmailGroupwareInterface->lastError().type()==QDBusError::NoError); } @@ -261,22 +279,10 @@ { if ( !connectToKMail() ) return false; - //TODO port it -#if 0 - if ( !connectToKMail() ) - return false; - - lst = mKmailGroupwareInterface->call( "incidencesKolab", mimetype, resource, startIndex, nbMessages ); - return (mKmailGroupwareInterface->lastError().type()==QDBusError::NoError); -#endif - //Registered dbus type. - QDBusReply r = mKmailGroupwareInterface->call( "incidencesKolab", mimetype, resource, startIndex, nbMessages ); + registerTypes(); + QDBusReply r = mKmailGroupwareInterface->call( "incidencesKolab", mimetype, resource, startIndex, nbMessages ); if (r.isValid()) { - // convert to - const QVariantMap val = r.value(); - for( QVariantMap::const_iterator it = val.begin(); it != val.end(); ++it ) { - //lst.insert(it.key().toUint(), it.value().toString()); - } + lst = r; } return (mKmailGroupwareInterface->lastError().type()==QDBusError::NoError); } @@ -316,29 +322,35 @@ const QStringList& attachmentNames, const QStringList& deletedAttachments ) { - //PORT it -#if 0 - kDebug(5006) << kBacktrace() << endl; - if ( connectToKMail() ) { - sernum = mKmailGroupwareInterface->update( resource, sernum, subject, plainTextBody, customHeaders, - attachmentURLs, attachmentMimetypes, attachmentNames, - deletedAttachments ); - return sernum && (mKmailGroupwareInterface->lastError().type()==QDBusError::NoError); - } else + if ( !connectToKMail() ) return false; -#endif - return false; + registerTypes(); + bool ret = false; + //TODO fix me + /*QList arg; + arg < reply = mKmailGroupwareInterface->callWithArgumentList( QDBus::NoBlock, "update", arg ); + if ( reply.isValid() ) + ret = reply;*/ + return ret; } bool KMailConnectionAdaptor::kmailStorageFormat( KMail::StorageFormat& type, const QString& folder ) { - //TODO port it -#if 0 bool ok = connectToKMail(); - type = mKmailGroupwareInterface->storageFormat( folder ); + QDBusReply reply = mKmailGroupwareInterface->call( "storageFormat", folder ); + if ( reply.isValid() ) + type = reply; return ok && (mKmailGroupwareInterface->lastError().type()==QDBusError::NoError); -#endif }