kontact
knode_plugin.cpp
Go to the documentation of this file.00001
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 <knodeinterface.h>
00028 #include <kontactinterfaces/core.h>
00029
00030 #include <kactioncollection.h>
00031 #include <kaction.h>
00032 #include <kdebug.h>
00033 #include <kgenericfactory.h>
00034 #include <kicon.h>
00035 #include <kiconloader.h>
00036 #include <kparts/componentfactory.h>
00037
00038 EXPORT_KONTACT_PLUGIN( KNodePlugin, knode )
00039
00040 KNodePlugin::KNodePlugin( Kontact::Core *core, const QVariantList & )
00041 : Kontact::Plugin( core, core, "knode" ), m_interface( 0 )
00042 {
00043 setComponentData( KontactPluginFactory::componentData() );
00044
00045 KAction *action = new KAction( KIcon( "mail-message-new" ), i18n( "New Article..." ), this );
00046 actionCollection()->addAction( "post_article", action );
00047 action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_A ) );
00048 connect( action, SIGNAL(triggered(bool)), SLOT(slotPostArticle()) );
00049 insertNewAction( action );
00050
00051 mUniqueAppWatcher = new Kontact::UniqueAppWatcher(
00052 new Kontact::UniqueAppHandlerFactory<KNodeUniqueAppHandler>(), this );
00053 }
00054
00055 KNodePlugin::~KNodePlugin()
00056 {
00057 }
00058
00059 bool KNodePlugin::createDBUSInterface( const QString &serviceType )
00060 {
00061 Q_UNUSED( serviceType );
00062 return false;
00063 }
00064
00065 bool KNodePlugin::isRunningStandalone()
00066 {
00067 return mUniqueAppWatcher->isRunningStandalone();
00068 }
00069
00070 QStringList KNodePlugin::invisibleToolbarActions() const
00071 {
00072 return QStringList( "article_postNew" );
00073 }
00074
00075 void KNodePlugin::slotPostArticle()
00076 {
00077 (void) part();
00078 Q_ASSERT( m_interface );
00079 if ( m_interface ) {
00080 m_interface->postArticle();
00081 }
00082 }
00083
00084 QString KNodePlugin::tipFile() const
00085 {
00086
00087
00088 QString file;
00089 return file;
00090 }
00091
00092 KParts::ReadOnlyPart *KNodePlugin::createPart()
00093 {
00094 KParts::ReadOnlyPart *part = loadPart();
00095 if ( !part ) {
00096 return 0;
00097 }
00098
00099 m_interface = new OrgKdeKnodeInterface(
00100 "org.kde.knode", "/KNode", QDBusConnection::sessionBus() );
00101 return part;
00102 }
00103
00105
00106 #include "../../../knode/knode_options.h"
00107 void KNodeUniqueAppHandler::loadCommandLineOptions()
00108 {
00109 KCmdLineArgs::addCmdLineOptions( knode_options() );
00110 }
00111
00112 int KNodeUniqueAppHandler::newInstance()
00113 {
00114 kDebug();
00115
00116 (void)plugin()->part();
00117 org::kde::knode knode( "org.kde.knode", "/KNode", QDBusConnection::sessionBus() );
00118 QDBusReply<bool> reply = knode.handleCommandLine();
00119
00120 if ( reply.isValid() ) {
00121 bool handled = reply;
00122 kDebug() << "handled=" << handled;
00123 if ( !handled ) {
00124 return Kontact::UniqueAppHandler::newInstance();
00125 }
00126 }
00127 return 0;
00128 }
00129
00130 #include "knode_plugin.moc"