• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kontact

knode_plugin.cpp

Go to the documentation of this file.
00001 /*
00002   This file is part of Kontact.
00003 
00004   Copyright (c) 2003 Zack Rusin <zack@kde.org>
00005 
00006   This program is free software; you can redistribute it and/or modify
00007   it under the terms of the GNU General Public License as published by
00008   the Free Software Foundation; either version 2 of the License, or
00009   (at your option) any later version.
00010 
00011   This program is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00014   GNU General Public License for more details.
00015 
00016   You should have received a copy of the GNU General Public License along
00017   with this program; if not, write to the Free Software Foundation, Inc.,
00018   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019 
00020   As a special exception, permission is given to link this program
00021   with any edition of Qt, and distribute the resulting executable,
00022   without including the source code for Qt in the source distribution.
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(); // ensure part is loaded
00078   Q_ASSERT( m_interface );
00079   if ( m_interface ) {
00080     m_interface->postArticle();
00081   }
00082 }
00083 
00084 QString KNodePlugin::tipFile() const
00085 {
00086   // TODO: tips file
00087   //QString file = KStandardDirs::locate("data", "knode/tips");
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   // Ensure part is loaded
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 ) { // no args -> simply bring knode plugin to front
00124       return Kontact::UniqueAppHandler::newInstance();
00125     }
00126   }
00127   return 0;
00128 }
00129 
00130 #include "knode_plugin.moc"

kontact

Skip menu "kontact"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal