summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.cpp
Side-by-side diff
Diffstat (limited to 'libkdepim/externalapphandler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp30
1 files changed, 16 insertions, 14 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index f376e6c..3fc548a 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -18,49 +18,51 @@
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 <qtimer.h>
#include <qmap.h>
#include <qregexp.h>
#ifndef DESKTOP_VERSION
#include <qpe/qpeapplication.h>
#include <qtopia/qcopenvelope_qws.h>
#else
#include <qapplication.h>
-#include <qprocess.h>
+#include <q3process.h>
+//Added by qt3to4:
+#include <Q3CString>
#endif
#include <kstaticdeleter.h>
#include <kmessagebox.h>
#include "externalapphandler.h"
#include "kpimglobalprefs.h"
//uncomment line to get debug output
//#define DEBUG_EXT_APP_HANDLER
/*********************************************************************************
*
********************************************************************************/
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)";
@@ -102,72 +104,72 @@ bool QCopTransferItem::sendMessageToTarget(const QString& uid, const QString& pa
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 )
+bool QCopTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
{
// 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() );
//we are in the target and get a request from the source
if ( (_sourceMessage + _sourceMessageParameters) == cmsg.data())
{
- QDataStream stream( data, IO_ReadOnly );
+ QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::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);
}
@@ -205,55 +207,55 @@ bool QCopMapTransferItem::sendMessageToSource(const QString& uid, const QMap<QSt
#ifdef DEBUG_EXT_APP_HANDLER
qDebug("2Using QCopEnvelope e(\"%s\",\"%s\")", _sourceChannel.latin1(), targetMessage.latin1());
qDebug("passing uid(%s) and map as parameter to QCopEnvelope", uid.latin1());
#endif
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 QCopMapTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
{
bool res = QCopTransferItem::appMessage( cmsg, data );
if (res == false)
{
- QDataStream stream( data, IO_ReadOnly );
+ QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::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;
}
/*********************************************************************************
*
@@ -284,58 +286,58 @@ bool QCopListTransferItem::sendMessageToSource(const QString& uid, const QString
for ( int i = 0; i < list3.count(); i++)
qDebug("listentry list3: %s",list3[i].latin1());
#endif
QCopEnvelope e(_sourceChannel.latin1(), targetMessage.latin1());
//US we need no names in the To field. The emailadresses are enough
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 QCopListTransferItem::appMessage( const Q3CString& cmsg, const QByteArray& data )
{
bool res = QCopTransferItem::appMessage( cmsg, data );
#ifdef DEBUG_EXT_APP_HANDLER
qDebug("1QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
#endif
if (res == false)
{
- QDataStream stream( data, IO_ReadOnly );
+ QDataStream stream( const_cast<QByteArray*>(&data), QIODevice::ReadOnly );
#ifdef DEBUG_EXT_APP_HANDLER
qDebug("2QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
#endif
//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;
#ifdef DEBUG_EXT_APP_HANDLER
qDebug("3QCopListTransferItem- QCOP message received: %s ", cmsg.data() );
#endif
stream >> uid >> list1 >> list2 >> list3 >> list4 >> list5 >> list6;
emit receivedMessageFromTarget(uid, list1, list2, list3, list4, list5, list6);
@@ -497,51 +499,51 @@ void ExternalAppHandler::loadConfig()
if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
( QFile::exists( opiepath + "/bin/kppi" )))
addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::KPPI_SIC, "KP/Pi SIP client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
}
ExternalAppHandler *ExternalAppHandler::instance()
{
if ( !sInstance ) {
sInstance = staticDeleter.setObject( new ExternalAppHandler() );
sInstance->loadConfig();
}
return sInstance;
}
void ExternalAppHandler::addDefaultAppItem(Types type, int id, const QString& label, const QString& channel, const QString& message, const QString& parameter, const QString& message2, const QString& parameter2)
{
DefaultAppItem* dai = new DefaultAppItem(type, id, label, channel, message, parameter, message2, parameter2);
// qDebug("%d %d %s %s ", type, id, label.latin1(), channel.latin1() );
mDefaultItems.append(dai);
}
-QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
+Q3PtrList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
{
- QList<DefaultAppItem> list;
+ Q3PtrList<DefaultAppItem> list;
DefaultAppItem* dai;
for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
{
if (dai->_type == type)
list.append(dai);
}
return list;
}
DefaultAppItem* ExternalAppHandler::getDefaultItem(Types type, int clientid)
{
DefaultAppItem* dai;
for ( dai=mDefaultItems.first(); dai != 0; dai=mDefaultItems.next() )
{
if (dai->_type == type && dai->_id == clientid)
return dai;
}
return 0;
}
@@ -725,75 +727,75 @@ bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QS
}
else
{
DefaultAppItem* dai = getDefaultItem(EMAIL, client);
if (!dai)
{
qDebug("could not find configured email application.");
return false;
}
channel = dai->_channel;
message2 = dai->_message2;
parameters2 = dai->_parameters2;
message = dai->_message;
parameters = dai->_parameters;
}
//first check if one of the mailers need the emails right in the message.
message2 = translateMessage(message2, emails, urls);
#ifdef DEBUG_EXT_APP_HANDLER
qDebug("4Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
qDebug("passing emailadresses(%s), attachmenturls(%s) as parameters in the form %s to QCopEnvelope", emails.latin1() , urls.latin1(), parameters2.latin1());
#endif
qDebug("%s --- %s %s --- %s %s", channel.latin1(), message.latin1(),message2.latin1(), parameters.latin1(), parameters2.latin1() );
//KMessageBox::sorry( 0, message2 );
- QProcess * proc = new QProcess( this );
+ Q3Process * proc = new Q3Process( this );
int i = 0;
proc->addArgument( channel );
if ( message.find (" " ) > 0 ) {
QStringList list = QStringList::split( " ", message );
int i = 0;
while ( i < list.count ( ) ) {
//qDebug("add%sdd ",list[i].latin1() );
proc->addArgument( list[i] );
//KMessageBox::sorry( 0,list[i]);
++i;
}
} else {
proc->addArgument(message );
//KMessageBox::sorry( 0, message );
}
parameters2 = translateMessage(parameters2, urls, "" );
QString arg = "to='%1'";
arg = arg.arg( emails ) + ","+parameters2;;
//KMessageBox::sorry( 0,arg );
//qDebug("2add%sdd ",arg.latin1() );
proc->addArgument( arg);
- proc->launch("");
+ proc->launch(QString());
#endif
return true;
}
/**************************************************************************
*
**************************************************************************/
//calls the emailapplication and creates a mail with parameter emails as recipients
bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& emailadress )
{
QString channel;
QString message;
QString parameters;
int client = KPimGlobalPrefs::instance()->mEmailClient;
if (client == KPimGlobalPrefs::OTHER_EMC)
{
channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
@@ -810,68 +812,68 @@ bool ExternalAppHandler::mailToOneContact( const QString& name, const QString& e
channel = dai->_channel;
message = dai->_message;
parameters = dai->_parameters;
}
#ifdef DESKTOP_VERSION
//message = channel + " " +message + " \""+ parameters + "\"";
#endif
//first check if one of the mailers need the emails right in the message.
message = translateMessage(message, name, emailadress);
#ifdef DEBUG_EXT_APP_HANDLER
qDebug("5Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
qDebug("passing name(%s), emailadresses(%s) as parameters in the form %s to QCopEnvelope", name.latin1(), emailadress.latin1(), parameters.latin1());
#endif
#ifndef DESKTOP_VERSION
QCopEnvelope e(channel.latin1(), message.latin1());
//US we need no names in the To field. The emailadresses are enough
passParameters(&e, parameters, name, emailadress);
#else // DESKTOP_VERSION
//KMessageBox::sorry( 0,channel );
- QProcess * proc = new QProcess( this );
+ Q3Process * proc = new Q3Process( this );
proc->addArgument( channel );
if ( message.find (" " ) > 0 ) {
QStringList list = QStringList::split( " ", message );
int i = 0;
while ( i < list.count ( ) ) {
//qDebug("add%sdd ",list[i].latin1() );
proc->addArgument( list[i] );
//KMessageBox::sorry( 0,list[i]);
++i;
}
} else {
proc->addArgument(message );
}
parameters = translateMessage(parameters, name, emailadress);
//KMessageBox::information(0,parameters);
proc->addArgument( parameters );
- proc->launch("");
+ proc->launch(QString());
#endif
return true;
}
/**************************************************************************
*
**************************************************************************/
//calls the emailapplication and creates a mail with parameter as recipients
// parameters format is
// NAME <EMAIL>:SUBJECT
bool ExternalAppHandler::mailToOneContact( const QString& adressline )
{
QString line = adressline;
int first = line.find( "<");
int last = line.find( ">");
QString name = line.left(first);
QString emailadress = line.mid(first+1, last-first-1);
//Subject can not be handled right now.
return mailToOneContact( name, emailadress );
@@ -1211,49 +1213,49 @@ void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& paramete
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 )
+void ExternalAppHandler::appMessage( const Q3CString& cmsg, const QByteArray& data )
{
qDebug("ExternalAppHandler::appMessage %s %x", cmsg.data(), this);
if ( cmsg == "nextView()" ) {
qDebug("nextView()");
QTimer::singleShot( 0, this, SIGNAL ( nextView() ));
return;
}
if ( cmsg == "callContactdialog()" ) {
qDebug("callContactdialog()");
QTimer::singleShot( 0, this, SIGNAL ( callContactdialog() ));
return;
}
if ( cmsg == "doRingSync" ) {
qDebug("doRingSync");
QTimer::singleShot( 0, this, SIGNAL ( doRingSync() ));
return;
}
bool res = mNameEmailUidListFromKAPITransfer->appMessage( cmsg, data );
if (!res)
res = mBirthdayListFromKAPITransfer->appMessage( cmsg, data );
if (!res)
res = mDisplayDetails->appMessage( cmsg, data );