summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
Side-by-side diff
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp282
1 files changed, 280 insertions, 2 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 35638b1..64caa7d 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -42,25 +42,261 @@ $Id$
#include "externalapphandler.h"
#include "kpimglobalprefs.h"
+/*********************************************************************************
+ *
+ ********************************************************************************/
+
+
+QCopTransferItem::QCopTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
+ : _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
+{
+ //sourceMessage passes later three parameters: sourceChannel, uid, param1
+ _sourceMessageParameters = "(QString,QString,QString)";
+}
+
+/*********************************************************************************/
+
+QCopTransferItem::QCopTransferItem()
+{
+}
+
+/*********************************************************************************/
+bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1)
+{
+
+#ifndef DESKTOP_VERSION
+ //sourceMessage passes two parameters: sourceChannel, uid
+ QString sourceMessage = _sourceMessage + _sourceMessageParameters;
+
+ qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _targetChannel.latin1(), sourceMessage.latin1());
+ qDebug("passing sourcechannel(%s), uid(%s), param1(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1());
+
+ QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
+
+ e << _sourceChannel << uid << param1;
+
+ return true;
+
+#else
+ KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
+ return false;
+#endif
+
+}
+
+
+/*********************************************************************************/
+void QCopTransferItem::setSourceChannel(const QString& sourceChannel)
+{
+
+ if (_sourceChannel.isEmpty())
+ _sourceChannel = sourceChannel;
+}
+
+
+/*********************************************************************************/
+bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
+{
+/*US
+ // copied from old mail2
+ static int ii = 0;
+
+ // block second call
+ if ( ii < 2 ) {
+ ++ii;
+ if ( ii > 1 ) {
+ qDebug("qcop call blocked ");
+ return true;
+ }
+ }
+*/
+ qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
+
+ //we are in the target and get a request from the source
+ if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
+ {
+ QDataStream stream( data, IO_ReadOnly );
+
+
+ QString sourceChannel;
+ QString uid;
+ QString param1;
+ stream >> sourceChannel >> uid >> param1;
+ emit receivedMessageFromSource(sourceChannel, uid, param1);
+ return true;
+ }
+
+ return false;
+}
+
+
+/*********************************************************************************
+ *
+ ********************************************************************************/
+
+
+QCopMapTransferItem::QCopMapTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
+ : QCopTransferItem(sourceMessage, targetChannel,targetMessage)
+{
+ //targetMessage returns later two parameters: uid, and map<qstring,qstring>
+ _targetMessageParameters = "(QString,QMAP<QString,QString>)";
+}
+
+/*********************************************************************************/
+bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap)
+{
+#ifndef DESKTOP_VERSION
+ //targetMessage passes two parameters: uid, map
+ QString targetMessage = _targetMessage + _targetMessageParameters;
+
+ qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
+ qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
+ QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
+ //US we need no names in the To field. The emailadresses are enough
+
+ e << uid << nameEmailMap;
+
+ return true;
+
+#else
+ KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
+ return false;
+#endif
+
+}
+
+
+/*********************************************************************************/
+bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
+{
+ bool res = QCopTransferItem::appMessage( cmsg, data );
+
+ if (res == false)
+ {
+ QDataStream stream( data, IO_ReadOnly );
+
+ qDebug("QCopMapTransferItem- QCOP message received: %s ", cmsg.data() );
+
+ //we are in the source and get an answer from the target
+ if ((_targetMessage + _targetMessageParameters) == cmsg.data())
+ {
+ QMap<QString,QString> adrMap;
+ QString uid;
+
+ stream >> uid >> adrMap;
+
+ emit receivedMessageFromTarget(uid, adrMap);
+
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+/*********************************************************************************
+ *
+ ********************************************************************************/
+
+
+QCopListTransferItem::QCopListTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
+ : QCopTransferItem(sourceMessage, targetChannel,targetMessage)
+{
+ //targetMessage returns later two parameters: uid, and map<qstring,qstring>
+ _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)";
+}
+
+/*********************************************************************************/
+bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
+{
+#ifndef DESKTOP_VERSION
+ //targetMessage passes two parameters: uid, map
+ QString targetMessage = _targetMessage + _targetMessageParameters;
+
+ qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
+ qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1());
+
+ QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
+ //US we need no names in the To field. The emailadresses are enough
+
+ e << uid << list1 << list2 << list3;
+
+ return true;
+
+#else
+ KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
+ return false;
+#endif
+
+}
+
+
+/*********************************************************************************/
+bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& data )
+{
+ bool res = QCopTransferItem::appMessage( cmsg, data );
+
+ if (res == false)
+ {
+ QDataStream stream( data, IO_ReadOnly );
+
+ qDebug("QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
+
+ //we are in the source and get an answer from the target
+ if ((_targetMessage + _targetMessageParameters) == cmsg.data())
+ {
+ QStringList list1;
+ QStringList list2;
+ QStringList list3;
+ QString uid;
+
+ stream >> uid >> list1 >> list2 >> list3;
+
+ emit receivedMessageFromTarget(uid, list1, list2, list3);
+
+
+ return true;
+ }
+ }
+
+ return false;
+}
+
+
+
+/*********************************************************************************
+ *
+ ********************************************************************************/
ExternalAppHandler *ExternalAppHandler::sInstance = 0;
static KStaticDeleter<ExternalAppHandler> staticDeleter;
-
ExternalAppHandler::ExternalAppHandler()
{
mDefaultItems.setAutoDelete(true);
+
+ mNameEmailUidListFromKAPITransfer = new QCopListTransferItem("requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
+ connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(const QString&, const QString&, const QString&)));
+ connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
+
+//US mFindByEmailFromKAPITransfer = new QCopListTransferItem("requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
+//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&)), this, SIGNAL (requestForFindByEmail(const QString&, const QString&, const QString&)));
+//US connect(mFindByEmailFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedFindByEmailEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)));
+
+
}
ExternalAppHandler::~ExternalAppHandler()
{
}
@@ -388,13 +624,14 @@ bool ExternalAppHandler::mailToOneContact( const QString& adressline )
int first = line.find( "<");
int last = line.find( ">");
QString name = line.left(first);
QString emailadress = line.mid(first+1, last-first-1);
//Subject can not be handled right now.
- mailToOneContact( name, emailadress );
+ return mailToOneContact( name, emailadress );
+
}
/**************************************************************************
*
**************************************************************************/
@@ -676,6 +913,47 @@ void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& paramete
#endif
}
+/**************************************************************************
+ *
+ **************************************************************************/
+
+void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
+{
+ bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
+
+// if (!res)
+// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
+}
+
+
+
+bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid)
+{
+ mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
+ return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(uid, QString::null);
+}
+
+bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
+{
+ mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
+ return mNameEmailUidListFromKAPITransfer->sendMessageToSource(uid, list1, list2, list3);
+}
+
+bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QString& email)
+{
+ mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
+ return mFindByEmailFromKAPITransfer->sendMessageToTarget(uid, email);
+}
+
+bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
+{
+ mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
+ return mFindByEmailFromKAPITransfer->sendMessageToSource(uid, list1, list2, list3);
+}
+
+
+
+