kontact
knode_plugin.cpp00001
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 "knode_plugin.h"
00026
00027 #include "core.h"
00028
00029 #include <kapplication.h>
00030 #include <kparts/componentfactory.h>
00031 #include <kgenericfactory.h>
00032 #include <kapplication.h>
00033 #include <kaction.h>
00034 #include <kiconloader.h>
00035 #include <kdebug.h>
00036
00037 #include <dcopclient.h>
00038
00039 #include <qwidget.h>
00040
00041
00042 typedef KGenericFactory<KNodePlugin, Kontact::Core> KNodePluginFactory;
00043 K_EXPORT_COMPONENT_FACTORY( libkontact_knodeplugin,
00044 KNodePluginFactory( "kontact_knodeplugin" ) )
00045
00046
00047 KNodePlugin::KNodePlugin( Kontact::Core *core, const char *, const QStringList& )
00048 : Kontact::Plugin( core, core, "knode" ), mStub(0)
00049 {
00050 setInstance( KNodePluginFactory::instance() );
00051
00052 insertNewAction( new KAction( i18n( "New Article..." ), "mail_new", CTRL+SHIFT+Key_A,
00053 this, SLOT( slotPostArticle() ), actionCollection(), "post_article" ) );
00054
00055 mUniqueAppWatcher = new Kontact::UniqueAppWatcher(
00056 new Kontact::UniqueAppHandlerFactory<KNodeUniqueAppHandler>(), this );
00057 }
00058
00059 KNodePlugin::~KNodePlugin()
00060 {
00061 }
00062
00063 bool KNodePlugin::createDCOPInterface( const QString& )
00064 {
00065 return false;
00066 }
00067
00068 bool KNodePlugin::isRunningStandalone()
00069 {
00070 return mUniqueAppWatcher->isRunningStandalone();
00071 }
00072
00073 QStringList KNodePlugin::invisibleToolbarActions() const
00074 {
00075 return QStringList( "article_postNew" );
00076 }
00077
00078 void KNodePlugin::slotPostArticle()
00079 {
00080 (void) part();
00081 Q_ASSERT( mStub );
00082 if ( mStub )
00083 mStub->postArticle();
00084 }
00085
00086 KParts::ReadOnlyPart* KNodePlugin::createPart()
00087 {
00088 KParts::ReadOnlyPart *part = loadPart();
00089 if ( !part ) return 0;
00090
00091 mStub = new KNodeIface_stub( dcopClient(), "knode", "KNodeIface" );
00092 return part;
00093 }
00094
00096
00097 #include "../../../knode/knode_options.h"
00098 void KNodeUniqueAppHandler::loadCommandLineOptions()
00099 {
00100 KCmdLineArgs::addCmdLineOptions( knode_options );
00101 }
00102
00103 int KNodeUniqueAppHandler::newInstance()
00104 {
00105
00106 (void)plugin()->part();
00107 DCOPRef knode( "knode", "KNodeIface" );
00108 DCOPReply reply = knode.call( "handleCommandLine" );
00109 #if 0
00110 if ( reply.isValid() ) {
00111 bool handled = reply;
00112 kdDebug(5602) << k_funcinfo << "handled=" << handled << endl;
00113 if ( !handled )
00114 #endif
00115
00116 return Kontact::UniqueAppHandler::newInstance();
00117 #if 0
00118 }
00119 return 0;
00120 #endif
00121 }
00122
00123 #include "knode_plugin.moc"
|