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

kontact

  • sources
  • kde-4.14
  • kdepim
  • kontact
  • plugins
  • knode
knode_plugin.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Kontact.
3 
4  Copyright (c) 2003 Zack Rusin <zack@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of Qt, and distribute the resulting executable,
22  without including the source code for Qt in the source distribution.
23 */
24 
25 #include "knode_plugin.h"
26 #include "knodeinterface.h"
27 #include "knode_options.h"
28 
29 #include <KontactInterface/Core>
30 
31 #include <KAction>
32 #include <KActionCollection>
33 #include <KIcon>
34 #include <KLocalizedString>
35 
36 EXPORT_KONTACT_PLUGIN( KNodePlugin, knode )
37 
38 KNodePlugin::KNodePlugin( KontactInterface::Core *core, const QVariantList & )
39  : KontactInterface::Plugin( core, core, "knode" ), m_interface( 0 )
40 {
41  setComponentData( KontactPluginFactory::componentData() );
42 
43  KAction *action =
44  new KAction( KIcon( QLatin1String("mail-message-new") ),
45  i18nc( "@action:inmenu", "New Article..." ), this );
46  actionCollection()->addAction( QLatin1String("post_article"), action );
47  action->setShortcut( QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_A ) );
48  action->setHelpText(
49  i18nc( "@info:status", "Create a new Usenet article" ) );
50  action->setWhatsThis(
51  i18nc( "@info:whatsthis",
52  "You will be presented with a dialog where you can create "
53  "a new article to post on Usenet." ) );
54  connect( action, SIGNAL(triggered(bool)), SLOT(slotPostArticle()) );
55  insertNewAction( action );
56 
57  mUniqueAppWatcher = new KontactInterface::UniqueAppWatcher(
58  new KontactInterface::UniqueAppHandlerFactory<KNodeUniqueAppHandler>(), this );
59 }
60 
61 KNodePlugin::~KNodePlugin()
62 {
63  delete m_interface;
64  m_interface = 0;
65 }
66 
67 bool KNodePlugin::createDBUSInterface( const QString &serviceType )
68 {
69  Q_UNUSED( serviceType );
70  return false;
71 }
72 
73 bool KNodePlugin::isRunningStandalone() const
74 {
75  return mUniqueAppWatcher->isRunningStandalone();
76 }
77 
78 QStringList KNodePlugin::invisibleToolbarActions() const
79 {
80  return QStringList() <<QLatin1String( "article_postNew" );
81 }
82 
83 void KNodePlugin::slotPostArticle()
84 {
85  (void) part(); // ensure part is loaded
86  Q_ASSERT( m_interface );
87  if ( m_interface ) {
88  m_interface->postArticle();
89  }
90 }
91 
92 QString KNodePlugin::tipFile() const
93 {
94  // TODO: tips file
95  //QString file = KStandardDirs::locate("data", "knode/tips");
96  QString file;
97  return file;
98 }
99 
100 KParts::ReadOnlyPart *KNodePlugin::createPart()
101 {
102  KParts::ReadOnlyPart *part = loadPart();
103  if ( !part ) {
104  return 0;
105  }
106 
107  m_interface = new OrgKdeKnodeInterface(
108  QLatin1String("org.kde.knode"), QLatin1String("/KNode"), QDBusConnection::sessionBus() );
109  return part;
110 }
111 
113 
114 void KNodeUniqueAppHandler::loadCommandLineOptions()
115 {
116  KCmdLineArgs::addCmdLineOptions( knode_options() );
117 }
118 
119 int KNodeUniqueAppHandler::newInstance()
120 {
121  // Ensure part is loaded
122  (void)plugin()->part();
123  org::kde::knode knode( QLatin1String("org.kde.knode"), QLatin1String("/KNode"), QDBusConnection::sessionBus() );
124  QDBusReply<bool> reply = knode.handleCommandLine();
125 
126  if ( reply.isValid() ) {
127  bool handled = reply;
128  if ( !handled ) { // no args -> simply bring knode plugin to front
129  return KontactInterface::UniqueAppHandler::newInstance();
130  }
131  }
132  return 0;
133 }
134 
QDBusReply
QDBusReply::isValid
bool isValid() const
QDBusConnection::sessionBus
QDBusConnection sessionBus()
KNodePlugin::~KNodePlugin
~KNodePlugin()
Definition: knode_plugin.cpp:61
KNodePlugin::invisibleToolbarActions
QStringList invisibleToolbarActions() const
Definition: knode_plugin.cpp:78
KNodePlugin::createDBUSInterface
bool createDBUSInterface(const QString &serviceType)
Definition: knode_plugin.cpp:67
KNodePlugin::slotPostArticle
void slotPostArticle()
Definition: knode_plugin.cpp:83
KNodePlugin::isRunningStandalone
bool isRunningStandalone() const
Definition: knode_plugin.cpp:73
KNodePlugin::createPart
virtual KParts::ReadOnlyPart * createPart()
Definition: knode_plugin.cpp:100
KNodePlugin
Definition: knode_plugin.h:45
knode_plugin.h
QString
QStringList
KNodeUniqueAppHandler::newInstance
virtual int newInstance()
Definition: knode_plugin.cpp:119
KNodeUniqueAppHandler::loadCommandLineOptions
virtual void loadCommandLineOptions()
Definition: knode_plugin.cpp:114
QLatin1String
QKeySequence
KNodePlugin::tipFile
QString tipFile() const
Definition: knode_plugin.cpp:92
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:11 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kontact

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

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal