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.cpp52
1 files changed, 35 insertions, 17 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index b57506b..bd83626 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -29,17 +29,20 @@ $Id$
*/
#include <stdlib.h>
#include <qfile.h>
#include <qmap.h>
#include <qregexp.h>
#ifndef DESKTOP_VERSION
+#include <qpe/qpeapplication.h>
#include <qtopia/qcopenvelope_qws.h>
+#else
+#include <qapplication.h>
#endif
#include <kstaticdeleter.h>
#include <kmessagebox.h>
#include "externalapphandler.h"
@@ -49,17 +52,24 @@ $Id$
*
********************************************************************************/
QCopTransferItem::QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
: _usedSourceParameters(usedSourceParameters), _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
{
//sourceMessage passes later three parameters: sourceChannel, uid, param1
- _sourceMessageParameters = "(QString,QString,QString)";
+ if (_usedSourceParameters == 0)
+ _sourceMessageParameters = "(QString,QString)";
+ else if (_usedSourceParameters == 1)
+ _sourceMessageParameters = "(QString,QString,QString)";
+ else if (_usedSourceParameters == 2)
+ _sourceMessageParameters = "(QString,QString,QString,QString)";
+ else if (_usedSourceParameters == 3)
+ _sourceMessageParameters = "(QString,QString,QString,QString,QString)";
}
/*********************************************************************************/
QCopTransferItem::QCopTransferItem()
{
}
@@ -67,29 +77,30 @@ QCopTransferItem::QCopTransferItem()
bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1, const QString& param2, const QString& param3)
{
#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), param3(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1());
+ qDebug("passing sourcechannel(%s), uid(%s), param1(%s), param2(%s), param3(%s) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.latin1(), param2.latin1(), param3.latin1());
QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
e << _sourceChannel << uid;
if (_usedSourceParameters == 1)
e << param1;
else if (_usedSourceParameters == 2)
e << param1 << param2;
else if (_usedSourceParameters == 3)
e << param1 << param2 << param3;
+ qApp->processEvents();
return true;
#else
KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
return false;
#endif
@@ -103,34 +114,37 @@ 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;
+ // block second call
+ if ( ii < 2 ) {
+ ++ii;
+ if ( ii > 1 ) {
+ qDebug("qcop call blocked ");
+ return true;
+ }
}
- }
*/
- qDebug("QCopTransferItem- QCOP message received: %s ", cmsg.data() );
+
+// 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;
QString param2;
QString param3;
@@ -186,16 +200,18 @@ bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QSt
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;
+ qApp->processEvents();
+
return true;
#else
KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
return false;
#endif
}
@@ -205,17 +221,17 @@ bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QSt
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() );
+// 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;
@@ -253,16 +269,18 @@ bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QString
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;
+ qApp->processEvents();
+
return true;
#else
KMessageBox::sorry( 0, i18n( "This version does not support QCop." ) );
return false;
#endif
}
@@ -272,17 +290,17 @@ bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QString
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() );
+// 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;
@@ -317,17 +335,17 @@ ExternalAppHandler::ExternalAppHandler()
connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForNameEmailUidList(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(1, "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&)));
mDisplayDetails = new QCopListTransferItem(3, "requestDisplayDetailsFromKAPI", "QPE/Application/kapi", "");
- connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
+ connect(mDisplayDetails, SIGNAL (receivedMessageFromSource(const QString&, const QString&, const QString&, const QString&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&)));
}
ExternalAppHandler::~ExternalAppHandler()
{
}
void ExternalAppHandler::loadConfig()
{
@@ -981,18 +999,18 @@ bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel
}
bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
{
mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3);
}
-bool ExternalAppHandler::requestDetailsFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid)
+bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid)
{
- mDisplayDetails->setSourceChannel(sourceChannel);
- return mDisplayDetails->sendMessageToTarget(sessionuid, name, email, uid);
+ mDisplayDetails->setSourceChannel("");
+ return mDisplayDetails->sendMessageToTarget("", name, email, uid);
}