summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp87
-rw-r--r--libkdepim/externalapphandler.h19
2 files changed, 77 insertions, 29 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 64caa7d..b57506b 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -47,39 +47,47 @@ $Id$
/*********************************************************************************
*
********************************************************************************/
-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;
@@ -121,16 +129,36 @@ bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data
QDataStream stream( data, IO_ReadOnly );
QString sourceChannel;
QString uid;
QString param1;
+ QString param2;
+ QString param3;
- stream >> sourceChannel >> uid >> param1;
+ stream >> sourceChannel >> uid;
- emit receivedMessageFromSource(sourceChannel, uid, param1);
+ 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;
}
@@ -138,14 +166,14 @@ bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data
/*********************************************************************************
*
********************************************************************************/
-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>)";
}
/*********************************************************************************/
@@ -205,16 +233,16 @@ bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& da
/*********************************************************************************
*
********************************************************************************/
-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)
{
@@ -282,21 +310,22 @@ 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()
{
}
@@ -921,39 +950,49 @@ void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& paramete
**************************************************************************/
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);
+}
+
+
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h
index 7c8de4e..a74080f 100644
--- a/libkdepim/externalapphandler.h
+++ b/libkdepim/externalapphandler.h
@@ -40,27 +40,31 @@ class QCopEnvelope;
class ExternalAppHandler;
class QCopTransferItem : public QObject
{
Q_OBJECT
public:
- QCopTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
+ QCopTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
QCopTransferItem();
- bool sendMessageToTarget(const QString& uid, const QString& param1);
+ bool sendMessageToTarget(const QString& uid, const QString& param1 = QString::null, const QString& param2 = QString::null, const QString& param3 = QString::null);
void setSourceChannel(const QString& sourceChannel);
virtual bool appMessage( const QCString& msg, const QByteArray& data );
signals:
+ void receivedMessageFromSource(const QString& sourceChannel, const QString& uid);
void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1);
+ void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2);
+ void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1, const QString& param2, const QString& param3);
public:
+ int _usedSourceParameters;
QString _sourceChannel;
QString _sourceMessage;
QString _sourceMessageParameters;
QString _targetChannel;
QString _targetMessage;
QString _targetMessageParameters;
@@ -72,13 +76,13 @@ class QCopTransferItem : public QObject
********************************************************************************/
class QCopMapTransferItem : public QCopTransferItem
{
Q_OBJECT
public:
- QCopMapTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
+ QCopMapTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
bool sendMessageToSource(const QString& uid, const QMap<QString,QString>& nameEmailMap);
virtual bool appMessage( const QCString& msg, const QByteArray& data );
@@ -93,13 +97,13 @@ class QCopMapTransferItem : public QCopTransferItem
********************************************************************************/
class QCopListTransferItem : public QCopTransferItem
{
Q_OBJECT
public:
- QCopListTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
+ QCopListTransferItem(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage);
bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3);
virtual bool appMessage( const QCString& msg, const QByteArray& data );
@@ -198,12 +202,14 @@ class ExternalAppHandler : public QObject
//Call this method on the target when you want to return the name/email map to the source (client).
bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& name, const QStringList& email, const QStringList& uid);
bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QString& email);
bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& uid, const QStringList& name, const QStringList& email, const QStringList& uid);
+ bool requestDetailsFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
+
//loadConfig clears the cache and checks again if the applications are available or not
void loadConfig();
QList<DefaultAppItem> getAvailableDefaultItems(Types);
DefaultAppItem* getDefaultItem(Types, int);
@@ -211,21 +217,23 @@ class ExternalAppHandler : public QObject
public slots:
void appMessage( const QCString& msg, const QByteArray& data );
signals:
// Emmitted when the target app receives a request from the source app
- void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid, const QString& param1);
+ void requestForNameEmailUidList(const QString& sourceChannel, const QString& uid);
// Emitted when the source app recieves a list of name/email pairs (=addresses) from another target app. Usually Ka/Pi
// The first parameter is a uniqueid. It can be used to identify the event
void receivedNameEmailUidListEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList);
void requestFindByEmail(const QString& sourceChannel, const QString& uid, const QString& email);
void receivedFindBbyEmailEvent(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList);
+ void requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
+
private:
ExternalAppHandler();
QList<DefaultAppItem> mDefaultItems;
Availability mEmailAppAvailable;
@@ -233,12 +241,13 @@ class ExternalAppHandler : public QObject
Availability mFaxAppAvailable;
Availability mSMSAppAvailable;
Availability mPagerAppAvailable;
QCopListTransferItem* mNameEmailUidListFromKAPITransfer;
QCopListTransferItem* mFindByEmailFromKAPITransfer;
+ QCopTransferItem* mDisplayDetails;
void addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2);
QString& translateMessage(QString& message, const QString& param1, const QString& param2) const;
void passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1, const QString& param2) const;