22 #include "uniqueapphandler.h"
23 #include <tdestartupinfo.h>
24 #include <tdeapplication.h>
25 #include <tdecmdlineargs.h>
28 #include <dcopclient.h>
30 #include <tdelocale.h>
31 #include <tdeuniqueapplication.h>
77 using namespace Kontact;
82 if ( kapp->mainWidget() ) {
83 kapp->mainWidget()->show();
84 KWin::forceActiveWindow( kapp->mainWidget()->winId() );
85 TDEStartupInfo::appStarted();
93 bool UniqueAppHandler::process(
const TQCString &fun,
const TQByteArray &data,
94 TQCString& replyType, TQByteArray &replyData )
96 if ( fun ==
"newInstance()" ) {
99 TDECmdLineArgs::reset();
103 TQDataStream ds( data, IO_ReadOnly );
104 TDECmdLineArgs::loadAppArgs( ds );
108 kapp->setStartupId( asn_id );
111 TQDataStream _replyStream( replyData, IO_WriteOnly );
117 TDECmdLineArgs::reset();
120 }
else if ( fun ==
"load()" ) {
122 (void)mPlugin->
part();
124 TQDataStream _replyStream( replyData, IO_WriteOnly );
125 _replyStream <<
true;
127 return DCOPObject::process( fun, data, replyType, replyData );
132 QCStringList UniqueAppHandler::interfaces()
134 QCStringList ifaces = DCOPObject::interfaces();
135 ifaces +=
"Kontact::UniqueAppHandler";
139 QCStringList UniqueAppHandler::functions()
141 QCStringList funcs = DCOPObject::functions();
142 funcs <<
"int newInstance()";
143 funcs <<
"bool load()";
148 : TQObject( plugin ), mFactory( factory ), mPlugin( plugin )
151 mRunningStandalone = kapp->dcopClient()->isApplicationRegistered( plugin->name() );
154 if ( mRunningStandalone && kapp->dcopClient()->findLocalClient( plugin->name() ) )
155 mRunningStandalone =
false;
157 if ( mRunningStandalone ) {
158 kapp->dcopClient()->setNotifications(
true );
159 connect( kapp->dcopClient(), TQ_SIGNAL( applicationRemoved(
const TQCString& ) ),
160 this, TQ_SLOT( unregisteredFromDCOP(
const TQCString& ) ) );
162 mFactory->createHandler( mPlugin );
166 UniqueAppWatcher::~UniqueAppWatcher()
168 if ( mRunningStandalone )
169 kapp->dcopClient()->setNotifications(
false );
174 void UniqueAppWatcher::unregisteredFromDCOP(
const TQCString& appId )
176 if ( appId == mPlugin->name() && mRunningStandalone ) {
177 disconnect( kapp->dcopClient(), TQ_SIGNAL( applicationRemoved(
const TQCString& ) ),
178 this, TQ_SLOT( unregisteredFromDCOP(
const TQCString& ) ) );
179 kdDebug(5601) << k_funcinfo << appId << endl;
180 mFactory->createHandler( mPlugin );
181 kapp->dcopClient()->setNotifications(
false );
182 mRunningStandalone =
false;
186 static TDECmdLineOptions options[] =
188 {
"module <module>", I18N_NOOP(
"Start with a specific Kontact module" ), 0 },
189 {
"iconify", I18N_NOOP(
"Start in iconified (minimized) mode" ), 0 },
190 {
"list", I18N_NOOP(
"List all possible modules and exit" ), 0 },
191 {
"listprofiles", I18N_NOOP(
"List all possible profiles and exit" ), 0 },
192 {
"profile <profile>", I18N_NOOP(
"Start with a specific Kontact profile" ), 0 },
198 TDECmdLineArgs::addCmdLineOptions( options );
199 TDEUniqueApplication::addCmdLineOptions();
200 TDEApplication::addCmdLineOptions();
203 #include "uniqueapphandler.moc"
virtual void selectPlugin(Kontact::Plugin *plugin)=0
Selects the given plugin.
Base class for all Plugins in Kontact.
KParts::ReadOnlyPart * part()
You can use this method if you need to access the current part.
Base class for UniqueAppHandler.
virtual void loadCommandLineOptions()=0
This must be reimplemented so that app-specific command line options can be parsed.
static void loadKontactCommandLineOptions()
Load the kontact command line options.
virtual int newInstance()
We can't use k_dcop and dcopidl here, because the data passed to newInstance can't be expressed in te...
UniqueAppWatcher(UniqueAppHandlerFactoryBase *factory, Plugin *plugin)
Create an instance of UniqueAppWatcher, which does everything necessary for the "unique application" ...