urihandler.cpp
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 <kprocess.h>
00035 #include <kdebug.h>
00036
00037 bool UriHandler::process( const QString &uri )
00038 {
00039 kdDebug(5850) << "UriHandler::process(): " << uri << endl;
00040
00041 #ifndef KORG_NODCOP
00042 if ( uri.startsWith( "kmail:" ) ) {
00043 int pos = uri.find( "/" );
00044 if ( pos > 5 ) {
00045 QString serialNumberStr = uri.mid( 6, pos - 6 );
00046 QString messageId = uri.mid( pos + 1 );
00047 kdDebug() << "SERIALNUMBERSTR: " << serialNumberStr << " MESSAGEID: "
00048 << messageId << endl;
00049 Q_UINT32 serialNumber = serialNumberStr.toUInt();
00050 kdDebug() << "SERIALNUMBER: " << serialNumber << endl;
00051 KMailIface_stub kmailIface( "kmail", "KMailIface" );
00052 kmailIface.showMail( serialNumber, messageId );
00053 return true;
00054 }
00055 } else if ( uri.startsWith( "mailto:" ) ) {
00056 KApplication::kApplication()->invokeMailer( uri.mid(7), QString::null );
00057 return true;
00058 } else if ( uri.startsWith( "uid:" ) ) {
00059 DCOPClient *client = KApplication::kApplication()->dcopClient();
00060 const QByteArray noParamData;
00061 const QByteArray paramData;
00062 QByteArray replyData;
00063 QCString replyTypeStr;
00064 bool foundAbbrowser = client->call( "kaddressbook", "KAddressBookIface",
00065 "interfaces()", noParamData,
00066 replyTypeStr, replyData );
00067 if ( foundAbbrowser ) {
00068
00069
00070 QDataStream arg( paramData, IO_WriteOnly );
00071 arg << uri.mid( 6 );
00072 client->send( "kaddressbook", "KAddressBookIface",
00073 "showContactEditor( QString )", paramData );
00074 return true;
00075 } else {
00076
00077
00078
00079
00080 KIconLoader *iconLoader = new KIconLoader();
00081 QString iconPath = iconLoader->iconPath( "go", KIcon::Small );
00082 QString tmpStr = "kaddressbook --editor-only --uid ";
00083 tmpStr += KProcess::quote( uri.mid( 6 ) );
00084 KRun::runCommand( tmpStr, "KAddressBook", iconPath );
00085 return true;
00086 }
00087 }
00088 else {
00089 KRun *run = new KRun(KURL( uri ));
00090 }
00091 #endif
00092
00093 return false;
00094 }
This file is part of the documentation for korganizer Library Version 3.2.2.