From 460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kontact/plugins/knode/knode_plugin.cpp | 123 +++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 kontact/plugins/knode/knode_plugin.cpp (limited to 'kontact/plugins/knode/knode_plugin.cpp') diff --git a/kontact/plugins/knode/knode_plugin.cpp b/kontact/plugins/knode/knode_plugin.cpp new file mode 100644 index 000000000..6ad7fedb1 --- /dev/null +++ b/kontact/plugins/knode/knode_plugin.cpp @@ -0,0 +1,123 @@ +/* + This file is part of Kontact. + + Copyright (c) 2003 Zack Rusin + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + + As a special exception, permission is given to link this program + with any edition of Qt, and distribute the resulting executable, + without including the source code for Qt in the source distribution. +*/ + +#include "knode_plugin.h" + +#include "core.h" + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + + +typedef KGenericFactory KNodePluginFactory; +K_EXPORT_COMPONENT_FACTORY( libkontact_knodeplugin, + KNodePluginFactory( "kontact_knodeplugin" ) ) + + +KNodePlugin::KNodePlugin( Kontact::Core *core, const char *, const QStringList& ) + : Kontact::Plugin( core, core, "knode" ), mStub(0) +{ + setInstance( KNodePluginFactory::instance() ); + + insertNewAction( new KAction( i18n( "New Article..." ), "mail_new", CTRL+SHIFT+Key_A, + this, SLOT( slotPostArticle() ), actionCollection(), "post_article" ) ); + + mUniqueAppWatcher = new Kontact::UniqueAppWatcher( + new Kontact::UniqueAppHandlerFactory(), this ); +} + +KNodePlugin::~KNodePlugin() +{ +} + +bool KNodePlugin::createDCOPInterface( const QString& /*serviceType*/ ) +{ + return false; +} + +bool KNodePlugin::isRunningStandalone() +{ + return mUniqueAppWatcher->isRunningStandalone(); +} + +QStringList KNodePlugin::invisibleToolbarActions() const +{ + return QStringList( "article_postNew" ); +} + +void KNodePlugin::slotPostArticle() +{ + (void) part(); // ensure part is loaded + Q_ASSERT( mStub ); + if ( mStub ) + mStub->postArticle(); +} + +KParts::ReadOnlyPart* KNodePlugin::createPart() +{ + KParts::ReadOnlyPart *part = loadPart(); + if ( !part ) return 0; + + mStub = new KNodeIface_stub( dcopClient(), "knode", "KNodeIface" ); + return part; +} + +//// + +#include "../../../knode/knode_options.h" +void KNodeUniqueAppHandler::loadCommandLineOptions() +{ + KCmdLineArgs::addCmdLineOptions( knode_options ); +} + +int KNodeUniqueAppHandler::newInstance() +{ + // Ensure part is loaded + (void)plugin()->part(); + DCOPRef knode( "knode", "KNodeIface" ); + DCOPReply reply = knode.call( "handleCommandLine" ); +#if 0 + if ( reply.isValid() ) { + bool handled = reply; + kdDebug(5602) << k_funcinfo << "handled=" << handled << endl; + if ( !handled ) +#endif + // in all cases, bring knode plugin to front + return Kontact::UniqueAppHandler::newInstance(); +#if 0 + } + return 0; +#endif +} + +#include "knode_plugin.moc" -- cgit v1.2.1