00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#include "urihandler.h"
00026
00027
#ifndef KORG_NODCOP
00028
#include <dcopclient.h>
00029
#include "kmailIface_stub.h"
00030
#endif
00031
00032
#include <kiconloader.h>
00033
#include <krun.h>
00034
#include <kapplication.h>
00035
#include <kprocess.h>
00036
#include <kdebug.h>
00037
00038
bool UriHandler::process(
const QString &uri )
00039 {
00040 kdDebug(5850) <<
"UriHandler::process(): " << uri << endl;
00041
00042
#ifndef KORG_NODCOP
00043
if ( uri.startsWith(
"kmail:" ) ) {
00044
int pos = uri.find(
"/", 8 );
00045
if ( pos > 8 ) {
00046
QString messageId = uri.mid( 8, pos - 8 );
00047 Q_UINT32 serialNumber = messageId.toUInt();
00048 kdDebug() <<
"SERIALNUMBERSTR: " << serialNumber <<
" MESSAGEID: "
00049 << messageId << endl;
00050 KMailIface_stub kmailIface(
"kmail",
"KMailIface" );
00051 kmailIface.showMail( serialNumber, messageId );
00052
return true;
00053 }
00054 }
else if ( uri.startsWith(
"mailto:" ) ) {
00055 KApplication::kApplication()->invokeMailer( uri.mid(7), QString::null );
00056
return true;
00057 }
else if ( uri.startsWith(
"uid:" ) ) {
00058 DCOPClient *client = KApplication::kApplication()->dcopClient();
00059
const QByteArray noParamData;
00060
const QByteArray paramData;
00061
QByteArray replyData;
00062
QCString replyTypeStr;
00063
bool foundAbbrowser = client->call(
"kaddressbook",
"KAddressBookIface",
00064
"interfaces()", noParamData,
00065 replyTypeStr, replyData );
00066
if ( foundAbbrowser ) {
00067
00068
00069
QDataStream arg( paramData, IO_WriteOnly );
00070 arg << uri.mid( 6 );
00071
#if KDE_IS_VERSION( 3, 2, 90 )
00072
kapp->updateRemoteUserTimestamp(
"kaddressbook");
00073
#endif
00074
client->send(
"kaddressbook",
"KAddressBookIface",
00075
"showContactEditor( QString )", paramData );
00076
return true;
00077 }
else {
00078
00079
00080
00081
00082 KIconLoader *iconLoader =
new KIconLoader();
00083
QString iconPath = iconLoader->iconPath(
"go", KIcon::Small );
00084
QString tmpStr =
"kaddressbook --editor-only --uid ";
00085 tmpStr += KProcess::quote( uri.mid( 6 ) );
00086 KRun::runCommand( tmpStr,
"KAddressBook", iconPath );
00087
return true;
00088 }
00089 }
00090
else {
00091 KRun *run =
new KRun(KURL( uri ));
00092 }
00093
#endif
00094
00095
return false;
00096 }