karm_plugin.cpp
1 /*
2  This file is part of Kontact.
3 
4  Copyright (c) 2004 Tobias Koenig <tokoe@kde.org>
5  adapted for karm 2005 by Thorsten Staerk <kde@staerk.de>
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 
21  As a special exception, permission is given to link this program
22  with any edition of TQt, and distribute the resulting executable,
23  without including the source code for TQt in the source distribution.
24 */
25 
26 #include <kgenericfactory.h>
27 #include <tdeparts/componentfactory.h>
28 
29 #include "core.h"
30 #include "plugin.h"
31 
32 #include "karm_plugin.h"
33 #include "karmdcopiface_stub.h"
34 
35 typedef KGenericFactory<KarmPlugin, Kontact::Core> KarmPluginFactory;
36 K_EXPORT_COMPONENT_FACTORY( libkontact_karm,
37  KarmPluginFactory( "kontact_karm" ) )
38 
39 KarmPlugin::KarmPlugin( Kontact::Core *core, const char *, const TQStringList& )
40  : Kontact::Plugin( core, core, "KArm" )
41 {
42  setInstance( KarmPluginFactory::instance() );
43  (void)dcopClient();
44  insertNewAction( new TDEAction( i18n( "New Task" ), "karm",
45  CTRL+SHIFT+Key_W, this, TQ_SLOT( newTask() ), actionCollection(),
46  "new_task" ) );
47 }
48 
49 KarmPlugin::~KarmPlugin()
50 {
51 }
52 
53 KParts::ReadOnlyPart* KarmPlugin::createPart()
54 {
55  KParts::ReadOnlyPart * part = loadPart();
56  if ( !part ) return 0;
57 
58  // this calls a DCOP interface from karm via the lib KarmDCOPIface_stub that is generated automatically
59  mStub = new KarmDCOPIface_stub( dcopClient(), "KArm",
60  "KarmDCOPIface" );
61 
62  return part;
63 }
64 
65 void KarmPlugin::newTask()
66 {
67  kdDebug() << "Entering newTask" << endl;
68  mStub->addTask("New Task");
69 }
70 
71 #include "karm_plugin.moc"