18 #include "kinstance.h"
23 #include "tdeconfig.h"
25 #include "kcharsets.h"
26 #include "kiconloader.h"
27 #ifdef __TDE_HAVE_TDEHWLIB
28 #include "tdehardwaredevices.h"
29 #include "tdenetworkconnections.h"
31 #include "tdeaboutdata.h"
32 #include "kstandarddirs.h"
34 #include "tdeglobal.h"
35 #include "kmimesourcefactory.h"
42 #include <tqptrdict.h>
43 static TQPtrList<TDEInstance> *allInstances = 0;
44 static TQPtrDict<TQCString> *allOldInstances = 0;
45 #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);
46 #define DEBUG_REMOVE do { allInstances->removeRef(this); } while (false);
47 #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);
51 #define DEBUG_CHECK_ALIVE
54 class TDEInstancePrivate
59 mimeSourceFactory = 0L;
62 ~TDEInstancePrivate ()
64 delete mimeSourceFactory;
77 #ifdef __TDE_HAVE_TDEHWLIB
78 _hardwaredevices (0L),
81 _name( name ), _aboutData( new
TDEAboutData( name,
"", 0 ) ), m_configReadOnly(false)
84 Q_ASSERT(!name.isEmpty());
85 if (!TDEGlobal::_instance)
87 TDEGlobal::_instance =
this;
91 d =
new TDEInstancePrivate ();
92 d->ownAboutdata =
true;
99 #ifdef __TDE_HAVE_TDEHWLIB
100 _hardwaredevices (0L),
101 _networkmanager (0L),
103 _name( aboutData->appName() ), _aboutData( aboutData ), m_configReadOnly(false)
106 Q_ASSERT(!_name.isEmpty());
108 if (!TDEGlobal::_instance)
110 TDEGlobal::_instance =
this;
114 d =
new TDEInstancePrivate ();
115 d->ownAboutdata =
false;
119 : _dirs ( src->_dirs ),
120 _config ( src->_config ),
121 _iconLoader ( src->_iconLoader ),
122 #ifdef __TDE_HAVE_TDEHWLIB
123 _hardwaredevices ( src->_hardwaredevices ),
124 _networkmanager ( src->_networkmanager ),
126 _name( src->_name ), _aboutData( src->_aboutData ), m_configReadOnly(false)
129 Q_ASSERT(!_name.isEmpty());
131 if (!TDEGlobal::_instance || TDEGlobal::_instance == src )
133 TDEGlobal::_instance =
this;
137 d =
new TDEInstancePrivate ();
138 d->ownAboutdata = src->d->ownAboutdata;
139 d->sharedConfig = src->d->sharedConfig;
143 src->_iconLoader = 0L;
144 #ifdef __TDE_HAVE_TDEHWLIB
145 src->_hardwaredevices = 0L;
146 src->_networkmanager = 0L;
148 src->_aboutData = 0L;
166 #ifdef __TDE_HAVE_TDEHWLIB
167 delete _hardwaredevices;
168 _hardwaredevices = 0;
170 delete _networkmanager;
179 if (TDEGlobal::_instance ==
this)
180 TDEGlobal::_instance = 0;
181 if (TDEGlobal::activeInstance() ==
this)
202 extern bool kde_kiosk_exception;
203 extern bool kde_kiosk_admin;
207 m_configReadOnly = ro;
214 if ( !d->configName.isEmpty() )
219 d->sharedConfig->setGroup(
"KDE Action Restrictions" );
220 TQString kioskException = d->sharedConfig->readEntry(
"kiosk_exception");
221 if (d->sharedConfig->readBoolEntry(
"custom_config",
true))
223 d->sharedConfig->setGroup(TQString::null);
232 if ( d->sharedConfig == 0 )
234 if ( !_name.isEmpty() ) {
243 if (kde_kiosk_admin && !kde_kiosk_exception && !TQCString(getenv(
"TDE_KIOSK_NO_RESTRICTIONS")).isEmpty())
245 kde_kiosk_exception =
true;
250 _config = d->sharedConfig;
265 return d->sharedConfig;
271 d->configName = configName;
277 if( _iconLoader == 0 ) {
285 #ifdef __TDE_HAVE_TDEHWLIB
286 TDEHardwareDevices *TDEInstance::hardwareDevices()
const
289 if( _hardwaredevices == 0 ) {
290 _hardwaredevices =
new TDEHardwareDevices( );
293 return _hardwaredevices;
296 TDEGlobalNetworkManager *TDEInstance::networkManager()
const
299 if( _networkmanager == 0 ) {
300 _networkmanager =
new TDEGlobalNetworkManager( );
303 return _networkmanager;
329 if (!d->mimeSourceFactory)
332 d->mimeSourceFactory->setInstance(const_cast<TDEInstance *>(
this));
335 return d->mimeSourceFactory;
338 void TDEInstance::virtual_hook(
int,
void* )
virtual void reparseConfiguration()
Clears all internal data structures and then reread configuration information from disk...
Access KDE Configuration entries.
void enableDelayedIconSetLoading(bool enable)
Enables on-demand icon loading for QIconSets using TQIconFactory.
static TDESharedConfig::Ptr openConfig(const TQString &fileName, bool readOnly=false, bool bUseKDEGlobals=true)
Returns a ref-counted pointer to a shared read-write config object.
TDEIconLoader * iconLoader() const
Returns an iconloader object.
TDEStandardDirs * dirs() const
Returns the application standard dirs object.
This class is used to store information about a program.
const TDEAboutData * aboutData() const
Returns the about data of this instance Warning, can be 0L.
Site-independent access to standard KDE directories.
void reconfigure(const TQString &_appname, TDEStandardDirs *_dirs)
Called by TDEInstance::newIconLoader to reconfigure the icon loader.
void newIconLoader() const
Re-allocate the global iconloader.
KMimeSourceFactory * mimeSourceFactory() const
Returns the KMimeSourceFactory of the instance.
static void reconfigure()
Reconfigure the theme.
TQCString instanceName() const
Returns the name of the instance.
void setConfigReadOnly(bool ro)
Set a read-only flag on the configuration files This must be called before config() or dirs() to have...
TDEConfig * config() const
Returns the general config object ("appnamerc").
bool addCustomized(TDEConfig *config)
Reads customized entries out of the given config object and add them via addResourceDirs().
TDEConfig variant using shared memory.
void setConfigName(const TQString &name)
Set name of default config file.
TDESharedConfig * sharedConfig() const
Returns the general config object ("appnamerc").
An extension to TQMimeSourceFactory that uses TDEIconLoader to find images.
Can be used to control the lifetime of an object that has derived TDEShared.
Access to KDE global objects for use in shared libraries.
static void setActiveInstance(TDEInstance *d)
The instance currently active (useful in a multi-instance application, such as a KParts application)...
virtual ~TDEInstance()
Destructor.
TDEInstance(const TQCString &instanceName)
Constructor.