korganizer Library API Documentation

urihandler.cpp

00001 /* 00002 This file is part of KOrganizer. 00003 00004 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of Qt, and distribute the resulting executable, 00022 without including the source code for Qt in the source distribution. 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 //KAddressbook is already running, so just DCOP to it to bring up the contact editor 00069 //client->send("kaddressbook","KAddressBookIface", 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 KaddressBook is not already running. Pass it the UID of the contact via the command line while starting it - its neater. 00078 We start it without its main interface 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 { // no special URI, let KDE handle it 00089 KRun *run = new KRun(KURL( uri )); 00090 } 00091 #endif 00092 00093 return false; 00094 }
KDE Logo
This file is part of the documentation for korganizer Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:14 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003