kontact Library API Documentation

knode_plugin.cpp

00001 /* 00002 This file is part of Kontact. 00003 Copyright (c) 2003 Zack Rusin 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 "knode_plugin.h" 00025 00026 #include "core.h" 00027 00028 #include <kapplication.h> 00029 #include <kparts/componentfactory.h> 00030 #include <kgenericfactory.h> 00031 #include <kapplication.h> 00032 #include <kaction.h> 00033 #include <kiconloader.h> 00034 #include <kdebug.h> 00035 00036 #include <dcopclient.h> 00037 00038 #include <qwidget.h> 00039 00040 00041 typedef KGenericFactory<KNodePlugin, Kontact::Core> KNodePluginFactory; 00042 K_EXPORT_COMPONENT_FACTORY( libkontact_knodeplugin, 00043 KNodePluginFactory( "kontact_knodeplugin" ) ) 00044 00045 00046 KNodePlugin::KNodePlugin( Kontact::Core *core, const char *, const QStringList& ) 00047 : Kontact::Plugin( core, core, "knode" ), mStub(0) 00048 { 00049 setInstance( KNodePluginFactory::instance() ); 00050 00051 insertNewAction( new KAction( i18n( "New Article..." ), "mail_new", 00052 0, this, SLOT( slotPostArticle() ), actionCollection(), "post_article" ) ); 00053 00054 mUniqueAppWatcher = new Kontact::UniqueAppWatcher( 00055 new Kontact::UniqueAppHandlerFactory<KNodeUniqueAppHandler>(), this ); 00056 } 00057 00058 KNodePlugin::~KNodePlugin() 00059 { 00060 } 00061 00062 bool KNodePlugin::createDCOPInterface( const QString& /*serviceType*/ ) 00063 { 00064 return false; 00065 } 00066 00067 bool KNodePlugin::isRunningStandalone() 00068 { 00069 return mUniqueAppWatcher->isRunningStandalone(); 00070 } 00071 00072 QStringList KNodePlugin::invisibleToolbarActions() const 00073 { 00074 return QStringList( "article_postNew" ); 00075 } 00076 00077 void KNodePlugin::slotPostArticle() 00078 { 00079 (void) part(); // ensure part is loaded 00080 Q_ASSERT( mStub ); 00081 if ( mStub ) 00082 mStub->postArticle(); 00083 } 00084 00085 KParts::Part* KNodePlugin::createPart() 00086 { 00087 KParts::Part *part = loadPart(); 00088 if ( !part ) return 0; 00089 00090 mStub = new KNodeIface_stub( dcopClient(), "knode", "KNodeIface" ); 00091 return part; 00092 } 00093 00095 00096 #include "../../../knode/knode_options.h" 00097 void KNodeUniqueAppHandler::loadCommandLineOptions() 00098 { 00099 KCmdLineArgs::addCmdLineOptions( knode_options ); 00100 } 00101 00102 int KNodeUniqueAppHandler::newInstance() 00103 { 00104 // Ensure part is loaded 00105 (void)plugin()->part(); 00106 DCOPRef knode( "knode", "KNodeIface" ); 00107 DCOPReply reply = knode.call( "handleCommandLine" ); 00108 #if 0 00109 if ( reply.isValid() ) { 00110 bool handled = reply; 00111 kdDebug(5602) << k_funcinfo << "handled=" << handled << endl; 00112 if ( !handled ) 00113 #endif 00114 // in all cases, bring knode plugin to front 00115 return Kontact::UniqueAppHandler::newInstance(); 00116 #if 0 00117 } 00118 return 0; 00119 #endif 00120 } 00121 00122 #include "knode_plugin.moc"
KDE Logo
This file is part of the documentation for kontact Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Oct 21 19:47:00 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003