Ran qt3to4
[basket4.git] / kontact_plugin / basket_plugin.cpp
blob6f77ed372d950a4dd4b024c849d14ccb5de44669
1 /***************************************************************************
2 * Copyright (C) 2006 by Petri Damsten *
3 * damu@iki.fi *
4 * *
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. *
9 * *
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. *
14 * *
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>
24 #include <klocale.h>
25 #include <kcmdlineargs.h>
26 #include <dcopref.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());
54 if(!part)
55 return 0;
57 m_stub = new BasketDcopInterface_stub(dcopClient(), "basket", "BasketIface");
58 connect(part, SIGNAL(showPart()), this, SLOT(showPart()));
59 return part;
62 void BasketPlugin::newBasket()
64 (void) part(); // ensure part is loaded
65 Q_ASSERT(m_stub);
66 if (m_stub) {
67 kdDebug() << k_funcinfo << endl;
68 m_stub->newBasket();
72 void BasketPlugin::showPart()
74 core()->selectPlugin(this);
77 #if 0
78 bool BasketPlugin::createDCOPInterface( const QString& serviceType )
80 kdDebug() << k_funcinfo << serviceType << endl;
81 return false;
83 #endif
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;
101 if ( !handled )
102 return Kontact::UniqueAppHandler::newInstance();
104 return 0;
107 #include "basket_plugin.moc"