kontact Library API Documentation

kmail_plugin.cpp

00001 /* 00002 This file is part of Kontact. 00003 Copyright (c) 2003 Kontact Developer 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 00022 */ 00023 00024 #include <qwidget.h> 00025 00026 #include <kaction.h> 00027 #include <kapplication.h> 00028 #include <kdebug.h> 00029 #include <kgenericfactory.h> 00030 #include <kiconloader.h> 00031 #include <kparts/componentfactory.h> 00032 #include <kstandarddirs.h> 00033 #include <dcopclient.h> 00034 00035 #include "core.h" 00036 #include "summarywidget.h" 00037 00038 #include "kmail_plugin.h" 00039 00040 typedef KGenericFactory<KMailPlugin, Kontact::Core> KMailPluginFactory; 00041 K_EXPORT_COMPONENT_FACTORY( libkontact_kmailplugin, 00042 KMailPluginFactory( "kontact_kmailplugin" ) ) 00043 00044 KMailPlugin::KMailPlugin(Kontact::Core *core, const char *, const QStringList& ) 00045 : Kontact::Plugin( core, core, "kmail" ), 00046 mStub( 0 ) 00047 { 00048 setInstance( KMailPluginFactory::instance() ); 00049 00050 insertNewAction( new KAction( i18n( "New Mail" ), BarIcon( "mail_new" ), 00051 0, this, SLOT( slotNewMail() ), actionCollection(), 00052 "new_mail" ) ); 00053 00054 mUniqueAppWatcher = new Kontact::UniqueAppWatcher( 00055 new Kontact::UniqueAppHandlerFactory<KMailUniqueAppHandler>(), this ); 00056 } 00057 00058 00059 void KMailPlugin::slotNewMail() 00060 { 00061 (void) part(); // ensure part is loaded 00062 Q_ASSERT( mStub ); 00063 if ( mStub ) 00064 mStub->openComposer( "", "", "", "", "", false, KURL() ); 00065 } 00066 00067 KMailPlugin::~KMailPlugin() 00068 { 00069 } 00070 00071 bool KMailPlugin::createDCOPInterface( const QString& serviceType ) 00072 { 00073 if ( serviceType == "DCOP/ResourceBackend/IMAP" ) { 00074 if ( part() ) 00075 return true; 00076 } 00077 00078 return false; 00079 } 00080 00081 QString KMailPlugin::tipFile() const 00082 { 00083 QString file = ::locate("data", "kmail/tips"); 00084 return file; 00085 } 00086 00087 KParts::Part* KMailPlugin::createPart() 00088 { 00089 KParts::Part *part = loadPart(); 00090 if ( !part ) return 0; 00091 00092 mStub = new KMailIface_stub( dcopClient(), "kmail", "KMailIface" ); 00093 return part; 00094 } 00095 00096 QStringList KMailPlugin::invisibleToolbarActions() const 00097 { 00098 return QStringList( "new_message" ); 00099 } 00100 00101 bool KMailPlugin::isRunningStandalone() 00102 { 00103 return mUniqueAppWatcher->isRunningStandalone(); 00104 } 00105 00106 Kontact::Summary *KMailPlugin::createSummaryWidget( QWidget *parent ) 00107 { 00108 return new SummaryWidget( this, parent ); 00109 } 00110 00112 00113 #include "../../../kmail/kmail_options.h" 00114 void KMailUniqueAppHandler::loadCommandLineOptions() 00115 { 00116 KCmdLineArgs::addCmdLineOptions( kmail_options ); 00117 } 00118 00119 int KMailUniqueAppHandler::newInstance() 00120 { 00121 // Ensure part is loaded 00122 (void)plugin()->part(); 00123 DCOPRef kmail( "kmail", "KMailIface" ); 00124 DCOPReply reply = kmail.call( "handleCommandLine", false ); 00125 if ( reply.isValid() ) { 00126 bool handled = reply; 00127 //kdDebug() << k_funcinfo << "handled=" << handled << endl; 00128 if ( !handled ) // no args -> simply bring kmail plugin to front 00129 return Kontact::UniqueAppHandler::newInstance(); 00130 } 00131 return 0; 00132 } 00133 00134 #include "kmail_plugin.moc"
KDE Logo
This file is part of the documentation for kontact Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:58:15 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003