summaryrefslogtreecommitdiffabout
path: root/libkdepim
authorulf69 <ulf69>2004-08-10 16:10:42 (UTC)
committer ulf69 <ulf69>2004-08-10 16:10:42 (UTC)
commitc56c4729e32a9c8ba8709493b3ea11cf7cf229d3 (patch) (side-by-side diff)
tree10072e3a37eb3dca26482e67c08229bd2a1cbba6 /libkdepim
parentc9d570427f3d5bead7bee1301514a2d4b82836ea (diff)
downloadkdepimpi-c56c4729e32a9c8ba8709493b3ea11cf7cf229d3.zip
kdepimpi-c56c4729e32a9c8ba8709493b3ea11cf7cf229d3.tar.gz
kdepimpi-c56c4729e32a9c8ba8709493b3ea11cf7cf229d3.tar.bz2
additional files for external application configuration
Diffstat (limited to 'libkdepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/externalapphandler.cpp526
-rw-r--r--libkdepim/externalapphandler.h120
-rw-r--r--libkdepim/kpimglobalprefs.cpp89
-rw-r--r--libkdepim/kpimglobalprefs.h112
4 files changed, 847 insertions, 0 deletions
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
new file mode 100644
index 0000000..6f812d0
--- a/dev/null
+++ b/libkdepim/externalapphandler.cpp
@@ -0,0 +1,526 @@
+/*
+ This file is part of libkdepim.
+ Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ 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 <qtopia/qcopenvelope_qws.h>
+
+
+#include <kstaticdeleter.h>
+
+
+#include "externalapphandler.h"
+
+#include "kpimglobalprefs.h"
+
+
+
+
+
+
+
+ExternalAppHandler *ExternalAppHandler::sInstance = 0;
+static KStaticDeleter<ExternalAppHandler> staticDeleter;
+
+
+ExternalAppHandler::ExternalAppHandler()
+{
+ mDefaultItems.setAutoDelete(true);
+}
+
+ExternalAppHandler::~ExternalAppHandler()
+{
+}
+
+void ExternalAppHandler::loadConfig()
+{
+ mDefaultItems.clear();
+
+
+
+ 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 = "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", "newMail(QString)", "%1", mailmsg2, "ATTACHMENT=%1");
+
+ if ( QFile::exists( qtopiapath + "/bin/qtmail" ))
+ addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::QTOPIA_EMC, "Qtopia email client", "QPE/Application/qtmail", mailmsg1, ";%1", mailmsg2, "ATTACHMENT=%1");
+
+ if ( QFile::exists( opiepath + "/bin/opiemail" ))
+ addDefaultAppItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::OPIE_EMC, "Opie email client", "QPE/Application/opiemail", mailmsg1, ";%1", mailmsg2, "ATTACHMENT=%1");
+
+
+
+ //phoneclients
+
+ addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC, "No phone client installed", undefined, undefined, undefined, undefined, undefined);
+ addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::OTHER_PHC, "Other phone client", undefined, undefined, undefined, undefined, undefined);
+ if (( QFile::exists( qtopiapath + "/bin/kppi" )) ||
+ ( QFile::exists( opiepath + "/bin/kppi" )))
+ addDefaultAppItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::KPPI_PHC, "KP/Pi phone client", "QPE/Application/kppi", "-ring:%1", "", undefined, undefined);
+
+ //faxclients
+ addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC, "No fax client installed", undefined, undefined, undefined, undefined, undefined);
+ addDefaultAppItem(ExternalAppHandler::FAX, KPimGlobalPrefs::OTHER_FAC, "Other fax client", undefined, undefined, undefined, undefined, undefined);
+
+ //smsclients
+ addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC, "No sms client installed", undefined, undefined, undefined, undefined, undefined);
+ addDefaultAppItem(ExternalAppHandler::SMS, KPimGlobalPrefs::OTHER_SMC, "Other sms client", undefined, undefined, undefined, undefined, undefined);
+
+ //pagerclients
+ addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC, "No pager client installed", undefined, undefined, undefined, undefined, undefined);
+ addDefaultAppItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::OTHER_PAC, "Other pager client", undefined, undefined, undefined, 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);
+
+ mDefaultItems.append(dai);
+}
+
+
+QList<DefaultAppItem> ExternalAppHandler::getAvailableDefaultItems(Types type)
+{
+ QList<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;
+}
+
+
+
+//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
+bool ExternalAppHandler::mailAttachments( const QString& urls )
+{
+#ifndef QT_NO_COP
+ QString channel;
+ QString message2;
+ QString parameters2;
+
+
+ int client = KPimGlobalPrefs::instance()->mEmailClient;
+ if (client == KPimGlobalPrefs::OTHER_EMC)
+ {
+ channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
+ message2 = KPimGlobalPrefs::instance()->mEmailOtherMessage;
+ parameters2 = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
+ }
+ 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;
+ }
+
+
+ qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message2.latin1());
+ qDebug("passing attachmenturls:(%s) as parameter in the form %s to QCopEnvelope", urls.latin1(), parameters2.latin1());
+
+ QCopEnvelope e(channel.latin1(), message2.latin1());
+ //US we need no names in the To field. The emailadresses are enough
+
+ passParameter(&e, parameters2, urls);
+
+
+#else
+ KMessageBox::sorry( this, i18n( "This version does not support the sending of emails." ) );
+#endif
+
+ return true;
+}
+
+
+
+//calls the emailapplication and creates a mail with parameter emails as recipients
+bool ExternalAppHandler::mailToContacts( const QString& emails )
+{
+#ifndef QT_NO_COP
+ QString channel;
+ QString message;
+ QString parameters;
+
+
+ int client = KPimGlobalPrefs::instance()->mEmailClient;
+ if (client == KPimGlobalPrefs::OTHER_EMC)
+ {
+ channel = KPimGlobalPrefs::instance()->mEmailOtherChannel;
+ message = KPimGlobalPrefs::instance()->mEmailOtherMessage;
+ parameters = KPimGlobalPrefs::instance()->mEmailOtherMessageParameters;
+ }
+ else
+ {
+ DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(EMAIL, client);
+ if (!dai)
+ {
+ qDebug("could not find configured email application.");
+ return false;
+ }
+ channel = dai->_channel;
+ message = dai->_message;
+ parameters = dai->_parameters;
+ }
+
+
+ //first check if one of the mailers need the emails right in the message.
+ message = translateMessage(message, emails);
+
+
+ qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
+ qDebug("passing emailadresses:(%s) as parameter in the form %s to QCopEnvelope", emails.latin1(), parameters.latin1());
+
+ QCopEnvelope e(channel.latin1(), message.latin1());
+ //US we need no names in the To field. The emailadresses are enough
+
+ passParameter(&e, parameters, emails);
+
+
+#else
+ KMessageBox::sorry( this, i18n( "This version does not support the sending of emails." ) );
+#endif
+
+
+ return true;
+}
+
+
+//calls the phoneapplication with the number
+bool ExternalAppHandler::callByPhone( const QString& phonenumber )
+{
+#ifndef QT_NO_COP
+ QString channel;
+ QString message;
+ QString parameters;
+
+
+ int client = KPimGlobalPrefs::instance()->mPhoneClient;
+ if (client == KPimGlobalPrefs::OTHER_PHC)
+ {
+ channel = KPimGlobalPrefs::instance()->mPhoneOtherChannel;
+ message = KPimGlobalPrefs::instance()->mPhoneOtherMessage;
+ parameters = KPimGlobalPrefs::instance()->mPhoneOtherMessageParameters;
+ }
+ else
+ {
+ DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PHONE, client);
+ if (!dai)
+ {
+ qDebug("could not find configured phone application.");
+ return false;
+ }
+ channel = dai->_channel;
+ message = dai->_message;
+ parameters = dai->_parameters;
+ }
+
+
+ //first check if one of the mailers need the emails right in the message.
+ message = translateMessage(message, phonenumber);
+
+
+ qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
+ qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
+
+ QCopEnvelope e(channel.latin1(), message.latin1());
+ //US we need no names in the To field. The emailadresses are enough
+
+ passParameter(&e, parameters, phonenumber);
+
+
+#else
+ KMessageBox::sorry( this, i18n( "This version does not support phonecalls." ) );
+#endif
+
+
+ return true;
+}
+
+//calls the smsapplication with the number
+bool ExternalAppHandler::callBySMS( const QString& phonenumber )
+{
+#ifndef QT_NO_COP
+ QString channel;
+ QString message;
+ QString parameters;
+
+
+ int client = KPimGlobalPrefs::instance()->mSMSClient;
+ if (client == KPimGlobalPrefs::OTHER_SMC)
+ {
+ channel = KPimGlobalPrefs::instance()->mSMSOtherChannel;
+ message = KPimGlobalPrefs::instance()->mSMSOtherMessage;
+ parameters = KPimGlobalPrefs::instance()->mSMSOtherMessageParameters;
+ }
+ else
+ {
+ DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SMS, client);
+ if (!dai)
+ {
+ qDebug("could not find configured sms application.");
+ return false;
+ }
+ channel = dai->_channel;
+ message = dai->_message;
+ parameters = dai->_parameters;
+ }
+
+
+ //first check if one of the mailers need the emails right in the message.
+ message = translateMessage(message, phonenumber);
+
+
+ qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
+ qDebug("passing phonenumber:(%s) as parameter in the form %s to QCopEnvelope", phonenumber.latin1(), parameters.latin1());
+
+ QCopEnvelope e(channel.latin1(), message.latin1());
+ //US we need no names in the To field. The emailadresses are enough
+
+ passParameter(&e, parameters, phonenumber);
+
+
+#else
+ KMessageBox::sorry( this, i18n( "This version does not support the sending of sms." ) );
+#endif
+
+
+ return true;
+}
+
+//calls the pagerapplication with the number
+bool ExternalAppHandler::callByPager( const QString& pagernumber )
+{
+#ifndef QT_NO_COP
+ QString channel;
+ QString message;
+ QString parameters;
+
+
+ int client = KPimGlobalPrefs::instance()->mPagerClient;
+ if (client == KPimGlobalPrefs::OTHER_PAC)
+ {
+ channel = KPimGlobalPrefs::instance()->mPagerOtherChannel;
+ message = KPimGlobalPrefs::instance()->mPagerOtherMessage;
+ parameters = KPimGlobalPrefs::instance()->mPagerOtherMessageParameters;
+ }
+ else
+ {
+ DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(PAGER, client);
+ if (!dai)
+ {
+ qDebug("could not find configured pager application.");
+ return false;
+ }
+ channel = dai->_channel;
+ message = dai->_message;
+ parameters = dai->_parameters;
+ }
+
+
+ //first check if one of the mailers need the emails right in the message.
+ message = translateMessage(message, pagernumber);
+
+
+ qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
+ qDebug("passing pagernumber:(%s) as parameter in the form %s to QCopEnvelope", pagernumber.latin1(), parameters.latin1());
+
+ QCopEnvelope e(channel.latin1(), message.latin1());
+ //US we need no names in the To field. The emailadresses are enough
+
+ passParameter(&e, parameters, pagernumber);
+
+
+#else
+ KMessageBox::sorry( this, i18n( "This version does not support paging." ) );
+#endif
+
+
+ return true;
+}
+
+//calls the faxapplication with the number
+bool ExternalAppHandler::callByFax( const QString& faxnumber )
+{
+#ifndef QT_NO_COP
+ QString channel;
+ QString message;
+ QString parameters;
+
+
+ int client = KPimGlobalPrefs::instance()->mFaxClient;
+ if (client == KPimGlobalPrefs::OTHER_FAC)
+ {
+ channel = KPimGlobalPrefs::instance()->mFaxOtherChannel;
+ message = KPimGlobalPrefs::instance()->mFaxOtherMessage;
+ parameters = KPimGlobalPrefs::instance()->mFaxOtherMessageParameters;
+ }
+ else
+ {
+ DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(FAX, client);
+ if (!dai)
+ {
+ qDebug("could not find configured fax application.");
+ return false;
+ }
+ channel = dai->_channel;
+ message = dai->_message;
+ parameters = dai->_parameters;
+ }
+
+
+ //first check if one of the mailers need the emails right in the message.
+ message = translateMessage(message, faxnumber);
+
+
+ qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
+ qDebug("passing faxnumber:(%s) as parameter in the form %s to QCopEnvelope", faxnumber.latin1(), parameters.latin1());
+
+ QCopEnvelope e(channel.latin1(), message.latin1());
+ //US we need no names in the To field. The emailadresses are enough
+
+ passParameter(&e, parameters, faxnumber);
+
+
+#else
+ KMessageBox::sorry( this, i18n( "This version does not support the sending of faxes." ) );
+#endif
+
+
+ return true;
+}
+
+
+
+
+
+
+QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1) const
+{
+ return message.replace( QRegExp("%1"), param1 );
+}
+
+void ExternalAppHandler::passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const
+{
+ QMap<QString, QString> valmap;
+ bool useValMap = false;
+
+ // first extract all parts of the parameters.
+ QStringList paramlist = QStringList::split(";", parameters);
+
+ //Now check how many parts we have.
+ //=0 :no params to pass
+ //>0 :parameters to pass
+ for ( QStringList::Iterator it = paramlist.begin(); it != paramlist.end(); ++it )
+ {
+ QString param = (*it);
+ QStringList keyvallist = QStringList::split("=", param);
+
+ //if we have keyvalue pairs, we assume that we pass a map to the envelope
+ QStringList::Iterator it2 = keyvallist.begin();
+ QString key = (*it2);
+ key = key.replace( QRegExp("%1"), param1 );
+ ++it2;
+
+ if(it2 != keyvallist.end())
+ {
+ QString value = (*it2);
+ value = value.replace( QRegExp("%1"), param1 );
+
+ valmap.insert(key, value);
+ useValMap = true;
+ }
+ else
+ {
+ (*e) << key.latin1();
+ }
+ }
+
+ if (useValMap == true)
+ (*e) << valmap;
+
+
+
+}
+
+
+
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h
new file mode 100644
index 0000000..3ecf1b1
--- a/dev/null
+++ b/libkdepim/externalapphandler.h
@@ -0,0 +1,120 @@
+/*
+ This file is part of libkdepim.
+ Copyright (c) 2004 Ulf Schenk
+
+ 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$
+*/
+
+#ifndef EXTERNALAPPHANDLER_H
+#define EXTERNALAPPHANDLER_H
+
+#include <qlist.h>
+
+class QCopEnvelope;
+
+
+class ExternalAppHandler;
+
+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 ;
+
+};
+
+class ExternalAppHandler
+{
+ public:
+ virtual ~ExternalAppHandler();
+
+ static ExternalAppHandler *instance();
+
+ enum Types {
+ EMAIL = 0,
+ PHONE = 1,
+ SMS = 2,
+ FAX = 3,
+ PAGER = 4
+ };
+
+ //calls the emailapplication with a number of attachments that need to be send
+ bool mailAttachments( const QString& urls );
+
+ //calls the emailapplication and creates a mail with parameter emails as recipients
+ bool mailToContacts( const QString& emails );
+
+ //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 );
+
+
+ //loadConfig clears the cache and checks again if the applications are available or not
+ void loadConfig();
+
+ QList<DefaultAppItem> getAvailableDefaultItems(Types);
+ DefaultAppItem* getDefaultItem(Types, int);
+
+
+ private:
+ ExternalAppHandler();
+ QList<DefaultAppItem> mDefaultItems;
+
+
+ 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& emails) const;
+ void passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const;
+
+
+ static ExternalAppHandler *sInstance;
+
+
+};
+
+#endif
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
new file mode 100644
index 0000000..4790980
--- a/dev/null
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -0,0 +1,89 @@
+/*
+ This file is part of libkdepim.
+ Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
+
+ 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 <kglobal.h>
+#include <kconfig.h>
+#include <klocale.h>
+#include <kdebug.h>
+#include <kstaticdeleter.h>
+
+#include "kpimglobalprefs.h"
+
+KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0;
+static KStaticDeleter<KPimGlobalPrefs> staticDeleter;
+
+
+KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
+ : KPrefs("kkdepimrc")
+{
+ KPrefs::setCurrentGroup( "ExternalApplications" );
+
+ addItemInt( "EmailChannelType", &mEmailClient, NONE_EMC );
+ addItemString( "EmailChannel", &mEmailOtherChannel, "" );
+ addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" );
+ addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" );
+ addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" );
+ addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" );
+
+ addItemInt( "PhoneChannelType", &mPhoneClient, NONE_PHC );
+ addItemString( "PhoneChannel", &mPhoneOtherChannel, "" );
+ addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" );
+ addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" );
+
+ addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC );
+ addItemString( "FaxChannel", &mFaxOtherChannel, "" );
+ addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" );
+ addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" );
+
+ addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC );
+ addItemString( "SMSChannel", &mSMSOtherChannel, "" );
+ addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" );
+ addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" );
+
+ addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC );
+ addItemString( "PagerChannel", &mPagerOtherChannel, "" );
+ addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" );
+ addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" );
+
+}
+
+KPimGlobalPrefs::~KPimGlobalPrefs()
+{
+}
+
+KPimGlobalPrefs *KPimGlobalPrefs::instance()
+{
+ if ( !sInstance ) {
+ sInstance = staticDeleter.setObject( new KPimGlobalPrefs() );
+ sInstance->readConfig();
+ }
+
+ return sInstance;
+}
diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h
new file mode 100644
index 0000000..80b2c4f
--- a/dev/null
+++ b/libkdepim/kpimglobalprefs.h
@@ -0,0 +1,112 @@
+/*
+ This file is part of libkdepim.
+ Copyright (c) 2004 Ulf Schenk
+
+ 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$
+*/
+
+#ifndef KPIMGLOBALPREFS_H
+#define KPIMGLOBALPREFS_H
+
+#include "kprefs.h"
+
+class KPimGlobalPrefs : public KPrefs
+{
+ public:
+
+ static KPimGlobalPrefs *instance();
+
+
+ virtual ~KPimGlobalPrefs();
+
+
+ enum EMailClients {
+ NONE_EMC = 0,
+ OTHER_EMC = 1,
+ OMPI_EMC = 2,
+ QTOPIA_EMC = 3,
+ OPIE_EMC = 4
+ };
+
+ enum PhoneClients {
+ NONE_PHC = 0,
+ OTHER_PHC = 1,
+ KPPI_PHC = 2
+ };
+
+ enum FaxClients {
+ NONE_FAC = 0,
+ OTHER_FAC = 1
+ };
+
+ enum SMSClients {
+ NONE_SMC = 0,
+ OTHER_SMC = 1
+ };
+
+ enum PagerClients {
+ NONE_PAC = 0,
+ OTHER_PAC = 1
+ };
+
+ private:
+ KPimGlobalPrefs( const QString &name = QString::null );
+
+ static KPimGlobalPrefs *sInstance;
+
+
+ public:
+ int mEmailClient;
+ QString mEmailOtherChannel;
+ QString mEmailOtherMessage;
+ QString mEmailOtherMessageParameters;
+ QString mEmailOtherMessage2;
+ QString mEmailOtherMessageParameters2;
+
+ int mPhoneClient;
+ QString mPhoneOtherChannel;
+ QString mPhoneOtherMessage;
+ QString mPhoneOtherMessageParameters;
+
+ int mFaxClient;
+ QString mFaxOtherChannel;
+ QString mFaxOtherMessage;
+ QString mFaxOtherMessageParameters;
+
+ int mSMSClient;
+ QString mSMSOtherChannel;
+ QString mSMSOtherMessage;
+ QString mSMSOtherMessageParameters;
+
+ int mPagerClient;
+ QString mPagerOtherChannel;
+ QString mPagerOtherMessage;
+ QString mPagerOtherMessageParameters;
+
+
+};
+
+#endif