|
|
@ -45,7 +45,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <tdeconfig.h>
|
|
|
|
#include <tdeconfig.h>
|
|
|
|
#include "kdebug.h"
|
|
|
|
#include "kdebug.h"
|
|
|
|
#include "kuniqueapplication.h"
|
|
|
|
#include "tdeuniqueapplication.h"
|
|
|
|
|
|
|
|
|
|
|
|
#if defined TQ_WS_X11
|
|
|
|
#if defined TQ_WS_X11
|
|
|
|
#include <netwm.h>
|
|
|
|
#include <netwm.h>
|
|
|
@ -59,12 +59,12 @@
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
bool KUniqueApplication::s_nofork = false;
|
|
|
|
bool TDEUniqueApplication::s_nofork = false;
|
|
|
|
bool KUniqueApplication::s_multipleInstances = false;
|
|
|
|
bool TDEUniqueApplication::s_multipleInstances = false;
|
|
|
|
bool KUniqueApplication::s_uniqueTestDone = false;
|
|
|
|
bool TDEUniqueApplication::s_uniqueTestDone = false;
|
|
|
|
bool KUniqueApplication::s_handleAutoStarted = false;
|
|
|
|
bool TDEUniqueApplication::s_handleAutoStarted = false;
|
|
|
|
|
|
|
|
|
|
|
|
static TDECmdLineOptions kunique_options[] =
|
|
|
|
static TDECmdLineOptions tdeunique_options[] =
|
|
|
|
{
|
|
|
|
{
|
|
|
|
{ "nofork", "Don't run in the background.", 0 },
|
|
|
|
{ "nofork", "Don't run in the background.", 0 },
|
|
|
|
TDECmdLineLastOption
|
|
|
|
TDECmdLineLastOption
|
|
|
@ -76,7 +76,7 @@ struct DCOPRequest {
|
|
|
|
DCOPClientTransaction *transaction;
|
|
|
|
DCOPClientTransaction *transaction;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class KUniqueApplicationPrivate {
|
|
|
|
class TDEUniqueApplicationPrivate {
|
|
|
|
public:
|
|
|
|
public:
|
|
|
|
TQPtrList <DCOPRequest> requestList;
|
|
|
|
TQPtrList <DCOPRequest> requestList;
|
|
|
|
bool processingRequest;
|
|
|
|
bool processingRequest;
|
|
|
@ -84,13 +84,13 @@ public:
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KUniqueApplication::addCmdLineOptions()
|
|
|
|
TDEUniqueApplication::addCmdLineOptions()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TDECmdLineArgs::addCmdLineOptions(kunique_options, 0, "kuniqueapp", "tde" );
|
|
|
|
TDECmdLineArgs::addCmdLineOptions(tdeunique_options, 0, "tdeuniqueapp", "tde" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
bool
|
|
|
|
KUniqueApplication::start()
|
|
|
|
TDEUniqueApplication::start()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if( s_uniqueTestDone )
|
|
|
|
if( s_uniqueTestDone )
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -99,7 +99,7 @@ KUniqueApplication::start()
|
|
|
|
#ifdef TQ_WS_WIN
|
|
|
|
#ifdef TQ_WS_WIN
|
|
|
|
s_nofork = true;
|
|
|
|
s_nofork = true;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs("kuniqueapp");
|
|
|
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs("tdeuniqueapp");
|
|
|
|
s_nofork = !args->isSet("fork");
|
|
|
|
s_nofork = !args->isSet("fork");
|
|
|
|
delete args;
|
|
|
|
delete args;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
@ -122,7 +122,7 @@ KUniqueApplication::start()
|
|
|
|
if(dcopClient()->registerAs(appName, false).isEmpty()) {
|
|
|
|
if(dcopClient()->registerAs(appName, false).isEmpty()) {
|
|
|
|
startKdeinit();
|
|
|
|
startKdeinit();
|
|
|
|
if(dcopClient()->registerAs(appName, false).isEmpty()) {
|
|
|
|
if(dcopClient()->registerAs(appName, false).isEmpty()) {
|
|
|
|
kdError() << "KUniqueApplication: Can't setup DCOP communication." << endl;
|
|
|
|
kdError() << "TDEUniqueApplication: Can't setup DCOP communication." << endl;
|
|
|
|
::exit(255);
|
|
|
|
::exit(255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -136,13 +136,13 @@ KUniqueApplication::start()
|
|
|
|
signed char result;
|
|
|
|
signed char result;
|
|
|
|
if (0 > pipe(fd))
|
|
|
|
if (0 > pipe(fd))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdError() << "KUniqueApplication: pipe() failed!" << endl;
|
|
|
|
kdError() << "TDEUniqueApplication: pipe() failed!" << endl;
|
|
|
|
::exit(255);
|
|
|
|
::exit(255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int fork_result = fork();
|
|
|
|
int fork_result = fork();
|
|
|
|
switch(fork_result) {
|
|
|
|
switch(fork_result) {
|
|
|
|
case -1:
|
|
|
|
case -1:
|
|
|
|
kdError() << "KUniqueApplication: fork() failed!" << endl;
|
|
|
|
kdError() << "TDEUniqueApplication: fork() failed!" << endl;
|
|
|
|
::exit(255);
|
|
|
|
::exit(255);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 0:
|
|
|
|
case 0:
|
|
|
@ -158,7 +158,7 @@ KUniqueApplication::start()
|
|
|
|
// Check DISPLAY
|
|
|
|
// Check DISPLAY
|
|
|
|
if (TQCString(getenv(DISPLAY)).isEmpty())
|
|
|
|
if (TQCString(getenv(DISPLAY)).isEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdError() << "KUniqueApplication: Can't determine DISPLAY. Aborting." << endl;
|
|
|
|
kdError() << "TDEUniqueApplication: Can't determine DISPLAY. Aborting." << endl;
|
|
|
|
result = -1; // Error
|
|
|
|
result = -1; // Error
|
|
|
|
::write(fd[1], &result, 1);
|
|
|
|
::write(fd[1], &result, 1);
|
|
|
|
::exit(255);
|
|
|
|
::exit(255);
|
|
|
@ -169,7 +169,7 @@ KUniqueApplication::start()
|
|
|
|
regName = dc->registerAs(appName, false);
|
|
|
|
regName = dc->registerAs(appName, false);
|
|
|
|
if (regName.isEmpty())
|
|
|
|
if (regName.isEmpty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdError() << "KUniqueApplication: Can't setup DCOP communication." << endl;
|
|
|
|
kdError() << "TDEUniqueApplication: Can't setup DCOP communication." << endl;
|
|
|
|
result = -1;
|
|
|
|
result = -1;
|
|
|
|
delete dc; // Clean up DCOP commmunication
|
|
|
|
delete dc; // Clean up DCOP commmunication
|
|
|
|
::write(fd[1], &result, 1);
|
|
|
|
::write(fd[1], &result, 1);
|
|
|
@ -246,12 +246,12 @@ KUniqueApplication::start()
|
|
|
|
if (n == 1) break;
|
|
|
|
if (n == 1) break;
|
|
|
|
if (n == 0)
|
|
|
|
if (n == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdError() << "KUniqueApplication: Pipe closed unexpectedly." << endl;
|
|
|
|
kdError() << "TDEUniqueApplication: Pipe closed unexpectedly." << endl;
|
|
|
|
::exit(255);
|
|
|
|
::exit(255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (errno != EINTR)
|
|
|
|
if (errno != EINTR)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdError() << "KUniqueApplication: Error reading from pipe." << endl;
|
|
|
|
kdError() << "TDEUniqueApplication: Error reading from pipe." << endl;
|
|
|
|
::exit(255);
|
|
|
|
::exit(255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -263,12 +263,12 @@ KUniqueApplication::start()
|
|
|
|
dc = new DCOPClient();
|
|
|
|
dc = new DCOPClient();
|
|
|
|
if (!dc->attach())
|
|
|
|
if (!dc->attach())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdError() << "KUniqueApplication: Parent process can't attach to DCOP." << endl;
|
|
|
|
kdError() << "TDEUniqueApplication: Parent process can't attach to DCOP." << endl;
|
|
|
|
delete dc; // Clean up DCOP commmunication
|
|
|
|
delete dc; // Clean up DCOP commmunication
|
|
|
|
::exit(255);
|
|
|
|
::exit(255);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!dc->isApplicationRegistered(appName)) {
|
|
|
|
if (!dc->isApplicationRegistered(appName)) {
|
|
|
|
kdError() << "KUniqueApplication: Registering failed!" << endl;
|
|
|
|
kdError() << "TDEUniqueApplication: Registering failed!" << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
TQCString new_asn_id;
|
|
|
|
TQCString new_asn_id;
|
|
|
@ -299,7 +299,7 @@ KUniqueApplication::start()
|
|
|
|
dc->setPriorityCall(false);
|
|
|
|
dc->setPriorityCall(false);
|
|
|
|
if (replyType != "int")
|
|
|
|
if (replyType != "int")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
kdError() << "KUniqueApplication: DCOP communication error!" << endl;
|
|
|
|
kdError() << "TDEUniqueApplication: DCOP communication error!" << endl;
|
|
|
|
delete dc; // Clean up DCOP commmunication
|
|
|
|
delete dc; // Clean up DCOP commmunication
|
|
|
|
::exit(255);
|
|
|
|
::exit(255);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -314,11 +314,11 @@ KUniqueApplication::start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KUniqueApplication::KUniqueApplication(bool allowStyles, bool GUIenabled, bool configUnique)
|
|
|
|
TDEUniqueApplication::TDEUniqueApplication(bool allowStyles, bool GUIenabled, bool configUnique)
|
|
|
|
: TDEApplication( allowStyles, GUIenabled, initHack( configUnique )),
|
|
|
|
: TDEApplication( allowStyles, GUIenabled, initHack( configUnique )),
|
|
|
|
DCOPObject(TDECmdLineArgs::about->appName())
|
|
|
|
DCOPObject(TDECmdLineArgs::about->appName())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d = new KUniqueApplicationPrivate;
|
|
|
|
d = new TDEUniqueApplicationPrivate;
|
|
|
|
d->processingRequest = false;
|
|
|
|
d->processingRequest = false;
|
|
|
|
d->firstInstance = true;
|
|
|
|
d->firstInstance = true;
|
|
|
|
|
|
|
|
|
|
|
@ -334,12 +334,12 @@ KUniqueApplication::KUniqueApplication(bool allowStyles, bool GUIenabled, bool c
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef TQ_WS_X11
|
|
|
|
#ifdef TQ_WS_X11
|
|
|
|
KUniqueApplication::KUniqueApplication(Display *display, TQt::HANDLE visual,
|
|
|
|
TDEUniqueApplication::TDEUniqueApplication(Display *display, TQt::HANDLE visual,
|
|
|
|
TQt::HANDLE colormap, bool allowStyles, bool configUnique)
|
|
|
|
TQt::HANDLE colormap, bool allowStyles, bool configUnique)
|
|
|
|
: TDEApplication( display, visual, colormap, allowStyles, initHack( configUnique )),
|
|
|
|
: TDEApplication( display, visual, colormap, allowStyles, initHack( configUnique )),
|
|
|
|
DCOPObject(TDECmdLineArgs::about->appName())
|
|
|
|
DCOPObject(TDECmdLineArgs::about->appName())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
d = new KUniqueApplicationPrivate;
|
|
|
|
d = new TDEUniqueApplicationPrivate;
|
|
|
|
d->processingRequest = false;
|
|
|
|
d->processingRequest = false;
|
|
|
|
d->firstInstance = true;
|
|
|
|
d->firstInstance = true;
|
|
|
|
|
|
|
|
|
|
|
@ -355,13 +355,13 @@ KUniqueApplication::KUniqueApplication(Display *display, TQt::HANDLE visual,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KUniqueApplication::~KUniqueApplication()
|
|
|
|
TDEUniqueApplication::~TDEUniqueApplication()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// this gets called before even entering TQApplication::TQApplication()
|
|
|
|
// this gets called before even entering TQApplication::TQApplication()
|
|
|
|
TDEInstance* KUniqueApplication::initHack( bool configUnique )
|
|
|
|
TDEInstance* TDEUniqueApplication::initHack( bool configUnique )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TDEInstance* inst = new TDEInstance( TDECmdLineArgs::about );
|
|
|
|
TDEInstance* inst = new TDEInstance( TDECmdLineArgs::about );
|
|
|
|
if (configUnique)
|
|
|
|
if (configUnique)
|
|
|
@ -375,7 +375,7 @@ TDEInstance* KUniqueApplication::initHack( bool configUnique )
|
|
|
|
return inst;
|
|
|
|
return inst;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KUniqueApplication::newInstanceNoFork()
|
|
|
|
void TDEUniqueApplication::newInstanceNoFork()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (dcopClient()->isSuspended())
|
|
|
|
if (dcopClient()->isSuspended())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -400,7 +400,7 @@ void KUniqueApplication::newInstanceNoFork()
|
|
|
|
// What to do with the return value ?
|
|
|
|
// What to do with the return value ?
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KUniqueApplication::process(const TQCString &fun, const TQByteArray &data,
|
|
|
|
bool TDEUniqueApplication::process(const TQCString &fun, const TQByteArray &data,
|
|
|
|
TQCString &replyType, TQByteArray &replyData)
|
|
|
|
TQCString &replyType, TQByteArray &replyData)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (fun == "newInstance()")
|
|
|
|
if (fun == "newInstance()")
|
|
|
@ -412,7 +412,7 @@ bool KUniqueApplication::process(const TQCString &fun, const TQByteArray &data,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KUniqueApplication::delayRequest(const TQCString &fun, const TQByteArray &data)
|
|
|
|
TDEUniqueApplication::delayRequest(const TQCString &fun, const TQByteArray &data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DCOPRequest *request = new DCOPRequest;
|
|
|
|
DCOPRequest *request = new DCOPRequest;
|
|
|
|
request->fun = fun;
|
|
|
|
request->fun = fun;
|
|
|
@ -426,7 +426,7 @@ KUniqueApplication::delayRequest(const TQCString &fun, const TQByteArray &data)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
KUniqueApplication::processDelayed()
|
|
|
|
TDEUniqueApplication::processDelayed()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (dcopClient()->isSuspended())
|
|
|
|
if (dcopClient()->isSuspended())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -468,12 +468,12 @@ KUniqueApplication::processDelayed()
|
|
|
|
d->processingRequest = false;
|
|
|
|
d->processingRequest = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool KUniqueApplication::restoringSession()
|
|
|
|
bool TDEUniqueApplication::restoringSession()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return d->firstInstance && isRestored();
|
|
|
|
return d->firstInstance && isRestored();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int KUniqueApplication::newInstance()
|
|
|
|
int TDEUniqueApplication::newInstance()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!d->firstInstance)
|
|
|
|
if (!d->firstInstance)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -493,13 +493,13 @@ int KUniqueApplication::newInstance()
|
|
|
|
return 0; // do nothing in default implementation
|
|
|
|
return 0; // do nothing in default implementation
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KUniqueApplication::setHandleAutoStarted()
|
|
|
|
void TDEUniqueApplication::setHandleAutoStarted()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
s_handleAutoStarted = false;
|
|
|
|
s_handleAutoStarted = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KUniqueApplication::virtual_hook( int id, void* data )
|
|
|
|
void TDEUniqueApplication::virtual_hook( int id, void* data )
|
|
|
|
{ TDEApplication::virtual_hook( id, data );
|
|
|
|
{ TDEApplication::virtual_hook( id, data );
|
|
|
|
DCOPObject::virtual_hook( id, data ); }
|
|
|
|
DCOPObject::virtual_hook( id, data ); }
|
|
|
|
|
|
|
|
|
|
|
|
#include "kuniqueapplication.moc"
|
|
|
|
#include "tdeuniqueapplication.moc"
|