summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libkdepim/addresseeview.cpp6
-rw-r--r--libkdepim/externalapphandler.cpp81
-rw-r--r--libkdepim/externalapphandler.h8
3 files changed, 93 insertions, 2 deletions
diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp
index 5c69010..b4717d7 100644
--- a/libkdepim/addresseeview.cpp
+++ b/libkdepim/addresseeview.cpp
@@ -68,34 +68,37 @@ void AddresseeView::setSource(const QString& n)
//qDebug("********AddresseeView::setSource %s", n.latin1());
if ( n.left( 6 ) == "mailto" )
ExternalAppHandler::instance()->mailToOneContact( n.mid(7) );
else if ( n.left( 7 ) == "phoneto" )
ExternalAppHandler::instance()->callByPhone( n.mid(8) );
else if ( n.left( 5 ) == "faxto" )
ExternalAppHandler::instance()->callByFax( n.mid(6) );
else if ( n.left( 5 ) == "smsto" )
ExternalAppHandler::instance()->callBySMS( n.mid(6) );
else if ( n.left( 7 ) == "pagerto" )
ExternalAppHandler::instance()->callByPager( n.mid(8) );
+ else if ( n.left( 5 ) == "sipto" )
+ ExternalAppHandler::instance()->callBySIP( n.mid(6) );
}
void AddresseeView::setAddressee( const KABC::Addressee& addr )
{
ExternalAppHandler* eah = ExternalAppHandler::instance();
bool kemailAvail = eah->isEmailAppAvailable();
bool kphoneAvail = eah->isPhoneAppAvailable();
bool kfaxAvail = eah->isFaxAppAvailable();
bool ksmsAvail = eah->isSMSAppAvailable();
bool kpagerAvail = eah->isPagerAppAvailable();
+ bool ksipAvail = eah->isSIPAppAvailable();
mAddressee = addr;
// clear view
setText( QString::null );
if ( mAddressee.isEmpty() )
return;
QString name = ( mAddressee.assembledName().isEmpty() ?
mAddressee.formattedName() : mAddressee.assembledName() );
@@ -150,24 +153,27 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr )
}
else
sms = "";
extension = QString::null;
if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
if (kfaxAvail) extension = "faxto:";
}
else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
if (kpagerAvail) extension = "pagerto:";
}
+ else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
+ if (ksipAvail) extension = "sipto:";
+ }
else if (kphoneAvail) {
extension = "phoneto:";
}
else
extension = QString::null;
if ( !extension.isEmpty() ) {
dynamicPart += QString(
"<tr><td align=\"right\"><b>%1</b></td>"
"<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
.arg( KABC::PhoneNumber::typeLabel( phonetype ) )
.arg( extension )
diff --git a/libkdepim/externalapphandler.cpp b/libkdepim/externalapphandler.cpp
index 5ba32b6..fa56ee9 100644
--- a/libkdepim/externalapphandler.cpp
+++ b/libkdepim/externalapphandler.cpp
@@ -346,25 +346,25 @@ ExternalAppHandler::~ExternalAppHandler()
{
}
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 = "";
@@ -395,24 +395,28 @@ void ExternalAppHandler::loadConfig()
//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);
+ //sipclients
+ addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC, "No sip client installed", undefined, undefined, undefined, undefined, undefined);
+ addDefaultAppItem(ExternalAppHandler::SIP, KPimGlobalPrefs::OTHER_SIC, "Other sip client", undefined, undefined, undefined, undefined, undefined);
+
}
ExternalAppHandler *ExternalAppHandler::instance()
{
if ( !sInstance ) {
sInstance = staticDeleter.setObject( new ExternalAppHandler() );
sInstance->loadConfig();
}
return sInstance;
}
@@ -533,24 +537,43 @@ bool ExternalAppHandler::isPagerAppAvailable()
if (client == KPimGlobalPrefs::NONE_PAC)
mPagerAppAvailable = UNAVAILABLE;
else
mPagerAppAvailable = AVAILABLE;
}
return (mPagerAppAvailable == AVAILABLE);
#else //DESKTOP_VERSION
return false;
#endif //DESKTOP_VERSION
}
+
+bool ExternalAppHandler::isSIPAppAvailable()
+{
+#ifndef DESKTOP_VERSION
+ if (mSIPAppAvailable == UNDEFINED)
+ {
+ int client = KPimGlobalPrefs::instance()->mSipClient;
+ if (client == KPimGlobalPrefs::NONE_SIC)
+ mSIPAppAvailable = UNAVAILABLE;
+ else
+ mSIPAppAvailable = AVAILABLE;
+ }
+
+ return (mSIPAppAvailable == AVAILABLE);
+#else //DESKTOP_VERSION
+ return false;
+#endif //DESKTOP_VERSION
+}
+
/**************************************************************************
*
**************************************************************************/
//calls the emailapplication with a number of attachments that need to be send (Seperated by Comma)
bool ExternalAppHandler::mailToMultipleContacts( const QString& emails, const QString& urls )
{
#ifndef DESKTOP_VERSION
QString channel;
QString message2;
@@ -892,24 +915,80 @@ bool ExternalAppHandler::callByFax( const QString& faxnumber )
#else
KMessageBox::sorry( 0, i18n( "This version does not support the sending of faxes." ) );
#endif
return true;
}
/**************************************************************************
*
**************************************************************************/
+//calls the sipapplication with the number
+bool ExternalAppHandler::callBySIP( const QString& sipnumber )
+{
+#ifndef DESKTOP_VERSION
+ QString channel;
+ QString message;
+ QString parameters;
+
+
+ int client = KPimGlobalPrefs::instance()->mSipClient;
+ if (client == KPimGlobalPrefs::OTHER_SIC)
+ {
+ channel = KPimGlobalPrefs::instance()->mSipOtherChannel;
+ message = KPimGlobalPrefs::instance()->mSipOtherMessage;
+ parameters = KPimGlobalPrefs::instance()->mSipOtherMessageParameters;
+ }
+ else
+ {
+ DefaultAppItem* dai = ExternalAppHandler::getDefaultItem(SIP, client);
+ if (!dai)
+ {
+ qDebug("could not find configured sip application.");
+ return false;
+ }
+ channel = dai->_channel;
+ message = dai->_message;
+ parameters = dai->_parameters;
+ }
+
+
+ //first check if one of the sip apps need the emails right in the message.
+ message = translateMessage(message, sipnumber, "");
+
+
+ qDebug("Using QCopEnvelope e(\"%s\",\"%s\")", channel.latin1(), message.latin1());
+ qDebug("passing sipnumber(%s) as parameter in the form %s to QCopEnvelope", sipnumber.latin1(), parameters.latin1());
+
+ QCopEnvelope e(channel.latin1(), message.latin1());
+ //US we need no names in the To field. The emailadresses are enough
+
+ passParameters(&e, parameters, sipnumber, "");
+
+
+#else
+ KMessageBox::sorry( 0, i18n( "This version does not support sip." ) );
+#endif
+
+
+ return true;
+}
+
+
+/**************************************************************************
+ *
+ **************************************************************************/
+
QString& ExternalAppHandler::translateMessage(QString& message, const QString& param1, const QString& param2 ) const
{
message = message.replace( QRegExp("%1"), param1 );
return message.replace( QRegExp("%2"), param2 );
}
/**************************************************************************
*
**************************************************************************/
void ExternalAppHandler::passParameters(QCopEnvelope* e, const QString& parameters, const QString& param1 , const QString& param2) const
diff --git a/libkdepim/externalapphandler.h b/libkdepim/externalapphandler.h
index 1b04b2b..cfe577b 100644
--- a/libkdepim/externalapphandler.h
+++ b/libkdepim/externalapphandler.h
@@ -148,25 +148,26 @@ class ExternalAppHandler : public QObject
{
Q_OBJECT
public:
virtual ~ExternalAppHandler();
static ExternalAppHandler *instance();
enum Types {
EMAIL = 0,
PHONE = 1,
SMS = 2,
FAX = 3,
- PAGER = 4
+ PAGER = 4,
+ SIP = 5
};
enum Availability {
UNDEFINED = -1,
UNAVAILABLE = 0,
AVAILABLE = 1
};
//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 );
@@ -181,29 +182,33 @@ class ExternalAppHandler : public QObject
//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);
@@ -232,24 +237,25 @@ class ExternalAppHandler : public QObject
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;
Availability mFaxAppAvailable;
Availability mSMSAppAvailable;
Availability mPagerAppAvailable;
+ Availability mSIPAppAvailable;
QCopListTransferItem* mNameEmailUidListFromKAPITransfer;
QCopListTransferItem* mFindByEmailFromKAPITransfer;
QCopTransferItem* mDisplayDetails;
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;