1 /***************************************************************************
2 * Copyright (C) 2006 by Petri Damsten *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include <kgenericfactory.h>
22 #include <kparts/componentfactory.h>
23 #include <kontact/core.h>
25 #include <kcmdlineargs.h>
27 #include "basketdcopiface_stub.h"
28 #include "basket_plugin.h"
29 #include "basket_options.h"
30 #include "basket_part.h"
32 typedef KGenericFactory
<BasketPlugin
, Kontact::Core
> BasketPluginFactory
;
33 K_EXPORT_COMPONENT_FACTORY( libkontact_basket
,
34 BasketPluginFactory( "kontact_basketplugin" ) )
36 BasketPlugin::BasketPlugin( Kontact::Core
*core
, const char *, const QStringList
& )
37 : Kontact::Plugin( core
, core
, "basket" )
39 setInstance( BasketPluginFactory::instance() );
40 insertNewAction(new KAction( i18n("&New Basket..."), "basket", CTRL
+SHIFT
+Key_B
,
41 this, SLOT(newBasket()), actionCollection(), "basket_new" ));
43 m_uniqueAppWatcher
= new Kontact::UniqueAppWatcher(
44 new Kontact::UniqueAppHandlerFactory
<BasketUniqueAppHandler
>(), this);
47 BasketPlugin::~BasketPlugin()
51 KParts::ReadOnlyPart
* BasketPlugin::createPart()
53 BasketPart
* part
= static_cast<BasketPart
*>(loadPart());
57 m_stub
= new BasketDcopInterface_stub(dcopClient(), "basket", "BasketIface");
58 connect(part
, SIGNAL(showPart()), this, SLOT(showPart()));
62 void BasketPlugin::newBasket()
64 (void) part(); // ensure part is loaded
67 kdDebug() << k_funcinfo
<< endl
;
72 void BasketPlugin::showPart()
74 core()->selectPlugin(this);
78 bool BasketPlugin::createDCOPInterface( const QString
& serviceType
)
80 kdDebug() << k_funcinfo
<< serviceType
<< endl
;
84 bool BasketPlugin::isRunningStandalone()
86 return m_uniqueAppWatcher
->isRunningStandalone();
89 void BasketUniqueAppHandler::loadCommandLineOptions()
91 KCmdLineArgs::addCmdLineOptions(basket_options
);
94 int BasketUniqueAppHandler::newInstance()
96 (void)plugin()->part();
97 DCOPRef
kmail("basket", "BasketIface");
98 DCOPReply reply
= kmail
.call("handleCommandLine", false);
99 if (reply
.isValid()) {
100 bool handled
= reply
;
102 return Kontact::UniqueAppHandler::newInstance();
107 #include "basket_plugin.moc"