knode_plugin.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 #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" ), BarIcon( "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& )
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();
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
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() << k_funcinfo << "handled=" << handled << endl;
00112 if ( !handled )
00113 #endif
00114
00115 return Kontact::UniqueAppHandler::newInstance();
00116 #if 0
00117 }
00118 return 0;
00119 #endif
00120 }
00121
00122 #include "knode_plugin.moc"
This file is part of the documentation for kontact Library Version 3.2.2.