summaryrefslogtreecommitdiffstats
path: root/kontact/plugins/knode/knode_plugin.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kontact/plugins/knode/knode_plugin.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
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
Diffstat (limited to 'kontact/plugins/knode/knode_plugin.cpp')
-rw-r--r--kontact/plugins/knode/knode_plugin.cpp123
1 files changed, 123 insertions, 0 deletions
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 <zack@kde.org>
+
+ 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 <kapplication.h>
+#include <kparts/componentfactory.h>
+#include <kgenericfactory.h>
+#include <kapplication.h>
+#include <kaction.h>
+#include <kiconloader.h>
+#include <kdebug.h>
+
+#include <dcopclient.h>
+
+#include <qwidget.h>
+
+
+typedef KGenericFactory<KNodePlugin, Kontact::Core> 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<KNodeUniqueAppHandler>(), 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"