Diffstat (limited to 'libkdepim/externalapphandler.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkdepim/externalapphandler.h | 111 |
1 files changed, 109 insertions, 2 deletions
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h index 3cf9e06..7c8de4e 100644 --- a/libkdepim/externalapphandler.h +++ b/libkdepim/externalapphandler.h @@ -28,18 +28,94 @@ Copyright (c) 2004 Ulf Schenk $Id$ */ #ifndef EXTERNALAPPHANDLER_H #define EXTERNALAPPHANDLER_H +#include <qobject.h> #include <qlist.h> +#include <qmap.h> class QCopEnvelope; class ExternalAppHandler; +class QCopTransferItem : public QObject +{ + Q_OBJECT + public: + QCopTransferItem(const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); + QCopTransferItem(); + + bool sendMessageToTarget(const QString& uid, const QString& param1); + + void setSourceChannel(const QString& sourceChannel); + + virtual bool appMessage( const QCString& msg, const QByteArray& data ); + + + signals: + void receivedMessageFromSource(const QString& sourceChannel, const QString& uid, const QString& param1); + + + public: + QString _sourceChannel; + QString _sourceMessage; + QString _sourceMessageParameters; + QString _targetChannel; + QString _targetMessage; + QString _targetMessageParameters; + +}; + +/********************************************************************************* + * + ********************************************************************************/ + +class QCopMapTransferItem : public QCopTransferItem +{ + Q_OBJECT + public: + QCopMapTransferItem(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 ); + + + signals: + void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); + +}; + +/********************************************************************************* + * + ********************************************************************************/ + +class QCopListTransferItem : public QCopTransferItem +{ + Q_OBJECT + public: + QCopListTransferItem(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 ); + + + signals: + void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3); + +}; + +/********************************************************************************* + * + ********************************************************************************/ + class DefaultAppItem { public: DefaultAppItem(int type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2) : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2) @@ -57,14 +133,19 @@ class DefaultAppItem QString _parameters; // a list of parameters in stringrepresentation. Delimiter is ; QString _message2; QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; }; -class ExternalAppHandler +/********************************************************************************* + * + ********************************************************************************/ + +class ExternalAppHandler : public QObject { + Q_OBJECT public: virtual ~ExternalAppHandler(); static ExternalAppHandler *instance(); enum Types { @@ -109,37 +190,63 @@ class ExternalAppHandler bool isSMSAppAvailable(); bool isPhoneAppAvailable(); bool isFaxAppAvailable(); bool isPagerAppAvailable(); + //Call this method on the source when you want to select names from the addressbook by using QCop + bool requestNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& uid); + //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); + //loadConfig clears the cache and checks again if the applications are available or not void loadConfig(); QList<DefaultAppItem> getAvailableDefaultItems(Types); DefaultAppItem* getDefaultItem(Types, int); + 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); + + // 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); + private: ExternalAppHandler(); QList<DefaultAppItem> mDefaultItems; Availability mEmailAppAvailable; Availability mPhoneAppAvailable; Availability mFaxAppAvailable; Availability mSMSAppAvailable; Availability mPagerAppAvailable; + QCopListTransferItem* mNameEmailUidListFromKAPITransfer; + QCopListTransferItem* mFindByEmailFromKAPITransfer; + 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; static ExternalAppHandler *sInstance; - }; + #endif |