summaryrefslogtreecommitdiffabout
path: root/libkdepim
Side-by-side diff
Diffstat (limited to 'libkdepim') (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp36
-rw-r--r--libkdepim/externalapphandler.h10
2 files changed, 32 insertions, 14 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index b57506b..bd83626 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -5,156 +5,170 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$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"
#include "kpimglobalprefs.h"
/*********************************************************************************
*
********************************************************************************/
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
+ 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()
{
}
/*********************************************************************************/
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
}
/*********************************************************************************/
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;
}
}
*/
- 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;
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;
@@ -162,196 +176,200 @@ bool QCopTransferItem::appMessage( const QCString& cmsg, const QByteArray& data
return false;
}
/*********************************************************************************
*
********************************************************************************/
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());
//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
}
/*********************************************************************************/
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;
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)";
}
/*********************************************************************************/
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
e << uid << list1 << list2 << list3;
+ 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 );
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;
stream >> uid >> list1 >> list2 >> list3;
emit receivedMessageFromTarget(uid, list1, list2, list3);
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&)));
//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()
{
mDefaultItems.clear();
mEmailAppAvailable = UNDEFINED;
mPhoneAppAvailable = UNDEFINED;
mFaxAppAvailable = UNDEFINED;
mSMSAppAvailable = UNDEFINED;
mPagerAppAvailable = 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);
@@ -957,42 +975,42 @@ void ExternalAppHandler::appMessage( const QCString& cmsg, const QByteArray& dat
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)
{
mNameEmailUidListFromKAPITransfer->setSourceChannel(sourceChannel);
return mNameEmailUidListFromKAPITransfer->sendMessageToSource(sessionuid, list1, list2, list3);
}
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)
{
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);
}
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h
index a74080f..1b04b2b 100644
--- a/libkdepim/externalapphandler.h
+++ b/libkdepim/externalapphandler.h
@@ -169,72 +169,72 @@ class ExternalAppHandler : public QObject
//calls the emailapplication with a number of attachments that need to be send.
//either parameter can be left empty.
bool mailToMultipleContacts( const QString& recipients, const QString& attachmenturls );
//calls the emailapplication and creates a mail with parameter emailadress as recipients
bool mailToOneContact( const QString& name, const QString& emailadress );
//calls the emailapplication and creates a mail with parameter as recipients
// 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 );
bool isEmailAppAvailable();
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);
+ 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& uid, const QStringList& name, const QStringList& email, const QStringList& uid);
+ bool returnNameEmailUidListFromKAPI(const QString& sourceChannel, const QString& sessionuid, 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 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& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
+ bool requestDetailsFromKAPI(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);
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 requestForDetails(const QString& sourceChannel, const QString& sessionuid, const QString& name, const QString& email, const QString& uid);
private:
ExternalAppHandler();
QList<DefaultAppItem> mDefaultItems;
Availability mEmailAppAvailable;
Availability mPhoneAppAvailable;