18 #include "kinstance.h"
25 #include "kcharsets.h"
26 #include "kiconloader.h"
27 #include "kaboutdata.h"
28 #include "kstandarddirs.h"
31 #include "kmimesourcefactory.h"
38 #include <tqptrdict.h>
39 static TQPtrList<KInstance> *allInstances = 0;
40 static TQPtrDict<TQCString> *allOldInstances = 0;
41 #define DEBUG_ADD do { if (!allInstances) { allInstances = new TQPtrList<KInstance>(); allOldInstances = new TQPtrDict<TQCString>(); } allInstances->append(this); allOldInstances->insert( this, new TQCString( _name)); } while (false);
42 #define DEBUG_REMOVE do { allInstances->removeRef(this); } while (false);
43 #define DEBUG_CHECK_ALIVE do { if (!allInstances->contains((KInstance*)this)) { TQCString *old = allOldInstances->find((KInstance*)this); qWarning("ACCESSING DELETED KINSTANCE! (%s)", old ? old->data() : "<unknown>"); assert(false); } } while (false);
47 #define DEBUG_CHECK_ALIVE
50 class KInstancePrivate
55 mimeSourceFactory = 0L;
60 delete mimeSourceFactory;
73 _name( name ), _aboutData( new
KAboutData( name,
"", 0 ) )
76 Q_ASSERT(!name.isEmpty());
77 if (!KGlobal::_instance)
79 KGlobal::_instance =
this;
83 d =
new KInstancePrivate ();
84 d->ownAboutdata =
true;
91 _name( aboutData->appName() ), _aboutData( aboutData )
94 Q_ASSERT(!_name.isEmpty());
96 if (!KGlobal::_instance)
98 KGlobal::_instance =
this;
102 d =
new KInstancePrivate ();
103 d->ownAboutdata =
false;
107 : _dirs ( src->_dirs ),
108 _config ( src->_config ),
109 _iconLoader ( src->_iconLoader ),
110 _name( src->_name ), _aboutData( src->_aboutData )
113 Q_ASSERT(!_name.isEmpty());
115 if (!KGlobal::_instance || KGlobal::_instance == src )
117 KGlobal::_instance =
this;
121 d =
new KInstancePrivate ();
122 d->ownAboutdata = src->d->ownAboutdata;
123 d->sharedConfig = src->d->sharedConfig;
127 src->_iconLoader = 0L;
128 src->_aboutData = 0L;
151 if (KGlobal::_instance ==
this)
152 KGlobal::_instance = 0;
153 if (KGlobal::activeInstance() ==
this)
174 extern bool kde_kiosk_exception;
175 extern bool kde_kiosk_admin;
181 if ( !d->configName.isEmpty() )
186 d->sharedConfig->setGroup(
"KDE Action Restrictions" );
187 TQString kioskException = d->sharedConfig->readEntry(
"kiosk_exception");
188 if (d->sharedConfig->readBoolEntry(
"custom_config",
true))
190 d->sharedConfig->setGroup(TQString::null);
199 if ( d->sharedConfig == 0 )
201 if ( !_name.isEmpty() )
208 if (kde_kiosk_admin && !kde_kiosk_exception && !TQCString(getenv(
"KDE_KIOSK_NO_RESTRICTIONS")).isEmpty())
210 kde_kiosk_exception =
true;
215 _config = d->sharedConfig;
230 return d->sharedConfig;
236 d->configName = configName;
242 if( _iconLoader == 0 ) {
272 if (!d->mimeSourceFactory)
275 d->mimeSourceFactory->setInstance(const_cast<KInstance *>(
this));
278 return d->mimeSourceFactory;
281 void KInstance::virtual_hook(
int,
void* )