author | ulf69 <ulf69> | 2004-10-07 01:04:18 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-10-07 01:04:18 (UTC) |
commit | 0406c1ac252f2fa631f7a486e73b0a97d09874f9 (patch) (side-by-side diff) | |
tree | 72de99490603b5913a39a101ef571ba74acd6798 | |
parent | 0afcfa29ace7bc5e42a11fae44301e1e8230a376 (diff) | |
download | kdepimpi-0406c1ac252f2fa631f7a486e73b0a97d09874f9.zip kdepimpi-0406c1ac252f2fa631f7a486e73b0a97d09874f9.tar.gz kdepimpi-0406c1ac252f2fa631f7a486e73b0a97d09874f9.tar.bz2 |
added functionality for Birthdaylookup from kopi via qCop
-rw-r--r-- | libkdepim/externalapphandler.cpp | 68 | ||||
-rw-r--r-- | libkdepim/externalapphandler.h | 32 |
2 files changed, 86 insertions, 14 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp index 99aee86..07bdff2 100644 --- a/libkdepim/externalapphandler.cpp +++ b/libkdepim/externalapphandler.cpp @@ -227,155 +227,185 @@ bool QCopMapTransferItem::appMessage( const QCString& cmsg, const QByteArray& da 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(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage) : QCopTransferItem(usedSourceParameters, sourceMessage, targetChannel,targetMessage) { //targetMessage returns later two parameters: uid, and three lists - _targetMessageParameters = "(QString,QStringList,QStringList,QStringList)"; + _targetMessageParameters = "(QString,QStringList,QStringList,QStringList,QStringList,QStringList,QStringList)"; } /*********************************************************************************/ -bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3) +bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) { #ifndef DESKTOP_VERSION //targetMessage passes two parameters: uid, map QString targetMessage = _targetMessage + _targetMessageParameters; qDebug("3Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1()); - qDebug("passing uid(%s) and list1, list2, list3 as parameter to QCopEnvelope", uid.latin1()); + qDebug("passing uid(%s) and list1, list2, list3, list4, list5, list6 as parameter to QCopEnvelope", uid.latin1()); + + + for ( int i = 0; i < list3.count(); i++) + qDebug("listentry list3: %s",list3[i].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; + e << uid << list1 << list2 << list3 << list4 << list5 << list6; qApp->processEvents(); 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 ); qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); if (res == false) { QDataStream stream( data, IO_ReadOnly ); qDebug("2QCopListTransferItem- 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; + QStringList list4; + QStringList list5; + QStringList list6; QString uid; - stream >> uid >> list1 >> list2 >> list3; - emit receivedMessageFromTarget(uid, list1, list2, list3); + qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() ); + + stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6; + emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6); return true; } } return false; } /********************************************************************************* * ********************************************************************************/ ExternalAppHandler *ExternalAppHandler::sInstance = 0; static KStaticDeleter<ExternalAppHandler> staticDeleter; ExternalAppHandler::ExternalAppHandler() { mDefaultItems.setAutoDelete(true); 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&))); + connect(mNameEmailUidListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SLOT (receivedNameEmailUidList_Slot(const QString&, const QStringList&, const QStringList&, const QStringList&, 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&, const QString&)), this, SIGNAL (requestForDetails(const QString&, const QString&, const QString&, const QString&, const QString&))); + + + + mBirthdayListFromKAPITransfer = new QCopListTransferItem(0, "requestBirthdayListFromKAPI", "QPE/Application/kapi", "receiveBirthdayList"); + connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromSource(const QString&, const QString&)), this, SIGNAL (requestForBirthdayList(const QString&, const QString&))); + connect(mBirthdayListFromKAPITransfer, SIGNAL (receivedMessageFromTarget(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), this, SIGNAL (receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); + + } ExternalAppHandler::~ExternalAppHandler() { } +void ExternalAppHandler::receivedNameEmailUidList_Slot(const QString& uid, + const QStringList& nameList, + const QStringList& emailList, + const QStringList& uidList, + const QStringList&, + const QStringList&, + const QStringList& ) +{ + // this method is a conevnient way to reduce the number of parameters I have to pass + emit receivedNameEmailUidListEvent(uid, nameList, emailList, uidList); +} + + void ExternalAppHandler::loadConfig() { mDefaultItems.clear(); mEmailAppAvailable = UNDEFINED; mPhoneAppAvailable = UNDEFINED; mFaxAppAvailable = UNDEFINED; mSMSAppAvailable = UNDEFINED; mPagerAppAvailable = UNDEFINED; mSIPAppAvailable = UNDEFINED; QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); if (opiepath.isEmpty()) opiepath = qtopiapath; //mailclients QString mailmsg1 = "writeMail(QString,QString)"; QString mailmsg2 = "writeMail(QMap(QString,QString))"; QString undefined = ""; addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC, "No email client installed", undefined, undefined, undefined, undefined, undefined); addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OTHER_EMC, "Userdefined email client", undefined, undefined, undefined, undefined, undefined); if (( QFile::exists( qtopiapath + "/bin/ompi" )) || ( QFile::exists( opiepath + "/bin/ompi" ))) addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OMPI_EMC, "OM/Pi email client", "QPE/Application/ompi", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); if ( QFile::exists( qtopiapath + "/bin/qtmail" )) addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, "%1;%2", mailmsg2, "TO=%1;ATTACHMENT=%2"); @@ -1020,75 +1050,93 @@ void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& paramete { QString value = (*it2); value = value.replace( QRegExp("%1"), param1 ); value = value.replace( QRegExp("%2"), param2 ); valmap.insert(key, value); useValMap = true; } else { // qDebug("pass parameter << %s", key.latin1()); (*e) << key; } } if (useValMap == true) (*e) << valmap; #endif } /************************************************************************** * **************************************************************************/ void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& data ) { bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data ); if (!res) + res = mBirthdayListFromKAPITransfer->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& sessionuid) { mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); return mNameEmailUidListFromKAPITransfer->sendMessageToTarget(sessionuid); } bool ExternalAppHandler::returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) { - + QStringList list4, list5, list6; + mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel); - return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); + return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); } bool ExternalAppHandler::requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email) { mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); return mFindByEmailFromKAPITransfer->sendMessageToTarget(sessionuid, email); } bool ExternalAppHandler::returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3) { + QStringList list4, list5, list6; + mFindByEmailFromKAPITransfer->setSourceChannel(sourceChannel); - return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3); + return mFindByEmailFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); } bool ExternalAppHandler::requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid) { mDisplayDetails->setSourceChannel(""); return mDisplayDetails->sendMessageToTarget("", name, email, uid); } +bool ExternalAppHandler::requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid) +{ + mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); + return mBirthdayListFromKAPITransfer->sendMessageToTarget(sessionuid); +} + +bool ExternalAppHandler::returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6) +{ + mBirthdayListFromKAPITransfer->setSourceChannel(sourceChannel); + return mBirthdayListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3, list4, list5, list6); +} + diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h index cfe577b..4c6f1ea 100644 --- a/libkdepim/externalapphandler.h +++ b/libkdepim/externalapphandler.h @@ -30,115 +30,114 @@ $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(int usedSourceParameters, const QString& sourceMessage, const QString& targetChannel, const QString& targetMessage); QCopTransferItem(); 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; }; /********************************************************************************* * ********************************************************************************/ class QCopMapTransferItem : public QCopTransferItem { Q_OBJECT public: 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 ); signals: void receivedMessageFromTarget(const QString& uid, const QMap<QString,QString>& nameEmailMap); }; /********************************************************************************* * ********************************************************************************/ class QCopListTransferItem : public QCopTransferItem { Q_OBJECT public: 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); + bool sendMessageToSource(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4, const QStringList& list5, const QStringList& list6); virtual bool appMessage( const QCString& msg, const QByteArray& data ); signals: - void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3); + void receivedMessageFromTarget(const QString& uid, const QStringList& list1, const QStringList& list2, const QStringList& list3, const QStringList& list4 , const QStringList& list5, const QStringList& list6); }; /********************************************************************************* * ********************************************************************************/ 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) { } DefaultAppItem() { } public: int _type; int _id; QString _label; QString _channel; QString _message; QString _parameters; // a list of parameters in stringrepresentation. Delimiter is ; QString _message2; QString _parameters2; // a list of parameters in stringrepresentation. Delimiter is ; }; /********************************************************************************* * @@ -178,90 +177,115 @@ class ExternalAppHandler : public QObject // parameters format is // NAME <EMAIL>:SUBJECT bool mailToOneContact( const QString& adressline ); //calls the phoneapplication with the number bool callByPhone( const QString& phonenumber ); //calls the smsapplication with the number bool callBySMS( const QString& phonenumber ); //calls the pagerapplication with the number bool callByPager( const QString& pagernumber ); //calls the faxapplication with the number bool callByFax( const QString& faxnumber ); //calls the sipapplication with the number bool callBySIP( const QString& sipnumber ); bool isEmailAppAvailable(); bool isSMSAppAvailable(); bool isPhoneAppAvailable(); bool isFaxAppAvailable(); bool isPagerAppAvailable(); bool isSIPAppAvailable(); //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& sessionuid); //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& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); + + bool requestFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QString& email); bool returnFindByEmailFromKAPI(const QString& sourceChannel, const QString& sessionuid, const QStringList& name, const QStringList& email, const QStringList& uid); bool requestDetailsFromKAPI(const QString& name, const QString& email, const QString& uid); + + bool requestBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid); + bool returnBirthdayListFromKAPI(const QString& sourceChannel, const QString& sessionuid, + const QStringList& birthdayList, const QStringList& anniversaryList, + const QStringList& realNameList, const QStringList& emailList, + const QStringList& assembledNameList, const QStringList& uidList); + + //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); // 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 receivedFindByEmailEvent(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); + // Emmitted when the target app receives a request from the source app + void requestForBirthdayList(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 receivedBirthdayListEvent(const QString& uid, const QStringList& birthdayList, + const QStringList& anniversaryList, const QStringList& realNameList, + const QStringList& emailList, const QStringList& assembledNameList, + const QStringList& uidList); + + private: ExternalAppHandler(); QList<DefaultAppItem> mDefaultItems; Availability mEmailAppAvailable; Availability mPhoneAppAvailable; Availability mFaxAppAvailable; Availability mSMSAppAvailable; Availability mPagerAppAvailable; Availability mSIPAppAvailable; QCopListTransferItem* mNameEmailUidListFromKAPITransfer; QCopListTransferItem* mFindByEmailFromKAPITransfer; QCopTransferItem* mDisplayDetails; + QCopListTransferItem* mBirthdayListFromKAPITransfer; 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; + private slots: + void receivedNameEmailUidList_Slot(const QString& uid, const QStringList& nameList, const QStringList& emailList, const QStringList& uidList, const QStringList&, const QStringList&, const QStringList& ); + }; #endif |