18 #include "kinstance.h"
23 #include "tdeconfig.h"
25 #include "kcharsets.h"
26 #include "kiconloader.h"
27 #include "tdehardwaredevices.h"
28 #include "tdenetworkconnections.h"
29 #include "tdeaboutdata.h"
30 #include "kstandarddirs.h"
32 #include "tdeglobal.h"
33 #include "kmimesourcefactory.h"
40 #include <tqptrdict.h>
41 static TQPtrList<TDEInstance> *allInstances = 0;
42 static TQPtrDict<TQCString> *allOldInstances = 0;
43 #define DEBUG_ADD do { if (!allInstances) { allInstances = new TQPtrList<TDEInstance>(); allOldInstances = new TQPtrDict<TQCString>(); } allInstances->append(this); allOldInstances->insert( this, new TQCString( _name)); } while (false);
44 #define DEBUG_REMOVE do { allInstances->removeRef(this); } while (false);
45 #define DEBUG_CHECK_ALIVE do { if (!allInstances->contains((TDEInstance*)this)) { TQCString *old = allOldInstances->find((TDEInstance*)this); tqWarning("ACCESSING DELETED KINSTANCE! (%s)", old ? old->data() : "<unknown>"); assert(false); } } while (false);
49 #define DEBUG_CHECK_ALIVE
52 class TDEInstancePrivate
57 mimeSourceFactory = 0L;
60 ~TDEInstancePrivate ()
62 delete mimeSourceFactory;
75 _hardwaredevices (0L),
77 _name( name ), _aboutData( new
TDEAboutData( name,
"", 0 ) ), m_configReadOnly(false)
80 Q_ASSERT(!name.isEmpty());
81 if (!TDEGlobal::_instance)
83 TDEGlobal::_instance =
this;
87 d =
new TDEInstancePrivate ();
88 d->ownAboutdata =
true;
95 _hardwaredevices (0L),
97 _name( aboutData->appName() ), _aboutData( aboutData ), m_configReadOnly(false)
100 Q_ASSERT(!_name.isEmpty());
102 if (!TDEGlobal::_instance)
104 TDEGlobal::_instance =
this;
108 d =
new TDEInstancePrivate ();
109 d->ownAboutdata =
false;
113 : _dirs ( src->_dirs ),
114 _config ( src->_config ),
115 _iconLoader ( src->_iconLoader ),
116 _hardwaredevices ( src->_hardwaredevices ),
117 _networkmanager ( src->_networkmanager ),
118 _name( src->_name ), _aboutData( src->_aboutData ), m_configReadOnly(false)
121 Q_ASSERT(!_name.isEmpty());
123 if (!TDEGlobal::_instance || TDEGlobal::_instance == src )
125 TDEGlobal::_instance =
this;
129 d =
new TDEInstancePrivate ();
130 d->ownAboutdata = src->d->ownAboutdata;
131 d->sharedConfig = src->d->sharedConfig;
135 src->_iconLoader = 0L;
136 src->_hardwaredevices = 0L;
137 src->_networkmanager = 0L;
138 src->_aboutData = 0L;
156 delete _hardwaredevices;
157 _hardwaredevices = 0;
159 delete _networkmanager;
167 if (TDEGlobal::_instance ==
this)
168 TDEGlobal::_instance = 0;
169 if (TDEGlobal::activeInstance() ==
this)
190 extern bool kde_kiosk_exception;
191 extern bool kde_kiosk_admin;
195 m_configReadOnly = ro;
202 if ( !d->configName.isEmpty() )
207 d->sharedConfig->setGroup(
"KDE Action Restrictions" );
208 TQString kioskException = d->sharedConfig->readEntry(
"kiosk_exception");
209 if (d->sharedConfig->readBoolEntry(
"custom_config",
true))
211 d->sharedConfig->setGroup(TQString::null);
220 if ( d->sharedConfig == 0 )
222 if ( !_name.isEmpty() ) {
231 if (kde_kiosk_admin && !kde_kiosk_exception && !TQCString(getenv(
"TDE_KIOSK_NO_RESTRICTIONS")).isEmpty())
233 kde_kiosk_exception =
true;
238 _config = d->sharedConfig;
253 return d->sharedConfig;
259 d->configName = configName;
265 if( _iconLoader == 0 ) {
276 if( _hardwaredevices == 0 ) {
277 _hardwaredevices =
new TDEHardwareDevices( );
280 return _hardwaredevices;
286 if( _networkmanager == 0 ) {
287 _networkmanager =
new TDEGlobalNetworkManager( );
290 return _networkmanager;
315 if (!d->mimeSourceFactory)
318 d->mimeSourceFactory->setInstance(const_cast<TDEInstance *>(
this));
321 return d->mimeSourceFactory;
324 void TDEInstance::virtual_hook(
int,
void* )