summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
authorulf69 <ulf69>2004-08-18 21:11:43 (UTC)
committer ulf69 <ulf69>2004-08-18 21:11:43 (UTC)
commit05a1b5cbea6a7c1a7500632f8e7c1bf5be9328d8 (patch) (side-by-side diff)
tree605819f51c314d137f24281f1ed4854b2086aa68 /libkdepim/externalapphandler.cpp
parent7d15927b7e7957a80da335587598e7b62dece1a4 (diff)
downloadkdepimpi-05a1b5cbea6a7c1a7500632f8e7c1bf5be9328d8.zip
kdepimpi-05a1b5cbea6a7c1a7500632f8e7c1bf5be9328d8.tar.gz
kdepimpi-05a1b5cbea6a7c1a7500632f8e7c1bf5be9328d8.tar.bz2
added new QCop method requestForDetails
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp85
1 files changed, 62 insertions, 23 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 64caa7d..b57506b 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -37,59 +37,67 @@ $Id$
#include <qtopia/qcopenvelope_qws.h>
#endif
#include <kstaticdeleter.h>
#include <kmessagebox.h>
#include "externalapphandler.h"
#include "kpimglobalprefs.h"
/*********************************************************************************
*
********************************************************************************/
-QCopTransferItem::QCopTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
- : _sourceMessage(sourceMessage), _targetChannel(targetChannel), _targetMessage(targetMessage)
+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)";
}
/*********************************************************************************/
QCopTransferItem::QCopTransferItem()
{
}
/*********************************************************************************/
-bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& param1)
+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) as parameter to QCopEnvelope", _sourceChannel.latin1(), uid.latin1(), param1.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());
QCopEnvelope e(_targetChannel.latin1(), sourceMessage.latin1());
- e << _sourceChannel << uid << param1;
+ e << _sourceChannel << uid;
+
+ if (_usedSourceParameters == 1)
+ e << param1;
+ else if (_usedSourceParameters == 2)
+ e << param1 << param2;
+ else if (_usedSourceParameters == 3)
+ e << param1 << param2 << param3;
+
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())
@@ -111,51 +119,71 @@ bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data
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;
+ QString param2;
+ QString param3;
- stream >> sourceChannel >> uid >> param1;
+ stream >> sourceChannel >> uid;
+ if (_usedSourceParameters == 0)
+ {
+ emit receivedMessageFromSource(sourceChannel, uid);
+ }
+ else if (_usedSourceParameters == 1)
+ {
+ stream >> param1;
emit receivedMessageFromSource(sourceChannel, uid, param1);
+ }
+ else if (_usedSourceParameters == 2)
+ {
+ stream >> param1 >> param2;
+ emit receivedMessageFromSource(sourceChannel, uid, param1, param2);
+ }
+ else if (_usedSourceParameters == 3)
+ {
+ stream >> param1 >> param2 >> param3;
+ emit receivedMessageFromSource(sourceChannel, uid, param1, param2, param3);
+ }
return true;
}
return false;
}
/*********************************************************************************
*
********************************************************************************/
-QCopMapTransferItem::QCopMapTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
- : QCopTransferItem(sourceMessage, targetChannel,targetMessage)
+QCopMapTransferItem::QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
+ : QCopTransferItem(usedSourceParameters, 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());
@@ -195,36 +223,36 @@ bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& da
emit receivedMessageFromTarget(uid, adrMap);
return true;
}
}
return false;
}
/*********************************************************************************
*
********************************************************************************/
-QCopListTransferItem::QCopListTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
- : QCopTransferItem(sourceMessage, targetChannel,targetMessage)
+QCopListTransferItem::QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage)
+ : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage)
{
- //targetMessage returns later two parameters: uid, and map<qstring,qstring>
+ //targetMessage returns later two parameters: uid, and three lists
_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
@@ -272,41 +300,42 @@ bool QCopListTransferItem::appMessage( const QCString& cmsg, const QByteArray& d
}
/*********************************************************************************
*
********************************************************************************/
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&)));
+ mNameEmailUidListFromKAPITransfer = new QCopListTransferItem(0, "requestNameEmailUIDListFromKAPI", "QPE/Application/kapi", "receiveNameEmailUIDList");
+ 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("requestFindByEmailFromKAPI", "QPE/Application/kapi", "receiveFindByEmailNameEmailUIDList");
+//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&)));
}
ExternalAppHandler::~ExternalAppHandler()
{
}
void ExternalAppHandler::loadConfig()
{
mDefaultItems.clear();
mEmailAppAvailable = UNDEFINED;
mPhoneAppAvailable = UNDEFINED;
mFaxAppAvailable = UNDEFINED;
mSMSAppAvailable = UNDEFINED;
mPagerAppAvailable = UNDEFINED;
@@ -911,49 +940,59 @@ void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& paramete
(*e) << valmap;
#endif
}
/**************************************************************************
*
**************************************************************************/
void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data )
{
bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
+ if (!res)
+ res = mDisplayDetails->appMessage( cmsg, data );
+
// if (!res)
// res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
}
-bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid)
+bool ExternalAppHandler::requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid)
{
mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
- return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(uid, QString::null);
+ return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid);
}
-bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
+bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
{
mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
- return mNameEmailUidListFromKAPITransfer->sendMessageToSource(uid, list1, list2, list3);
+ return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3);
}
-bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QString& email)
+bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email)
{
mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
- return mFindByEmailFromKAPITransfer->sendMessageToTarget(uid, email);
+ return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email);
}
-bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
+bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3)
{
mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel);
- return mFindByEmailFromKAPITransfer->sendMessageToSource(uid, list1, list2, list3);
+ 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)
+{
+ mDisplayDetails->setSourceChannel(sourceChannel);
+ return mDisplayDetails->sendMessageToTarget(sessionuid, name, email, uid);
+}
+
+